diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-06-07 09:30:59 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-06-07 09:30:59 -0300 |
commit | 8f4a89da9e9a760bc538ddec6687826007a1d04c (patch) | |
tree | 1eb144567bc6064f9f16bb72d13bb1270bb29141 | |
parent | 9aabc7e2945432ffb81a92e556b406bc93c3ef9a (diff) | |
parent | 0d79963da3174ac0a23ef4f8ae28f8b0ad30e636 (diff) | |
download | mediapointer-dvb-s2-8f4a89da9e9a760bc538ddec6687826007a1d04c.tar.gz mediapointer-dvb-s2-8f4a89da9e9a760bc538ddec6687826007a1d04c.tar.bz2 |
merge: http://linuxtv.org/hg/~mkrufky/tuner
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | linux/drivers/media/video/mt20xx.c | 40 | ||||
-rw-r--r-- | linux/drivers/media/video/tda8290.c | 15 | ||||
-rw-r--r-- | linux/drivers/media/video/tda9887.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/video/tea5761.c | 12 | ||||
-rw-r--r-- | linux/drivers/media/video/tea5767.c | 14 | ||||
-rw-r--r-- | linux/drivers/media/video/tuner-core.c | 62 | ||||
-rw-r--r-- | linux/drivers/media/video/tuner-simple.c | 13 | ||||
-rw-r--r-- | linux/include/media/tuner.h | 21 |
8 files changed, 113 insertions, 80 deletions
diff --git a/linux/drivers/media/video/mt20xx.c b/linux/drivers/media/video/mt20xx.c index 775d57f5d..898d4f850 100644 --- a/linux/drivers/media/video/mt20xx.c +++ b/linux/drivers/media/video/mt20xx.c @@ -46,6 +46,14 @@ struct microtune_priv { unsigned int radio_if2; }; +static void microtune_release(struct i2c_client *c) +{ + struct tuner *t = i2c_get_clientdata(c); + + kfree(t->priv); + t->priv = NULL; +} + // IsSpurInBand()? static int mt2032_spurcheck(struct i2c_client *c, int f1, int f2, int spectrum_from,int spectrum_to) @@ -312,6 +320,12 @@ static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq) 1085*1000*1000,if2,if2,if2); } +static struct tuner_operations mt2032_tuner_ops = { + .set_tv_freq = mt2032_set_tv_freq, + .set_radio_freq = mt2032_set_radio_freq, + .release = microtune_release, +}; + // Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001 static int mt2032_init(struct i2c_client *c) { @@ -365,8 +379,8 @@ static int mt2032_init(struct i2c_client *c) } while (xok != 1 ); priv->xogc=xogc; - t->set_tv_freq = mt2032_set_tv_freq; - t->set_radio_freq = mt2032_set_radio_freq; + memcpy(&t->ops, &mt2032_tuner_ops, sizeof(struct tuner_operations)); + return(1); } @@ -475,6 +489,12 @@ static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq) mt2050_set_antenna(c, radio_antenna); } +static struct tuner_operations mt2050_tuner_ops = { + .set_tv_freq = mt2050_set_tv_freq, + .set_radio_freq = mt2050_set_radio_freq, + .release = microtune_release, +}; + static int mt2050_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -494,17 +514,10 @@ static int mt2050_init(struct i2c_client *c) i2c_master_recv(c,buf,1); tuner_dbg("mt2050: sro is %x\n",buf[0]); - t->set_tv_freq = mt2050_set_tv_freq; - t->set_radio_freq = mt2050_set_radio_freq; - return 0; -} -static void microtune_release(struct i2c_client *c) -{ - struct tuner *t = i2c_get_clientdata(c); + memcpy(&t->ops, &mt2050_tuner_ops, sizeof(struct tuner_operations)); - kfree(t->priv); - t->priv = NULL; + return 0; } int microtune_init(struct i2c_client *c) @@ -523,10 +536,7 @@ int microtune_init(struct i2c_client *c) priv->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */ memset(buf,0,sizeof(buf)); - t->set_tv_freq = NULL; - t->set_radio_freq = NULL; - t->standby = NULL; - t->release = microtune_release; + if (t->std & V4L2_STD_525_60) { tuner_dbg("pinnacle ntsc\n"); priv->radio_if2 = 41300 * 1000; diff --git a/linux/drivers/media/video/tda8290.c b/linux/drivers/media/video/tda8290.c index 63d76b925..e0f2b79ab 100644 --- a/linux/drivers/media/video/tda8290.c +++ b/linux/drivers/media/video/tda8290.c @@ -607,6 +607,14 @@ static void tda8290_release(struct i2c_client *c) t->priv = NULL; } +static struct tuner_operations tda8290_tuner_ops = { + .set_tv_freq = set_tv_freq, + .set_radio_freq = set_radio_freq, + .has_signal = has_signal, + .standby = standby, + .release = tda8290_release, +}; + int tda8290_init(struct i2c_client *c) { struct tda8290_priv *priv = NULL; @@ -671,11 +679,8 @@ int tda8290_init(struct i2c_client *c) } tuner_info("type set to %s\n", c->name); - t->set_tv_freq = set_tv_freq; - t->set_radio_freq = set_radio_freq; - t->has_signal = has_signal; - t->standby = standby; - t->release = tda8290_release; + memcpy(&t->ops, &tda8290_tuner_ops, sizeof(struct tuner_operations)); + priv->tda827x_lpsel = 0; t->mode = V4L2_TUNER_ANALOG_TV; diff --git a/linux/drivers/media/video/tda9887.c b/linux/drivers/media/video/tda9887.c index 38c57a838..6ff82ff2d 100644 --- a/linux/drivers/media/video/tda9887.c +++ b/linux/drivers/media/video/tda9887.c @@ -610,6 +610,15 @@ static void tda9887_release(struct i2c_client *c) t->priv = NULL; } +static struct tuner_operations tda9887_tuner_ops = { + .set_tv_freq = tda9887_set_freq, + .set_radio_freq = tda9887_set_freq, + .standby = tda9887_standby, + .tuner_status = tda9887_tuner_status, + .get_afc = tda9887_get_afc, + .release = tda9887_release, +}; + int tda9887_tuner_init(struct i2c_client *c) { struct tda9887_priv *priv = NULL; @@ -625,12 +634,7 @@ int tda9887_tuner_init(struct i2c_client *c) tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr, t->i2c.driver->driver.name); - t->set_tv_freq = tda9887_set_freq; - t->set_radio_freq = tda9887_set_freq; - t->standby = tda9887_standby; - t->tuner_status = tda9887_tuner_status; - t->get_afc = tda9887_get_afc; - t->release = tda9887_release; + memcpy(&t->ops, &tda9887_tuner_ops, sizeof(struct tuner_operations)); return 0; } diff --git a/linux/drivers/media/video/tea5761.c b/linux/drivers/media/video/tea5761.c index 170c2181c..5c10287ab 100644 --- a/linux/drivers/media/video/tea5761.c +++ b/linux/drivers/media/video/tea5761.c @@ -220,6 +220,13 @@ int tea5761_autodetection(struct i2c_client *c) return 0; } +static struct tuner_operations tea5761_tuner_ops = { + .set_tv_freq = set_tv_freq, + .set_radio_freq = set_radio_freq, + .has_signal = tea5761_signal, + .is_stereo = tea5761_stereo, +}; + int tea5761_tuner_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -230,10 +237,7 @@ int tea5761_tuner_init(struct i2c_client *c) tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5761HN FM Radio"); strlcpy(c->name, "tea5761", sizeof(c->name)); - t->set_tv_freq = set_tv_freq; - t->set_radio_freq = set_radio_freq; - t->has_signal = tea5761_signal; - t->is_stereo = tea5761_stereo; + memcpy(&t->ops, &tea5761_tuner_ops, sizeof(struct tuner_operations)); return (0); } diff --git a/linux/drivers/media/video/tea5767.c b/linux/drivers/media/video/tea5767.c index c537c90d4..e5c36a19f 100644 --- a/linux/drivers/media/video/tea5767.c +++ b/linux/drivers/media/video/tea5767.c @@ -378,6 +378,14 @@ int tea5767_autodetection(struct i2c_client *c) return 0; } +static struct tuner_operations tea5767_tuner_ops = { + .set_tv_freq = set_tv_freq, + .set_radio_freq = set_radio_freq, + .has_signal = tea5767_signal, + .is_stereo = tea5767_stereo, + .standby = tea5767_standby, +}; + int tea5767_tuner_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -389,11 +397,7 @@ int tea5767_tuner_init(struct i2c_client *c) tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio"); strlcpy(c->name, "tea5767", sizeof(c->name)); - t->set_tv_freq = set_tv_freq; - t->set_radio_freq = set_radio_freq; - t->has_signal = tea5767_signal; - t->is_stereo = tea5767_stereo; - t->standby = tea5767_standby; + memcpy(&t->ops, &tea5767_tuner_ops, sizeof(struct tuner_operations)); return (0); } diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index b85d415ed..99570ec22 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -105,7 +105,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) tuner_warn ("tuner type not set\n"); return; } - if (NULL == t->set_tv_freq) { + if (NULL == t->ops.set_tv_freq) { tuner_warn ("Tuner has no way to set tv freq\n"); return; } @@ -120,7 +120,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) else freq = tv_range[1] * 16; } - t->set_tv_freq(c, freq); + t->ops.set_tv_freq(c, freq); } static void set_radio_freq(struct i2c_client *c, unsigned int freq) @@ -131,7 +131,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) tuner_warn ("tuner type not set\n"); return; } - if (NULL == t->set_radio_freq) { + if (NULL == t->ops.set_radio_freq) { tuner_warn ("tuner has no way to set radio frequency\n"); return; } @@ -147,7 +147,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) freq = radio_range[1] * 16000; } - t->set_radio_freq(c, freq); + t->ops.set_radio_freq(c, freq); } static void set_freq(struct i2c_client *c, unsigned long freq) @@ -205,8 +205,8 @@ static void set_type(struct i2c_client *c, unsigned int type, #endif /* discard private data, in case set_type() was previously called */ - if (t->release) - t->release(c); + if (t->ops.release) + t->ops.release(c); else { kfree(t->priv); t->priv = NULL; @@ -470,11 +470,11 @@ static void tuner_status(struct i2c_client *client) tuner_info("Standard: 0x%08lx\n", (unsigned long)t->std); if (t->mode != V4L2_TUNER_RADIO) return; - if (t->has_signal) { - tuner_info("Signal strength: %d\n", t->has_signal(client)); + if (t->ops.has_signal) { + tuner_info("Signal strength: %d\n", t->ops.has_signal(client)); } - if (t->is_stereo) { - tuner_info("Stereo: %s\n", t->is_stereo(client) ? "yes" : "no"); + if (t->ops.is_stereo) { + tuner_info("Stereo: %s\n", t->ops.is_stereo(client) ? "yes" : "no"); } } @@ -506,7 +506,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, t->type = UNSET; t->audmode = V4L2_TUNER_MODE_STEREO; t->mode_mask = T_UNINITIALIZED; - t->tuner_status = tuner_status; + t->ops.tuner_status = tuner_status; if (show_i2c) { unsigned char buffer[16]; @@ -623,8 +623,8 @@ static int tuner_detach(struct i2c_client *client) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) MOD_DEC_USE_COUNT; #endif - if (t->release) - t->release(client); + if (t->ops.release) + t->ops.release(client); else { kfree(t->priv); #if 0 @@ -651,8 +651,8 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, if (check_mode(t, cmd) == EINVAL) { t->mode = T_STANDBY; - if (t->standby) - t->standby (client); + if (t->ops.standby) + t->ops.standby (client); return EINVAL; } return 0; @@ -706,8 +706,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) return 0; t->mode = T_STANDBY; - if (t->standby) - t->standby (client); + if (t->ops.standby) + t->ops.standby (client); break; #ifdef CONFIG_VIDEO_V4L1 case VIDIOCSAUDIO: @@ -766,10 +766,10 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) return 0; if (V4L2_TUNER_RADIO == t->mode) { - if (t->has_signal) - vt->signal = t->has_signal(client); - if (t->is_stereo) { - if (t->is_stereo(client)) + if (t->ops.has_signal) + vt->signal = t->ops.has_signal(client); + if (t->ops.is_stereo) { + if (t->ops.is_stereo(client)) vt->flags |= VIDEO_TUNER_STEREO_ON; else @@ -797,8 +797,8 @@ 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) - va->mode = t->is_stereo(client) + if (V4L2_TUNER_RADIO == t->mode && t->ops.is_stereo) + va->mode = t->ops.is_stereo(client) ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; return 0; } @@ -863,8 +863,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) switch_v4l2(); tuner->type = t->mode; - if (t->get_afc) - tuner->afc=t->get_afc(client); + if (t->ops.get_afc) + tuner->afc=t->ops.get_afc(client); if (t->mode == V4L2_TUNER_ANALOG_TV) tuner->capability |= V4L2_TUNER_CAP_NORM; if (t->mode != V4L2_TUNER_RADIO) { @@ -874,13 +874,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) } /* radio mode */ - if (t->has_signal) - tuner->signal = t->has_signal(client); + if (t->ops.has_signal) + tuner->signal = t->ops.has_signal(client); tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; - if (t->is_stereo) { - tuner->rxsubchans = t->is_stereo(client) ? + if (t->ops.is_stereo) { + tuner->rxsubchans = t->ops.is_stereo(client) ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; } @@ -908,8 +908,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) break; } case VIDIOC_LOG_STATUS: - if (t->tuner_status) - t->tuner_status(client); + if (t->ops.tuner_status) + t->ops.tuner_status(client); break; } diff --git a/linux/drivers/media/video/tuner-simple.c b/linux/drivers/media/video/tuner-simple.c index a4718b2f0..8cac349fe 100644 --- a/linux/drivers/media/video/tuner-simple.c +++ b/linux/drivers/media/video/tuner-simple.c @@ -515,6 +515,13 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); } +static struct tuner_operations simple_tuner_ops = { + .set_tv_freq = default_set_tv_freq, + .set_radio_freq = default_set_radio_freq, + .has_signal = tuner_signal, + .is_stereo = tuner_stereo, +}; + int default_tuner_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -523,11 +530,7 @@ int default_tuner_init(struct i2c_client *c) t->type, tuners[t->type].name); strlcpy(c->name, tuners[t->type].name, sizeof(c->name)); - t->set_tv_freq = default_set_tv_freq; - t->set_radio_freq = default_set_radio_freq; - t->has_signal = tuner_signal; - t->is_stereo = tuner_stereo; - t->standby = NULL; + memcpy(&t->ops, &simple_tuner_ops, sizeof(struct tuner_operations)); return 0; } diff --git a/linux/include/media/tuner.h b/linux/include/media/tuner.h index 1f61f4681..e1821aa21 100644 --- a/linux/include/media/tuner.h +++ b/linux/include/media/tuner.h @@ -183,6 +183,17 @@ struct tuner_setup { int (*tuner_callback) (void *dev, int command,int arg); }; +struct tuner_operations { + void (*set_tv_freq)(struct i2c_client *c, unsigned int freq); + void (*set_radio_freq)(struct i2c_client *c, unsigned int freq); + int (*has_signal)(struct i2c_client *c); + int (*is_stereo)(struct i2c_client *c); + int (*get_afc)(struct i2c_client *c); + void (*tuner_status)(struct i2c_client *c); + void (*standby)(struct i2c_client *c); + void (*release)(struct i2c_client *c); +}; + struct tuner { /* device */ struct i2c_client i2c; @@ -207,15 +218,7 @@ struct tuner { unsigned int config; int (*tuner_callback) (void *dev, int command,int arg); - /* function ptrs */ - void (*set_tv_freq)(struct i2c_client *c, unsigned int freq); - void (*set_radio_freq)(struct i2c_client *c, unsigned int freq); - int (*has_signal)(struct i2c_client *c); - int (*is_stereo)(struct i2c_client *c); - int (*get_afc)(struct i2c_client *c); - void (*tuner_status)(struct i2c_client *c); - void (*standby)(struct i2c_client *c); - void (*release)(struct i2c_client *c); + struct tuner_operations ops; }; extern unsigned const int tuner_count; |