[media] tda8261: don't use set_state/get_state callbacks
Those callbacks are meant to be used only on some very specific cases. There's absolutely no need to do that at tda8261, as the only parameter that it allows to be set/get is the frequency. So, use the standard get_params() and get_frequency() kABI ops. There's no need to touch at any bridge driver, as all interactions are done via the macros at tda8261_cfg.h. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
8fdc25bf61
commit
e417668d40
|
@ -83,88 +83,71 @@ static int tda8261_get_status(struct dvb_frontend *fe, u32 *status)
|
||||||
static const u32 div_tab[] = { 2000, 1000, 500, 250, 125 }; /* kHz */
|
static const u32 div_tab[] = { 2000, 1000, 500, 250, 125 }; /* kHz */
|
||||||
static const u8 ref_div[] = { 0x00, 0x01, 0x02, 0x05, 0x07 };
|
static const u8 ref_div[] = { 0x00, 0x01, 0x02, 0x05, 0x07 };
|
||||||
|
|
||||||
static int tda8261_get_state(struct dvb_frontend *fe,
|
static int tda8261_get_frequency(struct dvb_frontend *fe, u32 *frequency)
|
||||||
enum tuner_param param,
|
|
||||||
struct tuner_state *tstate)
|
|
||||||
{
|
{
|
||||||
struct tda8261_state *state = fe->tuner_priv;
|
struct tda8261_state *state = fe->tuner_priv;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
switch (param) {
|
*frequency = state->frequency;
|
||||||
case DVBFE_TUNER_FREQUENCY:
|
|
||||||
tstate->frequency = state->frequency;
|
|
||||||
break;
|
|
||||||
case DVBFE_TUNER_BANDWIDTH:
|
|
||||||
tstate->bandwidth = 40000000; /* FIXME! need to calculate Bandwidth */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
pr_err("%s: Unknown parameter (param=%d)\n", __func__, param);
|
|
||||||
err = -EINVAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tda8261_set_state(struct dvb_frontend *fe,
|
static int tda8261_set_params(struct dvb_frontend *fe)
|
||||||
enum tuner_param param,
|
|
||||||
struct tuner_state *tstate)
|
|
||||||
{
|
{
|
||||||
|
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
||||||
struct tda8261_state *state = fe->tuner_priv;
|
struct tda8261_state *state = fe->tuner_priv;
|
||||||
const struct tda8261_config *config = state->config;
|
const struct tda8261_config *config = state->config;
|
||||||
u32 frequency, N, status = 0;
|
u32 frequency, N, status = 0;
|
||||||
u8 buf[4];
|
u8 buf[4];
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (param & DVBFE_TUNER_FREQUENCY) {
|
/*
|
||||||
/**
|
* N = Max VCO Frequency / Channel Spacing
|
||||||
* N = Max VCO Frequency / Channel Spacing
|
* Max VCO Frequency = VCO frequency + (channel spacing - 1)
|
||||||
* Max VCO Frequency = VCO frequency + (channel spacing - 1)
|
* (to account for half channel spacing on either side)
|
||||||
* (to account for half channel spacing on either side)
|
*/
|
||||||
*/
|
frequency = c->frequency;
|
||||||
frequency = tstate->frequency;
|
if ((frequency < 950000) || (frequency > 2150000)) {
|
||||||
if ((frequency < 950000) || (frequency > 2150000)) {
|
pr_warn("%s: Frequency beyond limits, frequency=%d\n",
|
||||||
pr_warn("%s: Frequency beyond limits, frequency=%d\n", __func__, frequency);
|
__func__, frequency);
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
N = (frequency + (div_tab[config->step_size] - 1)) / div_tab[config->step_size];
|
|
||||||
pr_debug("%s: Step size=%d, Divider=%d, PG=0x%02x (%d)\n",
|
|
||||||
__func__, config->step_size, div_tab[config->step_size], N, N);
|
|
||||||
|
|
||||||
buf[0] = (N >> 8) & 0xff;
|
|
||||||
buf[1] = N & 0xff;
|
|
||||||
buf[2] = (0x01 << 7) | ((ref_div[config->step_size] & 0x07) << 1);
|
|
||||||
|
|
||||||
if (frequency < 1450000)
|
|
||||||
buf[3] = 0x00;
|
|
||||||
else if (frequency < 2000000)
|
|
||||||
buf[3] = 0x40;
|
|
||||||
else if (frequency < 2150000)
|
|
||||||
buf[3] = 0x80;
|
|
||||||
|
|
||||||
/* Set params */
|
|
||||||
if ((err = tda8261_write(state, buf)) < 0) {
|
|
||||||
pr_err("%s: I/O Error\n", __func__);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
/* sleep for some time */
|
|
||||||
pr_debug("%s: Waiting to Phase LOCK\n", __func__);
|
|
||||||
msleep(20);
|
|
||||||
/* check status */
|
|
||||||
if ((err = tda8261_get_status(fe, &status)) < 0) {
|
|
||||||
pr_err("%s: I/O Error\n", __func__);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
if (status == 1) {
|
|
||||||
pr_debug("%s: Tuner Phase locked: status=%d\n", __func__, status);
|
|
||||||
state->frequency = frequency; /* cache successful state */
|
|
||||||
} else {
|
|
||||||
pr_debug("%s: No Phase lock: status=%d\n", __func__, status);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pr_err("%s: Unknown parameter (param=%d)\n", __func__, param);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
N = (frequency + (div_tab[config->step_size] - 1)) / div_tab[config->step_size];
|
||||||
|
pr_debug("%s: Step size=%d, Divider=%d, PG=0x%02x (%d)\n",
|
||||||
|
__func__, config->step_size, div_tab[config->step_size], N, N);
|
||||||
|
|
||||||
|
buf[0] = (N >> 8) & 0xff;
|
||||||
|
buf[1] = N & 0xff;
|
||||||
|
buf[2] = (0x01 << 7) | ((ref_div[config->step_size] & 0x07) << 1);
|
||||||
|
|
||||||
|
if (frequency < 1450000)
|
||||||
|
buf[3] = 0x00;
|
||||||
|
else if (frequency < 2000000)
|
||||||
|
buf[3] = 0x40;
|
||||||
|
else if (frequency < 2150000)
|
||||||
|
buf[3] = 0x80;
|
||||||
|
|
||||||
|
/* Set params */
|
||||||
|
err = tda8261_write(state, buf);
|
||||||
|
if (err < 0) {
|
||||||
|
pr_err("%s: I/O Error\n", __func__);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
/* sleep for some time */
|
||||||
|
pr_debug("%s: Waiting to Phase LOCK\n", __func__);
|
||||||
|
msleep(20);
|
||||||
|
/* check status */
|
||||||
|
if ((err = tda8261_get_status(fe, &status)) < 0) {
|
||||||
|
pr_err("%s: I/O Error\n", __func__);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if (status == 1) {
|
||||||
|
pr_debug("%s: Tuner Phase locked: status=%d\n", __func__,
|
||||||
|
status);
|
||||||
|
state->frequency = frequency; /* cache successful state */
|
||||||
|
} else {
|
||||||
|
pr_debug("%s: No Phase lock: status=%d\n", __func__, status);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -182,14 +165,13 @@ static struct dvb_tuner_ops tda8261_ops = {
|
||||||
|
|
||||||
.info = {
|
.info = {
|
||||||
.name = "TDA8261",
|
.name = "TDA8261",
|
||||||
// .tuner_name = NULL,
|
|
||||||
.frequency_min = 950000,
|
.frequency_min = 950000,
|
||||||
.frequency_max = 2150000,
|
.frequency_max = 2150000,
|
||||||
.frequency_step = 0
|
.frequency_step = 0
|
||||||
},
|
},
|
||||||
|
|
||||||
.set_state = tda8261_set_state,
|
.set_params = tda8261_set_params,
|
||||||
.get_state = tda8261_get_state,
|
.get_frequency = tda8261_get_frequency,
|
||||||
.get_status = tda8261_get_status,
|
.get_status = tda8261_get_status,
|
||||||
.release = tda8261_release
|
.release = tda8261_release
|
||||||
};
|
};
|
||||||
|
@ -210,10 +192,7 @@ struct dvb_frontend *tda8261_attach(struct dvb_frontend *fe,
|
||||||
fe->ops.tuner_ops = tda8261_ops;
|
fe->ops.tuner_ops = tda8261_ops;
|
||||||
|
|
||||||
fe->ops.tuner_ops.info.frequency_step = div_tab[config->step_size];
|
fe->ops.tuner_ops.info.frequency_step = div_tab[config->step_size];
|
||||||
// fe->ops.tuner_ops.tuner_name = &config->buf;
|
|
||||||
|
|
||||||
// printk("%s: Attaching %s TDA8261 8PSK/QPSK tuner\n",
|
|
||||||
// __func__, fe->ops.tuner_ops.tuner_name);
|
|
||||||
pr_info("%s: Attaching TDA8261 8PSK/QPSK tuner\n", __func__);
|
pr_info("%s: Attaching TDA8261 8PSK/QPSK tuner\n", __func__);
|
||||||
|
|
||||||
return fe;
|
return fe;
|
||||||
|
|
|
@ -21,17 +21,15 @@ static int tda8261_get_frequency(struct dvb_frontend *fe, u32 *frequency)
|
||||||
{
|
{
|
||||||
struct dvb_frontend_ops *frontend_ops = &fe->ops;
|
struct dvb_frontend_ops *frontend_ops = &fe->ops;
|
||||||
struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
|
struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
|
||||||
struct tuner_state t_state;
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (tuner_ops->get_state) {
|
if (tuner_ops->get_frequency) {
|
||||||
err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &t_state);
|
err = tuner_ops->get_frequency(fe, frequency);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printk("%s: Invalid parameter\n", __func__);
|
pr_err("%s: Invalid parameter\n", __func__);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
*frequency = t_state.frequency;
|
pr_debug("%s: Frequency=%d\n", __func__, *frequency);
|
||||||
printk("%s: Frequency=%d\n", __func__, t_state.frequency);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -40,37 +38,24 @@ static int tda8261_set_frequency(struct dvb_frontend *fe, u32 frequency)
|
||||||
{
|
{
|
||||||
struct dvb_frontend_ops *frontend_ops = &fe->ops;
|
struct dvb_frontend_ops *frontend_ops = &fe->ops;
|
||||||
struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
|
struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
|
||||||
struct tuner_state t_state;
|
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
t_state.frequency = frequency;
|
if (tuner_ops->set_params) {
|
||||||
|
err = tuner_ops->set_params(fe);
|
||||||
if (tuner_ops->set_state) {
|
|
||||||
err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &t_state);
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printk("%s: Invalid parameter\n", __func__);
|
pr_err("%s: Invalid parameter\n", __func__);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printk("%s: Frequency=%d\n", __func__, t_state.frequency);
|
pr_debug("%s: Frequency=%d\n", __func__, c->frequency);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tda8261_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
|
static int tda8261_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
|
||||||
{
|
{
|
||||||
struct dvb_frontend_ops *frontend_ops = &fe->ops;
|
/* FIXME! need to calculate Bandwidth */
|
||||||
struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
|
*bandwidth = 40000000;
|
||||||
struct tuner_state t_state;
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
if (tuner_ops->get_state) {
|
|
||||||
err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &t_state);
|
|
||||||
if (err < 0) {
|
|
||||||
printk("%s: Invalid parameter\n", __func__);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
*bandwidth = t_state.bandwidth;
|
|
||||||
printk("%s: Bandwidth=%d\n", __func__, t_state.bandwidth);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue