Commit 9481f400 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] tuner-simple: use DVBv5 parameters on set_params()

Despite its name, tuner-simple has a complex logic to set freqs ;)

Basically, it can be called by two different ways: via set_params()
or via calc_regs() callbacks. Both are bound to the DVBv3 API.
Also, set_params internally calls calc_regs().

In order to get rid of DVBv3 params at set_params(), it shouldn't
call calc_regs() anymore. The code duplication is very small,
as most of the code there is just to check for invalid parameters.

With regards to calc_regs(), it should still trust on bandwidth and
frequency parameters passed via DVBv3, until a later patch fixes
it.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 57605c96
...@@ -791,24 +791,26 @@ static int simple_set_params(struct dvb_frontend *fe, ...@@ -791,24 +791,26 @@ static int simple_set_params(struct dvb_frontend *fe,
} }
static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf,
const struct dvb_frontend_parameters *params) const u32 delsys,
const u32 frequency,
const u32 bandwidth)
{ {
struct tuner_simple_priv *priv = fe->tuner_priv; struct tuner_simple_priv *priv = fe->tuner_priv;
switch (priv->type) { switch (priv->type) {
case TUNER_PHILIPS_FMD1216ME_MK3: case TUNER_PHILIPS_FMD1216ME_MK3:
case TUNER_PHILIPS_FMD1216MEX_MK3: case TUNER_PHILIPS_FMD1216MEX_MK3:
if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && if (bandwidth == 8000000 &&
params->frequency >= 158870000) frequency >= 158870000)
buf[3] |= 0x08; buf[3] |= 0x08;
break; break;
case TUNER_PHILIPS_TD1316: case TUNER_PHILIPS_TD1316:
/* determine band */ /* determine band */
buf[3] |= (params->frequency < 161000000) ? 1 : buf[3] |= (frequency < 161000000) ? 1 :
(params->frequency < 444000000) ? 2 : 4; (frequency < 444000000) ? 2 : 4;
/* setup PLL filter */ /* setup PLL filter */
if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) if (bandwidth == 8000000)
buf[3] |= 1 << 3; buf[3] |= 1 << 3;
break; break;
case TUNER_PHILIPS_TUV1236D: case TUNER_PHILIPS_TUV1236D:
...@@ -819,12 +821,11 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, ...@@ -819,12 +821,11 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf,
if (dtv_input[priv->nr]) if (dtv_input[priv->nr])
new_rf = dtv_input[priv->nr]; new_rf = dtv_input[priv->nr];
else else
switch (params->u.vsb.modulation) { switch (delsys) {
case QAM_64: case SYS_DVBC_ANNEX_B:
case QAM_256:
new_rf = 1; new_rf = 1;
break; break;
case VSB_8: case SYS_ATSC:
default: default:
new_rf = 0; new_rf = 0;
break; break;
...@@ -838,7 +839,9 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, ...@@ -838,7 +839,9 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf,
} }
static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
const struct dvb_frontend_parameters *params) const u32 delsys,
const u32 freq,
const u32 bw)
{ {
/* This function returns the tuned frequency on success, 0 on error */ /* This function returns the tuned frequency on success, 0 on error */
struct tuner_simple_priv *priv = fe->tuner_priv; struct tuner_simple_priv *priv = fe->tuner_priv;
...@@ -847,7 +850,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, ...@@ -847,7 +850,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
u8 config, cb; u8 config, cb;
u32 div; u32 div;
int ret; int ret;
unsigned frequency = params->frequency / 62500; u32 frequency = freq / 62500;
if (!tun->stepsize) { if (!tun->stepsize) {
/* tuner-core was loaded before the digital tuner was /* tuner-core was loaded before the digital tuner was
...@@ -871,7 +874,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, ...@@ -871,7 +874,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
buf[2] = config; buf[2] = config;
buf[3] = cb; buf[3] = cb;
simple_set_dvb(fe, buf, params); simple_set_dvb(fe, buf, delsys, freq, bw);
tuner_dbg("%s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", tuner_dbg("%s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
tun->name, div, buf[0], buf[1], buf[2], buf[3]); tun->name, div, buf[0], buf[1], buf[2], buf[3]);
...@@ -884,13 +887,29 @@ static int simple_dvb_calc_regs(struct dvb_frontend *fe, ...@@ -884,13 +887,29 @@ static int simple_dvb_calc_regs(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params, struct dvb_frontend_parameters *params,
u8 *buf, int buf_len) u8 *buf, int buf_len)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
u32 delsys = c->delivery_system;
u32 bw = c->bandwidth_hz;
struct tuner_simple_priv *priv = fe->tuner_priv; struct tuner_simple_priv *priv = fe->tuner_priv;
u32 frequency; u32 frequency;
if (buf_len < 5) if (buf_len < 5)
return -EINVAL; return -EINVAL;
frequency = simple_dvb_configure(fe, buf+1, params); switch (delsys) {
case SYS_DVBT:
case SYS_DVBT2:
if (params->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
bw = 6000000;
if (params->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
bw = 7000000;
if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
bw = 8000000;
break;
default:
break;
}
frequency = simple_dvb_configure(fe, buf+1, delsys, params->frequency, bw);
if (frequency == 0) if (frequency == 0)
return -EINVAL; return -EINVAL;
...@@ -906,7 +925,12 @@ static int simple_dvb_calc_regs(struct dvb_frontend *fe, ...@@ -906,7 +925,12 @@ static int simple_dvb_calc_regs(struct dvb_frontend *fe,
static int simple_dvb_set_params(struct dvb_frontend *fe, static int simple_dvb_set_params(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params) struct dvb_frontend_parameters *params)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
u32 delsys = c->delivery_system;
u32 bw = c->bandwidth_hz;
u32 freq = c->frequency;
struct tuner_simple_priv *priv = fe->tuner_priv; struct tuner_simple_priv *priv = fe->tuner_priv;
u32 frequency;
u32 prev_freq, prev_bw; u32 prev_freq, prev_bw;
int ret; int ret;
u8 buf[5]; u8 buf[5];
...@@ -917,9 +941,14 @@ static int simple_dvb_set_params(struct dvb_frontend *fe, ...@@ -917,9 +941,14 @@ static int simple_dvb_set_params(struct dvb_frontend *fe,
prev_freq = priv->frequency; prev_freq = priv->frequency;
prev_bw = priv->bandwidth; prev_bw = priv->bandwidth;
ret = simple_dvb_calc_regs(fe, params, buf, 5); frequency = simple_dvb_configure(fe, buf+1, delsys, freq, bw);
if (ret != 5) if (frequency == 0)
goto fail; return -EINVAL;
buf[0] = priv->i2c_props.addr;
priv->frequency = frequency;
priv->bandwidth = bw;
/* put analog demod in standby when tuning digital */ /* put analog demod in standby when tuning digital */
if (fe->ops.analog_ops.standby) if (fe->ops.analog_ops.standby)
......
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