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 /* ---------------------------------------------------------------------- */
13 /* tv standard selection for Temic 4046 FM5
14 this value takes the low bits of control byte 2
15 from datasheet Rev.01, Feb.00
17 picture IF 38.9 38.9 38.9 33.95 38.9
18 sound 1 33.4 32.9 32.4 40.45 32.4
20 NICAM 33.05 32.348 33.05 33.05
22 #define TEMIC_SET_PAL_I 0x05
23 #define TEMIC_SET_PAL_DK 0x09
24 #define TEMIC_SET_PAL_L 0x0a // SECAM ?
25 #define TEMIC_SET_PAL_L2 0x0b // change IF !
26 #define TEMIC_SET_PAL_BG 0x0c
28 /* tv tuner system standard selection for Philips FQ1216ME
29 this value takes the low bits of control byte 2
30 from datasheet "1999 Nov 16" (supersedes "1999 Mar 23")
32 picture carrier 38.90 38.90 38.90 38.90 33.95
33 colour 34.47 34.47 34.47 34.47 38.38
34 sound 1 33.40 32.40 32.90 32.40 40.45
36 NICAM 33.05 33.05 32.35 33.05 39.80
38 #define PHILIPS_SET_PAL_I 0x01 /* Bit 2 always zero !*/
39 #define PHILIPS_SET_PAL_BGDK 0x09
40 #define PHILIPS_SET_PAL_L2 0x0a
41 #define PHILIPS_SET_PAL_L 0x0b
43 /* system switching for Philips FI1216MF MK2
44 from datasheet "1996 Jul 09",
46 picture carrier 38.90 38.90 33.95
47 colour 34.47 34.37 38.38
48 sound 1 33.40 32.40 40.45
50 NICAM 33.05 33.05 39.80
52 #define PHILIPS_MF_SET_BG 0x01 /* Bit 2 must be zero, Bit 3 is system output */
53 #define PHILIPS_MF_SET_PAL_L 0x03 // France
54 #define PHILIPS_MF_SET_PAL_L2 0x02 // L'
58 #define TUNER_RATIO_MASK 0x06 /* Bit cb1:cb2 */
59 #define TUNER_RATIO_SELECT_50 0x00
60 #define TUNER_RATIO_SELECT_32 0x02
61 #define TUNER_RATIO_SELECT_166 0x04
62 #define TUNER_RATIO_SELECT_62 0x06
64 #define TUNER_CHARGE_PUMP 0x40 /* Bit cb6 */
68 #define TUNER_POR 0x80
70 #define TUNER_MODE 0x38
71 #define TUNER_AFC 0x07
72 #define TUNER_SIGNAL 0x07
73 #define TUNER_STEREO 0x10
75 #define TUNER_PLL_LOCKED 0x40
76 #define TUNER_STEREO_MK3 0x04
78 /* ---------------------------------------------------------------------- */
84 unsigned short thresh1
; /* band switch VHF_LO <=> VHF_HI */
85 unsigned short thresh2
; /* band switch VHF_HI <=> UHF */
93 * The floats in the tuner struct are computed at compile time
94 * by gcc and cast back to integers. Thus we don't violate the
95 * "no float in kernel" rule.
97 static struct tunertype tuners
[] = {
99 [TUNER_TEMIC_PAL
] = { /* TEMIC PAL */
100 .name
= "Temic PAL (4002 FH5)",
101 .thresh1
= 16 * 140.25 /*MHz*/,
102 .thresh2
= 16 * 463.25 /*MHz*/,
108 [TUNER_PHILIPS_PAL_I
] = { /* Philips PAL_I */
109 .name
= "Philips PAL_I (FI1246 and compatibles)",
110 .thresh1
= 16 * 140.25 /*MHz*/,
111 .thresh2
= 16 * 463.25 /*MHz*/,
117 [TUNER_PHILIPS_NTSC
] = { /* Philips NTSC */
118 .name
= "Philips NTSC (FI1236,FM1236 and compatibles)",
119 .thresh1
= 16 * 157.25 /*MHz*/,
120 .thresh2
= 16 * 451.25 /*MHz*/,
126 [TUNER_PHILIPS_SECAM
] = { /* Philips SECAM */
127 .name
= "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)",
128 .thresh1
= 16 * 168.25 /*MHz*/,
129 .thresh2
= 16 * 447.25 /*MHz*/,
135 [TUNER_ABSENT
] = { /* Tuner Absent */
144 [TUNER_PHILIPS_PAL
] = { /* Philips PAL */
145 .name
= "Philips PAL_BG (FI1216 and compatibles)",
146 .thresh1
= 16 * 168.25 /*MHz*/,
147 .thresh2
= 16 * 447.25 /*MHz*/,
153 [TUNER_TEMIC_NTSC
] = { /* TEMIC NTSC */
154 .name
= "Temic NTSC (4032 FY5)",
155 .thresh1
= 16 * 157.25 /*MHz*/,
156 .thresh2
= 16 * 463.25 /*MHz*/,
162 [TUNER_TEMIC_PAL_I
] = { /* TEMIC PAL_I */
163 .name
= "Temic PAL_I (4062 FY5)",
164 .thresh1
= 16 * 170.00 /*MHz*/,
165 .thresh2
= 16 * 450.00 /*MHz*/,
171 [TUNER_TEMIC_4036FY5_NTSC
] = { /* TEMIC NTSC */
172 .name
= "Temic NTSC (4036 FY5)",
173 .thresh1
= 16 * 157.25 /*MHz*/,
174 .thresh2
= 16 * 463.25 /*MHz*/,
180 [TUNER_ALPS_TSBH1_NTSC
] = { /* TEMIC NTSC */
181 .name
= "Alps HSBH1",
182 .thresh1
= 16 * 137.25 /*MHz*/,
183 .thresh2
= 16 * 385.25 /*MHz*/,
191 [TUNER_ALPS_TSBE1_PAL
] = { /* TEMIC PAL */
192 .name
= "Alps TSBE1",
193 .thresh1
= 16 * 137.25 /*MHz*/,
194 .thresh2
= 16 * 385.25 /*MHz*/,
200 [TUNER_ALPS_TSBB5_PAL_I
] = { /* Alps PAL_I */
201 .name
= "Alps TSBB5",
202 .thresh1
= 16 * 133.25 /*MHz*/,
203 .thresh2
= 16 * 351.25 /*MHz*/,
209 [TUNER_ALPS_TSBE5_PAL
] = { /* Alps PAL */
210 .name
= "Alps TSBE5",
211 .thresh1
= 16 * 133.25 /*MHz*/,
212 .thresh2
= 16 * 351.25 /*MHz*/,
218 [TUNER_ALPS_TSBC5_PAL
] = { /* Alps PAL */
219 .name
= "Alps TSBC5",
220 .thresh1
= 16 * 133.25 /*MHz*/,
221 .thresh2
= 16 * 351.25 /*MHz*/,
227 [TUNER_TEMIC_4006FH5_PAL
] = { /* TEMIC PAL */
228 .name
= "Temic PAL_BG (4006FH5)",
229 .thresh1
= 16 * 170.00 /*MHz*/,
230 .thresh2
= 16 * 450.00 /*MHz*/,
236 [TUNER_ALPS_TSHC6_NTSC
] = { /* Alps NTSC */
237 .name
= "Alps TSCH6",
238 .thresh1
= 16 * 137.25 /*MHz*/,
239 .thresh2
= 16 * 385.25 /*MHz*/,
245 [TUNER_TEMIC_PAL_DK
] = { /* TEMIC PAL */
246 .name
= "Temic PAL_DK (4016 FY5)",
247 .thresh1
= 16 * 168.25 /*MHz*/,
248 .thresh2
= 16 * 456.25 /*MHz*/,
254 [TUNER_PHILIPS_NTSC_M
] = { /* Philips NTSC */
255 .name
= "Philips NTSC_M (MK2)",
256 .thresh1
= 16 * 160.00 /*MHz*/,
257 .thresh2
= 16 * 454.00 /*MHz*/,
263 [TUNER_TEMIC_4066FY5_PAL_I
] = { /* TEMIC PAL_I */
264 .name
= "Temic PAL_I (4066 FY5)",
265 .thresh1
= 16 * 169.00 /*MHz*/,
266 .thresh2
= 16 * 454.00 /*MHz*/,
272 [TUNER_TEMIC_4006FN5_MULTI_PAL
] = { /* TEMIC PAL */
273 .name
= "Temic PAL* auto (4006 FN5)",
274 .thresh1
= 16 * 169.00 /*MHz*/,
275 .thresh2
= 16 * 454.00 /*MHz*/,
283 [TUNER_TEMIC_4009FR5_PAL
] = { /* TEMIC PAL */
284 .name
= "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)",
285 .thresh1
= 16 * 141.00 /*MHz*/,
286 .thresh2
= 16 * 464.00 /*MHz*/,
292 [TUNER_TEMIC_4039FR5_NTSC
] = { /* TEMIC NTSC */
293 .name
= "Temic NTSC (4039 FR5)",
294 .thresh1
= 16 * 158.00 /*MHz*/,
295 .thresh2
= 16 * 453.00 /*MHz*/,
301 [TUNER_TEMIC_4046FM5
] = { /* TEMIC PAL */
302 .name
= "Temic PAL/SECAM multi (4046 FM5)",
303 .thresh1
= 16 * 169.00 /*MHz*/,
304 .thresh2
= 16 * 454.00 /*MHz*/,
310 [TUNER_PHILIPS_PAL_DK
] = { /* Philips PAL */
311 .name
= "Philips PAL_DK (FI1256 and compatibles)",
312 .thresh1
= 16 * 170.00 /*MHz*/,
313 .thresh2
= 16 * 450.00 /*MHz*/,
319 [TUNER_PHILIPS_FQ1216ME
] = { /* Philips PAL */
320 .name
= "Philips PAL/SECAM multi (FQ1216ME)",
321 .thresh1
= 16 * 170.00 /*MHz*/,
322 .thresh2
= 16 * 450.00 /*MHz*/,
328 [TUNER_LG_PAL_I_FM
] = { /* LGINNOTEK PAL_I */
329 .name
= "LG PAL_I+FM (TAPC-I001D)",
330 .thresh1
= 16 * 170.00 /*MHz*/,
331 .thresh2
= 16 * 450.00 /*MHz*/,
337 [TUNER_LG_PAL_I
] = { /* LGINNOTEK PAL_I */
338 .name
= "LG PAL_I (TAPC-I701D)",
339 .thresh1
= 16 * 170.00 /*MHz*/,
340 .thresh2
= 16 * 450.00 /*MHz*/,
346 [TUNER_LG_NTSC_FM
] = { /* LGINNOTEK NTSC */
347 .name
= "LG NTSC+FM (TPI8NSR01F)",
348 .thresh1
= 16 * 210.00 /*MHz*/,
349 .thresh2
= 16 * 497.00 /*MHz*/,
355 [TUNER_LG_PAL_FM
] = { /* LGINNOTEK PAL */
356 .name
= "LG PAL_BG+FM (TPI8PSB01D)",
357 .thresh1
= 16 * 170.00 /*MHz*/,
358 .thresh2
= 16 * 450.00 /*MHz*/,
364 [TUNER_LG_PAL
] = { /* LGINNOTEK PAL */
365 .name
= "LG PAL_BG (TPI8PSB11D)",
366 .thresh1
= 16 * 170.00 /*MHz*/,
367 .thresh2
= 16 * 450.00 /*MHz*/,
375 [TUNER_TEMIC_4009FN5_MULTI_PAL_FM
] = { /* TEMIC PAL */
376 .name
= "Temic PAL* auto + FM (4009 FN5)",
377 .thresh1
= 16 * 141.00 /*MHz*/,
378 .thresh2
= 16 * 464.00 /*MHz*/,
384 [TUNER_SHARP_2U5JF5540_NTSC
] = { /* SHARP NTSC */
385 .name
= "SHARP NTSC_JP (2U5JF5540)",
386 .thresh1
= 16 * 137.25 /*MHz*/,
387 .thresh2
= 16 * 317.25 /*MHz*/,
393 [TUNER_Samsung_PAL_TCPM9091PD27
] = { /* Samsung PAL */
394 .name
= "Samsung PAL TCPM9091PD27",
395 .thresh1
= 16 * 169 /*MHz*/,
396 .thresh2
= 16 * 464 /*MHz*/,
402 [TUNER_MT2032
] = { /* Microtune PAL|NTSC */
403 .name
= "MT20xx universal",
404 /* see mt20xx.c for details */ },
405 [TUNER_TEMIC_4106FH5
] = { /* TEMIC PAL */
406 .name
= "Temic PAL_BG (4106 FH5)",
407 .thresh1
= 16 * 141.00 /*MHz*/,
408 .thresh2
= 16 * 464.00 /*MHz*/,
414 [TUNER_TEMIC_4012FY5
] = { /* TEMIC PAL */
415 .name
= "Temic PAL_DK/SECAM_L (4012 FY5)",
416 .thresh1
= 16 * 140.25 /*MHz*/,
417 .thresh2
= 16 * 463.25 /*MHz*/,
423 [TUNER_TEMIC_4136FY5
] = { /* TEMIC NTSC */
424 .name
= "Temic NTSC (4136 FY5)",
425 .thresh1
= 16 * 158.00 /*MHz*/,
426 .thresh2
= 16 * 453.00 /*MHz*/,
432 [TUNER_LG_PAL_NEW_TAPC
] = { /* LGINNOTEK PAL */
433 .name
= "LG PAL (newer TAPC series)",
434 .thresh1
= 16 * 170.00 /*MHz*/,
435 .thresh2
= 16 * 450.00 /*MHz*/,
441 [TUNER_PHILIPS_FM1216ME_MK3
] = { /* Philips PAL */
442 .name
= "Philips PAL/SECAM multi (FM1216ME MK3)",
443 .thresh1
= 16 * 158.00 /*MHz*/,
444 .thresh2
= 16 * 442.00 /*MHz*/,
450 [TUNER_LG_NTSC_NEW_TAPC
] = { /* LGINNOTEK NTSC */
451 .name
= "LG NTSC (newer TAPC series)",
452 .thresh1
= 16 * 170.00 /*MHz*/,
453 .thresh2
= 16 * 450.00 /*MHz*/,
461 [TUNER_HITACHI_NTSC
] = { /* HITACHI NTSC */
462 .name
= "HITACHI V7-J180AT",
463 .thresh1
= 16 * 170.00 /*MHz*/,
464 .thresh2
= 16 * 450.00 /*MHz*/,
470 [TUNER_PHILIPS_PAL_MK
] = { /* Philips PAL */
471 .name
= "Philips PAL_MK (FI1216 MK)",
472 .thresh1
= 16 * 140.25 /*MHz*/,
473 .thresh2
= 16 * 463.25 /*MHz*/,
479 [TUNER_PHILIPS_ATSC
] = { /* Philips ATSC */
480 .name
= "Philips 1236D ATSC/NTSC daul in",
481 .thresh1
= 16 * 157.25 /*MHz*/,
482 .thresh2
= 16 * 454.00 /*MHz*/,
488 [TUNER_PHILIPS_FM1236_MK3
] = { /* Philips NTSC */
489 .name
= "Philips NTSC MK3 (FM1236MK3 or FM1236/F)",
490 .thresh1
= 16 * 160.00 /*MHz*/,
491 .thresh2
= 16 * 442.00 /*MHz*/,
497 [TUNER_PHILIPS_4IN1
] = { /* Philips NTSC */
498 .name
= "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)",
499 .thresh1
= 16 * 160.00 /*MHz*/,
500 .thresh2
= 16 * 442.00 /*MHz*/,
506 [TUNER_MICROTUNE_4049FM5
] = { /* Microtune PAL */
507 .name
= "Microtune 4049 FM5",
508 .thresh1
= 16 * 141.00 /*MHz*/,
509 .thresh2
= 16 * 464.00 /*MHz*/,
515 [TUNER_MICROTUNE_4042_FI5
] = { /* Panasonic NTSC */
516 .name
= "Panasonic VP27s/ENGE4324D",
517 .thresh1
= 16 * 160.00 /*MHz*/,
518 .thresh2
= 16 * 454.00 /*MHz*/,
524 [TUNER_LG_NTSC_TAPE
] = { /* LGINNOTEK NTSC */
525 .name
= "LG NTSC (TAPE series)",
526 .thresh1
= 16 * 160.00 /*MHz*/,
527 .thresh2
= 16 * 442.00 /*MHz*/,
533 [TUNER_TNF_8831BGFF
] = { /* Philips PAL */
534 .name
= "Tenna TNF 8831 BGFF)",
535 .thresh1
= 16 * 161.25 /*MHz*/,
536 .thresh2
= 16 * 463.25 /*MHz*/,
542 [TUNER_MICROTUNE_4042FI5
] = { /* Microtune NTSC */
543 .name
= "Microtune 4042 FI5 ATSC/NTSC dual in",
544 .thresh1
= 16 * 162.00 /*MHz*/,
545 .thresh2
= 16 * 457.00 /*MHz*/,
553 [TUNER_TCL_2002N
] = { /* TCL NTSC */
555 .thresh1
= 16 * 172.00 /*MHz*/,
556 .thresh2
= 16 * 448.00 /*MHz*/,
562 [TUNER_PHILIPS_FM1256_IH3
] = { /* Philips PAL */
563 .name
= "Philips PAL/SECAM_D (FM 1256 I-H3)",
564 .thresh1
= 16 * 160.00 /*MHz*/,
565 .thresh2
= 16 * 442.00 /*MHz*/,
571 [TUNER_THOMSON_DTT7610
] = { /* THOMSON ATSC */
572 .name
= "Thomson DDT 7610 (ATSC/NTSC)",
573 .thresh1
= 16 * 157.25 /*MHz*/,
574 .thresh2
= 16 * 454.00 /*MHz*/,
580 [TUNER_PHILIPS_FQ1286
] = { /* Philips NTSC */
581 .name
= "Philips FQ1286",
582 .thresh1
= 16 * 160.00 /*MHz*/,
583 .thresh2
= 16 * 454.00 /*MHz*/,
589 [TUNER_PHILIPS_TDA8290
] = { /* Philips PAL|NTSC */
590 .name
= "tda8290+75",
591 /* see tda8290.c for details */ },
592 [TUNER_TCL_2002MB
] = { /* TCL PAL */
593 .name
= "TCL 2002MB",
594 .thresh1
= 16 * 170.00 /*MHz*/,
595 .thresh2
= 16 * 450.00 /*MHz*/,
601 [TUNER_PHILIPS_FQ1216AME_MK4
] = { /* Philips PAL */
602 .name
= "Philips PAL/SECAM multi (FQ1216AME MK4)",
603 .thresh1
= 16 * 160.00 /*MHz*/,
604 .thresh2
= 16 * 442.00 /*MHz*/,
610 [TUNER_PHILIPS_FQ1236A_MK4
] = { /* Philips NTSC */
611 .name
= "Philips FQ1236A MK4",
612 .thresh1
= 16 * 160.00 /*MHz*/,
613 .thresh2
= 16 * 442.00 /*MHz*/,
619 [TUNER_YMEC_TVF_8531MF
] = { /* Philips NTSC */
620 .name
= "Ymec TVision TVF-8531MF/8831MF/8731MF",
621 .thresh1
= 16 * 160.00 /*MHz*/,
622 .thresh2
= 16 * 454.00 /*MHz*/,
628 [TUNER_YMEC_TVF_5533MF
] = { /* Philips NTSC */
629 .name
= "Ymec TVision TVF-5533MF",
630 .thresh1
= 16 * 160.00 /*MHz*/,
631 .thresh2
= 16 * 454.00 /*MHz*/,
639 [TUNER_THOMSON_DTT7611
] = { /* THOMSON ATSC */
640 .name
= "Thomson DDT 7611 (ATSC/NTSC)",
641 .thresh1
= 16 * 157.25 /*MHz*/,
642 .thresh2
= 16 * 454.00 /*MHz*/,
648 [TUNER_TENA_9533_DI
] = { /* Philips PAL */
649 .name
= "Tena TNF9533-D/IF/TNF9533-B/DF",
650 .thresh1
= 16 * 160.25 /*MHz*/,
651 .thresh2
= 16 * 464.25 /*MHz*/,
657 [TUNER_TEA5767
] = { /* Philips RADIO */
658 .name
= "Philips TEA5767HN FM Radio",
659 /* see tea5767.c for details */},
660 [TUNER_PHILIPS_FMD1216ME_MK3
] = { /* Philips PAL */
661 .name
= "Philips FMD1216ME MK3 Hybrid Tuner",
662 .thresh1
= 16 * 160.00 /*MHz*/,
663 .thresh2
= 16 * 442.00 /*MHz*/,
669 [TUNER_LG_TDVS_H062F
] = { /* LGINNOTEK ATSC */
670 .name
= "LG TDVS-H062F/TUA6034",
671 .thresh1
= 16 * 160.00 /*MHz*/,
672 .thresh2
= 16 * 455.00 /*MHz*/,
678 [TUNER_YMEC_TVF66T5_B_DFF
] = { /* Philips PAL */
679 .name
= "Ymec TVF66T5-B/DFF",
680 .thresh1
= 16 * 160.25 /*MHz*/,
681 .thresh2
= 16 * 464.25 /*MHz*/,
687 [TUNER_LG_NTSC_TALN_MINI
] = { /* LGINNOTEK NTSC */
688 .name
= "LG NTSC (TALN mini series)",
689 .thresh1
= 16 * 137.25 /*MHz*/,
690 .thresh2
= 16 * 373.25 /*MHz*/,
696 [TUNER_PHILIPS_TD1316
] = { /* Philips PAL */
697 .name
= "Philips TD1316 Hybrid Tuner",
698 .thresh1
= 16 * 160.00 /*MHz*/,
699 .thresh2
= 16 * 442.00 /*MHz*/,
705 [TUNER_PHILIPS_TUV1236D
] = { /* Philips ATSC */
706 .name
= "Philips TUV1236D ATSC/NTSC dual in",
707 .thresh1
= 16 * 157.25 /*MHz*/,
708 .thresh2
= 16 * 454.00 /*MHz*/,
714 [TUNER_TNF_5335MF
] = { /* Philips NTSC */
715 .name
= "Tena TNF 5335 MF",
716 .thresh1
= 16 * 157.25 /*MHz*/,
717 .thresh2
= 16 * 454.00 /*MHz*/,
725 unsigned const int tuner_count
= ARRAY_SIZE(tuners
);
727 /* ---------------------------------------------------------------------- */
729 static int tuner_getstatus(struct i2c_client
*c
)
733 if (1 != i2c_master_recv(c
,&byte
,1))
739 static int tuner_signal(struct i2c_client
*c
)
741 return (tuner_getstatus(c
) & TUNER_SIGNAL
) << 13;
744 static int tuner_stereo(struct i2c_client
*c
)
747 struct tuner
*t
= i2c_get_clientdata(c
);
749 status
= tuner_getstatus (c
);
752 case TUNER_PHILIPS_FM1216ME_MK3
:
753 case TUNER_PHILIPS_FM1236_MK3
:
754 case TUNER_PHILIPS_FM1256_IH3
:
755 stereo
= ((status
& TUNER_SIGNAL
) == TUNER_STEREO_MK3
);
758 stereo
= status
& TUNER_STEREO
;
765 /* ---------------------------------------------------------------------- */
767 static void default_set_tv_freq(struct i2c_client
*c
, unsigned int freq
)
769 struct tuner
*t
= i2c_get_clientdata(c
);
770 u8 config
, tuneraddr
;
772 struct tunertype
*tun
;
773 unsigned char buffer
[4];
776 tun
= &tuners
[t
->type
];
777 if (freq
< tun
->thresh1
) {
779 tuner_dbg("tv: VHF lowrange\n");
780 } else if (freq
< tun
->thresh2
) {
782 tuner_dbg("tv: VHF high range\n");
785 tuner_dbg("tv: UHF range\n");
789 /* tv norm specific stuff for multi-norm tuners */
791 case TUNER_PHILIPS_SECAM
: // FI1216MF
792 /* 0x01 -> ??? no change ??? */
793 /* 0x02 -> PAL BDGHI / SECAM L */
794 /* 0x04 -> ??? PAL others / SECAM others ??? */
796 if (t
->std
& V4L2_STD_SECAM
)
800 case TUNER_TEMIC_4046FM5
:
803 if (t
->std
& V4L2_STD_PAL_BG
) {
804 config
|= TEMIC_SET_PAL_BG
;
806 } else if (t
->std
& V4L2_STD_PAL_I
) {
807 config
|= TEMIC_SET_PAL_I
;
809 } else if (t
->std
& V4L2_STD_PAL_DK
) {
810 config
|= TEMIC_SET_PAL_DK
;
812 } else if (t
->std
& V4L2_STD_SECAM_L
) {
813 config
|= TEMIC_SET_PAL_L
;
818 case TUNER_PHILIPS_FQ1216ME
:
821 if (t
->std
& (V4L2_STD_PAL_BG
|V4L2_STD_PAL_DK
)) {
822 config
|= PHILIPS_SET_PAL_BGDK
;
824 } else if (t
->std
& V4L2_STD_PAL_I
) {
825 config
|= PHILIPS_SET_PAL_I
;
827 } else if (t
->std
& V4L2_STD_SECAM_L
) {
828 config
|= PHILIPS_SET_PAL_L
;
833 case TUNER_PHILIPS_ATSC
:
834 /* 0x00 -> ATSC antenna input 1 */
835 /* 0x01 -> ATSC antenna input 2 */
836 /* 0x02 -> NTSC antenna input 1 */
837 /* 0x03 -> NTSC antenna input 2 */
839 if (!(t
->std
& V4L2_STD_ATSC
))
844 case TUNER_MICROTUNE_4042FI5
:
845 /* Set the charge pump for fast tuning */
846 tun
->config
|= TUNER_CHARGE_PUMP
;
849 case TUNER_PHILIPS_TUV1236D
:
850 /* 0x40 -> ATSC antenna input 1 */
851 /* 0x48 -> ATSC antenna input 2 */
852 /* 0x00 -> NTSC antenna input 1 */
853 /* 0x08 -> NTSC antenna input 2 */
859 if (t
->std
& V4L2_STD_ATSC
) {
863 /* set to the correct mode (analog or digital) */
866 if (2 != (rc
= i2c_master_send(c
,&buffer
[0],2)))
867 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc
);
868 if (2 != (rc
= i2c_master_send(c
,&buffer
[2],2)))
869 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc
);
876 * Philips FI1216MK2 remark from specification :
877 * for channel selection involving band switching, and to ensure
878 * smooth tuning to the desired channel without causing
879 * unnecessary charge pump action, it is recommended to consider
880 * the difference between wanted channel frequency and the
881 * current channel frequency. Unnecessary charge pump action
882 * will result in very low tuning voltage which may drive the
883 * oscillator to extreme conditions.
885 * Progfou: specification says to send config data before
886 * frequency in case (wanted frequency < current frequency).
889 /* IFPCoff = Video Intermediate Frequency - Vif:
890 940 =16*58.75 NTSC/J (Japan)
891 732 =16*45.75 M/N STD
892 704 =16*44 ATSC (at DVB code)
894 622.4=16*38.90 B/G D/K I, L STD
895 592 =16*37.00 D China
896 590 =16.36.875 B Australia
897 543.2=16*33.95 L' STD
898 171.2=16*10.70 FM Radio (at set_radio_freq)
901 if (t
->std
& V4L2_STD_NTSC_M_JP
) {
903 } else if (t
->std
& V4L2_STD_MN
) {
905 } else if (t
->std
& V4L2_STD_SECAM_LC
) {
912 if (t
->type
== TUNER_PHILIPS_SECAM
&& freq
< t
->freq
) {
913 buffer
[0] = tun
->config
;
915 buffer
[2] = (div
>>8) & 0x7f;
916 buffer
[3] = div
& 0xff;
918 buffer
[0] = (div
>>8) & 0x7f;
919 buffer
[1] = div
& 0xff;
920 buffer
[2] = tun
->config
;
923 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
924 buffer
[0],buffer
[1],buffer
[2],buffer
[3]);
926 if (4 != (rc
= i2c_master_send(c
,buffer
,4)))
927 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc
);
929 if (t
->type
== TUNER_MICROTUNE_4042FI5
) {
930 // FIXME - this may also work for other tuners
931 unsigned long timeout
= jiffies
+ msecs_to_jiffies(1);
934 /* Wait until the PLL locks */
936 if (time_after(jiffies
,timeout
))
938 if (1 != (rc
= i2c_master_recv(c
,&status_byte
,1))) {
939 tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc
);
942 if (status_byte
& TUNER_PLL_LOCKED
)
947 /* Set the charge pump for optimized phase noise figure */
948 tun
->config
&= ~TUNER_CHARGE_PUMP
;
949 buffer
[0] = (div
>>8) & 0x7f;
950 buffer
[1] = div
& 0xff;
951 buffer
[2] = tun
->config
;
953 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
954 buffer
[0],buffer
[1],buffer
[2],buffer
[3]);
956 if (4 != (rc
= i2c_master_send(c
,buffer
,4)))
957 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc
);
961 static void default_set_radio_freq(struct i2c_client
*c
, unsigned int freq
)
963 struct tunertype
*tun
;
964 struct tuner
*t
= i2c_get_clientdata(c
);
965 unsigned char buffer
[4];
969 tun
= &tuners
[t
->type
];
970 div
= (20 * freq
/ 16000) + (int)(20*10.7); /* IF 10.7 MHz */
971 buffer
[2] = (tun
->config
& ~TUNER_RATIO_MASK
) | TUNER_RATIO_SELECT_50
; /* 50 kHz step */
974 case TUNER_TENA_9533_DI
:
975 case TUNER_YMEC_TVF_5533MF
:
976 tuner_dbg ("This tuner doesn't have FM. Most cards has a TEA5767 for FM\n");
978 case TUNER_PHILIPS_FM1216ME_MK3
:
979 case TUNER_PHILIPS_FM1236_MK3
:
980 case TUNER_PHILIPS_FMD1216ME_MK3
:
983 case TUNER_PHILIPS_FM1256_IH3
:
984 div
= (20 * freq
) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */
987 case TUNER_LG_PAL_FM
:
990 case TUNER_MICROTUNE_4049FM5
:
991 div
= (20 * freq
) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */
998 buffer
[0] = (div
>>8) & 0x7f;
999 buffer
[1] = div
& 0xff;
1001 tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
1002 buffer
[0],buffer
[1],buffer
[2],buffer
[3]);
1004 if (4 != (rc
= i2c_master_send(c
,buffer
,4)))
1005 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc
);
1008 int default_tuner_init(struct i2c_client
*c
)
1010 struct tuner
*t
= i2c_get_clientdata(c
);
1012 tuner_info("type set to %d (%s)\n",
1013 t
->type
, tuners
[t
->type
].name
);
1014 strlcpy(c
->name
, tuners
[t
->type
].name
, sizeof(c
->name
));
1016 t
->tv_freq
= default_set_tv_freq
;
1017 t
->radio_freq
= default_set_radio_freq
;
1018 t
->has_signal
= tuner_signal
;
1019 t
->is_stereo
= tuner_stereo
;
1026 * Overrides for Emacs so that we follow Linus's tabbing style.
1027 * ---------------------------------------------------------------------------