Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285537
b: refs/heads/master
c: 5ebffc3
h: refs/heads/master
i:
  285535: 76e4047
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed Dec 31, 2011
1 parent c4a52a8 commit ecbbf68
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dcc9a1299721835ece4e826c445cf8463c110832
refs/heads/master: 5ebffc39929d553f26599976b7393e425a07bd36
49 changes: 31 additions & 18 deletions trunk/drivers/media/dvb/frontends/sp887x.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware
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;

*reg0xc05 = 0x000;

switch (p->u.ofdm.constellation) {
switch (p->modulation) {
case QPSK:
break;
case QAM_16:
Expand All @@ -231,7 +231,7 @@ static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
return -EINVAL;
};

switch (p->u.ofdm.hierarchy_information) {
switch (p->hierarchy) {
case HIERARCHY_NONE:
break;
case HIERARCHY_1:
Expand All @@ -250,7 +250,7 @@ static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
return -EINVAL;
};

switch (p->u.ofdm.code_rate_HP) {
switch (p->code_rate_HP) {
case FEC_1_2:
break;
case FEC_2_3:
Expand Down Expand Up @@ -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,
struct dvb_frontend_parameters *p,
struct dtv_frontend_properties *p,
int actual_freq)
{
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 sysclock = 61003; //[kHz]
int ifreq = 36000000;
int freq;
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)
freq = ifreq - freq_offset;
else
Expand All @@ -333,17 +346,17 @@ static void sp887x_correct_offsets (struct sp887x_state* state,
sp887x_writereg(state, 0x30a, frequency_shift & 0xfff);
}

static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
struct dvb_frontend_parameters *p)
static int sp887x_setup_frontend_parameters(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct sp887x_state* state = fe->demodulator_priv;
unsigned actual_freq;
int err;
u16 val, reg0xc05;

if (p->u.ofdm.bandwidth != BANDWIDTH_8_MHZ &&
p->u.ofdm.bandwidth != BANDWIDTH_7_MHZ &&
p->u.ofdm.bandwidth != BANDWIDTH_6_MHZ)
if (p->bandwidth_hz != 8000000 &&
p->bandwidth_hz != 7000000 &&
p->bandwidth_hz != 6000000)
return -EINVAL;

if ((err = configure_reg0xc05(p, &reg0xc05)))
Expand All @@ -369,26 +382,26 @@ static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
sp887x_correct_offsets(state, p, actual_freq);

/* filter for 6/7/8 Mhz channel */
if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
if (p->bandwidth_hz == 6000000)
val = 2;
else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
else if (p->bandwidth_hz == 7000000)
val = 1;
else
val = 0;

sp887x_writereg(state, 0x311, val);

/* 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);
else
sp887x_writereg(state, 0x338, 0x001);

sp887x_writereg(state, 0xc05, reg0xc05);

if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
if (p->bandwidth_hz == 6000000)
val = 2 << 3;
else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
else if (p->bandwidth_hz == 7000000)
val = 3 << 3;
else
val = 0 << 3;
Expand Down Expand Up @@ -579,7 +592,7 @@ struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
}

static struct dvb_frontend_ops sp887x_ops = {

.delsys = { SYS_DVBT },
.info = {
.name = "Spase SP887x DVB-T",
.type = FE_OFDM,
Expand All @@ -598,7 +611,7 @@ static struct dvb_frontend_ops sp887x_ops = {
.sleep = sp887x_sleep,
.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,

.read_status = sp887x_read_status,
Expand Down

0 comments on commit ecbbf68

Please sign in to comment.