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) ...@@ -111,9 +111,8 @@ static int tda665x_get_status(struct dvb_frontend *fe, u32 *status)
return err; return err;
} }
static int tda665x_set_state(struct dvb_frontend *fe, static int tda665x_set_frequency(struct dvb_frontend *fe,
enum tuner_param param, u32 new_frequency)
struct tuner_state *tstate)
{ {
struct tda665x_state *state = fe->tuner_priv; struct tda665x_state *state = fe->tuner_priv;
const struct tda665x_config *config = state->config; const struct tda665x_config *config = state->config;
...@@ -121,14 +120,15 @@ static int tda665x_set_state(struct dvb_frontend *fe, ...@@ -121,14 +120,15 @@ static int tda665x_set_state(struct dvb_frontend *fe,
u8 buf[4]; u8 buf[4];
int err = 0; int err = 0;
if (param & DVBFE_TUNER_FREQUENCY) { if ((new_frequency < config->frequency_max)
|| (new_frequency > config->frequency_min)) {
frequency = tstate->frequency; printk(KERN_ERR "%s: Frequency beyond limits, frequency=%d\n",
if ((frequency < config->frequency_max) || (frequency > config->frequency_min)) { __func__, new_frequency);
printk(KERN_ERR "%s: Frequency beyond limits, frequency=%d\n", __func__, frequency);
return -EINVAL; return -EINVAL;
} }
frequency = new_frequency;
frequency += config->frequency_offst; frequency += config->frequency_offst;
frequency *= config->ref_multiplier; frequency *= config->ref_multiplier;
frequency += config->ref_divider >> 1; frequency += config->ref_divider >> 1;
...@@ -140,7 +140,7 @@ static int tda665x_set_state(struct dvb_frontend *fe, ...@@ -140,7 +140,7 @@ static int tda665x_set_state(struct dvb_frontend *fe,
buf[3] = 0x00; buf[3] = 0x00;
/* restore frequency */ /* restore frequency */
frequency = tstate->frequency; frequency = new_frequency;
if (frequency < 153000000) { if (frequency < 153000000) {
/* VHF-L */ /* VHF-L */
...@@ -187,14 +187,12 @@ static int tda665x_set_state(struct dvb_frontend *fe, ...@@ -187,14 +187,12 @@ static int tda665x_set_state(struct dvb_frontend *fe,
goto exit; goto exit;
if (status == 1) { 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 */ state->frequency = frequency; /* cache successful state */
} else { } else {
printk(KERN_ERR "%s: No Phase lock: status=%d\n", __func__, status); 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;
} }
return 0; return 0;
...@@ -203,6 +201,17 @@ static int tda665x_set_state(struct dvb_frontend *fe, ...@@ -203,6 +201,17 @@ static int tda665x_set_state(struct dvb_frontend *fe,
return err; 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) static int tda665x_release(struct dvb_frontend *fe)
{ {
struct tda665x_state *state = fe->tuner_priv; 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