Commit 1dde7a4f authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

V4L/DVB (6436): tuner: move analog_tuner_ops into dvb_frontend_ops

Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Reviewed-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 5bea1cd3
...@@ -62,6 +62,8 @@ struct dvb_tuner_info { ...@@ -62,6 +62,8 @@ struct dvb_tuner_info {
u32 bandwidth_step; u32 bandwidth_step;
}; };
struct analog_tuner_ops;
struct analog_parameters { struct analog_parameters {
unsigned int frequency; unsigned int frequency;
unsigned int mode; unsigned int mode;
...@@ -146,6 +148,7 @@ struct dvb_frontend_ops { ...@@ -146,6 +148,7 @@ struct dvb_frontend_ops {
int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire); int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
struct dvb_tuner_ops tuner_ops; struct dvb_tuner_ops tuner_ops;
struct analog_tuner_ops *analog_demod_ops;
}; };
#define MAX_EVENT 8 #define MAX_EVENT 8
......
...@@ -519,7 +519,7 @@ static void tda829x_release(struct tuner *t) ...@@ -519,7 +519,7 @@ static void tda829x_release(struct tuner *t)
t->priv = NULL; t->priv = NULL;
} }
static struct tuner_operations tda8290_tuner_ops = { static struct analog_tuner_ops tda8290_tuner_ops = {
.set_tv_freq = tda8290_set_freq, .set_tv_freq = tda8290_set_freq,
.set_radio_freq = tda8290_set_freq, .set_radio_freq = tda8290_set_freq,
.has_signal = tda8290_has_signal, .has_signal = tda8290_has_signal,
...@@ -527,7 +527,7 @@ static struct tuner_operations tda8290_tuner_ops = { ...@@ -527,7 +527,7 @@ static struct tuner_operations tda8290_tuner_ops = {
.release = tda829x_release, .release = tda829x_release,
}; };
static struct tuner_operations tda8295_tuner_ops = { static struct analog_tuner_ops tda8295_tuner_ops = {
.set_tv_freq = tda8295_set_freq, .set_tv_freq = tda8295_set_freq,
.set_radio_freq = tda8295_set_freq, .set_radio_freq = tda8295_set_freq,
.has_signal = tda8295_has_signal, .has_signal = tda8295_has_signal,
...@@ -612,7 +612,7 @@ int tda8290_attach(struct tuner *t) ...@@ -612,7 +612,7 @@ int tda8290_attach(struct tuner *t)
if (t->fe.ops.tuner_ops.sleep) if (t->fe.ops.tuner_ops.sleep)
t->fe.ops.tuner_ops.sleep(&t->fe); t->fe.ops.tuner_ops.sleep(&t->fe);
memcpy(&t->ops, &tda8290_tuner_ops, sizeof(struct tuner_operations)); t->fe.ops.analog_demod_ops = &tda8290_tuner_ops;
tuner_info("type set to %s\n", t->i2c.name); tuner_info("type set to %s\n", t->i2c.name);
...@@ -703,7 +703,7 @@ int tda8295_attach(struct tuner *t) ...@@ -703,7 +703,7 @@ int tda8295_attach(struct tuner *t)
priv->tda827x_ver |= 1; /* signifies 8295 vs 8290 */ priv->tda827x_ver |= 1; /* signifies 8295 vs 8290 */
tuner_info("type set to %s\n", t->i2c.name); tuner_info("type set to %s\n", t->i2c.name);
memcpy(&t->ops, &tda8295_tuner_ops, sizeof(struct tuner_operations)); t->fe.ops.analog_demod_ops = &tda8295_tuner_ops;
priv->cfg.tda827x_lpsel = 0; priv->cfg.tda827x_lpsel = 0;
t->mode = V4L2_TUNER_ANALOG_TV; t->mode = V4L2_TUNER_ANALOG_TV;
......
...@@ -610,7 +610,7 @@ static void tda9887_release(struct tuner *t) ...@@ -610,7 +610,7 @@ static void tda9887_release(struct tuner *t)
t->priv = NULL; t->priv = NULL;
} }
static struct tuner_operations tda9887_tuner_ops = { static struct analog_tuner_ops tda9887_tuner_ops = {
.set_tv_freq = tda9887_set_freq, .set_tv_freq = tda9887_set_freq,
.set_radio_freq = tda9887_set_freq, .set_radio_freq = tda9887_set_freq,
.standby = tda9887_standby, .standby = tda9887_standby,
...@@ -636,7 +636,7 @@ int tda9887_tuner_init(struct tuner *t) ...@@ -636,7 +636,7 @@ int tda9887_tuner_init(struct tuner *t)
tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr, tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr,
t->i2c.driver->driver.name); t->i2c.driver->driver.name);
memcpy(&t->ops, &tda9887_tuner_ops, sizeof(struct tuner_operations)); t->fe.ops.analog_demod_ops = &tda9887_tuner_ops;
return 0; return 0;
} }
......
...@@ -122,16 +122,28 @@ static int fe_has_signal(struct tuner *t) ...@@ -122,16 +122,28 @@ static int fe_has_signal(struct tuner *t)
return strength; 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 */ /* Set tuner frequency, freq in Units of 62.5kHz = 1/16MHz */
static void set_tv_freq(struct i2c_client *c, unsigned int freq) static void set_tv_freq(struct i2c_client *c, unsigned int freq)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;
if (t->type == UNSET) { if (t->type == UNSET) {
tuner_warn ("tuner type not set\n"); tuner_warn ("tuner type not set\n");
return; 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"); tuner_warn ("Tuner has no way to set tv freq\n");
return; return;
} }
...@@ -146,18 +158,19 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -146,18 +158,19 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
else else
freq = tv_range[1] * 16; 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) static void set_radio_freq(struct i2c_client *c, unsigned int freq)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;
if (t->type == UNSET) { if (t->type == UNSET) {
tuner_warn ("tuner type not set\n"); tuner_warn ("tuner type not set\n");
return; 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"); tuner_warn ("tuner has no way to set radio frequency\n");
return; return;
} }
...@@ -173,7 +186,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) ...@@ -173,7 +186,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
freq = radio_range[1] * 16000; 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) static void set_freq(struct i2c_client *c, unsigned long freq)
...@@ -235,6 +248,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -235,6 +248,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; 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]; unsigned char buffer[4];
if (type == UNSET || type == TUNER_ABSENT) { if (type == UNSET || type == TUNER_ABSENT) {
...@@ -262,8 +276,8 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -262,8 +276,8 @@ static void set_type(struct i2c_client *c, unsigned int type,
} }
/* discard private data, in case set_type() was previously called */ /* discard private data, in case set_type() was previously called */
if (t->ops.release) if ((ops) && (ops->release))
t->ops.release(t); ops->release(t);
else { else {
kfree(t->priv); kfree(t->priv);
t->priv = NULL; t->priv = NULL;
...@@ -339,15 +353,12 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -339,15 +353,12 @@ static void set_type(struct i2c_client *c, unsigned int type,
break; break;
} }
if ((fe_tuner_ops->set_analog_params) && if (((NULL == ops) ||
((NULL == t->ops.set_tv_freq) && (NULL == t->ops.set_radio_freq))) { ((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)); strlcpy(t->i2c.name, fe_tuner_ops->info.name, sizeof(t->i2c.name));
t->ops.set_tv_freq = fe_set_freq; t->fe.ops.analog_demod_ops = &tuner_core_ops;
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;
} }
tuner_info("type set to %s\n", t->i2c.name); tuner_info("type set to %s\n", t->i2c.name);
...@@ -524,6 +535,7 @@ static void tuner_status(struct tuner *t) ...@@ -524,6 +535,7 @@ static void tuner_status(struct tuner *t)
{ {
unsigned long freq, freq_fraction; unsigned long freq, freq_fraction;
struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; 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; const char *p;
switch (t->mode) { switch (t->mode) {
...@@ -553,11 +565,11 @@ static void tuner_status(struct tuner *t) ...@@ -553,11 +565,11 @@ static void tuner_status(struct tuner *t)
if (tuner_status & TUNER_STATUS_STEREO) if (tuner_status & TUNER_STATUS_STEREO)
tuner_info("Stereo: yes\n"); tuner_info("Stereo: yes\n");
} }
if (t->ops.has_signal) { if ((ops) && (ops->has_signal)) {
tuner_info("Signal strength: %d\n", t->ops.has_signal(t)); tuner_info("Signal strength: %d\n", ops->has_signal(t));
} }
if (t->ops.is_stereo) { if ((ops) && (ops->is_stereo)) {
tuner_info("Stereo: %s\n", t->ops.is_stereo(t) ? "yes" : "no"); tuner_info("Stereo: %s\n", ops->is_stereo(t) ? "yes" : "no");
} }
} }
...@@ -584,7 +596,6 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -584,7 +596,6 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
t->type = UNSET; t->type = UNSET;
t->audmode = V4L2_TUNER_MODE_STEREO; t->audmode = V4L2_TUNER_MODE_STEREO;
t->mode_mask = T_UNINITIALIZED; t->mode_mask = T_UNINITIALIZED;
t->ops.tuner_status = tuner_status;
if (show_i2c) { if (show_i2c) {
unsigned char buffer[16]; unsigned char buffer[16];
...@@ -701,6 +712,7 @@ static int tuner_probe(struct i2c_adapter *adap) ...@@ -701,6 +712,7 @@ static int tuner_probe(struct i2c_adapter *adap)
static int tuner_detach(struct i2c_client *client) static int tuner_detach(struct i2c_client *client)
{ {
struct tuner *t = i2c_get_clientdata(client); struct tuner *t = i2c_get_clientdata(client);
struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;
int err; int err;
err = i2c_detach_client(&t->i2c); err = i2c_detach_client(&t->i2c);
...@@ -710,8 +722,8 @@ static int tuner_detach(struct i2c_client *client) ...@@ -710,8 +722,8 @@ static int tuner_detach(struct i2c_client *client)
return err; return err;
} }
if (t->ops.release) if ((ops) && (ops->release))
t->ops.release(t); ops->release(t);
else { else {
kfree(t->priv); kfree(t->priv);
} }
...@@ -728,6 +740,8 @@ static int tuner_detach(struct i2c_client *client) ...@@ -728,6 +740,8 @@ static int tuner_detach(struct i2c_client *client)
static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd) 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) if (mode == t->mode)
return 0; return 0;
...@@ -735,8 +749,8 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, ...@@ -735,8 +749,8 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode,
if (check_mode(t, cmd) == EINVAL) { if (check_mode(t, cmd) == EINVAL) {
t->mode = T_STANDBY; t->mode = T_STANDBY;
if (t->ops.standby) if ((ops) && (ops->standby))
t->ops.standby(t); ops->standby(t);
return EINVAL; return EINVAL;
} }
return 0; return 0;
...@@ -759,6 +773,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -759,6 +773,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
{ {
struct tuner *t = i2c_get_clientdata(client); struct tuner *t = i2c_get_clientdata(client);
struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; 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) if (tuner_debug>1)
v4l_i2c_print_ioctl(&(t->i2c),cmd); v4l_i2c_print_ioctl(&(t->i2c),cmd);
...@@ -785,8 +800,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -785,8 +800,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL)
return 0; return 0;
t->mode = T_STANDBY; t->mode = T_STANDBY;
if (t->ops.standby) if ((ops) && (ops->standby))
t->ops.standby(t); ops->standby(t);
break; break;
#ifdef CONFIG_VIDEO_V4L1 #ifdef CONFIG_VIDEO_V4L1
case VIDIOCSAUDIO: case VIDIOCSAUDIO:
...@@ -854,8 +869,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -854,8 +869,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
else else
vt->flags &= ~VIDEO_TUNER_STEREO_ON; vt->flags &= ~VIDEO_TUNER_STEREO_ON;
} else { } else {
if (t->ops.is_stereo) { if ((ops) && (ops->is_stereo)) {
if (t->ops.is_stereo(t)) if (ops->is_stereo(t))
vt->flags |= vt->flags |=
VIDEO_TUNER_STEREO_ON; VIDEO_TUNER_STEREO_ON;
else else
...@@ -863,8 +878,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -863,8 +878,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
~VIDEO_TUNER_STEREO_ON; ~VIDEO_TUNER_STEREO_ON;
} }
} }
if (t->ops.has_signal) if ((ops) && (ops->has_signal))
vt->signal = t->ops.has_signal(t); vt->signal = ops->has_signal(t);
vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */ vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */
...@@ -894,8 +909,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -894,8 +909,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
fe_tuner_ops->get_status(&t->fe, &tuner_status); fe_tuner_ops->get_status(&t->fe, &tuner_status);
va->mode = (tuner_status & TUNER_STATUS_STEREO) va->mode = (tuner_status & TUNER_STATUS_STEREO)
? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
} else if (t->ops.is_stereo) } else if ((ops) && (ops->is_stereo))
va->mode = t->ops.is_stereo(t) va->mode = ops->is_stereo(t)
? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
} }
return 0; return 0;
...@@ -985,8 +1000,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -985,8 +1000,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
switch_v4l2(); switch_v4l2();
tuner->type = t->mode; tuner->type = t->mode;
if (t->ops.get_afc) if ((ops) && (ops->get_afc))
tuner->afc=t->ops.get_afc(t); tuner->afc = ops->get_afc(t);
if (t->mode == V4L2_TUNER_ANALOG_TV) if (t->mode == V4L2_TUNER_ANALOG_TV)
tuner->capability |= V4L2_TUNER_CAP_NORM; tuner->capability |= V4L2_TUNER_CAP_NORM;
if (t->mode != V4L2_TUNER_RADIO) { if (t->mode != V4L2_TUNER_RADIO) {
...@@ -1005,13 +1020,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -1005,13 +1020,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
tuner->rxsubchans = (tuner_status & TUNER_STATUS_STEREO) ? tuner->rxsubchans = (tuner_status & TUNER_STATUS_STEREO) ?
V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO;
} else { } else {
if (t->ops.is_stereo) { if ((ops) && (ops->is_stereo)) {
tuner->rxsubchans = t->ops.is_stereo(t) ? tuner->rxsubchans = ops->is_stereo(t) ?
V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO;
} }
} }
if (t->ops.has_signal) if ((ops) && (ops->has_signal))
tuner->signal = t->ops.has_signal(t); tuner->signal = ops->has_signal(t);
tuner->capability |= tuner->capability |=
V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
tuner->audmode = t->audmode; tuner->audmode = t->audmode;
...@@ -1036,8 +1051,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -1036,8 +1051,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
break; break;
} }
case VIDIOC_LOG_STATUS: case VIDIOC_LOG_STATUS:
if (t->ops.tuner_status) if ((ops) && (ops->tuner_status))
t->ops.tuner_status(t); ops->tuner_status(t);
break; break;
} }
......
...@@ -31,7 +31,7 @@ extern unsigned const int tuner_count; ...@@ -31,7 +31,7 @@ extern unsigned const int tuner_count;
struct tuner; struct tuner;
struct tuner_operations { struct analog_tuner_ops {
void (*set_tv_freq)(struct tuner *t, unsigned int freq); void (*set_tv_freq)(struct tuner *t, unsigned int freq);
void (*set_radio_freq)(struct tuner *t, unsigned int freq); void (*set_radio_freq)(struct tuner *t, unsigned int freq);
int (*has_signal)(struct tuner *t); int (*has_signal)(struct tuner *t);
...@@ -66,8 +66,6 @@ struct tuner { ...@@ -66,8 +66,6 @@ struct tuner {
unsigned int config; unsigned int config;
int (*tuner_callback) (void *dev, int command,int arg); int (*tuner_callback) (void *dev, int command,int arg);
struct tuner_operations ops;
}; };
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment