]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (6543): tda8290: enable probing of tda8295
authorMichael Krufky <mkrufky@linuxtv.org>
Sun, 4 Nov 2007 01:14:54 +0000 (22:14 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Fri, 25 Jan 2008 21:01:56 +0000 (19:01 -0200)
Prevent the tda8295 from falsely being detected as a tda9887

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/tda8290.c
drivers/media/video/tda8290.h
drivers/media/video/tuner-core.c

index c7705cbab2fb6a30db94238f6c2eccdc56baf51d..dd23996546544e542db0c42387bb4ffa1499ff8f 100644 (file)
@@ -632,6 +632,46 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
        return 0;
 }
 
+static int tda8290_probe(struct tuner_i2c_props *i2c_props)
+{
+#define TDA8290_ID 0x89
+       unsigned char tda8290_id[] = { 0x1f, 0x00 };
+
+       /* detect tda8290 */
+       tuner_i2c_xfer_send(i2c_props, &tda8290_id[0], 1);
+       tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1);
+
+       if (tda8290_id[1] == TDA8290_ID) {
+               if (tuner_debug)
+                       printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n",
+                              __FUNCTION__, i2c_adapter_id(i2c_props->adap),
+                              i2c_props->addr);
+               return 0;
+       }
+
+       return -1;
+}
+
+static int tda8295_probe(struct tuner_i2c_props *i2c_props)
+{
+#define TDA8295_ID 0x8a
+       unsigned char tda8295_id[] = { 0x2f, 0x00 };
+
+       /* detect tda8295 */
+       tuner_i2c_xfer_send(i2c_props, &tda8295_id[0], 1);
+       tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1);
+
+       if (tda8295_id[1] == TDA8295_ID) {
+               if (tuner_debug)
+                       printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n",
+                              __FUNCTION__, i2c_adapter_id(i2c_props->adap),
+                              i2c_props->addr);
+               return 0;
+       }
+
+       return -1;
+}
+
 static struct analog_tuner_ops tda8290_tuner_ops = {
        .set_tv_freq    = tda8290_set_freq,
        .set_radio_freq = tda8290_set_freq,
@@ -655,11 +695,6 @@ int tda829x_attach(struct tuner *t)
        struct dvb_frontend *fe = &t->fe;
        struct tda8290_priv *priv = NULL;
 
-       unsigned char tda8290_id[] = { 0x1f, 0x00 };
-#define TDA8290_ID 0x89
-       unsigned char tda8295_id[] = { 0x2f, 0x00 };
-#define TDA8295_ID 0x8a
-
        priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL);
        if (priv == NULL)
                return -ENOMEM;
@@ -671,18 +706,12 @@ int tda829x_attach(struct tuner *t)
        priv->cfg.tuner_callback = t->tuner_callback;
        priv->t = t;
 
-       /* detect tda8290 */
-       tuner_i2c_xfer_send(&priv->i2c_props, &tda8290_id[0], 1);
-       tuner_i2c_xfer_recv(&priv->i2c_props, &tda8290_id[1], 1);
-       if (tda8290_id[1] == TDA8290_ID) {
+       if (tda8290_probe(&priv->i2c_props) == 0) {
                priv->ver = TDA8290;
                fe->ops.analog_demod_ops = &tda8290_tuner_ops;
        }
 
-       /* detect tda8295 */
-       tuner_i2c_xfer_send(&priv->i2c_props, &tda8295_id[0], 1);
-       tuner_i2c_xfer_recv(&priv->i2c_props, &tda8295_id[1], 1);
-       if (tda8295_id[1] == TDA8295_ID) {
+       if (tda8295_probe(&priv->i2c_props) == 0) {
                priv->ver = TDA8295;
                fe->ops.analog_demod_ops = &tda8295_tuner_ops;
        }
@@ -704,7 +733,7 @@ int tda829x_attach(struct tuner *t)
 }
 EXPORT_SYMBOL_GPL(tda829x_attach);
 
-int tda8290_probe(struct tuner *t)
+int tda829x_probe(struct tuner *t)
 {
        struct tuner_i2c_props i2c_props = {
                .adap = t->i2c->adapter,
@@ -718,6 +747,11 @@ int tda8290_probe(struct tuner *t)
        unsigned char addr_dto_lsb = 0x07;
        unsigned char data;
 
+       if ((tda8290_probe(&i2c_props) == 0) ||
+           (tda8295_probe(&i2c_props) == 0))
+               return 0;
+
+       /* fall back to old probing method */
        tuner_i2c_xfer_send(&i2c_props, easy_mode_b, 2);
        tuner_i2c_xfer_send(&i2c_props, soft_reset, 2);
        tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1);
@@ -734,7 +768,7 @@ int tda8290_probe(struct tuner *t)
        tuner_i2c_xfer_send(&i2c_props, restore_9886, 3);
        return -1;
 }
-EXPORT_SYMBOL_GPL(tda8290_probe);
+EXPORT_SYMBOL_GPL(tda829x_probe);
 
 MODULE_DESCRIPTION("Philips/NXP TDA8290/TDA8295 analog IF demodulator driver");
 MODULE_AUTHOR("Gerd Knorr, Hartmut Hackmann, Michael Krufky");
index 81517370b8d6f72e2e94e6f25baed818bae01702..3a1f04520615303b884fd3787da802dfd58f248e 100644 (file)
 #include "tuner-driver.h"
 
 #if defined(CONFIG_TUNER_TDA8290) || (defined(CONFIG_TUNER_TDA8290_MODULE) && defined(MODULE))
-extern int tda8290_probe(struct tuner *t);
+extern int tda829x_probe(struct tuner *t);
 
 extern int tda829x_attach(struct tuner *t);
 #else
-static inline int tda8290_probe(struct tuner *t)
+static inline int tda829x_probe(struct tuner *t)
 {
        printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
        return -EINVAL;
index 17c873c869afc4d7533db9955526c7cdff65dbf1..3ec50dbed74272d5e7257564c04dc48dc9c12014 100644 (file)
@@ -649,8 +649,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
                case 0x4b:
                        /* If chip is not tda8290, don't register.
                           since it can be tda9887*/
-                       if (tda8290_probe(t) == 0) {
-                               tuner_dbg("chip at addr %x is a tda8290\n", addr);
+                       if (tda829x_probe(t) == 0) {
+                               tuner_dbg("tda829x detected\n");
                        } else {
                                /* Default is being tda9887 */
                                t->type = TUNER_TDA9887;