diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-10-21 12:40:56 -0400 |
---|---|---|
committer | Michael Krufky <mkrufky@linuxtv.org> | 2007-10-21 12:40:56 -0400 |
commit | e49bb6b1caf8169505d2d84a8181d77c6d3f9acf (patch) | |
tree | dcf48a8a983c32e889df42361582342980bd29a5 /linux/drivers/media/video/tuner-core.c | |
parent | d9d95216cef86d580d36f7a13cc80bcb4973c4c8 (diff) | |
download | mediapointer-dvb-s2-e49bb6b1caf8169505d2d84a8181d77c6d3f9acf.tar.gz mediapointer-dvb-s2-e49bb6b1caf8169505d2d84a8181d77c6d3f9acf.tar.bz2 |
tuner: move analog_tuner_ops into dvb_frontend_ops
From: Michael Krufky <mkrufky@linuxtv.org>
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/dvb/dvb-core/dvb_frontend.h | 3
linux/drivers/media/video/tda8290.c | 8 +-
linux/drivers/media/video/tda9887.c | 4 -
linux/drivers/media/video/tuner-core.c | 91 +++++++++++++-----------
linux/drivers/media/video/tuner-driver.h | 4 -
5 files changed, 63 insertions(+), 47 deletions(-)
Diffstat (limited to 'linux/drivers/media/video/tuner-core.c')
-rw-r--r-- | linux/drivers/media/video/tuner-core.c | 91 |
1 files changed, 53 insertions, 38 deletions
diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index e528435f5..23abb715b 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -147,16 +147,28 @@ static int fe_has_signal(struct tuner *t) return strength; } +static void tuner_status(struct tuner *t); + +static struct analog_tuner_ops tuner_core_ops = { + .set_tv_freq = fe_set_freq, + .set_radio_freq = fe_set_freq, + .standby = fe_standby, + .release = fe_release, + .has_signal = fe_has_signal, + .tuner_status = tuner_status +}; + /* Set tuner frequency, freq in Units of 62.5kHz = 1/16MHz */ 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; if (t->type == UNSET) { tuner_warn ("tuner type not set\n"); return; } - if (NULL == t->ops.set_tv_freq) { + if ((NULL == ops) || (NULL == ops->set_tv_freq)) { tuner_warn ("Tuner has no way to set tv freq\n"); return; } @@ -171,18 +183,19 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) else freq = tv_range[1] * 16; } - t->ops.set_tv_freq(t, freq); + ops->set_tv_freq(t, freq); } 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; if (t->type == UNSET) { tuner_warn ("tuner type not set\n"); return; } - if (NULL == t->ops.set_radio_freq) { + if ((NULL == ops) || (NULL == ops->set_radio_freq)) { tuner_warn ("tuner has no way to set radio frequency\n"); return; } @@ -198,7 +211,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) freq = radio_range[1] * 16000; } - t->ops.set_radio_freq(t, freq); + ops->set_radio_freq(t, freq); } static void set_freq(struct i2c_client *c, unsigned long freq) @@ -260,6 +273,7 @@ static void set_type(struct i2c_client *c, unsigned int type, { struct tuner *t = i2c_get_clientdata(c); struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; + struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; unsigned char buffer[4]; if (type == UNSET || type == TUNER_ABSENT) { @@ -289,8 +303,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->ops.release) - t->ops.release(t); + if ((ops) && (ops->release)) + ops->release(t); else { kfree(t->priv); t->priv = NULL; @@ -366,15 +380,12 @@ static void set_type(struct i2c_client *c, unsigned int type, break; } - if ((fe_tuner_ops->set_analog_params) && - ((NULL == t->ops.set_tv_freq) && (NULL == t->ops.set_radio_freq))) { + if (((NULL == ops) || + ((NULL == ops->set_tv_freq) && (NULL == ops->set_radio_freq))) && + (fe_tuner_ops->set_analog_params)) { strlcpy(t->i2c.name, fe_tuner_ops->info.name, sizeof(t->i2c.name)); - t->ops.set_tv_freq = fe_set_freq; - t->ops.set_radio_freq = fe_set_freq; - t->ops.standby = fe_standby; - t->ops.release = fe_release; - t->ops.has_signal = fe_has_signal; + t->fe.ops.analog_demod_ops = &tuner_core_ops; } tuner_info("type set to %s\n", t->i2c.name); @@ -560,6 +571,7 @@ static void tuner_status(struct tuner *t) { 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; const char *p; switch (t->mode) { @@ -589,11 +601,11 @@ static void tuner_status(struct tuner *t) if (tuner_status & TUNER_STATUS_STEREO) tuner_info("Stereo: yes\n"); } - if (t->ops.has_signal) { - tuner_info("Signal strength: %d\n", t->ops.has_signal(t)); + if ((ops) && (ops->has_signal)) { + tuner_info("Signal strength: %d\n", ops->has_signal(t)); } - if (t->ops.is_stereo) { - tuner_info("Stereo: %s\n", t->ops.is_stereo(t) ? "yes" : "no"); + if ((ops) && (ops->is_stereo)) { + tuner_info("Stereo: %s\n", ops->is_stereo(t) ? "yes" : "no"); } } @@ -625,7 +637,6 @@ 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->ops.tuner_status = tuner_status; if (show_i2c) { unsigned char buffer[16]; @@ -750,6 +761,7 @@ static int tuner_probe(struct i2c_adapter *adap) static int tuner_detach(struct i2c_client *client) { struct tuner *t = i2c_get_clientdata(client); + struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; int err; err = i2c_detach_client(&t->i2c); @@ -762,8 +774,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->ops.release) - t->ops.release(t); + if ((ops) && (ops->release)) + ops->release(t); else { kfree(t->priv); #if 0 @@ -783,6 +795,8 @@ MOD_DEC_USE_COUNT; static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd) { + struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; + if (mode == t->mode) return 0; @@ -790,8 +804,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->ops.standby) - t->ops.standby(t); + if ((ops) && (ops->standby)) + ops->standby(t); return EINVAL; } return 0; @@ -820,6 +834,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct tuner *t = i2c_get_clientdata(client); struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; + struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; if (tuner_debug>1) v4l_i2c_print_ioctl(&(t->i2c),cmd); @@ -846,8 +861,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->ops.standby) - t->ops.standby(t); + if ((ops) && (ops->standby)) + ops->standby(t); break; #ifdef CONFIG_VIDEO_V4L1 case VIDIOCSAUDIO: @@ -915,8 +930,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) else vt->flags &= ~VIDEO_TUNER_STEREO_ON; } else { - if (t->ops.is_stereo) { - if (t->ops.is_stereo(t)) + if ((ops) && (ops->is_stereo)) { + if (ops->is_stereo(t)) vt->flags |= VIDEO_TUNER_STEREO_ON; else @@ -924,8 +939,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ~VIDEO_TUNER_STEREO_ON; } } - if (t->ops.has_signal) - vt->signal = t->ops.has_signal(t); + if ((ops) && (ops->has_signal)) + vt->signal = ops->has_signal(t); vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */ @@ -955,8 +970,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) fe_tuner_ops->get_status(&t->fe, &tuner_status); va->mode = (tuner_status & TUNER_STATUS_STEREO) ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; - } else if (t->ops.is_stereo) - va->mode = t->ops.is_stereo(t) + } else if ((ops) && (ops->is_stereo)) + va->mode = ops->is_stereo(t) ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; } return 0; @@ -1046,8 +1061,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) switch_v4l2(); tuner->type = t->mode; - if (t->ops.get_afc) - tuner->afc=t->ops.get_afc(t); + if ((ops) && (ops->get_afc)) + tuner->afc = ops->get_afc(t); if (t->mode == V4L2_TUNER_ANALOG_TV) tuner->capability |= V4L2_TUNER_CAP_NORM; if (t->mode != V4L2_TUNER_RADIO) { @@ -1066,13 +1081,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) tuner->rxsubchans = (tuner_status & TUNER_STATUS_STEREO) ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; } else { - if (t->ops.is_stereo) { - tuner->rxsubchans = t->ops.is_stereo(t) ? + if ((ops) && (ops->is_stereo)) { + tuner->rxsubchans = ops->is_stereo(t) ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; } } - if (t->ops.has_signal) - tuner->signal = t->ops.has_signal(t); + if ((ops) && (ops->has_signal)) + tuner->signal = ops->has_signal(t); tuner->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; tuner->audmode = t->audmode; @@ -1097,8 +1112,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) break; } case VIDIOC_LOG_STATUS: - if (t->ops.tuner_status) - t->ops.tuner_status(t); + if ((ops) && (ops->tuner_status)) + ops->tuner_status(t); break; } |