]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (4648): Hauppauge Nova-T 500 support added
authorPatrick Boettcher <pb@linuxtv.org>
Tue, 19 Sep 2006 15:51:40 +0000 (12:51 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Tue, 3 Oct 2006 18:12:36 +0000 (15:12 -0300)
This changeset finalizes the support of the Hauppauge Nova-T 500 (Dual DVB-T).
It adds correct AGC setting for the 3000P, correct firmware download state
detection.
Additionally it fixes the mt2060-driver to be able to be used with dvb_attach.

Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/dvb/dvb-usb/dib0700.h
drivers/media/dvb/dvb-usb/dib0700_core.c
drivers/media/dvb/dvb-usb/dib0700_devices.c
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
drivers/media/dvb/dvb-usb/dvb-usb-ids.h
drivers/media/dvb/frontends/dib3000mc.c
drivers/media/dvb/frontends/mt2060.c
drivers/media/dvb/frontends/mt2060.h

index a2cd6970f4c256fd08930200c5fa76c4955940d7..ac84347f9d4c2b6d896cf5968dcf8ab15c8c6132 100644 (file)
@@ -32,13 +32,15 @@ extern int dvb_usb_dib0700_debug;
 
 struct dib0700_state {
        u8 channel_state;
-       u8 mt2060_if1[2];
+       u16 mt2060_if1[2];
 };
 
 extern int dib0700_set_gpio(struct dvb_usb_device *, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val);
 extern int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw);
 extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff);
 extern struct i2c_algorithm dib0700_i2c_algo;
+extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
+                       struct dvb_usb_device_description **desc, int *cold);
 
 extern int dib0700_device_count;
 extern struct dvb_usb_device_properties dib0700_devices[];
index 1f444a4411a5ecb1c5aec35700cd9150a04d6282..75e8570f4ad83ea6b08024c676abbec936fc8bdc 100644 (file)
@@ -26,7 +26,7 @@ static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
                USB_CTRL_GET_TIMEOUT);
 
        if (status != txlen)
-               err("ep 0 write error (status = %d, len: %d)",status,txlen);
+               deb_data("ep 0 write error (status = %d, len: %d)\n",status,txlen);
 
        return status < 0 ? status : 0;
 }
@@ -65,7 +65,7 @@ static int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u
                        USB_CTRL_GET_TIMEOUT);
 
        if (status < 0)
-               err("ep 0 read error (status = %d)",status);
+               deb_info("ep 0 read error (status = %d)\n",status);
 
        deb_data("<<< ");
        debug_dump(rx,rxlen,deb_data);
@@ -130,6 +130,19 @@ struct i2c_algorithm dib0700_i2c_algo = {
        .functionality = dib0700_i2c_func,
 };
 
+int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
+                       struct dvb_usb_device_description **desc, int *cold)
+{
+       u8 buf[3] = { REQUEST_SET_GPIO, 4, (GPIO_IN << 7) | (0 << 6) }; // GPIO4 is save - used for I2C
+       *cold = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
+               buf[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, buf, 3, USB_CTRL_GET_TIMEOUT) != 3;
+
+       deb_info("cold: %d\n", *cold);
+
+       *cold = 0;
+       return 0;
+}
+
 static int dib0700_jumpram(struct usb_device *udev, u32 address)
 {
        int ret, actlen;
@@ -182,8 +195,10 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
 
        if (ret == 0) {
                /* start the firmware */
-               if ((ret = dib0700_jumpram(udev,0x70000000)) == 0)
+               if ((ret = dib0700_jumpram(udev, 0x70000000)) == 0) {
                        info("firmware started successfully.");
+                       msleep(100);
+               }
        } else
                ret = -EIO;
 
index 74d98dfb5ae74615d1c933cf382c3d07f62c2ed1..da177e745e5ed82f5fe94e55000400c16658af03 100644 (file)
@@ -25,24 +25,24 @@ static struct mt2060_config bristol_mt2060_config[2] = {
 
 static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
        .band_caps = BAND_VHF | BAND_UHF,
-       .setup     = (0 << 15) | (0 << 14) | (1 << 13) | (1 << 12) | (29 << 0),
+       .setup     = (0 << 15) | (0 << 14) | (0 << 13) | (0 << 12) | (29 << 0),
 
-       .agc1_max = 48497,
-       .agc1_min = 23593,
-       .agc2_max = 46531,
-       .agc2_min = 24904,
+       .agc1_max = 42598,
+       .agc1_min = 17694,
+       .agc2_max = 45875,
+       .agc2_min = 0,
 
-       .agc1_pt1 = 0x65,
-       .agc1_pt2 = 0x69,
+       .agc1_pt1 = 0,
+       .agc1_pt2 = 59,
 
-       .agc1_slope1 = 0x51,
-       .agc1_slope2 = 0x27,
+       .agc1_slope1 = 0,
+       .agc1_slope2 = 69,
 
        .agc2_pt1 = 0,
-       .agc2_pt2 = 0x33,
+       .agc2_pt2 = 59,
 
-       .agc2_slope1 = 0x35,
-       .agc2_slope2 = 0x37,
+       .agc2_slope1 = 111,
+       .agc2_slope2 = 28,
 };
 
 static struct dib3000mc_config bristol_dib3000mc_config[2] = {
@@ -60,25 +60,31 @@ static struct dib3000mc_config bristol_dib3000mc_config[2] = {
 
 static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
 {
+       struct dib0700_state *st = adap->dev->priv;
        if (adap->id == 0) {
                dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 0); msleep(10);
                dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 1); msleep(10);
                dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
                dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
 
+               dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); msleep(10); // LNA
+
                if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
                        dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
                        return -ENODEV;
                }
        }
