Commit e14e1ec6 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] lgdt3305: convert set_fontend to use DVBv5 parameters

Instead of using dvb_frontend_parameters struct, that were
designed for a subset of the supported standards, use the DVBv5
cache information.

Also, fill the supported delivery systems at dvb_frontend_ops
struct.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent ca7072dd
...@@ -266,7 +266,7 @@ static int lgdt3305_mpeg_mode_polarity(struct lgdt3305_state *state, ...@@ -266,7 +266,7 @@ static int lgdt3305_mpeg_mode_polarity(struct lgdt3305_state *state,
} }
static int lgdt3305_set_modulation(struct lgdt3305_state *state, static int lgdt3305_set_modulation(struct lgdt3305_state *state,
struct dvb_frontend_parameters *param) struct dtv_frontend_properties *p)
{ {
u8 opermode; u8 opermode;
int ret; int ret;
...@@ -279,7 +279,7 @@ static int lgdt3305_set_modulation(struct lgdt3305_state *state, ...@@ -279,7 +279,7 @@ static int lgdt3305_set_modulation(struct lgdt3305_state *state,
opermode &= ~0x03; opermode &= ~0x03;
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
opermode |= 0x03; opermode |= 0x03;
break; break;
...@@ -298,11 +298,11 @@ static int lgdt3305_set_modulation(struct lgdt3305_state *state, ...@@ -298,11 +298,11 @@ static int lgdt3305_set_modulation(struct lgdt3305_state *state,
} }
static int lgdt3305_set_filter_extension(struct lgdt3305_state *state, static int lgdt3305_set_filter_extension(struct lgdt3305_state *state,
struct dvb_frontend_parameters *param) struct dtv_frontend_properties *p)
{ {
int val; int val;
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
val = 0; val = 0;
break; break;
...@@ -321,11 +321,11 @@ static int lgdt3305_set_filter_extension(struct lgdt3305_state *state, ...@@ -321,11 +321,11 @@ static int lgdt3305_set_filter_extension(struct lgdt3305_state *state,
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static int lgdt3305_passband_digital_agc(struct lgdt3305_state *state, static int lgdt3305_passband_digital_agc(struct lgdt3305_state *state,
struct dvb_frontend_parameters *param) struct dtv_frontend_properties *p)
{ {
u16 agc_ref; u16 agc_ref;
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
agc_ref = 0x32c4; agc_ref = 0x32c4;
break; break;
...@@ -348,11 +348,11 @@ static int lgdt3305_passband_digital_agc(struct lgdt3305_state *state, ...@@ -348,11 +348,11 @@ static int lgdt3305_passband_digital_agc(struct lgdt3305_state *state,
} }
static int lgdt3305_rfagc_loop(struct lgdt3305_state *state, static int lgdt3305_rfagc_loop(struct lgdt3305_state *state,
struct dvb_frontend_parameters *param) struct dtv_frontend_properties *p)
{ {
u16 ifbw, rfbw, agcdelay; u16 ifbw, rfbw, agcdelay;
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
agcdelay = 0x04c0; agcdelay = 0x04c0;
rfbw = 0x8000; rfbw = 0x8000;
...@@ -398,11 +398,11 @@ static int lgdt3305_rfagc_loop(struct lgdt3305_state *state, ...@@ -398,11 +398,11 @@ static int lgdt3305_rfagc_loop(struct lgdt3305_state *state,
} }
static int lgdt3305_agc_setup(struct lgdt3305_state *state, static int lgdt3305_agc_setup(struct lgdt3305_state *state,
struct dvb_frontend_parameters *param) struct dtv_frontend_properties *p)
{ {
int lockdten, acqen; int lockdten, acqen;
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
lockdten = 0; lockdten = 0;
acqen = 0; acqen = 0;
...@@ -432,15 +432,15 @@ static int lgdt3305_agc_setup(struct lgdt3305_state *state, ...@@ -432,15 +432,15 @@ static int lgdt3305_agc_setup(struct lgdt3305_state *state,
return -EINVAL; return -EINVAL;
} }
return lgdt3305_rfagc_loop(state, param); return lgdt3305_rfagc_loop(state, p);
} }
static int lgdt3305_set_agc_power_ref(struct lgdt3305_state *state, static int lgdt3305_set_agc_power_ref(struct lgdt3305_state *state,
struct dvb_frontend_parameters *param) struct dtv_frontend_properties *p)
{ {
u16 usref = 0; u16 usref = 0;
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
if (state->cfg->usref_8vsb) if (state->cfg->usref_8vsb)
usref = state->cfg->usref_8vsb; usref = state->cfg->usref_8vsb;
...@@ -473,14 +473,14 @@ static int lgdt3305_set_agc_power_ref(struct lgdt3305_state *state, ...@@ -473,14 +473,14 @@ static int lgdt3305_set_agc_power_ref(struct lgdt3305_state *state,
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static int lgdt3305_spectral_inversion(struct lgdt3305_state *state, static int lgdt3305_spectral_inversion(struct lgdt3305_state *state,
struct dvb_frontend_parameters *param, struct dtv_frontend_properties *p,
int inversion) int inversion)
{ {
int ret; int ret;
lg_dbg("(%d)\n", inversion); lg_dbg("(%d)\n", inversion);
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
ret = lgdt3305_write_reg(state, LGDT3305_CR_CTRL_7, ret = lgdt3305_write_reg(state, LGDT3305_CR_CTRL_7,
inversion ? 0xf9 : 0x79); inversion ? 0xf9 : 0x79);
...@@ -497,13 +497,13 @@ static int lgdt3305_spectral_inversion(struct lgdt3305_state *state, ...@@ -497,13 +497,13 @@ static int lgdt3305_spectral_inversion(struct lgdt3305_state *state,
} }
static int lgdt3305_set_if(struct lgdt3305_state *state, static int lgdt3305_set_if(struct lgdt3305_state *state,
struct dvb_frontend_parameters *param) struct dtv_frontend_properties *p)
{ {
u16 if_freq_khz; u16 if_freq_khz;
u8 nco1, nco2, nco3, nco4; u8 nco1, nco2, nco3, nco4;
u64 nco; u64 nco;
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
if_freq_khz = state->cfg->vsb_if_khz; if_freq_khz = state->cfg->vsb_if_khz;
break; break;
...@@ -517,7 +517,7 @@ static int lgdt3305_set_if(struct lgdt3305_state *state, ...@@ -517,7 +517,7 @@ static int lgdt3305_set_if(struct lgdt3305_state *state,
nco = if_freq_khz / 10; nco = if_freq_khz / 10;
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
nco <<= 24; nco <<= 24;
do_div(nco, 625); do_div(nco, 625);
...@@ -677,13 +677,13 @@ static int lgdt3305_init(struct dvb_frontend *fe) ...@@ -677,13 +677,13 @@ static int lgdt3305_init(struct dvb_frontend *fe)
return ret; return ret;
} }
static int lgdt3304_set_parameters(struct dvb_frontend *fe, static int lgdt3304_set_parameters(struct dvb_frontend *fe)
struct dvb_frontend_parameters *param)
{ {
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct lgdt3305_state *state = fe->demodulator_priv; struct lgdt3305_state *state = fe->demodulator_priv;
int ret; int ret;
lg_dbg("(%d, %d)\n", param->frequency, param->u.vsb.modulation); lg_dbg("(%d, %d)\n", p->frequency, p->modulation);
if (fe->ops.tuner_ops.set_params) { if (fe->ops.tuner_ops.set_params) {
ret = fe->ops.tuner_ops.set_params(fe); ret = fe->ops.tuner_ops.set_params(fe);
...@@ -691,23 +691,23 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe, ...@@ -691,23 +691,23 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe,
fe->ops.i2c_gate_ctrl(fe, 0); fe->ops.i2c_gate_ctrl(fe, 0);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
state->current_frequency = param->frequency; state->current_frequency = p->frequency;
} }
ret = lgdt3305_set_modulation(state, param); ret = lgdt3305_set_modulation(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
ret = lgdt3305_passband_digital_agc(state, param); ret = lgdt3305_passband_digital_agc(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
ret = lgdt3305_agc_setup(state, param); ret = lgdt3305_agc_setup(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
/* reg 0x030d is 3304-only... seen in vsb and qam usbsnoops... */ /* reg 0x030d is 3304-only... seen in vsb and qam usbsnoops... */
switch (param->u.vsb.modulation) { switch (p->modulation) {
case VSB_8: case VSB_8:
lgdt3305_write_reg(state, 0x030d, 0x00); lgdt3305_write_reg(state, 0x030d, 0x00);
lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_1, 0x4f); lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_1, 0x4f);
...@@ -718,7 +718,7 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe, ...@@ -718,7 +718,7 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe,
case QAM_64: case QAM_64:
case QAM_256: case QAM_256:
lgdt3305_write_reg(state, 0x030d, 0x14); lgdt3305_write_reg(state, 0x030d, 0x14);
ret = lgdt3305_set_if(state, param); ret = lgdt3305_set_if(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
break; break;
...@@ -727,13 +727,13 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe, ...@@ -727,13 +727,13 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe,
} }
ret = lgdt3305_spectral_inversion(state, param, ret = lgdt3305_spectral_inversion(state, p,
state->cfg->spectral_inversion state->cfg->spectral_inversion
? 1 : 0); ? 1 : 0);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
state->current_modulation = param->u.vsb.modulation; state->current_modulation = p->modulation;
ret = lgdt3305_mpeg_mode(state, state->cfg->mpeg_mode); ret = lgdt3305_mpeg_mode(state, state->cfg->mpeg_mode);
if (lg_fail(ret)) if (lg_fail(ret))
...@@ -747,13 +747,13 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe, ...@@ -747,13 +747,13 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe,
return ret; return ret;
} }
static int lgdt3305_set_parameters(struct dvb_frontend *fe, static int lgdt3305_set_parameters(struct dvb_frontend *fe)
struct dvb_frontend_parameters *param)
{ {
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct lgdt3305_state *state = fe->demodulator_priv; struct lgdt3305_state *state = fe->demodulator_priv;
int ret; int ret;
lg_dbg("(%d, %d)\n", param->frequency, param->u.vsb.modulation); lg_dbg("(%d, %d)\n", p->frequency, p->modulation);
if (fe->ops.tuner_ops.set_params) { if (fe->ops.tuner_ops.set_params) {
ret = fe->ops.tuner_ops.set_params(fe); ret = fe->ops.tuner_ops.set_params(fe);
...@@ -761,20 +761,20 @@ static int lgdt3305_set_parameters(struct dvb_frontend *fe, ...@@ -761,20 +761,20 @@ static int lgdt3305_set_parameters(struct dvb_frontend *fe,
fe->ops.i2c_gate_ctrl(fe, 0); fe->ops.i2c_gate_ctrl(fe, 0);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
state->current_frequency = param->frequency; state->current_frequency = p->frequency;
} }
ret = lgdt3305_set_modulation(state, param); ret = lgdt3305_set_modulation(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
ret = lgdt3305_passband_digital_agc(state, param); ret = lgdt3305_passband_digital_agc(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
ret = lgdt3305_set_agc_power_ref(state, param); ret = lgdt3305_set_agc_power_ref(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
ret = lgdt3305_agc_setup(state, param); ret = lgdt3305_agc_setup(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
...@@ -786,20 +786,20 @@ static int lgdt3305_set_parameters(struct dvb_frontend *fe, ...@@ -786,20 +786,20 @@ static int lgdt3305_set_parameters(struct dvb_frontend *fe,
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
ret = lgdt3305_set_if(state, param); ret = lgdt3305_set_if(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
ret = lgdt3305_spectral_inversion(state, param, ret = lgdt3305_spectral_inversion(state, p,
state->cfg->spectral_inversion state->cfg->spectral_inversion
? 1 : 0); ? 1 : 0);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
ret = lgdt3305_set_filter_extension(state, param); ret = lgdt3305_set_filter_extension(state, p);
if (lg_fail(ret)) if (lg_fail(ret))
goto fail; goto fail;
state->current_modulation = param->u.vsb.modulation; state->current_modulation = p->modulation;
ret = lgdt3305_mpeg_mode(state, state->cfg->mpeg_mode); ret = lgdt3305_mpeg_mode(state, state->cfg->mpeg_mode);
if (lg_fail(ret)) if (lg_fail(ret))
...@@ -814,14 +814,14 @@ static int lgdt3305_set_parameters(struct dvb_frontend *fe, ...@@ -814,14 +814,14 @@ static int lgdt3305_set_parameters(struct dvb_frontend *fe,
} }
static int lgdt3305_get_frontend(struct dvb_frontend *fe, static int lgdt3305_get_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *param) struct dtv_frontend_properties *p)
{ {
struct lgdt3305_state *state = fe->demodulator_priv; struct lgdt3305_state *state = fe->demodulator_priv;
lg_dbg("\n"); lg_dbg("\n");
param->u.vsb.modulation = state->current_modulation; p->modulation = state->current_modulation;
param->frequency = state->current_frequency; p->frequency = state->current_frequency;
return 0; return 0;
} }
...@@ -1176,8 +1176,8 @@ static struct dvb_frontend_ops lgdt3304_ops = { ...@@ -1176,8 +1176,8 @@ static struct dvb_frontend_ops lgdt3304_ops = {
}, },
.i2c_gate_ctrl = lgdt3305_i2c_gate_ctrl, .i2c_gate_ctrl = lgdt3305_i2c_gate_ctrl,
.init = lgdt3305_init, .init = lgdt3305_init,
.set_frontend_legacy = lgdt3304_set_parameters, .set_frontend = lgdt3304_set_parameters,
.get_frontend_legacy = lgdt3305_get_frontend, .get_frontend = lgdt3305_get_frontend,
.get_tune_settings = lgdt3305_get_tune_settings, .get_tune_settings = lgdt3305_get_tune_settings,
.read_status = lgdt3305_read_status, .read_status = lgdt3305_read_status,
.read_ber = lgdt3305_read_ber, .read_ber = lgdt3305_read_ber,
...@@ -1188,6 +1188,7 @@ static struct dvb_frontend_ops lgdt3304_ops = { ...@@ -1188,6 +1188,7 @@ static struct dvb_frontend_ops lgdt3304_ops = {
}; };
static struct dvb_frontend_ops lgdt3305_ops = { static struct dvb_frontend_ops lgdt3305_ops = {
.delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
.info = { .info = {
.name = "LG Electronics LGDT3305 VSB/QAM Frontend", .name = "LG Electronics LGDT3305 VSB/QAM Frontend",
.type = FE_ATSC, .type = FE_ATSC,
...@@ -1199,8 +1200,8 @@ static struct dvb_frontend_ops lgdt3305_ops = { ...@@ -1199,8 +1200,8 @@ static struct dvb_frontend_ops lgdt3305_ops = {
.i2c_gate_ctrl = lgdt3305_i2c_gate_ctrl, .i2c_gate_ctrl = lgdt3305_i2c_gate_ctrl,
.init = lgdt3305_init, .init = lgdt3305_init,
.sleep = lgdt3305_sleep, .sleep = lgdt3305_sleep,
.set_frontend_legacy = lgdt3305_set_parameters, .set_frontend = lgdt3305_set_parameters,
.get_frontend_legacy = lgdt3305_get_frontend, .get_frontend = lgdt3305_get_frontend,
.get_tune_settings = lgdt3305_get_tune_settings, .get_tune_settings = lgdt3305_get_tune_settings,
.read_status = lgdt3305_read_status, .read_status = lgdt3305_read_status,
.read_ber = lgdt3305_read_ber, .read_ber = lgdt3305_read_ber,
......
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