These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / media / usb / dvb-usb / dw2102.c
index f1f357f..14ef25d 100644 (file)
 
 struct dw2102_state {
        u8 initialized;
+       u8 last_lock;
        struct i2c_client *i2c_client_tuner;
-       int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
+
+       /* fe hook functions*/
+       int (*old_set_voltage)(struct dvb_frontend *f, enum fe_sec_voltage v);
+       int (*fe_read_status)(struct dvb_frontend *fe,
+                             enum fe_status *status);
 };
 
 /* debug */
@@ -437,7 +442,7 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
                                                ibuf, msg[j].len + 2,
                                                DW210X_READ_MSG);
                                memcpy(msg[j].buf, ibuf + 2, msg[j].len);
-                       mdelay(10);
+                               mdelay(10);
                        } else if (((msg[j].buf[0] == 0xb0) &&
                                                (msg[j].addr == 0x68)) ||
                                                ((msg[j].buf[0] == 0xf7) &&
@@ -928,8 +933,6 @@ static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
                        break;
                else
                        mac[i] = ibuf[0];
-
-               debug_dump(mac, 6, printk);
        }
 
        return 0;
@@ -946,7 +949,8 @@ static int su3000_identify_state(struct usb_device *udev,
        return 0;
 }
 
-static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
+static int dw210x_set_voltage(struct dvb_frontend *fe,
+                             enum fe_sec_voltage voltage)
 {
        static u8 command_13v[] = {0x00, 0x01};
        static u8 command_18v[] = {0x01, 0x01};
@@ -970,7 +974,8 @@ static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
        return 0;
 }
 
-static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
+static int s660_set_voltage(struct dvb_frontend *fe,
+                           enum fe_sec_voltage voltage)
 {
        struct dvb_usb_adapter *d =
                (struct dvb_usb_adapter *)(fe->dvb->priv);
@@ -1001,6 +1006,24 @@ static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
        i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
 }
 
+static int tt_s2_4600_read_status(struct dvb_frontend *fe,
+                                 enum fe_status *status)
+{
+       struct dvb_usb_adapter *d =
+               (struct dvb_usb_adapter *)(fe->dvb->priv);
+       struct dw2102_state *st = (struct dw2102_state *)d->dev->priv;
+       int ret;
+
+       ret = st->fe_read_status(fe, status);
+
+       /* resync slave fifo when signal change from unlock to lock */
+       if ((*status & FE_HAS_LOCK) && (!st->last_lock))
+               su3000_streaming_ctrl(d, 1);
+
+       st->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0;
+       return ret;
+}
+
 static struct stv0299_config sharp_z0194a_config = {
        .demod_address = 0x68,
        .inittab = sharp_z0194a_inittab,
@@ -1553,6 +1576,12 @@ static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap)
 
        state->i2c_client_tuner = client;
 
+       /* hook fe: need to resync the slave fifo when signal locks */
+       state->fe_read_status = adap->fe_adap[0].fe->ops.read_status;
+       adap->fe_adap[0].fe->ops.read_status = tt_s2_4600_read_status;
+
+       state->last_lock = 0;
+
        return 0;
 }
 
@@ -1657,6 +1686,8 @@ enum dw2102_table_entry {
        GOTVIEW_SAT_HD,
        GENIATECH_T220,
        TECHNOTREND_S2_4600,
+       TEVII_S482_1,
+       TEVII_S482_2,
 };
 
 static struct usb_device_id dw2102_table[] = {
@@ -1682,6 +1713,8 @@ static struct usb_device_id dw2102_table[] = {
        [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)},
        [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND,
                USB_PID_TECHNOTREND_CONNECT_S2_4600)},
+       [TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)},
+       [TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)},
        { }
 };
 
@@ -2199,12 +2232,20 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {
                } },
                }
        },
-       .num_device_descs = 1,
+       .num_device_descs = 3,
        .devices = {
                { "TechnoTrend TT-connect S2-4600",
                        { &dw2102_table[TECHNOTREND_S2_4600], NULL },
                        { NULL },
                },
+               { "TeVii S482 (tuner 1)",
+                       { &dw2102_table[TEVII_S482_1], NULL },
+                       { NULL },
+               },
+               { "TeVii S482 (tuner 2)",
+                       { &dw2102_table[TEVII_S482_2], NULL },
+                       { NULL },
+               },
        }
 };