Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 241957
b: refs/heads/master
c: cb8f74d
h: refs/heads/master
i:
  241955: b93075b
v: v3
  • Loading branch information
Igor M. Liplianin authored and Mauro Carvalho Chehab committed Mar 21, 2011
1 parent b1b7062 commit e31c02e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 96 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: 18a73f36a2109563beee00f8be3f19f6c1fe2ff6
refs/heads/master: cb8f74da107cf593eb50ac4968faaa5f49fbad4a
108 changes: 13 additions & 95 deletions trunk/drivers/media/dvb/frontends/ds3000.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,31 +229,11 @@ static u8 ds3000_dvbs2_init_tab[] = {
0xb8, 0x00,
};

/* DS3000 doesn't need some parameters as input and auto-detects them */
/* save input from the application of those parameters */
struct ds3000_tuning {
u32 frequency;
u32 symbol_rate;
fe_spectral_inversion_t inversion;
enum fe_code_rate fec;

/* input values */
u8 inversion_val;
fe_modulation_t delivery;
u8 rolloff;
};

struct ds3000_state {
struct i2c_adapter *i2c;
const struct ds3000_config *config;

struct dvb_frontend frontend;

struct ds3000_tuning dcur;
struct ds3000_tuning dnxt;

u8 skip_fw_load;

/* previous uncorrected block counter for DVB-S2 */
u16 prevUCBS2;
};
Expand Down Expand Up @@ -401,45 +381,6 @@ static int ds3000_tuner_readreg(struct ds3000_state *state, u8 reg)
return b1[0];
}

static int ds3000_set_inversion(struct ds3000_state *state,
fe_spectral_inversion_t inversion)
{
dprintk("%s(%d)\n", __func__, inversion);

switch (inversion) {
case INVERSION_OFF:
case INVERSION_ON:
case INVERSION_AUTO:
break;
default:
return -EINVAL;
}

state->dnxt.inversion = inversion;

return 0;
}

static int ds3000_set_symbolrate(struct ds3000_state *state, u32 rate)
{
int ret = 0;

dprintk("%s()\n", __func__);

dprintk("%s() symbol_rate = %d\n", __func__, state->dnxt.symbol_rate);

/* check if symbol rate is within limits */
if ((state->dnxt.symbol_rate >
state->frontend.ops.info.symbol_rate_max) ||
(state->dnxt.symbol_rate <
state->frontend.ops.info.symbol_rate_min))
ret = -EOPNOTSUPP;

state->dnxt.symbol_rate = rate;

return ret;
}

static int ds3000_load_firmware(struct dvb_frontend *fe,
const struct firmware *fw);

Expand Down Expand Up @@ -790,13 +731,6 @@ static int ds3000_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
return 0;
}

/* Overwrite the current tuning params, we are about to tune */
static void ds3000_clone_params(struct dvb_frontend *fe)
{
struct ds3000_state *state = fe->demodulator_priv;
memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur));
}

