dvb-pll.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /*
  2. * descriptions + helper functions for simple dvb plls.
  3. *
  4. * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #include <linux/module.h>
  21. #include <linux/dvb/frontend.h>
  22. #include <asm/types.h>
  23. #include "dvb-pll.h"
  24. /* ----------------------------------------------------------- */
  25. /* descriptions */
  26. struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
  27. .name = "Thomson dtt7579",
  28. .min = 177000000,
  29. .max = 858000000,
  30. .count = 5,
  31. .entries = {
  32. { 0, 36166667, 166666, 0xb4, 0x03 }, /* go sleep */
  33. { 443250000, 36166667, 166666, 0xb4, 0x02 },
  34. { 542000000, 36166667, 166666, 0xb4, 0x08 },
  35. { 771000000, 36166667, 166666, 0xbc, 0x08 },
  36. { 999999999, 36166667, 166666, 0xf4, 0x08 },
  37. },
  38. };
  39. EXPORT_SYMBOL(dvb_pll_thomson_dtt7579);
  40. struct dvb_pll_desc dvb_pll_thomson_dtt7610 = {
  41. .name = "Thomson dtt7610",
  42. .min = 44000000,
  43. .max = 958000000,
  44. .count = 3,
  45. .entries = {
  46. { 157250000, 44000000, 62500, 0x8e, 0x39 },
  47. { 454000000, 44000000, 62500, 0x8e, 0x3a },
  48. { 999999999, 44000000, 62500, 0x8e, 0x3c },
  49. },
  50. };
  51. EXPORT_SYMBOL(dvb_pll_thomson_dtt7610);
  52. static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth)
  53. {
  54. if (BANDWIDTH_7_MHZ == bandwidth)
  55. buf[3] |= 0x10;
  56. }
  57. struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
  58. .name = "Thomson dtt759x",
  59. .min = 177000000,
  60. .max = 896000000,
  61. .setbw = thomson_dtt759x_bw,
  62. .count = 6,
  63. .entries = {
  64. { 0, 36166667, 166666, 0x84, 0x03 },
  65. { 264000000, 36166667, 166666, 0xb4, 0x02 },
  66. { 470000000, 36166667, 166666, 0xbc, 0x02 },
  67. { 735000000, 36166667, 166666, 0xbc, 0x08 },
  68. { 835000000, 36166667, 166666, 0xf4, 0x08 },
  69. { 999999999, 36166667, 166666, 0xfc, 0x08 },
  70. },
  71. };
  72. EXPORT_SYMBOL(dvb_pll_thomson_dtt759x);
  73. struct dvb_pll_desc dvb_pll_lg_z201 = {
  74. .name = "LG z201",
  75. .min = 174000000,
  76. .max = 862000000,
  77. .count = 6,
  78. .entries = {
  79. { 0, 36166667, 166666, 0xbc, 0x03 },
  80. { 157500000, 36166667, 166666, 0xbc, 0x01 },
  81. { 443250000, 36166667, 166666, 0xbc, 0x02 },
  82. { 542000000, 36166667, 166666, 0xbc, 0x04 },
  83. { 830000000, 36166667, 166666, 0xf4, 0x04 },
  84. { 999999999, 36166667, 166666, 0xfc, 0x04 },
  85. },
  86. };
  87. EXPORT_SYMBOL(dvb_pll_lg_z201);
  88. struct dvb_pll_desc dvb_pll_microtune_4042 = {
  89. .name = "Microtune 4042 FI5",
  90. .min = 57000000,
  91. .max = 858000000,
  92. .count = 3,
  93. .entries = {
  94. { 162000000, 44000000, 62500, 0x8e, 0xa1 },
  95. { 457000000, 44000000, 62500, 0x8e, 0x91 },
  96. { 999999999, 44000000, 62500, 0x8e, 0x31 },
  97. },
  98. };
  99. EXPORT_SYMBOL(dvb_pll_microtune_4042);
  100. struct dvb_pll_desc dvb_pll_thomson_dtt761x = {
  101. /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */
  102. .name = "Thomson dtt761x",
  103. .min = 57000000,
  104. .max = 863000000,
  105. .count = 3,
  106. .entries = {
  107. { 147000000, 44000000, 62500, 0x8e, 0x39 },
  108. { 417000000, 44000000, 62500, 0x8e, 0x3a },
  109. { 999999999, 44000000, 62500, 0x8e, 0x3c },
  110. },
  111. };
  112. EXPORT_SYMBOL(dvb_pll_thomson_dtt761x);
  113. struct dvb_pll_desc dvb_pll_unknown_1 = {
  114. .name = "unknown 1", /* used by dntv live dvb-t */
  115. .min = 174000000,
  116. .max = 862000000,
  117. .count = 9,
  118. .entries = {
  119. { 150000000, 36166667, 166666, 0xb4, 0x01 },
  120. { 173000000, 36166667, 166666, 0xbc, 0x01 },
  121. { 250000000, 36166667, 166666, 0xb4, 0x02 },
  122. { 400000000, 36166667, 166666, 0xbc, 0x02 },
  123. { 420000000, 36166667, 166666, 0xf4, 0x02 },
  124. { 470000000, 36166667, 166666, 0xfc, 0x02 },
  125. { 600000000, 36166667, 166666, 0xbc, 0x08 },
  126. { 730000000, 36166667, 166666, 0xf4, 0x08 },
  127. { 999999999, 36166667, 166666, 0xfc, 0x08 },
  128. },
  129. };
  130. EXPORT_SYMBOL(dvb_pll_unknown_1);
  131. /* Infineon TUA6010XS
  132. * used in Thomson Cable Tuner
  133. */
  134. struct dvb_pll_desc dvb_pll_tua6010xs = {
  135. .name = "Infineon TUA6010XS",
  136. .min = 44250000,
  137. .max = 858000000,
  138. .count = 3,
  139. .entries = {
  140. { 115750000, 36125000, 62500, 0x8e, 0x03 },
  141. { 403250000, 36125000, 62500, 0x8e, 0x06 },
  142. { 999999999, 36125000, 62500, 0x8e, 0x85 },
  143. },
  144. };
  145. EXPORT_SYMBOL(dvb_pll_tua6010xs);
  146. /* Panasonic env57h1xd5 (some Philips PLL ?) */
  147. struct dvb_pll_desc dvb_pll_env57h1xd5 = {
  148. .name = "Panasonic ENV57H1XD5",
  149. .min = 44250000,
  150. .max = 858000000,
  151. .count = 4,
  152. .entries = {
  153. { 153000000, 36291666, 166666, 0xc2, 0x41 },
  154. { 470000000, 36291666, 166666, 0xc2, 0x42 },
  155. { 526000000, 36291666, 166666, 0xc2, 0x84 },
  156. { 999999999, 36291666, 166666, 0xc2, 0xa4 },
  157. },
  158. };
  159. EXPORT_SYMBOL(dvb_pll_env57h1xd5);
  160. /* Philips TDA6650/TDA6651
  161. * used in Panasonic ENV77H11D5
  162. */
  163. static void tda665x_bw(u8 *buf, u32 freq, int bandwidth)
  164. {
  165. if (bandwidth == BANDWIDTH_8_MHZ)
  166. buf[3] |= 0x08;
  167. }
  168. struct dvb_pll_desc dvb_pll_tda665x = {
  169. .name = "Philips TDA6650/TDA6651",
  170. .min = 44250000,
  171. .max = 858000000,
  172. .setbw = tda665x_bw,
  173. .count = 12,
  174. .entries = {
  175. { 93834000, 36249333, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
  176. { 123834000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
  177. { 161000000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
  178. { 163834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
  179. { 253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
  180. { 383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
  181. { 443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
  182. { 444000000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0 11 */ },
  183. { 583834000, 36249333, 166667, 0xca, 0x63 /* 011 0 0 0 11 */ },
  184. { 793834000, 36249333, 166667, 0xca, 0xa3 /* 101 0 0 0 11 */ },
  185. { 444834000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0 11 */ },
  186. { 861000000, 36249333, 166667, 0xca, 0xe3 /* 111 0 0 0 11 */ },
  187. }
  188. };
  189. EXPORT_SYMBOL(dvb_pll_tda665x);
  190. /* Infineon TUA6034
  191. * used in LG TDTP E102P
  192. */
  193. static void tua6034_bw(u8 *buf, u32 freq, int bandwidth)
  194. {
  195. if (BANDWIDTH_7_MHZ != bandwidth)
  196. buf[3] |= 0x08;
  197. }
  198. struct dvb_pll_desc dvb_pll_tua6034 = {
  199. .name = "Infineon TUA6034",
  200. .min = 44250000,
  201. .max = 858000000,
  202. .count = 3,
  203. .setbw = tua6034_bw,
  204. .entries = {
  205. { 174500000, 36166667, 62500, 0xce, 0x01 },
  206. { 230000000, 36166667, 62500, 0xce, 0x02 },
  207. { 999999999, 36166667, 62500, 0xce, 0x04 },
  208. },
  209. };
  210. EXPORT_SYMBOL(dvb_pll_tua6034);
  211. /* Infineon TUA6034
  212. * used in LG TDVS H061F and LG TDVS H062F
  213. */
  214. struct dvb_pll_desc dvb_pll_tdvs_tua6034 = {
  215. .name = "LG/Infineon TUA6034",
  216. .min = 54000000,
  217. .max = 863000000,
  218. .count = 3,
  219. .entries = {
  220. { 160000000, 44000000, 62500, 0xce, 0x01 },
  221. { 455000000, 44000000, 62500, 0xce, 0x02 },
  222. { 999999999, 44000000, 62500, 0xce, 0x04 },
  223. },
  224. };
  225. EXPORT_SYMBOL(dvb_pll_tdvs_tua6034);
  226. /* Philips FMD1216ME
  227. * used in Medion Hybrid PCMCIA card and USB Box
  228. */
  229. static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth)
  230. {
  231. if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000)
  232. buf[3] |= 0x08;
  233. }
  234. struct dvb_pll_desc dvb_pll_fmd1216me = {
  235. .name = "Philips FMD1216ME",
  236. .min = 50870000,
  237. .max = 858000000,
  238. .setbw = fmd1216me_bw,
  239. .count = 7,
  240. .entries = {
  241. { 143870000, 36213333, 166667, 0xbc, 0x41 },
  242. { 158870000, 36213333, 166667, 0xf4, 0x41 },
  243. { 329870000, 36213333, 166667, 0xbc, 0x42 },
  244. { 441870000, 36213333, 166667, 0xf4, 0x42 },
  245. { 625870000, 36213333, 166667, 0xbc, 0x44 },
  246. { 803870000, 36213333, 166667, 0xf4, 0x44 },
  247. { 999999999, 36213333, 166667, 0xfc, 0x44 },
  248. }
  249. };
  250. EXPORT_SYMBOL(dvb_pll_fmd1216me);
  251. /* ALPS TDED4
  252. * used in Nebula-Cards and USB boxes
  253. */
  254. static void tded4_bw(u8 *buf, u32 freq, int bandwidth)
  255. {
  256. if (bandwidth == BANDWIDTH_8_MHZ)
  257. buf[3] |= 0x04;
  258. }
  259. struct dvb_pll_desc dvb_pll_tded4 = {
  260. .name = "ALPS TDED4",
  261. .min = 47000000,
  262. .max = 863000000,
  263. .setbw = tded4_bw,
  264. .count = 4,
  265. .entries = {
  266. { 153000000, 36166667, 166667, 0x85, 0x01 },
  267. { 470000000, 36166667, 166667, 0x85, 0x02 },
  268. { 823000000, 36166667, 166667, 0x85, 0x08 },
  269. { 999999999, 36166667, 166667, 0x85, 0x88 },
  270. }
  271. };
  272. EXPORT_SYMBOL(dvb_pll_tded4);
  273. /* ALPS TDHU2
  274. * used in AverTVHD MCE A180
  275. */
  276. struct dvb_pll_desc dvb_pll_tdhu2 = {
  277. .name = "ALPS TDHU2",
  278. .min = 54000000,
  279. .max = 864000000,
  280. .count = 4,
  281. .entries = {
  282. { 162000000, 44000000, 62500, 0x85, 0x01 },
  283. { 426000000, 44000000, 62500, 0x85, 0x02 },
  284. { 782000000, 44000000, 62500, 0x85, 0x08 },
  285. { 999999999, 44000000, 62500, 0x85, 0x88 },
  286. }
  287. };
  288. EXPORT_SYMBOL(dvb_pll_tdhu2);
  289. /* Philips TUV1236D
  290. * used in ATI HDTV Wonder
  291. */
  292. struct dvb_pll_desc dvb_pll_tuv1236d = {
  293. .name = "Philips TUV1236D",
  294. .min = 54000000,
  295. .max = 864000000,
  296. .count = 3,
  297. .entries = {
  298. { 157250000, 44000000, 62500, 0xc6, 0x41 },
  299. { 454000000, 44000000, 62500, 0xc6, 0x42 },
  300. { 999999999, 44000000, 62500, 0xc6, 0x44 },
  301. },
  302. };
  303. EXPORT_SYMBOL(dvb_pll_tuv1236d);
  304. /* Samsung TBMV30111IN / TBMV30712IN1
  305. * used in Air2PC ATSC - 2nd generation (nxt2002)
  306. */
  307. struct dvb_pll_desc dvb_pll_samsung_tbmv = {
  308. .name = "Samsung TBMV30111IN / TBMV30712IN1",
  309. .min = 54000000,
  310. .max = 860000000,
  311. .count = 6,
  312. .entries = {
  313. { 172000000, 44000000, 166666, 0xb4, 0x01 },
  314. { 214000000, 44000000, 166666, 0xb4, 0x02 },
  315. { 467000000, 44000000, 166666, 0xbc, 0x02 },
  316. { 721000000, 44000000, 166666, 0xbc, 0x08 },
  317. { 841000000, 44000000, 166666, 0xf4, 0x08 },
  318. { 999999999, 44000000, 166666, 0xfc, 0x02 },
  319. }
  320. };
  321. EXPORT_SYMBOL(dvb_pll_samsung_tbmv);
  322. /*
  323. * Philips SD1878 Tuner.
  324. */
  325. struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
  326. .name = "Philips SD1878",
  327. .min = 950000,
  328. .max = 2150000,
  329. .count = 4,
  330. .entries = {
  331. { 1250000, 499, 500, 0xc4, 0x00},
  332. { 1550000, 499, 500, 0xc4, 0x40},
  333. { 2050000, 499, 500, 0xc4, 0x80},
  334. { 2150000, 499, 500, 0xc4, 0xc0},
  335. },
  336. };
  337. EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261);
  338. /*
  339. * Philips TD1316 Tuner.
  340. */
  341. static void td1316_bw(u8 *buf, u32 freq, int bandwidth)
  342. {
  343. u8 band;
  344. /* determine band */
  345. if (freq < 161000000)
  346. band = 1;
  347. else if (freq < 444000000)
  348. band = 2;
  349. else
  350. band = 4;
  351. buf[3] |= band;
  352. /* setup PLL filter */
  353. if (bandwidth == BANDWIDTH_8_MHZ)
  354. buf[3] |= 1 << 3;
  355. }
  356. struct dvb_pll_desc dvb_pll_philips_td1316 = {
  357. .name = "Philips TD1316",
  358. .min = 87000000,
  359. .max = 895000000,
  360. .setbw = td1316_bw,
  361. .count = 9,
  362. .entries = {
  363. { 93834000, 36166000, 166666, 0xca, 0x60},
  364. { 123834000, 36166000, 166666, 0xca, 0xa0},
  365. { 163834000, 36166000, 166666, 0xca, 0xc0},
  366. { 253834000, 36166000, 166666, 0xca, 0x60},
  367. { 383834000, 36166000, 166666, 0xca, 0xa0},
  368. { 443834000, 36166000, 166666, 0xca, 0xc0},
  369. { 583834000, 36166000, 166666, 0xca, 0x60},
  370. { 793834000, 36166000, 166666, 0xca, 0xa0},
  371. { 858834000, 36166000, 166666, 0xca, 0xe0},
  372. },
  373. };
  374. EXPORT_SYMBOL(dvb_pll_philips_td1316);
  375. /* FE6600 used on DViCO Hybrid */
  376. struct dvb_pll_desc dvb_pll_thomson_fe6600 = {
  377. .name = "Thomson FE6600",
  378. .min = 44250000,
  379. .max = 858000000,
  380. .count = 4,
  381. .entries = {
  382. { 250000000, 36213333, 166667, 0xb4, 0x12 },
  383. { 455000000, 36213333, 166667, 0xfe, 0x11 },
  384. { 775500000, 36213333, 166667, 0xbc, 0x18 },
  385. { 999999999, 36213333, 166667, 0xf4, 0x18 },
  386. }
  387. };
  388. EXPORT_SYMBOL(dvb_pll_thomson_fe6600);
  389. /* ----------------------------------------------------------- */
  390. /* code */
  391. static int debug = 0;
  392. module_param(debug, int, 0644);
  393. MODULE_PARM_DESC(debug, "enable verbose debug messages");
  394. int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
  395. u32 freq, int bandwidth)
  396. {
  397. u32 div;
  398. int i;
  399. if (freq != 0 && (freq < desc->min || freq > desc->max))
  400. return -EINVAL;
  401. for (i = 0; i < desc->count; i++) {
  402. if (freq > desc->entries[i].limit)
  403. continue;
  404. break;
  405. }
  406. if (debug)
  407. printk("pll: %s: freq=%d bw=%d | i=%d/%d\n",
  408. desc->name, freq, bandwidth, i, desc->count);
  409. BUG_ON(i == desc->count);
  410. div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize;
  411. buf[0] = div >> 8;
  412. buf[1] = div & 0xff;
  413. buf[2] = desc->entries[i].config;
  414. buf[3] = desc->entries[i].cb;
  415. if (desc->setbw)
  416. desc->setbw(buf, freq, bandwidth);
  417. if (debug)
  418. printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
  419. desc->name, div, buf[0], buf[1], buf[2], buf[3]);
  420. return 0;
  421. }
  422. EXPORT_SYMBOL(dvb_pll_configure);
  423. MODULE_DESCRIPTION("dvb pll library");
  424. MODULE_AUTHOR("Gerd Knorr");
  425. MODULE_LICENSE("GPL");