Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[pandora-kernel.git] / drivers / media / video / bt8xx / bttv-cards.c
index b9c3ba5..ca6558c 100644 (file)
@@ -3324,19 +3324,6 @@ void __devinit bttv_init_card1(struct bttv *btv)
 /* initialization part two -- after registering i2c bus */
 void __devinit bttv_init_card2(struct bttv *btv)
 {
-       static const unsigned short tvaudio_addrs[] = {
-               I2C_ADDR_TDA8425   >> 1,
-               I2C_ADDR_TEA6300   >> 1,
-               I2C_ADDR_TEA6420   >> 1,
-               I2C_ADDR_TDA9840   >> 1,
-               I2C_ADDR_TDA985x_L >> 1,
-               I2C_ADDR_TDA985x_H >> 1,
-               I2C_ADDR_TDA9874   >> 1,
-               I2C_ADDR_PIC16C54  >> 1,
-               I2C_CLIENT_END
-       };
-       int addr=ADDR_UNSET;
-
        btv->tuner_type = UNSET;
 
        if (BTTV_BOARD_UNKNOWN == btv->c.type) {
@@ -3481,9 +3468,6 @@ void __devinit bttv_init_card2(struct bttv *btv)
        btv->pll.pll_current = -1;
 
        /* tuner configuration (from card list / autodetect / insmod option) */
-       if (ADDR_UNSET != bttv_tvcards[btv->c.type].tuner_addr)
-               addr = bttv_tvcards[btv->c.type].tuner_addr;
-
        if (UNSET != bttv_tvcards[btv->c.type].tuner_type)
                if (UNSET == btv->tuner_type)
                        btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type;
@@ -3507,37 +3491,6 @@ void __devinit bttv_init_card2(struct bttv *btv)
        if (UNSET == btv->tuner_type)
                btv->tuner_type = TUNER_ABSENT;
 
-       if (btv->tuner_type != TUNER_ABSENT) {
-               struct tuner_setup tun_setup;
-
-               /* Load tuner module before issuing tuner config call! */
-               if (bttv_tvcards[btv->c.type].has_radio)
-                       v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
-                               "tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_RADIO));
-               v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner",
-                               "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
-               v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner",
-                               "tuner", v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD));
-
-               tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
-               tun_setup.type = btv->tuner_type;
-               tun_setup.addr = addr;
-
-               if (bttv_tvcards[btv->c.type].has_radio)
-                       tun_setup.mode_mask |= T_RADIO;
-
-               bttv_call_all(btv, tuner, s_type_addr, &tun_setup);
-       }
-
-       if (btv->tda9887_conf) {
-               struct v4l2_priv_tun_config tda9887_cfg;
-
-               tda9887_cfg.tuner = TUNER_TDA9887;
-               tda9887_cfg.priv = &btv->tda9887_conf;
-
-               bttv_call_all(btv, tuner, s_config, &tda9887_cfg);
-       }
-
        btv->dig = bttv_tvcards[btv->c.type].has_dig_in ?
                   bttv_tvcards[btv->c.type].video_inputs - 1 : UNSET;
        btv->svhs = bttv_tvcards[btv->c.type].svhs == NO_SVHS ?
@@ -3548,15 +3501,15 @@ void __devinit bttv_init_card2(struct bttv *btv)
                btv->has_remote = remote[btv->c.nr];
 
        if (bttv_tvcards[btv->c.type].has_radio)
-               btv->has_radio=1;
+               btv->has_radio = 1;
        if (bttv_tvcards[btv->c.type].has_remote)
-               btv->has_remote=1;
+               btv->has_remote = 1;
        if (!bttv_tvcards[btv->c.type].no_gpioirq)
-               btv->gpioirq=1;
+               btv->gpioirq = 1;
        if (bttv_tvcards[btv->c.type].volume_gpio)
-               btv->volume_gpio=bttv_tvcards[btv->c.type].volume_gpio;
+               btv->volume_gpio = bttv_tvcards[btv->c.type].volume_gpio;
        if (bttv_tvcards[btv->c.type].audio_mode_gpio)
-               btv->audio_mode_gpio=bttv_tvcards[btv->c.type].audio_mode_gpio;
+               btv->audio_mode_gpio = bttv_tvcards[btv->c.type].audio_mode_gpio;
 
        if (btv->tuner_type == TUNER_ABSENT)
                return;  /* no tuner or related drivers to load */
@@ -3570,8 +3523,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
                };
                struct v4l2_subdev *sd;
 
-               sd = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
-                               "saa6588", "saa6588", addrs);
+               sd = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
+                       &btv->c.i2c_adap, "saa6588", "saa6588", addrs);
                btv->has_saa6588 = (sd != NULL);
        }
 
@@ -3595,8 +3548,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
                        I2C_CLIENT_END
                };
 
