dvb-pll.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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_dtt7611 = {
  101. .name = "Thomson dtt7611",
  102. .min = 44000000,
  103. .max = 958000000,
  104. .count = 3,
  105. .entries = {
  106. { 157250000, 44000000, 62500, 0x8e, 0x39 },
  107. { 454000000, 44000000, 62500, 0x8e, 0x3a },
  108. { 999999999, 44000000, 62500, 0x8e, 0x3c },
  109. },
  110. };
  111. EXPORT_SYMBOL(dvb_pll_thomson_dtt7611);
  112. struct dvb_pll_desc dvb_pll_unknown_1 = {
  113. .name = "unknown 1", /* used by dntv live dvb-t */
  114. .min = 174000000,
  115. .max = 862000000,
  116. .count = 9,
  117. .entries = {
  118. { 150000000, 36166667, 166666, 0xb4, 0x01 },
  119. { 173000000, 36166667, 166666, 0xbc, 0x01 },
  120. { 250000000, 36166667, 166666, 0xb4, 0x02 },
  121. { 400000000, 36166667, 166666, 0xbc, 0x02 },
  122. { 420000000, 36166667, 166666, 0xf4, 0x02 },
  123. { 470000000, 36166667, 166666, 0xfc, 0x02 },
  124. { 600000000, 36166667, 166666, 0xbc, 0x08 },
  125. { 730000000, 36166667, 166666, 0xf4, 0x08 },
  126. { 999999999, 36166667, 166666, 0xfc, 0x08 },
  127. },
  128. };
  129. EXPORT_SYMBOL(dvb_pll_unknown_1);
  130. /* Infineon TUA6010XS
  131. * used in Thomson Cable Tuner
  132. */
  133. struct dvb_pll_desc dvb_pll_tua6010xs = {
  134. .name = "Infineon TUA6010XS",
  135. .min = 44250000,
  136. .max = 858000000,
  137. .count = 3,
  138. .entries = {
  139. { 115750000, 36125000, 62500, 0x8e, 0x03 },
  140. { 403250000, 36125000, 62500, 0x8e, 0x06 },
  141. { 999999999, 36125000, 62500, 0x8e, 0x85 },
  142. },
  143. };
  144. EXPORT_SYMBOL(dvb_pll_tua6010xs);
  145. /* Panasonic env57h1xd5 (some Philips PLL ?) */
  146. struct dvb_pll_desc dvb_pll_env57h1xd5 = {
  147. .name = "Panasonic ENV57H1XD5",
  148. .min = 44250000,
  149. .max = 858000000,
  150. .count = 4,
  151. .entries = {
  152. { 153000000, 36291666, 166666, 0xc2, 0x41 },
  153. { 470000000, 36291666, 166666, 0xc2, 0x42 },
  154. { 526000000, 36291666, 166666, 0xc2, 0x84 },
  155. { 999999999, 36291666, 166666, 0xc2, 0xa4 },
  156. },
  157. };
  158. EXPORT_SYMBOL(dvb_pll_env57h1xd5);
  159. /* Philips TDA6650/TDA6651
  160. * used in Panasonic ENV77H11D5
  161. */
  162. static void tda665x_bw(u8 *buf, u32 freq, int bandwidth)
  163. {
  164. if (bandwidth == BANDWIDTH_8_MHZ)
  165. buf[3] |= 0x08;
  166. }
  167. struct dvb_pll_desc dvb_pll_tda665x = {
  168. .name = "Philips TDA6650/TDA6651",
  169. .min = 44250000,
  170. .max = 858000000,
  171. .setbw = tda665x_bw,
  172. .count = 12,
  173. .entries = {
  174. { 93834000, 36249333, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
  175. { 123834000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
  176. { 161000000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
  177. { 163834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
  178. { 253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
  179. { 383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
  180. { 443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
  181. { 444000000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0 11 */ },
  182. { 583834000, 36249333, 166667, 0xca, 0x63 /* 011 0 0 0 11 */ },
  183. { 793834000, 36249333, 166667, 0xca, 0xa3 /* 101 0 0 0 11 */ },
  184. { 444834000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0 11 */ },
  185. { 861000000, 36249333, 166667, 0xca, 0xe3 /* 111 0 0 0 11 */ },
  186. }
  187. };
  188. EXPORT_SYMBOL(dvb_pll_tda665x);
  189. /* Infineon TUA6034
  190. * used in LG TDTP E102P
  191. */
  192. static void tua6034_bw(u8 *buf, u32 freq, int bandwidth)
  193. {
  194. if (BANDWIDTH_7_MHZ != bandwidth)
  195. buf[3] |= 0x08;
  196. }
  197. struct dvb_pll_desc dvb_pll_tua6034 = {
  198. .name = "Infineon TUA6034",
  199. .min = 44250000,
  200. .max = 858000000,
  201. .count = 3,
  202. .setbw = tua6034_bw,
  203. .entries = {
  204. { 174500000, 36166667, 62500, 0xce, 0x01 },
  205. { 230000000, 36166667, 62500, 0xce, 0x02 },
  206. { 999999999, 36166667, 62500, 0xce, 0x04 },
  207. },
  208. };
  209. EXPORT_SYMBOL(dvb_pll_tua6034);
  210. /* Infineon TUA6034
  211. * used in LG Innotek TDVS-H062F
  212. */
  213. struct dvb_pll_desc dvb_pll_tdvs_tua6034 = {
  214. .name = "LG/Infineon TUA6034",
  215. .min = 54000000,
  216. .max = 863000000,
  217. .count = 3,
  218. .entries = {
  219. { 160000000, 44000000, 62500, 0xce, 0x01 },
  220. { 455000000, 44000000, 62500, 0xce, 0x02 },
  221. { 999999999, 44000000, 62500, 0xce, 0x04 },
  222. },
  223. };
  224. EXPORT_SYMBOL(dvb_pll_tdvs_tua6034);
  225. /* Philips FMD1216ME
  226. * used in Medion Hybrid PCMCIA card and USB Box
  227. */
  228. static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth)
  229. {
  230. if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000)
  231. buf[3] |= 0x08;
  232. }
  233. struct dvb_pll_desc dvb_pll_fmd1216me = {
  234. .name = "Philips FMD1216ME",
  235. .min = 50870000,
  236. .max = 858000000,
  237. .setbw = fmd1216me_bw,
  238. .count = 7,
  239. .entries = {
  240. { 143870000, 36213333, 166667, 0xbc, 0x41 },
  241. { 158870000, 36213333, 166667, 0xf4, 0x41 },
  242. { 329870000, 36213333, 166667, 0xbc, 0x42 },
  243. { 441870000, 36213333, 166667, 0xf4, 0x42 },
  244. { 625870000, 36213333, 166667, 0xbc, 0x44 },
  245. { 803870000, 36213333, 166667, 0xf4, 0x44 },
  246. { 999999999, 36213333, 166667, 0xfc, 0x44 },
  247. }
  248. };
  249. EXPORT_SYMBOL(dvb_pll_fmd1216me);
  250. /* ALPS TDED4
  251. * used in Nebula-Cards and USB boxes
  252. */
  253. static void tded4_bw(u8 *buf, u32 freq, int bandwidth)
  254. {
  255. if (bandwidth == BANDWIDTH_8_MHZ)
  256. buf[3] |= 0x04;
  257. }
  258. struct dvb_pll_desc dvb_pll_tded4 = {
  259. .name = "ALPS TDED4",
  260. .min = 47000000,
  261. .max = 863000000,
  262. .setbw = tded4_bw,
  263. .count = 4,
  264. .entries = {
  265. { 153000000, 36166667, 166667, 0x85, 0x01 },
  266. { 470000000, 36166667, 166667, 0x85, 0x02 },
  267. { 823000000, 36166667, 166667, 0x85, 0x08 },
  268. { 999999999, 36166667, 166667, 0x85, 0x88 },
  269. }
  270. };
  271. EXPORT_SYMBOL(dvb_pll_tded4);
  272. /* ----------------------------------------------------------- */
  273. /* code */
  274. static int debug = 0;
  275. module_param(debug, int, 0644);
  276. MODULE_PARM_DESC(debug, "enable verbose debug messages");
  277. int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
  278. u32 freq, int bandwidth)
  279. {
  280. u32 div;
  281. int i;
  282. if (freq != 0 && (freq < desc->min || freq > desc->max))
  283. return -EINVAL;
  284. for (i = 0; i < desc->count; i++) {
  285. if (freq > desc->entries[i].limit)
  286. continue;
  287. break;
  288. }
  289. if (debug)
  290. printk("pll: %s: freq=%d bw=%d | i=%d/%d\n",
  291. desc->name, freq, bandwidth, i, desc->count);
  292. BUG_ON(i == desc->count);
  293. div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize;
  294. buf[0] = div >> 8;
  295. buf[1] = div & 0xff;
  296. buf[2] = desc->entries[i].cb1;
  297. buf[3] = desc->entries[i].cb2;
  298. if (desc->setbw)
  299. desc->setbw(buf, freq, bandwidth);
  300. if (debug)
  301. printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
  302. desc->name, div, buf[0], buf[1], buf[2], buf[3]);
  303. return 0;
  304. }
  305. EXPORT_SYMBOL(dvb_pll_configure);
  306. MODULE_DESCRIPTION("dvb pll library");
  307. MODULE_AUTHOR("Gerd Knorr");
  308. MODULE_LICENSE("GPL");