summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/tuner-core.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-12-12 00:38:33 -0200
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-12-12 00:38:33 -0200
commitc30e05a83632aeb144f9d3912d39162564244a34 (patch)
tree9877e4ed4167591ccb709ffbee27d7766986dabb /linux/drivers/media/video/tuner-core.c
parentba8e7e903d8aaa290f8528c1beba1284c1d33ddf (diff)
parente2b3b766697ca509f1281178161156ab8df5b0d5 (diff)
downloadmediapointer-dvb-s2-c30e05a83632aeb144f9d3912d39162564244a34.tar.gz
mediapointer-dvb-s2-c30e05a83632aeb144f9d3912d39162564244a34.tar.bz2
merge: http://linuxtv.org/hg/~mkrufky/oxford2
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video/tuner-core.c')
-rw-r--r--linux/drivers/media/video/tuner-core.c93
1 files changed, 70 insertions, 23 deletions
diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c
index 0b3bc1c91..479afb1f6 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 };
@@ -107,23 +134,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, &params);
+ fe_tuner_ops->set_analog_params(fe, params);
}
static void fe_release(struct dvb_frontend *fe)
@@ -165,8 +186,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 +199,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 +224,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, &params);
}
static void set_radio_freq(struct i2c_client *c, unsigned int freq)
@@ -206,11 +234,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 +259,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, &params);
}
static void set_freq(struct i2c_client *c, unsigned long freq)
@@ -282,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))
@@ -324,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:
@@ -388,14 +432,16 @@ 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));
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);
@@ -1082,7 +1128,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 */
@@ -1135,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);