dvb-pll.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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, 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 = 5,
  78. .entries = {
  79. { 0, 36166667, 166666, 0xbc, 0x03 },
  80. { 443250000, 36166667, 166666, 0xbc, 0x01 },
  81. { 542000000, 36166667, 166666, 0xbc, 0x02 },
  82. { 830000000, 36166667, 166666, 0xf4, 0x02 },
  83. { 999999999, 36166667, 166666, 0xfc, 0x02 },
  84. },
  85. };
  86. EXPORT_SYMBOL(dvb_pll_lg_z201);
  87. struct dvb_pll_desc dvb_pll_unknown_1 = {
  88. .name = "unknown 1", /* used by dntv live dvb-t */
  89. .min = 174000000,
  90. .max = 862000000,
  91. .count = 9,
  92. .entries = {
  93. { 150000000, 36166667, 166666, 0xb4, 0x01 },
  94. { 173000000, 36166667, 166666, 0xbc, 0x01 },
  95. { 250000000, 36166667, 166666, 0xb4, 0x02 },
  96. { 400000000, 36166667, 166666, 0xbc, 0x02 },
  97. { 420000000, 36166667, 166666, 0xf4, 0x02 },
  98. { 470000000, 36166667, 166666, 0xfc, 0x02 },
  99. { 600000000, 36166667, 166666, 0xbc, 0x08 },
  100. { 730000000, 36166667, 166666, 0xf4, 0x08 },
  101. { 999999999, 36166667, 166666, 0xfc, 0x08 },
  102. },
  103. };
  104. EXPORT_SYMBOL(dvb_pll_unknown_1);
  105. /* Infineon TUA6010XS
  106. * used in Thomson Cable Tuner
  107. */
  108. struct dvb_pll_desc dvb_pll_tua6010xs = {
  109. .name = "Infineon TUA6010XS",
  110. .min = 44250000,
  111. .max = 858000000,
  112. .count = 3,
  113. .entries = {
  114. { 115750000, 36125000, 62500, 0x8e, 0x03 },
  115. { 403250000, 36125000, 62500, 0x8e, 0x06 },
  116. { 999999999, 36125000, 62500, 0x8e, 0x85 },
  117. },
  118. };
  119. EXPORT_SYMBOL(dvb_pll_tua6010xs);
  120. /* Panasonic env57h1xd5 (some Philips PLL ?) */
  121. struct dvb_pll_desc dvb_pll_env57h1xd5 = {
  122. .name = "Panasonic ENV57H1XD5",
  123. .min = 44250000,
  124. .max = 858000000,
  125. .count = 4,
  126. .entries = {
  127. { 153000000, 36291666, 166666, 0xc2, 0x41 },
  128. { 470000000, 36291666, 166666, 0xc2, 0x42 },
  129. { 526000000, 36291666, 166666, 0xc2, 0x84 },
  130. { 999999999, 36291666, 166666, 0xc2, 0xa4 },
  131. },
  132. };
  133. EXPORT_SYMBOL(dvb_pll_env57h1xd5);
  134. /* Philips TDA6650/TDA6651
  135. * used in Panasonic ENV77H11D5
  136. */
  137. static void tda665x_bw(u8 *buf, int bandwidth)
  138. {
  139. if (bandwidth == BANDWIDTH_8_MHZ)
  140. buf[3] |= 0x08;
  141. }
  142. struct dvb_pll_desc dvb_pll_tda665x = {
  143. .name = "Philips TDA6650/TDA6651",
  144. .min = 44250000,
  145. .max = 858000000,
  146. .setbw = tda665x_bw,
  147. .count = 12,
  148. .entries = {
  149. { 93834000, 36249333, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
  150. { 123834000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
  151. { 161000000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
  152. { 163834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
  153. { 253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
  154. { 383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
  155. { 443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
  156. { 444000000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0 11 */ },
  157. { 583834000, 36249333, 166667, 0xca, 0x63 /* 011 0 0 0 11 */ },
  158. { 793834000, 36249333, 166667, 0xca, 0xa3 /* 101 0 0 0 11 */ },
  159. { 444834000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0 11 */ },
  160. { 861000000, 36249333, 166667, 0xca, 0xe3 /* 111 0 0 0 11 */ },
  161. }
  162. };
  163. EXPORT_SYMBOL(dvb_pll_tda665x);
  164. /* Infineon TUA6034
  165. * used in LG TDTP E102P
  166. */
  167. static void tua6034_bw(u8 *buf, int bandwidth)
  168. {
  169. if (BANDWIDTH_7_MHZ != bandwidth)
  170. buf[3] |= 0x08;
  171. }
  172. struct dvb_pll_desc dvb_pll_tua6034 = {
  173. .name = "Infineon TUA6034",
  174. .min = 44250000,
  175. .max = 858000000,
  176. .count = 3,
  177. .setbw = tua6034_bw,
  178. .entries = {
  179. { 174500000, 36166667, 62500, 0xce, 0x01 },
  180. { 230000000, 36166667, 62500, 0xce, 0x02 },
  181. { 999999999, 36166667, 62500, 0xce, 0x04 },
  182. },
  183. };
  184. EXPORT_SYMBOL(dvb_pll_tua6034);
  185. /* ----------------------------------------------------------- */
  186. /* code */
  187. static int debug = 0;
  188. module_param(debug, int, 0644);
  189. MODULE_PARM_DESC(debug, "enable verbose debug messages");
  190. int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
  191. u32 freq, int bandwidth)
  192. {
  193. u32 div;
  194. int i;
  195. if (freq != 0 && (freq < desc->min || freq > desc->max))
  196. return -EINVAL;
  197. for (i = 0; i < desc->count; i++) {
  198. if (freq > desc->entries[i].limit)
  199. continue;
  200. break;
  201. }
  202. if (debug)
  203. printk("pll: %s: freq=%d bw=%d | i=%d/%d\n",
  204. desc->name, freq, bandwidth, i, desc->count);
  205. BUG_ON(i == desc->count);
  206. div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize;
  207. buf[0] = div >> 8;
  208. buf[1] = div & 0xff;
  209. buf[2] = desc->entries[i].cb1;
  210. buf[3] = desc->entries[i].cb2;
  211. if (desc->setbw)
  212. desc->setbw(buf, bandwidth);
  213. if (debug)
  214. printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
  215. desc->name, div, buf[0], buf[1], buf[2], buf[3]);
  216. return 0;
  217. }
  218. EXPORT_SYMBOL(dvb_pll_configure);
  219. MODULE_DESCRIPTION("dvb pll library");
  220. MODULE_AUTHOR("Gerd Knorr");
  221. MODULE_LICENSE("GPL");