V4L/DVB (5805): Bttv: Fix problems with probing for non-existent tuners
authorTrent Piepho <xyzzy@speakeasy.org>
Thu, 28 Jun 2007 20:51:08 +0000 (17:51 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 18 Jul 2007 17:24:26 +0000 (14:24 -0300)
The bttv driver has code to detect if a tda9887 is present, that was previous
used to auto-load the tda9887 driver.  Now there is no tda9887 driver, so the
code is pointless; it just figures out if it should load the driver and then
does nothing.

For cards that are defined as having no tuner, the init code would still do
i2c probes for various tuner devices and auto-load the tuner module.  That can
be skipped for cards that don't need it.  The code is made to understand that
in addition to 'UNSET', 'TUNER_ABSENT' also means no tuner.

The tuner into printk()s are also made nicer.  Levels are added, INFO or
WARNING, depending on the meaning.  For cards with no tuner, or no tuner
defined, a more informative message is printed.

Card has no tuner, before patch:
bttv0: tuner type=-1
 or
bttv0: tuner type=4

After patch:

bttv0: tuner absent

Card has a tuner, but the type isn't defined, before patch:
bttv0: tuner type=-1

After patch:
bttv0: tuner type unset   [<- also warning now, as the tuner won't work right]

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/bt8xx/bttv-cards.c

index 2d61ed6fb0b5139c05cddfd347ea619600faf5cf..e6cdc9989e124b6ac10ee6dacdfab7ba66cb9020 100644 (file)
@@ -3370,10 +3370,9 @@ void __devinit bttv_init_card1(struct bttv *btv)
 /* initialization part two -- after registering i2c bus */
 void __devinit bttv_init_card2(struct bttv *btv)
 {
-       int tda9887;
        int addr=ADDR_UNSET;
 
-       btv->tuner_type = -1;
+       btv->tuner_type = UNSET;
 
        if (BTTV_BOARD_UNKNOWN == btv->c.type) {
                bttv_readee(btv,eeprom_data,0xa0);
@@ -3521,7 +3520,15 @@ void __devinit bttv_init_card2(struct bttv *btv)
                        btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type;
        if (UNSET != tuner[btv->c.nr])
                btv->tuner_type = tuner[btv->c.nr];
-       printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type);
+
+       if (btv->tuner_type == TUNER_ABSENT ||
+           bttv_tvcards[btv->c.type].tuner == UNSET)
+               printk(KERN_INFO "bttv%d: tuner absent\n", btv->c.nr);
+       else if(btv->tuner_type == UNSET)
+               printk(KERN_WARNING "bttv%d: tuner type unset\n", btv->c.nr);
+       else
+               printk(KERN_INFO "bttv%d: tuner type=%d\n", btv->c.nr,
+                      btv->tuner_type);
 
        if (btv->tuner_type != UNSET) {
                struct tuner_setup tun_setup;
@@ -3563,6 +3570,9 @@ void __devinit bttv_init_card2(struct bttv *btv)
        if (!autoload)
                return;
 
+       if (bttv_tvcards[btv->c.type].tuner == UNSET)
+               return;  /* no tuner or related drivers to load */
+
        /* try to detect audio/fader chips */
        if (!bttv_tvcards[btv->c.type].no_msp34xx &&
            bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx") >=0)
@@ -3583,17 +3593,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
        if (bttv_tvcards[btv->c.type].needs_tvaudio)
                request_module("tvaudio");
 
-       /* tuner modules */
-       tda9887 = 0;
-       if (btv->tda9887_conf)
-               tda9887 = 1;
-       if (0 == tda9887 && 0 == bttv_tvcards[btv->c.type].has_dvb &&
-           bttv_I2CRead(btv, I2C_ADDR_TDA9887, "TDA9887") >=0)
-               tda9887 = 1;
-       /* Hybrid DVB card, DOES have a tda9887 */
-       if (btv->c.type == BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE)
-               tda9887 = 1;
-       if (btv->tuner_type != UNSET)
+       if (btv->tuner_type != UNSET && btv->tuner_type != TUNER_ABSENT)
                request_module("tuner");
 }