aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-03-28 07:29:00 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:46 -0400
commit859f0277a6c3ba59b0a5a1eb183f8f6ce661a95d (patch)
tree47d9d7ee5b1cb7899db12c881d27cd373254e4f8 /drivers/media
parente4129a9ccea54e8f4fbc408476120059809a4627 (diff)
V4L/DVB (11278): bttv: convert to v4l2_subdev since i2c autoprobing will disappear.
Since i2c autoprobing will disappear bttv needs to be converted to use v4l2_subdev instead. Without autoprobing the autoload module option has become obsolete. A warning is generated if it is set, but it is otherwise ignored. Since the bttv card definitions are of questionable value a new option was introduced to allow the user to control which audio module is selected: msp3400, tda7432 or tvaudio (or none at all). By default bttv will use the card definitions and fallback on tvaudio as the last resort. If no audio device was found a warning is printed. The saa6588 RDS device is now also explicitly probed since it is no longer possible to autoprobe it. A new saa6588 module option was added to override the card definition since I suspect more cards have this device than one would guess from the card definitions. Note that the probe addresses of the i2c modules are hardcoded in this driver. Once all v4l drivers are converted to v4l2_subdev this will be cleaned up. Such data belongs in an i2c driver header. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c179
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c41
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c53
-rw-r--r--drivers/media/video/bt8xx/bttv.h7
-rw-r--r--drivers/media/video/bt8xx/bttvp.h5
5 files changed, 180 insertions, 105 deletions
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index 1536ab5a4a8d..b9c3ba51fb86 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -96,12 +96,10 @@ static unsigned int pll[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
96static unsigned int tuner[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; 96static unsigned int tuner[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
97static unsigned int svhs[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; 97static unsigned int svhs[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
98static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; 98static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
99static unsigned int audiodev[BTTV_MAX];
100static unsigned int saa6588[BTTV_MAX];
99static struct bttv *master[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = NULL }; 101static struct bttv *master[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = NULL };
100#ifdef MODULE 102static unsigned int autoload = UNSET;
101static unsigned int autoload = 1;
102#else
103static unsigned int autoload;
104#endif
105static unsigned int gpiomask = UNSET; 103static unsigned int gpiomask = UNSET;
106static unsigned int audioall = UNSET; 104static unsigned int audioall = UNSET;
107static unsigned int audiomux[5] = { [ 0 ... 4 ] = UNSET }; 105static unsigned int audiomux[5] = { [ 0 ... 4 ] = UNSET };
@@ -120,6 +118,7 @@ module_param_array(pll, int, NULL, 0444);
120module_param_array(tuner, int, NULL, 0444); 118module_param_array(tuner, int, NULL, 0444);
121module_param_array(svhs, int, NULL, 0444); 119module_param_array(svhs, int, NULL, 0444);
122module_param_array(remote, int, NULL, 0444); 120module_param_array(remote, int, NULL, 0444);
121module_param_array(audiodev, int, NULL, 0444);
123module_param_array(audiomux, int, NULL, 0444); 122module_param_array(audiomux, int, NULL, 0444);
124 123
125MODULE_PARM_DESC(triton1,"set ETBF pci config bit " 124MODULE_PARM_DESC(triton1,"set ETBF pci config bit "
@@ -130,7 +129,14 @@ MODULE_PARM_DESC(latency,"pci latency timer");
130MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list"); 129MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list");
131MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)"); 130MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)");
132MODULE_PARM_DESC(tuner,"specify installed tuner type"); 131MODULE_PARM_DESC(tuner,"specify installed tuner type");
133MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)"); 132MODULE_PARM_DESC(autoload, "obsolete option, please do not use anymore");
133MODULE_PARM_DESC(audiodev, "specify audio device:\n"
134 "\t\t-1 = no audio\n"
135 "\t\t 0 = autodetect (default)\n"
136 "\t\t 1 = msp3400\n"
137 "\t\t 2 = tda7432\n"
138 "\t\t 3 = tvaudio");
139MODULE_PARM_DESC(saa6588, "if 1, then load the saa6588 RDS module, default (0) is to use the card definition.");
134MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)" 140MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)"
135 " [some VIA/SIS chipsets are known to have problem with overlay]"); 141 " [some VIA/SIS chipsets are known to have problem with overlay]");
136 142
@@ -3318,6 +3324,17 @@ void __devinit bttv_init_card1(struct bttv *btv)
3318/* initialization part two -- after registering i2c bus */ 3324/* initialization part two -- after registering i2c bus */
3319void __devinit bttv_init_card2(struct bttv *btv) 3325void __devinit bttv_init_card2(struct bttv *btv)
3320{ 3326{
3327 static const unsigned short tvaudio_addrs[] = {
3328 I2C_ADDR_TDA8425 >> 1,
3329 I2C_ADDR_TEA6300 >> 1,
3330 I2C_ADDR_TEA6420 >> 1,
3331 I2C_ADDR_TDA9840 >> 1,
3332 I2C_ADDR_TDA985x_L >> 1,
3333 I2C_ADDR_TDA985x_H >> 1,
3334 I2C_ADDR_TDA9874 >> 1,
3335 I2C_ADDR_PIC16C54 >> 1,
3336 I2C_CLIENT_END
3337 };
3321 int addr=ADDR_UNSET; 3338 int addr=ADDR_UNSET;
3322 3339
3323 btv->tuner_type = UNSET; 3340 btv->tuner_type = UNSET;
@@ -3481,6 +3498,12 @@ void __devinit bttv_init_card2(struct bttv *btv)
3481 printk(KERN_INFO "bttv%d: tuner type=%d\n", btv->c.nr, 3498 printk(KERN_INFO "bttv%d: tuner type=%d\n", btv->c.nr,
3482 btv->tuner_type); 3499 btv->tuner_type);
3483 3500
3501 if (autoload != UNSET) {
3502 printk(KERN_WARNING "bttv%d: the autoload option is obsolete.\n", btv->c.nr);
3503 printk(KERN_WARNING "bttv%d: use option msp3400, tda7432 or tvaudio to\n", btv->c.nr);
3504 printk(KERN_WARNING "bttv%d: override which audio module should be used.\n", btv->c.nr);
3505 }
3506
3484 if (UNSET == btv->tuner_type) 3507 if (UNSET == btv->tuner_type)
3485 btv->tuner_type = TUNER_ABSENT; 3508 btv->tuner_type = TUNER_ABSENT;
3486 3509
@@ -3488,8 +3511,13 @@ void __devinit bttv_init_card2(struct bttv *btv)
3488 struct tuner_setup tun_setup; 3511 struct tuner_setup tun_setup;
3489 3512
3490 /* Load tuner module before issuing tuner config call! */ 3513 /* Load tuner module before issuing tuner config call! */
3491 if (autoload) 3514 if (bttv_tvcards[btv->c.type].has_radio)
3492 request_module("tuner"); 3515 v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
3516 "tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_RADIO));
3517 v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner",
3518 "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
3519 v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner",
3520 "tuner", v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD));
3493 3521
3494 tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; 3522 tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
3495 tun_setup.type = btv->tuner_type; 3523 tun_setup.type = btv->tuner_type;
@@ -3498,7 +3526,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
3498 if (bttv_tvcards[btv->c.type].has_radio) 3526 if (bttv_tvcards[btv->c.type].has_radio)
3499 tun_setup.mode_mask |= T_RADIO; 3527 tun_setup.mode_mask |= T_RADIO;
3500 3528
3501 bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup); 3529 bttv_call_all(btv, tuner, s_type_addr, &tun_setup);
3502 } 3530 }
3503 3531
3504 if (btv->tda9887_conf) { 3532 if (btv->tda9887_conf) {
@@ -3507,7 +3535,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
3507 tda9887_cfg.tuner = TUNER_TDA9887; 3535 tda9887_cfg.tuner = TUNER_TDA9887;
3508 tda9887_cfg.priv = &btv->tda9887_conf; 3536 tda9887_cfg.priv = &btv->tda9887_conf;
3509 3537
3510 bttv_call_i2c_clients(btv, TUNER_SET_CONFIG, &tda9887_cfg); 3538 bttv_call_all(btv, tuner, s_config, &tda9887_cfg);
3511 } 3539 }
3512 3540
3513 btv->dig = bttv_tvcards[btv->c.type].has_dig_in ? 3541 btv->dig = bttv_tvcards[btv->c.type].has_dig_in ?
@@ -3530,31 +3558,127 @@ void __devinit bttv_init_card2(struct bttv *btv)
3530 if (bttv_tvcards[btv->c.type].audio_mode_gpio) 3558 if (bttv_tvcards[btv->c.type].audio_mode_gpio)
3531 btv->audio_mode_gpio=bttv_tvcards[btv->c.type].audio_mode_gpio; 3559 btv->audio_mode_gpio=bttv_tvcards[btv->c.type].audio_mode_gpio;
3532 3560
3533 if (!autoload)
3534 return;
3535
3536 if (btv->tuner_type == TUNER_ABSENT) 3561 if (btv->tuner_type == TUNER_ABSENT)
3537 return; /* no tuner or related drivers to load */ 3562 return; /* no tuner or related drivers to load */
3538 3563
3564 if (btv->has_saa6588 || saa6588[btv->c.nr]) {
3565 /* Probe for RDS receiver chip */
3566 static const unsigned short addrs[] = {
3567 0x20 >> 1,
3568 0x22 >> 1,
3569 I2C_CLIENT_END
3570 };
3571 struct v4l2_subdev *sd;
3572
3573 sd = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
3574 "saa6588", "saa6588", addrs);
3575 btv->has_saa6588 = (sd != NULL);
3576 }
3577
3539 /* try to detect audio/fader chips */ 3578 /* try to detect audio/fader chips */
3540 if (!bttv_tvcards[btv->c.type].no_msp34xx &&
3541 bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx") >=0)
3542 request_module("msp3400");
3543 3579
3544 if (bttv_tvcards[btv->c.type].msp34xx_alt && 3580 /* First check if the user specified the audio chip via a module
3545 bttv_I2CRead(btv, I2C_ADDR_MSP3400_ALT, "MSP34xx (alternate address)") >=0) 3581 option. */
3546 request_module("msp3400"); 3582
3583 switch (audiodev[btv->c.nr]) {
3584 case -1:
3585 return; /* do not load any audio module */
3586
3587 case 0: /* autodetect */
3588 break;
3589
3590 case 1: {
3591 /* The user specified that we should probe for msp3400 */
3592 static const unsigned short addrs[] = {
3593 I2C_ADDR_MSP3400 >> 1,
3594 I2C_ADDR_MSP3400_ALT >> 1,
3595 I2C_CLIENT_END
3596 };
3597
3598 btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
3599 "msp3400", "msp3400", addrs);
3600 if (btv->sd_msp34xx)
3601 return;
3602 goto no_audio;
3603 }
3604
3605 case 2: {
3606 /* The user specified that we should probe for tda7432 */
3607 static const unsigned short addrs[] = {
3608 I2C_ADDR_TDA7432 >> 1,
3609 I2C_CLIENT_END
3610 };
3611
3612 if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
3613 "tda7432", "tda7432", addrs))
3614 return;
3615 goto no_audio;
3616 }
3547 3617
3548 if (!bttv_tvcards[btv->c.type].no_tda9875 && 3618 case 3: {
3549 bttv_I2CRead(btv, I2C_ADDR_TDA9875, "TDA9875") >=0) 3619 /* The user specified that we should probe for tvaudio */
3550 request_module("tda9875"); 3620 btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
3621 "tvaudio", "tvaudio", tvaudio_addrs);
3622 if (btv->sd_tvaudio)
3623 return;
3624 goto no_audio;
3625 }
3551 3626
3552 if (!bttv_tvcards[btv->c.type].no_tda7432 && 3627 default:
3553 bttv_I2CRead(btv, I2C_ADDR_TDA7432, "TDA7432") >=0) 3628 printk(KERN_WARNING "bttv%d: unknown audiodev value!\n",
3554 request_module("tda7432"); 3629 btv->c.nr);
3630 return;
3631 }
3632
3633 /* There were no overrides, so now we try to discover this through the
3634 card definition */
3635
3636 /* probe for msp3400 first: this driver can detect whether or not
3637 it really is a msp3400, so it will return NULL when the device
3638 found is really something else (e.g. a tea6300). */
3639 if (!bttv_tvcards[btv->c.type].no_msp34xx) {
3640 static const unsigned short addrs[] = {
3641 I2C_ADDR_MSP3400 >> 1,
3642 I2C_CLIENT_END
3643 };
3644
3645 btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
3646 "msp3400", "msp3400", addrs);
3647 } else if (bttv_tvcards[btv->c.type].msp34xx_alt) {
3648 static const unsigned short addrs[] = {
3649 I2C_ADDR_MSP3400_ALT >> 1,
3650 I2C_CLIENT_END
3651 };
3652
3653 btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
3654 "msp3400", "msp3400", addrs);
3655 }
3656
3657 /* If we found a msp34xx, then we're done. */
3658 if (btv->sd_msp34xx)
3659 return;
3660
3661 /* it might also be a tda7432. */
3662 if (!bttv_tvcards[btv->c.type].no_tda7432) {
3663 static const unsigned short addrs[] = {
3664 I2C_ADDR_TDA7432 >> 1,
3665 I2C_CLIENT_END
3666 };
3667
3668 if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
3669 "tda7432", "tda7432", addrs))
3670 return;
3671 }
3672
3673 /* Now see if we can find one of the tvaudio devices. */
3674 btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
3675 "tvaudio", "tvaudio", tvaudio_addrs);
3676 if (btv->sd_tvaudio)
3677 return;
3555 3678
3556 if (bttv_tvcards[btv->c.type].needs_tvaudio) 3679no_audio:
3557 request_module("tvaudio"); 3680 printk(KERN_WARNING "bttv%d: audio absent, no audio device found!\n",
3681 btv->c.nr);
3558} 3682}
3559 3683
3560 3684
@@ -3626,6 +3750,7 @@ static int terratec_active_radio_upgrade(struct bttv *btv)
3626 printk("bttv%d: Terratec Active Radio Upgrade found.\n", 3750 printk("bttv%d: Terratec Active Radio Upgrade found.\n",
3627 btv->c.nr); 3751 btv->c.nr);
3628 btv->has_radio = 1; 3752 btv->has_radio = 1;
3753 btv->has_saa6588 = 1;
3629 btv->has_matchbox = 1; 3754 btv->has_matchbox = 1;
3630 } else { 3755 } else {
3631 btv->has_radio = 0; 3756 btv->has_radio = 0;
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 1dc79b82cf42..7a8ca0d8356f 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -1163,7 +1163,6 @@ audio_mux(struct bttv *btv, int input, int mute)
1163{ 1163{
1164 int gpio_val, signal; 1164 int gpio_val, signal;
1165 struct v4l2_control ctrl; 1165 struct v4l2_control ctrl;
1166 struct i2c_client *c;
1167 1166
1168 gpio_inout(bttv_tvcards[btv->c.type].gpiomask, 1167 gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
1169 bttv_tvcards[btv->c.type].gpiomask); 1168 bttv_tvcards[btv->c.type].gpiomask);
@@ -1197,9 +1196,8 @@ audio_mux(struct bttv *btv, int input, int mute)
1197 1196
1198 ctrl.id = V4L2_CID_AUDIO_MUTE; 1197 ctrl.id = V4L2_CID_AUDIO_MUTE;
1199 ctrl.value = btv->mute; 1198 ctrl.value = btv->mute;
1200 bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, &ctrl); 1199 bttv_call_all(btv, core, s_ctrl, &ctrl);
1201 c = btv->i2c_msp34xx_client; 1200 if (btv->sd_msp34xx) {
1202 if (c) {
1203 struct v4l2_routing route; 1201 struct v4l2_routing route;
1204 1202
1205 /* Note: the inputs tuner/radio/extern/intern are translated 1203 /* Note: the inputs tuner/radio/extern/intern are translated
@@ -1238,15 +1236,14 @@ audio_mux(struct bttv *btv, int input, int mute)
1238 break; 1236 break;
1239 } 1237 }
1240 route.output = MSP_OUTPUT_DEFAULT; 1238 route.output = MSP_OUTPUT_DEFAULT;
1241 c->driver->command(c, VIDIOC_INT_S_AUDIO_ROUTING, &route); 1239 v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing, &route);
1242 } 1240 }
1243 c = btv->i2c_tvaudio_client; 1241 if (btv->sd_tvaudio) {
1244 if (c) {
1245 struct v4l2_routing route; 1242 struct v4l2_routing route;
1246 1243
1247 route.input = input; 1244 route.input = input;
1248 route.output = 0; 1245 route.output = 0;
1249 c->driver->command(c, VIDIOC_INT_S_AUDIO_ROUTING, &route); 1246 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, &route);
1250 } 1247 }
1251 return 0; 1248 return 0;
1252} 1249}
@@ -1332,7 +1329,7 @@ set_tvnorm(struct bttv *btv, unsigned int norm)
1332 break; 1329 break;
1333 } 1330 }
1334 id = tvnorm->v4l2_id; 1331 id = tvnorm->v4l2_id;
1335 bttv_call_i2c_clients(btv, VIDIOC_S_STD, &id); 1332 bttv_call_all(btv, tuner, s_std, id);
1336 1333
1337 return 0; 1334 return 0;
1338} 1335}
@@ -1476,7 +1473,7 @@ static int bttv_g_ctrl(struct file *file, void *priv,
1476 case V4L2_CID_AUDIO_BALANCE: 1473 case V4L2_CID_AUDIO_BALANCE:
1477 case V4L2_CID_AUDIO_BASS: 1474 case V4L2_CID_AUDIO_BASS:
1478 case V4L2_CID_AUDIO_TREBLE: 1475 case V4L2_CID_AUDIO_TREBLE:
1479 bttv_call_i2c_clients(btv, VIDIOC_G_CTRL, c); 1476 bttv_call_all(btv, core, g_ctrl, c);
1480 break; 1477 break;
1481 1478
1482 case V4L2_CID_PRIVATE_CHROMA_AGC: 1479 case V4L2_CID_PRIVATE_CHROMA_AGC:
@@ -1550,12 +1547,12 @@ static int bttv_s_ctrl(struct file *file, void *f,
1550 if (btv->volume_gpio) 1547 if (btv->volume_gpio)
1551 btv->volume_gpio(btv, c->value); 1548 btv->volume_gpio(btv, c->value);
1552 1549
1553 bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, c); 1550 bttv_call_all(btv, core, s_ctrl, c);
1554 break; 1551 break;
1555 case V4L2_CID_AUDIO_BALANCE: 1552 case V4L2_CID_AUDIO_BALANCE:
1556 case V4L2_CID_AUDIO_BASS: 1553 case V4L2_CID_AUDIO_BASS:
1557 case V4L2_CID_AUDIO_TREBLE: 1554 case V4L2_CID_AUDIO_TREBLE:
1558 bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, c); 1555 bttv_call_all(btv, core, s_ctrl, c);
1559 break; 1556 break;
1560 1557
1561 case V4L2_CID_PRIVATE_CHROMA_AGC: 1558 case V4L2_CID_PRIVATE_CHROMA_AGC:
@@ -1973,7 +1970,7 @@ static int bttv_s_tuner(struct file *file, void *priv,
1973 return -EINVAL; 1970 return -EINVAL;
1974 1971
1975 mutex_lock(&btv->lock); 1972 mutex_lock(&btv->lock);
1976 bttv_call_i2c_clients(btv, VIDIOC_S_TUNER, t); 1973 bttv_call_all(btv, tuner, s_tuner, t);
1977 1974
1978 if (btv->audio_mode_gpio) 1975 if (btv->audio_mode_gpio)
1979 btv->audio_mode_gpio(btv, t, 1); 1976 btv->audio_mode_gpio(btv, t, 1);
@@ -2018,7 +2015,7 @@ static int bttv_s_frequency(struct file *file, void *priv,
2018 return -EINVAL; 2015 return -EINVAL;
2019 mutex_lock(&btv->lock); 2016 mutex_lock(&btv->lock);
2020 btv->freq = f->frequency; 2017 btv->freq = f->frequency;
2021 bttv_call_i2c_clients(btv, VIDIOC_S_FREQUENCY, f); 2018 bttv_call_all(btv, tuner, s_frequency, f);
2022 if (btv->has_matchbox && btv->radio_user) 2019 if (btv->has_matchbox && btv->radio_user)
2023 tea5757_set_freq(btv, btv->freq); 2020 tea5757_set_freq(btv, btv->freq);
2024 mutex_unlock(&btv->lock); 2021 mutex_unlock(&btv->lock);
@@ -2032,7 +2029,7 @@ static int bttv_log_status(struct file *file, void *f)
2032 2029
2033 printk(KERN_INFO "bttv%d: ======== START STATUS CARD #%d ========\n", 2030 printk(KERN_INFO "bttv%d: ======== START STATUS CARD #%d ========\n",
2034 btv->c.nr, btv->c.nr); 2031 btv->c.nr, btv->c.nr);
2035 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, NULL); 2032 bttv_call_all(btv, core, log_status);
2036 printk(KERN_INFO "bttv%d: ======== END STATUS CARD #%d ========\n", 2033 printk(KERN_INFO "bttv%d: ======== END STATUS CARD #%d ========\n",
2037 btv->c.nr, btv->c.nr); 2034 btv->c.nr, btv->c.nr);
2038 return 0; 2035 return 0;
@@ -2946,7 +2943,7 @@ static int bttv_g_tuner(struct file *file, void *priv,
2946 2943
2947 mutex_lock(&btv->lock); 2944 mutex_lock(&btv->lock);
2948 t->rxsubchans = V4L2_TUNER_SUB_MONO; 2945 t->rxsubchans = V4L2_TUNER_SUB_MONO;
2949 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t); 2946 bttv_call_all(btv, tuner, g_tuner, t);
2950 strcpy(t->name, "Television"); 2947 strcpy(t->name, "Television");
2951 t->capability = V4L2_TUNER_CAP_NORM; 2948 t->capability = V4L2_TUNER_CAP_NORM;
2952 t->type = V4L2_TUNER_ANALOG_TV; 2949 t->type = V4L2_TUNER_ANALOG_TV;
@@ -3437,7 +3434,7 @@ static int radio_open(struct file *file)
3437 3434
3438 btv->radio_user++; 3435 btv->radio_user++;
3439 3436
3440 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL); 3437 bttv_call_all(btv, tuner, s_radio);
3441 audio_input(btv,TVAUDIO_INPUT_RADIO); 3438 audio_input(btv,TVAUDIO_INPUT_RADIO);
3442 3439
3443 mutex_unlock(&btv->lock); 3440 mutex_unlock(&btv->lock);
@@ -3457,7 +3454,7 @@ static int radio_release(struct file *file)
3457 3454
3458 btv->radio_user--; 3455 btv->radio_user--;
3459 3456
3460 bttv_call_i2c_clients(btv, RDS_CMD_CLOSE, &cmd); 3457 bttv_call_all(btv, core, ioctl, RDS_CMD_CLOSE, &cmd);
3461 3458
3462 return 0; 3459 return 0;
3463} 3460}
@@ -3490,7 +3487,7 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
3490 strcpy(t->name, "Radio"); 3487 strcpy(t->name, "Radio");
3491 t->type = V4L2_TUNER_RADIO; 3488 t->type = V4L2_TUNER_RADIO;
3492 3489
3493 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t); 3490 bttv_call_all(btv, tuner, g_tuner, t);
3494 3491
3495 if (btv->audio_mode_gpio) 3492 if (btv->audio_mode_gpio)
3496 btv->audio_mode_gpio(btv, t, 0); 3493 btv->audio_mode_gpio(btv, t, 0);
@@ -3532,7 +3529,7 @@ static int radio_s_tuner(struct file *file, void *priv,
3532 if (0 != t->index) 3529 if (0 != t->index)
3533 return -EINVAL; 3530 return -EINVAL;
3534 3531
3535 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t); 3532 bttv_call_all(btv, tuner, g_tuner, t);
3536 return 0; 3533 return 0;
3537} 3534}
3538 3535
@@ -3593,7 +3590,7 @@ static ssize_t radio_read(struct file *file, char __user *data,
3593 cmd.instance = file; 3590 cmd.instance = file;
3594 cmd.result = -ENODEV; 3591 cmd.result = -ENODEV;
3595 3592
3596 bttv_call_i2c_clients(btv, RDS_CMD_READ, &cmd); 3593 bttv_call_all(btv, core, ioctl, RDS_CMD_READ, &cmd);
3597 3594
3598 return cmd.result; 3595 return cmd.result;
3599} 3596}
@@ -3606,7 +3603,7 @@ static unsigned int radio_poll(struct file *file, poll_table *wait)
3606 cmd.instance = file; 3603 cmd.instance = file;
3607 cmd.event_list = wait; 3604 cmd.event_list = wait;
3608 cmd.result = -ENODEV; 3605 cmd.result = -ENODEV;
3609 bttv_call_i2c_clients(btv, RDS_CMD_POLL, &cmd); 3606 bttv_call_all(btv, core, ioctl, RDS_CMD_POLL, &cmd);
3610 3607
3611 return cmd.result; 3608 return cmd.result;
3612} 3609}
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index 9b66c5b09321..a99d92fac3dc 100644
--- a/drivers/media/video/bt8xx/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -36,8 +36,6 @@
36#include <linux/jiffies.h> 36#include <linux/jiffies.h>
37#include <asm/io.h> 37#include <asm/io.h>
38 38
39static int attach_inform(struct i2c_client *client);
40
41static int i2c_debug; 39static int i2c_debug;
42static int i2c_hw; 40static int i2c_hw;
43static int i2c_scan; 41static int i2c_scan;
@@ -266,51 +264,6 @@ static const struct i2c_algorithm bttv_algo = {
266/* ----------------------------------------------------------------------- */ 264/* ----------------------------------------------------------------------- */
267/* I2C functions - common stuff */ 265/* I2C functions - common stuff */
268 266
269static int attach_inform(struct i2c_client *client)
270{
271 struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
272 struct bttv *btv = to_bttv(v4l2_dev);
273 int addr=ADDR_UNSET;
274
275
276 if (ADDR_UNSET != bttv_tvcards[btv->c.type].tuner_addr)
277 addr = bttv_tvcards[btv->c.type].tuner_addr;
278
279
280 if (bttv_debug)
281 printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n",
282 btv->c.nr, client->driver->driver.name, client->addr,
283 client->name);
284 if (!client->driver->command)
285 return 0;
286
287 if (client->driver->id == I2C_DRIVERID_MSP3400)
288 btv->i2c_msp34xx_client = client;
289 if (client->driver->id == I2C_DRIVERID_TVAUDIO)
290 btv->i2c_tvaudio_client = client;
291 if (btv->tuner_type != TUNER_ABSENT) {
292 struct tuner_setup tun_setup;
293
294 if (addr == ADDR_UNSET || addr == client->addr) {
295 tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV | T_RADIO;
296 tun_setup.type = btv->tuner_type;
297 tun_setup.addr = addr;
298 bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup);
299 }
300
301 }
302
303 return 0;
304}
305
306void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
307{
308 if (0 != btv->i2c_rc)
309 return;
310 i2c_clients_command(&btv->c.i2c_adap, cmd, arg);
311}
312
313
314/* read I2C */ 267/* read I2C */
315int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for) 268int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for)
316{ 269{
@@ -417,8 +370,6 @@ int __devinit init_bttv_i2c(struct bttv *btv)
417 btv->c.i2c_adap.algo_data = &btv->i2c_algo; 370 btv->c.i2c_adap.algo_data = &btv->i2c_algo;
418 } 371 }
419 btv->c.i2c_adap.owner = THIS_MODULE; 372 btv->c.i2c_adap.owner = THIS_MODULE;
420 btv->c.i2c_adap.class = I2C_CLASS_TV_ANALOG;
421 btv->c.i2c_adap.client_register = attach_inform;
422 373
423 btv->c.i2c_adap.dev.parent = &btv->c.pci->dev; 374 btv->c.i2c_adap.dev.parent = &btv->c.pci->dev;
424 snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name), 375 snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name),
@@ -428,10 +379,6 @@ int __devinit init_bttv_i2c(struct bttv *btv)
428 i2c_set_adapdata(&btv->c.i2c_adap, &btv->c.v4l2_dev); 379 i2c_set_adapdata(&btv->c.i2c_adap, &btv->c.v4l2_dev);
429 btv->i2c_client.adapter = &btv->c.i2c_adap; 380 btv->i2c_client.adapter = &btv->c.i2c_adap;
430 381
431 if (bttv_tvcards[btv->c.type].no_video)
432 btv->c.i2c_adap.class &= ~I2C_CLASS_TV_ANALOG;
433 if (bttv_tvcards[btv->c.type].has_dvb)
434 btv->c.i2c_adap.class |= I2C_CLASS_TV_DIGITAL;
435 382
436 if (btv->use_i2c_hw) { 383 if (btv->use_i2c_hw) {
437 btv->i2c_rc = i2c_add_adapter(&btv->c.i2c_adap); 384 btv->i2c_rc = i2c_add_adapter(&btv->c.i2c_adap);
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h
index fac5f86356d2..3d36daf206f3 100644
--- a/drivers/media/video/bt8xx/bttv.h
+++ b/drivers/media/video/bt8xx/bttv.h
@@ -240,6 +240,9 @@ struct tvcard {
240 unsigned int no_tda7432:1; 240 unsigned int no_tda7432:1;
241 unsigned int needs_tvaudio:1; 241 unsigned int needs_tvaudio:1;
242 unsigned int msp34xx_alt:1; 242 unsigned int msp34xx_alt:1;
243 /* Note: currently no card definition needs to mark the presence
244 of a RDS saa6588 chip. If this is ever needed, then add a new
245 'has_saa6588' bit here. */
243 246
244 unsigned int no_video:1; /* video pci function is unused */ 247 unsigned int no_video:1; /* video pci function is unused */
245 unsigned int has_dvb:1; 248 unsigned int has_dvb:1;
@@ -355,7 +358,9 @@ void bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits);
355/* ---------------------------------------------------------- */ 358/* ---------------------------------------------------------- */
356/* i2c */ 359/* i2c */
357 360
358extern void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg); 361#define bttv_call_all(btv, o, f, args...) \
362 v4l2_device_call_all(&btv->c.v4l2_dev, 0, o, f, ##args)
363
359extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for); 364extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for);
360extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, 365extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
361 unsigned char b2, int both); 366 unsigned char b2, int both);
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index 5755b407c0a2..96498489199d 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -329,6 +329,7 @@ struct bttv {
329 unsigned int tuner_type; /* tuner chip type */ 329 unsigned int tuner_type; /* tuner chip type */
330 unsigned int tda9887_conf; 330 unsigned int tda9887_conf;
331 unsigned int svhs, dig; 331 unsigned int svhs, dig;
332 unsigned int has_saa6588:1;
332 struct bttv_pll_info pll; 333 struct bttv_pll_info pll;
333 int triton1; 334 int triton1;
334 int gpioirq; 335 int gpioirq;
@@ -352,8 +353,8 @@ struct bttv {
352 int i2c_state, i2c_rc; 353 int i2c_state, i2c_rc;
353 int i2c_done; 354 int i2c_done;
354 wait_queue_head_t i2c_queue; 355 wait_queue_head_t i2c_queue;
355 struct i2c_client *i2c_msp34xx_client; 356 struct v4l2_subdev *sd_msp34xx;
356 struct i2c_client *i2c_tvaudio_client; 357 struct v4l2_subdev *sd_tvaudio;
357 358
358 /* video4linux (1) */ 359 /* video4linux (1) */
359 struct video_device *video_dev; 360 struct video_device *video_dev;