aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/zl10353.c
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2007-02-10 08:19:11 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:35:24 -0500
commitf7f57770dc610eddd678aec483263e7980327ee9 (patch)
tree50970397f8f0fd7c74d4da5f95c4135d4280b00f /drivers/media/dvb/frontends/zl10353.c
parent0a11bb865a88a7459855ab46f74091e6ca4a1a20 (diff)
V4L/DVB (5217): Zl10353: Implement TRL nominal rate calculation
Implement trl nominal rate calculation to Zarlink ZL10353 demod, based on calculation used in Zarlink MT352. This adds support for 6 and 8MHz bandwidth transponders. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Chris Pascoe <c.pascoe@itee.uq.edu.au> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/frontends/zl10353.c')
-rw-r--r--drivers/media/dvb/frontends/zl10353.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c
index 50dac2054353..dbb53ba6f414 100644
--- a/drivers/media/dvb/frontends/zl10353.c
+++ b/drivers/media/dvb/frontends/zl10353.c
@@ -38,6 +38,12 @@ struct zl10353_state {
38 struct zl10353_config config; 38 struct zl10353_config config;
39}; 39};
40 40
41static int debug;
42#define dprintk(args...) \
43 do { \
44 if (debug) printk(KERN_DEBUG "zl10353: " args); \
45 } while (0)
46
41static int debug_regs = 0; 47static int debug_regs = 0;
42 48
43static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val) 49static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
@@ -113,6 +119,36 @@ static void zl10353_dump_regs(struct dvb_frontend *fe)
113 printk(KERN_DEBUG "%s\n", buf); 119 printk(KERN_DEBUG "%s\n", buf);
114} 120}
115 121
122static void zl10353_calc_nominal_rate(struct dvb_frontend *fe,
123 enum fe_bandwidth bandwidth,
124 u16 *nominal_rate)
125{
126 u32 adc_clock = 22528; /* 20.480 MHz on the board(!?) */
127 u8 bw;
128 struct zl10353_state *state = fe->demodulator_priv;
129
130 if (state->config.adc_clock)
131 adc_clock = state->config.adc_clock;
132
133 switch (bandwidth) {
134 case BANDWIDTH_6_MHZ:
135 bw = 6;
136 break;
137 case BANDWIDTH_7_MHZ:
138 bw = 7;
139 break;
140 case BANDWIDTH_8_MHZ:
141 default:
142 bw = 8;
143 break;
144 }
145
146 *nominal_rate = (64 * bw * (1<<16) / (7 * 8) * 4000 / adc_clock + 2) / 4;
147
148 dprintk("%s: bw %d, adc_clock %d => 0x%x\n",
149 __FUNCTION__, bw, adc_clock, *nominal_rate);
150}
151
116static int zl10353_sleep(struct dvb_frontend *fe) 152static int zl10353_sleep(struct dvb_frontend *fe)
117{ 153{
118 static u8 zl10353_softdown[] = { 0x50, 0x0C, 0x44 }; 154 static u8 zl10353_softdown[] = { 0x50, 0x0C, 0x44 };
@@ -125,7 +161,7 @@ static int zl10353_set_parameters(struct dvb_frontend *fe,
125 struct dvb_frontend_parameters *param) 161 struct dvb_frontend_parameters *param)
126{ 162{
127 struct zl10353_state *state = fe->demodulator_priv; 163 struct zl10353_state *state = fe->demodulator_priv;
128 164 u16 nominal_rate;
129 u8 pllbuf[6] = { 0x67 }; 165 u8 pllbuf[6] = { 0x67 };
130 166
131 /* These settings set "auto-everything" and start the FSM. */ 167 /* These settings set "auto-everything" and start the FSM. */
@@ -138,8 +174,11 @@ static int zl10353_set_parameters(struct dvb_frontend *fe,
138 zl10353_single_write(fe, 0x56, 0x28); 174 zl10353_single_write(fe, 0x56, 0x28);
139 zl10353_single_write(fe, 0x89, 0x20); 175 zl10353_single_write(fe, 0x89, 0x20);
140 zl10353_single_write(fe, 0x5E, 0x00); 176 zl10353_single_write(fe, 0x5E, 0x00);
141 zl10353_single_write(fe, 0x65, 0x5A); 177
142 zl10353_single_write(fe, 0x66, 0xE9); 178 zl10353_calc_nominal_rate(fe, param->u.ofdm.bandwidth, &nominal_rate);
179 zl10353_single_write(fe, TRL_NOMINAL_RATE_1, msb(nominal_rate));
180 zl10353_single_write(fe, TRL_NOMINAL_RATE_0, lsb(nominal_rate));
181
143 zl10353_single_write(fe, 0x6C, 0xCD); 182 zl10353_single_write(fe, 0x6C, 0xCD);
144 zl10353_single_write(fe, 0x6D, 0x7E); 183 zl10353_single_write(fe, 0x6D, 0x7E);
145 if (fe->ops.i2c_gate_ctrl) 184 if (fe->ops.i2c_gate_ctrl)
@@ -377,6 +416,9 @@ static struct dvb_frontend_ops zl10353_ops = {
377 .read_ucblocks = zl10353_read_ucblocks, 416 .read_ucblocks = zl10353_read_ucblocks,
378}; 417};
379 418
419module_param(debug, int, 0644);
420MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
421
380module_param(debug_regs, int, 0644); 422module_param(debug_regs, int, 0644);
381MODULE_PARM_DESC(debug_regs, "Turn on/off frontend register dumps (default:off)."); 423MODULE_PARM_DESC(debug_regs, "Turn on/off frontend register dumps (default:off).");
382 424