Commit 859f0277 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

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: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent e4129a9c
...@@ -96,12 +96,10 @@ static unsigned int pll[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; ...@@ -96,12 +96,10 @@ static unsigned int pll[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
static unsigned int tuner[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; static unsigned int tuner[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
static unsigned int svhs[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; static unsigned int svhs[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
static unsigned int audiodev[BTTV_MAX];
static unsigned int saa6588[BTTV_MAX];
static struct bttv *master[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = NULL }; static struct bttv *master[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = NULL };
#ifdef MODULE static unsigned int autoload = UNSET;
static unsigned int autoload = 1;
#else
static unsigned int autoload;
#endif
static unsigned int gpiomask = UNSET; static unsigned int gpiomask = UNSET;
static unsigned int audioall = UNSET; static unsigned int audioall = UNSET;
static unsigned int audiomux[5] = { [ 0 ... 4 ] = UNSET }; static unsigned int audiomux[5] = { [ 0 ... 4 ] = UNSET };
...@@ -120,6 +118,7 @@ module_param_array(pll, int, NULL, 0444); ...@@ -120,6 +118,7 @@ module_param_array(pll, int, NULL, 0444);
module_param_array(tuner, int, NULL, 0444); module_param_array(tuner, int, NULL, 0444);
module_param_array(svhs, int, NULL, 0444); module_param_array(svhs, int, NULL, 0444);
module_param_array(remote, int, NULL, 0444); module_param_array(remote, int, NULL, 0444);
module_param_array(audiodev, int, NULL, 0444);
module_param_array(audiomux, int, NULL, 0444); module_param_array(audiomux, int, NULL, 0444);
MODULE_PARM_DESC(triton1,"set ETBF pci config bit " MODULE_PARM_DESC(triton1,"set ETBF pci config bit "
...@@ -130,7 +129,14 @@ MODULE_PARM_DESC(latency,"pci latency timer"); ...@@ -130,7 +129,14 @@ MODULE_PARM_DESC(latency,"pci latency timer");
MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list"); MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list");
MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)"); MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)");
MODULE_PARM_DESC(tuner,"specify installed tuner type"); MODULE_PARM_DESC(tuner,"specify installed tuner type");
MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)"); MODULE_PARM_DESC(autoload, "obsolete option, please do not use anymore");
MODULE_PARM_DESC(audiodev, "specify audio device:\n"
"\t\t-1 = no audio\n"
"\t\t 0 = autodetect (default)\n"
"\t\t 1 = msp3400\n"
"\t\t 2 = tda7432\n"
"\t\t 3 = tvaudio");
MODULE_PARM_DESC(saa6588, "if 1, then load the saa6588 RDS module, default (0) is to use the card definition.");
MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)" MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)"
" [some VIA/SIS chipsets are known to have problem with overlay]"); " [some VIA/SIS chipsets are known to have problem with overlay]");
...@@ -3318,6 +3324,17 @@ void __devinit bttv_init_card1(struct bttv *btv) ...@@ -3318,6 +3324,17 @@ void __devinit bttv_init_card1(struct bttv *btv)
/* initialization part two -- after registering i2c bus */ /* initialization part two -- after registering i2c bus */
void __devinit bttv_init_card2(struct bttv *btv) 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; int addr=ADDR_UNSET;
btv->tuner_type = UNSET; btv->tuner_type = UNSET;
...@@ -3481,6 +3498,12 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3481,6 +3498,12 @@ void __devinit bttv_init_card2(struct bttv *btv)
printk(KERN_INFO "bttv%d: tuner type=%d\n", btv->c.nr, printk(KERN_INFO "bttv%d: tuner type=%d\n", btv->c.nr,
btv->tuner_type); btv->tuner_type);
if (autoload != UNSET) {
printk(KERN_WARNING "bttv%d: the autoload option is obsolete.\n", btv->c.nr);
printk(KERN_WARNING "bttv%d: use option msp3400, tda7432 or tvaudio to\n", btv->c.nr);
printk(KERN_WARNING "bttv%d: override which audio module should be used.\n", btv->c.nr);
}
if (UNSET == btv->tuner_type) if (UNSET == btv->tuner_type)
btv->tuner_type = TUNER_ABSENT; btv->tuner_type = TUNER_ABSENT;
...@@ -3488,8 +3511,13 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3488,8 +3511,13 @@ void __devinit bttv_init_card2(struct bttv *btv)
struct tuner_setup tun_setup; struct tuner_setup tun_setup;
/* Load tuner module before issuing tuner config call! */ /* Load tuner module before issuing tuner config call! */
if (autoload) if (bttv_tvcards[btv->c.type].has_radio)
request_module("tuner"); 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.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
tun_setup.type = btv->tuner_type; tun_setup.type = btv->tuner_type;
...@@ -3498,7 +3526,7 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3498,7 +3526,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
if (bttv_tvcards[btv->c.type].has_radio) if (bttv_tvcards[btv->c.type].has_radio)
tun_setup.mode_mask |= T_RADIO; tun_setup.mode_mask |= T_RADIO;
bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup); bttv_call_all(btv, tuner, s_type_addr, &tun_setup);
} }
if (btv->tda9887_conf) { if (btv->tda9887_conf) {
...@@ -3507,7 +3535,7 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3507,7 +3535,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
tda9887_cfg.tuner = TUNER_TDA9887; tda9887_cfg.tuner = TUNER_TDA9887;
tda9887_cfg.priv = &btv->tda9887_conf; tda9887_cfg.priv = &btv->tda9887_conf;
bttv_call_i2c_clients(btv, TUNER_SET_CONFIG, &tda9887_cfg); bttv_call_all(btv, tuner, s_config, &tda9887_cfg);
} }
btv->dig = bttv_tvcards[btv->c.type].has_dig_in ? btv->dig = bttv_tvcards[btv->c.type].has_dig_in ?
...@@ -3530,31 +3558,127 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3530,31 +3558,127 @@ void __devinit bttv_init_card2(struct bttv *btv)
if (bttv_tvcards[btv->c.type].audio_mode_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 (!autoload)
return;
if (btv->tuner_type == TUNER_ABSENT) if (btv->tuner_type == TUNER_ABSENT)
return; /* no tuner or related drivers to load */ return; /* no tuner or related drivers to load */
if (btv->has_saa6588 || saa6588[btv->c.nr]) {
/* Probe for RDS receiver chip */
static const unsigned short addrs[] = {
0x20 >> 1,
0x22 >> 1,
I2C_CLIENT_END
};
struct v4l2_subdev *sd;
sd = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"saa6588", "saa6588", addrs);
btv->has_saa6588 = (sd != NULL);
}
/* try to detect audio/fader chips */ /* try to detect audio/fader chips */
if (!bttv_tvcards[btv->c.type].no_msp34xx &&
bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx") >=0)
request_module("msp3400");
if (bttv_tvcards[btv->c.type].msp34xx_alt && /* First check if the user specified the audio chip via a module
bttv_I2CRead(btv, I2C_ADDR_MSP3400_ALT, "MSP34xx (alternate address)") >=0) option. */
request_module("msp3400");
switch (audiodev[btv->c.nr]) {
case -1:
return; /* do not load any audio module */
case 0: /* autodetect */
break;
case 1: {
/* The user specified that we should probe for msp3400 */
static const unsigned short addrs[] = {
I2C_ADDR_MSP3400 >> 1,
I2C_ADDR_MSP3400_ALT >> 1,
I2C_CLIENT_END
};
btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"msp3400", "msp3400", addrs);
if (btv->sd_msp34xx)
return;
goto no_audio;
}
case 2: {
/* The user specified that we should probe for tda7432 */
static const unsigned short addrs[] = {
I2C_ADDR_TDA7432 >> 1,
I2C_CLIENT_END
};
if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"tda7432", "tda7432", addrs))
return;
goto no_audio;
}
if (!bttv_tvcards[btv->c.type].no_tda9875 && case 3: {
bttv_I2CRead(btv, I2C_ADDR_TDA9875, "TDA9875") >=0) /* The user specified that we should probe for tvaudio */
request_module("tda9875"); btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"tvaudio", "tvaudio", tvaudio_addrs);
if (btv->sd_tvaudio)
return;
goto no_audio;
}
if (!bttv_tvcards[btv->c.type].no_tda7432 && default:
bttv_I2CRead(btv, I2C_ADDR_TDA7432, "TDA7432") >=0) printk(KERN_WARNING "bttv%d: unknown audiodev value!\n",
request_module("tda7432"); btv->c.nr);
return;
}
/* There were no overrides, so now we try to discover this through the
card definition */
/* probe for msp3400 first: this driver can detect whether or not
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);
} 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);
}
/* If we found a msp34xx, then we're done. */
if (btv->sd_msp34xx)
return;
/* it might also be a tda7432. */
if (!bttv_tvcards[btv->c.type].no_tda7432) {
static const unsigned short addrs[] = {
I2C_ADDR_TDA7432 >> 1,
I2C_CLIENT_END
};
if (v4l2_i2c_new_probed_subdev(&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);
if (btv->sd_tvaudio)
return;
if (bttv_tvcards[btv->c.type].needs_tvaudio) no_audio:
request_module("tvaudio"); printk(KERN_WARNING "bttv%d: audio absent, no audio device found!\n",
btv->c.nr);
} }
...@@ -3626,6 +3750,7 @@ static int terratec_active_radio_upgrade(struct bttv *btv) ...@@ -3626,6 +3750,7 @@ static int terratec_active_radio_upgrade(struct bttv *btv)
printk("bttv%d: Terratec Active Radio Upgrade found.\n", printk("bttv%d: Terratec Active Radio Upgrade found.\n",
btv->c.nr); btv->c.nr);
btv->has_radio = 1; btv->has_radio = 1;
btv->has_saa6588 = 1;
btv->has_matchbox = 1; btv->has_matchbox = 1;
} else { } else {
btv->has_radio = 0; btv->has_radio = 0;
......
...@@ -1163,7 +1163,6 @@ audio_mux(struct bttv *btv, int input, int mute) ...@@ -1163,7 +1163,6 @@ audio_mux(struct bttv *btv, int input, int mute)
{ {
int gpio_val, signal; int gpio_val, signal;
struct v4l2_control ctrl; struct v4l2_control ctrl;
struct i2c_client *c;
gpio_inout(bttv_tvcards[btv->c.type].gpiomask, gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
bttv_tvcards[btv->c.type].gpiomask); bttv_tvcards[btv->c.type].gpiomask);
...@@ -1197,9 +1196,8 @@ audio_mux(struct bttv *btv, int input, int mute) ...@@ -1197,9 +1196,8 @@ audio_mux(struct bttv *btv, int input, int mute)
ctrl.id = V4L2_CID_AUDIO_MUTE; ctrl.id = V4L2_CID_AUDIO_MUTE;
ctrl.value = btv->mute; ctrl.value = btv->mute;
bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, &ctrl); bttv_call_all(btv, core, s_ctrl, &ctrl);
c = btv->i2c_msp34xx_client; if (btv->sd_msp34xx) {
if (c) {
struct v4l2_routing route; struct v4l2_routing route;
/* Note: the inputs tuner/radio/extern/intern are translated /* Note: the inputs tuner/radio/extern/intern are translated
...@@ -1238,15 +1236,14 @@ audio_mux(struct bttv *btv, int input, int mute) ...@@ -1238,15 +1236,14 @@ audio_mux(struct bttv *btv, int input, int mute)
break; break;
} }
route.output = MSP_OUTPUT_DEFAULT; route.output = MSP_OUTPUT_DEFAULT;
c->driver->command(c, VIDIOC_INT_S_AUDIO_ROUTING, &route); v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing, &route);
} }
c = btv->i2c_tvaudio_client; if (btv->sd_tvaudio) {
if (c) {
struct v4l2_routing route; struct v4l2_routing route;
route.input = input; route.input = input;
route.output = 0; route.output = 0;
c->driver->command(c, VIDIOC_INT_S_AUDIO_ROUTING, &route); v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, &route);
} }
return 0; return 0;
} }
...@@ -1332,7 +1329,7 @@ set_tvnorm(struct bttv *btv, unsigned int norm) ...@@ -1332,7 +1329,7 @@ set_tvnorm(struct bttv *btv, unsigned int norm)
break; break;
} }
id = tvnorm->v4l2_id; id = tvnorm->v4l2_id;
bttv_call_i2c_clients(btv, VIDIOC_S_STD, &id); bttv_call_all(btv, tuner, s_std, id);
return 0; return 0;
} }
...@@ -1476,7 +1473,7 @@ static int bttv_g_ctrl(struct file *file, void *priv, ...@@ -1476,7 +1473,7 @@ static int bttv_g_ctrl(struct file *file, void *priv,
case V4L2_CID_AUDIO_BALANCE: case V4L2_CID_AUDIO_BALANCE:
case V4L2_CID_AUDIO_BASS: case V4L2_CID_AUDIO_BASS:
case V4L2_CID_AUDIO_TREBLE: case V4L2_CID_AUDIO_TREBLE:
bttv_call_i2c_clients(btv, VIDIOC_G_CTRL, c); bttv_call_all(btv, core, g_ctrl, c);
break; break;
case V4L2_CID_PRIVATE_CHROMA_AGC: case V4L2_CID_PRIVATE_CHROMA_AGC:
...@@ -1550,12 +1547,12 @@ static int bttv_s_ctrl(struct file *file, void *f, ...@@ -1550,12 +1547,12 @@ static int bttv_s_ctrl(struct file *file, void *f,
if (btv->volume_gpio) if (btv->volume_gpio)
btv->volume_gpio(btv, c->value); btv->volume_gpio(btv, c->value);
bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, c); bttv_call_all(btv, core, s_ctrl, c);
break; break;
case V4L2_CID_AUDIO_BALANCE: case V4L2_CID_AUDIO_BALANCE:
case V4L2_CID_AUDIO_BASS: case V4L2_CID_AUDIO_BASS:
case V4L2_CID_AUDIO_TREBLE: case V4L2_CID_AUDIO_TREBLE:
bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, c); bttv_call_all(btv, core, s_ctrl, c);
break; break;
case V4L2_CID_PRIVATE_CHROMA_AGC: case V4L2_CID_PRIVATE_CHROMA_AGC:
...@@ -1973,7 +1970,7 @@ static int bttv_s_tuner(struct file *file, void *priv, ...@@ -1973,7 +1970,7 @@ static int bttv_s_tuner(struct file *file, void *priv,
return -EINVAL; return -EINVAL;
mutex_lock(&btv->lock); mutex_lock(&btv->lock);
bttv_call_i2c_clients(btv, VIDIOC_S_TUNER, t); bttv_call_all(btv, tuner, s_tuner, t);
if (btv->audio_mode_gpio) if (btv->audio_mode_gpio)
btv->audio_mode_gpio(btv, t, 1); btv->audio_mode_gpio(btv, t, 1);
...@@ -2018,7 +2015,7 @@ static int bttv_s_frequency(struct file *file, void *priv, ...@@ -2018,7 +2015,7 @@ static int bttv_s_frequency(struct file *file, void *priv,
return -EINVAL; return -EINVAL;
mutex_lock(&btv->lock); mutex_lock(&btv->lock);
btv->freq = f->frequency; btv->freq = f->frequency;
bttv_call_i2c_clients(btv, VIDIOC_S_FREQUENCY, f); bttv_call_all(btv, tuner, s_frequency, f);
if (btv->has_matchbox && btv->radio_user) if (btv->has_matchbox && btv->radio_user)
tea5757_set_freq(btv, btv->freq); tea5757_set_freq(btv, btv->freq);
mutex_unlock(&btv->lock); mutex_unlock(&btv->lock);
...@@ -2032,7 +2029,7 @@ static int bttv_log_status(struct file *file, void *f) ...@@ -2032,7 +2029,7 @@ static int bttv_log_status(struct file *file, void *f)
printk(KERN_INFO "bttv%d: ======== START STATUS CARD #%d ========\n", printk(KERN_INFO "bttv%d: ======== START STATUS CARD #%d ========\n",
btv->c.nr, btv->c.nr); btv->c.nr, btv->c.nr);
bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, NULL); bttv_call_all(btv, core, log_status);
printk(KERN_INFO "bttv%d: ======== END STATUS CARD #%d ========\n", printk(KERN_INFO "bttv%d: ======== END STATUS CARD #%d ========\n",
btv->c.nr, btv->c.nr); btv->c.nr, btv->c.nr);
return 0; return 0;
...@@ -2946,7 +2943,7 @@ static int bttv_g_tuner(struct file *file, void *priv, ...@@ -2946,7 +2943,7 @@ static int bttv_g_tuner(struct file *file, void *priv,
mutex_lock(&btv->lock); mutex_lock(&btv->lock);
t->rxsubchans = V4L2_TUNER_SUB_MONO; t->rxsubchans = V4L2_TUNER_SUB_MONO;
bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t); bttv_call_all(btv, tuner, g_tuner, t);
strcpy(t->name, "Television"); strcpy(t->name, "Television");
t->capability = V4L2_TUNER_CAP_NORM; t->capability = V4L2_TUNER_CAP_NORM;
t->type = V4L2_TUNER_ANALOG_TV; t->type = V4L2_TUNER_ANALOG_TV;
...@@ -3437,7 +3434,7 @@ static int radio_open(struct file *file) ...@@ -3437,7 +3434,7 @@ static int radio_open(struct file *file)
btv->radio_user++; btv->radio_user++;
bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL); bttv_call_all(btv, tuner, s_radio);
audio_input(btv,TVAUDIO_INPUT_RADIO); audio_input(btv,TVAUDIO_INPUT_RADIO);
mutex_unlock(&btv->lock); mutex_unlock(&btv->lock);
...@@ -3457,7 +3454,7 @@ static int radio_release(struct file *file) ...@@ -3457,7 +3454,7 @@ static int radio_release(struct file *file)
btv->radio_user--; btv->radio_user--;
bttv_call_i2c_clients(btv, RDS_CMD_CLOSE, &cmd); bttv_call_all(btv, core, ioctl, RDS_CMD_CLOSE, &cmd);
return 0; return 0;
} }
...@@ -3490,7 +3487,7 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) ...@@ -3490,7 +3487,7 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
strcpy(t->name, "Radio"); strcpy(t->name, "Radio");
t->type = V4L2_TUNER_RADIO; t->type = V4L2_TUNER_RADIO;
bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t); bttv_call_all(btv, tuner, g_tuner, t);
if (btv->audio_mode_gpio) if (btv->audio_mode_gpio)
btv->audio_mode_gpio(btv, t, 0); btv->audio_mode_gpio(btv, t, 0);
...@@ -3532,7 +3529,7 @@ static int radio_s_tuner(struct file *file, void *priv, ...@@ -3532,7 +3529,7 @@ static int radio_s_tuner(struct file *file, void *priv,
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t); bttv_call_all(btv, tuner, g_tuner, t);
return 0; return 0;
} }
...@@ -3593,7 +3590,7 @@ static ssize_t radio_read(struct file *file, char __user *data, ...@@ -3593,7 +3590,7 @@ static ssize_t radio_read(struct file *file, char __user *data,
cmd.instance = file; cmd.instance = file;
cmd.result = -ENODEV; cmd.result = -ENODEV;
bttv_call_i2c_clients(btv, RDS_CMD_READ, &cmd); bttv_call_all(btv, core, ioctl, RDS_CMD_READ, &cmd);
return cmd.result; return cmd.result;
} }
...@@ -3606,7 +3603,7 @@ static unsigned int radio_poll(struct file *file, poll_table *wait) ...@@ -3606,7 +3603,7 @@ static unsigned int radio_poll(struct file *file, poll_table *wait)
cmd.instance = file; cmd.instance = file;
cmd.event_list = wait; cmd.event_list = wait;
cmd.result = -ENODEV; cmd.result = -ENODEV;
bttv_call_i2c_clients(btv, RDS_CMD_POLL, &cmd); bttv_call_all(btv, core, ioctl, RDS_CMD_POLL, &cmd);
return cmd.result; return cmd.result;
} }
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <asm/io.h> #include <asm/io.h>
static int attach_inform(struct i2c_client *client);
static int i2c_debug; static int i2c_debug;
static int i2c_hw; static int i2c_hw;
static int i2c_scan; static int i2c_scan;
...@@ -266,51 +264,6 @@ static const struct i2c_algorithm bttv_algo = { ...@@ -266,51 +264,6 @@ static const struct i2c_algorithm bttv_algo = {
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* I2C functions - common stuff */ /* I2C functions - common stuff */
static int attach_inform(struct i2c_client *client)
{
struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
struct bttv *btv = to_bttv(v4l2_dev);
int addr=ADDR_UNSET;
if (ADDR_UNSET != bttv_tvcards[btv->c.type].tuner_addr)
addr = bttv_tvcards[btv->c.type].tuner_addr;
if (bttv_debug)
printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n",
btv->c.nr, client->driver->driver.name, client->addr,
client->name);
if (!client->driver->command)
return 0;
if (client->driver->id == I2C_DRIVERID_MSP3400)
btv->i2c_msp34xx_client = client;
if (client->driver->id == I2C_DRIVERID_TVAUDIO)
btv->i2c_tvaudio_client = client;
if (btv->tuner_type != TUNER_ABSENT) {
struct tuner_setup tun_setup;
if (addr == ADDR_UNSET || addr == client->addr) {
tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV | T_RADIO;
tun_setup.type = btv->tuner_type;
tun_setup.addr = addr;
bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup);
}
}
return 0;
}
void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
{
if (0 != btv->i2c_rc)
return;
i2c_clients_command(&btv->c.i2c_adap, cmd, arg);
}
/* read I2C */ /* read I2C */
int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for) int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for)
{ {
...@@ -417,8 +370,6 @@ int __devinit init_bttv_i2c(struct bttv *btv) ...@@ -417,8 +370,6 @@ int __devinit init_bttv_i2c(struct bttv *btv)
btv->c.i2c_adap.algo_data = &btv->i2c_algo; btv->c.i2c_adap.algo_data = &btv->i2c_algo;
} }
btv->c.i2c_adap.owner = THIS_MODULE; btv->c.i2c_adap.owner = THIS_MODULE;
btv->c.i2c_adap.class = I2C_CLASS_TV_ANALOG;
btv->c.i2c_adap.client_register = attach_inform;
btv->c.i2c_adap.dev.parent = &btv->c.pci->dev; btv->c.i2c_adap.dev.parent = &btv->c.pci->dev;
snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name), 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,10 +379,6 @@ int __devinit init_bttv_i2c(struct bttv *btv)
i2c_set_adapdata(&btv->c.i2c_adap, &btv->c.v4l2_dev); i2c_set_adapdata(&btv->c.i2c_adap, &btv->c.v4l2_dev);
btv->i2c_client.adapter = &btv->c.i2c_adap; btv->i2c_client.adapter = &btv->c.i2c_adap;
if (bttv_tvcards[btv->c.type].no_video)
btv->c.i2c_adap.class &= ~I2C_CLASS_TV_ANALOG;
if (bttv_tvcards[btv->c.type].has_dvb)
btv->c.i2c_adap.class |= I2C_CLASS_TV_DIGITAL;
if (btv->use_i2c_hw) { if (btv->use_i2c_hw) {
btv->i2c_rc = i2c_add_adapter(&btv->c.i2c_adap); btv->i2c_rc = i2c_add_adapter(&btv->c.i2c_adap);
......
...@@ -240,6 +240,9 @@ struct tvcard { ...@@ -240,6 +240,9 @@ struct tvcard {
unsigned int no_tda7432:1; unsigned int no_tda7432:1;
unsigned int needs_tvaudio:1; unsigned int needs_tvaudio:1;
unsigned int msp34xx_alt:1; unsigned int msp34xx_alt:1;
/* Note: currently no card definition needs to mark the presence
of a RDS saa6588 chip. If this is ever needed, then add a new
'has_saa6588' bit here. */
unsigned int no_video:1; /* video pci function is unused */ unsigned int no_video:1; /* video pci function is unused */
unsigned int has_dvb:1; unsigned int has_dvb:1;
...@@ -355,7 +358,9 @@ void bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits); ...@@ -355,7 +358,9 @@ void bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits);
/* ---------------------------------------------------------- */ /* ---------------------------------------------------------- */
/* i2c */ /* i2c */
extern void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg); #define bttv_call_all(btv, o, f, args...) \
v4l2_device_call_all(&btv->c.v4l2_dev, 0, o, f, ##args)
extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for); extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for);
extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
unsigned char b2, int both); unsigned char b2, int both);
......
...@@ -329,6 +329,7 @@ struct bttv { ...@@ -329,6 +329,7 @@ struct bttv {
unsigned int tuner_type; /* tuner chip type */ unsigned int tuner_type; /* tuner chip type */
unsigned int tda9887_conf; unsigned int tda9887_conf;
unsigned int svhs, dig; unsigned int svhs, dig;
unsigned int has_saa6588:1;
struct bttv_pll_info pll; struct bttv_pll_info pll;
int triton1; int triton1;
int gpioirq; int gpioirq;
...@@ -352,8 +353,8 @@ struct bttv { ...@@ -352,8 +353,8 @@ struct bttv {
int i2c_state, i2c_rc; int i2c_state, i2c_rc;
int i2c_done; int i2c_done;
wait_queue_head_t i2c_queue; wait_queue_head_t i2c_queue;
struct i2c_client *i2c_msp34xx_client; struct v4l2_subdev *sd_msp34xx;
struct i2c_client *i2c_tvaudio_client; struct v4l2_subdev *sd_tvaudio;
/* video4linux (1) */ /* video4linux (1) */
struct video_device *video_dev; struct video_device *video_dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment