Commit 8e6c4be3 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] tda665x: split set_frequency from set_state

On tda665x, set_state only sets frequency. As the kABI for set_state
is meant to be used only on special cases, split the function
into two, in order to allow it to be latter used by a DVBv5
cache params logic.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent cffdbfe7
......@@ -111,9 +111,8 @@ static int tda665x_get_status(struct dvb_frontend *fe, u32 *status)
return err;
}
static int tda665x_set_state(struct dvb_frontend *fe,
enum tuner_param param,
struct tuner_state *tstate)
static int tda665x_set_frequency(struct dvb_frontend *fe,
u32 new_frequency)
{
struct tda665x_state *state = fe->tuner_priv;
const struct tda665x_config *config = state->config;
......@@ -121,14 +120,15 @@ static int tda665x_set_state(struct dvb_frontend *fe,
u8 buf[4];
int err = 0;
if (param & DVBFE_TUNER_FREQUENCY) {
frequency = tstate->frequency;
if ((frequency < config->frequency_max) || (frequency > config->frequency_min)) {
printk(KERN_ERR "%s: Frequency beyond limits, frequency=%d\n", __func__, frequency);
if ((new_frequency < config->frequency_max)
|| (new_frequency > config->frequency_min)) {
printk(KERN_ERR "%s: Frequency beyond limits, frequency=%d\n",
__func__, new_frequency);
return -EINVAL;
}
frequency = new_frequency;
frequency += config->frequency_offst;
frequency *= config->ref_multiplier;
frequency += config->ref_divider >> 1;
......@@ -140,7 +140,7 @@ static int tda665x_set_state(struct dvb_frontend *fe,
buf[3] = 0x00;
/* restore frequency */
frequency = tstate->frequency;
frequency = new_frequency;
if (frequency < 153000000) {
/* VHF-L */
......@@ -187,14 +187,12 @@ static int tda665x_set_state(struct dvb_frontend *fe,
goto exit;
if (status == 1) {
printk(KERN_DEBUG "%s: Tuner Phase locked: status=%d\n", __func__, status);
printk(KERN_DEBUG "%s: Tuner Phase locked: status=%d\n",
__func__, status);
state->frequency = frequency; /* cache successful state */
} else {
printk(KERN_ERR "%s: No Phase lock: status=%d\n", __func__, status);
}
} else {
printk(KERN_ERR "%s: Unknown parameter (param=%d)\n", __func__, param);
return -EINVAL;
printk(KERN_ERR "%s: No Phase lock: status=%d\n",
__func__, status);
}
return 0;
......@@ -203,6 +201,17 @@ static int tda665x_set_state(struct dvb_frontend *fe,
return err;
}
static int tda665x_set_state(struct dvb_frontend *fe,
enum tuner_param param,
struct tuner_state *tstate)
{
if (param & DVBFE_TUNER_FREQUENCY)
return tda665x_set_frequency(fe, tstate->frequency);
printk(KERN_ERR "%s: Unknown parameter (param=%d)\n", __func__, param);
return -EINVAL;
}
static int tda665x_release(struct dvb_frontend *fe)
{
struct tda665x_state *state = fe->tuner_priv;
......
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