-               btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
-                               "msp3400", "msp3400", addrs);
+               btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
+                       &btv->c.i2c_adap, "msp3400", "msp3400", addrs);
                if (btv->sd_msp34xx)
                        return;
                goto no_audio;
@@ -3609,16 +3562,16 @@ void __devinit bttv_init_card2(struct bttv *btv)
                        I2C_CLIENT_END
                };
 
-               if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
-                               "tda7432", "tda7432", addrs))
+               if (v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
+                               &btv->c.i2c_adap, "tda7432", "tda7432", addrs))
                        return;
                goto no_audio;
        }
 
        case 3: {
                /* The user specified that we should probe for tvaudio */
-               btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
-                               "tvaudio", "tvaudio", tvaudio_addrs);
+               btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
+                       &btv->c.i2c_adap, "tvaudio", "tvaudio", tvaudio_addrs());
                if (btv->sd_tvaudio)
                        return;
                goto no_audio;
@@ -3637,21 +3590,13 @@ void __devinit bttv_init_card2(struct bttv *btv)
           it really is a msp3400, so it will return NULL when the device
           found is really something else (e.g. a tea6300). */
        if (!bttv_tvcards[btv->c.type].no_msp34xx) {
-               static const unsigned short addrs[] = {
-                       I2C_ADDR_MSP3400 >> 1,
-                       I2C_CLIENT_END
-               };
-
-               btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
-                               "msp3400", "msp3400", addrs);
+               btv->sd_msp34xx = v4l2_i2c_new_probed_subdev_addr(&btv->c.v4l2_dev,
+                       &btv->c.i2c_adap, "msp3400", "msp3400",
+                       I2C_ADDR_MSP3400 >> 1);
        } else if (bttv_tvcards[btv->c.type].msp34xx_alt) {
-               static const unsigned short addrs[] = {
-                       I2C_ADDR_MSP3400_ALT >> 1,
-                       I2C_CLIENT_END
-               };
-
-               btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
-                               "msp3400", "msp3400", addrs);
+               btv->sd_msp34xx = v4l2_i2c_new_probed_subdev_addr(&btv->c.v4l2_dev,
+                       &btv->c.i2c_adap, "msp3400", "msp3400",
+                       I2C_ADDR_MSP3400_ALT >> 1);
        }
 
        /* If we found a msp34xx, then we're done. */
@@ -3665,14 +3610,14 @@ void __devinit bttv_init_card2(struct bttv *btv)
                        I2C_CLIENT_END
                };
 
-               if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
-                               "tda7432", "tda7432", addrs))
+               if (v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
+                               &btv->c.i2c_adap, "tda7432", "tda7432", addrs))
                        return;
        }
 
        /* Now see if we can find one of the tvaudio devices. */
-       btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
-                       "tvaudio", "tvaudio", tvaudio_addrs);
+       btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
+               &btv->c.i2c_adap, "tvaudio", "tvaudio", tvaudio_addrs());
        if (btv->sd_tvaudio)
                return;
 
@@ -3682,6 +3627,49 @@ no_audio:
 }
 
 
+/* initialize the tuner */
+void __devinit bttv_init_tuner(struct bttv *btv)
+{
+       int addr = ADDR_UNSET;
+
+       if (ADDR_UNSET != bttv_tvcards[btv->c.type].tuner_addr)
+               addr = bttv_tvcards[btv->c.type].tuner_addr;
+
+       if (btv->tuner_type != TUNER_ABSENT) {
+               struct tuner_setup tun_setup;
+
+               /* Load tuner module before issuing tuner config call! */
+               if (bttv_tvcards[btv->c.type].has_radio)
+                       v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
+                               &btv->c.i2c_adap, "tuner", "tuner",
+                               v4l2_i2c_tuner_addrs(ADDRS_RADIO));
+               v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
+                               &btv->c.i2c_adap, "tuner", "tuner",
+                               v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
+               v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
+                               &btv->c.i2c_adap, "tuner", "tuner",
+                               v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD));
+
+               tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
+               tun_setup.type = btv->tuner_type;
+               tun_setup.addr = addr;
+
+               if (bttv_tvcards[btv->c.type].has_radio)
+                       tun_setup.mode_mask |= T_RADIO;
+
+               bttv_call_all(btv, tuner, s_type_addr, &tun_setup);
+       }
+
+       if (btv->tda9887_conf) {
+               struct v4l2_priv_tun_config tda9887_cfg;
+
+               tda9887_cfg.tuner = TUNER_TDA9887;
+               tda9887_cfg.priv = &btv->tda9887_conf;
+
+               bttv_call_all(btv, tuner, s_config, &tda9887_cfg);
+       }
+}
+
 /* ----------------------------------------------------------------------- */
 
 static void modtec_eeprom(struct bttv *btv)