diff options
Diffstat (limited to 'linux/drivers/media/video')
-rw-r--r-- | linux/drivers/media/video/tuner-core.c | 122 |
1 files changed, 59 insertions, 63 deletions
diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index 627edeff0..917d932b2 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -1,5 +1,5 @@ /* - * $Id: tuner-core.c,v 1.50 2005/07/06 03:33:43 mchehab Exp $ + * $Id: tuner-core.c,v 1.51 2005/07/06 09:42:19 mchehab Exp $ * * i2c tv tuner chip device driver * core core, i.e. kernel interfaces, registering and so on @@ -120,25 +120,23 @@ static void set_freq(struct i2c_client *c, unsigned long freq) struct tuner *t = i2c_get_clientdata(c); switch (t->mode) { - case T_RADIO: + case V4L2_TUNER_RADIO: tuner_dbg("radio freq set to %lu.%02lu\n", freq / 16000, freq % 16000 * 100 / 16000); set_radio_freq(c, freq); break; - case T_ANALOG_TV: - case T_DIGITAL_TV: + case V4L2_TUNER_ANALOG_TV: + case V4L2_TUNER_DIGITAL_TV: tuner_dbg("tv freq set to %lu.%02lu\n", freq / 16, freq % 16 * 100 / 16); set_tv_freq(c, freq); break; - default: - return; } t->freq = freq; } static void set_type(struct i2c_client *c, unsigned int type, - unsigned int mode_mask) + unsigned int new_mode_mask) { struct tuner *t = i2c_get_clientdata(c); unsigned char buffer[4]; @@ -156,6 +154,7 @@ static void set_type(struct i2c_client *c, unsigned int type, /* This code detects calls by card attach_inform */ if (NULL == t->i2c.dev.driver) { tuner_dbg ("tuner 0x%02x: called before i2c_client register by adapter's attach_inform\n", c->addr); + t->type=type; return; } @@ -164,13 +163,13 @@ static void set_type(struct i2c_client *c, unsigned int type, switch (t->type) { case TUNER_MT2032: - microtune_init (c); + microtune_init(c); break; case TUNER_PHILIPS_TDA8290: - tda8290_init (c); + tda8290_init(c); break; case TUNER_TEA5767: - if (tea5767_tuner_init (c) == EINVAL) { + if (tea5767_tuner_init(c) == EINVAL) { t->type = TUNER_ABSENT; t->mode_mask = T_UNINITIALIZED; return; @@ -182,11 +181,11 @@ static void set_type(struct i2c_client *c, unsigned int type, buffer[1] = 0xdc; buffer[2] = 0x9c; buffer[3] = 0x60; - i2c_master_send (c, buffer, 4); + i2c_master_send(c, buffer, 4); mdelay(1); buffer[2] = 0x86; buffer[3] = 0x54; - i2c_master_send (c, buffer, 4); + i2c_master_send(c, buffer, 4); default_tuner_init(c); break; default: @@ -195,12 +194,12 @@ static void set_type(struct i2c_client *c, unsigned int type, } if (t->mode_mask == T_UNINITIALIZED) - t->mode_mask = mode_mask; + t->mode_mask = new_mode_mask; - set_freq (c, t->freq); - tuner_dbg ("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n", - c->adapter->name, c->driver->name, c->addr << 1, type, - t->mode_mask); + set_freq(c, t->freq); + tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n", + c->adapter->name, c->driver->name, c->addr << 1, type, + t->mode_mask); } /* @@ -223,23 +222,19 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup) } } -static inline int check_mode (struct tuner *t, char *cmd) +static inline int check_mode(struct tuner *t, char *cmd) { - if (t->mode & t->mode_mask) { - tuner_dbg ("mode=%d, mask=%d\n",t->mode, t->mode_mask); + if (1 << t->mode & t->mode_mask) { switch (t->mode) { - case T_RADIO: - tuner_dbg ("Cmd %s accepted for radio\n", cmd); + case V4L2_TUNER_RADIO: + tuner_dbg("Cmd %s accepted for radio\n", cmd); break; - case T_ANALOG_TV: - tuner_dbg ("Cmd %s accepted for analog TV\n", cmd); + case V4L2_TUNER_ANALOG_TV: + tuner_dbg("Cmd %s accepted for analog TV\n", cmd); break; - case T_DIGITAL_TV: - tuner_dbg ("Cmd %s accepted for digital TV\n", cmd); + case V4L2_TUNER_DIGITAL_TV: + tuner_dbg("Cmd %s accepted for digital TV\n", cmd); break; - default: - tuner_dbg ("Cmd %s for unknown mode %d\n", cmd,t->mode); - return EINVAL; } return 0; } @@ -310,7 +305,7 @@ static int tuner_fixup_std(struct tuner *t) /* ---------------------------------------------------------------------- */ /* static var Used only in tuner_attach and tuner_probe */ -static unsigned int default_mode_mask; +static unsigned default_mode_mask; /* During client attach, set_type is called by adapter's attach_inform callback. set_type must then be completed by tuner_attach. @@ -322,13 +317,12 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) client_template.adapter = adap; client_template.addr = addr; - t = kmalloc (sizeof(struct tuner), GFP_KERNEL); + t = kmalloc(sizeof(struct tuner), GFP_KERNEL); if (NULL == t) return -ENOMEM; memset(t, 0, sizeof(struct tuner)); memcpy(&t->i2c, &client_template, sizeof(struct i2c_client)); - i2c_set_clientdata (&t->i2c, t); - + i2c_set_clientdata(&t->i2c, t); t->type = UNSET; t->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */ t->audmode = V4L2_TUNER_MODE_STEREO; @@ -346,7 +340,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) default_mode_mask &= ~T_RADIO; i2c_attach_client (&t->i2c); - set_type (&t->i2c, t->type, t->mode_mask); + set_type(&t->i2c,t->type, t->mode_mask); return 0; } } @@ -361,8 +355,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) /* Should be just before return */ i2c_attach_client (&t->i2c); - set_type (&t->i2c, t->type, t->mode_mask); - + set_type (&t->i2c,t->type, t->mode_mask); return 0; } @@ -406,10 +399,11 @@ static int tuner_detach(struct i2c_client *client) static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd) { if (mode != t->mode) { + t->mode = mode; if (check_mode(t, cmd) == EINVAL) { t->mode_mask |= T_STANDBY; - if (T_RADIO == mode) { + if (V4L2_TUNER_RADIO == mode) { set_tv_freq(client, 400 * 16); } else { set_radio_freq(client, 87.5 * 16000); @@ -444,7 +438,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) switch (cmd) { /* --- configuration --- */ case TUNER_SET_TYPE_ADDR: - tuner_dbg ("Calling set_type_addr for type=%d, addr=0x%02x, mode_mask=0x%02x\n", + tuner_dbg ("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x\n", ((struct tuner_setup *)arg)->type, ((struct tuner_setup *)arg)->addr, ((struct tuner_setup *)arg)->mode_mask); @@ -452,7 +446,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) set_addr(client, (struct tuner_setup *)arg); break; case AUDC_SET_RADIO: - set_mode(client, t, T_RADIO, "AUDC_SET_RADIO"); + set_mode(client,t,V4L2_TUNER_RADIO, "AUDC_SET_RADIO"); break; case AUDC_CONFIG_PINNACLE: if (check_mode(t, "AUDC_CONFIG_PINNACLE") == EINVAL) @@ -488,7 +482,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (check_v4l2(t) == EINVAL) return 0; - if (set_mode (client, t, T_ANALOG_TV, "VIDIOCSCHAN") == EINVAL) + if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==EINVAL) return 0; if (vc->norm < ARRAY_SIZE(map)) @@ -519,18 +513,18 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (check_v4l2(t) == EINVAL) return 0; - if (T_RADIO == t->mode) { + if (V4L2_TUNER_RADIO == t->mode) { if (t->has_signal) vt->signal = t->has_signal(client); - - if (t->is_stereo && t->is_stereo(client)) { - vt->flags |= - VIDEO_TUNER_STEREO_ON; - } else { - vt->flags &= - ~VIDEO_TUNER_STEREO_ON; + if (t->is_stereo) { + if (t->is_stereo(client)) + vt->flags |= + VIDEO_TUNER_STEREO_ON; + else + vt->flags &= + ~VIDEO_TUNER_STEREO_ON; } - vt->flags |= V4L2_TUNER_CAP_LOW; /* Allow freqs at 62.5 Hz */ + vt->flags |= V4L2_TUNER_CAP_LOW; /* Allow freqs at 62.5 Hz */ vt->rangelow = radio_range[0] * 16000; vt->rangehigh = radio_range[1] * 16000; @@ -551,7 +545,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (check_v4l2(t) == EINVAL) return 0; - if (T_RADIO == t->mode && t->is_stereo) + if (V4L2_TUNER_RADIO == t->mode && t->is_stereo) va->mode = t->is_stereo(client) ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; return 0; @@ -561,7 +555,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { v4l2_std_id *id = arg; - if (set_mode (client, t, T_ANALOG_TV, "VIDIOC_S_STD") + if (set_mode (client, t, V4L2_TUNER_ANALOG_TV, "VIDIOC_S_STD") == EINVAL) return 0; @@ -580,8 +574,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) t->freq = f->frequency; switch_v4l2(); if (V4L2_TUNER_RADIO == f->type && - T_RADIO != t->mode) { - if (set_mode (client, t, T_RADIO, "VIDIOC_S_FREQUENCY") + V4L2_TUNER_RADIO != t->mode) { + if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY") == EINVAL) return 0; } @@ -604,22 +598,24 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct v4l2_tuner *tuner = arg; - if (check_mode (t, "VIDIOC_G_TUNER") == EINVAL) + if (check_mode(t, "VIDIOC_G_TUNER") == EINVAL) return 0; switch_v4l2(); - if (T_RADIO == t->mode) { + if (V4L2_TUNER_RADIO == t->mode) { if (t->has_signal) tuner->signal = t->has_signal(client); - if (t->is_stereo && t->is_stereo (client)) { - tuner->rxsubchans = - V4L2_TUNER_SUB_STEREO | - V4L2_TUNER_SUB_MONO; - } else { - tuner->rxsubchans = - V4L2_TUNER_SUB_MONO; + if (t->is_stereo) { + if (t->is_stereo(client)) { + tuner->rxsubchans = + V4L2_TUNER_SUB_STEREO | + V4L2_TUNER_SUB_MONO; + } else { + tuner->rxsubchans = + V4L2_TUNER_SUB_MONO; + } } tuner->capability |= @@ -644,7 +640,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) switch_v4l2(); - if (T_RADIO == t->mode) { + if (V4L2_TUNER_RADIO == t->mode) { t->audmode = tuner->audmode; set_radio_freq(client, t->freq); } |