Commit 5ebffc39 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] sp887x: 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 dcc9a129
...@@ -209,13 +209,13 @@ static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware ...@@ -209,13 +209,13 @@ static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware
return 0; return 0;
}; };
static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05) static int configure_reg0xc05(struct dtv_frontend_properties *p, u16 *reg0xc05)
{ {
int known_parameters = 1; int known_parameters = 1;
*reg0xc05 = 0x000; *reg0xc05 = 0x000;
switch (p->u.ofdm.constellation) { switch (p->modulation) {
case QPSK: case QPSK:
break; break;
case QAM_16: case QAM_16:
...@@ -231,7 +231,7 @@ static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05) ...@@ -231,7 +231,7 @@ static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
return -EINVAL; return -EINVAL;
}; };
switch (p->u.ofdm.hierarchy_information) { switch (p->hierarchy) {
case HIERARCHY_NONE: case HIERARCHY_NONE:
break; break;
case HIERARCHY_1: case HIERARCHY_1:
...@@ -250,7 +250,7 @@ static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05) ...@@ -250,7 +250,7 @@ static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
return -EINVAL; return -EINVAL;
}; };
switch (p->u.ofdm.code_rate_HP) { switch (p->code_rate_HP) {
case FEC_1_2: case FEC_1_2:
break; break;
case FEC_2_3: case FEC_2_3:
...@@ -303,17 +303,30 @@ static void divide (int n, int d, int *quotient_i, int *quotient_f) ...@@ -303,17 +303,30 @@ static void divide (int n, int d, int *quotient_i, int *quotient_f)
} }
static void sp887x_correct_offsets (struct sp887x_state* state, static void sp887x_correct_offsets (struct sp887x_state* state,
struct dvb_frontend_parameters *p, struct dtv_frontend_properties *p,
int actual_freq) int actual_freq)
{ {
static const u32 srate_correction [] = { 1879617, 4544878, 8098561 }; static const u32 srate_correction [] = { 1879617, 4544878, 8098561 };
int bw_index = p->u.ofdm.bandwidth - BANDWIDTH_8_MHZ; int bw_index;
int freq_offset = actual_freq - p->frequency; int freq_offset = actual_freq - p->frequency;
int sysclock = 61003; //[kHz] int sysclock = 61003; //[kHz]
int ifreq = 36000000; int ifreq = 36000000;
int freq; int freq;
int frequency_shift; int frequency_shift;
switch (p->bandwidth_hz) {
default:
case 8000000:
bw_index = 0;
break;
case 7000000:
bw_index = 1;
break;
case 6000000:
bw_index = 2;
break;
}
if (p->inversion == INVERSION_ON) if (p->inversion == INVERSION_ON)
freq = ifreq - freq_offset; freq = ifreq - freq_offset;
else else
...@@ -333,17 +346,17 @@ static void sp887x_correct_offsets (struct sp887x_state* state, ...@@ -333,17 +346,17 @@ static void sp887x_correct_offsets (struct sp887x_state* state,
sp887x_writereg(state, 0x30a, frequency_shift & 0xfff); sp887x_writereg(state, 0x30a, frequency_shift & 0xfff);
} }
static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe, static int sp887x_setup_frontend_parameters(struct dvb_frontend *fe)
struct dvb_frontend_parameters *p)
{ {
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct sp887x_state* state = fe->demodulator_priv; struct sp887x_state* state = fe->demodulator_priv;
unsigned actual_freq; unsigned actual_freq;
int err; int err;
u16 val, reg0xc05; u16 val, reg0xc05;
if (p->u.ofdm.bandwidth != BANDWIDTH_8_MHZ && if (p->bandwidth_hz != 8000000 &&
p->u.ofdm.bandwidth != BANDWIDTH_7_MHZ && p->bandwidth_hz != 7000000 &&
p->u.ofdm.bandwidth != BANDWIDTH_6_MHZ) p->bandwidth_hz != 6000000)
return -EINVAL; return -EINVAL;
if ((err = configure_reg0xc05(p, &reg0xc05))) if ((err = configure_reg0xc05(p, &reg0xc05)))
...@@ -369,9 +382,9 @@ static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe, ...@@ -369,9 +382,9 @@ static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
sp887x_correct_offsets(state, p, actual_freq); sp887x_correct_offsets(state, p, actual_freq);
/* filter for 6/7/8 Mhz channel */ /* filter for 6/7/8 Mhz channel */
if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ) if (p->bandwidth_hz == 6000000)
val = 2; val = 2;
else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ) else if (p->bandwidth_hz == 7000000)
val = 1; val = 1;
else else
val = 0; val = 0;
...@@ -379,16 +392,16 @@ static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe, ...@@ -379,16 +392,16 @@ static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
sp887x_writereg(state, 0x311, val); sp887x_writereg(state, 0x311, val);
/* scan order: 2k first = 0, 8k first = 1 */ /* scan order: 2k first = 0, 8k first = 1 */
if (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_2K) if (p->transmission_mode == TRANSMISSION_MODE_2K)
sp887x_writereg(state, 0x338, 0x000); sp887x_writereg(state, 0x338, 0x000);
else else
sp887x_writereg(state, 0x338, 0x001); sp887x_writereg(state, 0x338, 0x001);
sp887x_writereg(state, 0xc05, reg0xc05); sp887x_writereg(state, 0xc05, reg0xc05);
if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ) if (p->bandwidth_hz == 6000000)
val = 2 << 3; val = 2 << 3;
else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ) else if (p->bandwidth_hz == 7000000)
val = 3 << 3; val = 3 << 3;
else else
val = 0 << 3; val = 0 << 3;
...@@ -579,7 +592,7 @@ struct dvb_frontend* sp887x_attach(const struct sp887x_config* config, ...@@ -579,7 +592,7 @@ struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
} }
static struct dvb_frontend_ops sp887x_ops = { static struct dvb_frontend_ops sp887x_ops = {
.delsys = { SYS_DVBT },
.info = { .info = {
.name = "Spase SP887x DVB-T", .name = "Spase SP887x DVB-T",
.type = FE_OFDM, .type = FE_OFDM,
...@@ -598,7 +611,7 @@ static struct dvb_frontend_ops sp887x_ops = { ...@@ -598,7 +611,7 @@ static struct dvb_frontend_ops sp887x_ops = {
.sleep = sp887x_sleep, .sleep = sp887x_sleep,
.i2c_gate_ctrl = sp887x_i2c_gate_ctrl, .i2c_gate_ctrl = sp887x_i2c_gate_ctrl,
.set_frontend_legacy = sp887x_setup_frontend_parameters, .set_frontend = sp887x_setup_frontend_parameters,
.get_tune_settings = sp887x_get_tune_settings, .get_tune_settings = sp887x_get_tune_settings,
.read_status = sp887x_read_status, .read_status = sp887x_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