[media] cx23885: add DVBSky S950C dvb-s/s2 ci PCIe card support(no RC)
authornibble.max <nibble.max@gmail.com>
Thu, 23 Oct 2014 10:01:44 +0000 (07:01 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 3 Nov 2014 13:51:28 +0000 (11:51 -0200)
DVBSky s950ci dvb-s/s2 ci PCIe card:
1>dvb frontend: M88TS2022(tuner),M88DS3103(demod)
2>ci controller: CIMAX SP2 or its clone.
3>PCIe bridge: CX23885

The patchs are based on the following patchs.
Olli Salonen submit:
https://patchwork.linuxtv.org/patch/26180/
https://patchwork.linuxtv.org/patch/26183/
https://patchwork.linuxtv.org/patch/26324/
Nibble Max submit:
https://patchwork.linuxtv.org/patch/26207/

Signed-off-by: Nibble Max <nibble.max@gmail.com>
Reviewed-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/pci/cx23885/cx23885-cards.c
drivers/media/pci/cx23885/cx23885-dvb.c
drivers/media/pci/cx23885/cx23885.h

index c4a69e404c3b837969b3857be23da02e2235e4a3..ac34c27c8205ca86a6e6585b14b505a87ad0cf13 100644 (file)
@@ -684,6 +684,10 @@ struct cx23885_board cx23885_boards[] = {
                .name           = "DVBSky T980C",
                .portb          = CX23885_MPEG_DVB,
        },
+       [CX23885_BOARD_DVBSKY_S950C] = {
+               .name           = "DVBSky S950C",
+               .portb          = CX23885_MPEG_DVB,
+       },
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -947,6 +951,10 @@ struct cx23885_subid cx23885_subids[] = {
                .subvendor = 0x4254,
                .subdevice = 0x980c,
                .card      = CX23885_BOARD_DVBSKY_T980C,
+       }, {
+               .subvendor = 0x4254,
+               .subdevice = 0x950c,
+               .card      = CX23885_BOARD_DVBSKY_S950C,
        },
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1550,6 +1558,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
                cx23885_gpio_set(dev, GPIO_2 | GPIO_11);
                break;
        case CX23885_BOARD_DVBSKY_T980C:
+       case CX23885_BOARD_DVBSKY_S950C:
                /*
                 * GPIO-0 INTA from CiMax, input
                 * GPIO-1 reset CiMax, output, high active
@@ -1859,6 +1868,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
        case CX23885_BOARD_DVBWORLD_2005:
        case CX23885_BOARD_PROF_8000:
        case CX23885_BOARD_DVBSKY_T980C:
+       case CX23885_BOARD_DVBSKY_S950C:
                ts1->gen_ctrl_val  = 0x5; /* Parallel */
                ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
                ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
@@ -1978,6 +1988,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
        case CX23885_BOARD_TBS_6981:
        case CX23885_BOARD_DVBSKY_T9580:
        case CX23885_BOARD_DVBSKY_T980C:
+       case CX23885_BOARD_DVBSKY_S950C:
                dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
                                &dev->i2c_bus[2].i2c_adap,
                                "cx25840", 0x88 >> 1, NULL);
index 757854914781275c04e245be6810513dbc09bb72..f82eb1881ac2271d5ae25b0753e274c6a6c8408d 100644 (file)
@@ -635,7 +635,7 @@ static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
        struct cx23885_tsport *port = priv;
        struct cx23885_dev *dev = port->dev;
        int ret;
-       int tmp;
+       int tmp = 0;
        unsigned long timeout;
 
        mutex_lock(&dev->gpio_lock);
@@ -865,6 +865,19 @@ static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
        .agc = 0x99,
 };
 
+static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
+       .i2c_addr = 0x68,
+       .clock = 27000000,
+       .i2c_wr_max = 33,
+       .clock_out = 0,
+       .ts_mode = M88DS3103_TS_CI,
+       .ts_clk = 10000,
+       .ts_clk_pol = 1,
+       .lnb_en_pol = 1,
+       .lnb_hv_pol = 0,
+       .agc = 0x99,
+};
+
 static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
 {
        struct cx23885_dev *dev = (struct cx23885_dev *)device;
@@ -1020,7 +1033,7 @@ static int dvb_register(struct cx23885_tsport *port)
        struct m88ts2022_config m88ts2022_config;
        struct i2c_board_info info;
        struct i2c_adapter *adapter;
-       struct i2c_client *client_demod, *client_tuner, *client_ci;
+       struct i2c_client *client_demod = NULL, *client_tuner = NULL, *client_ci = NULL;
        int mfe_shared = 0; /* bus not shared by default */
        int ret;
 
@@ -1797,6 +1810,41 @@ static int dvb_register(struct cx23885_tsport *port)
                        i2c_unregister_device(client_demod);
                        goto frontend_detach;
                }
