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

[media] mt352: 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 2d76e22b
...@@ -111,20 +111,20 @@ static int mt352_sleep(struct dvb_frontend* fe) ...@@ -111,20 +111,20 @@ static int mt352_sleep(struct dvb_frontend* fe)
} }
static void mt352_calc_nominal_rate(struct mt352_state* state, static void mt352_calc_nominal_rate(struct mt352_state* state,
enum fe_bandwidth bandwidth, u32 bandwidth,
unsigned char *buf) unsigned char *buf)
{ {
u32 adc_clock = 20480; /* 20.340 MHz */ u32 adc_clock = 20480; /* 20.340 MHz */
u32 bw,value; u32 bw,value;
switch (bandwidth) { switch (bandwidth) {
case BANDWIDTH_6_MHZ: case 6000000:
bw = 6; bw = 6;
break; break;
case BANDWIDTH_7_MHZ: case 7000000:
bw = 7; bw = 7;
break; break;
case BANDWIDTH_8_MHZ: case 8000000:
default: default:
bw = 8; bw = 8;
break; break;
...@@ -166,15 +166,14 @@ static void mt352_calc_input_freq(struct mt352_state* state, ...@@ -166,15 +166,14 @@ static void mt352_calc_input_freq(struct mt352_state* state,
buf[1] = lsb(value); buf[1] = lsb(value);
} }
static int mt352_set_parameters(struct dvb_frontend* fe, static int mt352_set_parameters(struct dvb_frontend *fe)
struct dvb_frontend_parameters *param)
{ {
struct dtv_frontend_properties *op = &fe->dtv_property_cache;
struct mt352_state* state = fe->demodulator_priv; struct mt352_state* state = fe->demodulator_priv;
unsigned char buf[13]; unsigned char buf[13];
static unsigned char tuner_go[] = { 0x5d, 0x01 }; static unsigned char tuner_go[] = { 0x5d, 0x01 };
static unsigned char fsm_go[] = { 0x5e, 0x01 }; static unsigned char fsm_go[] = { 0x5e, 0x01 };
unsigned int tps = 0; unsigned int tps = 0;
struct dvb_ofdm_parameters *op = &param->u.ofdm;
switch (op->code_rate_HP) { switch (op->code_rate_HP) {
case FEC_2_3: case FEC_2_3:
...@@ -213,14 +212,14 @@ static int mt352_set_parameters(struct dvb_frontend* fe, ...@@ -213,14 +212,14 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
case FEC_AUTO: case FEC_AUTO:
break; break;
case FEC_NONE: case FEC_NONE:
if (op->hierarchy_information == HIERARCHY_AUTO || if (op->hierarchy == HIERARCHY_AUTO ||
op->hierarchy_information == HIERARCHY_NONE) op->hierarchy == HIERARCHY_NONE)
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
switch (op->constellation) { switch (op->modulation) {
case QPSK: case QPSK:
break; break;
case QAM_AUTO: case QAM_AUTO:
...@@ -262,7 +261,7 @@ static int mt352_set_parameters(struct dvb_frontend* fe, ...@@ -262,7 +261,7 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
return -EINVAL; return -EINVAL;
} }
switch (op->hierarchy_information) { switch (op->hierarchy) {
case HIERARCHY_AUTO: case HIERARCHY_AUTO:
case HIERARCHY_NONE: case HIERARCHY_NONE:
break; break;
...@@ -288,7 +287,7 @@ static int mt352_set_parameters(struct dvb_frontend* fe, ...@@ -288,7 +287,7 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
buf[3] = 0x50; // old buf[3] = 0x50; // old
// buf[3] = 0xf4; // pinnacle // buf[3] = 0xf4; // pinnacle
mt352_calc_nominal_rate(state, op->bandwidth, buf+4); mt352_calc_nominal_rate(state, op->bandwidth_hz, buf+4);
mt352_calc_input_freq(state, buf+6); mt352_calc_input_freq(state, buf+6);
if (state->config.no_tuner) { if (state->config.no_tuner) {
...@@ -313,13 +312,12 @@ static int mt352_set_parameters(struct dvb_frontend* fe, ...@@ -313,13 +312,12 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
} }
static int mt352_get_parameters(struct dvb_frontend* fe, static int mt352_get_parameters(struct dvb_frontend* fe,
struct dvb_frontend_parameters *param) struct dtv_frontend_properties *op)
{ {
struct mt352_state* state = fe->demodulator_priv; struct mt352_state* state = fe->demodulator_priv;
u16 tps; u16 tps;
u16 div; u16 div;
u8 trl; u8 trl;
struct dvb_ofdm_parameters *op = &param->u.ofdm;
static const u8 tps_fec_to_api[8] = static const u8 tps_fec_to_api[8] =
{ {
FEC_1_2, FEC_1_2,
...@@ -348,16 +346,16 @@ static int mt352_get_parameters(struct dvb_frontend* fe, ...@@ -348,16 +346,16 @@ static int mt352_get_parameters(struct dvb_frontend* fe,
switch ( (tps >> 13) & 3) switch ( (tps >> 13) & 3)
{ {
case 0: case 0:
op->constellation = QPSK; op->modulation = QPSK;
break; break;
case 1: case 1:
op->constellation = QAM_16; op->modulation = QAM_16;
break; break;
case 2: case 2:
op->constellation = QAM_64; op->modulation = QAM_64;
break; break;
default: default:
op->constellation = QAM_AUTO; op->modulation = QAM_AUTO;
break; break;
} }
...@@ -385,36 +383,36 @@ static int mt352_get_parameters(struct dvb_frontend* fe, ...@@ -385,36 +383,36 @@ static int mt352_get_parameters(struct dvb_frontend* fe,
switch ( (tps >> 10) & 7) switch ( (tps >> 10) & 7)
{ {
case 0: case 0:
op->hierarchy_information = HIERARCHY_NONE; op->hierarchy = HIERARCHY_NONE;
break; break;
case 1: case 1:
op->hierarchy_information = HIERARCHY_1; op->hierarchy = HIERARCHY_1;
break; break;
case 2: case 2:
op->hierarchy_information = HIERARCHY_2; op->hierarchy = HIERARCHY_2;
break; break;
case 3: case 3:
op->hierarchy_information = HIERARCHY_4; op->hierarchy = HIERARCHY_4;
break; break;
default: default:
op->hierarchy_information = HIERARCHY_AUTO; op->hierarchy = HIERARCHY_AUTO;
break; break;
} }
param->frequency = ( 500 * (div - IF_FREQUENCYx6) ) / 3 * 1000; op->frequency = (500 * (div - IF_FREQUENCYx6)) / 3 * 1000;
if (trl == 0x72) if (trl == 0x72)
op->bandwidth = BANDWIDTH_8_MHZ; op->bandwidth_hz = 8000000;
else if (trl == 0x64) else if (trl == 0x64)
op->bandwidth = BANDWIDTH_7_MHZ; op->bandwidth_hz = 7000000;
else else
op->bandwidth = BANDWIDTH_6_MHZ; op->bandwidth_hz = 6000000;
if (mt352_read_register(state, STATUS_2) & 0x02) if (mt352_read_register(state, STATUS_2) & 0x02)
param->inversion = INVERSION_OFF; op->inversion = INVERSION_OFF;
else else
param->inversion = INVERSION_ON; op->inversion = INVERSION_ON;
return 0; return 0;
} }
...@@ -569,7 +567,7 @@ struct dvb_frontend* mt352_attach(const struct mt352_config* config, ...@@ -569,7 +567,7 @@ struct dvb_frontend* mt352_attach(const struct mt352_config* config,
} }
static struct dvb_frontend_ops mt352_ops = { static struct dvb_frontend_ops mt352_ops = {
.delsys = { SYS_DVBT },
.info = { .info = {
.name = "Zarlink MT352 DVB-T", .name = "Zarlink MT352 DVB-T",
.type = FE_OFDM, .type = FE_OFDM,
...@@ -592,8 +590,8 @@ static struct dvb_frontend_ops mt352_ops = { ...@@ -592,8 +590,8 @@ static struct dvb_frontend_ops mt352_ops = {
.sleep = mt352_sleep, .sleep = mt352_sleep,
.write = _mt352_write, .write = _mt352_write,
.set_frontend_legacy = mt352_set_parameters, .set_frontend = mt352_set_parameters,
.get_frontend_legacy = mt352_get_parameters, .get_frontend = mt352_get_parameters,
.get_tune_settings = mt352_get_tune_settings, .get_tune_settings = mt352_get_tune_settings,
.read_status = mt352_read_status, .read_status = mt352_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