tuner-simple.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. /*
  2. * $Id: tuner-simple.c,v 1.31 2005/06/21 16:02:25 mkrufky Exp $
  3. *
  4. * i2c tv tuner chip device driver
  5. * controls all those simple 4-control-bytes style tuners.
  6. */
  7. #include <linux/delay.h>
  8. #include <linux/i2c.h>
  9. #include <linux/videodev.h>
  10. #include <media/tuner.h>
  11. /* ---------------------------------------------------------------------- */
  12. /* tv standard selection for Temic 4046 FM5
  13. this value takes the low bits of control byte 2
  14. from datasheet Rev.01, Feb.00
  15. standard BG I L L2 D
  16. picture IF 38.9 38.9 38.9 33.95 38.9
  17. sound 1 33.4 32.9 32.4 40.45 32.4
  18. sound 2 33.16
  19. NICAM 33.05 32.348 33.05 33.05
  20. */
  21. #define TEMIC_SET_PAL_I 0x05
  22. #define TEMIC_SET_PAL_DK 0x09
  23. #define TEMIC_SET_PAL_L 0x0a // SECAM ?
  24. #define TEMIC_SET_PAL_L2 0x0b // change IF !
  25. #define TEMIC_SET_PAL_BG 0x0c
  26. /* tv tuner system standard selection for Philips FQ1216ME
  27. this value takes the low bits of control byte 2
  28. from datasheet "1999 Nov 16" (supersedes "1999 Mar 23")
  29. standard BG DK I L L`
  30. picture carrier 38.90 38.90 38.90 38.90 33.95
  31. colour 34.47 34.47 34.47 34.47 38.38
  32. sound 1 33.40 32.40 32.90 32.40 40.45
  33. sound 2 33.16 - - - -
  34. NICAM 33.05 33.05 32.35 33.05 39.80
  35. */
  36. #define PHILIPS_SET_PAL_I 0x01 /* Bit 2 always zero !*/
  37. #define PHILIPS_SET_PAL_BGDK 0x09
  38. #define PHILIPS_SET_PAL_L2 0x0a
  39. #define PHILIPS_SET_PAL_L 0x0b
  40. /* system switching for Philips FI1216MF MK2
  41. from datasheet "1996 Jul 09",
  42. standard BG L L'
  43. picture carrier 38.90 38.90 33.95
  44. colour 34.47 34.37 38.38
  45. sound 1 33.40 32.40 40.45
  46. sound 2 33.16 - -
  47. NICAM 33.05 33.05 39.80
  48. */
  49. #define PHILIPS_MF_SET_BG 0x01 /* Bit 2 must be zero, Bit 3 is system output */
  50. #define PHILIPS_MF_SET_PAL_L 0x03 // France
  51. #define PHILIPS_MF_SET_PAL_L2 0x02 // L'
  52. /* ---------------------------------------------------------------------- */
  53. struct tunertype
  54. {
  55. char *name;
  56. unsigned char Vendor;
  57. unsigned char Type;
  58. unsigned short thresh1; /* band switch VHF_LO <=> VHF_HI */
  59. unsigned short thresh2; /* band switch VHF_HI <=> UHF */
  60. unsigned char VHF_L;
  61. unsigned char VHF_H;
  62. unsigned char UHF;
  63. unsigned char config;
  64. unsigned short IFPCoff; /* 622.4=16*38.90 MHz PAL,
  65. 732 =16*45.75 NTSCi,
  66. 940 =16*58.75 NTSC-Japan
  67. 704 =16*44 ATSC */
  68. };
  69. /*
  70. * The floats in the tuner struct are computed at compile time
  71. * by gcc and cast back to integers. Thus we don't violate the
  72. * "no float in kernel" rule.
  73. */
  74. static struct tunertype tuners[] = {
  75. { "Temic PAL (4002 FH5)", TEMIC, PAL,
  76. 16*140.25,16*463.25,0x02,0x04,0x01,0x8e,623},
  77. { "Philips PAL_I (FI1246 and compatibles)", Philips, PAL_I,
  78. 16*140.25,16*463.25,0xa0,0x90,0x30,0x8e,623},
  79. { "Philips NTSC (FI1236,FM1236 and compatibles)", Philips, NTSC,
  80. 16*157.25,16*451.25,0xA0,0x90,0x30,0x8e,732},
  81. { "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)", Philips, SECAM,
  82. 16*168.25,16*447.25,0xA7,0x97,0x37,0x8e,623},
  83. { "NoTuner", NoTuner, NOTUNER,
  84. 0,0,0x00,0x00,0x00,0x00,0x00},
  85. { "Philips PAL_BG (FI1216 and compatibles)", Philips, PAL,
  86. 16*168.25,16*447.25,0xA0,0x90,0x30,0x8e,623},
  87. { "Temic NTSC (4032 FY5)", TEMIC, NTSC,
  88. 16*157.25,16*463.25,0x02,0x04,0x01,0x8e,732},
  89. { "Temic PAL_I (4062 FY5)", TEMIC, PAL_I,
  90. 16*170.00,16*450.00,0x02,0x04,0x01,0x8e,623},
  91. { "Temic NTSC (4036 FY5)", TEMIC, NTSC,
  92. 16*157.25,16*463.25,0xa0,0x90,0x30,0x8e,732},
  93. { "Alps HSBH1", TEMIC, NTSC,
  94. 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732},
  95. { "Alps TSBE1",TEMIC,PAL,
  96. 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732},
  97. { "Alps TSBB5", Alps, PAL_I, /* tested (UK UHF) with Modulartech MM205 */
  98. 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,632},
  99. { "Alps TSBE5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */
  100. 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,622},
  101. { "Alps TSBC5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */
  102. 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,608},
  103. { "Temic PAL_BG (4006FH5)", TEMIC, PAL,
  104. 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
  105. { "Alps TSCH6",Alps,NTSC,
  106. 16*137.25,16*385.25,0x14,0x12,0x11,0x8e,732},
  107. { "Temic PAL_DK (4016 FY5)",TEMIC,PAL,
  108. 16*168.25,16*456.25,0xa0,0x90,0x30,0x8e,623},
  109. { "Philips NTSC_M (MK2)",Philips,NTSC,
  110. 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732},
  111. { "Temic PAL_I (4066 FY5)", TEMIC, PAL_I,
  112. 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623},
  113. { "Temic PAL* auto (4006 FN5)", TEMIC, PAL,
  114. 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623},
  115. { "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)", TEMIC, PAL,
  116. 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
  117. { "Temic NTSC (4039 FR5)", TEMIC, NTSC,
  118. 16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732},
  119. { "Temic PAL/SECAM multi (4046 FM5)", TEMIC, PAL,
  120. 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623},
  121. { "Philips PAL_DK (FI1256 and compatibles)", Philips, PAL,
  122. 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
  123. { "Philips PAL/SECAM multi (FQ1216ME)", Philips, PAL,
  124. 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
  125. { "LG PAL_I+FM (TAPC-I001D)", LGINNOTEK, PAL_I,
  126. 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
  127. { "LG PAL_I (TAPC-I701D)", LGINNOTEK, PAL_I,
  128. 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
  129. { "LG NTSC+FM (TPI8NSR01F)", LGINNOTEK, NTSC,
  130. 16*210.00,16*497.00,0xa0,0x90,0x30,0x8e,732},
  131. { "LG PAL_BG+FM (TPI8PSB01D)", LGINNOTEK, PAL,
  132. 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
  133. { "LG PAL_BG (TPI8PSB11D)", LGINNOTEK, PAL,
  134. 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
  135. { "Temic PAL* auto + FM (4009 FN5)", TEMIC, PAL,
  136. 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
  137. { "SHARP NTSC_JP (2U5JF5540)", SHARP, NTSC, /* 940=16*58.75 NTSC@Japan */
  138. 16*137.25,16*317.25,0x01,0x02,0x08,0x8e,940 },
  139. { "Samsung PAL TCPM9091PD27", Samsung, PAL, /* from sourceforge v3tv */
  140. 16*169,16*464,0xA0,0x90,0x30,0x8e,623},
  141. { "MT20xx universal", Microtune,PAL|NTSC,
  142. /* see mt20xx.c for details */ },
  143. { "Temic PAL_BG (4106 FH5)", TEMIC, PAL,
  144. 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
  145. { "Temic PAL_DK/SECAM_L (4012 FY5)", TEMIC, PAL,
  146. 16*140.25, 16*463.25, 0x02,0x04,0x01,0x8e,623},
  147. { "Temic NTSC (4136 FY5)", TEMIC, NTSC,
  148. 16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732},
  149. { "LG PAL (newer TAPC series)", LGINNOTEK, PAL,
  150. 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,623},
  151. { "Philips PAL/SECAM multi (FM1216ME MK3)", Philips, PAL,
  152. 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 },
  153. { "LG NTSC (newer TAPC series)", LGINNOTEK, NTSC,
  154. 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,732},
  155. { "HITACHI V7-J180AT", HITACHI, NTSC,
  156. 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,940 },
  157. { "Philips PAL_MK (FI1216 MK)", Philips, PAL,
  158. 16*140.25,16*463.25,0x01,0xc2,0xcf,0x8e,623},
  159. { "Philips 1236D ATSC/NTSC daul in",Philips,ATSC,
  160. 16*157.25,16*454.00,0xa0,0x90,0x30,0x8e,732},
  161. { "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", Philips, NTSC,
  162. 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732},
  163. { "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", Philips, NTSC,
  164. 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732},
  165. { "Microtune 4049 FM5",Microtune,PAL,
  166. 16*141.00,16*464.00,0xa0,0x90,0x30,0x8e,623},
  167. { "Panasonic VP27s/ENGE4324D", Panasonic, NTSC,
  168. 16*160.00,16*454.00,0x01,0x02,0x08,0xce,940},
  169. { "LG NTSC (TAPE series)", LGINNOTEK, NTSC,
  170. 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 },
  171. { "Tenna TNF 8831 BGFF)", Philips, PAL,
  172. 16*161.25,16*463.25,0xa0,0x90,0x30,0x8e,623},
  173. { "Microtune 4042 FI5 ATSC/NTSC dual in", Microtune, NTSC,
  174. 16*162.00,16*457.00,0xa2,0x94,0x31,0x8e,732},
  175. { "TCL 2002N", TCL, NTSC,
  176. 16*172.00,16*448.00,0x01,0x02,0x08,0x8e,732},
  177. { "Philips PAL/SECAM_D (FM 1256 I-H3)", Philips, PAL,
  178. 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 },
  179. { "Thomson DDT 7610 (ATSC/NTSC)", THOMSON, ATSC,
  180. 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732},
  181. { "Philips FQ1286", Philips, NTSC,
  182. 16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, // UHF band untested
  183. { "tda8290+75", Philips,PAL|NTSC,
  184. /* see tda8290.c for details */ },
  185. { "LG PAL (TAPE series)", LGINNOTEK, PAL,
  186. 16*170.00, 16*450.00, 0x01,0x02,0x08,0xce,623},
  187. { "Philips PAL/SECAM multi (FQ1216AME MK4)", Philips, PAL,
  188. 16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 },
  189. { "Philips FQ1236A MK4", Philips, NTSC,
  190. 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 },
  191. /* Should work for TVF8531MF, TVF8831MF, TVF8731MF */
  192. { "Ymec TVision TVF-8531MF", Philips, NTSC,
  193. 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732},
  194. { "Ymec TVision TVF-5533MF", Philips, NTSC,
  195. 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732},
  196. { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC,
  197. 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732},
  198. /* Should work for TNF9533-D/IF, TNF9533-B/DF */
  199. { "Tena TNF9533-D/IF", Philips, PAL,
  200. 16*160.25,16*464.25,0x01,0x02,0x04,0x8e,623},
  201. /* This entry is for TEA5767 FM radio only chip used on several boards w/TV tuner */
  202. { TEA5767_TUNER_NAME, Philips, RADIO,
  203. -1, -1, 0, 0, 0, TEA5767_LOW_LO_32768,0},
  204. { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL,
  205. 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 },
  206. };
  207. unsigned const int tuner_count = ARRAY_SIZE(tuners);
  208. /* ---------------------------------------------------------------------- */
  209. static int tuner_getstatus(struct i2c_client *c)
  210. {
  211. unsigned char byte;
  212. if (1 != i2c_master_recv(c,&byte,1))
  213. return 0;
  214. return byte;
  215. }
  216. #define TUNER_POR 0x80
  217. #define TUNER_FL 0x40
  218. #define TUNER_MODE 0x38
  219. #define TUNER_AFC 0x07
  220. #define TUNER_STEREO 0x10 /* radio mode */
  221. #define TUNER_STEREO_MK3 0x04 /* radio mode */
  222. #define TUNER_SIGNAL 0x07 /* radio mode */
  223. static int tuner_signal(struct i2c_client *c)
  224. {
  225. return (tuner_getstatus(c) & TUNER_SIGNAL) << 13;
  226. }
  227. static int tuner_stereo(struct i2c_client *c)
  228. {
  229. int stereo, status;
  230. struct tuner *t = i2c_get_clientdata(c);
  231. status = tuner_getstatus (c);
  232. switch (t->type) {
  233. case TUNER_PHILIPS_FM1216ME_MK3:
  234. case TUNER_PHILIPS_FM1236_MK3:
  235. case TUNER_PHILIPS_FM1256_IH3:
  236. stereo = ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
  237. break;
  238. default:
  239. stereo = status & TUNER_STEREO;
  240. }
  241. return stereo;
  242. }
  243. #if 0 /* unused */
  244. static int tuner_islocked (struct i2c_client *c)
  245. {
  246. return (tuner_getstatus (c) & TUNER_FL);
  247. }
  248. static int tuner_afcstatus (struct i2c_client *c)
  249. {
  250. return (tuner_getstatus (c) & TUNER_AFC) - 2;
  251. }
  252. static int tuner_mode (struct i2c_client *c)
  253. {
  254. return (tuner_getstatus (c) & TUNER_MODE) >> 3;
  255. }
  256. #endif
  257. /* ---------------------------------------------------------------------- */
  258. static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
  259. {
  260. struct tuner *t = i2c_get_clientdata(c);
  261. u8 config;
  262. u16 div;
  263. struct tunertype *tun;
  264. unsigned char buffer[4];
  265. int rc;
  266. tun = &tuners[t->type];
  267. if (freq < tun->thresh1) {
  268. config = tun->VHF_L;
  269. tuner_dbg("tv: VHF lowrange\n");
  270. } else if (freq < tun->thresh2) {
  271. config = tun->VHF_H;
  272. tuner_dbg("tv: VHF high range\n");
  273. } else {
  274. config = tun->UHF;
  275. tuner_dbg("tv: UHF range\n");
  276. }
  277. /* tv norm specific stuff for multi-norm tuners */
  278. switch (t->type) {
  279. case TUNER_PHILIPS_SECAM: // FI1216MF
  280. /* 0x01 -> ??? no change ??? */
  281. /* 0x02 -> PAL BDGHI / SECAM L */
  282. /* 0x04 -> ??? PAL others / SECAM others ??? */
  283. config &= ~0x02;
  284. if (t->std & V4L2_STD_SECAM)
  285. config |= 0x02;
  286. break;
  287. case TUNER_TEMIC_4046FM5:
  288. config &= ~0x0f;
  289. if (t->std & V4L2_STD_PAL_BG) {
  290. config |= TEMIC_SET_PAL_BG;
  291. } else if (t->std & V4L2_STD_PAL_I) {
  292. config |= TEMIC_SET_PAL_I;
  293. } else if (t->std & V4L2_STD_PAL_DK) {
  294. config |= TEMIC_SET_PAL_DK;
  295. } else if (t->std & V4L2_STD_SECAM_L) {
  296. config |= TEMIC_SET_PAL_L;
  297. }
  298. break;
  299. case TUNER_PHILIPS_FQ1216ME:
  300. config &= ~0x0f;
  301. if (t->std & (V4L2_STD_PAL_BG|V4L2_STD_PAL_DK)) {
  302. config |= PHILIPS_SET_PAL_BGDK;
  303. } else if (t->std & V4L2_STD_PAL_I) {
  304. config |= PHILIPS_SET_PAL_I;
  305. } else if (t->std & V4L2_STD_SECAM_L) {
  306. config |= PHILIPS_SET_PAL_L;
  307. }
  308. break;
  309. case TUNER_PHILIPS_ATSC:
  310. /* 0x00 -> ATSC antenna input 1 */
  311. /* 0x01 -> ATSC antenna input 2 */
  312. /* 0x02 -> NTSC antenna input 1 */
  313. /* 0x03 -> NTSC antenna input 2 */
  314. config &= ~0x03;
  315. if (!(t->std & V4L2_STD_ATSC))
  316. config |= 2;
  317. /* FIXME: input */
  318. break;
  319. case TUNER_MICROTUNE_4042FI5:
  320. /* Set the charge pump for fast tuning */
  321. tun->config |= 0x40;
  322. break;
  323. }
  324. /*
  325. * Philips FI1216MK2 remark from specification :
  326. * for channel selection involving band switching, and to ensure
  327. * smooth tuning to the desired channel without causing
  328. * unnecessary charge pump action, it is recommended to consider
  329. * the difference between wanted channel frequency and the
  330. * current channel frequency. Unnecessary charge pump action
  331. * will result in very low tuning voltage which may drive the
  332. * oscillator to extreme conditions.
  333. *
  334. * Progfou: specification says to send config data before
  335. * frequency in case (wanted frequency < current frequency).
  336. */
  337. div=freq + tun->IFPCoff;
  338. if (t->type == TUNER_PHILIPS_SECAM && freq < t->freq) {
  339. buffer[0] = tun->config;
  340. buffer[1] = config;
  341. buffer[2] = (div>>8) & 0x7f;
  342. buffer[3] = div & 0xff;
  343. } else {
  344. buffer[0] = (div>>8) & 0x7f;
  345. buffer[1] = div & 0xff;
  346. buffer[2] = tun->config;
  347. buffer[3] = config;
  348. }
  349. tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
  350. buffer[0],buffer[1],buffer[2],buffer[3]);
  351. if (4 != (rc = i2c_master_send(c,buffer,4)))
  352. tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
  353. if (t->type == TUNER_MICROTUNE_4042FI5) {
  354. // FIXME - this may also work for other tuners
  355. unsigned long timeout = jiffies + msecs_to_jiffies(1);
  356. u8 status_byte = 0;
  357. /* Wait until the PLL locks */
  358. for (;;) {
  359. if (time_after(jiffies,timeout))
  360. return;
  361. if (1 != (rc = i2c_master_recv(c,&status_byte,1))) {
  362. tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc);
  363. break;
  364. }
  365. /* bit 6 is PLL locked indicator */
  366. if (status_byte & 0x40)
  367. break;
  368. udelay(10);
  369. }
  370. /* Set the charge pump for optimized phase noise figure */
  371. tun->config &= ~0x40;
  372. buffer[0] = (div>>8) & 0x7f;
  373. buffer[1] = div & 0xff;
  374. buffer[2] = tun->config;
  375. buffer[3] = config;
  376. tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
  377. buffer[0],buffer[1],buffer[2],buffer[3]);
  378. if (4 != (rc = i2c_master_send(c,buffer,4)))
  379. tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
  380. }
  381. }
  382. static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
  383. {
  384. struct tunertype *tun;
  385. struct tuner *t = i2c_get_clientdata(c);
  386. unsigned char buffer[4];
  387. unsigned div;
  388. int rc;
  389. tun=&tuners[t->type];
  390. div = (freq / 1000) + (int)(16*10.7);
  391. buffer[2] = tun->config;
  392. switch (t->type) {
  393. case TUNER_TENA_9533_DI:
  394. case TUNER_YMEC_TVF_5533MF:
  395. /*These values are empirically determinated */
  396. div = (freq * 122) / 16000 - 20;
  397. buffer[2] = 0x88; /* could be also 0x80 */
  398. buffer[3] = 0x19; /* could be also 0x10, 0x18, 0x99 */
  399. break;
  400. case TUNER_PHILIPS_FM1216ME_MK3:
  401. case TUNER_PHILIPS_FM1236_MK3:
  402. case TUNER_PHILIPS_FMD1216ME_MK3:
  403. buffer[3] = 0x19;
  404. break;
  405. case TUNER_PHILIPS_FM1256_IH3:
  406. div = (20 * freq) / 16000 + 333 * 2;
  407. buffer[2] = 0x80;
  408. buffer[3] = 0x19;
  409. break;
  410. case TUNER_LG_PAL_FM:
  411. buffer[3] = 0xa5;
  412. break;
  413. default:
  414. buffer[3] = 0xa4;
  415. break;
  416. }
  417. buffer[0] = (div>>8) & 0x7f;
  418. buffer[1] = div & 0xff;
  419. tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
  420. buffer[0],buffer[1],buffer[2],buffer[3]);
  421. if (4 != (rc = i2c_master_send(c,buffer,4)))
  422. tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
  423. }
  424. int default_tuner_init(struct i2c_client *c)
  425. {
  426. struct tuner *t = i2c_get_clientdata(c);
  427. tuner_info("type set to %d (%s)\n",
  428. t->type, tuners[t->type].name);
  429. strlcpy(c->name, tuners[t->type].name, sizeof(c->name));
  430. t->tv_freq = default_set_tv_freq;
  431. t->radio_freq = default_set_radio_freq;
  432. t->has_signal = tuner_signal;
  433. t->is_stereo = tuner_stereo;
  434. return 0;
  435. }
  436. /*
  437. * Overrides for Emacs so that we follow Linus's tabbing style.
  438. * ---------------------------------------------------------------------------
  439. * Local variables:
  440. * c-basic-offset: 8
  441. * End:
  442. */