diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-10-21 18:39:50 -0400 |
---|---|---|
committer | Michael Krufky <mkrufky@linuxtv.org> | 2007-10-21 18:39:50 -0400 |
commit | 45eba30725ae74b83dcb73a3cb79db3bbe2f53b1 (patch) | |
tree | 44f278484a2708de0531b48504c91f68cdee5f67 /linux/drivers/media | |
parent | 1dc24f728097d312f26ea779561fba5da19de63b (diff) | |
download | mediapointer-dvb-s2-45eba30725ae74b83dcb73a3cb79db3bbe2f53b1.tar.gz mediapointer-dvb-s2-45eba30725ae74b83dcb73a3cb79db3bbe2f53b1.tar.bz2 |
tuner: convert analog tuner demod sub-modules to dvb_frontend interface
From: Michael Krufky <mkrufky@linuxtv.org>
Convert tda9887 and tda8290/5 to dvb_frontend interface
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
---
linux/drivers/media/video/tda8290.c | 168 ++++++++++++++++---------------
linux/drivers/media/video/tda9887.c | 78 ++++++++------
linux/drivers/media/video/tuner-core.c | 79 +++++++-------
linux/drivers/media/video/tuner-driver.h | 16 +-
4 files changed, 188 insertions(+), 153 deletions(-)
Diffstat (limited to 'linux/drivers/media')
-rw-r--r-- | linux/drivers/media/video/tda8290.c | 168 | ||||
-rw-r--r-- | linux/drivers/media/video/tda9887.c | 78 | ||||
-rw-r--r-- | linux/drivers/media/video/tuner-core.c | 79 | ||||
-rw-r--r-- | linux/drivers/media/video/tuner-driver.h | 16 |
4 files changed, 188 insertions, 153 deletions
diff --git a/linux/drivers/media/video/tda8290.c b/linux/drivers/media/video/tda8290.c index 2d6b55ead..aed23ce1f 100644 --- a/linux/drivers/media/video/tda8290.c +++ b/linux/drivers/media/video/tda8290.c @@ -53,13 +53,15 @@ struct tda8290_priv { unsigned char tda827x_ver; struct tda827x_config cfg; + + struct tuner *t; }; /*---------------------------------------------------------------------*/ -static void tda8290_i2c_bridge(struct tuner *t, int close) +static void tda8290_i2c_bridge(struct dvb_frontend *fe, int close) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char enable[2] = { 0x21, 0xC0 }; unsigned char disable[2] = { 0x21, 0x00 }; @@ -76,9 +78,9 @@ static void tda8290_i2c_bridge(struct tuner *t, int close) } #if 1 -static void tda8295_i2c_bridge(struct tuner *t, int close) +static void tda8295_i2c_bridge(struct dvb_frontend *fe, int close) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char enable[2] = { 0x45, 0xc1 }; unsigned char disable[2] = { 0x46, 0x00 }; @@ -104,9 +106,9 @@ static void tda8295_i2c_bridge(struct tuner *t, int close) } } #else -static void tda8295_i2c_bridge(struct tuner *t, int close) +static void tda8295_i2c_bridge(struct dvb_frontend *fe, int close) { - struct tda8290_priv *priv = t->priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char buf[] = { 0x45, 0x00 }; @@ -125,9 +127,10 @@ static void tda8295_i2c_bridge(struct tuner *t, int close) /*---------------------------------------------------------------------*/ -static void set_audio(struct tuner *t) +static void set_audio(struct dvb_frontend *fe) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; + struct tuner *t = priv->t; char* mode; priv->cfg.tda827x_lpsel = 0; @@ -172,9 +175,11 @@ static void set_audio(struct tuner *t) tuner_dbg("setting tda8290 to system %s\n", mode); } -static void tda8290_set_freq(struct tuner *t, unsigned int freq) +static void tda8290_set_freq(struct dvb_frontend *fe, unsigned int freq) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; + struct tuner *t = priv->t; + unsigned char soft_reset[] = { 0x00, 0x00 }; unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; unsigned char expert_mode[] = { 0x01, 0x80 }; @@ -204,7 +209,7 @@ static void tda8290_set_freq(struct tuner *t, unsigned int freq) .std = t->std }; - set_audio(t); + set_audio(fe); tuner_dbg("tda827xa config is 0x%02x\n", t->config); tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); @@ -222,10 +227,10 @@ static void tda8290_set_freq(struct tuner *t, unsigned int freq) tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2); tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2); - tda8290_i2c_bridge(t, 1); + tda8290_i2c_bridge(fe, 1); - if (t->fe.ops.tuner_ops.set_analog_params) - t->fe.ops.tuner_ops.set_analog_params(&t->fe, ¶ms); + if (fe->ops.tuner_ops.set_analog_params) + fe->ops.tuner_ops.set_analog_params(fe, ¶ms); for (i = 0; i < 3; i++) { tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); @@ -256,7 +261,7 @@ static void tda8290_set_freq(struct tuner *t, unsigned int freq) tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", agc_stat, pll_stat & 0x80); if (priv->cfg.agcf) - priv->cfg.agcf(&t->fe); + priv->cfg.agcf(fe); msleep(100); tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); @@ -285,15 +290,15 @@ static void tda8290_set_freq(struct tuner *t, unsigned int freq) } } - tda8290_i2c_bridge(t, 0); + tda8290_i2c_bridge(fe, 0); tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2); } /*---------------------------------------------------------------------*/ -static void tda8295_power(struct tuner *t, int enable) +static void tda8295_power(struct dvb_frontend *fe, int enable) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char buf[] = { 0x30, 0x00 }; /* clb_stdbt */ tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); @@ -307,9 +312,9 @@ static void tda8295_power(struct tuner *t, int enable) tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); } -static void tda8295_set_easy_mode(struct tuner *t, int enable) +static void tda8295_set_easy_mode(struct dvb_frontend *fe, int enable) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char buf[] = { 0x01, 0x00 }; tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); @@ -323,23 +328,23 @@ static void tda8295_set_easy_mode(struct tuner *t, int enable) tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); } -static void tda8295_set_video_std(struct tuner *t) +static void tda8295_set_video_std(struct dvb_frontend *fe) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char buf[] = { 0x00, priv->tda8290_easy_mode }; tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); - tda8295_set_easy_mode(t, 1); + tda8295_set_easy_mode(fe, 1); msleep(20); - tda8295_set_easy_mode(t, 0); + tda8295_set_easy_mode(fe, 0); } /*---------------------------------------------------------------------*/ -static void tda8295_agc1_out(struct tuner *t, int enable) +static void tda8295_agc1_out(struct dvb_frontend *fe, int enable) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char buf[] = { 0x02, 0x00 }; /* DIV_FUNC */ tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); @@ -353,9 +358,9 @@ static void tda8295_agc1_out(struct tuner *t, int enable) tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); } -static void tda8295_agc2_out(struct tuner *t, int enable) +static void tda8295_agc2_out(struct dvb_frontend *fe, int enable) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char set_gpio_cf[] = { 0x44, 0x00 }; unsigned char set_gpio_val[] = { 0x46, 0x00 }; @@ -374,9 +379,9 @@ static void tda8295_agc2_out(struct tuner *t, int enable) tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_val, 2); } -static int tda8295_has_signal(struct tuner *t) +static int tda8295_has_signal(struct dvb_frontend *fe) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char hvpll_stat = 0x26; unsigned char ret; @@ -388,9 +393,10 @@ static int tda8295_has_signal(struct tuner *t) /*---------------------------------------------------------------------*/ -static void tda8295_set_freq(struct tuner *t, unsigned int freq) +static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; + struct tuner *t = priv->t; u16 ifc; unsigned char blanking_mode[] = { 0x1d, 0x00 }; @@ -402,45 +408,45 @@ static void tda8295_set_freq(struct tuner *t, unsigned int freq) .std = t->std }; - set_audio(t); + set_audio(fe); ifc = priv->cfg.sgIF; /* FIXME */ tuner_dbg("%s: ifc = %u, freq = %d\n", __FUNCTION__, ifc, freq); - tda8295_power(t, 1); - tda8295_agc1_out(t, 1); + tda8295_power(fe, 1); + tda8295_agc1_out(fe, 1); tuner_i2c_xfer_send(&priv->i2c_props, &blanking_mode[0], 1); tuner_i2c_xfer_recv(&priv->i2c_props, &blanking_mode[1], 1); - tda8295_set_video_std(t); + tda8295_set_video_std(fe); blanking_mode[1] = 0x03; tuner_i2c_xfer_send(&priv->i2c_props, blanking_mode, 2); msleep(20); - tda8295_i2c_bridge(t, 1); + tda8295_i2c_bridge(fe, 1); - if (t->fe.ops.tuner_ops.set_analog_params) - t->fe.ops.tuner_ops.set_analog_params(&t->fe, ¶ms); + if (fe->ops.tuner_ops.set_analog_params) + fe->ops.tuner_ops.set_analog_params(fe, ¶ms); if (priv->cfg.agcf) - priv->cfg.agcf(&t->fe); + priv->cfg.agcf(fe); - if (tda8295_has_signal(t)) + if (tda8295_has_signal(fe)) tuner_dbg("tda8295 is locked\n"); else tuner_dbg("tda8295 not locked, no signal?\n"); - tda8295_i2c_bridge(t, 0); + tda8295_i2c_bridge(fe, 0); } /*---------------------------------------------------------------------*/ -static int tda8290_has_signal(struct tuner *t) +static int tda8290_has_signal(struct dvb_frontend *fe) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char i2c_get_afc[1] = { 0x1B }; unsigned char afc = 0; @@ -452,33 +458,35 @@ static int tda8290_has_signal(struct tuner *t) /*---------------------------------------------------------------------*/ -static void tda8290_standby(struct tuner *t) +static void tda8290_standby(struct dvb_frontend *fe) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; + unsigned char cb1[] = { 0x30, 0xD0 }; unsigned char tda8290_standby[] = { 0x00, 0x02 }; unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; - tda8290_i2c_bridge(t, 1); + tda8290_i2c_bridge(fe, 1); if (priv->tda827x_ver != 0) cb1[1] = 0x90; i2c_transfer(priv->i2c_props.adap, &msg, 1); - tda8290_i2c_bridge(t, 0); + tda8290_i2c_bridge(fe, 0); tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2); tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2); } -static void tda8295_standby(struct tuner *t) +static void tda8295_standby(struct dvb_frontend *fe) { - tda8295_agc1_out(t, 0); /* Put AGC in tri-state */ + tda8295_agc1_out(fe, 0); /* Put AGC in tri-state */ - tda8295_power(t, 0); + tda8295_power(fe, 0); } -static void tda8290_init_if(struct tuner *t) +static void tda8290_init_if(struct dvb_frontend *fe) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; + struct tuner *t = priv->t; unsigned char set_VS[] = { 0x30, 0x6F }; unsigned char set_GP00_CF[] = { 0x20, 0x01 }; @@ -491,9 +499,9 @@ static void tda8290_init_if(struct tuner *t) tuner_i2c_xfer_send(&priv->i2c_props, set_VS, 2); } -static void tda8295_init_if(struct tuner *t) +static void tda8295_init_if(struct dvb_frontend *fe) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; static unsigned char set_adc_ctl[] = { 0x33, 0x14 }; static unsigned char set_adc_ctl2[] = { 0x34, 0x00 }; @@ -503,10 +511,10 @@ static void tda8295_init_if(struct tuner *t) static unsigned char set_pll_reg10[] = { 0x42, 0x61 }; static unsigned char set_gpio_reg0[] = { 0x44, 0x0b }; - tda8295_power(t, 1); + tda8295_power(fe, 1); - tda8295_set_easy_mode(t, 0); - tda8295_set_video_std(t); + tda8295_set_easy_mode(fe, 0); + tda8295_set_video_std(fe); tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl, 2); tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl2, 2); @@ -516,13 +524,13 @@ static void tda8295_init_if(struct tuner *t) tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg10, 2); tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_reg0, 2); - tda8295_agc1_out(t, 0); - tda8295_agc2_out(t, 0); + tda8295_agc1_out(fe, 0); + tda8295_agc2_out(fe, 0); } -static void tda8290_init_tuner(struct tuner *t) +static void tda8290_init_tuner(struct dvb_frontend *fe) { - struct tda8290_priv *priv = t->fe.analog_demod_priv; + struct tda8290_priv *priv = fe->analog_demod_priv; unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, @@ -532,20 +540,20 @@ static void tda8290_init_tuner(struct tuner *t) if (priv->tda827x_ver != 0) msg.buf = tda8275a_init; - tda8290_i2c_bridge(t, 1); + tda8290_i2c_bridge(fe, 1); i2c_transfer(priv->i2c_props.adap, &msg, 1); - tda8290_i2c_bridge(t, 0); + tda8290_i2c_bridge(fe, 0); } /*---------------------------------------------------------------------*/ -static void tda829x_release(struct tuner *t) +static void tda829x_release(struct dvb_frontend *fe) { - if (t->fe.ops.tuner_ops.release) - t->fe.ops.tuner_ops.release(&t->fe); + if (fe->ops.tuner_ops.release) + fe->ops.tuner_ops.release(fe); - kfree(t->fe.analog_demod_priv); - t->fe.analog_demod_priv = NULL; + kfree(fe->analog_demod_priv); + fe->analog_demod_priv = NULL; } static struct analog_tuner_ops tda8290_tuner_ops = { @@ -581,8 +589,9 @@ int tda8290_attach(struct tuner *t) priv->i2c_props.adap = t->i2c.adapter; priv->cfg.config = &t->config; priv->cfg.tuner_callback = t->tuner_callback; + priv->t = t; - tda8290_i2c_bridge(t, 1); + tda8290_i2c_bridge(&t->fe, 1); /* probe for tuner chip */ tuners_found = 0; tuner_addrs = 0; @@ -598,7 +607,7 @@ int tda8290_attach(struct tuner *t) behind the bridge and we choose the highest address that doesn't give a response now */ - tda8290_i2c_bridge(t, 0); + tda8290_i2c_bridge(&t->fe, 0); if(tuners_found > 1) for (i = 0; i < tuners_found; i++) { msg.addr = tuner_addrs & 0xff; @@ -619,7 +628,7 @@ int tda8290_attach(struct tuner *t) priv->tda827x_addr = tuner_addrs; msg.addr = tuner_addrs; - tda8290_i2c_bridge(t, 1); + tda8290_i2c_bridge(&t->fe, 1); ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); if( ret != 1) @@ -648,8 +657,8 @@ int tda8290_attach(struct tuner *t) priv->cfg.tda827x_lpsel = 0; t->mode = V4L2_TUNER_ANALOG_TV; - tda8290_init_tuner(t); - tda8290_init_if(t); + tda8290_init_tuner(&t->fe); + tda8290_init_if(&t->fe); return 0; } EXPORT_SYMBOL_GPL(tda8290_attach); @@ -669,8 +678,9 @@ int tda8295_attach(struct tuner *t) priv->i2c_props.addr = t->i2c.addr; priv->i2c_props.adap = t->i2c.adapter; + priv->t = t; - tda8295_i2c_bridge(t, 1); + tda8295_i2c_bridge(&t->fe, 1); /* probe for tuner chip */ tuners_found = 0; tuner_addrs = 0; @@ -686,7 +696,7 @@ int tda8295_attach(struct tuner *t) behind the bridge and we choose the highest address that doesn't give a response now */ - tda8295_i2c_bridge(t, 0); + tda8295_i2c_bridge(&t->fe, 0); if (tuners_found > 1) for (i = 0; i < tuners_found; i++) { msg.addr = tuner_addrs & 0xff; @@ -707,9 +717,9 @@ int tda8295_attach(struct tuner *t) priv->tda827x_addr = tuner_addrs; msg.addr = tuner_addrs; - tda8295_i2c_bridge(t, 1); + tda8295_i2c_bridge(&t->fe, 1); ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); - tda8295_i2c_bridge(t, 0); + tda8295_i2c_bridge(&t->fe, 0); if (ret != 1) tuner_warn("TDA827x access failed!\n"); if ((data & 0x3c) == 0) { @@ -737,7 +747,7 @@ int tda8295_attach(struct tuner *t) priv->cfg.tda827x_lpsel = 0; t->mode = V4L2_TUNER_ANALOG_TV; - tda8295_init_if(t); + tda8295_init_if(&t->fe); return 0; } EXPORT_SYMBOL_GPL(tda8295_attach); diff --git a/linux/drivers/media/video/tda9887.c b/linux/drivers/media/video/tda9887.c index 394e13504..1edb1299f 100644 --- a/linux/drivers/media/video/tda9887.c +++ b/linux/drivers/media/video/tda9887.c @@ -25,17 +25,19 @@ */ #define tda9887_info(fmt, arg...) do {\ - printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ - i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) + printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ + i2c_adapter_id(priv->t->i2c.adapter), priv->t->i2c.addr , ##arg); } while (0) #define tda9887_dbg(fmt, arg...) do {\ if (tuner_debug) \ - printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ - i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) + printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ + i2c_adapter_id(priv->t->i2c.adapter), priv->t->i2c.addr , ##arg); } while (0) struct tda9887_priv { struct tuner_i2c_props i2c_props; unsigned char data[4]; + + struct tuner *t; }; /* ---------------------------------------------------------------------- */ @@ -266,8 +268,10 @@ static struct tvnorm radio_mono = { /* ---------------------------------------------------------------------- */ -static void dump_read_message(struct tuner *t, unsigned char *buf) +static void dump_read_message(struct dvb_frontend *fe, unsigned char *buf) { + struct tda9887_priv *priv = fe->analog_demod_priv; + static char *afc[16] = { "- 12.5 kHz", "- 37.5 kHz", @@ -294,8 +298,10 @@ static void dump_read_message(struct tuner *t, unsigned char *buf) tda9887_info(" vfi level : %s\n", (buf[0] & 0x80) ? "high" : "low"); } -static void dump_write_message(struct tuner *t, unsigned char *buf) +static void dump_write_message(struct dvb_frontend *fe, unsigned char *buf) { + struct tda9887_priv *priv = fe->analog_demod_priv; + static char *sound[4] = { "AM/TV", "FM/radio", @@ -390,9 +396,12 @@ static void dump_write_message(struct tuner *t, unsigned char *buf) /* ---------------------------------------------------------------------- */ -static int tda9887_set_tvnorm(struct tuner *t, char *buf) +static int tda9887_set_tvnorm(struct dvb_frontend *fe) { + struct tda9887_priv *priv = fe->analog_demod_priv; + struct tuner *t = priv->t; struct tvnorm *norm = NULL; + char *buf = priv->data; int i; if (t->mode == V4L2_TUNER_RADIO) { @@ -437,8 +446,11 @@ module_param(qss, int, 0644); module_param(adjust, int, 0644); #endif -static int tda9887_set_insmod(struct tuner *t, char *buf) +static int tda9887_set_insmod(struct dvb_frontend *fe) { + struct tda9887_priv *priv = fe->analog_demod_priv; + char *buf = priv->data; + if (UNSET != port1) { if (port1) buf[1] |= cOutputPort1Inactive; @@ -466,8 +478,12 @@ static int tda9887_set_insmod(struct tuner *t, char *buf) return 0; } -static int tda9887_set_config(struct tuner *t, char *buf) +static int tda9887_set_config(struct dvb_frontend *fe) { + struct tda9887_priv *priv = fe->analog_demod_priv; + struct tuner *t = priv->t; + char *buf = priv->data; + if (t->tda9887_config & TDA9887_PORT1_ACTIVE) buf[1] &= ~cOutputPort1Inactive; if (t->tda9887_config & TDA9887_PORT1_INACTIVE) @@ -521,26 +537,27 @@ static int tda9887_set_config(struct tuner *t, char *buf) /* ---------------------------------------------------------------------- */ -static int tda9887_status(struct tuner *t) +static int tda9887_status(struct dvb_frontend *fe) { - struct tda9887_priv *priv = t->fe.analog_demod_priv; + struct tda9887_priv *priv = fe->analog_demod_priv; unsigned char buf[1]; int rc; memset(buf,0,sizeof(buf)); if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,buf,1))) tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc); - dump_read_message(t, buf); + dump_read_message(fe, buf); return 0; } -static void tda9887_configure(struct tuner *t) +static void tda9887_configure(struct dvb_frontend *fe) { - struct tda9887_priv *priv = t->fe.analog_demod_priv; + struct tda9887_priv *priv = fe->analog_demod_priv; + struct tuner *t = priv->t; int rc; memset(priv->data,0,sizeof(priv->data)); - tda9887_set_tvnorm(t,priv->data); + tda9887_set_tvnorm(fe); /* A note on the port settings: These settings tend to depend on the specifics of the board. @@ -558,8 +575,8 @@ static void tda9887_configure(struct tuner *t) priv->data[1] |= cOutputPort1Inactive; priv->data[1] |= cOutputPort2Inactive; - tda9887_set_config(t,priv->data); - tda9887_set_insmod(t,priv->data); + tda9887_set_config(fe); + tda9887_set_insmod(fe); if (t->mode == T_STANDBY) { priv->data[1] |= cForcedMuteAudioON; @@ -568,28 +585,28 @@ static void tda9887_configure(struct tuner *t) tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1],priv->data[2],priv->data[3]); if (tuner_debug > 1) - dump_write_message(t, priv->data); + dump_write_message(fe, priv->data); if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,priv->data,4))) tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); if (tuner_debug > 2) { msleep_interruptible(1000); - tda9887_status(t); + tda9887_status(fe); } } /* ---------------------------------------------------------------------- */ -static void tda9887_tuner_status(struct tuner *t) +static void tda9887_tuner_status(struct dvb_frontend *fe) { - struct tda9887_priv *priv = t->fe.analog_demod_priv; + struct tda9887_priv *priv = fe->analog_demod_priv; tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]); } -static int tda9887_get_afc(struct tuner *t) +static int tda9887_get_afc(struct dvb_frontend *fe) { - struct tda9887_priv *priv = t->fe.analog_demod_priv; + struct tda9887_priv *priv = fe->analog_demod_priv; static int AFC_BITS_2_kHz[] = { -12500, -37500, -62500, -97500, -112500, -137500, -162500, -187500, @@ -605,20 +622,20 @@ static int tda9887_get_afc(struct tuner *t) return afc; } -static void tda9887_standby(struct tuner *t) +static void tda9887_standby(struct dvb_frontend *fe) { - tda9887_configure(t); + tda9887_configure(fe); } -static void tda9887_set_freq(struct tuner *t, unsigned int freq) +static void tda9887_set_freq(struct dvb_frontend *fe, unsigned int freq) { - tda9887_configure(t); + tda9887_configure(fe); } -static void tda9887_release(struct tuner *t) +static void tda9887_release(struct dvb_frontend *fe) { - kfree(t->fe.analog_demod_priv); - t->fe.analog_demod_priv = NULL; + kfree(fe->analog_demod_priv); + fe->analog_demod_priv = NULL; } static struct analog_tuner_ops tda9887_tuner_ops = { @@ -641,6 +658,7 @@ int tda9887_tuner_init(struct tuner *t) priv->i2c_props.addr = t->i2c.addr; priv->i2c_props.adap = t->i2c.adapter; + priv->t = t; strlcpy(t->i2c.name, "tda9887", sizeof(t->i2c.name)); diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index d743581bf..7c52d616a 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -102,9 +102,10 @@ static struct i2c_client client_template; /* ---------------------------------------------------------------------- */ -static void fe_set_freq(struct tuner *t, unsigned int freq) +static void fe_set_freq(struct dvb_frontend *fe, unsigned int freq) { - struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; + struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; + struct tuner *t = fe->analog_demod_priv; struct analog_parameters params = { .frequency = freq, @@ -117,39 +118,38 @@ static void fe_set_freq(struct tuner *t, unsigned int freq) tuner_warn("Tuner frontend module has no way to set freq\n"); return; } - fe_tuner_ops->set_analog_params(&t->fe, ¶ms); + fe_tuner_ops->set_analog_params(fe, ¶ms); } -static void fe_release(struct tuner *t) +static void fe_release(struct dvb_frontend *fe) { - struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; - - if (fe_tuner_ops->release) - fe_tuner_ops->release(&t->fe); + if (fe->ops.tuner_ops.release) + fe->ops.tuner_ops.release(fe); - t->fe.ops.analog_demod_ops = NULL; + fe->ops.analog_demod_ops = NULL; + /* DO NOT kfree(t->fe.analog_demod_priv) */ + fe->analog_demod_priv = NULL; } -static void fe_standby(struct tuner *t) +static void fe_standby(struct dvb_frontend *fe) { - struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; + struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; if (fe_tuner_ops->sleep) - fe_tuner_ops->sleep(&t->fe); + fe_tuner_ops->sleep(fe); } -static int fe_has_signal(struct tuner *t) +static int fe_has_signal(struct dvb_frontend *fe) { - struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; u16 strength = 0; - if (fe_tuner_ops->get_rf_strength) - fe_tuner_ops->get_rf_strength(&t->fe, &strength); + if (fe->ops.tuner_ops.get_rf_strength) + fe->ops.tuner_ops.get_rf_strength(fe, &strength); return strength; } -static void tuner_status(struct tuner *t); +static void tuner_status(struct dvb_frontend *fe); static struct analog_tuner_ops tuner_core_ops = { .set_tv_freq = fe_set_freq, @@ -185,7 +185,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) else freq = tv_range[1] * 16; } - ops->set_tv_freq(t, freq); + ops->set_tv_freq(&t->fe, freq); } static void set_radio_freq(struct i2c_client *c, unsigned int freq) @@ -213,7 +213,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) freq = radio_range[1] * 16000; } - ops->set_radio_freq(t, freq); + ops->set_radio_freq(&t->fe, freq); } static void set_freq(struct i2c_client *c, unsigned long freq) @@ -306,7 +306,7 @@ static void set_type(struct i2c_client *c, unsigned int type, /* discard private data, in case set_type() was previously called */ if ((ops) && (ops->release)) - ops->release(t); + ops->release(&t->fe); switch (t->type) { case TUNER_MT2032: @@ -386,6 +386,7 @@ static void set_type(struct i2c_client *c, unsigned int type, strlcpy(t->i2c.name, fe_tuner_ops->info.name, sizeof(t->i2c.name)); t->fe.ops.analog_demod_ops = &tuner_core_ops; + t->fe.analog_demod_priv = t; } tuner_info("type set to %s\n", t->i2c.name); @@ -567,8 +568,9 @@ static int tuner_fixup_std(struct tuner *t) return 0; } -static void tuner_status(struct tuner *t) +static void tuner_status(struct dvb_frontend *fe) { + struct tuner *t = fe->analog_demod_priv; unsigned long freq, freq_fraction; struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; @@ -602,10 +604,11 @@ static void tuner_status(struct tuner *t) tuner_info("Stereo: yes\n"); } if ((ops) && (ops->has_signal)) { - tuner_info("Signal strength: %d\n", ops->has_signal(t)); + tuner_info("Signal strength: %d\n", ops->has_signal(fe)); } if ((ops) && (ops->is_stereo)) { - tuner_info("Stereo: %s\n", ops->is_stereo(t) ? "yes" : "no"); + tuner_info("Stereo: %s\n", ops->is_stereo(fe) ? + "yes" : "no"); } } @@ -775,7 +778,7 @@ static int tuner_detach(struct i2c_client *client) MOD_DEC_USE_COUNT; #endif if ((ops) && (ops->release)) - ops->release(t); + ops->release(&t->fe); kfree(t); return 0; @@ -800,7 +803,7 @@ 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 ((ops) && (ops->standby)) - ops->standby(t); + ops->standby(&t->fe); return EINVAL; } return 0; @@ -857,7 +860,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) return 0; t->mode = T_STANDBY; if ((ops) && (ops->standby)) - ops->standby(t); + ops->standby(&t->fe); break; #ifdef CONFIG_VIDEO_V4L1 case VIDIOCSAUDIO: @@ -926,7 +929,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) vt->flags &= ~VIDEO_TUNER_STEREO_ON; } else { if ((ops) && (ops->is_stereo)) { - if (ops->is_stereo(t)) + if (ops->is_stereo(&t->fe)) vt->flags |= VIDEO_TUNER_STEREO_ON; else @@ -935,7 +938,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) } } if ((ops) && (ops->has_signal)) - vt->signal = ops->has_signal(t); + vt->signal = ops->has_signal(&t->fe); vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */ @@ -966,7 +969,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) va->mode = (tuner_status & TUNER_STATUS_STEREO) ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; } else if ((ops) && (ops->is_stereo)) - va->mode = ops->is_stereo(t) + va->mode = ops->is_stereo(&t->fe) ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; } return 0; @@ -1057,7 +1060,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) tuner->type = t->mode; if ((ops) && (ops->get_afc)) - tuner->afc = ops->get_afc(t); + tuner->afc = ops->get_afc(&t->fe); if (t->mode == V4L2_TUNER_ANALOG_TV) tuner->capability |= V4L2_TUNER_CAP_NORM; if (t->mode != V4L2_TUNER_RADIO) { @@ -1073,16 +1076,20 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) u32 tuner_status; fe_tuner_ops->get_status(&t->fe, &tuner_status); - tuner->rxsubchans = (tuner_status & TUNER_STATUS_STEREO) ? - V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; + tuner->rxsubchans = + (tuner_status & TUNER_STATUS_STEREO) ? + V4L2_TUNER_SUB_STEREO : + V4L2_TUNER_SUB_MONO; } else { if ((ops) && (ops->is_stereo)) { - tuner->rxsubchans = ops->is_stereo(t) ? - V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; + tuner->rxsubchans = + ops->is_stereo(&t->fe) ? + V4L2_TUNER_SUB_STEREO : + V4L2_TUNER_SUB_MONO; } } if ((ops) && (ops->has_signal)) - tuner->signal = ops->has_signal(t); + tuner->signal = ops->has_signal(&t->fe); tuner->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; tuner->audmode = t->audmode; @@ -1108,7 +1115,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) } case VIDIOC_LOG_STATUS: if ((ops) && (ops->tuner_status)) - ops->tuner_status(t); + ops->tuner_status(&t->fe); break; } diff --git a/linux/drivers/media/video/tuner-driver.h b/linux/drivers/media/video/tuner-driver.h index db6be5d52..e9d7dc061 100644 --- a/linux/drivers/media/video/tuner-driver.h +++ b/linux/drivers/media/video/tuner-driver.h @@ -32,14 +32,14 @@ extern unsigned const int tuner_count; struct tuner; struct analog_tuner_ops { - void (*set_tv_freq)(struct tuner *t, unsigned int freq); - void (*set_radio_freq)(struct tuner *t, unsigned int freq); - int (*has_signal)(struct tuner *t); - int (*is_stereo)(struct tuner *t); - int (*get_afc)(struct tuner *t); - void (*tuner_status)(struct tuner *t); - void (*standby)(struct tuner *t); - void (*release)(struct tuner *t); + void (*set_tv_freq)(struct dvb_frontend *fe, unsigned int freq); + void (*set_radio_freq)(struct dvb_frontend *fe, unsigned int freq); + int (*has_signal)(struct dvb_frontend *fe); + int (*is_stereo)(struct dvb_frontend *fe); + int (*get_afc)(struct dvb_frontend *fe); + void (*tuner_status)(struct dvb_frontend *fe); + void (*standby)(struct dvb_frontend *fe); + void (*release)(struct dvb_frontend *fe); }; struct tuner { |