+               port->i2c_client_tuner = client_tuner;
+               break;
+       case CX23885_BOARD_DVBSKY_S950C:
+               i2c_bus = &dev->i2c_bus[1];
+               i2c_bus2 = &dev->i2c_bus[0];
+
+               /* attach frontend */
+               fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
+                               &dvbsky_s950c_m88ds3103_config,
+                               &i2c_bus->i2c_adap, &adapter);
+               if (fe0->dvb.frontend == NULL)
+                       break;
+
+               /* attach tuner */
+               memset(&m88ts2022_config, 0, sizeof(m88ts2022_config));
+               m88ts2022_config.fe = fe0->dvb.frontend;
+               m88ts2022_config.clock = 27000000;
+               memset(&info, 0, sizeof(struct i2c_board_info));
+               strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE);
+               info.addr = 0x60;
+               info.platform_data = &m88ts2022_config;
+               request_module(info.type);
+               client_tuner = i2c_new_device(adapter, &info);
+               if (client_tuner == NULL ||
+                               client_tuner->dev.driver == NULL)
+                       goto frontend_detach;
+               if (!try_module_get(client_tuner->dev.driver->owner)) {
+                       i2c_unregister_device(client_tuner);
+                       goto frontend_detach;
+               }
+
+               /* delegate signal strength measurement to tuner */
+               fe0->dvb.frontend->ops.read_signal_strength =
+                       fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
+
                port->i2c_client_tuner = client_tuner;
                break;
        default:
@@ -1889,6 +1937,7 @@ static int dvb_register(struct cx23885_tsport *port)
                        (port->nr-1) * 8, 6);
                break;
                }
+       case CX23885_BOARD_DVBSKY_S950C:
        case CX23885_BOARD_DVBSKY_T980C: {
                u8 eeprom[256]; /* 24C02 i2c eeprom */
 
@@ -1905,18 +1954,26 @@ static int dvb_register(struct cx23885_tsport *port)
                client_ci = i2c_new_device(&i2c_bus2->i2c_adap, &info);
                if (client_ci == NULL ||
                                client_ci->dev.driver == NULL) {
-                       module_put(client_tuner->dev.driver->owner);
-                       i2c_unregister_device(client_tuner);
-                       module_put(client_demod->dev.driver->owner);
-                       i2c_unregister_device(client_demod);
+                       if (client_tuner) {
+                               module_put(client_tuner->dev.driver->owner);
+                               i2c_unregister_device(client_tuner);
+                       }
+                       if (client_demod) {
+                               module_put(client_demod->dev.driver->owner);
+                               i2c_unregister_device(client_demod);
+                       }
                        goto frontend_detach;
                }
                if (!try_module_get(client_ci->dev.driver->owner)) {
                        i2c_unregister_device(client_ci);
-                       module_put(client_tuner->dev.driver->owner);
-                       i2c_unregister_device(client_tuner);
-                       module_put(client_demod->dev.driver->owner);
-                       i2c_unregister_device(client_demod);
+                       if (client_tuner) {
+                               module_put(client_tuner->dev.driver->owner);
+                               i2c_unregister_device(client_tuner);
+                       }
+                       if (client_demod) {
+                               module_put(client_demod->dev.driver->owner);
+                               i2c_unregister_device(client_demod);
+                       }
                        goto frontend_detach;
                }
                port->i2c_client_ci = client_ci;
@@ -1928,7 +1985,7 @@ static int dvb_register(struct cx23885_tsport *port)
                dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
                tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
                                sizeof(eeprom));
-               printk(KERN_INFO "DVBSky T980C MAC address: %pM\n",
+               printk(KERN_INFO "DVBSky T980C/S950C MAC address: %pM\n",
                        eeprom + 0xc0);
                memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
                break;
index 27ea249d07cfb9ec95a810c92781d845e989ae8a..f6f6974ee824ce16d14fcb37ed5b43982f3ec20c 100644 (file)
@@ -94,6 +94,7 @@
 #define CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2 44
 #define CX23885_BOARD_DVBSKY_T9580             45
 #define CX23885_BOARD_DVBSKY_T980C             46
+#define CX23885_BOARD_DVBSKY_S950C             47
 
 #define GPIO_0 0x00000001
 #define GPIO_1 0x00000002