[media] dvb: remove dvb_frontend_parameters from calc_regs()

The calc_regs() callback is used by a few frontends (mt352, nxt200x,
digitv and zl10353). On all places it is called, the parameters are
set by DVBv5 way. So, just use the DVBv5 struct and remove the
extra parameter.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Mauro Carvalho Chehab 2011-12-24 12:03:05 -03:00
parent 1466194db5
commit 249fa0b01c
8 changed files with 54 additions and 57 deletions

View File

@ -884,7 +884,6 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
} }
static int simple_dvb_calc_regs(struct dvb_frontend *fe, static int simple_dvb_calc_regs(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params,
u8 *buf, int buf_len) u8 *buf, int buf_len)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
@ -896,28 +895,14 @@ static int simple_dvb_calc_regs(struct dvb_frontend *fe,
if (buf_len < 5) if (buf_len < 5)
return -EINVAL; return -EINVAL;
switch (delsys) { frequency = simple_dvb_configure(fe, buf+1, delsys, c->frequency, bw);
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;
buf[0] = priv->i2c_props.addr; buf[0] = priv->i2c_props.addr;
priv->frequency = frequency; priv->frequency = frequency;
priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? priv->bandwidth = c->bandwidth_hz;
params->u.ofdm.bandwidth : 0;
return 5; return 5;
} }
@ -1044,7 +1029,17 @@ static int simple_get_frequency(struct dvb_frontend *fe, u32 *frequency)
static int simple_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) static int simple_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
{ {
struct tuner_simple_priv *priv = fe->tuner_priv; struct tuner_simple_priv *priv = fe->tuner_priv;
*bandwidth = priv->bandwidth; switch (priv->bandwidth) {
case 6000000:
*bandwidth = BANDWIDTH_6_MHZ;
break;
case 7000000:
*bandwidth = BANDWIDTH_7_MHZ;
break;
case 8000000:
*bandwidth = BANDWIDTH_8_MHZ;
break;
}
return 0; return 0;
} }

View File

