aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/bt8xx/bttv-cards.c
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/video/bt8xx/bttv-cards.c
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/video/bt8xx/bttv-cards.c')
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c179
1 files changed, 152 insertions, 27 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;