aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/dvb/frontends/zl10353.c48
-rw-r--r--drivers/media/dvb/frontends/zl10353.h3
-rw-r--r--drivers/media/dvb/frontends/zl10353_priv.h29
3 files changed, 65 insertions, 15 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
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h
index 0bc0109737f1..cb274dc12b82 100644
--- a/drivers/media/dvb/frontends/zl10353.h
+++ b/drivers/media/dvb/frontends/zl10353.h
@@ -29,6 +29,9 @@ struct zl10353_config
29 /* demodulator's I2C address */ 29 /* demodulator's I2C address */
30 u8 demod_address; 30 u8 demod_address;
31 31
32 /* frequencies in kHz */
33 int adc_clock; // default: 22528
34
32 /* set if no pll is connected to the secondary i2c bus */ 35 /* set if no pll is connected to the secondary i2c bus */
33 int no_tuner; 36 int no_tuner;
34 37
diff --git a/drivers/media/dvb/frontends/zl10353_priv.h b/drivers/media/dvb/frontends/zl10353_priv.h
index b72224bd7dde..d2186927f8f1 100644
--- a/drivers/media/dvb/frontends/zl10353_priv.h
+++ b/drivers/media/dvb/frontends/zl10353_priv.h
@@ -24,19 +24,24 @@
24 24
25#define ID_ZL10353 0x14 25#define ID_ZL10353 0x14
26 26
27#define msb(x) (((x) >> 8) & 0xff)
28#define lsb(x) ((x) & 0xff)
29
27enum zl10353_reg_addr { 30enum zl10353_reg_addr {
28 INTERRUPT_0 = 0x00, 31 INTERRUPT_0 = 0x00,
29 INTERRUPT_1 = 0x01, 32 INTERRUPT_1 = 0x01,
30 INTERRUPT_2 = 0x02, 33 INTERRUPT_2 = 0x02,
31 INTERRUPT_3 = 0x03, 34 INTERRUPT_3 = 0x03,
32 INTERRUPT_4 = 0x04, 35 INTERRUPT_4 = 0x04,
33 INTERRUPT_5 = 0x05, 36 INTERRUPT_5 = 0x05,
34 STATUS_6 = 0x06, 37 STATUS_6 = 0x06,
35 STATUS_7 = 0x07, 38 STATUS_7 = 0x07,
36 STATUS_8 = 0x08, 39 STATUS_8 = 0x08,
37 STATUS_9 = 0x09, 40 STATUS_9 = 0x09,
38 SNR = 0x10, 41 SNR = 0x10,
39 CHIP_ID = 0x7F, 42 TRL_NOMINAL_RATE_1 = 0x65,
43 TRL_NOMINAL_RATE_0 = 0x66,
44 CHIP_ID = 0x7F,
40}; 45};
41 46
42#endif /* _ZL10353_PRIV_ */ 47#endif /* _ZL10353_PRIV_ */