REVIEW: bttv conversion to v4l2_subdev
Quoted 9 lines
Hi Hans,
Quoted 3 lines · On Sun, 15 Mar 2009 19:53:06 +0100 Hans Verkuil <[email protected]> wrote:
Quoted 2 lines · On Sunday 15 March 2009 18:28:42 Trent Piepho wrote:
Quoted 1 line · Hans Verkuil
On Sunday 15 March 2009 17:04:43 Trent Piepho wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · Hans Verkuil
Quoted 3 lines
Hi Mauro,
Can you review my ~hverkuil/v4l-dvb-bttv2 tree?
I'll review it during the week. This will likely take some time, since we need
to be sure that we will not cause any regressions on bttv.
No problem.
Quoted 3 lines
I appreciate if people could try the new driver and give us any feedback if
this works or not, and what boards are confirmed to work.
Please do. I have only one bttv card (Hauppauge WinTV with a msp3400), SO I cannot test any of the tvaudio and tda7432 devices.
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
It would be a lot easier if you would provide patch descriptions.
Here it is:
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
- bttv: convert to
v4l2_subdev.You aren't even trying. I could easily write two pages on this patch.
You are right. Mauro already knew about all this, but since I posted it to
linux-media as well I should have given a more detailed explanation.The better is to add such comments at the first patch of the series.
Quoted 8 lines
Since the patches change the user behaviour, it should, by default, work with
the broader range as possible of probing things.It should also print some warning messages about the use of deprecated module
parameters (instead of just removing a module and causing load and causing breakages).
No problem.
Quoted 3 lines
We should also provide some sort of documenting that this change happened, asking people to report troubles to [email protected].
Will do.
Quoted 11 lines
Quoted 7 lines
Here we go:
Quoted 1 line
What new module parameters did you add?
tvaudio to override the '
needs_tvaudio' from the card definition.At least on the first kernel with the new driver, IMO, the default should for
this option should be 1.
I disagree. If you set it to 1 then incorrect card definitions will never be detected. You have a new tvaudio module option that you can use to setup the right value and, when used, prints a log message telling the user to inform the mailinglist about it.
Quoted 25 lines
Quoted 13 lines
Quoted 2 lines
Why?
Since just modprobing a module manually will no longer work when the i2c autoprobing mechanism disappears. So you need a method to override it.
The main reason for doing this is if the card definition is incorrect.
Quoted 2 lines
What module parameters did
you delete?autoload
Quoted 7 lines
Quoted 1 line
Why?
You will always autoload, so it has become meaningless.
Quoted 1 line
How does one translate a existing modprobe.conf file?
Remove the autoload option.
If you just remove autoload, depmod/insmod will complain and not load it. We
should keep it with a deprecated warning message instead.
Quoted 8 lines
We can keep this warning up to a few kernel releases, to make sure that people
will be aware (like we did in the past with other deprecated modprobe functions).Since we're changing an userspace option, we should document it at the features
to deprecated doc in Kernel.
Will do.
Quoted 44 lines
Quoted 7 lines
Quoted 2 lines
Why are the i2c addresses from various i2c chips moved into the bttv driver?
It is now the adapter driver that tells the i2c core where to probe instead
of the other way around. The reason is that it is the adapter driver who has the knowledge where i2c chips are.This is bad. The I2C address is a property of the i2c adapter, not a property
of the bridge driver. We shouldn't hardcode I2C numbers inside bttv or other drivers. Maybe we can just create a .h file for each driver, with their
I2C addresses there... oh well, this will just create more complexity.Quoted 16 lines
Quoted 3 lines
Doesn't it make more sense that the addresses for chip X should be in the driver for chip X?
I do not want to make too many changes, but when all v4l drivers are converted I will revisit this issue. I'm thinking of adding an inline function like this in the header belonging to each i2c driver (in
include/media):static inline const unsigned short
*tvaudio_addrs(void){ static const unsigned short addrs[] = { ... }; return addrs; }Quoted 4 lines
Then you can use that in the adapter driver. It's only relevant if you do
not know the exact address, since it is always better to use that if you know it.This seems even worse. The problem is not related with a I2C range, but with
the fact that msp3400 were designed by the manufacturer to work at the address
with addresses0x40or0x44. There's no practical way (or reason) for any bttv
vendor to use msp3400 on any other address.
Quoted 2 lines
So, the bttv and other adapter should only use either one of those two i2c addresses if they're trying to talk with msp3400.
Not sure what your point is. That's exactly what is happening. And as I stated it is my intention to move the list of possible addresses supported by an i2c device to the device's header in include/media. But I prefer to do that *after* all drivers are converted to v4l2_subdev so that I have a good overview of how the various devices are probed.
If you insist I can do this part first, but I'd really rather do it afterwards as part of a final cleanup sweep.
Quoted 11 lines
Quoted 10 lines
Quoted 1 line
How has module loading changed? Can one no longer *not* autoload
modules
Quoted 1 line
if you are trying to test drivers that are not installed in
/lib/modules?The adapter driver initiates loading of the i2c modules and probes for and
attaches to the i2c devices. Just doing 'modprobe foo' will no longer cause
it to attach to any i2c adapter.
Quoted 6 lines
I think that Trent's talking about a different issue. Since nobody knows what
boards will be broken by this changeset, and assuming that this can happen, it
is important to have some options for the user to change the behaviour, to reproduce what we had before.
That's why I added the tvaudio module option.
Quoted 10 lines
So, currently, if you load bttv with:
bttv autoload=0Any user can just load the drivers he knows that it works with his device, avoiding to load other drivers that could cause troubles.
IMO, we should have something like this, to offer as an option. Maybe something like:
bttv probe_only_i2c_addresses=0x40,0x48,0x60
As far as I can tell this isn't needed at all and only makes things complicated for the user. If you really want to go this way, then we should add an msp3400 and tda7432 option alongside the tvaudio option. That way you can enable/disable each module that bttv needs. I believe that there is no need for this since msp3400 already detects whether it found a msp3400 or not, and tda7432 doesn't conflict with anything as far as I am aware.
Regards,
Hans
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG
Quoted 10 lines · On Mon, 16 Mar 2009 11:44:12 +0100 (CET) "Hans Verkuil" <[email protected]>…
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
What new module parameters did you add?
tvaudio to override the '
needs_tvaudio' from the card definition.At least on the first kernel with the new driver, IMO, the default should for
this option should be 1.I disagree. If you set it to 1 then incorrect card definitions will never be detected.
Good point. Yet, we should try to minimize troubles to the end user. I suspect that we'll have more problems by disabling it than if we enable it.
Quoted 3 lines
You have a new tvaudio module option that you can use to setup the right value and, when used, prints a log message telling the user to inform the mailinglist about it.
Filling tvaudio with lots of options won't help if the user doesn't know what should he do. It seems that we'll need some kind of FAQ describing how can an user replicate the behaviour that he had with bttv with the new way.
Quoted 12 lines
Quoted 11 lines
This seems even worse. The problem is not related with a I2C range, but with
the fact that msp3400 were designed by the manufacturer to work at the address
with addresses0x40or0x44. There's no practical way (or reason) for any bttv
vendor to use msp3400 on any other address.So, the bttv and other adapter should only use either one of those two i2c addresses if they're trying to talk with msp3400.
Quoted 8 lines
Not sure what your point is. That's exactly what is happening. And as I stated it is my intention to move the list of possible addresses supported by an i2c device to the device's header in
include/media. But I prefer to do that *after* all drivers are converted tov4l2_subdevso that I have a good overview of how the various devices are probed.If you insist I can do this part first, but I'd really rather do it afterwards as part of a final cleanup sweep.
This can be done on a final step.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 1 line
How has module loading changed? Can one no longer *not* autoload
modules
Quoted 1 line
if you are trying to test drivers that are not installed in
/lib/modules?The adapter driver initiates loading of the i2c modules and probes for and
attaches to the i2c devices. Just doing 'modprobe foo' will no longer cause
it to attach to any i2c adapter.
Quoted 8 lines
Quoted 6 lines
I think that Trent's talking about a different issue. Since nobody knows what
boards will be broken by this changeset, and assuming that this can happen, it
is important to have some options for the user to change the behaviour, to reproduce what we had before.That's why I added the tvaudio module option.
See above. We should describe what options will now be needed, when converting from a legacy /etc/modprobe.conf into a new one, while keeping the driver working.
Quoted 12 lines
Quoted 11 lines
So, currently, if you load bttv with:
bttv autoload=0Any user can just load the drivers he knows that it works with his device, avoiding to load other drivers that could cause troubles.
IMO, we should have something like this, to offer as an option. Maybe something like:
bttv probe_only_i2c_addresses=0x40,0x48,0x60
Quoted 7 lines
As far as I can tell this isn't needed at all and only makes things complicated for the user. If you really want to go this way, then we should add an msp3400 and tda7432 option alongside the tvaudio option. That way you can enable/disable each module that bttv needs. I believe that there is no need for this since msp3400 already detects whether it found a msp3400 or not, and tda7432 doesn't conflict with anything as far as I am aware.
I'm not concerned with things that we are aware, but with things we aren't.
We're touching hardly on a driver that none of us has a complete domain. It is old, designed during kernel 2.2, supports a huge number of different boards will all sorts of eccentricities, etc.
I wouldn't doubt if some device has some I2C chipset that we aren't aware (and currently untouched, when autoprobe=0). For example, some i2c chip at tda7432 and the new behaviour will incorrectly set it to wrong values since right now autoload can't be disabled.
Cheers,
Mauro
Quoted 6 lines · On Mon, 16 Mar 2009 11:44:12 +0100 (CET) "Hans Verkuil" <[email protected]>…
Quoted 6 lines
Hi Hans,
On Sun, 15 Mar 2009 19:53:06 +0100
Hans Verkuil <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · On Sunday 15 March 2009 18:28:42 Trent Piepho wrote:
Quoted 6 lines · Hans Verkuil
Quoted 5 lines · On Sunday 15 March 2009 17:04:43 Trent Piepho wrote:
Quoted 4 lines · Hans Verkuil
Quoted 3 lines
Hi Mauro,
Can you review my ~hverkuil/v4l-dvb-bttv2 tree?
Except for that small issue with tvaudio that I've already pointed, I've reviewed all but the last one.
Since the last one is the one that do most of the job, and, in order to help me and others to review and comment IMO, it is better to send the it through the ML as a patch. This way, people can reply on it, if needed.
So, here it is:
---
# HG changeset patch
# User Hans Verkuil <[email protected]>
# Date 1237118835 -3600
# Node ID 2b8fedc4d5ab72728ffc9e3f105758bb506eb2db # Parent f97862ee5dcf20923902fd7795200a59b3be4535
bttv: convert to v4l2_subdev.
From: Hans Verkuil <[email protected]>
Priority: normal
linux/drivers/media/video/bt8xx/bttv-cards.c +100 -32
@@ -97,12 +97,8 @@ static unsigned int tuner[BTTV_MAX] = {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 remote[BTTV_MAX ] = { [0 ... (BTTV_MAX -1 ) ] =UNSET }; +static unsigned int tvaudio[BTTV_MAX ] = { [0 ... (BTTV_MAX -1 )] =UNSET };static struct bttv *master[BTTV_MAX ] = { [0 ... (BTTV_MAX -1 ) ] =NULL }; -#ifdef MODULE -static unsigned int autoload =1 ; -#else -static unsigned int autoload; -#endif static unsigned int gpiomask =UNSET ;static unsigned int audioall =UNSET ;static unsigned int audiomux[5 ] = { [0 ...4 ] =UNSET };
@@ -114,13 +110,13 @@ module_param(latency, int, 0444);module_param (latency, int,0444 );module_param (gpiomask, int,0444 );module_param (audioall, int,0444 ); -module_param (autoload, int,0444 );module_param_array (card, int,NULL ,0444 );module_param_array (pll, int,NULL ,0444 );module_param_array (tuner, int,NULL ,0444 );module_param_array (svhs, int,NULL ,0444 );module_param_array (remote, int,NULL ,0444 ); +module_param_array (tvaudio, int,NULL ,0444 );module_param_array (audiomux, int,NULL ,0444 ); MODULE_PARM_DESC(triton1,"set ETBF pci config bit "
@@ -131,7 +127,8 @@ MODULE_PARM_DESC(card,"specify TV/grabbeMODULE_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 (tuner,"specify installed tuner type" ); -MODULE_PARM_DESC (autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)" ); +MODULE_PARM_DESC (tvaudio,"specify whether tvaudio should be loaded (1) or not (0)," +" default is autodetect" );MODULE_PARM_DESC (no_overlay,"allow override overlay default (0 disables, 1 enables)" " [some VIA/SIS chipsets are known to have problem with overlay]" );
@@ -3333,8 +3330,10 @@ void __devinit bttv_init_card2(struct btvoid __devinit bttv_init_card2 (struct bttv *btv) {int addr=ADDR_UNSET ; +int load_tvaudio = tvaudio[btv->c.nr]; btv->tuner_type =UNSET ; + btv->has_saa6588 = bttv_tvcards[btv->c.type].has_saa6588;if (BTTV_BOARD_UNKNOWN == btv->c.type) {bttv_readee (btv,eeprom_data,0xa0 );
@@ -3502,8 +3501,13 @@ void __devinit bttv_init_card2(struct btstruct tuner_setup tun_setup;/* Load tuner module before issuing tuner config call! */ -if (autoload) -request_module ("tuner" ); +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;
@@ -3512,7 +3516,7 @@ void __devinit bttv_init_card2(struct btif (bttv_tvcards[btv->c.type].has_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) {
@@ -3521,7 +3525,7 @@ void __devinit bttv_init_card2(struct bt tda9887_cfg.tuner =TUNER_TDA9887 ; 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 ?
@@ -3544,31 +3548,94 @@ void __devinit bttv_init_card2(struct btif (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 )return ;/* no tuner or related drivers to load */ +if (btv->has_saa6588) { +/* Probe for RDS receiver chip */ +static const unsigned short addrs[] = { +0x20 >>1 , +0x22 >>1 , +I2C_CLIENT_END + }; + + btv->sd_rds =v4l2_i2c_new_probed_subdev (&btv->c.i2c_adap, +"saa6588" ,"saa6588" , addrs); + } +/* 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 && -bttv_I2CRead (btv,I2C_ADDR_MSP3400_ALT ,"MSP34xx (alternate address)" ) >=0 ) -request_module ("msp3400" ); - -if (!bttv_tvcards[btv->c.type].no_tda9875 && -bttv_I2CRead (btv,I2C_ADDR_TDA9875 ,"TDA9875" ) >=0 ) -request_module ("tda9875" ); - -if (!bttv_tvcards[btv->c.type].no_tda7432 && -bttv_I2CRead (btv,I2C_ADDR_TDA7432 ,"TDA7432" ) >=0 ) -request_module ("tda7432" ); - -if (bttv_tvcards[btv->c.type].needs_tvaudio) -request_module ("tvaudio" ); + +/* 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].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); + }else 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); + } + +/* If we found a msp34xx, then we're done. */ +if (btv->sd_msp34xx) +return ; + +if (load_tvaudio !=UNSET ) { +printk (KERN_INFO "bttv%d: if you need to set the tvaudio module option to %d, then the\n" , + btv->c.nr, load_tvaudio); +printk (KERN_INFO "bttv%d: definition for card type %d needs to be updated.\n" , + btv->c.nr, btv->c.type); +printk (KERN_INFO "bttv%d: please report this to the bttv maintainer.\n" , btv->c.nr); + }else { +/* tda9875 is now also handled by tvaudio. It used to be +handled by the tda9875 module, but that causes problems +in detecting whether you have a tda9874 or tda9875. It is +better to use tvaudio for both. */ + load_tvaudio = bttv_tvcards[btv->c.type].needs_tvaudio || + !bttv_tvcards[btv->c.type].no_tda9875; + } + +/* Now see if we can find one of the tvaudio devices. */ +if (load_tvaudio) { +static const unsigned short 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 + }; + + btv->sd_tvaudio =v4l2_i2c_new_probed_subdev (&btv->c.i2c_adap, +"tvaudio" ,"tvaudio" , addrs); +/* If we found a device supported by tvaudio, then we're done +as well. */ +if (btv->sd_tvaudio) +return ; + } +/* Last possibility: it might be a tda7432. */ +if (!bttv_tvcards[btv->c.type].no_tda7432) { +static const unsigned short addrs[] = { +I2C_ADDR_TDA7432 >>1 , +I2C_CLIENT_END + }; + +v4l2_i2c_new_probed_subdev (&btv->c.i2c_adap,"tda7432" , +"tda7432" , addrs); + } }
@@ -3640,6 +3707,7 @@ static int terratec_active_radio_upgradeprintk ("bttv%d: Terratec Active Radio Upgrade found.\n" , btv->c.nr); btv->has_radio =1 ; + btv->has_saa6588 =1 ; btv->has_matchbox =1 ; }else { btv->has_radio =0 ;
linux/drivers/media/video/bt8xx/bttv-driver.c +20 -23
147 lines not on this page · raw message
linux/drivers/media/video/bt8xx/bttv-i2c.c +4 -48
81 lines not on this page · raw message
linux/drivers/media/video/bt8xx/bttv.h +4 -1
@@ -242,6 +242,7 @@ struct tvcard { unsigned int msp34xx_alt:1; unsigned int no_video:1; /* video pci function is unused */ + unsigned int has_saa6588:1; unsigned int has_dvb:1; unsigned int has_remote:1; unsigned int has_radio:1;
@@ -357,7 +358,9 @@ void bttv_gpio_bits(struct bttv_core *co/* ---------------------------------------------------------- */ /* 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_I2CWrite (struct bttv *btv,unsigned char addr,unsigned char b1,unsigned char b2,int both);
linux/drivers/media/video/bt8xx/bttvp.h +4 -2
@@ -331,6 +331,7 @@ struct bttv {unsigned int tuner_type;/* tuner chip type */ unsigned int tda9887_conf;unsigned int svhs, dig; +int has_saa6588;struct bttv_pll_info pll;int triton1;int gpioirq;
@@ -354,8 +355,9 @@ struct bttv {int i2c_state, i2c_rc;int i2c_done;wait_queue_head_t i2c_queue; -struct i2c_client *i2c_msp34xx_client; -struct i2c_client *i2c_tvaudio_client; +struct v4l2_subdev *sd_msp34xx; +struct v4l2_subdev *sd_tvaudio; +struct v4l2_subdev *sd_rds;/* video4linux (1) */ struct video_device *video_dev;
Quoted 1 line · On Mon, 16 Mar 2009 08:09:44 -0300 Mauro Carvalho Chehab…
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Can you review my ~hverkuil/v4l-dvb-bttv2 tree?
Ok, it was not that hard. It follows my comments.
Quoted 17 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +1
-5@@ -97,12 +97,8 @@ static unsigned int tuner[BTTV_MAX] = {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 remote[BTTV_MAX ] = { [0 ... (BTTV_MAX -1 ) ] =UNSET }; +static unsigned int tvaudio[BTTV_MAX ] = { [0 ... (BTTV_MAX -1 )] =UNSET };static struct bttv *master[BTTV_MAX ] = { [0 ... (BTTV_MAX -1 ) ] =NULL }; -#ifdef MODULE -static unsigned int autoload =1 ; -#else -static unsigned int autoload; -#endif static unsigned int gpiomask =UNSET ;static unsigned int audioall =UNSET ;static unsigned int audiomux[5 ] = { [0 ...4 ] =UNSET };
linux/drivers/media/video/bt8xx/bttv-cards.c module_param(latency, int, 0444); · line 117
Quoted 4 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +0
-1@@ -114,13 +110,13 @@ module_param(latency, int, 0444);module_param (latency, int,0444 );module_param (gpiomask, int,0444 );module_param (audioall, int,0444 ); -module_param (autoload, int,0444 );
As already discussed, instead of removing, just print some warning if people use this parameter. The printed message should ideally direct to some wiki page commenting about the changes, and explaining how to emulate the previous behaviour where such parameter were needed.
Quoted 34 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +5
-1module_param_array (card, int,NULL ,0444 );module_param_array (pll, int,NULL ,0444 );module_param_array (tuner, int,NULL ,0444 );module_param_array (svhs, int,NULL ,0444 );module_param_array (remote, int,NULL ,0444 ); +module_param_array (tvaudio, int,NULL ,0444 );module_param_array (audiomux, int,NULL ,0444 ); MODULE_PARM_DESC(triton1,"set ETBF pci config bit "@@ -131,7 +127,8 @@ MODULE_PARM_DESC(card,"specify TV/grabbeMODULE_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 (tuner,"specify installed tuner type" ); -MODULE_PARM_DESC (autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)" ); +MODULE_PARM_DESC (tvaudio,"specify whether tvaudio should be loaded (1) or not (0)," +" default is autodetect" );MODULE_PARM_DESC (no_overlay,"allow override overlay default (0 disables, 1 enables)" " [some VIA/SIS chipsets are known to have problem with overlay]" );@@ -3333,8 +3330,10 @@ void __devinit bttv_init_card2(struct btvoid __devinit bttv_init_card2 (struct bttv *btv) {int addr=ADDR_UNSET ; +int load_tvaudio = tvaudio[btv->c.nr]; btv->tuner_type =UNSET ; + btv->has_saa6588 = bttv_tvcards[btv->c.type].has_saa6588;if (BTTV_BOARD_UNKNOWN == btv->c.type) {bttv_readee (btv,eeprom_data,0xa0 );@@ -3502,8 +3501,13 @@ void __devinit bttv_init_card2(struct btstruct tuner_setup tun_setup;
linux/drivers/media/video/bt8xx/bttv-cards.c void __devinit bttv_init_card2(struct bt · line 3510
Quoted 10 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +7
-2/* Load tuner module before issuing tuner config call! */ -if (autoload) -request_module ("tuner" ); +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 ));
There are several bttv boards without tuner. In fact, those are becoming a more common setup with bttv, since there are still several surveillance boards with bttv being selled in the market. We should test if !TUNER_ABSENT before doing the probe for a tuner.
Quoted 60 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +14
-22tun_setup.mode_mask =T_ANALOG_TV |T_DIGITAL_TV ; tun_setup.type = btv->tuner_type;@@ -3512,7 +3516,7 @@ void __devinit bttv_init_card2(struct btif (bttv_tvcards[btv->c.type].has_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) {@@ -3521,7 +3525,7 @@ void __devinit bttv_init_card2(struct bt tda9887_cfg.tuner =TUNER_TDA9887 ; 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 ?@@ -3544,31 +3548,94 @@ void __devinit bttv_init_card2(struct btif (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 )return ;/* no tuner or related drivers to load */ +if (btv->has_saa6588) { +/* Probe for RDS receiver chip */ +static const unsigned short addrs[] = { +0x20 >>1 , +0x22 >>1 , +I2C_CLIENT_END + }; + + btv->sd_rds =v4l2_i2c_new_probed_subdev (&btv->c.i2c_adap, +"saa6588" ,"saa6588" , addrs); + } +/* 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 && -bttv_I2CRead (btv,I2C_ADDR_MSP3400_ALT ,"MSP34xx (alternate address)" ) >=0 ) -request_module ("msp3400" ); - -if (!bttv_tvcards[btv->c.type].no_tda9875 && -bttv_I2CRead (btv,I2C_ADDR_TDA9875 ,"TDA9875" ) >=0 ) -request_module ("tda9875" ); - -if (!bttv_tvcards[btv->c.type].no_tda7432 && -bttv_I2CRead (btv,I2C_ADDR_TDA7432 ,"TDA7432" ) >=0 ) -request_module ("tda7432" ); - -if (bttv_tvcards[btv->c.type].needs_tvaudio)
linux/drivers/media/video/bt8xx/bttv-cards.c void __devinit bttv_init_card2(struct bt · line 3575
Quoted 10 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +9
-1-request_module ("tvaudio" ); + +/* 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].msp34xx_alt) { +static const unsigned short addrs[] = { +I2C_ADDR_MSP3400_ALT >>1 , +I2C_CLIENT_END + };
Why aren't you probing first at I2C_ADDR_MSP3400? You're changing the behaviour here. It is better to probe at the same order as the previous version.
linux/drivers/media/video/bt8xx/bttv-cards.c void __devinit bttv_init_card2(struct bt · line 3587
Quoted 12 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +12
-0+ + btv->sd_msp34xx =v4l2_i2c_new_probed_subdev (&btv->c.i2c_adap, +"msp3400" ,"msp3400" , addrs); + }else 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); + }
Why do you need to probe it twice? Shouldn't it be just one probing for both addresses?
linux/drivers/media/video/bt8xx/bttv-cards.c void __devinit bttv_init_card2(struct bt · line 3598
Quoted 11 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +11
-0+ +/* If we found a msp34xx, then we're done. */ +if (btv->sd_msp34xx) +return ; + +if (load_tvaudio !=UNSET ) { +printk (KERN_INFO "bttv%d: if you need to set the tvaudio module option to %d, then the\n" , + btv->c.nr, load_tvaudio); +printk (KERN_INFO "bttv%d: definition for card type %d needs to be updated.\n" , + btv->c.nr, btv->c.type); +printk (KERN_INFO "bttv%d: please report this to the bttv maintainer.\n" , btv->c.nr);
This is not what I call "tvaudio autodectect" (that should be the default way, as the comments for tvaudio option states).
A bttv board should have some audio chip otherwise audio won't work.
I dunno if is there any supported card without audio at all, but probably, if we have, this is by far much less than boards with an audio chip.
Based on this principle, IMO, the probing function should, by default, probe for tvaudio, if it doesn't find another audio device. You may eventually ask for people to report, to warn us that the board entry is broken, but we shouln't intentionally break a device that we're almost sure that requires tvaudio or tda7432.
Quoted 12 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +12
-0+ }else { +/* tda9875 is now also handled by tvaudio. It used to be +handled by the tda9875 module, but that causes problems +in detecting whether you have a tda9874 or tda9875. It is +better to use tvaudio for both. */ + load_tvaudio = bttv_tvcards[btv->c.type].needs_tvaudio || + !bttv_tvcards[btv->c.type].no_tda9875; + } + +/* Now see if we can find one of the tvaudio devices. */ +if (load_tvaudio) { + static const unsigned short addrs[] = {
linux/drivers/media/video/bt8xx/bttv-cards.c void __devinit bttv_init_card2(struct bt · line 3620
Quoted 10 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +10
-0+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 + };
We should preserve the same probing order as before, in order to reduce breakage risks.
Quoted 8 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +8
-0+ + btv->sd_tvaudio =v4l2_i2c_new_probed_subdev (&btv->c.i2c_adap, +"tvaudio" ,"tvaudio" , addrs); +/* If we found a device supported by tvaudio, then we're done +as well. */ +if (btv->sd_tvaudio) +return ; + }
linux/drivers/media/video/bt8xx/bttv-cards.c void __devinit bttv_init_card2(struct bt · line 3638
Quoted 10 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +10
-0+/* Last possibility: it might be a tda7432. */ +if (!bttv_tvcards[btv->c.type].no_tda7432) { +static const unsigned short addrs[] = { +I2C_ADDR_TDA7432 >>1 , +I2C_CLIENT_END + }; + +v4l2_i2c_new_probed_subdev (&btv->c.i2c_adap,"tda7432" , +"tda7432" , addrs); + }
No audio module found. This requires printing a warning, since the board won't have audio working.
Quoted 196 lines
linux/drivers/media/video/bt8xx/bttv-cards.c +1
-0}@@ -3640,6 +3707,7 @@ static int terratec_active_radio_upgradeprintk ("bttv%d: Terratec Active Radio Upgrade found.\n" , btv->c.nr); btv->has_radio =1 ; + btv->has_saa6588 =1 ; btv->has_matchbox =1 ; }else { btv->has_radio =0 ;linux/drivers/media/video/bt8xx/bttv-driver.c +20
-23@@ -1181,7 +1181,6 @@ audio_mux(struct bttv *btv, int input, i {int gpio_val, signal;struct v4l2_control ctrl; -struct i2c_client *c;gpio_inout (bttv_tvcards[btv->c.type].gpiomask, bttv_tvcards[btv->c.type].gpiomask);@@ -1220,9 +1219,8 @@ audio_mux(struct bttv *btv, int input, i ctrl.id =V4L2_CID_AUDIO_MUTE ; ctrl.value = btv->mute; -bttv_call_i2c_clients (btv,VIDIOC_S_CTRL , &ctrl); - c = btv->i2c_msp34xx_client; -if (c) { +bttv_call_all (btv, core, s_ctrl, &ctrl); +if (btv->sd_msp34xx) {struct v4l2_routing route;/* Note: the inputs tuner/radio/extern/intern are translated @@ -1261,15 +1259,14 @@ audio_mux(struct bttv *btv, int input, ibreak ; } route.output =MSP_OUTPUT_DEFAULT ; - c->driver->command (c,VIDIOC_INT_S_AUDIO_ROUTING , &route); - } - c = btv->i2c_tvaudio_client; -if (c) { +v4l2_subdev_call (btv->sd_msp34xx, audio, s_routing, &route); + } +if (btv->sd_tvaudio) {struct v4l2_routing route; route.input = input; 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 ; }@@ -1360,7 +1357,7 @@ set_tvnorm(struct bttv *btv, unsigned in#endif } id = tvnorm->v4l2_id; -bttv_call_i2c_clients (btv,VIDIOC_S_STD , &id); +bttv_call_all (btv, tuner, s_std, id);return 0 ; }@@ -1504,7 +1501,7 @@ static int bttv_g_ctrl(struct file *filecase V4L2_CID_AUDIO_BALANCE :case V4L2_CID_AUDIO_BASS :case V4L2_CID_AUDIO_TREBLE : -bttv_call_i2c_clients (btv,VIDIOC_G_CTRL , c); +bttv_call_all (btv, core, g_ctrl, c);break ;case V4L2_CID_PRIVATE_CHROMA_AGC :@@ -1578,12 +1575,12 @@ static int bttv_s_ctrl(struct file *fileif (btv->volume_gpio) btv->volume_gpio (btv, c->value); -bttv_call_i2c_clients (btv,VIDIOC_S_CTRL , c); +bttv_call_all (btv, core, s_ctrl, c);break ;case V4L2_CID_AUDIO_BALANCE :case V4L2_CID_AUDIO_BASS :case V4L2_CID_AUDIO_TREBLE : -bttv_call_i2c_clients (btv,VIDIOC_S_CTRL , c); +bttv_call_all (btv, core, s_ctrl, c);break ;case V4L2_CID_PRIVATE_CHROMA_AGC :@@ -2001,7 +1998,7 @@ static int bttv_s_tuner(struct file *filreturn -EINVAL ;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) btv->audio_mode_gpio (btv, t,1 );@@ -2046,7 +2043,7 @@ static int bttv_s_frequency(struct filereturn -EINVAL ;mutex_lock (&btv->lock); 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)tea5757_set_freq (btv, btv->freq);mutex_unlock (&btv->lock);@@ -2060,7 +2057,7 @@ static int bttv_log_status(struct file *printk (KERN_INFO "bttv%d: ======== START STATUS CARD #%d ========\n" , 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" , btv->c.nr, btv->c.nr);return 0 ;@@ -2976,7 +2973,7 @@ static int bttv_g_tuner(struct file *filmutex_lock (&btv->lock); 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" ); t->capability =V4L2_TUNER_CAP_NORM ; t->type =V4L2_TUNER_ANALOG_TV ;@@ -3467,7 +3464,7 @@ static int radio_open(struct file *file) 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 );mutex_unlock (&btv->lock);@@ -3487,7 +3484,7 @@ static int radio_release(struct file *fi btv->radio_user--; -bttv_call_i2c_clients (btv,RDS_CMD_CLOSE , &cmd); +bttv_call_all (btv, core, ioctl,RDS_CMD_CLOSE , &cmd);return 0 ; }@@ -3520,7 +3517,7 @@ static int radio_g_tuner(struct file *fistrcpy (t->name,"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) btv->audio_mode_gpio (btv, t,0 );@@ -3562,7 +3559,7 @@ static int radio_s_tuner(struct file *fiif (0 != t->index)return -EINVAL ; -bttv_call_i2c_clients (btv,VIDIOC_G_TUNER , t); +bttv_call_all (btv, tuner, g_tuner, t);return 0 ; }@@ -3623,7 +3620,7 @@ static ssize_t radio_read(struct file *f cmd.instance = file; 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; }@@ -3636,7 +3633,7 @@ static unsigned int radio_poll(struct fi cmd.instance = file; cmd.event_list = wait; 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; }linux/drivers/media/video/bt8xx/bttv-i2c.c +0
-7@@ -35,8 +35,6 @@#include <media/v4l2-common.h> #include <linux/jiffies.h> #include <asm/io.h> - -static int attach_inform (struct i2c_client *client);static int i2c_debug;static int i2c_hw;@@ -269,51 +267,6 @@ static const struct i2c_algorithm bttv_a/* ----------------------------------------------------------------------- */ /* 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 ;
linux/drivers/media/video/bt8xx/bttv-i2c.c static const struct i2c_algorithm bttv_a · line 286
Quoted 10 lines
linux/drivers/media/video/bt8xx/bttv-i2c.c +0
-10- - -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);
It is still valid to print a message when a device is attached at i2c bus, for debugging purposes.
Quoted 81 lines
linux/drivers/media/video/bt8xx/bttv-i2c.c +4
-31-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 */ int bttv_I2CRead (struct bttv *btv,unsigned char addr,char *probe_for) {@@ -424,8 +377,9 @@ int __devinit init_bttv_i2c(struct bttv btv->c.i2c_adap.algo_data = &btv->i2c_algo; } btv->c.i2c_adap.owner =THIS_MODULE ; +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,22 ) btv->c.i2c_adap.class =I2C_CLASS_TV_ANALOG ; - btv->c.i2c_adap.client_register = attach_inform; +#endif btv->c.i2c_adap.dev.parent = &btv->c.pci->dev; snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name),@@ -435,10 +389,12 @@ int __devinit init_bttv_i2c(struct bttvi2c_set_adapdata (&btv->c.i2c_adap, &btv->c.v4l2_dev); btv->i2c_client.adapter = &btv->c.i2c_adap; +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,22 )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 ; +#endif if (btv->use_i2c_hw) { btv->i2c_rc =i2c_add_adapter (&btv->c.i2c_adap);linux/drivers/media/video/bt8xx/bttv.h +4
-1@@ -242,6 +242,7 @@ struct tvcard { unsigned int msp34xx_alt:1; unsigned int no_video:1; /* video pci function is unused */ + unsigned int has_saa6588:1; unsigned int has_dvb:1; unsigned int has_remote:1; unsigned int has_radio:1;@@ -357,7 +358,9 @@ void bttv_gpio_bits(struct bttv_core *co/* ---------------------------------------------------------- */ /* 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_I2CWrite (struct bttv *btv,unsigned char addr,unsigned char b1,unsigned char b2,int both);
linux/drivers/media/video/bt8xx/bttvp.h struct bttv { · line 334
Quoted 4 lines
linux/drivers/media/video/bt8xx/bttvp.h +1
-0@@ -331,6 +331,7 @@ struct bttv {unsigned int tuner_type;/* tuner chip type */ unsigned int tda9887_conf;unsigned int svhs, dig; +int has_saa6588;
Does it need to be a 32 or 64 bit integer?
Quoted 17 lines
linux/drivers/media/video/bt8xx/bttvp.h +3
-3struct bttv_pll_info pll;int triton1;int gpioirq;@@ -354,8 +355,9 @@ struct bttv {int i2c_state, i2c_rc;int i2c_done;wait_queue_head_t i2c_queue; -struct i2c_client *i2c_msp34xx_client; -struct i2c_client *i2c_tvaudio_client; +struct v4l2_subdev *sd_msp34xx; +struct v4l2_subdev *sd_tvaudio; +struct v4l2_subdev *sd_rds;/* video4linux (1) */ struct video_device *video_dev; --
Quoted 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers,
Mauro