@ -148,8 +148,9 @@ static int thomson_dtt7579_demod_init(struct dvb_frontend* fe)
return 0; return 0;
} }
static int thomson_dtt7579_tuner_calc_regs(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf, int buf_len) static int thomson_dtt7579_tuner_calc_regs(struct dvb_frontend *fe, u8* pllbuf, int buf_len)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
u32 div; u32 div;
unsigned char bs = 0; unsigned char bs = 0;
unsigned char cp = 0; unsigned char cp = 0;
@ -157,18 +158,18 @@ static int thomson_dtt7579_tuner_calc_regs(struct dvb_frontend* fe, struct dvb_f
if (buf_len < 5) if (buf_len < 5)
return -EINVAL; return -EINVAL;
div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; div = (((c->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
if (params->frequency < 542000000) if (c->frequency < 542000000)
cp = 0xb4; cp = 0xb4;
else if (params->frequency < 771000000) else if (c->frequency < 771000000)
cp = 0xbc; cp = 0xbc;
else else
cp = 0xf4; cp = 0xf4;
if (params->frequency == 0) if (c->frequency == 0)
bs = 0x03; bs = 0x03;
else if (params->frequency < 443250000) else if (c->frequency < 443250000)
bs = 0x02; bs = 0x02;
else else
bs = 0x08; bs = 0x08;
@ -342,50 +343,51 @@ static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
return 0; return 0;
} }
static int advbt771_samsung_tdtc9251dh0_tuner_calc_regs(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf, int buf_len) static int advbt771_samsung_tdtc9251dh0_tuner_calc_regs(struct dvb_frontend *fe, u8 *pllbuf, int buf_len)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
u32 div; u32 div;
unsigned char bs = 0; unsigned char bs = 0;
unsigned char cp = 0; unsigned char cp = 0;
if (buf_len < 5) return -EINVAL; if (buf_len < 5) return -EINVAL;
div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; div = (((c->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
if (params->frequency < 150000000) if (c->frequency < 150000000)
cp = 0xB4; cp = 0xB4;
else if (params->frequency < 173000000) else if (c->frequency < 173000000)
cp = 0xBC; cp = 0xBC;
else if (params->frequency < 250000000) else if (c->frequency < 250000000)
cp = 0xB4; cp = 0xB4;
else if (params->frequency < 400000000) else if (c->frequency < 400000000)
cp = 0xBC; cp = 0xBC;
else if (params->frequency < 420000000) else if (c->frequency < 420000000)
cp = 0xF4; cp = 0xF4;
else if (params->frequency < 470000000) else if (c->frequency < 470000000)
cp = 0xFC; cp = 0xFC;
else if (params->frequency < 600000000) else if (c->frequency < 600000000)
cp = 0xBC; cp = 0xBC;
else if (params->frequency < 730000000) else if (c->frequency < 730000000)
cp = 0xF4; cp = 0xF4;
else else
cp = 0xFC; cp = 0xFC;
if (params->frequency < 150000000) if (c->frequency < 150000000)
bs = 0x01; bs = 0x01;
else if (params->frequency < 173000000) else if (c->frequency < 173000000)
bs = 0x01; bs = 0x01;
else if (params->frequency < 250000000) else if (c->frequency < 250000000)
bs = 0x02; bs = 0x02;
else if (params->frequency < 400000000) else if (c->frequency < 400000000)
bs = 0x02; bs = 0x02;
else if (params->frequency < 420000000) else if (c->frequency < 420000000)
bs = 0x02; bs = 0x02;
else if (params->frequency < 470000000) else if (c->frequency < 470000000)
bs = 0x02; bs = 0x02;
else if (params->frequency < 600000000) else if (c->frequency < 600000000)
bs = 0x08; bs = 0x08;
else if (params->frequency < 730000000) else if (c->frequency < 730000000)
bs = 0x08; bs = 0x08;
else else
bs = 0x08; bs = 0x08;
@ -514,31 +516,31 @@ static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe)
return 0; return 0;
} }
static int digitv_alps_tded4_tuner_calc_regs(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf, int buf_len) static int digitv_alps_tded4_tuner_calc_regs(struct dvb_frontend *fe, u8 *pllbuf, int buf_len)
{ {
u32 div; u32 div;
struct dvb_ofdm_parameters *op = &params->u.ofdm; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
if (buf_len < 5) if (buf_len < 5)
return -EINVAL; return -EINVAL;
div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; div = (((c->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
pllbuf[0] = 0x61; pllbuf[0] = 0x61;
pllbuf[1] = (div >> 8) & 0x7F; pllbuf[1] = (div >> 8) & 0x7F;
pllbuf[2] = div & 0xFF; pllbuf[2] = div & 0xFF;
pllbuf[3] = 0x85; pllbuf[3] = 0x85;
dprintk("frequency %u, div %u\n", params->frequency, div); dprintk("frequency %u, div %u\n", c->frequency, div);
if (params->frequency < 470000000) if (c->frequency < 470000000)
pllbuf[4] = 0x02; pllbuf[4] = 0x02;
else if (params->frequency > 823000000) else if (c->frequency > 823000000)
pllbuf[4] = 0x88; pllbuf[4] = 0x88;
else else
pllbuf[4] = 0x08; pllbuf[4] = 0x08;
if (op->bandwidth == 8) if (c->bandwidth_hz == 8000000)
pllbuf[4] |= 0x04; pllbuf[4] |= 0x04;
return 5; return 5;

View File

@ -202,7 +202,7 @@ struct dvb_tuner_ops {
int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p); int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
/** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */ /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
int (*calc_regs)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len); int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len);
/** This is to allow setting tuner-specific configs */ /** This is to allow setting tuner-specific configs */
int (*set_config)(struct dvb_frontend *fe, void *priv_cfg); int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);

View File

@ -123,7 +123,7 @@ static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe, struct dvb_f
struct dvb_usb_adapter *adap = fe->dvb->priv; struct dvb_usb_adapter *adap = fe->dvb->priv;
u8 b[5]; u8 b[5];
fe->ops.tuner_ops.calc_regs(fe, fep, b, sizeof(b)); fe->ops.tuner_ops.calc_regs(fe, b, sizeof(b));
if (fe->ops.i2c_gate_ctrl) if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1); fe->ops.i2c_gate_ctrl(fe, 1);
return digitv_ctrl_msg(adap->dev, USB_WRITE_TUNER, 0, &b[1], 4, NULL, 0); return digitv_ctrl_msg(adap->dev, USB_WRITE_TUNER, 0, &b[1], 4, NULL, 0);

View File

@ -647,9 +647,9 @@ static int dvb_pll_set_params(struct dvb_frontend *fe,
} }
static int dvb_pll_calc_regs(struct dvb_frontend *fe, static int dvb_pll_calc_regs(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params,
u8 *buf, int buf_len) u8 *buf, int buf_len)
{ {
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;
int result; int result;
u32 frequency = 0; u32 frequency = 0;
@ -657,7 +657,7 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe,
if (buf_len < 5) if (buf_len < 5)
return -EINVAL; return -EINVAL;
result = dvb_pll_configure(fe, buf + 1, params->frequency); result = dvb_pll_configure(fe, buf + 1, c->frequency);
if (result < 0) if (result < 0)
return result; return result;
else else
@ -666,7 +666,7 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe,
buf[0] = priv->pll_i2c_address; buf[0] = priv->pll_i2c_address;
priv->frequency = frequency; priv->frequency = frequency;
priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0; priv->bandwidth = c->bandwidth_hz;
return 5; return 5;
} }

View File

@ -302,7 +302,7 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
_mt352_write(fe, fsm_go, 2); _mt352_write(fe, fsm_go, 2);
} else { } else {
if (fe->ops.tuner_ops.calc_regs) { if (fe->ops.tuner_ops.calc_regs) {
fe->ops.tuner_ops.calc_regs(fe, param, buf+8, 5); fe->ops.tuner_ops.calc_regs(fe, buf+8, 5);
buf[8] <<= 1; buf[8] <<= 1;
_mt352_write(fe, buf, sizeof(buf)); _mt352_write(fe, buf, sizeof(buf));
_mt352_write(fe, tuner_go, 2); _mt352_write(fe, tuner_go, 2);

View File

@ -566,7 +566,7 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
if (fe->ops.tuner_ops.calc_regs) { if (fe->ops.tuner_ops.calc_regs) {
/* get tuning information */ /* get tuning information */
fe->ops.tuner_ops.calc_regs(fe, p, buf, 5); fe->ops.tuner_ops.calc_regs(fe, buf, 5);
/* write frequency information */ /* write frequency information */
nxt200x_writetuner(state, buf); nxt200x_writetuner(state, buf);

View File

@ -367,7 +367,7 @@ static int zl10353_set_parameters(struct dvb_frontend *fe,
fe->ops.i2c_gate_ctrl(fe, 0); fe->ops.i2c_gate_ctrl(fe, 0);
} }
} else if (fe->ops.tuner_ops.calc_regs) { } else if (fe->ops.tuner_ops.calc_regs) {
fe->ops.tuner_ops.calc_regs(fe, param, pllbuf + 1, 5); fe->ops.tuner_ops.calc_regs(fe, pllbuf + 1, 5);
pllbuf[1] <<= 1; pllbuf[1] <<= 1;
zl10353_write(fe, pllbuf, sizeof(pllbuf)); zl10353_write(fe, pllbuf, sizeof(pllbuf));
} }