diff options
Diffstat (limited to 'drivers/media/dvb/frontends')
-rw-r--r-- | drivers/media/dvb/frontends/cx22702.c | 506 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/cx22702.h | 20 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/cx24116.c | 589 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/cx24116.h | 21 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/cx24123.c | 228 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/cx24123.h | 10 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/s5h1409.c | 138 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/s5h1409.h | 15 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/s5h1411.c | 8 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/tda10048.c | 100 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/z0194a.h | 16 |
11 files changed, 936 insertions, 715 deletions
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c index 9430e03dba6c..5d1abe34bddb 100644 --- a/drivers/media/dvb/frontends/cx22702.c +++ b/drivers/media/dvb/frontends/cx22702.c | |||
@@ -34,13 +34,12 @@ | |||
34 | #include "dvb_frontend.h" | 34 | #include "dvb_frontend.h" |
35 | #include "cx22702.h" | 35 | #include "cx22702.h" |
36 | 36 | ||
37 | |||
38 | struct cx22702_state { | 37 | struct cx22702_state { |
39 | 38 | ||
40 | struct i2c_adapter* i2c; | 39 | struct i2c_adapter *i2c; |
41 | 40 | ||
42 | /* configuration settings */ | 41 | /* configuration settings */ |
43 | const struct cx22702_config* config; | 42 | const struct cx22702_config *config; |
44 | 43 | ||
45 | struct dvb_frontend frontend; | 44 | struct dvb_frontend frontend; |
46 | 45 | ||
@@ -49,10 +48,13 @@ struct cx22702_state { | |||
49 | }; | 48 | }; |
50 | 49 | ||
51 | static int debug; | 50 | static int debug; |
51 | module_param(debug, int, 0644); | ||
52 | MODULE_PARM_DESC(debug, "Enable verbose debug messages"); | ||
53 | |||
52 | #define dprintk if (debug) printk | 54 | #define dprintk if (debug) printk |
53 | 55 | ||
54 | /* Register values to initialise the demod */ | 56 | /* Register values to initialise the demod */ |
55 | static u8 init_tab [] = { | 57 | static u8 init_tab[] = { |
56 | 0x00, 0x00, /* Stop aquisition */ | 58 | 0x00, 0x00, /* Stop aquisition */ |
57 | 0x0B, 0x06, | 59 | 0x0B, 0x06, |
58 | 0x09, 0x01, | 60 | 0x09, 0x01, |
@@ -80,65 +82,67 @@ static u8 init_tab [] = { | |||
80 | 0xfd, 0x00, | 82 | 0xfd, 0x00, |
81 | }; | 83 | }; |
82 | 84 | ||
83 | static int cx22702_writereg (struct cx22702_state* state, u8 reg, u8 data) | 85 | static int cx22702_writereg(struct cx22702_state *state, u8 reg, u8 data) |
84 | { | 86 | { |
85 | int ret; | 87 | int ret; |
86 | u8 buf [] = { reg, data }; | 88 | u8 buf[] = { reg, data }; |
87 | struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; | 89 | struct i2c_msg msg = { |
90 | .addr = state->config->demod_address, .flags = 0, | ||
91 | .buf = buf, .len = 2 }; | ||
88 | 92 | ||
89 | ret = i2c_transfer(state->i2c, &msg, 1); | 93 | ret = i2c_transfer(state->i2c, &msg, 1); |
90 | 94 | ||
91 | if (ret != 1) | 95 | if (ret != 1) |
92 | printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", | 96 | printk(KERN_ERR |
97 | "%s: error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", | ||
93 | __func__, reg, data, ret); | 98 | __func__, reg, data, ret); |
94 | 99 | ||
95 | return (ret != 1) ? -1 : 0; | 100 | return (ret != 1) ? -1 : 0; |
96 | } | 101 | } |
97 | 102 | ||
98 | static u8 cx22702_readreg (struct cx22702_state* state, u8 reg) | 103 | static u8 cx22702_readreg(struct cx22702_state *state, u8 reg) |
99 | { | 104 | { |
100 | int ret; | 105 | int ret; |
101 | u8 b0 [] = { reg }; | 106 | u8 b0[] = { reg }; |
102 | u8 b1 [] = { 0 }; | 107 | u8 b1[] = { 0 }; |
103 | 108 | ||
104 | struct i2c_msg msg [] = { | 109 | struct i2c_msg msg[] = { |
105 | { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, | 110 | { .addr = state->config->demod_address, .flags = 0, |
106 | { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; | 111 | .buf = b0, .len = 1 }, |
112 | { .addr = state->config->demod_address, .flags = I2C_M_RD, | ||
113 | .buf = b1, .len = 1 } }; | ||
107 | 114 | ||
108 | ret = i2c_transfer(state->i2c, msg, 2); | 115 | ret = i2c_transfer(state->i2c, msg, 2); |
109 | 116 | ||
110 | if (ret != 2) | 117 | if (ret != 2) |
111 | printk("%s: readreg error (ret == %i)\n", __func__, ret); | 118 | printk(KERN_ERR "%s: readreg error (ret == %i)\n", |
119 | __func__, ret); | ||
112 | 120 | ||
113 | return b1[0]; | 121 | return b1[0]; |
114 | } | 122 | } |
115 | 123 | ||
116 | static int cx22702_set_inversion (struct cx22702_state *state, int inversion) | 124 | static int cx22702_set_inversion(struct cx22702_state *state, int inversion) |
117 | { | 125 | { |
118 | u8 val; | 126 | u8 val; |
119 | 127 | ||
120 | switch (inversion) { | 128 | switch (inversion) { |
121 | 129 | case INVERSION_AUTO: | |
122 | case INVERSION_AUTO: | 130 | return -EOPNOTSUPP; |
123 | return -EOPNOTSUPP; | 131 | case INVERSION_ON: |
124 | 132 | val = cx22702_readreg(state, 0x0C); | |
125 | case INVERSION_ON: | 133 | return cx22702_writereg(state, 0x0C, val | 0x01); |
126 | val = cx22702_readreg (state, 0x0C); | 134 | case INVERSION_OFF: |
127 | return cx22702_writereg (state, 0x0C, val | 0x01); | 135 | val = cx22702_readreg(state, 0x0C); |
128 | 136 | return cx22702_writereg(state, 0x0C, val & 0xfe); | |
129 | case INVERSION_OFF: | 137 | default: |
130 | val = cx22702_readreg (state, 0x0C); | 138 | return -EINVAL; |
131 | return cx22702_writereg (state, 0x0C, val & 0xfe); | ||
132 | |||
133 | default: | ||
134 | return -EINVAL; | ||
135 | |||
136 | } | 139 | } |
137 | 140 | ||
138 | } | 141 | } |
139 | 142 | ||
140 | /* Retrieve the demod settings */ | 143 | /* Retrieve the demod settings */ |
141 | static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_parameters *p) | 144 | static int cx22702_get_tps(struct cx22702_state *state, |
145 | struct dvb_ofdm_parameters *p) | ||
142 | { | 146 | { |
143 | u8 val; | 147 | u8 val; |
144 | 148 | ||
@@ -146,180 +150,281 @@ static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_paramet | |||
146 | if (!(cx22702_readreg(state, 0x0A) & 0x20)) | 150 | if (!(cx22702_readreg(state, 0x0A) & 0x20)) |
147 | return -EAGAIN; | 151 | return -EAGAIN; |
148 | 152 | ||
149 | val = cx22702_readreg (state, 0x01); | 153 | val = cx22702_readreg(state, 0x01); |
150 | switch( (val&0x18)>>3) { | 154 | switch ((val & 0x18) >> 3) { |
151 | case 0: p->constellation = QPSK; break; | 155 | case 0: |
152 | case 1: p->constellation = QAM_16; break; | 156 | p->constellation = QPSK; |
153 | case 2: p->constellation = QAM_64; break; | 157 | break; |
158 | case 1: | ||
159 | p->constellation = QAM_16; | ||
160 | break; | ||
161 | case 2: | ||
162 | p->constellation = QAM_64; | ||
163 | break; | ||
154 | } | 164 | } |
155 | switch( val&0x07 ) { | 165 | switch (val & 0x07) { |
156 | case 0: p->hierarchy_information = HIERARCHY_NONE; break; | 166 | case 0: |
157 | case 1: p->hierarchy_information = HIERARCHY_1; break; | 167 | p->hierarchy_information = HIERARCHY_NONE; |
158 | case 2: p->hierarchy_information = HIERARCHY_2; break; | 168 | break; |
159 | case 3: p->hierarchy_information = HIERARCHY_4; break; | 169 | case 1: |
170 | p->hierarchy_information = HIERARCHY_1; | ||
171 | break; | ||
172 | case 2: | ||
173 | p->hierarchy_information = HIERARCHY_2; | ||
174 | break; | ||
175 | case 3: | ||
176 | p->hierarchy_information = HIERARCHY_4; | ||
177 | break; | ||
160 | } | 178 | } |
161 | 179 | ||
162 | 180 | ||
163 | val = cx22702_readreg (state, 0x02); | 181 | val = cx22702_readreg(state, 0x02); |
164 | switch( (val&0x38)>>3 ) { | 182 | switch ((val & 0x38) >> 3) { |
165 | case 0: p->code_rate_HP = FEC_1_2; break; | 183 | case 0: |
166 | case 1: p->code_rate_HP = FEC_2_3; break; | 184 | p->code_rate_HP = FEC_1_2; |
167 | case 2: p->code_rate_HP = FEC_3_4; break; | 185 | break; |
168 | case 3: p->code_rate_HP = FEC_5_6; break; | 186 | case 1: |
169 | case 4: p->code_rate_HP = FEC_7_8; break; | 187 | p->code_rate_HP = FEC_2_3; |
188 | break; | ||
189 | case 2: | ||
190 | p->code_rate_HP = FEC_3_4; | ||
191 | break; | ||
192 | case 3: | ||
193 | p->code_rate_HP = FEC_5_6; | ||
194 | break; | ||
195 | case 4: | ||
196 | p->code_rate_HP = FEC_7_8; | ||
197 | break; | ||
170 | } | 198 | } |
171 | switch( val&0x07 ) { | 199 | switch (val & 0x07) { |
172 | case 0: p->code_rate_LP = FEC_1_2; break; | 200 | case 0: |
173 | case 1: p->code_rate_LP = FEC_2_3; break; | 201 | p->code_rate_LP = FEC_1_2; |
174 | case 2: p->code_rate_LP = FEC_3_4; break; | 202 | break; |
175 | case 3: p->code_rate_LP = FEC_5_6; break; | 203 | case 1: |
176 | case 4: p->code_rate_LP = FEC_7_8; break; | 204 | p->code_rate_LP = FEC_2_3; |
205 | break; | ||
206 | case 2: | ||
207 | p->code_rate_LP = FEC_3_4; | ||
208 | break; | ||
209 | case 3: | ||
210 | p->code_rate_LP = FEC_5_6; | ||
211 | break; | ||
212 | case 4: | ||
213 | p->code_rate_LP = FEC_7_8; | ||
214 | break; | ||
177 | } | 215 | } |
178 | 216 | ||
179 | 217 | val = cx22702_readreg(state, 0x03); | |
180 | val = cx22702_readreg (state, 0x03); | 218 | switch ((val & 0x0c) >> 2) { |
181 | switch( (val&0x0c)>>2 ) { | 219 | case 0: |
182 | case 0: p->guard_interval = GUARD_INTERVAL_1_32; break; | 220 | p->guard_interval = GUARD_INTERVAL_1_32; |
183 | case 1: p->guard_interval = GUARD_INTERVAL_1_16; break; | 221 | break; |
184 | case 2: p->guard_interval = GUARD_INTERVAL_1_8; break; | 222 | case 1: |
185 | case 3: p->guard_interval = GUARD_INTERVAL_1_4; break; | 223 | p->guard_interval = GUARD_INTERVAL_1_16; |
224 | break; | ||
225 | case 2: | ||
226 | p->guard_interval = GUARD_INTERVAL_1_8; | ||
227 | break; | ||
228 | case 3: | ||
229 | p->guard_interval = GUARD_INTERVAL_1_4; | ||
230 | break; | ||
186 | } | 231 | } |
187 | switch( val&0x03 ) { | 232 | switch (val & 0x03) { |
188 | case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break; | 233 | case 0: |
189 | case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break; | 234 | p->transmission_mode = TRANSMISSION_MODE_2K; |
235 | break; | ||
236 | case 1: | ||
237 | p->transmission_mode = TRANSMISSION_MODE_8K; | ||
238 | break; | ||
190 | } | 239 | } |
191 | 240 | ||
192 | return 0; | 241 | return 0; |
193 | } | 242 | } |
194 | 243 | ||
195 | static int cx22702_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | 244 | static int cx22702_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) |
196 | { | 245 | { |
197 | struct cx22702_state* state = fe->demodulator_priv; | 246 | struct cx22702_state *state = fe->demodulator_priv; |
198 | dprintk ("%s(%d)\n", __func__, enable); | 247 | dprintk("%s(%d)\n", __func__, enable); |
199 | if (enable) | 248 | if (enable) |
200 | return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) & 0xfe); | 249 | return cx22702_writereg(state, 0x0D, |
250 | cx22702_readreg(state, 0x0D) & 0xfe); | ||
201 | else | 251 | else |
202 | return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) | 1); | 252 | return cx22702_writereg(state, 0x0D, |
253 | cx22702_readreg(state, 0x0D) | 1); | ||
203 | } | 254 | } |
204 | 255 | ||
205 | /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ | 256 | /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ |
206 | static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 257 | static int cx22702_set_tps(struct dvb_frontend *fe, |
258 | struct dvb_frontend_parameters *p) | ||
207 | { | 259 | { |
208 | u8 val; | 260 | u8 val; |
209 | struct cx22702_state* state = fe->demodulator_priv; | 261 | struct cx22702_state *state = fe->demodulator_priv; |
210 | 262 | ||
211 | if (fe->ops.tuner_ops.set_params) { | 263 | if (fe->ops.tuner_ops.set_params) { |
212 | fe->ops.tuner_ops.set_params(fe, p); | 264 | fe->ops.tuner_ops.set_params(fe, p); |
213 | if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); | 265 | if (fe->ops.i2c_gate_ctrl) |
266 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
214 | } | 267 | } |
215 | 268 | ||
216 | /* set inversion */ | 269 | /* set inversion */ |
217 | cx22702_set_inversion (state, p->inversion); | 270 | cx22702_set_inversion(state, p->inversion); |
218 | 271 | ||
219 | /* set bandwidth */ | 272 | /* set bandwidth */ |
220 | switch(p->u.ofdm.bandwidth) { | 273 | switch (p->u.ofdm.bandwidth) { |
221 | case BANDWIDTH_6_MHZ: | 274 | case BANDWIDTH_6_MHZ: |
222 | cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20 ); | 275 | cx22702_writereg(state, 0x0C, |
276 | (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20); | ||
223 | break; | 277 | break; |
224 | case BANDWIDTH_7_MHZ: | 278 | case BANDWIDTH_7_MHZ: |
225 | cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10 ); | 279 | cx22702_writereg(state, 0x0C, |
280 | (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10); | ||
226 | break; | 281 | break; |
227 | case BANDWIDTH_8_MHZ: | 282 | case BANDWIDTH_8_MHZ: |
228 | cx22702_writereg(state, 0x0C, cx22702_readreg(state, 0x0C) &0xcf ); | 283 | cx22702_writereg(state, 0x0C, |
284 | cx22702_readreg(state, 0x0C) & 0xcf); | ||
229 | break; | 285 | break; |
230 | default: | 286 | default: |
231 | dprintk ("%s: invalid bandwidth\n",__func__); | 287 | dprintk("%s: invalid bandwidth\n", __func__); |
232 | return -EINVAL; | 288 | return -EINVAL; |
233 | } | 289 | } |
234 | 290 | ||
235 | 291 | p->u.ofdm.code_rate_LP = FEC_AUTO; /* temp hack as manual not working */ | |
236 | p->u.ofdm.code_rate_LP = FEC_AUTO; //temp hack as manual not working | ||
237 | 292 | ||
238 | /* use auto configuration? */ | 293 | /* use auto configuration? */ |
239 | if((p->u.ofdm.hierarchy_information==HIERARCHY_AUTO) || | 294 | if ((p->u.ofdm.hierarchy_information == HIERARCHY_AUTO) || |
240 | (p->u.ofdm.constellation==QAM_AUTO) || | 295 | (p->u.ofdm.constellation == QAM_AUTO) || |
241 | (p->u.ofdm.code_rate_HP==FEC_AUTO) || | 296 | (p->u.ofdm.code_rate_HP == FEC_AUTO) || |
242 | (p->u.ofdm.code_rate_LP==FEC_AUTO) || | 297 | (p->u.ofdm.code_rate_LP == FEC_AUTO) || |
243 | (p->u.ofdm.guard_interval==GUARD_INTERVAL_AUTO) || | 298 | (p->u.ofdm.guard_interval == GUARD_INTERVAL_AUTO) || |
244 | (p->u.ofdm.transmission_mode==TRANSMISSION_MODE_AUTO) ) { | 299 | (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_AUTO)) { |
245 | 300 | ||
246 | /* TPS Source - use hardware driven values */ | 301 | /* TPS Source - use hardware driven values */ |
247 | cx22702_writereg(state, 0x06, 0x10); | 302 | cx22702_writereg(state, 0x06, 0x10); |
248 | cx22702_writereg(state, 0x07, 0x9); | 303 | cx22702_writereg(state, 0x07, 0x9); |
249 | cx22702_writereg(state, 0x08, 0xC1); | 304 | cx22702_writereg(state, 0x08, 0xC1); |
250 | cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc ); | 305 | cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) |
251 | cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 ); | 306 | & 0xfc); |
307 | cx22702_writereg(state, 0x0C, | ||
308 | (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40); | ||
252 | cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */ | 309 | cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */ |
253 | dprintk("%s: Autodetecting\n",__func__); | 310 | dprintk("%s: Autodetecting\n", __func__); |
254 | return 0; | 311 | return 0; |
255 | } | 312 | } |
256 | 313 | ||
257 | /* manually programmed values */ | 314 | /* manually programmed values */ |
258 | val=0; | 315 | val = 0; |
259 | switch(p->u.ofdm.constellation) { | 316 | switch (p->u.ofdm.constellation) { |
260 | case QPSK: val = (val&0xe7); break; | 317 | case QPSK: |
261 | case QAM_16: val = (val&0xe7)|0x08; break; | 318 | val = (val & 0xe7); |
262 | case QAM_64: val = (val&0xe7)|0x10; break; | 319 | break; |
263 | default: | 320 | case QAM_16: |
264 | dprintk ("%s: invalid constellation\n",__func__); | 321 | val = (val & 0xe7) | 0x08; |
265 | return -EINVAL; | 322 | break; |
323 | case QAM_64: | ||
324 | val = (val & 0xe7) | 0x10; | ||
325 | break; | ||
326 | default: | ||
327 | dprintk("%s: invalid constellation\n", __func__); | ||
328 | return -EINVAL; | ||
266 | } | 329 | } |
267 | switch(p->u.ofdm.hierarchy_information) { | 330 | switch (p->u.ofdm.hierarchy_information) { |
268 | case HIERARCHY_NONE: val = (val&0xf8); break; | 331 | case HIERARCHY_NONE: |
269 | case HIERARCHY_1: val = (val&0xf8)|1; break; | 332 | val = (val & 0xf8); |
270 | case HIERARCHY_2: val = (val&0xf8)|2; break; | 333 | break; |
271 | case HIERARCHY_4: val = (val&0xf8)|3; break; | 334 | case HIERARCHY_1: |
272 | default: | 335 | val = (val & 0xf8) | 1; |
273 | dprintk ("%s: invalid hierarchy\n",__func__); | 336 | break; |
274 | return -EINVAL; | 337 | case HIERARCHY_2: |
338 | val = (val & 0xf8) | 2; | ||
339 | break; | ||
340 | case HIERARCHY_4: | ||
341 | val = (val & 0xf8) | 3; | ||
342 | break; | ||
343 | default: | ||
344 | dprintk("%s: invalid hierarchy\n", __func__); | ||
345 | return -EINVAL; | ||
275 | } | 346 | } |
276 | cx22702_writereg (state, 0x06, val); | 347 | cx22702_writereg(state, 0x06, val); |
277 | 348 | ||
278 | val=0; | 349 | val = 0; |
279 | switch(p->u.ofdm.code_rate_HP) { | 350 | switch (p->u.ofdm.code_rate_HP) { |
280 | case FEC_NONE: | 351 | case FEC_NONE: |
281 | case FEC_1_2: val = (val&0xc7); break; | 352 | case FEC_1_2: |
282 | case FEC_2_3: val = (val&0xc7)|0x08; break; | 353 | val = (val & 0xc7); |
283 | case FEC_3_4: val = (val&0xc7)|0x10; break; | 354 | break; |
284 | case FEC_5_6: val = (val&0xc7)|0x18; break; | 355 | case FEC_2_3: |
285 | case FEC_7_8: val = (val&0xc7)|0x20; break; | 356 | val = (val & 0xc7) | 0x08; |
286 | default: | 357 | break; |
287 | dprintk ("%s: invalid code_rate_HP\n",__func__); | 358 | case FEC_3_4: |
288 | return -EINVAL; | 359 | val = (val & 0xc7) | 0x10; |
360 | break; | ||
361 | case FEC_5_6: | ||
362 | val = (val & 0xc7) | 0x18; | ||
363 | break; | ||
364 | case FEC_7_8: | ||
365 | val = (val & 0xc7) | 0x20; | ||
366 | break; | ||
367 | default: | ||
368 | dprintk("%s: invalid code_rate_HP\n", __func__); | ||
369 | return -EINVAL; | ||
289 | } | 370 | } |
290 | switch(p->u.ofdm.code_rate_LP) { | 371 | switch (p->u.ofdm.code_rate_LP) { |
291 | case FEC_NONE: | 372 | case FEC_NONE: |
292 | case FEC_1_2: val = (val&0xf8); break; | 373 | case FEC_1_2: |
293 | case FEC_2_3: val = (val&0xf8)|1; break; | 374 | val = (val & 0xf8); |
294 | case FEC_3_4: val = (val&0xf8)|2; break; | 375 | break; |
295 | case FEC_5_6: val = (val&0xf8)|3; break; | 376 | case FEC_2_3: |
296 | case FEC_7_8: val = (val&0xf8)|4; break; | 377 | val = (val & 0xf8) | 1; |
297 | default: | 378 | break; |
298 | dprintk ("%s: invalid code_rate_LP\n",__func__); | 379 | case FEC_3_4: |
299 | return -EINVAL; | 380 | val = (val & 0xf8) | 2; |
381 | break; | ||
382 | case FEC_5_6: | ||
383 | val = (val & 0xf8) | 3; | ||
384 | break; | ||
385 | case FEC_7_8: | ||
386 | val = (val & 0xf8) | 4; | ||
387 | break; | ||
388 | default: | ||
389 | dprintk("%s: invalid code_rate_LP\n", __func__); | ||
390 | return -EINVAL; | ||
300 | } | 391 | } |
301 | cx22702_writereg (state, 0x07, val); | 392 | cx22702_writereg(state, 0x07, val); |
302 | 393 | ||
303 | val=0; | 394 | val = 0; |
304 | switch(p->u.ofdm.guard_interval) { | 395 | switch (p->u.ofdm.guard_interval) { |
305 | case GUARD_INTERVAL_1_32: val = (val&0xf3); break; | 396 | case GUARD_INTERVAL_1_32: |
306 | case GUARD_INTERVAL_1_16: val = (val&0xf3)|0x04; break; | 397 | val = (val & 0xf3); |
307 | case GUARD_INTERVAL_1_8: val = (val&0xf3)|0x08; break; | 398 | break; |
308 | case GUARD_INTERVAL_1_4: val = (val&0xf3)|0x0c; break; | 399 | case GUARD_INTERVAL_1_16: |
309 | default: | 400 | val = (val & 0xf3) | 0x04; |
310 | dprintk ("%s: invalid guard_interval\n",__func__); | 401 | break; |
311 | return -EINVAL; | 402 | case GUARD_INTERVAL_1_8: |
403 | val = (val & 0xf3) | 0x08; | ||
404 | break; | ||
405 | case GUARD_INTERVAL_1_4: | ||
406 | val = (val & 0xf3) | 0x0c; | ||
407 | break; | ||
408 | default: | ||
409 | dprintk("%s: invalid guard_interval\n", __func__); | ||
410 | return -EINVAL; | ||
312 | } | 411 | } |
313 | switch(p->u.ofdm.transmission_mode) { | 412 | switch (p->u.ofdm.transmission_mode) { |
314 | case TRANSMISSION_MODE_2K: val = (val&0xfc); break; | 413 | case TRANSMISSION_MODE_2K: |
315 | case TRANSMISSION_MODE_8K: val = (val&0xfc)|1; break; | 414 | val = (val & 0xfc); |
316 | default: | 415 | break; |
317 | dprintk ("%s: invalid transmission_mode\n",__func__); | 416 | case TRANSMISSION_MODE_8K: |
318 | return -EINVAL; | 417 | val = (val & 0xfc) | 1; |
418 | break; | ||
419 | default: | ||
420 | dprintk("%s: invalid transmission_mode\n", __func__); | ||
421 | return -EINVAL; | ||
319 | } | 422 | } |
320 | cx22702_writereg(state, 0x08, val); | 423 | cx22702_writereg(state, 0x08, val); |
321 | cx22702_writereg(state, 0x0B, (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02 ); | 424 | cx22702_writereg(state, 0x0B, |
322 | cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 ); | 425 | (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02); |
426 | cx22702_writereg(state, 0x0C, | ||
427 | (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40); | ||
323 | 428 | ||
324 | /* Begin channel aquisition */ | 429 | /* Begin channel aquisition */ |
325 | cx22702_writereg(state, 0x00, 0x01); | 430 | cx22702_writereg(state, 0x00, 0x01); |
@@ -329,109 +434,111 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
329 | 434 | ||
330 | /* Reset the demod hardware and reset all of the configuration registers | 435 | /* Reset the demod hardware and reset all of the configuration registers |
331 | to a default state. */ | 436 | to a default state. */ |
332 | static int cx22702_init (struct dvb_frontend* fe) | 437 | static int cx22702_init(struct dvb_frontend *fe) |
333 | { | 438 | { |
334 | int i; | 439 | int i; |
335 | struct cx22702_state* state = fe->demodulator_priv; | 440 | struct cx22702_state *state = fe->demodulator_priv; |
336 | 441 | ||
337 | cx22702_writereg (state, 0x00, 0x02); | 442 | cx22702_writereg(state, 0x00, 0x02); |
338 | 443 | ||
339 | msleep(10); | 444 | msleep(10); |
340 | 445 | ||
341 | for (i=0; i<sizeof(init_tab); i+=2) | 446 | for (i = 0; i < ARRAY_SIZE(init_tab); i += 2) |
342 | cx22702_writereg (state, init_tab[i], init_tab[i+1]); | 447 | cx22702_writereg(state, init_tab[i], init_tab[i + 1]); |
343 | 448 | ||
344 | cx22702_writereg (state, 0xf8, (state->config->output_mode << 1) & 0x02); | 449 | cx22702_writereg(state, 0xf8, (state->config->output_mode << 1) |
450 | & 0x02); | ||
345 | 451 | ||
346 | cx22702_i2c_gate_ctrl(fe, 0); | 452 | cx22702_i2c_gate_ctrl(fe, 0); |
347 | 453 | ||
348 | return 0; | 454 | return 0; |
349 | } | 455 | } |
350 | 456 | ||
351 | static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status) | 457 | static int cx22702_read_status(struct dvb_frontend *fe, fe_status_t *status) |
352 | { | 458 | { |
353 | struct cx22702_state* state = fe->demodulator_priv; | 459 | struct cx22702_state *state = fe->demodulator_priv; |
354 | u8 reg0A; | 460 | u8 reg0A; |
355 | u8 reg23; | 461 | u8 reg23; |
356 | 462 | ||
357 | *status = 0; | 463 | *status = 0; |
358 | 464 | ||
359 | reg0A = cx22702_readreg (state, 0x0A); | 465 | reg0A = cx22702_readreg(state, 0x0A); |
360 | reg23 = cx22702_readreg (state, 0x23); | 466 | reg23 = cx22702_readreg(state, 0x23); |
361 | 467 | ||
362 | dprintk ("%s: status demod=0x%02x agc=0x%02x\n" | 468 | dprintk("%s: status demod=0x%02x agc=0x%02x\n" |
363 | ,__func__,reg0A,reg23); | 469 | , __func__, reg0A, reg23); |
364 | 470 | ||
365 | if(reg0A & 0x10) { | 471 | if (reg0A & 0x10) { |
366 | *status |= FE_HAS_LOCK; | 472 | *status |= FE_HAS_LOCK; |
367 | *status |= FE_HAS_VITERBI; | 473 | *status |= FE_HAS_VITERBI; |
368 | *status |= FE_HAS_SYNC; | 474 | *status |= FE_HAS_SYNC; |
369 | } | 475 | } |
370 | 476 | ||
371 | if(reg0A & 0x20) | 477 | if (reg0A & 0x20) |
372 | *status |= FE_HAS_CARRIER; | 478 | *status |= FE_HAS_CARRIER; |
373 | 479 | ||
374 | if(reg23 < 0xf0) | 480 | if (reg23 < 0xf0) |
375 | *status |= FE_HAS_SIGNAL; | 481 | *status |= FE_HAS_SIGNAL; |
376 | 482 | ||
377 | return 0; | 483 | return 0; |
378 | } | 484 | } |
379 | 485 | ||
380 | static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber) | 486 | static int cx22702_read_ber(struct dvb_frontend *fe, u32 *ber) |
381 | { | 487 | { |
382 | struct cx22702_state* state = fe->demodulator_priv; | 488 | struct cx22702_state *state = fe->demodulator_priv; |
383 | 489 | ||
384 | if(cx22702_readreg (state, 0xE4) & 0x02) { | 490 | if (cx22702_readreg(state, 0xE4) & 0x02) { |
385 | /* Realtime statistics */ | 491 | /* Realtime statistics */ |
386 | *ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 | 492 | *ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 |
387 | | (cx22702_readreg (state, 0xDF)&0x7F); | 493 | | (cx22702_readreg(state, 0xDF) & 0x7F); |
388 | } else { | 494 | } else { |
389 | /* Averagtine statistics */ | 495 | /* Averagtine statistics */ |
390 | *ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 | 496 | *ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 |
391 | | cx22702_readreg (state, 0xDF); | 497 | | cx22702_readreg(state, 0xDF); |
392 | } | 498 | } |
393 | 499 | ||
394 | return 0; | 500 | return 0; |
395 | } | 501 | } |
396 | 502 | ||
397 | static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) | 503 | static int cx22702_read_signal_strength(struct dvb_frontend *fe, |
504 | u16 *signal_strength) | ||
398 | { | 505 | { |
399 | struct cx22702_state* state = fe->demodulator_priv; | 506 | struct cx22702_state *state = fe->demodulator_priv; |
400 | 507 | ||
401 | u16 rs_ber = 0; | 508 | u16 rs_ber = 0; |
402 | rs_ber = cx22702_readreg (state, 0x23); | 509 | rs_ber = cx22702_readreg(state, 0x23); |
403 | *signal_strength = (rs_ber << 8) | rs_ber; | 510 | *signal_strength = (rs_ber << 8) | rs_ber; |
404 | 511 | ||
405 | return 0; | 512 | return 0; |
406 | } | 513 | } |
407 | 514 | ||
408 | static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr) | 515 | static int cx22702_read_snr(struct dvb_frontend *fe, u16 *snr) |
409 | { | 516 | { |
410 | struct cx22702_state* state = fe->demodulator_priv; | 517 | struct cx22702_state *state = fe->demodulator_priv; |
411 | 518 | ||
412 | u16 rs_ber=0; | 519 | u16 rs_ber = 0; |
413 | if(cx22702_readreg (state, 0xE4) & 0x02) { | 520 | if (cx22702_readreg(state, 0xE4) & 0x02) { |
414 | /* Realtime statistics */ | 521 | /* Realtime statistics */ |
415 | rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 | 522 | rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 |
416 | | (cx22702_readreg (state, 0xDF)& 0x7F); | 523 | | (cx22702_readreg(state, 0xDF) & 0x7F); |
417 | } else { | 524 | } else { |
418 | /* Averagine statistics */ | 525 | /* Averagine statistics */ |
419 | rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 8 | 526 | rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 8 |
420 | | cx22702_readreg (state, 0xDF); | 527 | | cx22702_readreg(state, 0xDF); |
421 | } | 528 | } |
422 | *snr = ~rs_ber; | 529 | *snr = ~rs_ber; |
423 | 530 | ||
424 | return 0; | 531 | return 0; |
425 | } | 532 | } |
426 | 533 | ||
427 | static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | 534 | static int cx22702_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) |
428 | { | 535 | { |
429 | struct cx22702_state* state = fe->demodulator_priv; | 536 | struct cx22702_state *state = fe->demodulator_priv; |
430 | 537 | ||
431 | u8 _ucblocks; | 538 | u8 _ucblocks; |
432 | 539 | ||
433 | /* RS Uncorrectable Packet Count then reset */ | 540 | /* RS Uncorrectable Packet Count then reset */ |
434 | _ucblocks = cx22702_readreg (state, 0xE3); | 541 | _ucblocks = cx22702_readreg(state, 0xE3); |
435 | if (state->prevUCBlocks < _ucblocks) | 542 | if (state->prevUCBlocks < _ucblocks) |
436 | *ucblocks = (_ucblocks - state->prevUCBlocks); | 543 | *ucblocks = (_ucblocks - state->prevUCBlocks); |
437 | else | 544 | else |
@@ -441,34 +548,36 @@ static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | |||
441 | return 0; | 548 | return 0; |
442 | } | 549 | } |
443 | 550 | ||
444 | static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 551 | static int cx22702_get_frontend(struct dvb_frontend *fe, |
552 | struct dvb_frontend_parameters *p) | ||
445 | { | 553 | { |
446 | struct cx22702_state* state = fe->demodulator_priv; | 554 | struct cx22702_state *state = fe->demodulator_priv; |
447 | 555 | ||
448 | u8 reg0C = cx22702_readreg (state, 0x0C); | 556 | u8 reg0C = cx22702_readreg(state, 0x0C); |
449 | 557 | ||
450 | p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF; | 558 | p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF; |
451 | return cx22702_get_tps (state, &p->u.ofdm); | 559 | return cx22702_get_tps(state, &p->u.ofdm); |
452 | } | 560 | } |
453 | 561 | ||
454 | static int cx22702_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) | 562 | static int cx22702_get_tune_settings(struct dvb_frontend *fe, |
563 | struct dvb_frontend_tune_settings *tune) | ||
455 | { | 564 | { |
456 | tune->min_delay_ms = 1000; | 565 | tune->min_delay_ms = 1000; |
457 | return 0; | 566 | return 0; |
458 | } | 567 | } |
459 | 568 | ||
460 | static void cx22702_release(struct dvb_frontend* fe) | 569 | static void cx22702_release(struct dvb_frontend *fe) |
461 | { | 570 | { |
462 | struct cx22702_state* state = fe->demodulator_priv; | 571 | struct cx22702_state *state = fe->demodulator_priv; |
463 | kfree(state); | 572 | kfree(state); |
464 | } | 573 | } |
465 | 574 | ||
466 | static struct dvb_frontend_ops cx22702_ops; | 575 | static struct dvb_frontend_ops cx22702_ops; |
467 | 576 | ||
468 | struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, | 577 | struct dvb_frontend *cx22702_attach(const struct cx22702_config *config, |
469 | struct i2c_adapter* i2c) | 578 | struct i2c_adapter *i2c) |
470 | { | 579 | { |
471 | struct cx22702_state* state = NULL; | 580 | struct cx22702_state *state = NULL; |
472 | 581 | ||
473 | /* allocate memory for the internal state */ | 582 | /* allocate memory for the internal state */ |
474 | state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); | 583 | state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); |
@@ -485,7 +594,8 @@ struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, | |||
485 | goto error; | 594 | goto error; |
486 | 595 | ||
487 | /* create dvb_frontend */ | 596 | /* create dvb_frontend */ |
488 | memcpy(&state->frontend.ops, &cx22702_ops, sizeof(struct dvb_frontend_ops)); | 597 | memcpy(&state->frontend.ops, &cx22702_ops, |
598 | sizeof(struct dvb_frontend_ops)); | ||
489 | state->frontend.demodulator_priv = state; | 599 | state->frontend.demodulator_priv = state; |
490 | return &state->frontend; | 600 | return &state->frontend; |
491 | 601 | ||
@@ -493,6 +603,7 @@ error: | |||
493 | kfree(state); | 603 | kfree(state); |
494 | return NULL; | 604 | return NULL; |
495 | } | 605 | } |
606 | EXPORT_SYMBOL(cx22702_attach); | ||
496 | 607 | ||
497 | static struct dvb_frontend_ops cx22702_ops = { | 608 | static struct dvb_frontend_ops cx22702_ops = { |
498 | 609 | ||
@@ -525,11 +636,6 @@ static struct dvb_frontend_ops cx22702_ops = { | |||
525 | .read_ucblocks = cx22702_read_ucblocks, | 636 | .read_ucblocks = cx22702_read_ucblocks, |
526 | }; | 637 | }; |
527 | 638 | ||
528 | module_param(debug, int, 0644); | ||
529 | MODULE_PARM_DESC(debug, "Enable verbose debug messages"); | ||
530 | |||
531 | MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver"); | 639 | MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver"); |
532 | MODULE_AUTHOR("Steven Toth"); | 640 | MODULE_AUTHOR("Steven Toth"); |
533 | MODULE_LICENSE("GPL"); | 641 | MODULE_LICENSE("GPL"); |
534 | |||
535 | EXPORT_SYMBOL(cx22702_attach); | ||
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h index b1e465c6c2ce..f154e1f428eb 100644 --- a/drivers/media/dvb/frontends/cx22702.h +++ b/drivers/media/dvb/frontends/cx22702.h | |||
@@ -30,8 +30,7 @@ | |||
30 | 30 | ||
31 | #include <linux/dvb/frontend.h> | 31 | #include <linux/dvb/frontend.h> |
32 | 32 | ||
33 | struct cx22702_config | 33 | struct cx22702_config { |
34 | { | ||
35 | /* the demodulator's i2c address */ | 34 | /* the demodulator's i2c address */ |
36 | u8 demod_address; | 35 | u8 demod_address; |
37 | 36 | ||
@@ -41,16 +40,19 @@ struct cx22702_config | |||
41 | u8 output_mode; | 40 | u8 output_mode; |
42 | }; | 41 | }; |
43 | 42 | ||
44 | #if defined(CONFIG_DVB_CX22702) || (defined(CONFIG_DVB_CX22702_MODULE) && defined(MODULE)) | 43 | #if defined(CONFIG_DVB_CX22702) || (defined(CONFIG_DVB_CX22702_MODULE) \ |
45 | extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, | 44 | && defined(MODULE)) |
46 | struct i2c_adapter* i2c); | 45 | extern struct dvb_frontend *cx22702_attach( |
46 | const struct cx22702_config *config, | ||
47 | struct i2c_adapter *i2c); | ||
47 | #else | 48 | #else |
48 | static inline struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, | 49 | static inline struct dvb_frontend *cx22702_attach( |
49 | struct i2c_adapter* i2c) | 50 | const struct cx22702_config *config, |
51 | struct i2c_adapter *i2c) | ||
50 | { | 52 | { |
51 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 53 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
52 | return NULL; | 54 | return NULL; |
53 | } | 55 | } |
54 | #endif // CONFIG_DVB_CX22702 | 56 | #endif |
55 | 57 | ||
56 | #endif // CX22702_H | 58 | #endif |
diff --git a/drivers/media/dvb/frontends/cx24116.c b/drivers/media/dvb/frontends/cx24116.c index deb36f469ada..b144b308a4dd 100644 --- a/drivers/media/dvb/frontends/cx24116.c +++ b/drivers/media/dvb/frontends/cx24116.c | |||
@@ -41,10 +41,14 @@ | |||
41 | #include "dvb_frontend.h" | 41 | #include "dvb_frontend.h" |
42 | #include "cx24116.h" | 42 | #include "cx24116.h" |
43 | 43 | ||
44 | static int debug = 0; | 44 | static int debug; |
45 | module_param(debug, int, 0644); | ||
46 | MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); | ||
47 | |||
45 | #define dprintk(args...) \ | 48 | #define dprintk(args...) \ |
46 | do { \ | 49 | do { \ |
47 | if (debug) printk ("cx24116: " args); \ | 50 | if (debug) \ |
51 | printk(KERN_INFO "cx24116: " args); \ | ||
48 | } while (0) | 52 | } while (0) |
49 | 53 | ||
50 | #define CX24116_DEFAULT_FIRMWARE "dvb-fe-cx24116.fw" | 54 | #define CX24116_DEFAULT_FIRMWARE "dvb-fe-cx24116.fw" |
@@ -68,13 +72,20 @@ static int debug = 0; | |||
68 | #define CX24116_REG_UCB8 (0xca) | 72 | #define CX24116_REG_UCB8 (0xca) |
69 | #define CX24116_REG_CLKDIV (0xf3) | 73 | #define CX24116_REG_CLKDIV (0xf3) |
70 | #define CX24116_REG_RATEDIV (0xf9) | 74 | #define CX24116_REG_RATEDIV (0xf9) |
71 | #define CX24116_REG_FECSTATUS (0x9c) /* configured fec (not tuned) or actual FEC (tuned) 1=1/2 2=2/3 etc */ | 75 | |
76 | /* configured fec (not tuned) or actual FEC (tuned) 1=1/2 2=2/3 etc */ | ||
77 | #define CX24116_REG_FECSTATUS (0x9c) | ||
72 | 78 | ||
73 | /* FECSTATUS bits */ | 79 | /* FECSTATUS bits */ |
74 | #define CX24116_FEC_FECMASK (0x1f) /* mask to determine configured fec (not tuned) or actual fec (tuned) */ | 80 | /* mask to determine configured fec (not tuned) or actual fec (tuned) */ |
75 | #define CX24116_FEC_DVBS (0x20) /* Select DVB-S demodulator, else DVB-S2 */ | 81 | #define CX24116_FEC_FECMASK (0x1f) |
82 | |||
83 | /* Select DVB-S demodulator, else DVB-S2 */ | ||
84 | #define CX24116_FEC_DVBS (0x20) | ||
76 | #define CX24116_FEC_UNKNOWN (0x40) /* Unknown/unused */ | 85 | #define CX24116_FEC_UNKNOWN (0x40) /* Unknown/unused */ |
77 | #define CX24116_FEC_PILOT (0x80) /* Pilot mode requested when tuning else always reset when tuned */ | 86 | |
87 | /* Pilot mode requested when tuning else always reset when tuned */ | ||
88 | #define CX24116_FEC_PILOT (0x80) | ||
78 | 89 | ||
79 | /* arg buffer size */ | 90 | /* arg buffer size */ |
80 | #define CX24116_ARGLEN (0x1e) | 91 | #define CX24116_ARGLEN (0x1e) |
@@ -116,12 +127,17 @@ static int debug = 0; | |||
116 | 127 | ||
117 | /* DiSEqC tone burst */ | 128 | /* DiSEqC tone burst */ |
118 | static int toneburst = 1; | 129 | static int toneburst = 1; |
130 | module_param(toneburst, int, 0644); | ||
131 | MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, "\ | ||
132 | "2=MESSAGE CACHE (default:1)"); | ||
119 | 133 | ||
120 | /* SNR measurements */ | 134 | /* SNR measurements */ |
121 | static int esno_snr = 0; | 135 | static int esno_snr; |
136 | module_param(esno_snr, int, 0644); | ||
137 | MODULE_PARM_DESC(debug, "SNR return units, 0=PERCENTAGE 0-100, "\ | ||
138 | "1=ESNO(db * 10) (default:0)"); | ||
122 | 139 | ||
123 | enum cmds | 140 | enum cmds { |
124 | { | ||
125 | CMD_SET_VCO = 0x10, | 141 | CMD_SET_VCO = 0x10, |
126 | CMD_TUNEREQUEST = 0x11, | 142 | CMD_TUNEREQUEST = 0x11, |
127 | CMD_MPEGCONFIG = 0x13, | 143 | CMD_MPEGCONFIG = 0x13, |
@@ -138,8 +154,7 @@ enum cmds | |||
138 | }; | 154 | }; |
139 | 155 | ||
140 | /* The Demod/Tuner can't easily provide these, we cache them */ | 156 | /* The Demod/Tuner can't easily provide these, we cache them */ |
141 | struct cx24116_tuning | 157 | struct cx24116_tuning { |
142 | { | ||
143 | u32 frequency; | 158 | u32 frequency; |
144 | u32 symbol_rate; | 159 | u32 symbol_rate; |
145 | fe_spectral_inversion_t inversion; | 160 | fe_spectral_inversion_t inversion; |
@@ -158,16 +173,14 @@ struct cx24116_tuning | |||
158 | }; | 173 | }; |
159 | 174 | ||
160 | /* Basic commands that are sent to the firmware */ | 175 | /* Basic commands that are sent to the firmware */ |
161 | struct cx24116_cmd | 176 | struct cx24116_cmd { |
162 | { | ||
163 | u8 len; | 177 | u8 len; |
164 | u8 args[CX24116_ARGLEN]; | 178 | u8 args[CX24116_ARGLEN]; |
165 | }; | 179 | }; |
166 | 180 | ||
167 | struct cx24116_state | 181 | struct cx24116_state { |
168 | { | 182 | struct i2c_adapter *i2c; |
169 | struct i2c_adapter* i2c; | 183 | const struct cx24116_config *config; |
170 | const struct cx24116_config* config; | ||
171 | 184 | ||
172 | struct dvb_frontend frontend; | 185 | struct dvb_frontend frontend; |
173 | 186 | ||
@@ -179,19 +192,20 @@ struct cx24116_state | |||
179 | struct cx24116_cmd dsec_cmd; | 192 | struct cx24116_cmd dsec_cmd; |
180 | }; | 193 | }; |
181 | 194 | ||
182 | static int cx24116_writereg(struct cx24116_state* state, int reg, int data) | 195 | static int cx24116_writereg(struct cx24116_state *state, int reg, int data) |
183 | { | 196 | { |
184 | u8 buf[] = { reg, data }; | 197 | u8 buf[] = { reg, data }; |
185 | struct i2c_msg msg = { .addr = state->config->demod_address, | 198 | struct i2c_msg msg = { .addr = state->config->demod_address, |
186 | .flags = 0, .buf = buf, .len = 2 }; | 199 | .flags = 0, .buf = buf, .len = 2 }; |
187 | int err; | 200 | int err; |
188 | 201 | ||
189 | if (debug>1) | 202 | if (debug > 1) |
190 | printk("cx24116: %s: write reg 0x%02x, value 0x%02x\n", | 203 | printk("cx24116: %s: write reg 0x%02x, value 0x%02x\n", |
191 | __func__,reg, data); | 204 | __func__, reg, data); |
192 | 205 | ||
193 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { | 206 | err = i2c_transfer(state->i2c, &msg, 1); |
194 | printk("%s: writereg error(err == %i, reg == 0x%02x," | 207 | if (err != 1) { |
208 | printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x," | ||
195 | " value == 0x%02x)\n", __func__, err, reg, data); | 209 | " value == 0x%02x)\n", __func__, err, reg, data); |
196 | return -EREMOTEIO; | 210 | return -EREMOTEIO; |
197 | } | 211 | } |
@@ -200,7 +214,8 @@ static int cx24116_writereg(struct cx24116_state* state, int reg, int data) | |||
200 | } | 214 | } |
201 | 215 | ||
202 | /* Bulk byte writes to a single I2C address, for 32k firmware load */ | 216 | /* Bulk byte writes to a single I2C address, for 32k firmware load */ |
203 | static int cx24116_writeregN(struct cx24116_state* state, int reg, u8 *data, u16 len) | 217 | static int cx24116_writeregN(struct cx24116_state *state, int reg, |
218 | const u8 *data, u16 len) | ||
204 | { | 219 | { |
205 | int ret = -EREMOTEIO; | 220 | int ret = -EREMOTEIO; |
206 | struct i2c_msg msg; | 221 | struct i2c_msg msg; |
@@ -221,12 +236,13 @@ static int cx24116_writeregN(struct cx24116_state* state, int reg, u8 *data, u16 | |||
221 | msg.buf = buf; | 236 | msg.buf = buf; |
222 | msg.len = len + 1; | 237 | msg.len = len + 1; |
223 | 238 | ||
224 | if (debug>1) | 239 | if (debug > 1) |
225 | printk("cx24116: %s: write regN 0x%02x, len = %d\n", | 240 | printk(KERN_INFO "cx24116: %s: write regN 0x%02x, len = %d\n", |
226 | __func__,reg, len); | 241 | __func__, reg, len); |
227 | 242 | ||
228 | if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) { | 243 | ret = i2c_transfer(state->i2c, &msg, 1); |
229 | printk("%s: writereg error(err == %i, reg == 0x%02x\n", | 244 | if (ret != 1) { |
245 | printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x\n", | ||
230 | __func__, ret, reg); | 246 | __func__, ret, reg); |
231 | ret = -EREMOTEIO; | 247 | ret = -EREMOTEIO; |
232 | } | 248 | } |
@@ -237,30 +253,35 @@ error: | |||
237 | return ret; | 253 | return ret; |
238 | } | 254 | } |
239 | 255 | ||
240 | static int cx24116_readreg(struct cx24116_state* state, u8 reg) | 256 | static int cx24116_readreg(struct cx24116_state *state, u8 reg) |
241 | { | 257 | { |
242 | int ret; | 258 | int ret; |
243 | u8 b0[] = { reg }; | 259 | u8 b0[] = { reg }; |
244 | u8 b1[] = { 0 }; | 260 | u8 b1[] = { 0 }; |
245 | struct i2c_msg msg[] = { | 261 | struct i2c_msg msg[] = { |
246 | { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, | 262 | { .addr = state->config->demod_address, .flags = 0, |
247 | { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } | 263 | .buf = b0, .len = 1 }, |
264 | { .addr = state->config->demod_address, .flags = I2C_M_RD, | ||
265 | .buf = b1, .len = 1 } | ||
248 | }; | 266 | }; |
249 | 267 | ||
250 | ret = i2c_transfer(state->i2c, msg, 2); | 268 | ret = i2c_transfer(state->i2c, msg, 2); |
251 | 269 | ||
252 | if (ret != 2) { | 270 | if (ret != 2) { |
253 | printk("%s: reg=0x%x (error=%d)\n", __func__, reg, ret); | 271 | printk(KERN_ERR "%s: reg=0x%x (error=%d)\n", |
272 | __func__, reg, ret); | ||
254 | return ret; | 273 | return ret; |
255 | } | 274 | } |
256 | 275 | ||
257 | if (debug>1) | 276 | if (debug > 1) |
258 | printk("cx24116: read reg 0x%02x, value 0x%02x\n",reg, b1[0]); | 277 | printk(KERN_INFO "cx24116: read reg 0x%02x, value 0x%02x\n", |
278 | reg, b1[0]); | ||
259 | 279 | ||
260 | return b1[0]; | 280 | return b1[0]; |
261 | } | 281 | } |
262 | 282 | ||
263 | static int cx24116_set_inversion(struct cx24116_state* state, fe_spectral_inversion_t inversion) | 283 | static int cx24116_set_inversion(struct cx24116_state *state, |
284 | fe_spectral_inversion_t inversion) | ||
264 | { | 285 | { |
265 | dprintk("%s(%d)\n", __func__, inversion); | 286 | dprintk("%s(%d)\n", __func__, inversion); |
266 | 287 | ||
@@ -308,10 +329,10 @@ static int cx24116_set_inversion(struct cx24116_state* state, fe_spectral_invers | |||
308 | * Eg.(2/3) szap "Zone Horror" | 329 | * Eg.(2/3) szap "Zone Horror" |
309 | * | 330 | * |
310 | * mask/val = 0x04, 0x20 | 331 | * mask/val = 0x04, 0x20 |
311 | * status 1f | signal c3c0 | snr a333 | ber 00000098 | unc 00000000 | FE_HAS_LOCK | 332 | * status 1f | signal c3c0 | snr a333 | ber 00000098 | unc 0 | FE_HAS_LOCK |
312 | * | 333 | * |
313 | * mask/val = 0x04, 0x30 | 334 | * mask/val = 0x04, 0x30 |
314 | * status 1f | signal c3c0 | snr a333 | ber 00000000 | unc 00000000 | FE_HAS_LOCK | 335 | * status 1f | signal c3c0 | snr a333 | ber 00000000 | unc 0 | FE_HAS_LOCK |
315 | * | 336 | * |
316 | * After tuning FECSTATUS contains actual FEC | 337 | * After tuning FECSTATUS contains actual FEC |
317 | * in use numbered 1 through to 8 for 1/2 .. 2/3 etc | 338 | * in use numbered 1 through to 8 for 1/2 .. 2/3 etc |
@@ -389,18 +410,16 @@ struct cx24116_modfec { | |||
389 | */ | 410 | */ |
390 | }; | 411 | }; |
391 | 412 | ||
392 | static int cx24116_lookup_fecmod(struct cx24116_state* state, | 413 | static int cx24116_lookup_fecmod(struct cx24116_state *state, |
393 | fe_modulation_t m, fe_code_rate_t f) | 414 | fe_modulation_t m, fe_code_rate_t f) |
394 | { | 415 | { |
395 | int i, ret = -EOPNOTSUPP; | 416 | int i, ret = -EOPNOTSUPP; |
396 | 417 | ||
397 | dprintk("%s(0x%02x,0x%02x)\n", __func__, m, f); | 418 | dprintk("%s(0x%02x,0x%02x)\n", __func__, m, f); |
398 | 419 | ||
399 | for(i=0 ; i < sizeof(CX24116_MODFEC_MODES) / sizeof(struct cx24116_modfec) ; i++) | 420 | for (i = 0; i < ARRAY_SIZE(CX24116_MODFEC_MODES); i++) { |
400 | { | 421 | if ((m == CX24116_MODFEC_MODES[i].modulation) && |
401 | if( (m == CX24116_MODFEC_MODES[i].modulation) && | 422 | (f == CX24116_MODFEC_MODES[i].fec)) { |
402 | (f == CX24116_MODFEC_MODES[i].fec) ) | ||
403 | { | ||
404 | ret = i; | 423 | ret = i; |
405 | break; | 424 | break; |
406 | } | 425 | } |
@@ -409,7 +428,8 @@ static int cx24116_lookup_fecmod(struct cx24116_state* state, | |||
409 | return ret; | 428 | return ret; |
410 | } | 429 | } |
411 | 430 | ||
412 | static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_code_rate_t fec) | 431 | static int cx24116_set_fec(struct cx24116_state *state, |
432 | fe_modulation_t mod, fe_code_rate_t fec) | ||
413 | { | 433 | { |
414 | int ret = 0; | 434 | int ret = 0; |
415 | 435 | ||
@@ -417,7 +437,7 @@ static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_ | |||
417 | 437 | ||
418 | ret = cx24116_lookup_fecmod(state, mod, fec); | 438 | ret = cx24116_lookup_fecmod(state, mod, fec); |
419 | 439 | ||
420 | if(ret < 0) | 440 | if (ret < 0) |
421 | return ret; | 441 | return ret; |
422 | 442 | ||
423 | state->dnxt.fec = fec; | 443 | state->dnxt.fec = fec; |
@@ -429,7 +449,7 @@ static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_ | |||
429 | return 0; | 449 | return 0; |
430 | } | 450 | } |
431 | 451 | ||
432 | static int cx24116_set_symbolrate(struct cx24116_state* state, u32 rate) | 452 | static int cx24116_set_symbolrate(struct cx24116_state *state, u32 rate) |
433 | { | 453 | { |
434 | dprintk("%s(%d)\n", __func__, rate); | 454 | dprintk("%s(%d)\n", __func__, rate); |
435 | 455 | ||
@@ -446,42 +466,49 @@ static int cx24116_set_symbolrate(struct cx24116_state* state, u32 rate) | |||
446 | return 0; | 466 | return 0; |
447 | } | 467 | } |
448 | 468 | ||
449 | static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware *fw); | 469 | static int cx24116_load_firmware(struct dvb_frontend *fe, |
470 | const struct firmware *fw); | ||
450 | 471 | ||
451 | static int cx24116_firmware_ondemand(struct dvb_frontend* fe) | 472 | static int cx24116_firmware_ondemand(struct dvb_frontend *fe) |
452 | { | 473 | { |
453 | struct cx24116_state *state = fe->demodulator_priv; | 474 | struct cx24116_state *state = fe->demodulator_priv; |
454 | const struct firmware *fw; | 475 | const struct firmware *fw; |
455 | int ret = 0; | 476 | int ret = 0; |
456 | 477 | ||
457 | dprintk("%s()\n",__func__); | 478 | dprintk("%s()\n", __func__); |
458 | 479 | ||
459 | if (cx24116_readreg(state, 0x20) > 0) | 480 | if (cx24116_readreg(state, 0x20) > 0) { |
460 | { | ||
461 | 481 | ||
462 | if (state->skip_fw_load) | 482 | if (state->skip_fw_load) |
463 | return 0; | 483 | return 0; |
464 | 484 | ||
465 | /* Load firmware */ | 485 | /* Load firmware */ |
466 | /* request the firmware, this will block until someone uploads it */ | 486 | /* request the firmware, this will block until loaded */ |
467 | printk("%s: Waiting for firmware upload (%s)...\n", __func__, CX24116_DEFAULT_FIRMWARE); | 487 | printk(KERN_INFO "%s: Waiting for firmware upload (%s)...\n", |
468 | ret = request_firmware(&fw, CX24116_DEFAULT_FIRMWARE, &state->i2c->dev); | 488 | __func__, CX24116_DEFAULT_FIRMWARE); |
469 | printk("%s: Waiting for firmware upload(2)...\n", __func__); | 489 | ret = request_firmware(&fw, CX24116_DEFAULT_FIRMWARE, |
490 | &state->i2c->dev); | ||
491 | printk(KERN_INFO "%s: Waiting for firmware upload(2)...\n", | ||
492 | __func__); | ||
470 | if (ret) { | 493 | if (ret) { |
471 | printk("%s: No firmware uploaded (timeout or file not found?)\n", __func__); | 494 | printk(KERN_ERR "%s: No firmware uploaded " |
495 | "(timeout or file not found?)\n", __func__); | ||
472 | return ret; | 496 | return ret; |
473 | } | 497 | } |
474 | 498 | ||
475 | /* Make sure we don't recurse back through here during loading */ | 499 | /* Make sure we don't recurse back through here |
500 | * during loading */ | ||
476 | state->skip_fw_load = 1; | 501 | state->skip_fw_load = 1; |
477 | 502 | ||
478 | ret = cx24116_load_firmware(fe, fw); | 503 | ret = cx24116_load_firmware(fe, fw); |
479 | if (ret) | 504 | if (ret) |
480 | printk("%s: Writing firmware to device failed\n", __func__); | 505 | printk(KERN_ERR "%s: Writing firmware to device failed\n", |
506 | __func__); | ||
481 | 507 | ||
482 | release_firmware(fw); | 508 | release_firmware(fw); |
483 | 509 | ||
484 | printk("%s: Firmware upload %s\n", __func__, ret == 0 ? "complete" : "failed"); | 510 | printk(KERN_INFO "%s: Firmware upload %s\n", __func__, |
511 | ret == 0 ? "complete" : "failed"); | ||
485 | 512 | ||
486 | /* Ensure firmware is always loaded if required */ | 513 | /* Ensure firmware is always loaded if required */ |
487 | state->skip_fw_load = 0; | 514 | state->skip_fw_load = 0; |
@@ -490,8 +517,10 @@ static int cx24116_firmware_ondemand(struct dvb_frontend* fe) | |||
490 | return ret; | 517 | return ret; |
491 | } | 518 | } |
492 | 519 | ||
493 | /* Take a basic firmware command structure, format it and forward it for processing */ | 520 | /* Take a basic firmware command structure, format it |
494 | static int cx24116_cmd_execute(struct dvb_frontend* fe, struct cx24116_cmd *cmd) | 521 | * and forward it for processing |
522 | */ | ||
523 | static int cx24116_cmd_execute(struct dvb_frontend *fe, struct cx24116_cmd *cmd) | ||
495 | { | 524 | { |
496 | struct cx24116_state *state = fe->demodulator_priv; | 525 | struct cx24116_state *state = fe->demodulator_priv; |
497 | int i, ret; | 526 | int i, ret; |
@@ -499,49 +528,49 @@ static int cx24116_cmd_execute(struct dvb_frontend* fe, struct cx24116_cmd *cmd) | |||
499 | dprintk("%s()\n", __func__); | 528 | dprintk("%s()\n", __func__); |
500 | 529 | ||
501 | /* Load the firmware if required */ | 530 | /* Load the firmware if required */ |
502 | if ( (ret = cx24116_firmware_ondemand(fe)) != 0) | 531 | ret = cx24116_firmware_ondemand(fe); |
503 | { | 532 | if (ret != 0) { |
504 | printk("%s(): Unable initialise the firmware\n", __func__); | 533 | printk(KERN_ERR "%s(): Unable initialise the firmware\n", |
534 | __func__); | ||
505 | return ret; | 535 | return ret; |
506 | } | 536 | } |
507 | 537 | ||
508 | /* Write the command */ | 538 | /* Write the command */ |
509 | for(i = 0; i < cmd->len ; i++) | 539 | for (i = 0; i < cmd->len ; i++) { |
510 | { | ||
511 | dprintk("%s: 0x%02x == 0x%02x\n", __func__, i, cmd->args[i]); | 540 | dprintk("%s: 0x%02x == 0x%02x\n", __func__, i, cmd->args[i]); |
512 | cx24116_writereg(state, i, cmd->args[i]); | 541 | cx24116_writereg(state, i, cmd->args[i]); |
513 | } | 542 | } |
514 | 543 | ||
515 | /* Start execution and wait for cmd to terminate */ | 544 | /* Start execution and wait for cmd to terminate */ |
516 | cx24116_writereg(state, CX24116_REG_EXECUTE, 0x01); | 545 | cx24116_writereg(state, CX24116_REG_EXECUTE, 0x01); |
517 | while( cx24116_readreg(state, CX24116_REG_EXECUTE) ) | 546 | while (cx24116_readreg(state, CX24116_REG_EXECUTE)) { |
518 | { | ||
519 | msleep(10); | 547 | msleep(10); |
520 | if(i++ > 64) | 548 | if (i++ > 64) { |
521 | { | 549 | /* Avoid looping forever if the firmware does |
522 | /* Avoid looping forever if the firmware does no respond */ | 550 | not respond */ |
523 | printk("%s() Firmware not responding\n", __func__); | 551 | printk(KERN_WARNING "%s() Firmware not responding\n", |
552 | __func__); | ||
524 | return -EREMOTEIO; | 553 | return -EREMOTEIO; |
525 | } | 554 | } |
526 | } | 555 | } |
527 | return 0; | 556 | return 0; |
528 | } | 557 | } |
529 | 558 | ||
530 | static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware *fw) | 559 | static int cx24116_load_firmware(struct dvb_frontend *fe, |
560 | const struct firmware *fw) | ||
531 | { | 561 | { |
532 | struct cx24116_state* state = fe->demodulator_priv; | 562 | struct cx24116_state *state = fe->demodulator_priv; |
533 | struct cx24116_cmd cmd; | 563 | struct cx24116_cmd cmd; |
534 | int i, ret; | 564 | int i, ret; |
535 | unsigned char vers[4]; | 565 | unsigned char vers[4]; |
536 | 566 | ||
537 | dprintk("%s\n", __func__); | 567 | dprintk("%s\n", __func__); |
538 | dprintk("Firmware is %zu bytes (%02x %02x .. %02x %02x)\n" | 568 | dprintk("Firmware is %zu bytes (%02x %02x .. %02x %02x)\n", |
539 | ,fw->size | 569 | fw->size, |
540 | ,fw->data[0] | 570 | fw->data[0], |
541 | ,fw->data[1] | 571 | fw->data[1], |
542 | ,fw->data[ fw->size-2 ] | 572 | fw->data[fw->size-2], |
543 | ,fw->data[ fw->size-1 ] | 573 | fw->data[fw->size-1]); |
544 | ); | ||
545 | 574 | ||
546 | /* Toggle 88x SRST pin to reset demod */ | 575 | /* Toggle 88x SRST pin to reset demod */ |
547 | if (state->config->reset_device) | 576 | if (state->config->reset_device) |
@@ -587,7 +616,7 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware | |||
587 | cmd.args[0x07] = 0x9d; | 616 | cmd.args[0x07] = 0x9d; |
588 | cmd.args[0x08] = 0xfc; | 617 | cmd.args[0x08] = 0xfc; |
589 | cmd.args[0x09] = 0x06; | 618 | cmd.args[0x09] = 0x06; |
590 | cmd.len= 0x0a; | 619 | cmd.len = 0x0a; |
591 | ret = cx24116_cmd_execute(fe, &cmd); | 620 | ret = cx24116_cmd_execute(fe, &cmd); |
592 | if (ret != 0) | 621 | if (ret != 0) |
593 | return ret; | 622 | return ret; |
@@ -598,7 +627,7 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware | |||
598 | cmd.args[0x00] = CMD_TUNERINIT; | 627 | cmd.args[0x00] = CMD_TUNERINIT; |
599 | cmd.args[0x01] = 0x00; | 628 | cmd.args[0x01] = 0x00; |
600 | cmd.args[0x02] = 0x00; | 629 | cmd.args[0x02] = 0x00; |
601 | cmd.len= 0x03; | 630 | cmd.len = 0x03; |
602 | ret = cx24116_cmd_execute(fe, &cmd); | 631 | ret = cx24116_cmd_execute(fe, &cmd); |
603 | if (ret != 0) | 632 | if (ret != 0) |
604 | return ret; | 633 | return ret; |
@@ -615,36 +644,38 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware | |||
615 | else | 644 | else |
616 | cmd.args[0x04] = 0x02; | 645 | cmd.args[0x04] = 0x02; |
617 | cmd.args[0x05] = 0x00; | 646 | cmd.args[0x05] = 0x00; |
618 | cmd.len= 0x06; | 647 | cmd.len = 0x06; |
619 | ret = cx24116_cmd_execute(fe, &cmd); | 648 | ret = cx24116_cmd_execute(fe, &cmd); |
620 | if (ret != 0) | 649 | if (ret != 0) |
621 | return ret; | 650 | return ret; |
622 | 651 | ||
623 | /* Firmware CMD 35: Get firmware version */ | 652 | /* Firmware CMD 35: Get firmware version */ |
624 | cmd.args[0x00] = CMD_UPDFWVERS; | 653 | cmd.args[0x00] = CMD_UPDFWVERS; |
625 | cmd.len= 0x02; | 654 | cmd.len = 0x02; |
626 | for(i=0; i<4; i++) { | 655 | for (i = 0; i < 4; i++) { |
627 | cmd.args[0x01] = i; | 656 | cmd.args[0x01] = i; |
628 | ret = cx24116_cmd_execute(fe, &cmd); | 657 | ret = cx24116_cmd_execute(fe, &cmd); |
629 | if (ret != 0) | 658 | if (ret != 0) |
630 | return ret; | 659 | return ret; |
631 | vers[i]= cx24116_readreg(state, CX24116_REG_MAILBOX); | 660 | vers[i] = cx24116_readreg(state, CX24116_REG_MAILBOX); |
632 | } | 661 | } |
633 | printk("%s: FW version %i.%i.%i.%i\n", __func__, | 662 | printk(KERN_INFO "%s: FW version %i.%i.%i.%i\n", __func__, |
634 | vers[0], vers[1], vers[2], vers[3]); | 663 | vers[0], vers[1], vers[2], vers[3]); |
635 | 664 | ||
636 | return 0; | 665 | return 0; |
637 | } | 666 | } |
638 | 667 | ||
639 | static int cx24116_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) | 668 | static int cx24116_set_voltage(struct dvb_frontend *fe, |
669 | fe_sec_voltage_t voltage) | ||
640 | { | 670 | { |
641 | /* The isl6421 module will override this function in the fops. */ | 671 | /* The isl6421 module will override this function in the fops. */ |
642 | dprintk("%s() This should never appear if the isl6421 module is loaded correctly\n",__func__); | 672 | dprintk("%s() This should never appear if the isl6421 module " |
673 | "is loaded correctly\n", __func__); | ||
643 | 674 | ||
644 | return -EOPNOTSUPP; | 675 | return -EOPNOTSUPP; |
645 | } | 676 | } |
646 | 677 | ||
647 | static int cx24116_read_status(struct dvb_frontend* fe, fe_status_t* status) | 678 | static int cx24116_read_status(struct dvb_frontend *fe, fe_status_t *status) |
648 | { | 679 | { |
649 | struct cx24116_state *state = fe->demodulator_priv; | 680 | struct cx24116_state *state = fe->demodulator_priv; |
650 | 681 | ||
@@ -666,22 +697,23 @@ static int cx24116_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
666 | return 0; | 697 | return 0; |
667 | } | 698 | } |
668 | 699 | ||
669 | static int cx24116_read_ber(struct dvb_frontend* fe, u32* ber) | 700 | static int cx24116_read_ber(struct dvb_frontend *fe, u32 *ber) |
670 | { | 701 | { |
671 | struct cx24116_state *state = fe->demodulator_priv; | 702 | struct cx24116_state *state = fe->demodulator_priv; |
672 | 703 | ||
673 | dprintk("%s()\n", __func__); | 704 | dprintk("%s()\n", __func__); |
674 | 705 | ||
675 | *ber = ( cx24116_readreg(state, CX24116_REG_BER24) << 24 ) | | 706 | *ber = (cx24116_readreg(state, CX24116_REG_BER24) << 24) | |
676 | ( cx24116_readreg(state, CX24116_REG_BER16) << 16 ) | | 707 | (cx24116_readreg(state, CX24116_REG_BER16) << 16) | |
677 | ( cx24116_readreg(state, CX24116_REG_BER8 ) << 8 ) | | 708 | (cx24116_readreg(state, CX24116_REG_BER8) << 8) | |
678 | cx24116_readreg(state, CX24116_REG_BER0 ); | 709 | cx24116_readreg(state, CX24116_REG_BER0); |
679 | 710 | ||
680 | return 0; | 711 | return 0; |
681 | } | 712 | } |
682 | 713 | ||
683 | /* TODO Determine function and scale appropriately */ | 714 | /* TODO Determine function and scale appropriately */ |
684 | static int cx24116_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) | 715 | static int cx24116_read_signal_strength(struct dvb_frontend *fe, |
716 | u16 *signal_strength) | ||
685 | { | 717 | { |
686 | struct cx24116_state *state = fe->demodulator_priv; | 718 | struct cx24116_state *state = fe->demodulator_priv; |
687 | struct cx24116_cmd cmd; | 719 | struct cx24116_cmd cmd; |
@@ -692,39 +724,43 @@ static int cx24116_read_signal_strength(struct dvb_frontend* fe, u16* signal_str | |||
692 | 724 | ||
693 | /* Firmware CMD 19: Get AGC */ | 725 | /* Firmware CMD 19: Get AGC */ |
694 | cmd.args[0x00] = CMD_GETAGC; | 726 | cmd.args[0x00] = CMD_GETAGC; |
695 | cmd.len= 0x01; | 727 | cmd.len = 0x01; |
696 | ret = cx24116_cmd_execute(fe, &cmd); | 728 | ret = cx24116_cmd_execute(fe, &cmd); |
697 | if (ret != 0) | 729 | if (ret != 0) |
698 | return ret; | 730 | return ret; |
699 | 731 | ||
700 | sig_reading = ( cx24116_readreg(state, CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK ) | | 732 | sig_reading = |
701 | ( cx24116_readreg(state, CX24116_REG_SIGNAL) << 6 ); | 733 | (cx24116_readreg(state, |
702 | *signal_strength= 0 - sig_reading; | 734 | CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK) | |
735 | (cx24116_readreg(state, CX24116_REG_SIGNAL) << 6); | ||
736 | *signal_strength = 0 - sig_reading; | ||
703 | 737 | ||
704 | dprintk("%s: raw / cooked = 0x%04x / 0x%04x\n", __func__, sig_reading, *signal_strength); | 738 | dprintk("%s: raw / cooked = 0x%04x / 0x%04x\n", |
739 | __func__, sig_reading, *signal_strength); | ||
705 | 740 | ||
706 | return 0; | 741 | return 0; |
707 | } | 742 | } |
708 | 743 | ||
709 | /* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */ | 744 | /* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */ |
710 | static int cx24116_read_snr_pct(struct dvb_frontend* fe, u16* snr) | 745 | static int cx24116_read_snr_pct(struct dvb_frontend *fe, u16 *snr) |
711 | { | 746 | { |
712 | struct cx24116_state *state = fe->demodulator_priv; | 747 | struct cx24116_state *state = fe->demodulator_priv; |
713 | u8 snr_reading; | 748 | u8 snr_reading; |
714 | static const u32 snr_tab[] = { /* 10 x Table (rounded up) */ | 749 | static const u32 snr_tab[] = { /* 10 x Table (rounded up) */ |
715 | 0x00000,0x0199A,0x03333,0x04ccD,0x06667, | 750 | 0x00000, 0x0199A, 0x03333, 0x04ccD, 0x06667, |
716 | 0x08000,0x0999A,0x0b333,0x0cccD,0x0e667, | 751 | 0x08000, 0x0999A, 0x0b333, 0x0cccD, 0x0e667, |
717 | 0x10000,0x1199A,0x13333,0x14ccD,0x16667,0x18000 }; | 752 | 0x10000, 0x1199A, 0x13333, 0x14ccD, 0x16667, |
753 | 0x18000 }; | ||
718 | 754 | ||
719 | dprintk("%s()\n", __func__); | 755 | dprintk("%s()\n", __func__); |
720 | 756 | ||
721 | snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0); | 757 | snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0); |
722 | 758 | ||
723 | if(snr_reading >= 0xa0 /* 100% */) | 759 | if (snr_reading >= 0xa0 /* 100% */) |
724 | *snr = 0xffff; | 760 | *snr = 0xffff; |
725 | else | 761 | else |
726 | *snr = snr_tab [ ( snr_reading & 0xf0 ) >> 4 ] + | 762 | *snr = snr_tab[(snr_reading & 0xf0) >> 4] + |
727 | ( snr_tab [ ( snr_reading & 0x0f ) ] >> 4 ); | 763 | (snr_tab[(snr_reading & 0x0f)] >> 4); |
728 | 764 | ||
729 | dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__, | 765 | dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__, |
730 | snr_reading, *snr); | 766 | snr_reading, *snr); |
@@ -736,7 +772,7 @@ static int cx24116_read_snr_pct(struct dvb_frontend* fe, u16* snr) | |||
736 | * ESNO, from 0->30db (values 0->300). We provide this value by | 772 | * ESNO, from 0->30db (values 0->300). We provide this value by |
737 | * default. | 773 | * default. |
738 | */ | 774 | */ |
739 | static int cx24116_read_snr_esno(struct dvb_frontend* fe, u16* snr) | 775 | static int cx24116_read_snr_esno(struct dvb_frontend *fe, u16 *snr) |
740 | { | 776 | { |
741 | struct cx24116_state *state = fe->demodulator_priv; | 777 | struct cx24116_state *state = fe->demodulator_priv; |
742 | 778 | ||
@@ -750,7 +786,7 @@ static int cx24116_read_snr_esno(struct dvb_frontend* fe, u16* snr) | |||
750 | return 0; | 786 | return 0; |
751 | } | 787 | } |
752 | 788 | ||
753 | static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) | 789 | static int cx24116_read_snr(struct dvb_frontend *fe, u16 *snr) |
754 | { | 790 | { |
755 | if (esno_snr == 1) | 791 | if (esno_snr == 1) |
756 | return cx24116_read_snr_esno(fe, snr); | 792 | return cx24116_read_snr_esno(fe, snr); |
@@ -758,27 +794,27 @@ static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) | |||
758 | return cx24116_read_snr_pct(fe, snr); | 794 | return cx24116_read_snr_pct(fe, snr); |
759 | } | 795 | } |
760 | 796 | ||
761 | static int cx24116_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | 797 | static int cx24116_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) |
762 | { | 798 | { |
763 | struct cx24116_state *state = fe->demodulator_priv; | 799 | struct cx24116_state *state = fe->demodulator_priv; |
764 | 800 | ||
765 | dprintk("%s()\n", __func__); | 801 | dprintk("%s()\n", __func__); |
766 | 802 | ||
767 | *ucblocks = ( cx24116_readreg(state, CX24116_REG_UCB8) << 8 ) | | 803 | *ucblocks = (cx24116_readreg(state, CX24116_REG_UCB8) << 8) | |
768 | cx24116_readreg(state, CX24116_REG_UCB0); | 804 | cx24116_readreg(state, CX24116_REG_UCB0); |
769 | 805 | ||
770 | return 0; | 806 | return 0; |
771 | } | 807 | } |
772 | 808 | ||
773 | /* Overwrite the current tuning params, we are about to tune */ | 809 | /* Overwrite the current tuning params, we are about to tune */ |
774 | static void cx24116_clone_params(struct dvb_frontend* fe) | 810 | static void cx24116_clone_params(struct dvb_frontend *fe) |
775 | { | 811 | { |
776 | struct cx24116_state *state = fe->demodulator_priv; | 812 | struct cx24116_state *state = fe->demodulator_priv; |
777 | memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur)); | 813 | memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur)); |
778 | } | 814 | } |
779 | 815 | ||
780 | /* Wait for LNB */ | 816 | /* Wait for LNB */ |
781 | static int cx24116_wait_for_lnb(struct dvb_frontend* fe) | 817 | static int cx24116_wait_for_lnb(struct dvb_frontend *fe) |
782 | { | 818 | { |
783 | struct cx24116_state *state = fe->demodulator_priv; | 819 | struct cx24116_state *state = fe->demodulator_priv; |
784 | int i; | 820 | int i; |
@@ -787,7 +823,7 @@ static int cx24116_wait_for_lnb(struct dvb_frontend* fe) | |||
787 | cx24116_readreg(state, CX24116_REG_QSTATUS)); | 823 | cx24116_readreg(state, CX24116_REG_QSTATUS)); |
788 | 824 | ||
789 | /* Wait for up to 300 ms */ | 825 | /* Wait for up to 300 ms */ |
790 | for(i = 0; i < 30 ; i++) { | 826 | for (i = 0; i < 30 ; i++) { |
791 | if (cx24116_readreg(state, CX24116_REG_QSTATUS) & 0x20) | 827 | if (cx24116_readreg(state, CX24116_REG_QSTATUS) & 0x20) |
792 | return 0; | 828 | return 0; |
793 | msleep(10); | 829 | msleep(10); |
@@ -798,20 +834,21 @@ static int cx24116_wait_for_lnb(struct dvb_frontend* fe) | |||
798 | return -ETIMEDOUT; /* -EBUSY ? */ | 834 | return -ETIMEDOUT; /* -EBUSY ? */ |
799 | } | 835 | } |
800 | 836 | ||
801 | static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | 837 | static int cx24116_set_tone(struct dvb_frontend *fe, |
838 | fe_sec_tone_mode_t tone) | ||
802 | { | 839 | { |
803 | struct cx24116_cmd cmd; | 840 | struct cx24116_cmd cmd; |
804 | int ret; | 841 | int ret; |
805 | 842 | ||
806 | dprintk("%s(%d)\n", __func__, tone); | 843 | dprintk("%s(%d)\n", __func__, tone); |
807 | if ( (tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF) ) { | 844 | if ((tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF)) { |
808 | printk("%s: Invalid, tone=%d\n", __func__, tone); | 845 | printk(KERN_ERR "%s: Invalid, tone=%d\n", __func__, tone); |
809 | return -EINVAL; | 846 | return -EINVAL; |
810 | } | 847 | } |
811 | 848 | ||
812 | /* Wait for LNB ready */ | 849 | /* Wait for LNB ready */ |
813 | ret = cx24116_wait_for_lnb(fe); | 850 | ret = cx24116_wait_for_lnb(fe); |
814 | if(ret != 0) | 851 | if (ret != 0) |
815 | return ret; | 852 | return ret; |
816 | 853 | ||
817 | /* Min delay time after DiSEqC send */ | 854 | /* Min delay time after DiSEqC send */ |
@@ -820,7 +857,7 @@ static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
820 | /* This is always done before the tone is set */ | 857 | /* This is always done before the tone is set */ |
821 | cmd.args[0x00] = CMD_SET_TONEPRE; | 858 | cmd.args[0x00] = CMD_SET_TONEPRE; |
822 | cmd.args[0x01] = 0x00; | 859 | cmd.args[0x01] = 0x00; |
823 | cmd.len= 0x02; | 860 | cmd.len = 0x02; |
824 | ret = cx24116_cmd_execute(fe, &cmd); | 861 | ret = cx24116_cmd_execute(fe, &cmd); |
825 | if (ret != 0) | 862 | if (ret != 0) |
826 | return ret; | 863 | return ret; |
@@ -836,11 +873,11 @@ static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
836 | cmd.args[0x03] = 0x01; | 873 | cmd.args[0x03] = 0x01; |
837 | break; | 874 | break; |
838 | case SEC_TONE_OFF: | 875 | case SEC_TONE_OFF: |
839 | dprintk("%s: setting tone off\n",__func__); | 876 | dprintk("%s: setting tone off\n", __func__); |
840 | cmd.args[0x03] = 0x00; | 877 | cmd.args[0x03] = 0x00; |
841 | break; | 878 | break; |
842 | } | 879 | } |
843 | cmd.len= 0x04; | 880 | cmd.len = 0x04; |
844 | 881 | ||
845 | /* Min delay time before DiSEqC send */ | 882 | /* Min delay time before DiSEqC send */ |
846 | msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ | 883 | msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ |
@@ -849,7 +886,7 @@ static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
849 | } | 886 | } |
850 | 887 | ||
851 | /* Initialise DiSEqC */ | 888 | /* Initialise DiSEqC */ |
852 | static int cx24116_diseqc_init(struct dvb_frontend* fe) | 889 | static int cx24116_diseqc_init(struct dvb_frontend *fe) |
853 | { | 890 | { |
854 | struct cx24116_state *state = fe->demodulator_priv; | 891 | struct cx24116_state *state = fe->demodulator_priv; |
855 | struct cx24116_cmd cmd; | 892 | struct cx24116_cmd cmd; |
@@ -864,7 +901,7 @@ static int cx24116_diseqc_init(struct dvb_frontend* fe) | |||
864 | cmd.args[0x05] = 0x28; | 901 | cmd.args[0x05] = 0x28; |
865 | cmd.args[0x06] = (toneburst == CX24116_DISEQC_TONEOFF) ? 0x00 : 0x01; | 902 | cmd.args[0x06] = (toneburst == CX24116_DISEQC_TONEOFF) ? 0x00 : 0x01; |
866 | cmd.args[0x07] = 0x01; | 903 | cmd.args[0x07] = 0x01; |
867 | cmd.len= 0x08; | 904 | cmd.len = 0x08; |
868 | ret = cx24116_cmd_execute(fe, &cmd); | 905 | ret = cx24116_cmd_execute(fe, &cmd); |
869 | if (ret != 0) | 906 | if (ret != 0) |
870 | return ret; | 907 | return ret; |
@@ -878,36 +915,38 @@ static int cx24116_diseqc_init(struct dvb_frontend* fe) | |||
878 | /* Unknown */ | 915 | /* Unknown */ |
879 | state->dsec_cmd.args[CX24116_DISEQC_ARG2_2] = 0x02; | 916 | state->dsec_cmd.args[CX24116_DISEQC_ARG2_2] = 0x02; |
880 | state->dsec_cmd.args[CX24116_DISEQC_ARG3_0] = 0x00; | 917 | state->dsec_cmd.args[CX24116_DISEQC_ARG3_0] = 0x00; |
881 | state->dsec_cmd.args[CX24116_DISEQC_ARG4_0] = 0x00; /* Continuation flag? */ | 918 | /* Continuation flag? */ |
919 | state->dsec_cmd.args[CX24116_DISEQC_ARG4_0] = 0x00; | ||
882 | 920 | ||
883 | /* DiSEqC message length */ | 921 | /* DiSEqC message length */ |
884 | state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = 0x00; | 922 | state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = 0x00; |
885 | 923 | ||
886 | /* Command length */ | 924 | /* Command length */ |
887 | state->dsec_cmd.len= CX24116_DISEQC_MSGOFS; | 925 | state->dsec_cmd.len = CX24116_DISEQC_MSGOFS; |
888 | 926 | ||
889 | return 0; | 927 | return 0; |
890 | } | 928 | } |
891 | 929 | ||
892 | /* Send DiSEqC message with derived burst (hack) || previous burst */ | 930 | /* Send DiSEqC message with derived burst (hack) || previous burst */ |
893 | static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *d) | 931 | static int cx24116_send_diseqc_msg(struct dvb_frontend *fe, |
932 | struct dvb_diseqc_master_cmd *d) | ||
894 | { | 933 | { |
895 | struct cx24116_state *state = fe->demodulator_priv; | 934 | struct cx24116_state *state = fe->demodulator_priv; |
896 | int i, ret; | 935 | int i, ret; |
897 | 936 | ||
898 | /* Dump DiSEqC message */ | 937 | /* Dump DiSEqC message */ |
899 | if (debug) { | 938 | if (debug) { |
900 | printk("cx24116: %s(", __func__); | 939 | printk(KERN_INFO "cx24116: %s(", __func__); |
901 | for(i = 0 ; i < d->msg_len ;) { | 940 | for (i = 0 ; i < d->msg_len ;) { |
902 | printk("0x%02x", d->msg[i]); | 941 | printk(KERN_INFO "0x%02x", d->msg[i]); |
903 | if(++i < d->msg_len) | 942 | if (++i < d->msg_len) |
904 | printk(", "); | 943 | printk(KERN_INFO ", "); |
905 | } | 944 | } |
906 | printk(") toneburst=%d\n", toneburst); | 945 | printk(") toneburst=%d\n", toneburst); |
907 | } | 946 | } |
908 | 947 | ||
909 | /* Validate length */ | 948 | /* Validate length */ |
910 | if(d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) | 949 | if (d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) |
911 | return -EINVAL; | 950 | return -EINVAL; |
912 | 951 | ||
913 | /* DiSEqC message */ | 952 | /* DiSEqC message */ |
@@ -918,18 +957,19 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma | |||
918 | state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; | 957 | state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; |
919 | 958 | ||
920 | /* Command length */ | 959 | /* Command length */ |
921 | state->dsec_cmd.len= CX24116_DISEQC_MSGOFS + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; | 960 | state->dsec_cmd.len = CX24116_DISEQC_MSGOFS + |
961 | state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; | ||
922 | 962 | ||
923 | /* DiSEqC toneburst */ | 963 | /* DiSEqC toneburst */ |
924 | if(toneburst == CX24116_DISEQC_MESGCACHE) | 964 | if (toneburst == CX24116_DISEQC_MESGCACHE) |
925 | /* Message is cached */ | 965 | /* Message is cached */ |
926 | return 0; | 966 | return 0; |
927 | 967 | ||
928 | else if(toneburst == CX24116_DISEQC_TONEOFF) | 968 | else if (toneburst == CX24116_DISEQC_TONEOFF) |
929 | /* Message is sent without burst */ | 969 | /* Message is sent without burst */ |
930 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; | 970 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; |
931 | 971 | ||
932 | else if(toneburst == CX24116_DISEQC_TONECACHE) { | 972 | else if (toneburst == CX24116_DISEQC_TONECACHE) { |
933 | /* | 973 | /* |
934 | * Message is sent with derived else cached burst | 974 | * Message is sent with derived else cached burst |
935 | * | 975 | * |
@@ -948,15 +988,17 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma | |||
948 | * Y = VOLTAGE (0=13V, 1=18V) | 988 | * Y = VOLTAGE (0=13V, 1=18V) |
949 | * Z = BAND (0=LOW, 1=HIGH(22K)) | 989 | * Z = BAND (0=LOW, 1=HIGH(22K)) |
950 | */ | 990 | */ |
951 | if(d->msg_len >= 4 && d->msg[2] == 0x38) | 991 | if (d->msg_len >= 4 && d->msg[2] == 0x38) |
952 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = ((d->msg[3] & 4) >> 2); | 992 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = |
953 | if(debug) | 993 | ((d->msg[3] & 4) >> 2); |
954 | dprintk("%s burst=%d\n", __func__, state->dsec_cmd.args[CX24116_DISEQC_BURST]); | 994 | if (debug) |
995 | dprintk("%s burst=%d\n", __func__, | ||
996 | state->dsec_cmd.args[CX24116_DISEQC_BURST]); | ||
955 | } | 997 | } |
956 | 998 | ||
957 | /* Wait for LNB ready */ | 999 | /* Wait for LNB ready */ |
958 | ret = cx24116_wait_for_lnb(fe); | 1000 | ret = cx24116_wait_for_lnb(fe); |
959 | if(ret != 0) | 1001 | if (ret != 0) |
960 | return ret; | 1002 | return ret; |
961 | 1003 | ||
962 | /* Wait for voltage/min repeat delay */ | 1004 | /* Wait for voltage/min repeat delay */ |
@@ -964,7 +1006,7 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma | |||
964 | 1006 | ||
965 | /* Command */ | 1007 | /* Command */ |
966 | ret = cx24116_cmd_execute(fe, &state->dsec_cmd); | 1008 | ret = cx24116_cmd_execute(fe, &state->dsec_cmd); |
967 | if(ret != 0) | 1009 | if (ret != 0) |
968 | return ret; | 1010 | return ret; |
969 | /* | 1011 | /* |
970 | * Wait for send | 1012 | * Wait for send |
@@ -976,29 +1018,33 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma | |||
976 | * 12.5ms burst + | 1018 | * 12.5ms burst + |
977 | * >15ms delay (XXX determine if FW does this, see set_tone) | 1019 | * >15ms delay (XXX determine if FW does this, see set_tone) |
978 | */ | 1020 | */ |
979 | msleep( (state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60) ); | 1021 | msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + |
1022 | ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60)); | ||
980 | 1023 | ||
981 | return 0; | 1024 | return 0; |
982 | } | 1025 | } |
983 | 1026 | ||
984 | /* Send DiSEqC burst */ | 1027 | /* Send DiSEqC burst */ |
985 | static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) | 1028 | static int cx24116_diseqc_send_burst(struct dvb_frontend *fe, |
1029 | fe_sec_mini_cmd_t burst) | ||
986 | { | 1030 | { |
987 | struct cx24116_state *state = fe->demodulator_priv; | 1031 | struct cx24116_state *state = fe->demodulator_priv; |
988 | int ret; | 1032 | int ret; |
989 | 1033 | ||
990 | dprintk("%s(%d) toneburst=%d\n",__func__, burst, toneburst); | 1034 | dprintk("%s(%d) toneburst=%d\n", __func__, burst, toneburst); |
991 | 1035 | ||
992 | /* DiSEqC burst */ | 1036 | /* DiSEqC burst */ |
993 | if (burst == SEC_MINI_A) | 1037 | if (burst == SEC_MINI_A) |
994 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = CX24116_DISEQC_MINI_A; | 1038 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = |
995 | else if(burst == SEC_MINI_B) | 1039 | CX24116_DISEQC_MINI_A; |
996 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = CX24116_DISEQC_MINI_B; | 1040 | else if (burst == SEC_MINI_B) |
1041 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = | ||
1042 | CX24116_DISEQC_MINI_B; | ||
997 | else | 1043 | else |
998 | return -EINVAL; | 1044 | return -EINVAL; |
999 | 1045 | ||
1000 | /* DiSEqC toneburst */ | 1046 | /* DiSEqC toneburst */ |
1001 | if(toneburst != CX24116_DISEQC_MESGCACHE) | 1047 | if (toneburst != CX24116_DISEQC_MESGCACHE) |
1002 | /* Burst is cached */ | 1048 | /* Burst is cached */ |
1003 | return 0; | 1049 | return 0; |
1004 | 1050 | ||
@@ -1006,7 +1052,7 @@ static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t | |||
1006 | 1052 | ||
1007 | /* Wait for LNB ready */ | 1053 | /* Wait for LNB ready */ |
1008 | ret = cx24116_wait_for_lnb(fe); | 1054 | ret = cx24116_wait_for_lnb(fe); |
1009 | if(ret != 0) | 1055 | if (ret != 0) |
1010 | return ret; | 1056 | return ret; |
1011 | 1057 | ||
1012 | /* Wait for voltage/min repeat delay */ | 1058 | /* Wait for voltage/min repeat delay */ |
@@ -1014,7 +1060,7 @@ static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t | |||
1014 | 1060 | ||
1015 | /* Command */ | 1061 | /* Command */ |
1016 | ret = cx24116_cmd_execute(fe, &state->dsec_cmd); | 1062 | ret = cx24116_cmd_execute(fe, &state->dsec_cmd); |
1017 | if(ret != 0) | 1063 | if (ret != 0) |
1018 | return ret; | 1064 | return ret; |
1019 | 1065 | ||
1020 | /* | 1066 | /* |
@@ -1027,34 +1073,32 @@ static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t | |||
1027 | * 12.5ms burst + | 1073 | * 12.5ms burst + |
1028 | * >15ms delay (XXX determine if FW does this, see set_tone) | 1074 | * >15ms delay (XXX determine if FW does this, see set_tone) |
1029 | */ | 1075 | */ |
1030 | msleep( (state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60 ); | 1076 | msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60); |
1031 | 1077 | ||
1032 | return 0; | 1078 | return 0; |
1033 | } | 1079 | } |
1034 | 1080 | ||
1035 | static void cx24116_release(struct dvb_frontend* fe) | 1081 | static void cx24116_release(struct dvb_frontend *fe) |
1036 | { | 1082 | { |
1037 | struct cx24116_state* state = fe->demodulator_priv; | 1083 | struct cx24116_state *state = fe->demodulator_priv; |
1038 | dprintk("%s\n",__func__); | 1084 | dprintk("%s\n", __func__); |
1039 | kfree(state); | 1085 | kfree(state); |
1040 | } | 1086 | } |
1041 | 1087 | ||
1042 | static struct dvb_frontend_ops cx24116_ops; | 1088 | static struct dvb_frontend_ops cx24116_ops; |
1043 | 1089 | ||
1044 | struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, | 1090 | struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, |
1045 | struct i2c_adapter* i2c) | 1091 | struct i2c_adapter *i2c) |
1046 | { | 1092 | { |
1047 | struct cx24116_state* state = NULL; | 1093 | struct cx24116_state *state = NULL; |
1048 | int ret; | 1094 | int ret; |
1049 | 1095 | ||
1050 | dprintk("%s\n",__func__); | 1096 | dprintk("%s\n", __func__); |
1051 | 1097 | ||
1052 | /* allocate memory for the internal state */ | 1098 | /* allocate memory for the internal state */ |
1053 | state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL); | 1099 | state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL); |
1054 | if (state == NULL) { | 1100 | if (state == NULL) |
1055 | printk("Unable to kmalloc\n"); | ||
1056 | goto error1; | 1101 | goto error1; |
1057 | } | ||
1058 | 1102 | ||
1059 | /* setup the state */ | 1103 | /* setup the state */ |
1060 | memset(state, 0, sizeof(struct cx24116_state)); | 1104 | memset(state, 0, sizeof(struct cx24116_state)); |
@@ -1063,32 +1107,36 @@ struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, | |||
1063 | state->i2c = i2c; | 1107 | state->i2c = i2c; |
1064 | 1108 | ||
1065 | /* check if the demod is present */ | 1109 | /* check if the demod is present */ |
1066 | ret = (cx24116_readreg(state, 0xFF) << 8) | cx24116_readreg(state, 0xFE); | 1110 | ret = (cx24116_readreg(state, 0xFF) << 8) | |
1111 | cx24116_readreg(state, 0xFE); | ||
1067 | if (ret != 0x0501) { | 1112 | if (ret != 0x0501) { |
1068 | printk("Invalid probe, probably not a CX24116 device\n"); | 1113 | printk(KERN_INFO "Invalid probe, probably not a CX24116 device\n"); |
1069 | goto error2; | 1114 | goto error2; |
1070 | } | 1115 | } |
1071 | 1116 | ||
1072 | /* create dvb_frontend */ | 1117 | /* create dvb_frontend */ |
1073 | memcpy(&state->frontend.ops, &cx24116_ops, sizeof(struct dvb_frontend_ops)); | 1118 | memcpy(&state->frontend.ops, &cx24116_ops, |
1119 | sizeof(struct dvb_frontend_ops)); | ||
1074 | state->frontend.demodulator_priv = state; | 1120 | state->frontend.demodulator_priv = state; |
1075 | return &state->frontend; | 1121 | return &state->frontend; |
1076 | 1122 | ||
1077 | error2: kfree(state); | 1123 | error2: kfree(state); |
1078 | error1: return NULL; | 1124 | error1: return NULL; |
1079 | } | 1125 | } |
1126 | EXPORT_SYMBOL(cx24116_attach); | ||
1127 | |||
1080 | /* | 1128 | /* |
1081 | * Initialise or wake up device | 1129 | * Initialise or wake up device |
1082 | * | 1130 | * |
1083 | * Power config will reset and load initial firmware if required | 1131 | * Power config will reset and load initial firmware if required |
1084 | */ | 1132 | */ |
1085 | static int cx24116_initfe(struct dvb_frontend* fe) | 1133 | static int cx24116_initfe(struct dvb_frontend *fe) |
1086 | { | 1134 | { |
1087 | struct cx24116_state* state = fe->demodulator_priv; | 1135 | struct cx24116_state *state = fe->demodulator_priv; |
1088 | struct cx24116_cmd cmd; | 1136 | struct cx24116_cmd cmd; |
1089 | int ret; | 1137 | int ret; |
1090 | 1138 | ||
1091 | dprintk("%s()\n",__func__); | 1139 | dprintk("%s()\n", __func__); |
1092 | 1140 | ||
1093 | /* Power on */ | 1141 | /* Power on */ |
1094 | cx24116_writereg(state, 0xe0, 0); | 1142 | cx24116_writereg(state, 0xe0, 0); |
@@ -1098,9 +1146,9 @@ static int cx24116_initfe(struct dvb_frontend* fe) | |||
1098 | /* Firmware CMD 36: Power config */ | 1146 | /* Firmware CMD 36: Power config */ |
1099 | cmd.args[0x00] = CMD_TUNERSLEEP; | 1147 | cmd.args[0x00] = CMD_TUNERSLEEP; |
1100 | cmd.args[0x01] = 0; | 1148 | cmd.args[0x01] = 0; |
1101 | cmd.len= 0x02; | 1149 | cmd.len = 0x02; |
1102 | ret = cx24116_cmd_execute(fe, &cmd); | 1150 | ret = cx24116_cmd_execute(fe, &cmd); |
1103 | if(ret != 0) | 1151 | if (ret != 0) |
1104 | return ret; | 1152 | return ret; |
1105 | 1153 | ||
1106 | return cx24116_diseqc_init(fe); | 1154 | return cx24116_diseqc_init(fe); |
@@ -1109,20 +1157,20 @@ static int cx24116_initfe(struct dvb_frontend* fe) | |||
1109 | /* | 1157 | /* |
1110 | * Put device to sleep | 1158 | * Put device to sleep |
1111 | */ | 1159 | */ |
1112 | static int cx24116_sleep(struct dvb_frontend* fe) | 1160 | static int cx24116_sleep(struct dvb_frontend *fe) |
1113 | { | 1161 | { |
1114 | struct cx24116_state* state = fe->demodulator_priv; | 1162 | struct cx24116_state *state = fe->demodulator_priv; |
1115 | struct cx24116_cmd cmd; | 1163 | struct cx24116_cmd cmd; |
1116 | int ret; | 1164 | int ret; |
1117 | 1165 | ||
1118 | dprintk("%s()\n",__func__); | 1166 | dprintk("%s()\n", __func__); |
1119 | 1167 | ||
1120 | /* Firmware CMD 36: Power config */ | 1168 | /* Firmware CMD 36: Power config */ |
1121 | cmd.args[0x00] = CMD_TUNERSLEEP; | 1169 | cmd.args[0x00] = CMD_TUNERSLEEP; |
1122 | cmd.args[0x01] = 1; | 1170 | cmd.args[0x01] = 1; |
1123 | cmd.len= 0x02; | 1171 | cmd.len = 0x02; |
1124 | ret = cx24116_cmd_execute(fe, &cmd); | 1172 | ret = cx24116_cmd_execute(fe, &cmd); |
1125 | if(ret != 0) | 1173 | if (ret != 0) |
1126 | return ret; | 1174 | return ret; |
1127 | 1175 | ||
1128 | /* Power off (Shutdown clocks) */ | 1176 | /* Power off (Shutdown clocks) */ |
@@ -1133,13 +1181,15 @@ static int cx24116_sleep(struct dvb_frontend* fe) | |||
1133 | return 0; | 1181 | return 0; |
1134 | } | 1182 | } |
1135 | 1183 | ||
1136 | static int cx24116_set_property(struct dvb_frontend *fe, struct dtv_property* tvp) | 1184 | static int cx24116_set_property(struct dvb_frontend *fe, |
1185 | struct dtv_property *tvp) | ||
1137 | { | 1186 | { |
1138 | dprintk("%s(..)\n", __func__); | 1187 | dprintk("%s(..)\n", __func__); |
1139 | return 0; | 1188 | return 0; |
1140 | } | 1189 | } |
1141 | 1190 | ||
1142 | static int cx24116_get_property(struct dvb_frontend *fe, struct dtv_property* tvp) | 1191 | static int cx24116_get_property(struct dvb_frontend *fe, |
1192 | struct dtv_property *tvp) | ||
1143 | { | 1193 | { |
1144 | dprintk("%s(..)\n", __func__); | 1194 | dprintk("%s(..)\n", __func__); |
1145 | return 0; | 1195 | return 0; |
@@ -1148,7 +1198,8 @@ static int cx24116_get_property(struct dvb_frontend *fe, struct dtv_property* tv | |||
1148 | /* dvb-core told us to tune, the tv property cache will be complete, | 1198 | /* dvb-core told us to tune, the tv property cache will be complete, |
1149 | * it's safe for is to pull values and use them for tuning purposes. | 1199 | * it's safe for is to pull values and use them for tuning purposes. |
1150 | */ | 1200 | */ |
1151 | static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 1201 | static int cx24116_set_frontend(struct dvb_frontend *fe, |
1202 | struct dvb_frontend_parameters *p) | ||
1152 | { | 1203 | { |
1153 | struct cx24116_state *state = fe->demodulator_priv; | 1204 | struct cx24116_state *state = fe->demodulator_priv; |
1154 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 1205 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
@@ -1156,96 +1207,102 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
1156 | fe_status_t tunerstat; | 1207 | fe_status_t tunerstat; |
1157 | int i, status, ret, retune; | 1208 | int i, status, ret, retune; |
1158 | 1209 | ||
1159 | dprintk("%s()\n",__func__); | 1210 | dprintk("%s()\n", __func__); |
1160 | 1211 | ||
1161 | switch(c->delivery_system) { | 1212 | switch (c->delivery_system) { |
1162 | case SYS_DVBS: | 1213 | case SYS_DVBS: |
1163 | dprintk("%s: DVB-S delivery system selected\n",__func__); | 1214 | dprintk("%s: DVB-S delivery system selected\n", __func__); |
1164 | 1215 | ||
1165 | /* Only QPSK is supported for DVB-S */ | 1216 | /* Only QPSK is supported for DVB-S */ |
1166 | if(c->modulation != QPSK) { | 1217 | if (c->modulation != QPSK) { |
1167 | dprintk("%s: unsupported modulation selected (%d)\n", | 1218 | dprintk("%s: unsupported modulation selected (%d)\n", |
1168 | __func__, c->modulation); | 1219 | __func__, c->modulation); |
1169 | return -EOPNOTSUPP; | 1220 | return -EOPNOTSUPP; |
1170 | } | 1221 | } |
1171 | 1222 | ||
1172 | /* Pilot doesn't exist in DVB-S, turn bit off */ | 1223 | /* Pilot doesn't exist in DVB-S, turn bit off */ |
1173 | state->dnxt.pilot_val = CX24116_PILOT_OFF; | 1224 | state->dnxt.pilot_val = CX24116_PILOT_OFF; |
1174 | retune = 1; | 1225 | retune = 1; |
1175 | 1226 | ||
1176 | /* DVB-S only supports 0.35 */ | 1227 | /* DVB-S only supports 0.35 */ |
1177 | if(c->rolloff != ROLLOFF_35) { | 1228 | if (c->rolloff != ROLLOFF_35) { |
1178 | dprintk("%s: unsupported rolloff selected (%d)\n", | 1229 | dprintk("%s: unsupported rolloff selected (%d)\n", |
1179 | __func__, c->rolloff); | 1230 | __func__, c->rolloff); |
1180 | return -EOPNOTSUPP; | 1231 | return -EOPNOTSUPP; |
1181 | } | 1232 | } |
1182 | state->dnxt.rolloff_val = CX24116_ROLLOFF_035; | 1233 | state->dnxt.rolloff_val = CX24116_ROLLOFF_035; |
1183 | break; | 1234 | break; |
1184 | 1235 | ||
1185 | case SYS_DVBS2: | 1236 | case SYS_DVBS2: |
1186 | dprintk("%s: DVB-S2 delivery system selected\n",__func__); | 1237 | dprintk("%s: DVB-S2 delivery system selected\n", __func__); |
1187 | |||
1188 | /* | ||
1189 | * NBC 8PSK/QPSK with DVB-S is supported for DVB-S2, | ||
1190 | * but not hardware auto detection | ||
1191 | */ | ||
1192 | if(c->modulation != PSK_8 && c->modulation != QPSK) { | ||
1193 | dprintk("%s: unsupported modulation selected (%d)\n", | ||
1194 | __func__, c->modulation); | ||
1195 | return -EOPNOTSUPP; | ||
1196 | } | ||
1197 | 1238 | ||
1198 | switch(c->pilot) { | 1239 | /* |
1199 | case PILOT_AUTO: /* Not supported but emulated */ | 1240 | * NBC 8PSK/QPSK with DVB-S is supported for DVB-S2, |
1200 | retune = 2; /* Fall-through */ | 1241 | * but not hardware auto detection |
1201 | case PILOT_OFF: | 1242 | */ |
1202 | state->dnxt.pilot_val = CX24116_PILOT_OFF; | 1243 | if (c->modulation != PSK_8 && c->modulation != QPSK) { |
1203 | break; | 1244 | dprintk("%s: unsupported modulation selected (%d)\n", |
1204 | case PILOT_ON: | 1245 | __func__, c->modulation); |
1205 | state->dnxt.pilot_val = CX24116_PILOT_ON; | 1246 | return -EOPNOTSUPP; |
1206 | break; | 1247 | } |
1207 | default: | ||
1208 | dprintk("%s: unsupported pilot mode selected (%d)\n", | ||
1209 | __func__, c->pilot); | ||
1210 | return -EOPNOTSUPP; | ||
1211 | } | ||
1212 | 1248 | ||
1213 | switch(c->rolloff) { | 1249 | switch (c->pilot) { |
1214 | case ROLLOFF_20: | 1250 | case PILOT_AUTO: /* Not supported but emulated */ |
1215 | state->dnxt.rolloff_val= CX24116_ROLLOFF_020; | 1251 | state->dnxt.pilot_val = (c->modulation == QPSK) |
1216 | break; | 1252 | ? CX24116_PILOT_OFF : CX24116_PILOT_ON; |
1217 | case ROLLOFF_25: | 1253 | retune = 2; |
1218 | state->dnxt.rolloff_val= CX24116_ROLLOFF_025; | 1254 | break; |
1219 | break; | 1255 | case PILOT_OFF: |
1220 | case ROLLOFF_35: | 1256 | state->dnxt.pilot_val = CX24116_PILOT_OFF; |
1221 | state->dnxt.rolloff_val= CX24116_ROLLOFF_035; | 1257 | break; |
1222 | break; | 1258 | case PILOT_ON: |
1223 | case ROLLOFF_AUTO: /* Rolloff must be explicit */ | 1259 | state->dnxt.pilot_val = CX24116_PILOT_ON; |
1224 | default: | ||
1225 | dprintk("%s: unsupported rolloff selected (%d)\n", | ||
1226 | __func__, c->rolloff); | ||
1227 | return -EOPNOTSUPP; | ||
1228 | } | ||
1229 | break; | 1260 | break; |
1261 | default: | ||
1262 | dprintk("%s: unsupported pilot mode selected (%d)\n", | ||
1263 | __func__, c->pilot); | ||
1264 | return -EOPNOTSUPP; | ||
1265 | } | ||
1230 | 1266 | ||
1267 | switch (c->rolloff) { | ||
1268 | case ROLLOFF_20: | ||
1269 | state->dnxt.rolloff_val = CX24116_ROLLOFF_020; | ||
1270 | break; | ||
1271 | case ROLLOFF_25: | ||
1272 | state->dnxt.rolloff_val = CX24116_ROLLOFF_025; | ||
1273 | break; | ||
1274 | case ROLLOFF_35: | ||
1275 | state->dnxt.rolloff_val = CX24116_ROLLOFF_035; | ||
1276 | break; | ||
1277 | case ROLLOFF_AUTO: /* Rolloff must be explicit */ | ||
1231 | default: | 1278 | default: |
1232 | dprintk("%s: unsupported delivery system selected (%d)\n", | 1279 | dprintk("%s: unsupported rolloff selected (%d)\n", |
1233 | __func__, c->delivery_system); | 1280 | __func__, c->rolloff); |
1234 | return -EOPNOTSUPP; | 1281 | return -EOPNOTSUPP; |
1282 | } | ||
1283 | break; | ||
1284 | |||
1285 | default: | ||
1286 | dprintk("%s: unsupported delivery system selected (%d)\n", | ||
1287 | __func__, c->delivery_system); | ||
1288 | return -EOPNOTSUPP; | ||
1235 | } | 1289 | } |
1236 | state->dnxt.modulation = c->modulation; | 1290 | state->dnxt.modulation = c->modulation; |
1237 | state->dnxt.frequency = c->frequency; | 1291 | state->dnxt.frequency = c->frequency; |
1238 | state->dnxt.pilot = c->pilot; | 1292 | state->dnxt.pilot = c->pilot; |
1239 | state->dnxt.rolloff = c->rolloff; | 1293 | state->dnxt.rolloff = c->rolloff; |
1240 | 1294 | ||
1241 | if ((ret = cx24116_set_inversion(state, c->inversion)) != 0) | 1295 | ret = cx24116_set_inversion(state, c->inversion); |
1296 | if (ret != 0) | ||
1242 | return ret; | 1297 | return ret; |
1243 | 1298 | ||
1244 | /* FEC_NONE/AUTO for DVB-S2 is not supported and detected here */ | 1299 | /* FEC_NONE/AUTO for DVB-S2 is not supported and detected here */ |
1245 | if ((ret = cx24116_set_fec(state, c->modulation, c->fec_inner)) != 0) | 1300 | ret = cx24116_set_fec(state, c->modulation, c->fec_inner); |
1301 | if (ret != 0) | ||
1246 | return ret; | 1302 | return ret; |
1247 | 1303 | ||
1248 | if ((ret = cx24116_set_symbolrate(state, c->symbol_rate)) != 0) | 1304 | ret = cx24116_set_symbolrate(state, c->symbol_rate); |
1305 | if (ret != 0) | ||
1249 | return ret; | 1306 | return ret; |
1250 | 1307 | ||
1251 | /* discard the 'current' tuning parameters and prepare to tune */ | 1308 | /* discard the 'current' tuning parameters and prepare to tune */ |
@@ -1271,7 +1328,7 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
1271 | /* Set/Reset B/W */ | 1328 | /* Set/Reset B/W */ |
1272 | cmd.args[0x00] = CMD_BANDWIDTH; | 1329 | cmd.args[0x00] = CMD_BANDWIDTH; |
1273 | cmd.args[0x01] = 0x01; | 1330 | cmd.args[0x01] = 0x01; |
1274 | cmd.len= 0x02; | 1331 | cmd.len = 0x02; |
1275 | ret = cx24116_cmd_execute(fe, &cmd); | 1332 | ret = cx24116_cmd_execute(fe, &cmd); |
1276 | if (ret != 0) | 1333 | if (ret != 0) |
1277 | return ret; | 1334 | return ret; |
@@ -1319,7 +1376,7 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
1319 | cx24116_writereg(state, CX24116_REG_RATEDIV, 0x00); | 1376 | cx24116_writereg(state, CX24116_REG_RATEDIV, 0x00); |
1320 | } | 1377 | } |
1321 | 1378 | ||
1322 | cmd.len= 0x13; | 1379 | cmd.len = 0x13; |
1323 | 1380 | ||
1324 | /* We need to support pilot and non-pilot tuning in the | 1381 | /* We need to support pilot and non-pilot tuning in the |
1325 | * driver automatically. This is a workaround for because | 1382 | * driver automatically. This is a workaround for because |
@@ -1327,12 +1384,13 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
1327 | */ | 1384 | */ |
1328 | do { | 1385 | do { |
1329 | /* Reset status register */ | 1386 | /* Reset status register */ |
1330 | status = cx24116_readreg(state, CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK; | 1387 | status = cx24116_readreg(state, CX24116_REG_SSTATUS) |
1388 | & CX24116_SIGNAL_MASK; | ||
1331 | cx24116_writereg(state, CX24116_REG_SSTATUS, status); | 1389 | cx24116_writereg(state, CX24116_REG_SSTATUS, status); |
1332 | 1390 | ||
1333 | /* Tune */ | 1391 | /* Tune */ |
1334 | ret = cx24116_cmd_execute(fe, &cmd); | 1392 | ret = cx24116_cmd_execute(fe, &cmd); |
1335 | if( ret != 0 ) | 1393 | if (ret != 0) |
1336 | break; | 1394 | break; |
1337 | 1395 | ||
1338 | /* | 1396 | /* |
@@ -1341,28 +1399,27 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
1341 | * If we are able to tune then generally it occurs within 100ms. | 1399 | * If we are able to tune then generally it occurs within 100ms. |
1342 | * If it takes longer, try a different toneburst setting. | 1400 | * If it takes longer, try a different toneburst setting. |
1343 | */ | 1401 | */ |
1344 | for(i = 0; i < 50 ; i++) { | 1402 | for (i = 0; i < 50 ; i++) { |
1345 | cx24116_read_status(fe, &tunerstat); | 1403 | cx24116_read_status(fe, &tunerstat); |
1346 | status = tunerstat & (FE_HAS_SIGNAL | FE_HAS_SYNC); | 1404 | status = tunerstat & (FE_HAS_SIGNAL | FE_HAS_SYNC); |
1347 | if(status == (FE_HAS_SIGNAL | FE_HAS_SYNC)) { | 1405 | if (status == (FE_HAS_SIGNAL | FE_HAS_SYNC)) { |
1348 | dprintk("%s: Tuned\n",__func__); | 1406 | dprintk("%s: Tuned\n", __func__); |
1349 | goto tuned; | 1407 | goto tuned; |
1350 | } | 1408 | } |
1351 | msleep(10); | 1409 | msleep(10); |
1352 | } | 1410 | } |
1353 | 1411 | ||
1354 | dprintk("%s: Not tuned\n",__func__); | 1412 | dprintk("%s: Not tuned\n", __func__); |
1355 | 1413 | ||
1356 | /* Toggle pilot bit when in auto-pilot */ | 1414 | /* Toggle pilot bit when in auto-pilot */ |
1357 | if(state->dcur.pilot == PILOT_AUTO) | 1415 | if (state->dcur.pilot == PILOT_AUTO) |
1358 | cmd.args[0x07] ^= CX24116_PILOT_ON; | 1416 | cmd.args[0x07] ^= CX24116_PILOT_ON; |
1359 | } | 1417 | } while (--retune); |
1360 | while(--retune); | ||
1361 | 1418 | ||
1362 | tuned: /* Set/Reset B/W */ | 1419 | tuned: /* Set/Reset B/W */ |
1363 | cmd.args[0x00] = CMD_BANDWIDTH; | 1420 | cmd.args[0x00] = CMD_BANDWIDTH; |
1364 | cmd.args[0x01] = 0x00; | 1421 | cmd.args[0x01] = 0x00; |
1365 | cmd.len= 0x02; | 1422 | cmd.len = 0x02; |
1366 | ret = cx24116_cmd_execute(fe, &cmd); | 1423 | ret = cx24116_cmd_execute(fe, &cmd); |
1367 | if (ret != 0) | 1424 | if (ret != 0) |
1368 | return ret; | 1425 | return ret; |
@@ -1407,17 +1464,7 @@ static struct dvb_frontend_ops cx24116_ops = { | |||
1407 | .set_frontend = cx24116_set_frontend, | 1464 | .set_frontend = cx24116_set_frontend, |
1408 | }; | 1465 | }; |
1409 | 1466 | ||
1410 | module_param(debug, int, 0644); | ||
1411 | MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); | ||
1412 | |||
1413 | module_param(toneburst, int, 0644); | ||
1414 | MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, 2=MESSAGE CACHE (default:1)"); | ||
1415 | |||
1416 | module_param(esno_snr, int, 0644); | ||
1417 | MODULE_PARM_DESC(debug, "SNR return units, 0=PERCENTAGE 0-100, 1=ESNO(db * 10) (default:0)"); | ||
1418 | |||
1419 | MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); | 1467 | MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); |
1420 | MODULE_AUTHOR("Steven Toth"); | 1468 | MODULE_AUTHOR("Steven Toth"); |
1421 | MODULE_LICENSE("GPL"); | 1469 | MODULE_LICENSE("GPL"); |
1422 | 1470 | ||
1423 | EXPORT_SYMBOL(cx24116_attach); | ||
diff --git a/drivers/media/dvb/frontends/cx24116.h b/drivers/media/dvb/frontends/cx24116.h index 8dbcec268394..4cb3ddd6c626 100644 --- a/drivers/media/dvb/frontends/cx24116.h +++ b/drivers/media/dvb/frontends/cx24116.h | |||
@@ -23,31 +23,32 @@ | |||
23 | 23 | ||
24 | #include <linux/dvb/frontend.h> | 24 | #include <linux/dvb/frontend.h> |
25 | 25 | ||
26 | struct cx24116_config | 26 | struct cx24116_config { |
27 | { | ||
28 | /* the demodulator's i2c address */ | 27 | /* the demodulator's i2c address */ |
29 | u8 demod_address; | 28 | u8 demod_address; |
30 | 29 | ||
31 | /* Need to set device param for start_dma */ | 30 | /* Need to set device param for start_dma */ |
32 | int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); | 31 | int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured); |
33 | 32 | ||
34 | /* Need to reset device during firmware loading */ | 33 | /* Need to reset device during firmware loading */ |
35 | int (*reset_device)(struct dvb_frontend* fe); | 34 | int (*reset_device)(struct dvb_frontend *fe); |
36 | 35 | ||
37 | /* Need to set MPEG parameters */ | 36 | /* Need to set MPEG parameters */ |
38 | u8 mpg_clk_pos_pol:0x02; | 37 | u8 mpg_clk_pos_pol:0x02; |
39 | }; | 38 | }; |
40 | 39 | ||
41 | #if defined(CONFIG_DVB_CX24116) || defined(CONFIG_DVB_CX24116_MODULE) | 40 | #if defined(CONFIG_DVB_CX24116) || defined(CONFIG_DVB_CX24116_MODULE) |
42 | extern struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, | 41 | extern struct dvb_frontend *cx24116_attach( |
43 | struct i2c_adapter* i2c); | 42 | const struct cx24116_config *config, |
43 | struct i2c_adapter *i2c); | ||
44 | #else | 44 | #else |
45 | static inline struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, | 45 | static inline struct dvb_frontend *cx24116_attach( |
46 | struct i2c_adapter* i2c) | 46 | const struct cx24116_config *config, |
47 | struct i2c_adapter *i2c) | ||
47 | { | 48 | { |
48 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 49 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
49 | return NULL; | 50 | return NULL; |
50 | } | 51 | } |
51 | #endif // CONFIG_DVB_CX24116 | 52 | #endif |
52 | 53 | ||
53 | #endif /* CX24116_H */ | 54 | #endif /* CX24116_H */ |
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c index 7156157cb34b..1a8c36f76061 100644 --- a/drivers/media/dvb/frontends/cx24123.c +++ b/drivers/media/dvb/frontends/cx24123.c | |||
@@ -33,7 +33,13 @@ | |||
33 | #define XTAL 10111000 | 33 | #define XTAL 10111000 |
34 | 34 | ||
35 | static int force_band; | 35 | static int force_band; |
36 | module_param(force_band, int, 0644); | ||
37 | MODULE_PARM_DESC(force_band, "Force a specific band select "\ | ||
38 | "(1-9, default:off)."); | ||
39 | |||
36 | static int debug; | 40 | static int debug; |
41 | module_param(debug, int, 0644); | ||
42 | MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); | ||
37 | 43 | ||
38 | #define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0) | 44 | #define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0) |
39 | #define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0) | 45 | #define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0) |
@@ -46,10 +52,9 @@ static int debug; | |||
46 | } \ | 52 | } \ |
47 | } while (0) | 53 | } while (0) |
48 | 54 | ||
49 | struct cx24123_state | 55 | struct cx24123_state { |
50 | { | 56 | struct i2c_adapter *i2c; |
51 | struct i2c_adapter* i2c; | 57 | const struct cx24123_config *config; |
52 | const struct cx24123_config* config; | ||
53 | 58 | ||
54 | struct dvb_frontend frontend; | 59 | struct dvb_frontend frontend; |
55 | 60 | ||
@@ -70,8 +75,7 @@ struct cx24123_state | |||
70 | }; | 75 | }; |
71 | 76 | ||
72 | /* Various tuner defaults need to be established for a given symbol rate Sps */ | 77 | /* Various tuner defaults need to be established for a given symbol rate Sps */ |
73 | static struct | 78 | static struct cx24123_AGC_val { |
74 | { | ||
75 | u32 symbolrate_low; | 79 | u32 symbolrate_low; |
76 | u32 symbolrate_high; | 80 | u32 symbolrate_high; |
77 | u32 VCAprogdata; | 81 | u32 VCAprogdata; |
@@ -109,8 +113,7 @@ static struct | |||
109 | * fixme: The bounds on the bands do not match the doc in real life. | 113 | * fixme: The bounds on the bands do not match the doc in real life. |
110 | * fixme: Some of them have been moved, other might need adjustment. | 114 | * fixme: Some of them have been moved, other might need adjustment. |
111 | */ | 115 | */ |
112 | static struct | 116 | static struct cx24123_bandselect_val { |
113 | { | ||
114 | u32 freq_low; | 117 | u32 freq_low; |
115 | u32 freq_high; | 118 | u32 freq_high; |
116 | u32 VCOdivider; | 119 | u32 VCOdivider; |
@@ -249,7 +252,8 @@ static int cx24123_i2c_writereg(struct cx24123_state *state, | |||
249 | 252 | ||
250 | /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */ | 253 | /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */ |
251 | 254 | ||
252 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { | 255 | err = i2c_transfer(state->i2c, &msg, 1); |
256 | if (err != 1) { | ||
253 | printk("%s: writereg error(err == %i, reg == 0x%02x," | 257 | printk("%s: writereg error(err == %i, reg == 0x%02x," |
254 | " data == 0x%02x)\n", __func__, err, reg, data); | 258 | " data == 0x%02x)\n", __func__, err, reg, data); |
255 | return err; | 259 | return err; |
@@ -284,7 +288,8 @@ static int cx24123_i2c_readreg(struct cx24123_state *state, u8 i2c_addr, u8 reg) | |||
284 | #define cx24123_writereg(state, reg, val) \ | 288 | #define cx24123_writereg(state, reg, val) \ |
285 | cx24123_i2c_writereg(state, state->config->demod_address, reg, val) | 289 | cx24123_i2c_writereg(state, state->config->demod_address, reg, val) |
286 | 290 | ||
287 | static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) | 291 | static int cx24123_set_inversion(struct cx24123_state *state, |
292 | fe_spectral_inversion_t inversion) | ||
288 | { | 293 | { |
289 | u8 nom_reg = cx24123_readreg(state, 0x0e); | 294 | u8 nom_reg = cx24123_readreg(state, 0x0e); |
290 | u8 auto_reg = cx24123_readreg(state, 0x10); | 295 | u8 auto_reg = cx24123_readreg(state, 0x10); |
@@ -311,7 +316,8 @@ static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_invers | |||
311 | return 0; | 316 | return 0; |
312 | } | 317 | } |
313 | 318 | ||
314 | static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_inversion_t *inversion) | 319 | static int cx24123_get_inversion(struct cx24123_state *state, |
320 | fe_spectral_inversion_t *inversion) | ||
315 | { | 321 | { |
316 | u8 val; | 322 | u8 val; |
317 | 323 | ||
@@ -328,18 +334,20 @@ static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_invers | |||
328 | return 0; | 334 | return 0; |
329 | } | 335 | } |
330 | 336 | ||
331 | static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) | 337 | static int cx24123_set_fec(struct cx24123_state *state, fe_code_rate_t fec) |
332 | { | 338 | { |
333 | u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07; | 339 | u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07; |
334 | 340 | ||
335 | if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) | 341 | if ((fec < FEC_NONE) || (fec > FEC_AUTO)) |
336 | fec = FEC_AUTO; | 342 | fec = FEC_AUTO; |
337 | 343 | ||
338 | /* Set the soft decision threshold */ | 344 | /* Set the soft decision threshold */ |
339 | if(fec == FEC_1_2) | 345 | if (fec == FEC_1_2) |
340 | cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01); | 346 | cx24123_writereg(state, 0x43, |
347 | cx24123_readreg(state, 0x43) | 0x01); | ||
341 | else | 348 | else |
342 | cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01); | 349 | cx24123_writereg(state, 0x43, |
350 | cx24123_readreg(state, 0x43) & ~0x01); | ||
343 | 351 | ||
344 | switch (fec) { | 352 | switch (fec) { |
345 | case FEC_1_2: | 353 | case FEC_1_2: |
@@ -388,11 +396,11 @@ static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) | |||
388 | return 0; | 396 | return 0; |
389 | } | 397 | } |
390 | 398 | ||
391 | static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec) | 399 | static int cx24123_get_fec(struct cx24123_state *state, fe_code_rate_t *fec) |
392 | { | 400 | { |
393 | int ret; | 401 | int ret; |
394 | 402 | ||
395 | ret = cx24123_readreg (state, 0x1b); | 403 | ret = cx24123_readreg(state, 0x1b); |
396 | if (ret < 0) | 404 | if (ret < 0) |
397 | return ret; | 405 | return ret; |
398 | ret = ret & 0x07; | 406 | ret = ret & 0x07; |
@@ -433,16 +441,16 @@ static u32 cx24123_int_log2(u32 a, u32 b) | |||
433 | { | 441 | { |
434 | u32 exp, nearest = 0; | 442 | u32 exp, nearest = 0; |
435 | u32 div = a / b; | 443 | u32 div = a / b; |
436 | if(a % b >= b / 2) ++div; | 444 | if (a % b >= b / 2) |
437 | if(div < (1 << 31)) | 445 | ++div; |
438 | { | 446 | if (div < (1 << 31)) { |
439 | for(exp = 1; div > exp; nearest++) | 447 | for (exp = 1; div > exp; nearest++) |
440 | exp += exp; | 448 | exp += exp; |
441 | } | 449 | } |
442 | return nearest; | 450 | return nearest; |
443 | } | 451 | } |
444 | 452 | ||
445 | static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) | 453 | static int cx24123_set_symbolrate(struct cx24123_state *state, u32 srate) |
446 | { | 454 | { |
447 | u32 tmp, sample_rate, ratio, sample_gain; | 455 | u32 tmp, sample_rate, ratio, sample_gain; |
448 | u8 pll_mult; | 456 | u8 pll_mult; |
@@ -498,9 +506,9 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) | |||
498 | 506 | ||
499 | cx24123_writereg(state, 0x01, pll_mult * 6); | 507 | cx24123_writereg(state, 0x01, pll_mult * 6); |
500 | 508 | ||
501 | cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f ); | 509 | cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f); |
502 | cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff ); | 510 | cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff); |
503 | cx24123_writereg(state, 0x0a, (ratio ) & 0xff ); | 511 | cx24123_writereg(state, 0x0a, ratio & 0xff); |
504 | 512 | ||
505 | /* also set the demodulator sample gain */ | 513 | /* also set the demodulator sample gain */ |
506 | sample_gain = cx24123_int_log2(sample_rate, srate); | 514 | sample_gain = cx24123_int_log2(sample_rate, srate); |
@@ -514,10 +522,12 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) | |||
514 | } | 522 | } |
515 | 523 | ||
516 | /* | 524 | /* |
517 | * Based on the required frequency and symbolrate, the tuner AGC has to be configured | 525 | * Based on the required frequency and symbolrate, the tuner AGC has |
518 | * and the correct band selected. Calculate those values | 526 | * to be configured and the correct band selected. |
527 | * Calculate those values. | ||
519 | */ | 528 | */ |
520 | static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 529 | static int cx24123_pll_calculate(struct dvb_frontend *fe, |
530 | struct dvb_frontend_parameters *p) | ||
521 | { | 531 | { |
522 | struct cx24123_state *state = fe->demodulator_priv; | 532 | struct cx24123_state *state = fe->demodulator_priv; |
523 | u32 ndiv = 0, adiv = 0, vco_div = 0; | 533 | u32 ndiv = 0, adiv = 0, vco_div = 0; |
@@ -525,6 +535,8 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa | |||
525 | int pump = 2; | 535 | int pump = 2; |
526 | int band = 0; | 536 | int band = 0; |
527 | int num_bands = ARRAY_SIZE(cx24123_bandselect_vals); | 537 | int num_bands = ARRAY_SIZE(cx24123_bandselect_vals); |
538 | struct cx24123_bandselect_val *bsv = NULL; | ||
539 | struct cx24123_AGC_val *agcv = NULL; | ||
528 | 540 | ||
529 | /* Defaults for low freq, low rate */ | 541 | /* Defaults for low freq, low rate */ |
530 | state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; | 542 | state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; |
@@ -532,58 +544,65 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa | |||
532 | state->bandselectarg = cx24123_bandselect_vals[0].progdata; | 544 | state->bandselectarg = cx24123_bandselect_vals[0].progdata; |
533 | vco_div = cx24123_bandselect_vals[0].VCOdivider; | 545 | vco_div = cx24123_bandselect_vals[0].VCOdivider; |
534 | 546 | ||
535 | /* For the given symbol rate, determine the VCA, VGA and FILTUNE programming bits */ | 547 | /* For the given symbol rate, determine the VCA, VGA and |
536 | for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) | 548 | * FILTUNE programming bits */ |
537 | { | 549 | for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) { |
538 | if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) && | 550 | agcv = &cx24123_AGC_vals[i]; |
539 | (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) { | 551 | if ((agcv->symbolrate_low <= p->u.qpsk.symbol_rate) && |
540 | state->VCAarg = cx24123_AGC_vals[i].VCAprogdata; | 552 | (agcv->symbolrate_high >= p->u.qpsk.symbol_rate)) { |
541 | state->VGAarg = cx24123_AGC_vals[i].VGAprogdata; | 553 | state->VCAarg = agcv->VCAprogdata; |
542 | state->FILTune = cx24123_AGC_vals[i].FILTune; | 554 | state->VGAarg = agcv->VGAprogdata; |
555 | state->FILTune = agcv->FILTune; | ||
543 | } | 556 | } |
544 | } | 557 | } |
545 | 558 | ||
546 | /* determine the band to use */ | 559 | /* determine the band to use */ |
547 | if(force_band < 1 || force_band > num_bands) | 560 | if (force_band < 1 || force_band > num_bands) { |
548 | { | 561 | for (i = 0; i < num_bands; i++) { |
549 | for (i = 0; i < num_bands; i++) | 562 | bsv = &cx24123_bandselect_vals[i]; |
550 | { | 563 | if ((bsv->freq_low <= p->frequency) && |
551 | if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) && | 564 | (bsv->freq_high >= p->frequency)) |
552 | (cx24123_bandselect_vals[i].freq_high >= p->frequency) ) | ||
553 | band = i; | 565 | band = i; |
554 | } | 566 | } |
555 | } | 567 | } else |
556 | else | ||
557 | band = force_band - 1; | 568 | band = force_band - 1; |
558 | 569 | ||
559 | state->bandselectarg = cx24123_bandselect_vals[band].progdata; | 570 | state->bandselectarg = cx24123_bandselect_vals[band].progdata; |
560 | vco_div = cx24123_bandselect_vals[band].VCOdivider; | 571 | vco_div = cx24123_bandselect_vals[band].VCOdivider; |
561 | 572 | ||
562 | /* determine the charge pump current */ | 573 | /* determine the charge pump current */ |
563 | if ( p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high)/2 ) | 574 | if (p->frequency < (cx24123_bandselect_vals[band].freq_low + |
575 | cx24123_bandselect_vals[band].freq_high) / 2) | ||
564 | pump = 0x01; | 576 | pump = 0x01; |
565 | else | 577 | else |
566 | pump = 0x02; | 578 | pump = 0x02; |
567 | 579 | ||
568 | /* Determine the N/A dividers for the requested lband freq (in kHz). */ | 580 | /* Determine the N/A dividers for the requested lband freq (in kHz). */ |
569 | /* Note: the reference divider R=10, frequency is in KHz, XTAL is in Hz */ | 581 | /* Note: the reference divider R=10, frequency is in KHz, |
570 | ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff; | 582 | * XTAL is in Hz */ |
571 | adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f; | 583 | ndiv = (((p->frequency * vco_div * 10) / |
584 | (2 * XTAL / 1000)) / 32) & 0x1ff; | ||
585 | adiv = (((p->frequency * vco_div * 10) / | ||
586 | (2 * XTAL / 1000)) % 32) & 0x1f; | ||
572 | 587 | ||
573 | if (adiv == 0 && ndiv > 0) | 588 | if (adiv == 0 && ndiv > 0) |
574 | ndiv--; | 589 | ndiv--; |
575 | 590 | ||
576 | /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */ | 591 | /* control bits 11, refdiv 11, charge pump polarity 1, |
577 | state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv; | 592 | * charge pump current, ndiv, adiv */ |
593 | state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | | ||
594 | (pump << 14) | (ndiv << 5) | adiv; | ||
578 | 595 | ||
579 | return 0; | 596 | return 0; |
580 | } | 597 | } |
581 | 598 | ||
582 | /* | 599 | /* |
583 | * Tuner data is 21 bits long, must be left-aligned in data. | 600 | * Tuner data is 21 bits long, must be left-aligned in data. |
584 | * Tuner cx24109 is written through a dedicated 3wire interface on the demod chip. | 601 | * Tuner cx24109 is written through a dedicated 3wire interface |
602 | * on the demod chip. | ||
585 | */ | 603 | */ |
586 | static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data) | 604 | static int cx24123_pll_writereg(struct dvb_frontend *fe, |
605 | struct dvb_frontend_parameters *p, u32 data) | ||
587 | { | 606 | { |
588 | struct cx24123_state *state = fe->demodulator_priv; | 607 | struct cx24123_state *state = fe->demodulator_priv; |
589 | unsigned long timeout; | 608 | unsigned long timeout; |
@@ -610,7 +629,7 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par | |||
610 | 629 | ||
611 | /* send another 8 bytes, wait for the send to be completed */ | 630 | /* send another 8 bytes, wait for the send to be completed */ |
612 | timeout = jiffies + msecs_to_jiffies(40); | 631 | timeout = jiffies + msecs_to_jiffies(40); |
613 | cx24123_writereg(state, 0x22, (data>>8) & 0xff ); | 632 | cx24123_writereg(state, 0x22, (data >> 8) & 0xff); |
614 | while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { | 633 | while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { |
615 | if (time_after(jiffies, timeout)) { | 634 | if (time_after(jiffies, timeout)) { |
616 | err("%s: demodulator is not responding, "\ | 635 | err("%s: demodulator is not responding, "\ |
@@ -620,9 +639,10 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par | |||
620 | msleep(10); | 639 | msleep(10); |
621 | } | 640 | } |
622 | 641 | ||
623 | /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */ | 642 | /* send the lower 5 bits of this byte, padded with 3 LBB, |
643 | * wait for the send to be completed */ | ||
624 | timeout = jiffies + msecs_to_jiffies(40); | 644 | timeout = jiffies + msecs_to_jiffies(40); |
625 | cx24123_writereg(state, 0x22, (data) & 0xff ); | 645 | cx24123_writereg(state, 0x22, (data) & 0xff); |
626 | while ((cx24123_readreg(state, 0x20) & 0x80)) { | 646 | while ((cx24123_readreg(state, 0x20) & 0x80)) { |
627 | if (time_after(jiffies, timeout)) { | 647 | if (time_after(jiffies, timeout)) { |
628 | err("%s: demodulator is not responding," \ | 648 | err("%s: demodulator is not responding," \ |
@@ -639,7 +659,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par | |||
639 | return 0; | 659 | return 0; |
640 | } | 660 | } |
641 | 661 | ||
642 | static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 662 | static int cx24123_pll_tune(struct dvb_frontend *fe, |
663 | struct dvb_frontend_parameters *p) | ||
643 | { | 664 | { |
644 | struct cx24123_state *state = fe->demodulator_priv; | 665 | struct cx24123_state *state = fe->demodulator_priv; |
645 | u8 val; | 666 | u8 val; |
@@ -690,7 +711,7 @@ static int cx24123_repeater_mode(struct cx24123_state *state, u8 mode, u8 start) | |||
690 | return cx24123_writereg(state, 0x23, r); | 711 | return cx24123_writereg(state, 0x23, r); |
691 | } | 712 | } |
692 | 713 | ||
693 | static int cx24123_initfe(struct dvb_frontend* fe) | 714 | static int cx24123_initfe(struct dvb_frontend *fe) |
694 | { | 715 | { |
695 | struct cx24123_state *state = fe->demodulator_priv; | 716 | struct cx24123_state *state = fe->demodulator_priv; |
696 | int i; | 717 | int i; |
@@ -699,19 +720,22 @@ static int cx24123_initfe(struct dvb_frontend* fe) | |||
699 | 720 | ||
700 | /* Configure the demod to a good set of defaults */ | 721 | /* Configure the demod to a good set of defaults */ |
701 | for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) | 722 | for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) |
702 | cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); | 723 | cx24123_writereg(state, cx24123_regdata[i].reg, |
724 | cx24123_regdata[i].data); | ||
703 | 725 | ||
704 | /* Set the LNB polarity */ | 726 | /* Set the LNB polarity */ |
705 | if(state->config->lnb_polarity) | 727 | if (state->config->lnb_polarity) |
706 | cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); | 728 | cx24123_writereg(state, 0x32, |
729 | cx24123_readreg(state, 0x32) | 0x02); | ||
707 | 730 | ||
708 | if (state->config->dont_use_pll) | 731 | if (state->config->dont_use_pll) |
709 | cx24123_repeater_mode(state, 1, 0); | 732 | cx24123_repeater_mode(state, 1, 0); |
710 | 733 | ||
711 | return 0; | 734 | return 0; |
712 | } | 735 | } |
713 | 736 | ||
714 | static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) | 737 | static int cx24123_set_voltage(struct dvb_frontend *fe, |
738 | fe_sec_voltage_t voltage) | ||
715 | { | 739 | { |
716 | struct cx24123_state *state = fe->demodulator_priv; | 740 | struct cx24123_state *state = fe->demodulator_priv; |
717 | u8 val; | 741 | u8 val; |
@@ -740,7 +764,7 @@ static void cx24123_wait_for_diseqc(struct cx24123_state *state) | |||
740 | { | 764 | { |
741 | unsigned long timeout = jiffies + msecs_to_jiffies(200); | 765 | unsigned long timeout = jiffies + msecs_to_jiffies(200); |
742 | while (!(cx24123_readreg(state, 0x29) & 0x40)) { | 766 | while (!(cx24123_readreg(state, 0x29) & 0x40)) { |
743 | if(time_after(jiffies, timeout)) { | 767 | if (time_after(jiffies, timeout)) { |
744 | err("%s: diseqc queue not ready, " \ | 768 | err("%s: diseqc queue not ready, " \ |
745 | "command may be lost.\n", __func__); | 769 | "command may be lost.\n", __func__); |
746 | break; | 770 | break; |
@@ -749,7 +773,8 @@ static void cx24123_wait_for_diseqc(struct cx24123_state *state) | |||
749 | } | 773 | } |
750 | } | 774 | } |
751 | 775 | ||
752 | static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd) | 776 | static int cx24123_send_diseqc_msg(struct dvb_frontend *fe, |
777 | struct dvb_diseqc_master_cmd *cmd) | ||
753 | { | 778 | { |
754 | struct cx24123_state *state = fe->demodulator_priv; | 779 | struct cx24123_state *state = fe->demodulator_priv; |
755 | int i, val, tone; | 780 | int i, val, tone; |
@@ -771,20 +796,21 @@ static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma | |||
771 | cx24123_writereg(state, 0x2C + i, cmd->msg[i]); | 796 | cx24123_writereg(state, 0x2C + i, cmd->msg[i]); |
772 | 797 | ||
773 | val = cx24123_readreg(state, 0x29); | 798 | val = cx24123_readreg(state, 0x29); |
774 | cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); | 799 | cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | |
800 | ((cmd->msg_len-3) & 3)); | ||
775 | 801 | ||
776 | /* wait for diseqc message to finish sending */ | 802 | /* wait for diseqc message to finish sending */ |
777 | cx24123_wait_for_diseqc(state); | 803 | cx24123_wait_for_diseqc(state); |
778 | 804 | ||
779 | /* restart continuous tone if enabled */ | 805 | /* restart continuous tone if enabled */ |
780 | if (tone & 0x10) { | 806 | if (tone & 0x10) |
781 | cx24123_writereg(state, 0x29, tone & ~0x40); | 807 | cx24123_writereg(state, 0x29, tone & ~0x40); |
782 | } | ||
783 | 808 | ||
784 | return 0; | 809 | return 0; |
785 | } | 810 | } |
786 | 811 | ||
787 | static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) | 812 | static int cx24123_diseqc_send_burst(struct dvb_frontend *fe, |
813 | fe_sec_mini_cmd_t burst) | ||
788 | { | 814 | { |
789 | struct cx24123_state *state = fe->demodulator_priv; | 815 | struct cx24123_state *state = fe->demodulator_priv; |
790 | int val, tone; | 816 | int val, tone; |
@@ -814,13 +840,13 @@ static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t | |||
814 | cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb); | 840 | cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb); |
815 | 841 | ||
816 | /* restart continuous tone if enabled */ | 842 | /* restart continuous tone if enabled */ |
817 | if (tone & 0x10) { | 843 | if (tone & 0x10) |
818 | cx24123_writereg(state, 0x29, tone & ~0x40); | 844 | cx24123_writereg(state, 0x29, tone & ~0x40); |
819 | } | 845 | |
820 | return 0; | 846 | return 0; |
821 | } | 847 | } |
822 | 848 | ||
823 | static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) | 849 | static int cx24123_read_status(struct dvb_frontend *fe, fe_status_t *status) |
824 | { | 850 | { |
825 | struct cx24123_state *state = fe->demodulator_priv; | 851 | struct cx24123_state *state = fe->demodulator_priv; |
826 | int sync = cx24123_readreg(state, 0x14); | 852 | int sync = cx24123_readreg(state, 0x14); |
@@ -853,8 +879,9 @@ static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
853 | } | 879 | } |
854 | 880 | ||
855 | /* | 881 | /* |
856 | * Configured to return the measurement of errors in blocks, because no UCBLOCKS value | 882 | * Configured to return the measurement of errors in blocks, |
857 | * is available, so this value doubles up to satisfy both measurements | 883 | * because no UCBLOCKS value is available, so this value doubles up |
884 | * to satisfy both measurements. | ||
858 | */ | 885 | */ |
859 | static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber) | 886 | static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber) |
860 | { | 887 | { |
@@ -876,7 +903,8 @@ static int cx24123_read_signal_strength(struct dvb_frontend *fe, | |||
876 | { | 903 | { |
877 | struct cx24123_state *state = fe->demodulator_priv; | 904 | struct cx24123_state *state = fe->demodulator_priv; |
878 | 905 | ||
879 | *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ | 906 | /* larger = better */ |
907 | *signal_strength = cx24123_readreg(state, 0x3b) << 8; | ||
880 | 908 | ||
881 | dprintk("Signal strength = %d\n", *signal_strength); | 909 | dprintk("Signal strength = %d\n", *signal_strength); |
882 | 910 | ||
@@ -907,7 +935,7 @@ static int cx24123_set_frontend(struct dvb_frontend *fe, | |||
907 | if (state->config->set_ts_params) | 935 | if (state->config->set_ts_params) |
908 | state->config->set_ts_params(fe, 0); | 936 | state->config->set_ts_params(fe, 0); |
909 | 937 | ||
910 | state->currentfreq=p->frequency; | 938 | state->currentfreq = p->frequency; |
911 | state->currentsymbolrate = p->u.qpsk.symbol_rate; | 939 | state->currentsymbolrate = p->u.qpsk.symbol_rate; |
912 | 940 | ||
913 | cx24123_set_inversion(state, p->inversion); | 941 | cx24123_set_inversion(state, p->inversion); |
@@ -932,7 +960,8 @@ static int cx24123_set_frontend(struct dvb_frontend *fe, | |||
932 | return 0; | 960 | return 0; |
933 | } | 961 | } |
934 | 962 | ||
935 | static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 963 | static int cx24123_get_frontend(struct dvb_frontend *fe, |
964 | struct dvb_frontend_parameters *p) | ||
936 | { | 965 | { |
937 | struct cx24123_state *state = fe->demodulator_priv; | 966 | struct cx24123_state *state = fe->demodulator_priv; |
938 | 967 | ||
@@ -952,7 +981,7 @@ static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
952 | return 0; | 981 | return 0; |
953 | } | 982 | } |
954 | 983 | ||
955 | static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | 984 | static int cx24123_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) |
956 | { | 985 | { |
957 | struct cx24123_state *state = fe->demodulator_priv; | 986 | struct cx24123_state *state = fe->demodulator_priv; |
958 | u8 val; | 987 | u8 val; |
@@ -977,8 +1006,8 @@ static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
977 | return 0; | 1006 | return 0; |
978 | } | 1007 | } |
979 | 1008 | ||
980 | static int cx24123_tune(struct dvb_frontend* fe, | 1009 | static int cx24123_tune(struct dvb_frontend *fe, |
981 | struct dvb_frontend_parameters* params, | 1010 | struct dvb_frontend_parameters *params, |
982 | unsigned int mode_flags, | 1011 | unsigned int mode_flags, |
983 | unsigned int *delay, | 1012 | unsigned int *delay, |
984 | fe_status_t *status) | 1013 | fe_status_t *status) |
@@ -997,12 +1026,12 @@ static int cx24123_tune(struct dvb_frontend* fe, | |||
997 | 1026 | ||
998 | static int cx24123_get_algo(struct dvb_frontend *fe) | 1027 | static int cx24123_get_algo(struct dvb_frontend *fe) |
999 | { | 1028 | { |
1000 | return 1; //FE_ALGO_HW | 1029 | return 1; /* FE_ALGO_HW */ |
1001 | } | 1030 | } |
1002 | 1031 | ||
1003 | static void cx24123_release(struct dvb_frontend* fe) | 1032 | static void cx24123_release(struct dvb_frontend *fe) |
1004 | { | 1033 | { |
1005 | struct cx24123_state* state = fe->demodulator_priv; | 1034 | struct cx24123_state *state = fe->demodulator_priv; |
1006 | dprintk("\n"); | 1035 | dprintk("\n"); |
1007 | i2c_del_adapter(&state->tuner_i2c_adapter); | 1036 | i2c_del_adapter(&state->tuner_i2c_adapter); |
1008 | kfree(state); | 1037 | kfree(state); |
@@ -1013,7 +1042,7 @@ static int cx24123_tuner_i2c_tuner_xfer(struct i2c_adapter *i2c_adap, | |||
1013 | { | 1042 | { |
1014 | struct cx24123_state *state = i2c_get_adapdata(i2c_adap); | 1043 | struct cx24123_state *state = i2c_get_adapdata(i2c_adap); |
1015 | /* this repeater closes after the first stop */ | 1044 | /* this repeater closes after the first stop */ |
1016 | cx24123_repeater_mode(state, 1, 1); | 1045 | cx24123_repeater_mode(state, 1, 1); |
1017 | return i2c_transfer(state->i2c, msg, num); | 1046 | return i2c_transfer(state->i2c, msg, num); |
1018 | } | 1047 | } |
1019 | 1048 | ||
@@ -1037,8 +1066,8 @@ EXPORT_SYMBOL(cx24123_get_tuner_i2c_adapter); | |||
1037 | 1066 | ||
1038 | static struct dvb_frontend_ops cx24123_ops; | 1067 | static struct dvb_frontend_ops cx24123_ops; |
1039 | 1068 | ||
1040 | struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, | 1069 | struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, |
1041 | struct i2c_adapter* i2c) | 1070 | struct i2c_adapter *i2c) |
1042 | { | 1071 | { |
1043 | struct cx24123_state *state = | 1072 | struct cx24123_state *state = |
1044 | kzalloc(sizeof(struct cx24123_state), GFP_KERNEL); | 1073 | kzalloc(sizeof(struct cx24123_state), GFP_KERNEL); |
@@ -1057,20 +1086,25 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, | |||
1057 | /* check if the demod is there */ | 1086 | /* check if the demod is there */ |
1058 | state->demod_rev = cx24123_readreg(state, 0x00); | 1087 | state->demod_rev = cx24123_readreg(state, 0x00); |
1059 | switch (state->demod_rev) { | 1088 | switch (state->demod_rev) { |
1060 | case 0xe1: info("detected CX24123C\n"); break; | 1089 | case 0xe1: |
1061 | case 0xd1: info("detected CX24123\n"); break; | 1090 | info("detected CX24123C\n"); |
1091 | break; | ||
1092 | case 0xd1: | ||
1093 | info("detected CX24123\n"); | ||
1094 | break; | ||
1062 | default: | 1095 | default: |
1063 | err("wrong demod revision: %x\n", state->demod_rev); | 1096 | err("wrong demod revision: %x\n", state->demod_rev); |
1064 | goto error; | 1097 | goto error; |
1065 | } | 1098 | } |
1066 | 1099 | ||
1067 | /* create dvb_frontend */ | 1100 | /* create dvb_frontend */ |
1068 | memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); | 1101 | memcpy(&state->frontend.ops, &cx24123_ops, |
1102 | sizeof(struct dvb_frontend_ops)); | ||
1069 | state->frontend.demodulator_priv = state; | 1103 | state->frontend.demodulator_priv = state; |
1070 | 1104 | ||
1071 | /* create tuner i2c adapter */ | 1105 | /* create tuner i2c adapter */ |
1072 | if (config->dont_use_pll) | 1106 | if (config->dont_use_pll) |
1073 | cx24123_repeater_mode(state, 1, 0); | 1107 | cx24123_repeater_mode(state, 1, 0); |
1074 | 1108 | ||
1075 | strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus", | 1109 | strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus", |
1076 | sizeof(state->tuner_i2c_adapter.name)); | 1110 | sizeof(state->tuner_i2c_adapter.name)); |
@@ -1079,7 +1113,7 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, | |||
1079 | state->tuner_i2c_adapter.algo_data = NULL; | 1113 | state->tuner_i2c_adapter.algo_data = NULL; |
1080 | i2c_set_adapdata(&state->tuner_i2c_adapter, state); | 1114 | i2c_set_adapdata(&state->tuner_i2c_adapter, state); |
1081 | if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) { | 1115 | if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) { |
1082 | err("tuner i2c bus could not be initialized\n"); | 1116 | err("tuner i2c bus could not be initialized\n"); |
1083 | goto error; | 1117 | goto error; |
1084 | } | 1118 | } |
1085 | 1119 | ||
@@ -1090,6 +1124,7 @@ error: | |||
1090 | 1124 | ||
1091 | return NULL; | 1125 | return NULL; |
1092 | } | 1126 | } |
1127 | EXPORT_SYMBOL(cx24123_attach); | ||
1093 | 1128 | ||
1094 | static struct dvb_frontend_ops cx24123_ops = { | 1129 | static struct dvb_frontend_ops cx24123_ops = { |
1095 | 1130 | ||
@@ -1126,15 +1161,8 @@ static struct dvb_frontend_ops cx24123_ops = { | |||
1126 | .get_frontend_algo = cx24123_get_algo, | 1161 | .get_frontend_algo = cx24123_get_algo, |
1127 | }; | 1162 | }; |
1128 | 1163 | ||
1129 | module_param(debug, int, 0644); | ||
1130 | MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); | ||
1131 | |||
1132 | module_param(force_band, int, 0644); | ||
1133 | MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off)."); | ||
1134 | |||
1135 | MODULE_DESCRIPTION("DVB Frontend module for Conexant " \ | 1164 | MODULE_DESCRIPTION("DVB Frontend module for Conexant " \ |
1136 | "CX24123/CX24109/CX24113 hardware"); | 1165 | "CX24123/CX24109/CX24113 hardware"); |
1137 | MODULE_AUTHOR("Steven Toth"); | 1166 | MODULE_AUTHOR("Steven Toth"); |
1138 | MODULE_LICENSE("GPL"); | 1167 | MODULE_LICENSE("GPL"); |
1139 | 1168 | ||
1140 | EXPORT_SYMBOL(cx24123_attach); | ||
diff --git a/drivers/media/dvb/frontends/cx24123.h b/drivers/media/dvb/frontends/cx24123.h index cc6b411d6d20..51ae866e9fed 100644 --- a/drivers/media/dvb/frontends/cx24123.h +++ b/drivers/media/dvb/frontends/cx24123.h | |||
@@ -23,13 +23,12 @@ | |||
23 | 23 | ||
24 | #include <linux/dvb/frontend.h> | 24 | #include <linux/dvb/frontend.h> |
25 | 25 | ||
26 | struct cx24123_config | 26 | struct cx24123_config { |
27 | { | ||
28 | /* the demodulator's i2c address */ | 27 | /* the demodulator's i2c address */ |
29 | u8 demod_address; | 28 | u8 demod_address; |
30 | 29 | ||
31 | /* Need to set device param for start_dma */ | 30 | /* Need to set device param for start_dma */ |
32 | int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); | 31 | int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured); |
33 | 32 | ||
34 | /* 0 = LNB voltage normal, 1 = LNB voltage inverted */ | 33 | /* 0 = LNB voltage normal, 1 = LNB voltage inverted */ |
35 | int lnb_polarity; | 34 | int lnb_polarity; |
@@ -39,7 +38,8 @@ struct cx24123_config | |||
39 | void (*agc_callback) (struct dvb_frontend *); | 38 | void (*agc_callback) (struct dvb_frontend *); |
40 | }; | 39 | }; |
41 | 40 | ||
42 | #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE)) | 41 | #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) \ |
42 | && defined(MODULE)) | ||
43 | extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, | 43 | extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, |
44 | struct i2c_adapter *i2c); | 44 | struct i2c_adapter *i2c); |
45 | extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *); | 45 | extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *); |
@@ -56,6 +56,6 @@ static struct i2c_adapter * | |||
56 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 56 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
57 | return NULL; | 57 | return NULL; |
58 | } | 58 | } |
59 | #endif // CONFIG_DVB_CX24123 | 59 | #endif |
60 | 60 | ||
61 | #endif /* CX24123_H */ | 61 | #endif /* CX24123_H */ |
diff --git a/drivers/media/dvb/frontends/s5h1409.c b/drivers/media/dvb/frontends/s5h1409.c index 7500a1c53e68..cf4d8936bb83 100644 --- a/drivers/media/dvb/frontends/s5h1409.c +++ b/drivers/media/dvb/frontends/s5h1409.c | |||
@@ -30,10 +30,10 @@ | |||
30 | 30 | ||
31 | struct s5h1409_state { | 31 | struct s5h1409_state { |
32 | 32 | ||
33 | struct i2c_adapter* i2c; | 33 | struct i2c_adapter *i2c; |
34 | 34 | ||
35 | /* configuration settings */ | 35 | /* configuration settings */ |
36 | const struct s5h1409_config* config; | 36 | const struct s5h1409_config *config; |
37 | 37 | ||
38 | struct dvb_frontend frontend; | 38 | struct dvb_frontend frontend; |
39 | 39 | ||
@@ -48,6 +48,9 @@ struct s5h1409_state { | |||
48 | }; | 48 | }; |
49 | 49 | ||
50 | static int debug; | 50 | static int debug; |
51 | module_param(debug, int, 0644); | ||
52 | MODULE_PARM_DESC(debug, "Enable verbose debug messages"); | ||
53 | |||
51 | #define dprintk if (debug) printk | 54 | #define dprintk if (debug) printk |
52 | 55 | ||
53 | /* Register values to initialise the demod, this will set VSB by default */ | 56 | /* Register values to initialise the demod, this will set VSB by default */ |
@@ -299,10 +302,10 @@ static struct qam256_snr_tab { | |||
299 | }; | 302 | }; |
300 | 303 | ||
301 | /* 8 bit registers, 16 bit values */ | 304 | /* 8 bit registers, 16 bit values */ |
302 | static int s5h1409_writereg(struct s5h1409_state* state, u8 reg, u16 data) | 305 | static int s5h1409_writereg(struct s5h1409_state *state, u8 reg, u16 data) |
303 | { | 306 | { |
304 | int ret; | 307 | int ret; |
305 | u8 buf [] = { reg, data >> 8, data & 0xff }; | 308 | u8 buf[] = { reg, data >> 8, data & 0xff }; |
306 | 309 | ||
307 | struct i2c_msg msg = { .addr = state->config->demod_address, | 310 | struct i2c_msg msg = { .addr = state->config->demod_address, |
308 | .flags = 0, .buf = buf, .len = 3 }; | 311 | .flags = 0, .buf = buf, .len = 3 }; |
@@ -310,19 +313,19 @@ static int s5h1409_writereg(struct s5h1409_state* state, u8 reg, u16 data) | |||
310 | ret = i2c_transfer(state->i2c, &msg, 1); | 313 | ret = i2c_transfer(state->i2c, &msg, 1); |
311 | 314 | ||
312 | if (ret != 1) | 315 | if (ret != 1) |
313 | printk("%s: writereg error (reg == 0x%02x, val == 0x%04x, " | 316 | printk(KERN_ERR "%s: error (reg == 0x%02x, val == 0x%04x, " |
314 | "ret == %i)\n", __func__, reg, data, ret); | 317 | "ret == %i)\n", __func__, reg, data, ret); |
315 | 318 | ||
316 | return (ret != 1) ? -1 : 0; | 319 | return (ret != 1) ? -1 : 0; |
317 | } | 320 | } |
318 | 321 | ||
319 | static u16 s5h1409_readreg(struct s5h1409_state* state, u8 reg) | 322 | static u16 s5h1409_readreg(struct s5h1409_state *state, u8 reg) |
320 | { | 323 | { |
321 | int ret; | 324 | int ret; |
322 | u8 b0 [] = { reg }; | 325 | u8 b0[] = { reg }; |
323 | u8 b1 [] = { 0, 0 }; | 326 | u8 b1[] = { 0, 0 }; |
324 | 327 | ||
325 | struct i2c_msg msg [] = { | 328 | struct i2c_msg msg[] = { |
326 | { .addr = state->config->demod_address, .flags = 0, | 329 | { .addr = state->config->demod_address, .flags = 0, |
327 | .buf = b0, .len = 1 }, | 330 | .buf = b0, .len = 1 }, |
328 | { .addr = state->config->demod_address, .flags = I2C_M_RD, | 331 | { .addr = state->config->demod_address, .flags = I2C_M_RD, |
@@ -335,9 +338,9 @@ static u16 s5h1409_readreg(struct s5h1409_state* state, u8 reg) | |||
335 | return (b1[0] << 8) | b1[1]; | 338 | return (b1[0] << 8) | b1[1]; |
336 | } | 339 | } |
337 | 340 | ||
338 | static int s5h1409_softreset(struct dvb_frontend* fe) | 341 | static int s5h1409_softreset(struct dvb_frontend *fe) |
339 | { | 342 | { |
340 | struct s5h1409_state* state = fe->demodulator_priv; | 343 | struct s5h1409_state *state = fe->demodulator_priv; |
341 | 344 | ||
342 | dprintk("%s()\n", __func__); | 345 | dprintk("%s()\n", __func__); |
343 | 346 | ||
@@ -349,11 +352,11 @@ static int s5h1409_softreset(struct dvb_frontend* fe) | |||
349 | } | 352 | } |
350 | 353 | ||
351 | #define S5H1409_VSB_IF_FREQ 5380 | 354 | #define S5H1409_VSB_IF_FREQ 5380 |
352 | #define S5H1409_QAM_IF_FREQ state->config->qam_if | 355 | #define S5H1409_QAM_IF_FREQ (state->config->qam_if) |
353 | 356 | ||
354 | static int s5h1409_set_if_freq(struct dvb_frontend* fe, int KHz) | 357 | static int s5h1409_set_if_freq(struct dvb_frontend *fe, int KHz) |
355 | { | 358 | { |
356 | struct s5h1409_state* state = fe->demodulator_priv; | 359 | struct s5h1409_state *state = fe->demodulator_priv; |
357 | 360 | ||
358 | dprintk("%s(%d KHz)\n", __func__, KHz); | 361 | dprintk("%s(%d KHz)\n", __func__, KHz); |
359 | 362 | ||
@@ -376,26 +379,26 @@ static int s5h1409_set_if_freq(struct dvb_frontend* fe, int KHz) | |||
376 | return 0; | 379 | return 0; |
377 | } | 380 | } |
378 | 381 | ||
379 | static int s5h1409_set_spectralinversion(struct dvb_frontend* fe, int inverted) | 382 | static int s5h1409_set_spectralinversion(struct dvb_frontend *fe, int inverted) |
380 | { | 383 | { |
381 | struct s5h1409_state* state = fe->demodulator_priv; | 384 | struct s5h1409_state *state = fe->demodulator_priv; |
382 | 385 | ||
383 | dprintk("%s(%d)\n", __func__, inverted); | 386 | dprintk("%s(%d)\n", __func__, inverted); |
384 | 387 | ||
385 | if(inverted == 1) | 388 | if (inverted == 1) |
386 | return s5h1409_writereg(state, 0x1b, 0x1101); /* Inverted */ | 389 | return s5h1409_writereg(state, 0x1b, 0x1101); /* Inverted */ |
387 | else | 390 | else |
388 | return s5h1409_writereg(state, 0x1b, 0x0110); /* Normal */ | 391 | return s5h1409_writereg(state, 0x1b, 0x0110); /* Normal */ |
389 | } | 392 | } |
390 | 393 | ||
391 | static int s5h1409_enable_modulation(struct dvb_frontend* fe, | 394 | static int s5h1409_enable_modulation(struct dvb_frontend *fe, |
392 | fe_modulation_t m) | 395 | fe_modulation_t m) |
393 | { | 396 | { |
394 | struct s5h1409_state* state = fe->demodulator_priv; | 397 | struct s5h1409_state *state = fe->demodulator_priv; |
395 | 398 | ||
396 | dprintk("%s(0x%08x)\n", __func__, m); | 399 | dprintk("%s(0x%08x)\n", __func__, m); |
397 | 400 | ||
398 | switch(m) { | 401 | switch (m) { |
399 | case VSB_8: | 402 | case VSB_8: |
400 | dprintk("%s() VSB_8\n", __func__); | 403 | dprintk("%s() VSB_8\n", __func__); |
401 | if (state->if_freq != S5H1409_VSB_IF_FREQ) | 404 | if (state->if_freq != S5H1409_VSB_IF_FREQ) |
@@ -422,9 +425,9 @@ static int s5h1409_enable_modulation(struct dvb_frontend* fe, | |||
422 | return 0; | 425 | return 0; |
423 | } | 426 | } |
424 | 427 | ||
425 | static int s5h1409_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | 428 | static int s5h1409_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) |
426 | { | 429 | { |
427 | struct s5h1409_state* state = fe->demodulator_priv; | 430 | struct s5h1409_state *state = fe->demodulator_priv; |
428 | 431 | ||
429 | dprintk("%s(%d)\n", __func__, enable); | 432 | dprintk("%s(%d)\n", __func__, enable); |
430 | 433 | ||
@@ -434,9 +437,9 @@ static int s5h1409_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | |||
434 | return s5h1409_writereg(state, 0xf3, 0); | 437 | return s5h1409_writereg(state, 0xf3, 0); |
435 | } | 438 | } |
436 | 439 | ||
437 | static int s5h1409_set_gpio(struct dvb_frontend* fe, int enable) | 440 | static int s5h1409_set_gpio(struct dvb_frontend *fe, int enable) |
438 | { | 441 | { |
439 | struct s5h1409_state* state = fe->demodulator_priv; | 442 | struct s5h1409_state *state = fe->demodulator_priv; |
440 | 443 | ||
441 | dprintk("%s(%d)\n", __func__, enable); | 444 | dprintk("%s(%d)\n", __func__, enable); |
442 | 445 | ||
@@ -448,18 +451,18 @@ static int s5h1409_set_gpio(struct dvb_frontend* fe, int enable) | |||
448 | s5h1409_readreg(state, 0xe3) & 0xfeff); | 451 | s5h1409_readreg(state, 0xe3) & 0xfeff); |
449 | } | 452 | } |
450 | 453 | ||
451 | static int s5h1409_sleep(struct dvb_frontend* fe, int enable) | 454 | static int s5h1409_sleep(struct dvb_frontend *fe, int enable) |
452 | { | 455 | { |
453 | struct s5h1409_state* state = fe->demodulator_priv; | 456 | struct s5h1409_state *state = fe->demodulator_priv; |
454 | 457 | ||
455 | dprintk("%s(%d)\n", __func__, enable); | 458 | dprintk("%s(%d)\n", __func__, enable); |
456 | 459 | ||
457 | return s5h1409_writereg(state, 0xf2, enable); | 460 | return s5h1409_writereg(state, 0xf2, enable); |
458 | } | 461 | } |
459 | 462 | ||
460 | static int s5h1409_register_reset(struct dvb_frontend* fe) | 463 | static int s5h1409_register_reset(struct dvb_frontend *fe) |
461 | { | 464 | { |
462 | struct s5h1409_state* state = fe->demodulator_priv; | 465 | struct s5h1409_state *state = fe->demodulator_priv; |
463 | 466 | ||
464 | dprintk("%s()\n", __func__); | 467 | dprintk("%s()\n", __func__); |
465 | 468 | ||
@@ -483,7 +486,7 @@ static void s5h1409_set_qam_amhum_mode(struct dvb_frontend *fe) | |||
483 | reg &= 0xff; | 486 | reg &= 0xff; |
484 | 487 | ||
485 | s5h1409_writereg(state, 0x96, 0x00c); | 488 | s5h1409_writereg(state, 0x96, 0x00c); |
486 | if ((reg < 0x38) || (reg > 0x68) ) { | 489 | if ((reg < 0x38) || (reg > 0x68)) { |
487 | s5h1409_writereg(state, 0x93, 0x3332); | 490 | s5h1409_writereg(state, 0x93, 0x3332); |
488 | s5h1409_writereg(state, 0x9e, 0x2c37); | 491 | s5h1409_writereg(state, 0x9e, 0x2c37); |
489 | } else { | 492 | } else { |
@@ -514,7 +517,7 @@ static void s5h1409_set_qam_interleave_mode(struct dvb_frontend *fe) | |||
514 | 517 | ||
515 | s5h1409_writereg(state, 0x96, 0x20); | 518 | s5h1409_writereg(state, 0x96, 0x20); |
516 | s5h1409_writereg(state, 0xad, | 519 | s5h1409_writereg(state, 0xad, |
517 | ( ((reg1 & 0xf000) >> 4) | (reg2 & 0xf0ff)) ); | 520 | (((reg1 & 0xf000) >> 4) | (reg2 & 0xf0ff))); |
518 | s5h1409_writereg(state, 0xab, | 521 | s5h1409_writereg(state, 0xab, |
519 | s5h1409_readreg(state, 0xab) & 0xeffe); | 522 | s5h1409_readreg(state, 0xab) & 0xeffe); |
520 | } | 523 | } |
@@ -529,10 +532,10 @@ static void s5h1409_set_qam_interleave_mode(struct dvb_frontend *fe) | |||
529 | } | 532 | } |
530 | 533 | ||
531 | /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ | 534 | /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ |
532 | static int s5h1409_set_frontend (struct dvb_frontend* fe, | 535 | static int s5h1409_set_frontend(struct dvb_frontend *fe, |
533 | struct dvb_frontend_parameters *p) | 536 | struct dvb_frontend_parameters *p) |
534 | { | 537 | { |
535 | struct s5h1409_state* state = fe->demodulator_priv; | 538 | struct s5h1409_state *state = fe->demodulator_priv; |
536 | 539 | ||
537 | dprintk("%s(frequency=%d)\n", __func__, p->frequency); | 540 | dprintk("%s(frequency=%d)\n", __func__, p->frequency); |
538 | 541 | ||
@@ -546,9 +549,11 @@ static int s5h1409_set_frontend (struct dvb_frontend* fe, | |||
546 | msleep(100); | 549 | msleep(100); |
547 | 550 | ||
548 | if (fe->ops.tuner_ops.set_params) { | 551 | if (fe->ops.tuner_ops.set_params) { |
549 | if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); | 552 | if (fe->ops.i2c_gate_ctrl) |
553 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
550 | fe->ops.tuner_ops.set_params(fe, p); | 554 | fe->ops.tuner_ops.set_params(fe, p); |
551 | if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); | 555 | if (fe->ops.i2c_gate_ctrl) |
556 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
552 | } | 557 | } |
553 | 558 | ||
554 | /* Optimize the demod for QAM */ | 559 | /* Optimize the demod for QAM */ |
@@ -592,17 +597,17 @@ static int s5h1409_set_mpeg_timing(struct dvb_frontend *fe, int mode) | |||
592 | 597 | ||
593 | /* Reset the demod hardware and reset all of the configuration registers | 598 | /* Reset the demod hardware and reset all of the configuration registers |
594 | to a default state. */ | 599 | to a default state. */ |
595 | static int s5h1409_init (struct dvb_frontend* fe) | 600 | static int s5h1409_init(struct dvb_frontend *fe) |
596 | { | 601 | { |
597 | int i; | 602 | int i; |
598 | 603 | ||
599 | struct s5h1409_state* state = fe->demodulator_priv; | 604 | struct s5h1409_state *state = fe->demodulator_priv; |
600 | dprintk("%s()\n", __func__); | 605 | dprintk("%s()\n", __func__); |
601 | 606 | ||
602 | s5h1409_sleep(fe, 0); | 607 | s5h1409_sleep(fe, 0); |
603 | s5h1409_register_reset(fe); | 608 | s5h1409_register_reset(fe); |
604 | 609 | ||
605 | for (i=0; i < ARRAY_SIZE(init_tab); i++) | 610 | for (i = 0; i < ARRAY_SIZE(init_tab); i++) |
606 | s5h1409_writereg(state, init_tab[i].reg, init_tab[i].data); | 611 | s5h1409_writereg(state, init_tab[i].reg, init_tab[i].data); |
607 | 612 | ||
608 | /* The datasheet says that after initialisation, VSB is default */ | 613 | /* The datasheet says that after initialisation, VSB is default */ |
@@ -627,9 +632,9 @@ static int s5h1409_init (struct dvb_frontend* fe) | |||
627 | return 0; | 632 | return 0; |
628 | } | 633 | } |
629 | 634 | ||
630 | static int s5h1409_read_status(struct dvb_frontend* fe, fe_status_t* status) | 635 | static int s5h1409_read_status(struct dvb_frontend *fe, fe_status_t *status) |
631 | { | 636 | { |
632 | struct s5h1409_state* state = fe->demodulator_priv; | 637 | struct s5h1409_state *state = fe->demodulator_priv; |
633 | u16 reg; | 638 | u16 reg; |
634 | u32 tuner_status = 0; | 639 | u32 tuner_status = 0; |
635 | 640 | ||
@@ -637,12 +642,12 @@ static int s5h1409_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
637 | 642 | ||
638 | /* Get the demodulator status */ | 643 | /* Get the demodulator status */ |
639 | reg = s5h1409_readreg(state, 0xf1); | 644 | reg = s5h1409_readreg(state, 0xf1); |
640 | if(reg & 0x1000) | 645 | if (reg & 0x1000) |
641 | *status |= FE_HAS_VITERBI; | 646 | *status |= FE_HAS_VITERBI; |
642 | if(reg & 0x8000) | 647 | if (reg & 0x8000) |
643 | *status |= FE_HAS_LOCK | FE_HAS_SYNC; | 648 | *status |= FE_HAS_LOCK | FE_HAS_SYNC; |
644 | 649 | ||
645 | switch(state->config->status_mode) { | 650 | switch (state->config->status_mode) { |
646 | case S5H1409_DEMODLOCKING: | 651 | case S5H1409_DEMODLOCKING: |
647 | if (*status & FE_HAS_VITERBI) | 652 | if (*status & FE_HAS_VITERBI) |
648 | *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; | 653 | *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; |
@@ -668,12 +673,12 @@ static int s5h1409_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
668 | return 0; | 673 | return 0; |
669 | } | 674 | } |
670 | 675 | ||
671 | static int s5h1409_qam256_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | 676 | static int s5h1409_qam256_lookup_snr(struct dvb_frontend *fe, u16 *snr, u16 v) |
672 | { | 677 | { |
673 | int i, ret = -EINVAL; | 678 | int i, ret = -EINVAL; |
674 | dprintk("%s()\n", __func__); | 679 | dprintk("%s()\n", __func__); |
675 | 680 | ||
676 | for (i=0; i < ARRAY_SIZE(qam256_snr_tab); i++) { | 681 | for (i = 0; i < ARRAY_SIZE(qam256_snr_tab); i++) { |
677 | if (v < qam256_snr_tab[i].val) { | 682 | if (v < qam256_snr_tab[i].val) { |
678 | *snr = qam256_snr_tab[i].data; | 683 | *snr = qam256_snr_tab[i].data; |
679 | ret = 0; | 684 | ret = 0; |
@@ -683,12 +688,12 @@ static int s5h1409_qam256_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | |||
683 | return ret; | 688 | return ret; |
684 | } | 689 | } |
685 | 690 | ||
686 | static int s5h1409_qam64_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | 691 | static int s5h1409_qam64_lookup_snr(struct dvb_frontend *fe, u16 *snr, u16 v) |
687 | { | 692 | { |
688 | int i, ret = -EINVAL; | 693 | int i, ret = -EINVAL; |
689 | dprintk("%s()\n", __func__); | 694 | dprintk("%s()\n", __func__); |
690 | 695 | ||
691 | for (i=0; i < ARRAY_SIZE(qam64_snr_tab); i++) { | 696 | for (i = 0; i < ARRAY_SIZE(qam64_snr_tab); i++) { |
692 | if (v < qam64_snr_tab[i].val) { | 697 | if (v < qam64_snr_tab[i].val) { |
693 | *snr = qam64_snr_tab[i].data; | 698 | *snr = qam64_snr_tab[i].data; |
694 | ret = 0; | 699 | ret = 0; |
@@ -698,12 +703,12 @@ static int s5h1409_qam64_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | |||
698 | return ret; | 703 | return ret; |
699 | } | 704 | } |
700 | 705 | ||
701 | static int s5h1409_vsb_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | 706 | static int s5h1409_vsb_lookup_snr(struct dvb_frontend *fe, u16 *snr, u16 v) |
702 | { | 707 | { |
703 | int i, ret = -EINVAL; | 708 | int i, ret = -EINVAL; |
704 | dprintk("%s()\n", __func__); | 709 | dprintk("%s()\n", __func__); |
705 | 710 | ||
706 | for (i=0; i < ARRAY_SIZE(vsb_snr_tab); i++) { | 711 | for (i = 0; i < ARRAY_SIZE(vsb_snr_tab); i++) { |
707 | if (v > vsb_snr_tab[i].val) { | 712 | if (v > vsb_snr_tab[i].val) { |
708 | *snr = vsb_snr_tab[i].data; | 713 | *snr = vsb_snr_tab[i].data; |
709 | ret = 0; | 714 | ret = 0; |
@@ -714,13 +719,13 @@ static int s5h1409_vsb_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | |||
714 | return ret; | 719 | return ret; |
715 | } | 720 | } |
716 | 721 | ||
717 | static int s5h1409_read_snr(struct dvb_frontend* fe, u16* snr) | 722 | static int s5h1409_read_snr(struct dvb_frontend *fe, u16 *snr) |
718 | { | 723 | { |
719 | struct s5h1409_state* state = fe->demodulator_priv; | 724 | struct s5h1409_state *state = fe->demodulator_priv; |
720 | u16 reg; | 725 | u16 reg; |
721 | dprintk("%s()\n", __func__); | 726 | dprintk("%s()\n", __func__); |
722 | 727 | ||
723 | switch(state->current_modulation) { | 728 | switch (state->current_modulation) { |
724 | case QAM_64: | 729 | case QAM_64: |
725 | reg = s5h1409_readreg(state, 0xf0) & 0xff; | 730 | reg = s5h1409_readreg(state, 0xf0) & 0xff; |
726 | return s5h1409_qam64_lookup_snr(fe, snr, reg); | 731 | return s5h1409_qam64_lookup_snr(fe, snr, reg); |
@@ -737,30 +742,30 @@ static int s5h1409_read_snr(struct dvb_frontend* fe, u16* snr) | |||
737 | return -EINVAL; | 742 | return -EINVAL; |
738 | } | 743 | } |
739 | 744 | ||
740 | static int s5h1409_read_signal_strength(struct dvb_frontend* fe, | 745 | static int s5h1409_read_signal_strength(struct dvb_frontend *fe, |
741 | u16* signal_strength) | 746 | u16 *signal_strength) |
742 | { | 747 | { |
743 | return s5h1409_read_snr(fe, signal_strength); | 748 | return s5h1409_read_snr(fe, signal_strength); |
744 | } | 749 | } |
745 | 750 | ||
746 | static int s5h1409_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | 751 | static int s5h1409_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) |
747 | { | 752 | { |
748 | struct s5h1409_state* state = fe->demodulator_priv; | 753 | struct s5h1409_state *state = fe->demodulator_priv; |
749 | 754 | ||
750 | *ucblocks = s5h1409_readreg(state, 0xb5); | 755 | *ucblocks = s5h1409_readreg(state, 0xb5); |
751 | 756 | ||
752 | return 0; | 757 | return 0; |
753 | } | 758 | } |
754 | 759 | ||
755 | static int s5h1409_read_ber(struct dvb_frontend* fe, u32* ber) | 760 | static int s5h1409_read_ber(struct dvb_frontend *fe, u32 *ber) |
756 | { | 761 | { |
757 | return s5h1409_read_ucblocks(fe, ber); | 762 | return s5h1409_read_ucblocks(fe, ber); |
758 | } | 763 | } |
759 | 764 | ||
760 | static int s5h1409_get_frontend(struct dvb_frontend* fe, | 765 | static int s5h1409_get_frontend(struct dvb_frontend *fe, |
761 | struct dvb_frontend_parameters *p) | 766 | struct dvb_frontend_parameters *p) |
762 | { | 767 | { |
763 | struct s5h1409_state* state = fe->demodulator_priv; | 768 | struct s5h1409_state *state = fe->demodulator_priv; |
764 | 769 | ||
765 | p->frequency = state->current_frequency; | 770 | p->frequency = state->current_frequency; |
766 | p->u.vsb.modulation = state->current_modulation; | 771 | p->u.vsb.modulation = state->current_modulation; |
@@ -768,25 +773,25 @@ static int s5h1409_get_frontend(struct dvb_frontend* fe, | |||
768 | return 0; | 773 | return 0; |
769 | } | 774 | } |
770 | 775 | ||
771 | static int s5h1409_get_tune_settings(struct dvb_frontend* fe, | 776 | static int s5h1409_get_tune_settings(struct dvb_frontend *fe, |
772 | struct dvb_frontend_tune_settings *tune) | 777 | struct dvb_frontend_tune_settings *tune) |
773 | { | 778 | { |
774 | tune->min_delay_ms = 1000; | 779 | tune->min_delay_ms = 1000; |
775 | return 0; | 780 | return 0; |
776 | } | 781 | } |
777 | 782 | ||
778 | static void s5h1409_release(struct dvb_frontend* fe) | 783 | static void s5h1409_release(struct dvb_frontend *fe) |
779 | { | 784 | { |
780 | struct s5h1409_state* state = fe->demodulator_priv; | 785 | struct s5h1409_state *state = fe->demodulator_priv; |
781 | kfree(state); | 786 | kfree(state); |
782 | } | 787 | } |
783 | 788 | ||
784 | static struct dvb_frontend_ops s5h1409_ops; | 789 | static struct dvb_frontend_ops s5h1409_ops; |
785 | 790 | ||
786 | struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, | 791 | struct dvb_frontend *s5h1409_attach(const struct s5h1409_config *config, |
787 | struct i2c_adapter* i2c) | 792 | struct i2c_adapter *i2c) |
788 | { | 793 | { |
789 | struct s5h1409_state* state = NULL; | 794 | struct s5h1409_state *state = NULL; |
790 | u16 reg; | 795 | u16 reg; |
791 | 796 | ||
792 | /* allocate memory for the internal state */ | 797 | /* allocate memory for the internal state */ |
@@ -825,6 +830,7 @@ error: | |||
825 | kfree(state); | 830 | kfree(state); |
826 | return NULL; | 831 | return NULL; |
827 | } | 832 | } |
833 | EXPORT_SYMBOL(s5h1409_attach); | ||
828 | 834 | ||
829 | static struct dvb_frontend_ops s5h1409_ops = { | 835 | static struct dvb_frontend_ops s5h1409_ops = { |
830 | 836 | ||
@@ -850,14 +856,10 @@ static struct dvb_frontend_ops s5h1409_ops = { | |||
850 | .release = s5h1409_release, | 856 | .release = s5h1409_release, |
851 | }; | 857 | }; |
852 | 858 | ||
853 | module_param(debug, int, 0644); | ||
854 | MODULE_PARM_DESC(debug, "Enable verbose debug messages"); | ||
855 | |||
856 | MODULE_DESCRIPTION("Samsung S5H1409 QAM-B/ATSC Demodulator driver"); | 859 | MODULE_DESCRIPTION("Samsung S5H1409 QAM-B/ATSC Demodulator driver"); |
857 | MODULE_AUTHOR("Steven Toth"); | 860 | MODULE_AUTHOR("Steven Toth"); |
858 | MODULE_LICENSE("GPL"); | 861 | MODULE_LICENSE("GPL"); |
859 | 862 | ||
860 | EXPORT_SYMBOL(s5h1409_attach); | ||
861 | 863 | ||
862 | /* | 864 | /* |
863 | * Local variables: | 865 | * Local variables: |
diff --git a/drivers/media/dvb/frontends/s5h1409.h b/drivers/media/dvb/frontends/s5h1409.h index d1a1d2eb8e11..070d9743e330 100644 --- a/drivers/media/dvb/frontends/s5h1409.h +++ b/drivers/media/dvb/frontends/s5h1409.h | |||
@@ -24,8 +24,7 @@ | |||
24 | 24 | ||
25 | #include <linux/dvb/frontend.h> | 25 | #include <linux/dvb/frontend.h> |
26 | 26 | ||
27 | struct s5h1409_config | 27 | struct s5h1409_config { |
28 | { | ||
29 | /* the demodulator's i2c address */ | 28 | /* the demodulator's i2c address */ |
30 | u8 demod_address; | 29 | u8 demod_address; |
31 | 30 | ||
@@ -60,12 +59,14 @@ struct s5h1409_config | |||
60 | u16 mpeg_timing; | 59 | u16 mpeg_timing; |
61 | }; | 60 | }; |
62 | 61 | ||
63 | #if defined(CONFIG_DVB_S5H1409) || (defined(CONFIG_DVB_S5H1409_MODULE) && defined(MODULE)) | 62 | #if defined(CONFIG_DVB_S5H1409) || (defined(CONFIG_DVB_S5H1409_MODULE) \ |
64 | extern struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, | 63 | && defined(MODULE)) |
65 | struct i2c_adapter* i2c); | 64 | extern struct dvb_frontend *s5h1409_attach(const struct s5h1409_config *config, |
65 | struct i2c_adapter *i2c); | ||
66 | #else | 66 | #else |
67 | static inline struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, | 67 | static inline struct dvb_frontend *s5h1409_attach( |
68 | struct i2c_adapter* i2c) | 68 | const struct s5h1409_config *config, |
69 | struct i2c_adapter *i2c) | ||
69 | { | 70 | { |
70 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 71 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
71 | return NULL; | 72 | return NULL; |
diff --git a/drivers/media/dvb/frontends/s5h1411.c b/drivers/media/dvb/frontends/s5h1411.c index 2da1a3763de9..2febfb5a846b 100644 --- a/drivers/media/dvb/frontends/s5h1411.c +++ b/drivers/media/dvb/frontends/s5h1411.c | |||
@@ -343,7 +343,7 @@ static int s5h1411_writereg(struct s5h1411_state *state, | |||
343 | u8 addr, u8 reg, u16 data) | 343 | u8 addr, u8 reg, u16 data) |
344 | { | 344 | { |
345 | int ret; | 345 | int ret; |
346 | u8 buf [] = { reg, data >> 8, data & 0xff }; | 346 | u8 buf[] = { reg, data >> 8, data & 0xff }; |
347 | 347 | ||
348 | struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 3 }; | 348 | struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 3 }; |
349 | 349 | ||
@@ -359,10 +359,10 @@ static int s5h1411_writereg(struct s5h1411_state *state, | |||
359 | static u16 s5h1411_readreg(struct s5h1411_state *state, u8 addr, u8 reg) | 359 | static u16 s5h1411_readreg(struct s5h1411_state *state, u8 addr, u8 reg) |
360 | { | 360 | { |
361 | int ret; | 361 | int ret; |
362 | u8 b0 [] = { reg }; | 362 | u8 b0[] = { reg }; |
363 | u8 b1 [] = { 0, 0 }; | 363 | u8 b1[] = { 0, 0 }; |
364 | 364 | ||
365 | struct i2c_msg msg [] = { | 365 | struct i2c_msg msg[] = { |
366 | { .addr = addr, .flags = 0, .buf = b0, .len = 1 }, | 366 | { .addr = addr, .flags = 0, .buf = b0, .len = 1 }, |
367 | { .addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 2 } }; | 367 | { .addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 2 } }; |
368 | 368 | ||
diff --git a/drivers/media/dvb/frontends/tda10048.c b/drivers/media/dvb/frontends/tda10048.c index 04e7f1cc1403..2a8bbcd44cd0 100644 --- a/drivers/media/dvb/frontends/tda10048.c +++ b/drivers/media/dvb/frontends/tda10048.c | |||
@@ -195,7 +195,7 @@ static struct init_tab { | |||
195 | static int tda10048_writereg(struct tda10048_state *state, u8 reg, u8 data) | 195 | static int tda10048_writereg(struct tda10048_state *state, u8 reg, u8 data) |
196 | { | 196 | { |
197 | int ret; | 197 | int ret; |
198 | u8 buf [] = { reg, data }; | 198 | u8 buf[] = { reg, data }; |
199 | struct i2c_msg msg = { | 199 | struct i2c_msg msg = { |
200 | .addr = state->config->demod_address, | 200 | .addr = state->config->demod_address, |
201 | .flags = 0, .buf = buf, .len = 2 }; | 201 | .flags = 0, .buf = buf, .len = 2 }; |
@@ -213,9 +213,9 @@ static int tda10048_writereg(struct tda10048_state *state, u8 reg, u8 data) | |||
213 | static u8 tda10048_readreg(struct tda10048_state *state, u8 reg) | 213 | static u8 tda10048_readreg(struct tda10048_state *state, u8 reg) |
214 | { | 214 | { |
215 | int ret; | 215 | int ret; |
216 | u8 b0 [] = { reg }; | 216 | u8 b0[] = { reg }; |
217 | u8 b1 [] = { 0 }; | 217 | u8 b1[] = { 0 }; |
218 | struct i2c_msg msg [] = { | 218 | struct i2c_msg msg[] = { |
219 | { .addr = state->config->demod_address, | 219 | { .addr = state->config->demod_address, |
220 | .flags = 0, .buf = b0, .len = 1 }, | 220 | .flags = 0, .buf = b0, .len = 1 }, |
221 | { .addr = state->config->demod_address, | 221 | { .addr = state->config->demod_address, |
@@ -393,43 +393,89 @@ static int tda10048_get_tps(struct tda10048_state *state, | |||
393 | 393 | ||
394 | val = tda10048_readreg(state, TDA10048_OUT_CONF2); | 394 | val = tda10048_readreg(state, TDA10048_OUT_CONF2); |
395 | switch ((val & 0x60) >> 5) { | 395 | switch ((val & 0x60) >> 5) { |
396 | case 0: p->constellation = QPSK; break; | 396 | case 0: |
397 | case 1: p->constellation = QAM_16; break; | 397 | p->constellation = QPSK; |
398 | case 2: p->constellation = QAM_64; break; | 398 | break; |
399 | case 1: | ||
400 | p->constellation = QAM_16; | ||
401 | break; | ||
402 | case 2: | ||
403 | p->constellation = QAM_64; | ||
404 | break; | ||
399 | } | 405 | } |
400 | switch ((val & 0x18) >> 3) { | 406 | switch ((val & 0x18) >> 3) { |
401 | case 0: p->hierarchy_information = HIERARCHY_NONE; break; | 407 | case 0: |
402 | case 1: p->hierarchy_information = HIERARCHY_1; break; | 408 | p->hierarchy_information = HIERARCHY_NONE; |
403 | case 2: p->hierarchy_information = HIERARCHY_2; break; | 409 | break; |
404 | case 3: p->hierarchy_information = HIERARCHY_4; break; | 410 | case 1: |
411 | p->hierarchy_information = HIERARCHY_1; | ||
412 | break; | ||
413 | case 2: | ||
414 | p->hierarchy_information = HIERARCHY_2; | ||
415 | break; | ||
416 | case 3: | ||
417 | p->hierarchy_information = HIERARCHY_4; | ||
418 | break; | ||
405 | } | 419 | } |
406 | switch (val & 0x07) { | 420 | switch (val & 0x07) { |
407 | case 0: p->code_rate_HP = FEC_1_2; break; | 421 | case 0: |
408 | case 1: p->code_rate_HP = FEC_2_3; break; | 422 | p->code_rate_HP = FEC_1_2; |
409 | case 2: p->code_rate_HP = FEC_3_4; break; | 423 | break; |
410 | case 3: p->code_rate_HP = FEC_5_6; break; | 424 | case 1: |
411 | case 4: p->code_rate_HP = FEC_7_8; break; | 425 | p->code_rate_HP = FEC_2_3; |
426 | break; | ||
427 | case 2: | ||
428 | p->code_rate_HP = FEC_3_4; | ||
429 | break; | ||
430 | case 3: | ||
431 | p->code_rate_HP = FEC_5_6; | ||
432 | break; | ||
433 | case 4: | ||
434 | p->code_rate_HP = FEC_7_8; | ||
435 | break; | ||
412 | } | 436 | } |
413 | 437 | ||
414 | val = tda10048_readreg(state, TDA10048_OUT_CONF3); | 438 | val = tda10048_readreg(state, TDA10048_OUT_CONF3); |
415 | switch (val & 0x07) { | 439 | switch (val & 0x07) { |
416 | case 0: p->code_rate_LP = FEC_1_2; break; | 440 | case 0: |
417 | case 1: p->code_rate_LP = FEC_2_3; break; | 441 | p->code_rate_LP = FEC_1_2; |
418 | case 2: p->code_rate_LP = FEC_3_4; break; | 442 | break; |
419 | case 3: p->code_rate_LP = FEC_5_6; break; | 443 | case 1: |
420 | case 4: p->code_rate_LP = FEC_7_8; break; | 444 | p->code_rate_LP = FEC_2_3; |
445 | break; | ||
446 | case 2: | ||
447 | p->code_rate_LP = FEC_3_4; | ||
448 | break; | ||
449 | case 3: | ||
450 | p->code_rate_LP = FEC_5_6; | ||
451 | break; | ||
452 | case 4: | ||
453 | p->code_rate_LP = FEC_7_8; | ||
454 | break; | ||
421 | } | 455 | } |
422 | 456 | ||
423 | val = tda10048_readreg(state, TDA10048_OUT_CONF1); | 457 | val = tda10048_readreg(state, TDA10048_OUT_CONF1); |
424 | switch ((val & 0x0c) >> 2) { | 458 | switch ((val & 0x0c) >> 2) { |
425 | case 0: p->guard_interval = GUARD_INTERVAL_1_32; break; | 459 | case 0: |
426 | case 1: p->guard_interval = GUARD_INTERVAL_1_16; break; | 460 | p->guard_interval = GUARD_INTERVAL_1_32; |
427 | case 2: p->guard_interval = GUARD_INTERVAL_1_8; break; | 461 | break; |
428 | case 3: p->guard_interval = GUARD_INTERVAL_1_4; break; | 462 | case 1: |
463 | p->guard_interval = GUARD_INTERVAL_1_16; | ||
464 | break; | ||
465 | case 2: | ||
466 | p->guard_interval = GUARD_INTERVAL_1_8; | ||
467 | break; | ||
468 | case 3: | ||
469 | p->guard_interval = GUARD_INTERVAL_1_4; | ||
470 | break; | ||
429 | } | 471 | } |
430 | switch (val & 0x02) { | 472 | switch (val & 0x02) { |
431 | case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break; | 473 | case 0: |
432 | case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break; | 474 | p->transmission_mode = TRANSMISSION_MODE_2K; |
475 | break; | ||
476 | case 1: | ||
477 | p->transmission_mode = TRANSMISSION_MODE_8K; | ||
478 | break; | ||
433 | } | 479 | } |
434 | 480 | ||
435 | return 0; | 481 | return 0; |
diff --git a/drivers/media/dvb/frontends/z0194a.h b/drivers/media/dvb/frontends/z0194a.h index d2876d2e1769..07f3fc0998f6 100644 --- a/drivers/media/dvb/frontends/z0194a.h +++ b/drivers/media/dvb/frontends/z0194a.h | |||
@@ -12,7 +12,7 @@ | |||
12 | #ifndef Z0194A | 12 | #ifndef Z0194A |
13 | #define Z0194A | 13 | #define Z0194A |
14 | 14 | ||
15 | static int sharp_z0194a__set_symbol_rate(struct dvb_frontend *fe, | 15 | static int sharp_z0194a_set_symbol_rate(struct dvb_frontend *fe, |
16 | u32 srate, u32 ratio) | 16 | u32 srate, u32 ratio) |
17 | { | 17 | { |
18 | u8 aclk = 0; | 18 | u8 aclk = 0; |
@@ -40,7 +40,7 @@ static int sharp_z0194a__set_symbol_rate(struct dvb_frontend *fe, | |||
40 | return 0; | 40 | return 0; |
41 | } | 41 | } |
42 | 42 | ||
43 | static u8 sharp_z0194a__inittab[] = { | 43 | static u8 sharp_z0194a_inittab[] = { |
44 | 0x01, 0x15, | 44 | 0x01, 0x15, |
45 | 0x02, 0x00, | 45 | 0x02, 0x00, |
46 | 0x03, 0x00, | 46 | 0x03, 0x00, |
@@ -82,16 +82,4 @@ static u8 sharp_z0194a__inittab[] = { | |||
82 | 0xff, 0xff | 82 | 0xff, 0xff |
83 | }; | 83 | }; |
84 | 84 | ||
85 | static struct stv0299_config sharp_z0194a_config = { | ||
86 | .demod_address = 0x68, | ||
87 | .inittab = sharp_z0194a__inittab, | ||
88 | .mclk = 88000000UL, | ||
89 | .invert = 1, | ||
90 | .skip_reinit = 0, | ||
91 | .lock_output = STV0299_LOCKOUTPUT_1, | ||
92 | .volt13_op0_op1 = STV0299_VOLT13_OP1, | ||
93 | .min_delay_ms = 100, | ||
94 | .set_symbol_rate = sharp_z0194a__set_symbol_rate, | ||
95 | }; | ||
96 | |||
97 | #endif | 85 | #endif |