Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285399
b: refs/heads/master
c: 37c52ab
h: refs/heads/master
i:
  285397: 7db1b96
  285395: 40f521b
  285391: 20fc256
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed Dec 20, 2011
1 parent 7762e94 commit 65b4b62
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 24 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: 0d7d0ac87b7f023a4e76e7ea7a16e904d5a49ca1
refs/heads/master: 37c52abd565aa8d10ffd7f31a37792425d1564df
66 changes: 43 additions & 23 deletions trunk/drivers/media/dvb/frontends/tda10023.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,42 +298,62 @@ static int tda10023_init (struct dvb_frontend *fe)
return 0;
}

struct qam_params {
u8 qam, lockthr, mseth, aref, agcrefnyq, eragnyq_thd;
};

static int tda10023_set_parameters (struct dvb_frontend *fe,
struct dvb_frontend_parameters *p)
{
struct tda10023_state* state = fe->demodulator_priv;

static int qamvals[6][6] = {
// QAM LOCKTHR MSETH AREF AGCREFNYQ ERAGCNYQ_THD
{ (5<<2), 0x78, 0x8c, 0x96, 0x78, 0x4c }, // 4 QAM
{ (0<<2), 0x87, 0xa2, 0x91, 0x8c, 0x57 }, // 16 QAM
{ (1<<2), 0x64, 0x74, 0x96, 0x8c, 0x57 }, // 32 QAM
{ (2<<2), 0x46, 0x43, 0x6a, 0x6a, 0x44 }, // 64 QAM
{ (3<<2), 0x36, 0x34, 0x7e, 0x78, 0x4c }, // 128 QAM
{ (4<<2), 0x26, 0x23, 0x6c, 0x5c, 0x3c }, // 256 QAM
static const struct qam_params qam_params[] = {
/* Modulation QAM LOCKTHR MSETH AREF AGCREFNYQ ERAGCNYQ_THD */
[QPSK] = { (5<<2), 0x78, 0x8c, 0x96, 0x78, 0x4c },
[QAM_16] = { (0<<2), 0x87, 0xa2, 0x91, 0x8c, 0x57 },
[QAM_32] = { (1<<2), 0x64, 0x74, 0x96, 0x8c, 0x57 },
[QAM_64] = { (2<<2), 0x46, 0x43, 0x6a, 0x6a, 0x44 },
[QAM_128] = { (3<<2), 0x36, 0x34, 0x7e, 0x78, 0x4c },
[QAM_256] = { (4<<2), 0x26, 0x23, 0x6c, 0x5c, 0x3c },
};

int qam = p->u.qam.modulation;

if (qam < 0 || qam > 5)
unsigned qam = p->u.qam.modulation;

/*
* gcc optimizes the code bellow the same way as it would code:
* "if (qam > 5) return -EINVAL;"
* Yet, the code is clearer, as it shows what QAM standards are
* supported by the driver, and avoids the usage of magic numbers on
* it.
*/
switch (qam) {
case QPSK:
case QAM_16:
case QAM_32:
case QAM_64:
case QAM_128:
case QAM_256:
break;
default:
return -EINVAL;
}

if (fe->ops.tuner_ops.set_params) {
fe->ops.tuner_ops.set_params(fe, p);
if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
}

tda10023_set_symbolrate (state, p->u.qam.symbol_rate);
tda10023_writereg (state, 0x05, qamvals[qam][1]);
tda10023_writereg (state, 0x08, qamvals[qam][2]);
tda10023_writereg (state, 0x09, qamvals[qam][3]);
tda10023_writereg (state, 0xb4, qamvals[qam][4]);
tda10023_writereg (state, 0xb6, qamvals[qam][5]);

// tda10023_writereg (state, 0x04, (p->inversion?0x12:0x32));
// tda10023_writebit (state, 0x04, 0x60, (p->inversion?0:0x20));
tda10023_writebit (state, 0x04, 0x40, 0x40);
tda10023_setup_reg0 (state, qamvals[qam][0]);
tda10023_writereg(state, 0x05, qam_params[qam].lockthr);
tda10023_writereg(state, 0x08, qam_params[qam].mseth);
tda10023_writereg(state, 0x09, qam_params[qam].aref);
tda10023_writereg(state, 0xb4, qam_params[qam].agcrefnyq);
tda10023_writereg(state, 0xb6, qam_params[qam].eragnyq_thd);

#if 0
tda10023_writereg(state, 0x04, (p->inversion ? 0x12 : 0x32));
tda10023_writebit(state, 0x04, 0x60, (p->inversion ? 0 : 0x20));
#endif
tda10023_writebit(state, 0x04, 0x40, 0x40);
tda10023_setup_reg0(state, qam_params[qam].qam);

return 0;
}
Expand Down

0 comments on commit 65b4b62

Please sign in to comment.