static int ds3000_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
{
struct ds3000_state *state = fe->demodulator_priv;
Expand Down Expand Up @@ -1027,22 +961,6 @@ static int ds3000_tune(struct dvb_frontend *fe,

dprintk("%s() ", __func__);

state->dnxt.delivery = c->modulation;
state->dnxt.frequency = c->frequency;
state->dnxt.rolloff = 2; /* fixme */
state->dnxt.fec = c->fec_inner;

ret = ds3000_set_inversion(state, p->inversion);
if (ret != 0)
return ret;

ret = ds3000_set_symbolrate(state, c->symbol_rate);
if (ret != 0)
return ret;

/* discard the 'current' tuning parameters and prepare to tune */
ds3000_clone_params(fe);

/* Reset status register */
status = 0;
/* Tune */
Expand All @@ -1053,14 +971,14 @@ static int ds3000_tune(struct dvb_frontend *fe,
ds3000_tuner_writereg(state, 0x08, 0x01);
ds3000_tuner_writereg(state, 0x00, 0x01);
/* calculate and set freq divider */
if (state->dcur.frequency < 1146000) {
if (p->frequency < 1146000) {
ds3000_tuner_writereg(state, 0x10, 0x11);
ndiv = ((state->dcur.frequency * (6 + 8) * 4) +
ndiv = ((p->frequency * (6 + 8) * 4) +
(DS3000_XTAL_FREQ / 2)) /
DS3000_XTAL_FREQ - 1024;
} else {
ds3000_tuner_writereg(state, 0x10, 0x01);
ndiv = ((state->dcur.frequency * (6 + 8) * 2) +
ndiv = ((p->frequency * (6 + 8) * 2) +
(DS3000_XTAL_FREQ / 2)) /
DS3000_XTAL_FREQ - 1024;
}
Expand Down Expand Up @@ -1106,8 +1024,8 @@ static int ds3000_tune(struct dvb_frontend *fe,
ds3000_tuner_writereg(state, 0x50, 0x00);
msleep(5);

f3db = ((state->dcur.symbol_rate / 1000) << 2) / 5 + 2000;
if ((state->dcur.symbol_rate / 1000) < 5000)
f3db = ((c->symbol_rate / 1000) << 2) / 5 + 2000;
if ((c->symbol_rate / 1000) < 5000)
f3db += 3000;
if (f3db < 7000)
f3db = 7000;
Expand Down Expand Up @@ -1196,38 +1114,38 @@ static int ds3000_tune(struct dvb_frontend *fe,
ds3000_writereg(state, 0x25, 0x8a);

/* enhance symbol rate performance */
if ((state->dcur.symbol_rate / 1000) <= 5000) {
value = 29777 / (state->dcur.symbol_rate / 1000) + 1;
if ((c->symbol_rate / 1000) <= 5000) {
value = 29777 / (c->symbol_rate / 1000) + 1;
if (value % 2 != 0)
value++;
ds3000_writereg(state, 0xc3, 0x0d);
ds3000_writereg(state, 0xc8, value);
ds3000_writereg(state, 0xc4, 0x10);
ds3000_writereg(state, 0xc7, 0x0e);
} else if ((state->dcur.symbol_rate / 1000) <= 10000) {
value = 92166 / (state->dcur.symbol_rate / 1000) + 1;
} else if ((c->symbol_rate / 1000) <= 10000) {
value = 92166 / (c->symbol_rate / 1000) + 1;
if (value % 2 != 0)
value++;
ds3000_writereg(state, 0xc3, 0x07);
ds3000_writereg(state, 0xc8, value);
ds3000_writereg(state, 0xc4, 0x09);
ds3000_writereg(state, 0xc7, 0x12);
} else if ((state->dcur.symbol_rate / 1000) <= 20000) {
value = 64516 / (state->dcur.symbol_rate / 1000) + 1;
} else if ((c->symbol_rate / 1000) <= 20000) {
value = 64516 / (c->symbol_rate / 1000) + 1;
ds3000_writereg(state, 0xc3, value);
ds3000_writereg(state, 0xc8, 0x0e);
ds3000_writereg(state, 0xc4, 0x07);
ds3000_writereg(state, 0xc7, 0x18);
} else {
value = 129032 / (state->dcur.symbol_rate / 1000) + 1;
value = 129032 / (c->symbol_rate / 1000) + 1;
ds3000_writereg(state, 0xc3, value);
ds3000_writereg(state, 0xc8, 0x0a);
ds3000_writereg(state, 0xc4, 0x05);
ds3000_writereg(state, 0xc7, 0x24);
}

/* normalized symbol rate rounded to the closest integer */
value = (((state->dcur.symbol_rate / 1000) << 16) +
value = (((c->symbol_rate / 1000) << 16) +
(DS3000_SAMPLE_RATE / 2)) / DS3000_SAMPLE_RATE;
ds3000_writereg(state, 0x61, value & 0x00ff);
ds3000_writereg(state, 0x62, (value & 0xff00) >> 8);
Expand Down

0 comments on commit e31c02e

Please sign in to comment.