aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2006-09-23 19:40:20 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:50 -0500
commit017cf012570c955c3e1ff025802d7cb46fd1d37b (patch)
tree7cceec55fdfdbc40751198d267c89f8ea13473bd /drivers/media/dvb/dvb-usb
parent2a2bfa7d61b29170b7f9bbf42712a77229e6b935 (diff)
V4L/DVB (5129): M920x: break out qt1010 tuner code into a separate file
qt1010 is a tuner used in some other devices, so this code should be put into a separate file so that it could be reused by other drivers. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.c204
1 files changed, 1 insertions, 203 deletions
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index 5ab16b15b95c..292805aad69a 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -13,6 +13,7 @@
13 13
14#include "mt352.h" 14#include "mt352.h"
15#include "mt352_priv.h" 15#include "mt352_priv.h"
16#include "qt1010.h"
16 17
17/* debug */ 18/* debug */
18int dvb_usb_m920x_debug; 19int dvb_usb_m920x_debug;
@@ -226,209 +227,6 @@ static int megasky_mt352_demod_init(struct dvb_frontend *fe)
226 227
227struct mt352_state; 228struct mt352_state;
228 229
229#define W 0
230#define R 1
231/* Not actual hw limits. */
232#define QT1010_MIN_STEP 2000000
233#define QT1010_MIN_FREQ 48000000
234
235int qt1010_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8 *buf, int buf_len)
236{
237 int i;
238 int div, mod;
239 struct {
240 u8 read, reg, value;
241 } rd[46] = { { W, 0x01, 0x80 },
242 { W, 0x02, 0x3f },
243 { W, 0x05, 0xff }, /* c */
244 { W, 0x06, 0x44 },
245 { W, 0x07, 0xff }, /* c */
246 { W, 0x08, 0x08 },
247 { W, 0x09, 0xff }, /* c */
248 { W, 0x0a, 0xff }, /* c */
249 { W, 0x0b, 0xff }, /* c */
250 { W, 0x0c, 0xe1 },
251 { W, 0x1a, 0xff }, /* 10 c */
252 { W, 0x1b, 0x00 },
253 { W, 0x1c, 0x89 },
254 { W, 0x11, 0xff }, /* c */
255 { W, 0x12, 0x91 },
256 { W, 0x22, 0xff }, /* c */
257 { W, 0x1e, 0x00 },
258 { W, 0x1e, 0xd0 },
259 { R, 0x22, 0xff }, /* c read */
260 { W, 0x1e, 0x00 },
261 { R, 0x05, 0xff }, /* 20 c read */
262 { R, 0x22, 0xff }, /* c read */
263 { W, 0x23, 0xd0 },
264 { W, 0x1e, 0x00 },
265 { W, 0x1e, 0xe0 },
266 { R, 0x23, 0xff }, /* c read */
267 { W, 0x1e, 0x00 },
268 { W, 0x24, 0xd0 },
269 { W, 0x1e, 0x00 },
270 { W, 0x1e, 0xf0 },
271 { R, 0x24, 0xff }, /* 30 c read */
272 { W, 0x1e, 0x00 },
273 { W, 0x14, 0x7f },
274 { W, 0x15, 0x7f },
275 { W, 0x05, 0xff }, /* c */
276 { W, 0x06, 0x00 },
277 { W, 0x15, 0x1f },
278 { W, 0x16, 0xff },
279 { W, 0x18, 0xff },
280 { W, 0x1f, 0xff }, /* c */
281 { W, 0x20, 0xff }, /* 40 c */
282 { W, 0x21, 0x53 },
283 { W, 0x25, 0xbd },
284 { W, 0x26, 0x15 },
285 { W, 0x02, 0x00 },
286 { W, 0x01, 0x00 },
287 };
288 struct i2c_msg msg;
289 struct dvb_usb_device *d = fe->dvb->priv;
290 unsigned long freq = params->frequency;
291
292 if (freq % QT1010_MIN_STEP)
293 deb_rc("frequency not supported.\n");
294
295 (void) buf;
296 (void) buf_len;
297
298 div = (freq - QT1010_MIN_FREQ) / QT1010_MIN_STEP;
299 mod = (div + 16 - 9) % 16;
300
301 /* 0x5 */
302 if (div >= 377)
303 rd[2].value = 0x74;
304 else if (div >= 265)
305 rd[2].value = 0x54;
306 else if (div >= 121)
307 rd[2].value = 0x34;
308 else
309 rd[2].value = 0x14;
310
311 /* 0x7 */
312 rd[4].value = (((freq - QT1010_MIN_FREQ) / 1000000) * 9975 + 12960000) / 320000;
313
314 /* 09 */
315 if (mod < 4)
316 rd[6].value = 0x1d;
317 else
318 rd[6].value = 0x1c;
319
320 /* 0a */
321 if (mod < 2)
322 rd[7].value = 0x09;
323 else if (mod < 4)
324 rd[7].value = 0x08;
325 else if (mod < 6)
326 rd[7].value = 0x0f;
327 else if (mod < 8)
328 rd[7].value = 0x0e;
329 else if (mod < 10)
330 rd[7].value = 0x0d;
331 else if (mod < 12)
332 rd[7].value = 0x0c;
333 else if (mod < 14)
334 rd[7].value = 0x0b;
335 else
336 rd[7].value = 0x0a;
337
338 /* 0b */
339 if (div & 1)
340 rd[8].value = 0x45;
341 else
342 rd[8].value = 0x44;
343
344 /* 1a */
345 if (div & 1)
346 rd[10].value = 0x78;
347 else
348 rd[10].value = 0xf8;
349
350 /* 11 */
351 if (div >= 265)
352 rd[13].value = 0xf9;
353 else if (div >= 121)
354 rd[13].value = 0xfd;
355 else
356 rd[13].value = 0xf9;
357
358 /* 22 */
359 if (div < 201)
360 rd[15].value = 0xd0;
361 else if (div < 217)
362 rd[15].value = 0xd3;
363 else if (div < 233)
364 rd[15].value = 0xd6;
365 else if (div < 249)
366 rd[15].value = 0xd9;
367 else if (div < 265)
368 rd[15].value = 0xda;
369 else
370 rd[15].value = 0xd0;
371
372 /* 05 */
373 if (div >= 377)
374 rd[34].value = 0x70;
375 else if (div >= 265)
376 rd[34].value = 0x50;
377 else if (div >= 121)
378 rd[34].value = 0x30;
379 else
380 rd[34].value = 0x10;
381
382 /* 1f */
383 if (mod < 4)
384 rd[39].value = 0x64;
385 else if (mod < 6)
386 rd[39].value = 0x66;
387 else if (mod < 8)
388 rd[39].value = 0x67;
389 else if (mod < 12)
390 rd[39].value = 0x68;
391 else if (mod < 14)
392 rd[39].value = 0x69;
393 else
394 rd[39].value = 0x6a;
395
396 /* 20 */
397 if (mod < 4)
398 rd[40].value = 0x10;
399 else if (mod < 6)
400 rd[40].value = 0x11;
401 else if (mod < 10)
402 rd[40].value = 0x12;
403 else if (mod < 12)
404 rd[40].value = 0x13;
405 else if (mod < 14)
406 rd[40].value = 0x14;
407 else
408 rd[40].value = 0x15;
409
410 deb_rc("Now tuning... ");
411 for (i = 0; i < sizeof(rd) / sizeof(*rd); i++) {
412 if (rd[i].read)
413 continue;
414
415 msg.flags = 0;
416 msg.len = 2;
417 msg.addr = 0xc4;
418 msg.buf = &rd[i].reg;
419
420 if (i2c_transfer(&d->i2c_adap, &msg, 1) != 1) {
421 deb_rc("tuner write failed\n");
422 return -EIO;
423 }
424 }
425 deb_rc("done\n");
426
427 return 0;
428}
429#undef W
430#undef R
431
432static struct mt352_config megasky_mt352_config = { 230static struct mt352_config megasky_mt352_config = {
433 .demod_address = 0x1e, 231 .demod_address = 0x1e,
434 .demod_init = megasky_mt352_demod_init, 232 .demod_init = megasky_mt352_demod_init,