3 * i2c tv tuner chip device driver
4 * controls all those simple 4-control-bytes style tuners.
6 #include <linux/delay.h>
8 #include <linux/videodev.h>
9 #include <media/tuner.h>
11 static int offset
= 0;
12 module_param(offset
, int, 0666);
13 MODULE_PARM_DESC(offset
,"Allows to specify an offset for tuner");
15 /* ---------------------------------------------------------------------- */
17 /* tv standard selection for Temic 4046 FM5
18 this value takes the low bits of control byte 2
19 from datasheet Rev.01, Feb.00
21 picture IF 38.9 38.9 38.9 33.95 38.9
22 sound 1 33.4 32.9 32.4 40.45 32.4
24 NICAM 33.05 32.348 33.05 33.05
26 #define TEMIC_SET_PAL_I 0x05
27 #define TEMIC_SET_PAL_DK 0x09
28 #define TEMIC_SET_PAL_L 0x0a // SECAM ?
29 #define TEMIC_SET_PAL_L2 0x0b // change IF !
30 #define TEMIC_SET_PAL_BG 0x0c
32 /* tv tuner system standard selection for Philips FQ1216ME
33 this value takes the low bits of control byte 2
34 from datasheet "1999 Nov 16" (supersedes "1999 Mar 23")
36 picture carrier 38.90 38.90 38.90 38.90 33.95
37 colour 34.47 34.47 34.47 34.47 38.38
38 sound 1 33.40 32.40 32.90 32.40 40.45
40 NICAM 33.05 33.05 32.35 33.05 39.80
42 #define PHILIPS_SET_PAL_I 0x01 /* Bit 2 always zero !*/
43 #define PHILIPS_SET_PAL_BGDK 0x09
44 #define PHILIPS_SET_PAL_L2 0x0a
45 #define PHILIPS_SET_PAL_L 0x0b
47 /* system switching for Philips FI1216MF MK2
48 from datasheet "1996 Jul 09",
50 picture carrier 38.90 38.90 33.95
51 colour 34.47 34.37 38.38
52 sound 1 33.40 32.40 40.45
54 NICAM 33.05 33.05 39.80
56 #define PHILIPS_MF_SET_BG 0x01 /* Bit 2 must be zero, Bit 3 is system output */
57 #define PHILIPS_MF_SET_PAL_L 0x03 // France
58 #define PHILIPS_MF_SET_PAL_L2 0x02 // L'
62 #define TUNER_RATIO_MASK 0x06 /* Bit cb1:cb2 */
63 #define TUNER_RATIO_SELECT_50 0x00
64 #define TUNER_RATIO_SELECT_32 0x02
65 #define TUNER_RATIO_SELECT_166 0x04
66 #define TUNER_RATIO_SELECT_62 0x06
68 #define TUNER_CHARGE_PUMP 0x40 /* Bit cb6 */
72 #define TUNER_POR 0x80
74 #define TUNER_MODE 0x38
75 #define TUNER_AFC 0x07
76 #define TUNER_SIGNAL 0x07
77 #define TUNER_STEREO 0x10
79 #define TUNER_PLL_LOCKED 0x40
80 #define TUNER_STEREO_MK3 0x04
82 #define TUNER_MAX_RANGES 3
84 /* ---------------------------------------------------------------------- */
92 unsigned short thresh
;
94 } ranges
[TUNER_MAX_RANGES
];
99 * The floats in the tuner struct are computed at compile time
100 * by gcc and cast back to integers. Thus we don't violate the
101 * "no float in kernel" rule.
103 static struct tunertype tuners
[] = {
105 [TUNER_TEMIC_PAL
] = { /* TEMIC PAL */
106 .name
= "Temic PAL (4002 FH5)",
109 { 16 * 140.25 /*MHz*/, 0x02, },
110 { 16 * 463.25 /*MHz*/, 0x04, },
111 { 16 * 999.99 , 0x01, },
115 [TUNER_PHILIPS_PAL_I
] = { /* Philips PAL_I */
116 .name
= "Philips PAL_I (FI1246 and compatibles)",
119 { 16 * 140.25 /*MHz*/, 0xa0, },
120 { 16 * 463.25 /*MHz*/, 0x90, },
121 { 16 * 999.99 , 0x30, },
125 [TUNER_PHILIPS_NTSC
] = { /* Philips NTSC */
126 .name
= "Philips NTSC (FI1236,FM1236 and compatibles)",
129 { 16 * 157.25 /*MHz*/, 0xa0, },
130 { 16 * 451.25 /*MHz*/, 0x90, },
131 { 16 * 999.99 , 0x30, },
135 [TUNER_PHILIPS_SECAM
] = { /* Philips SECAM */
136 .name
= "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)",
139 { 16 * 168.25 /*MHz*/, 0xa7, },
140 { 16 * 447.25 /*MHz*/, 0x97, },
141 { 16 * 999.99 , 0x37, },
145 [TUNER_ABSENT
] = { /* Tuner Absent */
153 [TUNER_PHILIPS_PAL
] = { /* Philips PAL */
154 .name
= "Philips PAL_BG (FI1216 and compatibles)",
157 { 16 * 168.25 /*MHz*/, 0xa0, },
158 { 16 * 447.25 /*MHz*/, 0x90, },
159 { 16 * 999.99 , 0x30, },
163 [TUNER_TEMIC_NTSC
] = { /* TEMIC NTSC */
164 .name
= "Temic NTSC (4032 FY5)",
167 { 16 * 157.25 /*MHz*/, 0x02, },
168 { 16 * 463.25 /*MHz*/, 0x04, },
169 { 16 * 999.99 , 0x01, },
173 [TUNER_TEMIC_PAL_I
] = { /* TEMIC PAL_I */
174 .name
= "Temic PAL_I (4062 FY5)",
177 { 16 * 170.00 /*MHz*/, 0x02, },
178 { 16 * 450.00 /*MHz*/, 0x04, },
179 { 16 * 999.99 , 0x01, },
183 [TUNER_TEMIC_4036FY5_NTSC
] = { /* TEMIC NTSC */
184 .name
= "Temic NTSC (4036 FY5)",
187 { 16 * 157.25 /*MHz*/, 0xa0, },
188 { 16 * 463.25 /*MHz*/, 0x90, },
189 { 16 * 999.99 , 0x30, },
193 [TUNER_ALPS_TSBH1_NTSC
] = { /* TEMIC NTSC */
194 .name
= "Alps HSBH1",
197 { 16 * 137.25 /*MHz*/, 0x01, },
198 { 16 * 385.25 /*MHz*/, 0x02, },
199 { 16 * 999.99 , 0x08, },
205 [TUNER_ALPS_TSBE1_PAL
] = { /* TEMIC PAL */
206 .name
= "Alps TSBE1",
209 { 16 * 137.25 /*MHz*/, 0x01, },
210 { 16 * 385.25 /*MHz*/, 0x02, },
211 { 16 * 999.99 , 0x08, },
215 [TUNER_ALPS_TSBB5_PAL_I
] = { /* Alps PAL_I */
216 .name
= "Alps TSBB5",
219 { 16 * 133.25 /*MHz*/, 0x01, },
220 { 16 * 351.25 /*MHz*/, 0x02, },
221 { 16 * 999.99 , 0x08, },
225 [TUNER_ALPS_TSBE5_PAL
] = { /* Alps PAL */
226 .name
= "Alps TSBE5",
229 { 16 * 133.25 /*MHz*/, 0x01, },
230 { 16 * 351.25 /*MHz*/, 0x02, },
231 { 16 * 999.99 , 0x08, },
235 [TUNER_ALPS_TSBC5_PAL
] = { /* Alps PAL */
236 .name
= "Alps TSBC5",
239 { 16 * 133.25 /*MHz*/, 0x01, },
240 { 16 * 351.25 /*MHz*/, 0x02, },
241 { 16 * 999.99 , 0x08, },
245 [TUNER_TEMIC_4006FH5_PAL
] = { /* TEMIC PAL */
246 .name
= "Temic PAL_BG (4006FH5)",
249 { 16 * 170.00 /*MHz*/, 0xa0, },
250 { 16 * 450.00 /*MHz*/, 0x90, },
251 { 16 * 999.99 , 0x30, },
255 [TUNER_ALPS_TSHC6_NTSC
] = { /* Alps NTSC */
256 .name
= "Alps TSCH6",
259 { 16 * 137.25 /*MHz*/, 0x14, },
260 { 16 * 385.25 /*MHz*/, 0x12, },
261 { 16 * 999.99 , 0x11, },
265 [TUNER_TEMIC_PAL_DK
] = { /* TEMIC PAL */
266 .name
= "Temic PAL_DK (4016 FY5)",
269 { 16 * 168.25 /*MHz*/, 0xa0, },
270 { 16 * 456.25 /*MHz*/, 0x90, },
271 { 16 * 999.99 , 0x30, },
275 [TUNER_PHILIPS_NTSC_M
] = { /* Philips NTSC */
276 .name
= "Philips NTSC_M (MK2)",
279 { 16 * 160.00 /*MHz*/, 0xa0, },
280 { 16 * 454.00 /*MHz*/, 0x90, },
281 { 16 * 999.99 , 0x30, },
285 [TUNER_TEMIC_4066FY5_PAL_I
] = { /* TEMIC PAL_I */
286 .name
= "Temic PAL_I (4066 FY5)",
289 { 16 * 169.00 /*MHz*/, 0xa0, },
290 { 16 * 454.00 /*MHz*/, 0x90, },
291 { 16 * 999.99 , 0x30, },
295 [TUNER_TEMIC_4006FN5_MULTI_PAL
] = { /* TEMIC PAL */
296 .name
= "Temic PAL* auto (4006 FN5)",
299 { 16 * 169.00 /*MHz*/, 0xa0, },
300 { 16 * 454.00 /*MHz*/, 0x90, },
301 { 16 * 999.99 , 0x30, },
307 [TUNER_TEMIC_4009FR5_PAL
] = { /* TEMIC PAL */
308 .name
= "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)",
311 { 16 * 141.00 /*MHz*/, 0xa0, },
312 { 16 * 464.00 /*MHz*/, 0x90, },
313 { 16 * 999.99 , 0x30, },
317 [TUNER_TEMIC_4039FR5_NTSC
] = { /* TEMIC NTSC */
318 .name
= "Temic NTSC (4039 FR5)",
321 { 16 * 158.00 /*MHz*/, 0xa0, },
322 { 16 * 453.00 /*MHz*/, 0x90, },
323 { 16 * 999.99 , 0x30, },
327 [TUNER_TEMIC_4046FM5
] = { /* TEMIC PAL */
328 .name
= "Temic PAL/SECAM multi (4046 FM5)",
331 { 16 * 169.00 /*MHz*/, 0xa0, },
332 { 16 * 454.00 /*MHz*/, 0x90, },
333 { 16 * 999.99 , 0x30, },
337 [TUNER_PHILIPS_PAL_DK
] = { /* Philips PAL */
338 .name
= "Philips PAL_DK (FI1256 and compatibles)",
341 { 16 * 170.00 /*MHz*/, 0xa0, },
342 { 16 * 450.00 /*MHz*/, 0x90, },
343 { 16 * 999.99 , 0x30, },
347 [TUNER_PHILIPS_FQ1216ME
] = { /* Philips PAL */
348 .name
= "Philips PAL/SECAM multi (FQ1216ME)",
351 { 16 * 170.00 /*MHz*/, 0xa0, },
352 { 16 * 450.00 /*MHz*/, 0x90, },
353 { 16 * 999.99 , 0x30, },
357 [TUNER_LG_PAL_I_FM
] = { /* LGINNOTEK PAL_I */
358 .name
= "LG PAL_I+FM (TAPC-I001D)",
361 { 16 * 170.00 /*MHz*/, 0xa0, },
362 { 16 * 450.00 /*MHz*/, 0x90, },
363 { 16 * 999.99 , 0x30, },
367 [TUNER_LG_PAL_I
] = { /* LGINNOTEK PAL_I */
368 .name
= "LG PAL_I (TAPC-I701D)",
371 { 16 * 170.00 /*MHz*/, 0xa0, },
372 { 16 * 450.00 /*MHz*/, 0x90, },
373 { 16 * 999.99 , 0x30, },
377 [TUNER_LG_NTSC_FM
] = { /* LGINNOTEK NTSC */
378 .name
= "LG NTSC+FM (TPI8NSR01F)",
381 { 16 * 210.00 /*MHz*/, 0xa0, },
382 { 16 * 497.00 /*MHz*/, 0x90, },
383 { 16 * 999.99 , 0x30, },
387 [TUNER_LG_PAL_FM
] = { /* LGINNOTEK PAL */
388 .name
= "LG PAL_BG+FM (TPI8PSB01D)",
391 { 16 * 170.00 /*MHz*/, 0xa0, },
392 { 16 * 450.00 /*MHz*/, 0x90, },
393 { 16 * 999.99 , 0x30, },
397 [TUNER_LG_PAL
] = { /* LGINNOTEK PAL */
398 .name
= "LG PAL_BG (TPI8PSB11D)",
401 { 16 * 170.00 /*MHz*/, 0xa0, },
402 { 16 * 450.00 /*MHz*/, 0x90, },
403 { 16 * 999.99 , 0x30, },
409 [TUNER_TEMIC_4009FN5_MULTI_PAL_FM
] = { /* TEMIC PAL */
410 .name
= "Temic PAL* auto + FM (4009 FN5)",
413 { 16 * 141.00 /*MHz*/, 0xa0, },
414 { 16 * 464.00 /*MHz*/, 0x90, },
415 { 16 * 999.99 , 0x30, },
419 [TUNER_SHARP_2U5JF5540_NTSC
] = { /* SHARP NTSC */
420 .name
= "SHARP NTSC_JP (2U5JF5540)",
423 { 16 * 137.25 /*MHz*/, 0x01, },
424 { 16 * 317.25 /*MHz*/, 0x02, },
425 { 16 * 999.99 , 0x08, },
429 [TUNER_Samsung_PAL_TCPM9091PD27
] = { /* Samsung PAL */
430 .name
= "Samsung PAL TCPM9091PD27",
433 { 16 * 169 /*MHz*/, 0xa0, },
434 { 16 * 464 /*MHz*/, 0x90, },
435 { 16 * 999.99 , 0x30, },
439 [TUNER_MT2032
] = { /* Microtune PAL|NTSC */
440 .name
= "MT20xx universal",
441 /* see mt20xx.c for details */ },
442 [TUNER_TEMIC_4106FH5
] = { /* TEMIC PAL */
443 .name
= "Temic PAL_BG (4106 FH5)",
446 { 16 * 141.00 /*MHz*/, 0xa0, },
447 { 16 * 464.00 /*MHz*/, 0x90, },
448 { 16 * 999.99 , 0x30, },
452 [TUNER_TEMIC_4012FY5
] = { /* TEMIC PAL */
453 .name
= "Temic PAL_DK/SECAM_L (4012 FY5)",
456 { 16 * 140.25 /*MHz*/, 0x02, },
457 { 16 * 463.25 /*MHz*/, 0x04, },
458 { 16 * 999.99 , 0x01, },
462 [TUNER_TEMIC_4136FY5
] = { /* TEMIC NTSC */
463 .name
= "Temic NTSC (4136 FY5)",
466 { 16 * 158.00 /*MHz*/, 0xa0, },
467 { 16 * 453.00 /*MHz*/, 0x90, },
468 { 16 * 999.99 , 0x30, },
472 [TUNER_LG_PAL_NEW_TAPC
] = { /* LGINNOTEK PAL */
473 .name
= "LG PAL (newer TAPC series)",
476 { 16 * 170.00 /*MHz*/, 0x01, },
477 { 16 * 450.00 /*MHz*/, 0x02, },
478 { 16 * 999.99 , 0x08, },
482 [TUNER_PHILIPS_FM1216ME_MK3
] = { /* Philips PAL */
483 .name
= "Philips PAL/SECAM multi (FM1216ME MK3)",
486 { 16 * 158.00 /*MHz*/, 0x01, },
487 { 16 * 442.00 /*MHz*/, 0x02, },
488 { 16 * 999.99 , 0x04, },
492 [TUNER_LG_NTSC_NEW_TAPC
] = { /* LGINNOTEK NTSC */
493 .name
= "LG NTSC (newer TAPC series)",
496 { 16 * 170.00 /*MHz*/, 0x01, },
497 { 16 * 450.00 /*MHz*/, 0x02, },
498 { 16 * 999.99 , 0x08, },
504 [TUNER_HITACHI_NTSC
] = { /* HITACHI NTSC */
505 .name
= "HITACHI V7-J180AT",
508 { 16 * 170.00 /*MHz*/, 0x01, },
509 { 16 * 450.00 /*MHz*/, 0x02, },
510 { 16 * 999.99 , 0x08, },
514 [TUNER_PHILIPS_PAL_MK
] = { /* Philips PAL */
515 .name
= "Philips PAL_MK (FI1216 MK)",
518 { 16 * 140.25 /*MHz*/, 0x01, },
519 { 16 * 463.25 /*MHz*/, 0xc2, },
520 { 16 * 999.99 , 0xcf, },
524 [TUNER_PHILIPS_ATSC
] = { /* Philips ATSC */
525 .name
= "Philips 1236D ATSC/NTSC dual in",
528 { 16 * 157.25 /*MHz*/, 0xa0, },
529 { 16 * 454.00 /*MHz*/, 0x90, },
530 { 16 * 999.99 , 0x30, },
534 [TUNER_PHILIPS_FM1236_MK3
] = { /* Philips NTSC */
535 .name
= "Philips NTSC MK3 (FM1236MK3 or FM1236/F)",
538 { 16 * 160.00 /*MHz*/, 0x01, },
539 { 16 * 442.00 /*MHz*/, 0x02, },
540 { 16 * 999.99 , 0x04, },
544 [TUNER_PHILIPS_4IN1
] = { /* Philips NTSC */
545 .name
= "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)",
548 { 16 * 160.00 /*MHz*/, 0x01, },
549 { 16 * 442.00 /*MHz*/, 0x02, },
550 { 16 * 999.99 , 0x04, },
554 [TUNER_MICROTUNE_4049FM5
] = { /* Microtune PAL */
555 .name
= "Microtune 4049 FM5",
558 { 16 * 141.00 /*MHz*/, 0xa0, },
559 { 16 * 464.00 /*MHz*/, 0x90, },
560 { 16 * 999.99 , 0x30, },
564 [TUNER_PANASONIC_VP27
] = { /* Panasonic NTSC */
565 .name
= "Panasonic VP27s/ENGE4324D",
568 { 16 * 160.00 /*MHz*/, 0x01, },
569 { 16 * 454.00 /*MHz*/, 0x02, },
570 { 16 * 999.99 , 0x08, },
574 [TUNER_LG_NTSC_TAPE
] = { /* LGINNOTEK NTSC */
575 .name
= "LG NTSC (TAPE series)",
578 { 16 * 160.00 /*MHz*/, 0x01, },
579 { 16 * 442.00 /*MHz*/, 0x02, },
580 { 16 * 999.99 , 0x04, },
584 [TUNER_TNF_8831BGFF
] = { /* Philips PAL */
585 .name
= "Tenna TNF 8831 BGFF)",
588 { 16 * 161.25 /*MHz*/, 0xa0, },
589 { 16 * 463.25 /*MHz*/, 0x90, },
590 { 16 * 999.99 , 0x30, },
594 [TUNER_MICROTUNE_4042FI5
] = { /* Microtune NTSC */
595 .name
= "Microtune 4042 FI5 ATSC/NTSC dual in",
598 { 16 * 162.00 /*MHz*/, 0xa2, },
599 { 16 * 457.00 /*MHz*/, 0x94, },
600 { 16 * 999.99 , 0x31, },
606 [TUNER_TCL_2002N
] = { /* TCL NTSC */
610 { 16 * 172.00 /*MHz*/, 0x01, },
611 { 16 * 448.00 /*MHz*/, 0x02, },
612 { 16 * 999.99 , 0x08, },
616 [TUNER_PHILIPS_FM1256_IH3
] = { /* Philips PAL */
617 .name
= "Philips PAL/SECAM_D (FM 1256 I-H3)",
620 { 16 * 160.00 /*MHz*/, 0x01, },
621 { 16 * 442.00 /*MHz*/, 0x02, },
622 { 16 * 999.99 , 0x04, },
626 [TUNER_THOMSON_DTT7610
] = { /* THOMSON ATSC */
627 .name
= "Thomson DTT 7610 (ATSC/NTSC)",
630 { 16 * 157.25 /*MHz*/, 0x39, },
631 { 16 * 454.00 /*MHz*/, 0x3a, },
632 { 16 * 999.99 , 0x3c, },
636 [TUNER_PHILIPS_FQ1286
] = { /* Philips NTSC */
637 .name
= "Philips FQ1286",
640 { 16 * 160.00 /*MHz*/, 0x41, },
641 { 16 * 454.00 /*MHz*/, 0x42, },
642 { 16 * 999.99 , 0x04, },
646 [TUNER_PHILIPS_TDA8290
] = { /* Philips PAL|NTSC */
647 .name
= "tda8290+75",
648 /* see tda8290.c for details */ },
649 [TUNER_TCL_2002MB
] = { /* TCL PAL */
650 .name
= "TCL 2002MB",
653 { 16 * 170.00 /*MHz*/, 0x01, },
654 { 16 * 450.00 /*MHz*/, 0x02, },
655 { 16 * 999.99 , 0x08, },
659 [TUNER_PHILIPS_FQ1216AME_MK4
] = { /* Philips PAL */
660 .name
= "Philips PAL/SECAM multi (FQ1216AME MK4)",
663 { 16 * 160.00 /*MHz*/, 0x01, },
664 { 16 * 442.00 /*MHz*/, 0x02, },
665 { 16 * 999.99 , 0x04, },
669 [TUNER_PHILIPS_FQ1236A_MK4
] = { /* Philips NTSC */
670 .name
= "Philips FQ1236A MK4",
673 { 16 * 160.00 /*MHz*/, 0x01, },
674 { 16 * 442.00 /*MHz*/, 0x02, },
675 { 16 * 999.99 , 0x04, },
679 [TUNER_YMEC_TVF_8531MF
] = { /* Philips NTSC */
680 .name
= "Ymec TVision TVF-8531MF/8831MF/8731MF",
683 { 16 * 160.00 /*MHz*/, 0xa0, },
684 { 16 * 454.00 /*MHz*/, 0x90, },
685 { 16 * 999.99 , 0x30, },
689 [TUNER_YMEC_TVF_5533MF
] = { /* Philips NTSC */
690 .name
= "Ymec TVision TVF-5533MF",
693 { 16 * 160.00 /*MHz*/, 0x01, },
694 { 16 * 454.00 /*MHz*/, 0x02, },
695 { 16 * 999.99 , 0x04, },
701 [TUNER_THOMSON_DTT761X
] = { /* THOMSON ATSC */
702 /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */
703 .name
= "Thomson DTT 761X (ATSC/NTSC)",
706 { 16 * 145.25 /*MHz*/, 0x39, },
707 { 16 * 415.25 /*MHz*/, 0x3a, },
708 { 16 * 999.99 , 0x3c, },
712 [TUNER_TENA_9533_DI
] = { /* Philips PAL */
713 .name
= "Tena TNF9533-D/IF/TNF9533-B/DF",
716 { 16 * 160.25 /*MHz*/, 0x01, },
717 { 16 * 464.25 /*MHz*/, 0x02, },
718 { 16 * 999.99 , 0x04, },
722 [TUNER_TEA5767
] = { /* Philips RADIO */
723 .name
= "Philips TEA5767HN FM Radio",
724 /* see tea5767.c for details */},
725 [TUNER_PHILIPS_FMD1216ME_MK3
] = { /* Philips PAL */
726 .name
= "Philips FMD1216ME MK3 Hybrid Tuner",
729 { 16 * 160.00 /*MHz*/, 0x51, },
730 { 16 * 442.00 /*MHz*/, 0x52, },
731 { 16 * 999.99 , 0x54, },
735 [TUNER_LG_TDVS_H062F
] = { /* LGINNOTEK ATSC */
736 .name
= "LG TDVS-H062F/TUA6034",
739 { 16 * 160.00 /*MHz*/, 0x01 },
740 { 16 * 455.00 /*MHz*/, 0x02 },
741 { 16 * 999.99 , 0x04 },
745 [TUNER_YMEC_TVF66T5_B_DFF
] = { /* Philips PAL */
746 .name
= "Ymec TVF66T5-B/DFF",
749 { 16 * 160.25 /*MHz*/, 0x01, },
750 { 16 * 464.25 /*MHz*/, 0x02, },
751 { 16 * 999.99 , 0x08, },
755 [TUNER_LG_NTSC_TALN_MINI
] = { /* LGINNOTEK NTSC */
756 .name
= "LG NTSC (TALN mini series)",
759 { 16 * 137.25 /*MHz*/, 0x01, },
760 { 16 * 373.25 /*MHz*/, 0x02, },
761 { 16 * 999.99 , 0x08, },
765 [TUNER_PHILIPS_TD1316
] = { /* Philips PAL */
766 .name
= "Philips TD1316 Hybrid Tuner",
769 { 16 * 160.00 /*MHz*/, 0xa1, },
770 { 16 * 442.00 /*MHz*/, 0xa2, },
771 { 16 * 999.99 , 0xa4, },
775 [TUNER_PHILIPS_TUV1236D
] = { /* Philips ATSC */
776 .name
= "Philips TUV1236D ATSC/NTSC dual in",
779 { 16 * 157.25 /*MHz*/, 0x01, },
780 { 16 * 454.00 /*MHz*/, 0x02, },
781 { 16 * 999.99 , 0x04, },
785 [TUNER_TNF_5335MF
] = { /* Philips NTSC */
786 .name
= "Tena TNF 5335 MF",
789 { 16 * 157.25 /*MHz*/, 0x01, },
790 { 16 * 454.00 /*MHz*/, 0x02, },
791 { 16 * 999.99 , 0x04, },
797 unsigned const int tuner_count
= ARRAY_SIZE(tuners
);
799 /* ---------------------------------------------------------------------- */
801 static int tuner_getstatus(struct i2c_client
*c
)
805 if (1 != i2c_master_recv(c
,&byte
,1))
811 static int tuner_signal(struct i2c_client
*c
)
813 return (tuner_getstatus(c
) & TUNER_SIGNAL
) << 13;
816 static int tuner_stereo(struct i2c_client
*c
)
819 struct tuner
*t
= i2c_get_clientdata(c
);
821 status
= tuner_getstatus (c
);
824 case TUNER_PHILIPS_FM1216ME_MK3
:
825 case TUNER_PHILIPS_FM1236_MK3
:
826 case TUNER_PHILIPS_FM1256_IH3
:
827 stereo
= ((status
& TUNER_SIGNAL
) == TUNER_STEREO_MK3
);
830 stereo
= status
& TUNER_STEREO
;
837 /* ---------------------------------------------------------------------- */
839 static void default_set_tv_freq(struct i2c_client
*c
, unsigned int freq
)
841 struct tuner
*t
= i2c_get_clientdata(c
);
842 u8 config
, tuneraddr
;
844 struct tunertype
*tun
;
845 unsigned char buffer
[4];
848 tun
= &tuners
[t
->type
];
849 for (i
= 0; i
< tun
->count
; i
++) {
850 if (freq
> tun
->ranges
[i
].thresh
)
854 config
= tun
->ranges
[i
].cb
;
855 /* i == 0 -> VHF_LO */
856 /* i == 1 -> VHF_HI */
858 tuner_dbg("tv: range %d\n",i
);
860 /* tv norm specific stuff for multi-norm tuners */
862 case TUNER_PHILIPS_SECAM
: // FI1216MF
863 /* 0x01 -> ??? no change ??? */
864 /* 0x02 -> PAL BDGHI / SECAM L */
865 /* 0x04 -> ??? PAL others / SECAM others ??? */
867 if (t
->std
& V4L2_STD_SECAM
)
871 case TUNER_TEMIC_4046FM5
:
874 if (t
->std
& V4L2_STD_PAL_BG
) {
875 config
|= TEMIC_SET_PAL_BG
;
877 } else if (t
->std
& V4L2_STD_PAL_I
) {
878 config
|= TEMIC_SET_PAL_I
;
880 } else if (t
->std
& V4L2_STD_PAL_DK
) {
881 config
|= TEMIC_SET_PAL_DK
;
883 } else if (t
->std
& V4L2_STD_SECAM_L
) {
884 config
|= TEMIC_SET_PAL_L
;
889 case TUNER_PHILIPS_FQ1216ME
:
892 if (t
->std
& (V4L2_STD_PAL_BG
|V4L2_STD_PAL_DK
)) {
893 config
|= PHILIPS_SET_PAL_BGDK
;
895 } else if (t
->std
& V4L2_STD_PAL_I
) {
896 config
|= PHILIPS_SET_PAL_I
;
898 } else if (t
->std
& V4L2_STD_SECAM_L
) {
899 config
|= PHILIPS_SET_PAL_L
;
904 case TUNER_PHILIPS_ATSC
:
905 /* 0x00 -> ATSC antenna input 1 */
906 /* 0x01 -> ATSC antenna input 2 */
907 /* 0x02 -> NTSC antenna input 1 */
908 /* 0x03 -> NTSC antenna input 2 */
910 if (!(t
->std
& V4L2_STD_ATSC
))
915 case TUNER_MICROTUNE_4042FI5
:
916 /* Set the charge pump for fast tuning */
917 tun
->config
|= TUNER_CHARGE_PUMP
;
920 case TUNER_PHILIPS_TUV1236D
:
921 /* 0x40 -> ATSC antenna input 1 */
922 /* 0x48 -> ATSC antenna input 2 */
923 /* 0x00 -> NTSC antenna input 1 */
924 /* 0x08 -> NTSC antenna input 2 */
930 if (t
->std
& V4L2_STD_ATSC
) {
934 /* set to the correct mode (analog or digital) */
937 if (2 != (rc
= i2c_master_send(c
,&buffer
[0],2)))
938 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc
);
939 if (2 != (rc
= i2c_master_send(c
,&buffer
[2],2)))
940 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc
);
947 * Philips FI1216MK2 remark from specification :
948 * for channel selection involving band switching, and to ensure
949 * smooth tuning to the desired channel without causing
950 * unnecessary charge pump action, it is recommended to consider
951 * the difference between wanted channel frequency and the
952 * current channel frequency. Unnecessary charge pump action
953 * will result in very low tuning voltage which may drive the
954 * oscillator to extreme conditions.
956 * Progfou: specification says to send config data before
957 * frequency in case (wanted frequency < current frequency).
960 /* IFPCoff = Video Intermediate Frequency - Vif:
961 940 =16*58.75 NTSC/J (Japan)
962 732 =16*45.75 M/N STD
963 704 =16*44 ATSC (at DVB code)
965 622.4=16*38.90 B/G D/K I, L STD
966 592 =16*37.00 D China
967 590 =16.36.875 B Australia
968 543.2=16*33.95 L' STD
969 171.2=16*10.70 FM Radio (at set_radio_freq)
972 if (t
->std
== V4L2_STD_NTSC_M_JP
) {
974 } else if ((t
->std
& V4L2_STD_MN
) &&
975 !(t
->std
& ~V4L2_STD_MN
)) {
977 } else if (t
->std
== V4L2_STD_SECAM_LC
) {
983 div
=freq
+ IFPCoff
+ offset
;
985 tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, Offset=%d.%02d MHz, div=%0d\n",
986 freq
/ 16, freq
% 16 * 100 / 16,
987 IFPCoff
/ 16, IFPCoff
% 16 * 100 / 16,
988 offset
/ 16, offset
% 16 * 100 / 16,
991 if (t
->type
== TUNER_PHILIPS_SECAM
&& freq
< t
->freq
) {
992 buffer
[0] = tun
->config
;
994 buffer
[2] = (div
>>8) & 0x7f;
995 buffer
[3] = div
& 0xff;
997 buffer
[0] = (div
>>8) & 0x7f;
998 buffer
[1] = div
& 0xff;
999 buffer
[2] = tun
->config
;
1002 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
1003 buffer
[0],buffer
[1],buffer
[2],buffer
[3]);
1005 if (4 != (rc
= i2c_master_send(c
,buffer
,4)))
1006 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc
);
1008 if (t
->type
== TUNER_MICROTUNE_4042FI5
) {
1009 // FIXME - this may also work for other tuners
1010 unsigned long timeout
= jiffies
+ msecs_to_jiffies(1);
1013 /* Wait until the PLL locks */
1015 if (time_after(jiffies
,timeout
))
1017 if (1 != (rc
= i2c_master_recv(c
,&status_byte
,1))) {
1018 tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc
);
1021 if (status_byte
& TUNER_PLL_LOCKED
)
1026 /* Set the charge pump for optimized phase noise figure */
1027 tun
->config
&= ~TUNER_CHARGE_PUMP
;
1028 buffer
[0] = (div
>>8) & 0x7f;
1029 buffer
[1] = div
& 0xff;
1030 buffer
[2] = tun
->config
;
1032 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
1033 buffer
[0],buffer
[1],buffer
[2],buffer
[3]);
1035 if (4 != (rc
= i2c_master_send(c
,buffer
,4)))
1036 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc
);
1040 static void default_set_radio_freq(struct i2c_client
*c
, unsigned int freq
)
1042 struct tunertype
*tun
;
1043 struct tuner
*t
= i2c_get_clientdata(c
);
1044 unsigned char buffer
[4];
1048 tun
= &tuners
[t
->type
];
1049 div
= (20 * freq
/ 16000) + (int)(20*10.7); /* IF 10.7 MHz */
1050 buffer
[2] = (tun
->config
& ~TUNER_RATIO_MASK
) | TUNER_RATIO_SELECT_50
; /* 50 kHz step */
1053 case TUNER_TENA_9533_DI
:
1054 case TUNER_YMEC_TVF_5533MF
:
1055 tuner_dbg ("This tuner doesn't have FM. Most cards has a TEA5767 for FM\n");
1057 case TUNER_PHILIPS_FM1216ME_MK3
:
1058 case TUNER_PHILIPS_FM1236_MK3
:
1059 case TUNER_PHILIPS_FMD1216ME_MK3
:
1062 case TUNER_PHILIPS_FM1256_IH3
:
1063 div
= (20 * freq
) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */
1066 case TUNER_LG_PAL_FM
:
1069 case TUNER_MICROTUNE_4049FM5
:
1070 div
= (20 * freq
) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */
1077 buffer
[0] = (div
>>8) & 0x7f;
1078 buffer
[1] = div
& 0xff;
1080 tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
1081 buffer
[0],buffer
[1],buffer
[2],buffer
[3]);
1083 if (4 != (rc
= i2c_master_send(c
,buffer
,4)))
1084 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc
);
1087 int default_tuner_init(struct i2c_client
*c
)
1089 struct tuner
*t
= i2c_get_clientdata(c
);
1091 tuner_info("type set to %d (%s)\n",
1092 t
->type
, tuners
[t
->type
].name
);
1093 strlcpy(c
->name
, tuners
[t
->type
].name
, sizeof(c
->name
));
1095 t
->tv_freq
= default_set_tv_freq
;
1096 t
->radio_freq
= default_set_radio_freq
;
1097 t
->has_signal
= tuner_signal
;
1098 t
->is_stereo
= tuner_stereo
;
1105 * Overrides for Emacs so that we follow Linus's tabbing style.
1106 * ---------------------------------------------------------------------------