1
0
Fork 0

V4L/DVB (10560): bttv: make tuner card info more consistent

The bttv card database structure had a "tuner" field that was the input
number of the tuner input or UNSET for no tuner.  However, the only values
it could ever be are 0 and UNSET.  Having a tuner on an input other than 0
didn't work and was never used.

There is also a "tuner_type" field that can be set to TUNER_ABSENT to
indicate no tuner, which makes "tuner = UNSET" redundant.  In many cases,
tuner_type was set to UNSET when there was no tuner, which isn't quite
correct.  tuner_type == UNSET is supposed to mean the tuner type isn't yet
known.

So, I changed cards where "tuner == UNSET" to always have tuner_type of
TUNER_ABSENT.  At this point the tuner field is redundant, so I deleted it.

I have the card setup code set the card's tuner_type (not the card type's
tuner_type!) to TUNER_ABSENT if it hasn't yet been set at the end of the
setup code.  Various places that check if the card has a tuner will now
look for this instead of checking the card type's "tuner" field.

Also autoload the tuner module before issuing the TUNER_SET_TYPE_ADDR I2C
client call instead of after issuing it.

Overall, on ia32 this decreases compiled code size by about 24 bytes and
reduces the data size by 640 bytes.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
hifive-unleashed-5.1
Trent Piepho 2009-01-28 21:32:59 -03:00 committed by Mauro Carvalho Chehab
parent 72134a6d51
commit abb0362f49
4 changed files with 77 additions and 230 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1356,8 +1356,8 @@ set_input(struct bttv *btv, unsigned int input, unsigned int norm)
} else {
video_mux(btv,input);
}
audio_input(btv,(input == bttv_tvcards[btv->c.type].tuner ?
TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN));
audio_input(btv, (btv->tuner_type != TUNER_ABSENT && input == 0) ?
TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN);
set_tvnorm(btv, norm);
}
@ -1907,7 +1907,7 @@ static int bttv_enum_input(struct file *file, void *priv,
i->type = V4L2_INPUT_TYPE_CAMERA;
i->audioset = 1;
if (i->index == bttv_tvcards[btv->c.type].tuner) {
if (btv->tuner_type != TUNER_ABSENT && i->index == 0) {
sprintf(i->name, "Television");
i->type = V4L2_INPUT_TYPE_TUNER;
i->tuner = 0;
@ -1971,7 +1971,7 @@ static int bttv_s_tuner(struct file *file, void *priv,
if (0 != err)
return err;
if (UNSET == bttv_tvcards[btv->c.type].tuner)
if (btv->tuner_type == TUNER_ABSENT)
return -EINVAL;
if (0 != t->index)
@ -2665,8 +2665,7 @@ static int bttv_querycap(struct file *file, void *priv,
if (no_overlay <= 0)
cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY;
if (bttv_tvcards[btv->c.type].tuner != UNSET &&
bttv_tvcards[btv->c.type].tuner != TUNER_ABSENT)
if (btv->tuner_type != TUNER_ABSENT)
cap->capabilities |= V4L2_CAP_TUNER;
return 0;
}
@ -2949,7 +2948,7 @@ static int bttv_g_tuner(struct file *file, void *priv,
struct bttv_fh *fh = priv;
struct bttv *btv = fh->btv;
if (UNSET == bttv_tvcards[btv->c.type].tuner)
if (btv->tuner_type == TUNER_ABSENT)
return -EINVAL;
if (0 != t->index)
return -EINVAL;
@ -3509,7 +3508,7 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
struct bttv_fh *fh = priv;
struct bttv *btv = fh->btv;
if (UNSET == bttv_tvcards[btv->c.type].tuner)
if (btv->tuner_type == TUNER_ABSENT)
return -EINVAL;
if (0 != t->index)
return -EINVAL;

View File

@ -286,12 +286,10 @@ static int attach_inform(struct i2c_client *client)
btv->i2c_msp34xx_client = client;
if (client->driver->id == I2C_DRIVERID_TVAUDIO)
btv->i2c_tvaudio_client = client;
if (btv->tuner_type != UNSET) {
if (btv->tuner_type != TUNER_ABSENT) {
struct tuner_setup tun_setup;
if ((addr==ADDR_UNSET) ||
(addr==client->addr)) {
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;

View File

@ -216,7 +216,6 @@ struct tvcard
char *name;
unsigned int video_inputs;
unsigned int audio_inputs;
unsigned int tuner;
unsigned int svhs;
unsigned int digital_mode; // DIGITAL_MODE_CAMERA or DIGITAL_MODE_VIDEO
u32 gpiomask;