-       return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap, 10 + adap->id, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
+       st->mt2060_if1[adap->id] = 1220;
+       return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
+               (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
 }
 
 static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
 {
        struct dib0700_state *st = adap->dev->priv;
        struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
-       return mt2060_attach(adap->fe, tun_i2c, &bristol_mt2060_config[adap->id], st->mt2060_if1[adap->id]);
+       return dvb_attach(mt2060_attach,adap->fe, tun_i2c, &bristol_mt2060_config[adap->id],
+               st->mt2060_if1[adap->id]) == NULL ? -ENODEV : 0;
 }
 
 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
@@ -119,8 +125,10 @@ MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
        .usb_ctrl          = DEVICE_SPECIFIC, \
        .firmware          = "dvb-usb-dib0700-01.fw", \
        .download_firmware = dib0700_download_firmware, \
+       .no_reconnect      = 1, \
        .size_of_priv      = sizeof(struct dib0700_state), \
-       .i2c_algo          = &dib0700_i2c_algo
+       .i2c_algo          = &dib0700_i2c_algo, \
+       .identify_state    = dib0700_identify_state
 
 #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
        .streaming_ctrl   = dib0700_streaming_ctrl, \
index e1112e39fb638e4d9731510afd7a22667ba434ea..4e986f12b674b5e6d6a4ec0c948eebe9c14b1060 100644 (file)
@@ -80,6 +80,7 @@ int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_device_pro
        int ret;
        const struct firmware *fw = NULL;
 
+
        if ((ret = request_firmware(&fw, props->firmware, &udev->dev)) != 0) {
                err("did not find the firmware file. (%s) "
                        "Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
index feb098727dc3baa8c1452bfa8979603155400835..415a9892391de41b30a63c77be6c842587e112a1 100644 (file)
@@ -94,8 +94,8 @@
 #define USB_PID_WT220U_ZL0353_WARM                     0x022b
 #define USB_PID_WINTV_NOVA_T_USB2_COLD                 0x9300
 #define USB_PID_WINTV_NOVA_T_USB2_WARM                 0x9301
-#define USB_PID_HAUPPAUGE_NOVA_T_500                   0x1234
-#define USB_PID_HAUPPAUGE_NOVA_T_STICK                 0x1234
+#define USB_PID_HAUPPAUGE_NOVA_T_500                   0x9941
+#define USB_PID_HAUPPAUGE_NOVA_T_STICK                 0x7050
 #define USB_PID_AVERMEDIA_VOLAR                                0x1234
 #define USB_PID_NEBULA_DIGITV                          0x0201
 #define USB_PID_DVICO_BLUEBIRD_LGDT                    0xd820
index d7c4a98da1255f1d5e7363e10a62932213b13aa7..60e10dba36844f60a8c0584cfd29adef0f7bfb21 100644 (file)
@@ -830,6 +830,7 @@ struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr
 
        st->cfg = cfg;
        st->i2c_adap = i2c_adap;
+       st->i2c_addr = i2c_addr;
 
        demod                   = &st->demod;
        demod->demodulator_priv = st;
index 19bd66a1816ab925e6b6ab5971aac77b6d7cf22b..450fad8d9b65099ced8ca7f99a789fce9e3636ad 100644 (file)
@@ -332,14 +332,14 @@ static const struct dvb_tuner_ops mt2060_tuner_ops = {
 };
 
 /* This functions tries to identify a MT2060 tuner by reading the PART/REV register. This is hasty. */
-int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1)
+struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1)
 {
        struct mt2060_priv *priv = NULL;
        u8 id = 0;
 
        priv = kzalloc(sizeof(struct mt2060_priv), GFP_KERNEL);
        if (priv == NULL)
-               return -ENOMEM;
+               return NULL;
 
        priv->cfg      = cfg;
        priv->i2c      = i2c;
@@ -347,12 +347,12 @@ int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt206
 
        if (mt2060_readreg(priv,REG_PART_REV,&id) != 0) {
                kfree(priv);
-               return -ENODEV;
+               return NULL;
        }
 
        if (id != PART_REV) {
                kfree(priv);
-               return -ENODEV;
+               return NULL;
        }
        printk(KERN_INFO "MT2060: successfully identified (IF1 = %d)\n", if1);
        memcpy(&fe->ops.tuner_ops, &mt2060_tuner_ops, sizeof(struct dvb_tuner_ops));
@@ -361,7 +361,7 @@ int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt206
 
        mt2060_calibrate(priv);
 
-       return 0;
+       return fe;
 }
 EXPORT_SYMBOL(mt2060_attach);
 
index 471d3326e29da9f4825753d6a440d7295fe92570..fc12c790f913f72f732a1da964e1e562249f7eb4 100644 (file)
@@ -30,6 +30,6 @@ struct mt2060_config {
        u8 clock_out; /* 0 = off, 1 = CLK/1, 2 = CLK/2, 3 = CLK/4 */
 };
 
-extern int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1);
+extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1);
 
 #endif