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

[media] dib3000mb: 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 9e9c5bf7
...@@ -113,13 +113,12 @@ static u16 dib3000_seq[2][2][2] = /* fft,gua, inv */ ...@@ -113,13 +113,12 @@ static u16 dib3000_seq[2][2][2] = /* fft,gua, inv */
}; };
static int dib3000mb_get_frontend(struct dvb_frontend* fe, static int dib3000mb_get_frontend(struct dvb_frontend* fe,
struct dvb_frontend_parameters *fep); struct dtv_frontend_properties *c);
static int dib3000mb_set_frontend(struct dvb_frontend* fe, static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
struct dvb_frontend_parameters *fep, int tuner)
{ {
struct dib3000_state* state = fe->demodulator_priv; struct dib3000_state* state = fe->demodulator_priv;
struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
fe_code_rate_t fe_cr = FEC_NONE; fe_code_rate_t fe_cr = FEC_NONE;
int search_state, seq; int search_state, seq;
...@@ -128,23 +127,23 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -128,23 +127,23 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
deb_setf("bandwidth: "); deb_setf("bandwidth: ");
switch (ofdm->bandwidth) { switch (c->bandwidth_hz) {
case BANDWIDTH_8_MHZ: case 8000000:
deb_setf("8 MHz\n"); deb_setf("8 MHz\n");
wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]); wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]);
wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz); wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz);
break; break;
case BANDWIDTH_7_MHZ: case 7000000:
deb_setf("7 MHz\n"); deb_setf("7 MHz\n");
wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[1]); wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[1]);
wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_7mhz); wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_7mhz);
break; break;
case BANDWIDTH_6_MHZ: case 6000000:
deb_setf("6 MHz\n"); deb_setf("6 MHz\n");
wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[0]); wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[0]);
wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_6mhz); wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_6mhz);
break; break;
case BANDWIDTH_AUTO: case 0:
return -EOPNOTSUPP; return -EOPNOTSUPP;
default: default:
err("unknown bandwidth value."); err("unknown bandwidth value.");
...@@ -154,7 +153,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -154,7 +153,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4); wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4);
deb_setf("transmission mode: "); deb_setf("transmission mode: ");
switch (ofdm->transmission_mode) { switch (c->transmission_mode) {
case TRANSMISSION_MODE_2K: case TRANSMISSION_MODE_2K:
deb_setf("2k\n"); deb_setf("2k\n");
wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_2K); wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_2K);
...@@ -171,7 +170,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -171,7 +170,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
} }
deb_setf("guard: "); deb_setf("guard: ");
switch (ofdm->guard_interval) { switch (c->guard_interval) {
case GUARD_INTERVAL_1_32: case GUARD_INTERVAL_1_32:
deb_setf("1_32\n"); deb_setf("1_32\n");
wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_32); wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_32);
...@@ -196,7 +195,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -196,7 +195,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
} }
deb_setf("inversion: "); deb_setf("inversion: ");
switch (fep->inversion) { switch (c->inversion) {
case INVERSION_OFF: case INVERSION_OFF:
deb_setf("off\n"); deb_setf("off\n");
wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_OFF); wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_OFF);
...@@ -212,8 +211,8 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -212,8 +211,8 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
return -EINVAL; return -EINVAL;
} }
deb_setf("constellation: "); deb_setf("modulation: ");
switch (ofdm->constellation) { switch (c->modulation) {
case QPSK: case QPSK:
deb_setf("qpsk\n"); deb_setf("qpsk\n");
wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_QPSK); wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_QPSK);
...@@ -232,7 +231,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -232,7 +231,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
return -EINVAL; return -EINVAL;
} }
deb_setf("hierarchy: "); deb_setf("hierarchy: ");
switch (ofdm->hierarchy_information) { switch (c->hierarchy) {
case HIERARCHY_NONE: case HIERARCHY_NONE:
deb_setf("none "); deb_setf("none ");
/* fall through */ /* fall through */
...@@ -256,16 +255,16 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -256,16 +255,16 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
} }
deb_setf("hierarchy: "); deb_setf("hierarchy: ");
if (ofdm->hierarchy_information == HIERARCHY_NONE) { if (c->hierarchy == HIERARCHY_NONE) {
deb_setf("none\n"); deb_setf("none\n");
wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_OFF); wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_OFF);
wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_HP); wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_HP);
fe_cr = ofdm->code_rate_HP; fe_cr = c->code_rate_HP;
} else if (ofdm->hierarchy_information != HIERARCHY_AUTO) { } else if (c->hierarchy != HIERARCHY_AUTO) {
deb_setf("on\n"); deb_setf("on\n");
wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_ON); wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_ON);
wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_LP); wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_LP);
fe_cr = ofdm->code_rate_LP; fe_cr = c->code_rate_LP;
} }
deb_setf("fec: "); deb_setf("fec: ");
switch (fe_cr) { switch (fe_cr) {
...@@ -300,9 +299,9 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -300,9 +299,9 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
} }
seq = dib3000_seq seq = dib3000_seq
[ofdm->transmission_mode == TRANSMISSION_MODE_AUTO] [c->transmission_mode == TRANSMISSION_MODE_AUTO]
[ofdm->guard_interval == GUARD_INTERVAL_AUTO] [c->guard_interval == GUARD_INTERVAL_AUTO]
[fep->inversion == INVERSION_AUTO]; [c->inversion == INVERSION_AUTO];
deb_setf("seq? %d\n", seq); deb_setf("seq? %d\n", seq);
...@@ -310,8 +309,8 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -310,8 +309,8 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
wr(DIB3000MB_REG_ISI, seq ? DIB3000MB_ISI_INHIBIT : DIB3000MB_ISI_ACTIVATE); wr(DIB3000MB_REG_ISI, seq ? DIB3000MB_ISI_INHIBIT : DIB3000MB_ISI_ACTIVATE);
if (ofdm->transmission_mode == TRANSMISSION_MODE_2K) { if (c->transmission_mode == TRANSMISSION_MODE_2K) {
if (ofdm->guard_interval == GUARD_INTERVAL_1_8) { if (c->guard_interval == GUARD_INTERVAL_1_8) {
wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_2K_1_8); wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_2K_1_8);
} else { } else {
wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_DEFAULT); wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_DEFAULT);
...@@ -339,10 +338,10 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -339,10 +338,10 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_low); wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_low);
/* something has to be auto searched */ /* something has to be auto searched */
if (ofdm->constellation == QAM_AUTO || if (c->modulation == QAM_AUTO ||
ofdm->hierarchy_information == HIERARCHY_AUTO || c->hierarchy == HIERARCHY_AUTO ||
fe_cr == FEC_AUTO || fe_cr == FEC_AUTO ||
fep->inversion == INVERSION_AUTO) { c->inversion == INVERSION_AUTO) {
int as_count=0; int as_count=0;
deb_setf("autosearch enabled.\n"); deb_setf("autosearch enabled.\n");
...@@ -361,10 +360,9 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe, ...@@ -361,10 +360,9 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count); deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count);
if (search_state == 1) { if (search_state == 1) {
struct dvb_frontend_parameters feps; if (dib3000mb_get_frontend(fe, c) == 0) {
if (dib3000mb_get_frontend(fe, &feps) == 0) {
deb_setf("reading tuning data from frontend succeeded.\n"); deb_setf("reading tuning data from frontend succeeded.\n");
return dib3000mb_set_frontend(fe, &feps, 0); return dib3000mb_set_frontend(fe, 0);
} }
} }
...@@ -454,10 +452,9 @@ static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode) ...@@ -454,10 +452,9 @@ static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
} }
static int dib3000mb_get_frontend(struct dvb_frontend* fe, static int dib3000mb_get_frontend(struct dvb_frontend* fe,
struct dvb_frontend_parameters *fep) struct dtv_frontend_properties *c)
{ {
struct dib3000_state* state = fe->demodulator_priv; struct dib3000_state* state = fe->demodulator_priv;
struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
fe_code_rate_t *cr; fe_code_rate_t *cr;
u16 tps_val; u16 tps_val;
int inv_test1,inv_test2; int inv_test1,inv_test2;
...@@ -484,25 +481,25 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe, ...@@ -484,25 +481,25 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
else else
inv_test2 = 2; inv_test2 = 2;
fep->inversion = c->inversion =
((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) || ((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) ||
((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ? ((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ?
INVERSION_ON : INVERSION_OFF; INVERSION_ON : INVERSION_OFF;
deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, fep->inversion); deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, c->inversion);
switch ((tps_val = rd(DIB3000MB_REG_TPS_QAM))) { switch ((tps_val = rd(DIB3000MB_REG_TPS_QAM))) {
case DIB3000_CONSTELLATION_QPSK: case DIB3000_CONSTELLATION_QPSK:
deb_getf("QPSK "); deb_getf("QPSK ");
ofdm->constellation = QPSK; c->modulation = QPSK;
break; break;
case DIB3000_CONSTELLATION_16QAM: case DIB3000_CONSTELLATION_16QAM:
deb_getf("QAM16 "); deb_getf("QAM16 ");
ofdm->constellation = QAM_16; c->modulation = QAM_16;
break; break;
case DIB3000_CONSTELLATION_64QAM: case DIB3000_CONSTELLATION_64QAM:
deb_getf("QAM64 "); deb_getf("QAM64 ");
ofdm->constellation = QAM_64; c->modulation = QAM_64;
break; break;
default: default:
err("Unexpected constellation returned by TPS (%d)", tps_val); err("Unexpected constellation returned by TPS (%d)", tps_val);
...@@ -512,24 +509,24 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe, ...@@ -512,24 +509,24 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
if (rd(DIB3000MB_REG_TPS_HRCH)) { if (rd(DIB3000MB_REG_TPS_HRCH)) {
deb_getf("HRCH ON\n"); deb_getf("HRCH ON\n");
cr = &ofdm->code_rate_LP; cr = &c->code_rate_LP;
ofdm->code_rate_HP = FEC_NONE; c->code_rate_HP = FEC_NONE;
switch ((tps_val = rd(DIB3000MB_REG_TPS_VIT_ALPHA))) { switch ((tps_val = rd(DIB3000MB_REG_TPS_VIT_ALPHA))) {
case DIB3000_ALPHA_0: case DIB3000_ALPHA_0:
deb_getf("HIERARCHY_NONE "); deb_getf("HIERARCHY_NONE ");
ofdm->hierarchy_information = HIERARCHY_NONE; c->hierarchy = HIERARCHY_NONE;
break; break;
case DIB3000_ALPHA_1: case DIB3000_ALPHA_1:
deb_getf("HIERARCHY_1 "); deb_getf("HIERARCHY_1 ");
ofdm->hierarchy_information = HIERARCHY_1; c->hierarchy = HIERARCHY_1;
break; break;
case DIB3000_ALPHA_2: case DIB3000_ALPHA_2:
deb_getf("HIERARCHY_2 "); deb_getf("HIERARCHY_2 ");
ofdm->hierarchy_information = HIERARCHY_2; c->hierarchy = HIERARCHY_2;
break; break;
case DIB3000_ALPHA_4: case DIB3000_ALPHA_4:
deb_getf("HIERARCHY_4 "); deb_getf("HIERARCHY_4 ");
ofdm->hierarchy_information = HIERARCHY_4; c->hierarchy = HIERARCHY_4;
break; break;
default: default:
err("Unexpected ALPHA value returned by TPS (%d)", tps_val); err("Unexpected ALPHA value returned by TPS (%d)", tps_val);
...@@ -540,9 +537,9 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe, ...@@ -540,9 +537,9 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_LP); tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_LP);
} else { } else {
deb_getf("HRCH OFF\n"); deb_getf("HRCH OFF\n");
cr = &ofdm->code_rate_HP; cr = &c->code_rate_HP;
ofdm->code_rate_LP = FEC_NONE; c->code_rate_LP = FEC_NONE;
ofdm->hierarchy_information = HIERARCHY_NONE; c->hierarchy = HIERARCHY_NONE;
tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_HP); tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_HP);
} }
...@@ -577,19 +574,19 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe, ...@@ -577,19 +574,19 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
switch ((tps_val = rd(DIB3000MB_REG_TPS_GUARD_TIME))) { switch ((tps_val = rd(DIB3000MB_REG_TPS_GUARD_TIME))) {
case DIB3000_GUARD_TIME_1_32: case DIB3000_GUARD_TIME_1_32:
deb_getf("GUARD_INTERVAL_1_32 "); deb_getf("GUARD_INTERVAL_1_32 ");
ofdm->guard_interval = GUARD_INTERVAL_1_32; c->guard_interval = GUARD_INTERVAL_1_32;
break; break;
case DIB3000_GUARD_TIME_1_16: case DIB3000_GUARD_TIME_1_16:
deb_getf("GUARD_INTERVAL_1_16 "); deb_getf("GUARD_INTERVAL_1_16 ");
ofdm->guard_interval = GUARD_INTERVAL_1_16; c->guard_interval = GUARD_INTERVAL_1_16;
break; break;
case DIB3000_GUARD_TIME_1_8: case DIB3000_GUARD_TIME_1_8:
deb_getf("GUARD_INTERVAL_1_8 "); deb_getf("GUARD_INTERVAL_1_8 ");
ofdm->guard_interval = GUARD_INTERVAL_1_8; c->guard_interval = GUARD_INTERVAL_1_8;
break; break;
case DIB3000_GUARD_TIME_1_4: case DIB3000_GUARD_TIME_1_4:
deb_getf("GUARD_INTERVAL_1_4 "); deb_getf("GUARD_INTERVAL_1_4 ");
ofdm->guard_interval = GUARD_INTERVAL_1_4; c->guard_interval = GUARD_INTERVAL_1_4;
break; break;
default: default:
err("Unexpected Guard Time returned by TPS (%d)", tps_val); err("Unexpected Guard Time returned by TPS (%d)", tps_val);
...@@ -600,11 +597,11 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe, ...@@ -600,11 +597,11 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
switch ((tps_val = rd(DIB3000MB_REG_TPS_FFT))) { switch ((tps_val = rd(DIB3000MB_REG_TPS_FFT))) {
case DIB3000_TRANSMISSION_MODE_2K: case DIB3000_TRANSMISSION_MODE_2K:
deb_getf("TRANSMISSION_MODE_2K "); deb_getf("TRANSMISSION_MODE_2K ");
ofdm->transmission_mode = TRANSMISSION_MODE_2K; c->transmission_mode = TRANSMISSION_MODE_2K;
break; break;
case DIB3000_TRANSMISSION_MODE_8K: case DIB3000_TRANSMISSION_MODE_8K:
deb_getf("TRANSMISSION_MODE_8K "); deb_getf("TRANSMISSION_MODE_8K ");
ofdm->transmission_mode = TRANSMISSION_MODE_8K; c->transmission_mode = TRANSMISSION_MODE_8K;
break; break;
default: default:
err("unexpected transmission mode return by TPS (%d)", tps_val); err("unexpected transmission mode return by TPS (%d)", tps_val);
...@@ -701,9 +698,9 @@ static int dib3000mb_fe_init_nonmobile(struct dvb_frontend* fe) ...@@ -701,9 +698,9 @@ static int dib3000mb_fe_init_nonmobile(struct dvb_frontend* fe)
return dib3000mb_fe_init(fe, 0); return dib3000mb_fe_init(fe, 0);
} }
static int dib3000mb_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_frontend_parameters *fep) static int dib3000mb_set_frontend_and_tuner(struct dvb_frontend *fe)
{ {
return dib3000mb_set_frontend(fe, fep, 1); return dib3000mb_set_frontend(fe, 1);
} }
static void dib3000mb_release(struct dvb_frontend* fe) static void dib3000mb_release(struct dvb_frontend* fe)
...@@ -794,7 +791,7 @@ struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, ...@@ -794,7 +791,7 @@ struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
} }
static struct dvb_frontend_ops dib3000mb_ops = { static struct dvb_frontend_ops dib3000mb_ops = {
.delsys = { SYS_DVBT },
.info = { .info = {
.name = "DiBcom 3000M-B DVB-T", .name = "DiBcom 3000M-B DVB-T",
.type = FE_OFDM, .type = FE_OFDM,
...@@ -816,8 +813,8 @@ static struct dvb_frontend_ops dib3000mb_ops = { ...@@ -816,8 +813,8 @@ static struct dvb_frontend_ops dib3000mb_ops = {
.init = dib3000mb_fe_init_nonmobile, .init = dib3000mb_fe_init_nonmobile,
.sleep = dib3000mb_sleep, .sleep = dib3000mb_sleep,
.set_frontend_legacy = dib3000mb_set_frontend_and_tuner, .set_frontend = dib3000mb_set_frontend_and_tuner,
.get_frontend_legacy = dib3000mb_get_frontend, .get_frontend = dib3000mb_get_frontend,
.get_tune_settings = dib3000mb_fe_get_tune_settings, .get_tune_settings = dib3000mb_fe_get_tune_settings,
.read_status = dib3000mb_read_status, .read_status = dib3000mb_read_status,
......
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