summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/tuner-core.c
diff options
context:
space:
mode:
authorNickolay V. Shmyrev <devnull@localhost>2005-07-05 17:37:35 +0000
committerNickolay V. Shmyrev <devnull@localhost>2005-07-05 17:37:35 +0000
commit1f40d1644d3d1f28c93be46a75081421aaefb80e (patch)
tree83a33bfca94e034d19a75bb5ebafea1fb6001af0 /linux/drivers/media/video/tuner-core.c
parente878ee9ed558c1eb13033b79cdaebf4145865efa (diff)
downloadmediapointer-dvb-s2-1f40d1644d3d1f28c93be46a75081421aaefb80e.tar.gz
mediapointer-dvb-s2-1f40d1644d3d1f28c93be46a75081421aaefb80e.tar.bz2
Rename tuner structures fields. Move MD detection hack to
saa7134-cards.c
Diffstat (limited to 'linux/drivers/media/video/tuner-core.c')
-rw-r--r--linux/drivers/media/video/tuner-core.c174
1 files changed, 86 insertions, 88 deletions
diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c
index 67f956a4f..f563a57f8 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.48 2005/07/04 22:34:39 nsh Exp $
+ * $Id: tuner-core.c,v 1.49 2005/07/05 17:37:35 nsh Exp $
*
* i2c tv tuner chip device driver
* core core, i.e. kernel interfaces, registering and so on
@@ -120,23 +120,25 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
struct tuner *t = i2c_get_clientdata(c);
switch (t->mode) {
- case V4L2_TUNER_RADIO:
+ case T_RADIO:
tuner_dbg("radio freq set to %lu.%02lu\n",
freq / 16000, freq % 16000 * 100 / 16000);
set_radio_freq(c, freq);
break;
- case V4L2_TUNER_ANALOG_TV:
- case V4L2_TUNER_DIGITAL_TV:
+ case T_ANALOG_TV:
+ case T_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,
- enum tuner_admin_state new_admin_status)
+ unsigned int mode_mask)
{
struct tuner *t = i2c_get_clientdata(c);
unsigned char buffer[4];
@@ -154,7 +156,6 @@ 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;
}
@@ -163,29 +164,29 @@ 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->admin_status = T_UNINITIALIZED;
+ t->mode_mask = T_UNINITIALIZED;
return;
}
- t->admin_status = T_RADIO;
+ t->mode_mask = T_RADIO;
break;
case TUNER_PHILIPS_FMD1216ME_MK3:
buffer[0] = 0x0b;
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:
@@ -193,48 +194,50 @@ static void set_type(struct i2c_client *c, unsigned int type,
break;
}
- if (t->admin_status == T_UNINITIALIZED)
- t->admin_status = new_admin_status;
+ if (t->mode_mask == T_UNINITIALIZED)
+ t->mode_mask = 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->admin_status);
+ 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);
}
/*
* This function apply tuner config to tuner specified
- * by tun_addr structure. I addr is unset, then admin status
+ * by tun_setup structure. I addr is unset, then admin status
* and tun addr status is more precise then current status,
* it's applied. Otherwise status and type are applied only to
* tuner with exactly the same addr.
*/
-static void set_addr(struct i2c_client *c, struct tuner_addr *tun_addr)
+static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup)
{
struct tuner *t = i2c_get_clientdata(c);
- if (tun_addr->addr == ADDR_UNSET) {
- if (t->admin_status & tun_addr->state)
- set_type(c, tun_addr->type, tun_addr->state);
- } else if (tun_addr->addr == c->addr) {
- set_type(c, tun_addr->type, tun_addr->state);
+ if (tun_setup->addr == ADDR_UNSET) {
+ if (t->mode_mask & tun_setup->mode_mask)
+ set_type(c, tun_setup->type, tun_setup->mode_mask);
+ } else if (tun_setup->addr == c->addr) {
+ set_type(c, tun_setup->type, tun_setup->mode_mask);
}
}
-static inline int check_mode(struct tuner *t, char *cmd)
+static inline int check_mode (struct tuner *t, char *cmd)
{
- if (1 << t->mode & t->admin_status) {
+ if (t->mode & t->mode_mask) {
switch (t->mode) {
- case V4L2_TUNER_RADIO:
- tuner_dbg("Cmd %s accepted for radio\n", cmd);
+ case T_RADIO:
+ tuner_dbg ("Cmd %s accepted for radio\n", cmd);
break;
- case V4L2_TUNER_ANALOG_TV:
- tuner_dbg("Cmd %s accepted for analog TV\n", cmd);
+ case T_ANALOG_TV:
+ tuner_dbg ("Cmd %s accepted for analog TV\n", cmd);
break;
- case V4L2_TUNER_DIGITAL_TV:
- tuner_dbg("Cmd %s accepted for digital TV\n", cmd);
+ case T_DIGITAL_TV:
+ tuner_dbg ("Cmd %s accepted for digital TV\n", cmd);
break;
+ default:
+ return EINVAL;
}
return 0;
}
@@ -305,7 +308,7 @@ static int tuner_fixup_std(struct tuner *t)
/* ---------------------------------------------------------------------- */
/* static var Used only in tuner_attach and tuner_probe */
-static unsigned default_admin_status;
+static unsigned int 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.
@@ -317,16 +320,17 @@ 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;
- t->admin_status = T_UNINITIALIZED;
+ t->mode_mask = T_UNINITIALIZED;
tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
@@ -335,27 +339,28 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
if (addr == 0x60) {
if (tea5767_autodetection(&t->i2c) != EINVAL) {
t->type = TUNER_TEA5767;
- t->admin_status = T_RADIO | T_STANDBY;
+ t->mode_mask = T_RADIO | T_STANDBY;
t->freq = 87.5 * 16; /* Sets freq to FM range */
- default_admin_status &= ~T_RADIO;
+ default_mode_mask &= ~T_RADIO;
i2c_attach_client (&t->i2c);
- set_type(&t->i2c,t->type, t->admin_status);
+ set_type (&t->i2c, t->type, t->mode_mask);
return 0;
}
}
/* Initializes only the first adapter found */
- if (default_admin_status != T_UNINITIALIZED) {
- tuner_dbg ("Setting admin_status to 0x%02x\n", default_admin_status);
- t->admin_status = default_admin_status;
+ if (default_mode_mask != T_UNINITIALIZED) {
+ tuner_dbg ("Setting mode_mask to 0x%02x\n", default_mode_mask);
+ t->mode_mask = default_mode_mask;
t->freq = 400 * 16; /* Sets freq to VHF High */
- default_admin_status = T_UNINITIALIZED;
+ default_mode_mask = T_UNINITIALIZED;
}
/* Should be just before return */
i2c_attach_client (&t->i2c);
- set_type (&t->i2c,t->type, t->admin_status);
+ set_type (&t->i2c, t->type, t->mode_mask);
+
return 0;
}
@@ -366,7 +371,7 @@ static int tuner_probe(struct i2c_adapter *adap)
normal_i2c[1] = I2C_CLIENT_END;
}
- default_admin_status = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
+ default_mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tuner_attach);
@@ -399,22 +404,17 @@ 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->admin_status |= T_STANDBY;
- if (V4L2_TUNER_RADIO == mode) {
+ t->mode = T_STANDBY;
+ set_freq (client, t->freq);
+ return EINVAL;
+ } else {
+ if (T_RADIO == mode) {
set_tv_freq(client, 400 * 16);
} else {
set_radio_freq(client, 87.5 * 16000);
}
- return EINVAL;
- } else {
- t->admin_status &= ~T_STANDBY;
- if (t->mode == V4L2_TUNER_RADIO)
- set_freq (client, t->freq * 1000);
- else
- set_freq (client, t->freq / 1000);
}
}
return 0;
@@ -441,15 +441,15 @@ 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=0x%02x\n",
- ((struct tuner_addr *)arg)->type,
- ((struct tuner_addr *)arg)->addr,
- ((struct tuner_addr *)arg)->state);
+ tuner_dbg ("Calling set_type_addr for type=%d, addr=0x%02x, mode_mask=0x%02x\n",
+ ((struct tuner_setup *)arg)->type,
+ ((struct tuner_setup *)arg)->addr,
+ ((struct tuner_setup *)arg)->mode_mask);
- set_addr(client, (struct tuner_addr *)arg);
+ set_addr(client, (struct tuner_setup *)arg);
break;
case AUDC_SET_RADIO:
- set_mode(client,t,V4L2_TUNER_RADIO, "AUDC_SET_RADIO");
+ set_mode(client, t, T_RADIO, "AUDC_SET_RADIO");
break;
case AUDC_CONFIG_PINNACLE:
if (check_mode(t, "AUDC_CONFIG_PINNACLE") == EINVAL)
@@ -485,7 +485,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,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==EINVAL)
+ if (set_mode (client, t, T_ANALOG_TV, "VIDIOCSCHAN") == EINVAL)
return 0;
if (vc->norm < ARRAY_SIZE(map))
@@ -516,16 +516,16 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
if (check_v4l2(t) == EINVAL)
return 0;
- if (V4L2_TUNER_RADIO == t->mode) {
+ if (T_RADIO == t->mode) {
if (t->has_signal)
vt->signal = t->has_signal(client);
- if (t->is_stereo) {
- if (t->is_stereo(client))
- vt->flags |=
- VIDEO_TUNER_STEREO_ON;
- else
- vt->flags &=
- ~VIDEO_TUNER_STEREO_ON;
+
+ if (t->is_stereo && t->is_stereo(client)) {
+ vt->flags |=
+ VIDEO_TUNER_STEREO_ON;
+ } else {
+ vt->flags &=
+ ~VIDEO_TUNER_STEREO_ON;
}
vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */
@@ -548,7 +548,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
if (check_v4l2(t) == EINVAL)
return 0;
- if (V4L2_TUNER_RADIO == t->mode && t->is_stereo)
+ if (T_RADIO == t->mode && t->is_stereo)
va->mode = t->is_stereo(client)
? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
return 0;
@@ -558,7 +558,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
v4l2_std_id *id = arg;
- if (set_mode (client, t, V4L2_TUNER_ANALOG_TV, "VIDIOC_S_STD")
+ if (set_mode (client, t, T_ANALOG_TV, "VIDIOC_S_STD")
== EINVAL)
return 0;
@@ -577,8 +577,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 &&
- V4L2_TUNER_RADIO != t->mode) {
- if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY")
+ T_RADIO != t->mode) {
+ if (set_mode (client, t, T_RADIO, "VIDIOC_S_FREQUENCY")
== EINVAL)
return 0;
}
@@ -601,24 +601,22 @@ 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 (V4L2_TUNER_RADIO == t->mode) {
+ if (T_RADIO == t->mode) {
if (t->has_signal)
tuner->signal = t->has_signal(client);
- 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;
- }
+ 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;
}
tuner->capability |=
@@ -643,7 +641,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
switch_v4l2();
- if (V4L2_TUNER_RADIO == t->mode) {
+ if (T_RADIO == t->mode) {
t->audmode = tuner->audmode;
set_radio_freq(client, t->freq);
}