Commit 80d8d498 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] dvb-pll: use DVBv5 parameters on set_params()

Instead of using DVBv3 parameters, rely on DVBv5 parameters to
set the tuner.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent cba3f88a
...@@ -61,8 +61,7 @@ struct dvb_pll_desc { ...@@ -61,8 +61,7 @@ struct dvb_pll_desc {
u32 min; u32 min;
u32 max; u32 max;
u32 iffreq; u32 iffreq;
void (*set)(struct dvb_frontend *fe, u8 *buf, void (*set)(struct dvb_frontend *fe, u8 *buf);
const struct dvb_frontend_parameters *params);
u8 *initdata; u8 *initdata;
u8 *initdata2; u8 *initdata2;
u8 *sleepdata; u8 *sleepdata;
...@@ -93,10 +92,10 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { ...@@ -93,10 +92,10 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
}, },
}; };
static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf, static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf)
const struct dvb_frontend_parameters *params)
{ {
if (BANDWIDTH_7_MHZ == params->u.ofdm.bandwidth) u32 bw = fe->dtv_property_cache.bandwidth_hz;
if (bw == 7000000)
buf[3] |= 0x10; buf[3] |= 0x10;
} }
...@@ -186,10 +185,10 @@ static struct dvb_pll_desc dvb_pll_env57h1xd5 = { ...@@ -186,10 +185,10 @@ static struct dvb_pll_desc dvb_pll_env57h1xd5 = {
/* Philips TDA6650/TDA6651 /* Philips TDA6650/TDA6651
* used in Panasonic ENV77H11D5 * used in Panasonic ENV77H11D5
*/ */
static void tda665x_bw(struct dvb_frontend *fe, u8 *buf, static void tda665x_bw(struct dvb_frontend *fe, u8 *buf)
const struct dvb_frontend_parameters *params)
{ {
if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) u32 bw = fe->dtv_property_cache.bandwidth_hz;
if (bw == 8000000)
buf[3] |= 0x08; buf[3] |= 0x08;
} }
...@@ -220,10 +219,10 @@ static struct dvb_pll_desc dvb_pll_tda665x = { ...@@ -220,10 +219,10 @@ static struct dvb_pll_desc dvb_pll_tda665x = {
/* Infineon TUA6034 /* Infineon TUA6034
* used in LG TDTP E102P * used in LG TDTP E102P
*/ */
static void tua6034_bw(struct dvb_frontend *fe, u8 *buf, static void tua6034_bw(struct dvb_frontend *fe, u8 *buf)
const struct dvb_frontend_parameters *params)
{ {
if (BANDWIDTH_7_MHZ != params->u.ofdm.bandwidth) u32 bw = fe->dtv_property_cache.bandwidth_hz;
if (bw == 7000000)
buf[3] |= 0x08; buf[3] |= 0x08;
} }
...@@ -244,10 +243,10 @@ static struct dvb_pll_desc dvb_pll_tua6034 = { ...@@ -244,10 +243,10 @@ static struct dvb_pll_desc dvb_pll_tua6034 = {
/* ALPS TDED4 /* ALPS TDED4
* used in Nebula-Cards and USB boxes * used in Nebula-Cards and USB boxes
*/ */
static void tded4_bw(struct dvb_frontend *fe, u8 *buf, static void tded4_bw(struct dvb_frontend *fe, u8 *buf)
const struct dvb_frontend_parameters *params)
{ {
if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) u32 bw = fe->dtv_property_cache.bandwidth_hz;
if (bw == 8000000)
buf[3] |= 0x04; buf[3] |= 0x04;
} }
...@@ -319,11 +318,11 @@ static struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = { ...@@ -319,11 +318,11 @@ static struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
}, },
}; };
static void opera1_bw(struct dvb_frontend *fe, u8 *buf, static void opera1_bw(struct dvb_frontend *fe, u8 *buf)
const struct dvb_frontend_parameters *params)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct dvb_pll_priv *priv = fe->tuner_priv; struct dvb_pll_priv *priv = fe->tuner_priv;
u32 b_w = (params->u.qpsk.symbol_rate * 27) / 32000; u32 b_w = (c->symbol_rate * 27) / 32000;
struct i2c_msg msg = { struct i2c_msg msg = {
.addr = priv->pll_i2c_address, .addr = priv->pll_i2c_address,
.flags = 0, .flags = 0,
...@@ -392,8 +391,7 @@ static struct dvb_pll_desc dvb_pll_opera1 = { ...@@ -392,8 +391,7 @@ static struct dvb_pll_desc dvb_pll_opera1 = {
} }
}; };
static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf, static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf)
const struct dvb_frontend_parameters *params)
{ {
struct dvb_pll_priv *priv = fe->tuner_priv; struct dvb_pll_priv *priv = fe->tuner_priv;
struct i2c_msg msg = { struct i2c_msg msg = {
...@@ -537,30 +535,29 @@ static struct dvb_pll_desc *pll_list[] = { ...@@ -537,30 +535,29 @@ static struct dvb_pll_desc *pll_list[] = {
/* code */ /* code */
static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf, static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
const struct dvb_frontend_parameters *params) const u32 frequency)
{ {
struct dvb_pll_priv *priv = fe->tuner_priv; struct dvb_pll_priv *priv = fe->tuner_priv;
struct dvb_pll_desc *desc = priv->pll_desc; struct dvb_pll_desc *desc = priv->pll_desc;
u32 div; u32 div;
int i; int i;
if (params->frequency != 0 && (params->frequency < desc->min || if (frequency && (frequency < desc->min || frequency > desc->max))
params->frequency > desc->max))
return -EINVAL; return -EINVAL;
for (i = 0; i < desc->count; i++) { for (i = 0; i < desc->count; i++) {
if (params->frequency > desc->entries[i].limit) if (frequency > desc->entries[i].limit)
continue; continue;
break; break;
} }
if (debug) if (debug)
printk("pll: %s: freq=%d | i=%d/%d\n", desc->name, printk("pll: %s: freq=%d | i=%d/%d\n", desc->name,
params->frequency, i, desc->count); frequency, i, desc->count);
if (i == desc->count) if (i == desc->count)
return -EINVAL; return -EINVAL;
div = (params->frequency + desc->iffreq + div = (frequency + desc->iffreq +
desc->entries[i].stepsize/2) / desc->entries[i].stepsize; desc->entries[i].stepsize/2) / desc->entries[i].stepsize;
buf[0] = div >> 8; buf[0] = div >> 8;
buf[1] = div & 0xff; buf[1] = div & 0xff;
...@@ -568,7 +565,7 @@ static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf, ...@@ -568,7 +565,7 @@ static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
buf[3] = desc->entries[i].cb; buf[3] = desc->entries[i].cb;
if (desc->set) if (desc->set)
desc->set(fe, buf, params); desc->set(fe, buf);
if (debug) if (debug)
printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
...@@ -614,6 +611,7 @@ static int dvb_pll_sleep(struct dvb_frontend *fe) ...@@ -614,6 +611,7 @@ static int dvb_pll_sleep(struct dvb_frontend *fe)
static int dvb_pll_set_params(struct dvb_frontend *fe, static int dvb_pll_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;
struct dvb_pll_priv *priv = fe->tuner_priv; struct dvb_pll_priv *priv = fe->tuner_priv;
u8 buf[4]; u8 buf[4];
struct i2c_msg msg = struct i2c_msg msg =
...@@ -625,7 +623,8 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, ...@@ -625,7 +623,8 @@ static int dvb_pll_set_params(struct dvb_frontend *fe,
if (priv->i2c == NULL) if (priv->i2c == NULL)
return -EINVAL; return -EINVAL;
if ((result = dvb_pll_configure(fe, buf, params)) < 0) result = dvb_pll_configure(fe, buf, c->frequency);
if (result < 0)
return result; return result;
else else
frequency = result; frequency = result;
...@@ -637,7 +636,12 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, ...@@ -637,7 +636,12 @@ static int dvb_pll_set_params(struct dvb_frontend *fe,
} }
priv->frequency = frequency; priv->frequency = frequency;
priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0; if (c->bandwidth_hz <= 6000000)
priv->bandwidth = BANDWIDTH_6_MHZ;
else if (c->bandwidth_hz <= 7000000)
priv->bandwidth = BANDWIDTH_7_MHZ;
if (c->bandwidth_hz <= 8000000)
priv->bandwidth = BANDWIDTH_8_MHZ;
return 0; return 0;
} }
...@@ -653,7 +657,8 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe, ...@@ -653,7 +657,8 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe,
if (buf_len < 5) if (buf_len < 5)
return -EINVAL; return -EINVAL;
if ((result = dvb_pll_configure(fe, buf+1, params)) < 0) result = dvb_pll_configure(fe, buf + 1, params->frequency);
if (result < 0)
return result; return result;
else else
frequency = result; frequency = result;
......
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