From 017775baf90cbd3c43a14e4d10e00e1aca9f98f2 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Sat, 8 Dec 2007 15:06:30 -0500 Subject: tuner: combine set_tv_freq and set_radio_freq into a single set_params method From: Michael Krufky We can tell whether we are tuning television or radio by testing for struct analog_parameters *params->mode == V4L2_TUNER_RADIO There is no longer any need for separate set_tv_freq and set_radio_freq functions in the analog tuner demodulator modules. Signed-off-by: Michael Krufky --- linux/drivers/media/video/tuner-core.c | 41 ++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'linux/drivers/media/video/tuner-core.c') diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index 0b3bc1c91..df65efd46 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -107,23 +107,17 @@ MODULE_LICENSE("GPL"); /* ---------------------------------------------------------------------- */ -static void fe_set_freq(struct dvb_frontend *fe, unsigned int freq) +static void fe_set_params(struct dvb_frontend *fe, + struct analog_parameters *params) { struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; struct tuner *t = fe->analog_demod_priv; - struct analog_parameters params = { - .frequency = freq, - .mode = t->mode, - .audmode = t->audmode, - .std = t->std - }; - if (NULL == fe_tuner_ops->set_analog_params) { tuner_warn("Tuner frontend module has no way to set freq\n"); return; } - fe_tuner_ops->set_analog_params(fe, ¶ms); + fe_tuner_ops->set_analog_params(fe, params); } static void fe_release(struct dvb_frontend *fe) @@ -165,8 +159,7 @@ static int fe_has_signal(struct dvb_frontend *fe) static void tuner_status(struct dvb_frontend *fe); static struct analog_tuner_ops tuner_core_ops = { - .set_tv_freq = fe_set_freq, - .set_radio_freq = fe_set_freq, + .set_params = fe_set_params, .standby = fe_standby, .release = fe_release, .has_signal = fe_has_signal, @@ -179,11 +172,17 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) struct tuner *t = i2c_get_clientdata(c); struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; + struct analog_parameters params = { + .mode = t->mode, + .audmode = t->audmode, + .std = t->std + }; + if (t->type == UNSET) { tuner_warn ("tuner type not set\n"); return; } - if ((NULL == ops) || (NULL == ops->set_tv_freq)) { + if ((NULL == ops) || (NULL == ops->set_params)) { tuner_warn ("Tuner has no way to set tv freq\n"); return; } @@ -198,7 +197,9 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) else freq = tv_range[1] * 16; } - ops->set_tv_freq(&t->fe, freq); + params.frequency = freq; + + ops->set_params(&t->fe, ¶ms); } static void set_radio_freq(struct i2c_client *c, unsigned int freq) @@ -206,11 +207,17 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) struct tuner *t = i2c_get_clientdata(c); struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; + struct analog_parameters params = { + .mode = t->mode, + .audmode = t->audmode, + .std = t->std + }; + if (t->type == UNSET) { tuner_warn ("tuner type not set\n"); return; } - if ((NULL == ops) || (NULL == ops->set_radio_freq)) { + if ((NULL == ops) || (NULL == ops->set_params)) { tuner_warn ("tuner has no way to set radio frequency\n"); return; } @@ -225,8 +232,9 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) else freq = radio_range[1] * 16000; } + params.frequency = freq; - ops->set_radio_freq(&t->fe, freq); + ops->set_params(&t->fe, ¶ms); } static void set_freq(struct i2c_client *c, unsigned long freq) @@ -388,8 +396,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ops = t->fe.ops.analog_demod_ops; - if (((NULL == ops) || - ((NULL == ops->set_tv_freq) && (NULL == ops->set_radio_freq))) && + if (((NULL == ops) || (NULL == ops->set_params)) && (fe_tuner_ops->set_analog_params)) { strlcpy(t->i2c->name, fe_tuner_ops->info.name, sizeof(t->i2c->name)); -- cgit v1.2.3 From 1eb95e84c755878770c7a55f8fc226dd63170813 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Sun, 9 Dec 2007 00:26:48 -0500 Subject: tda8290: remove dependency on struct tuner From: Michael Krufky - remove dependency of tda8290 module on struct tuner - move tuner_foo printk macros from tuner-driver.h into tuner-core.c - clean up #includes of tuner-i2c.h / tuner-driver.h Signed-off-by: Michael Krufky --- linux/drivers/media/video/tuner-core.c | 43 +++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'linux/drivers/media/video/tuner-core.c') diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index df65efd46..0d2648e27 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -63,7 +63,34 @@ static unsigned int no_autodetect = 0; static unsigned int show_i2c = 0; /* insmod options used at runtime => read/write */ -int tuner_debug = 0; +static int tuner_debug; + +#define tuner_warn(fmt, arg...) do { \ + printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \ + i2c_adapter_id(t->i2c->adapter), \ + t->i2c->addr, ##arg); \ + } while (0) + +#define tuner_info(fmt, arg...) do { \ + printk(KERN_INFO "%s %d-%04x: " fmt, PREFIX, \ + i2c_adapter_id(t->i2c->adapter), \ + t->i2c->addr, ##arg); \ + } while (0) + +#define tuner_err(fmt, arg...) do { \ + printk(KERN_ERR "%s %d-%04x: " fmt, PREFIX, \ + i2c_adapter_id(t->i2c->adapter), \ + t->i2c->addr, ##arg); \ + } while (0) + +#define tuner_dbg(fmt, arg...) do { \ + if (tuner_debug) \ + printk(KERN_DEBUG "%s %d-%04x: " fmt, PREFIX, \ + i2c_adapter_id(t->i2c->adapter), \ + t->i2c->addr, ##arg); \ + } while (0) + +/* ------------------------------------------------------------------------ */ static unsigned int tv_range[2] = { 44, 958 }; static unsigned int radio_range[2] = { 65, 108 }; @@ -290,6 +317,15 @@ static void attach_simple_tuner(struct tuner *t) simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg); } +static void attach_tda829x(struct tuner *t) +{ + struct tda829x_config cfg = { + .lna_cfg = &t->config, + .tuner_callback = t->tuner_callback, + }; + tda829x_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg); +} + static void set_type(struct i2c_client *c, unsigned int type, unsigned int new_mode_mask, unsigned int new_config, int (*tuner_callback) (void *dev, int command,int arg)) @@ -332,7 +368,7 @@ static void set_type(struct i2c_client *c, unsigned int type, break; case TUNER_PHILIPS_TDA8290: { - tda829x_attach(t); + attach_tda829x(t); break; } case TUNER_TEA5767: @@ -1089,7 +1125,8 @@ static int tuner_probe(struct i2c_client *client) case 0x4b: /* If chip is not tda8290, don't register. since it can be tda9887*/ - if (tda829x_probe(t) == 0) { + if (tda829x_probe(t->i2c->adapter, + t->i2c->addr) == 0) { tuner_dbg("tda829x detected\n"); } else { /* Default is being tda9887 */ -- cgit v1.2.3 From 446475ffbe175d4c8c7cd071681b0c2ea1385650 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Sun, 9 Dec 2007 11:52:51 -0500 Subject: tuner: add struct analog_demod_info to struct analog_tuner_ops From: Michael Krufky Store the analog demodulator name in fe.ops.analog_demod_ops.info.name Signed-off-by: Michael Krufky --- linux/drivers/media/video/tuner-core.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'linux/drivers/media/video/tuner-core.c') diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index 0d2648e27..3cbf47a7a 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -439,6 +439,9 @@ static void set_type(struct i2c_client *c, unsigned int type, t->fe.ops.analog_demod_ops = &tuner_core_ops; t->fe.analog_demod_priv = t; + } else { + strlcpy(t->i2c->name, ops->info.name, + sizeof(t->i2c->name)); } tuner_dbg("type set to %s\n", t->i2c->name); -- cgit v1.2.3 From 84cad69d9ea1d0b5f0ea9d3983f8b7d0f068a0f0 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Sun, 9 Dec 2007 15:21:54 -0500 Subject: tuner: bug-fix: default mode was set to bogus value From: Michael Krufky Fix type inconsistency in t->mode value, causing the following: tuner' 1-0043: freq set: unknown mode: 0x0004! (only visible with tuner debug enabled) Signed-off-by: Michael Krufky --- linux/drivers/media/video/tuner-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'linux/drivers/media/video/tuner-core.c') diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index 3cbf47a7a..479afb1f6 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -1182,11 +1182,11 @@ register_client: /* Sets a default mode */ if (t->mode_mask & T_ANALOG_TV) { - t->mode = T_ANALOG_TV; + t->mode = V4L2_TUNER_ANALOG_TV; } else if (t->mode_mask & T_RADIO) { - t->mode = T_RADIO; + t->mode = V4L2_TUNER_RADIO; } else { - t->mode = T_DIGITAL_TV; + t->mode = V4L2_TUNER_DIGITAL_TV; } set_type(client, t->type, t->mode_mask, t->config, t->tuner_callback); list_add_tail(&t->list, &tuner_list); -- cgit v1.2.3