Commit 9b54464f authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] budget-ci: 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 e439aedf
...@@ -663,30 +663,31 @@ static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate, ...@@ -663,30 +663,31 @@ static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate,
static int philips_su1278_tt_tuner_set_params(struct dvb_frontend *fe, static int philips_su1278_tt_tuner_set_params(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params) struct dvb_frontend_parameters *params)
{ {
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
u32 div; u32 div;
u8 buf[4]; u8 buf[4];
struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) }; struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
if ((params->frequency < 950000) || (params->frequency > 2150000)) if ((p->frequency < 950000) || (p->frequency > 2150000))
return -EINVAL; return -EINVAL;
div = (params->frequency + (500 - 1)) / 500; // round correctly div = (p->frequency + (500 - 1)) / 500; /* round correctly */
buf[0] = (div >> 8) & 0x7f; buf[0] = (div >> 8) & 0x7f;
buf[1] = div & 0xff; buf[1] = div & 0xff;
buf[2] = 0x80 | ((div & 0x18000) >> 10) | 2; buf[2] = 0x80 | ((div & 0x18000) >> 10) | 2;
buf[3] = 0x20; buf[3] = 0x20;
if (params->u.qpsk.symbol_rate < 4000000) if (p->symbol_rate < 4000000)
buf[3] |= 1; buf[3] |= 1;
if (params->frequency < 1250000) if (p->frequency < 1250000)
buf[3] |= 0; buf[3] |= 0;
else if (params->frequency < 1550000) else if (p->frequency < 1550000)
buf[3] |= 0x40; buf[3] |= 0x40;
else if (params->frequency < 2050000) else if (p->frequency < 2050000)
buf[3] |= 0x80; buf[3] |= 0x80;
else if (params->frequency < 2150000) else if (p->frequency < 2150000)
buf[3] |= 0xC0; buf[3] |= 0xC0;
if (fe->ops.i2c_gate_ctrl) if (fe->ops.i2c_gate_ctrl)
...@@ -743,6 +744,7 @@ static int philips_tdm1316l_tuner_init(struct dvb_frontend *fe) ...@@ -743,6 +744,7 @@ static int philips_tdm1316l_tuner_init(struct dvb_frontend *fe)
static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
{ {
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
u8 tuner_buf[4]; u8 tuner_buf[4];
struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = tuner_buf,.len = sizeof(tuner_buf) }; struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = tuner_buf,.len = sizeof(tuner_buf) };
...@@ -750,7 +752,7 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb ...@@ -750,7 +752,7 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb
u8 band, cp, filter; u8 band, cp, filter;
// determine charge pump // determine charge pump
tuner_frequency = params->frequency + 36130000; tuner_frequency = p->frequency + 36130000;
if (tuner_frequency < 87000000) if (tuner_frequency < 87000000)
return -EINVAL; return -EINVAL;
else if (tuner_frequency < 130000000) else if (tuner_frequency < 130000000)
...@@ -775,30 +777,30 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb ...@@ -775,30 +777,30 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb
return -EINVAL; return -EINVAL;
// determine band // determine band
if (params->frequency < 49000000) if (p->frequency < 49000000)
return -EINVAL; return -EINVAL;
else if (params->frequency < 159000000) else if (p->frequency < 159000000)
band = 1; band = 1;
else if (params->frequency < 444000000) else if (p->frequency < 444000000)
band = 2; band = 2;
else if (params->frequency < 861000000) else if (p->frequency < 861000000)
band = 4; band = 4;
else else
return -EINVAL; return -EINVAL;
// setup PLL filter and TDA9889 // setup PLL filter and TDA9889
switch (params->u.ofdm.bandwidth) { switch (p->bandwidth_hz) {
case BANDWIDTH_6_MHZ: case 6000000:
tda1004x_writereg(fe, 0x0C, 0x14); tda1004x_writereg(fe, 0x0C, 0x14);
filter = 0; filter = 0;
break; break;
case BANDWIDTH_7_MHZ: case 7000000:
tda1004x_writereg(fe, 0x0C, 0x80); tda1004x_writereg(fe, 0x0C, 0x80);
filter = 0; filter = 0;
break; break;
case BANDWIDTH_8_MHZ: case 8000000:
tda1004x_writereg(fe, 0x0C, 0x14); tda1004x_writereg(fe, 0x0C, 0x14);
filter = 1; filter = 1;
break; break;
...@@ -809,7 +811,7 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb ...@@ -809,7 +811,7 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb
// calculate divisor // calculate divisor
// ((36130000+((1000000/6)/2)) + Finput)/(1000000/6) // ((36130000+((1000000/6)/2)) + Finput)/(1000000/6)
tuner_frequency = (((params->frequency / 1000) * 6) + 217280) / 1000; tuner_frequency = (((p->frequency / 1000) * 6) + 217280) / 1000;
// setup tuner buffer // setup tuner buffer
tuner_buf[0] = tuner_frequency >> 8; tuner_buf[0] = tuner_frequency >> 8;
...@@ -858,6 +860,7 @@ static struct tda1004x_config philips_tdm1316l_config_invert = { ...@@ -858,6 +860,7 @@ static struct tda1004x_config philips_tdm1316l_config_invert = {
static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
{ {
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
u8 tuner_buf[5]; u8 tuner_buf[5];
struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address, struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,
...@@ -868,7 +871,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struc ...@@ -868,7 +871,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struc
u8 band, cp, filter; u8 band, cp, filter;
// determine charge pump // determine charge pump
tuner_frequency = params->frequency + 36125000; tuner_frequency = p->frequency + 36125000;
if (tuner_frequency < 87000000) if (tuner_frequency < 87000000)
return -EINVAL; return -EINVAL;
else if (tuner_frequency < 130000000) { else if (tuner_frequency < 130000000) {
...@@ -905,7 +908,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struc ...@@ -905,7 +908,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struc
filter = 1; filter = 1;
// calculate divisor // calculate divisor
tuner_frequency = (params->frequency + 36125000 + (62500/2)) / 62500; tuner_frequency = (p->frequency + 36125000 + (62500/2)) / 62500;
// setup tuner buffer // setup tuner buffer
tuner_buf[0] = tuner_frequency >> 8; tuner_buf[0] = tuner_frequency >> 8;
......
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