V4L/DVB (3350): Added USB ID for DigitalNow DVB-T Dual USB, DViCO clone
[deliverable/linux.git] / drivers / media / dvb / frontends / dvb-pll.c
CommitLineData
1da177e4 1/*
1da177e4
LT
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
21#include <linux/module.h>
22#include <linux/dvb/frontend.h>
23#include <asm/types.h>
24
25#include "dvb-pll.h"
26
27/* ----------------------------------------------------------- */
28/* descriptions */
29
30struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
31 .name = "Thomson dtt7579",
32 .min = 177000000,
33 .max = 858000000,
34 .count = 5,
35 .entries = {
36 { 0, 36166667, 166666, 0xb4, 0x03 }, /* go sleep */
37 { 443250000, 36166667, 166666, 0xb4, 0x02 },
38 { 542000000, 36166667, 166666, 0xb4, 0x08 },
39 { 771000000, 36166667, 166666, 0xbc, 0x08 },
40 { 999999999, 36166667, 166666, 0xf4, 0x08 },
41 },
42};
43EXPORT_SYMBOL(dvb_pll_thomson_dtt7579);
44
45struct dvb_pll_desc dvb_pll_thomson_dtt7610 = {
46 .name = "Thomson dtt7610",
47 .min = 44000000,
48 .max = 958000000,
49 .count = 3,
50 .entries = {
51 { 157250000, 44000000, 62500, 0x8e, 0x39 },
52 { 454000000, 44000000, 62500, 0x8e, 0x3a },
53 { 999999999, 44000000, 62500, 0x8e, 0x3c },
54 },
55};
56EXPORT_SYMBOL(dvb_pll_thomson_dtt7610);
57
49dc82fd 58static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth)
1da177e4
LT
59{
60 if (BANDWIDTH_7_MHZ == bandwidth)
61 buf[3] |= 0x10;
62}
63
64struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
65 .name = "Thomson dtt759x",
66 .min = 177000000,
67 .max = 896000000,
68 .setbw = thomson_dtt759x_bw,
69 .count = 6,
70 .entries = {
71 { 0, 36166667, 166666, 0x84, 0x03 },
72 { 264000000, 36166667, 166666, 0xb4, 0x02 },
73 { 470000000, 36166667, 166666, 0xbc, 0x02 },
74 { 735000000, 36166667, 166666, 0xbc, 0x08 },
75 { 835000000, 36166667, 166666, 0xf4, 0x08 },
76 { 999999999, 36166667, 166666, 0xfc, 0x08 },
77 },
78};
79EXPORT_SYMBOL(dvb_pll_thomson_dtt759x);
80
81struct dvb_pll_desc dvb_pll_lg_z201 = {
82 .name = "LG z201",
83 .min = 174000000,
84 .max = 862000000,
9e00e486 85 .count = 6,
1da177e4
LT
86 .entries = {
87 { 0, 36166667, 166666, 0xbc, 0x03 },
9e00e486
GF
88 { 157500000, 36166667, 166666, 0xbc, 0x01 },
89 { 443250000, 36166667, 166666, 0xbc, 0x02 },
90 { 542000000, 36166667, 166666, 0xbc, 0x04 },
91 { 830000000, 36166667, 166666, 0xf4, 0x04 },
92 { 999999999, 36166667, 166666, 0xfc, 0x04 },
1da177e4
LT
93 },
94};
95EXPORT_SYMBOL(dvb_pll_lg_z201);
96
d8667cbb
MM
97struct dvb_pll_desc dvb_pll_microtune_4042 = {
98 .name = "Microtune 4042 FI5",
99 .min = 57000000,
100 .max = 858000000,
101 .count = 3,
102 .entries = {
103 { 162000000, 44000000, 62500, 0x8e, 0xa1 },
104 { 457000000, 44000000, 62500, 0x8e, 0x91 },
105 { 999999999, 44000000, 62500, 0x8e, 0x31 },
106 },
107};
108EXPORT_SYMBOL(dvb_pll_microtune_4042);
109
83ac8722
MK
110struct dvb_pll_desc dvb_pll_thomson_dtt761x = {
111 /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */
112 .name = "Thomson dtt761x",
113 .min = 57000000,
114 .max = 863000000,
0d723c09
MK
115 .count = 3,
116 .entries = {
83ac8722
MK
117 { 147000000, 44000000, 62500, 0x8e, 0x39 },
118 { 417000000, 44000000, 62500, 0x8e, 0x3a },
0d723c09
MK
119 { 999999999, 44000000, 62500, 0x8e, 0x3c },
120 },
121};
83ac8722 122EXPORT_SYMBOL(dvb_pll_thomson_dtt761x);
0d723c09 123
1da177e4
LT
124struct dvb_pll_desc dvb_pll_unknown_1 = {
125 .name = "unknown 1", /* used by dntv live dvb-t */
126 .min = 174000000,
127 .max = 862000000,
128 .count = 9,
129 .entries = {
130 { 150000000, 36166667, 166666, 0xb4, 0x01 },
131 { 173000000, 36166667, 166666, 0xbc, 0x01 },
132 { 250000000, 36166667, 166666, 0xb4, 0x02 },
133 { 400000000, 36166667, 166666, 0xbc, 0x02 },
134 { 420000000, 36166667, 166666, 0xf4, 0x02 },
135 { 470000000, 36166667, 166666, 0xfc, 0x02 },
136 { 600000000, 36166667, 166666, 0xbc, 0x08 },
137 { 730000000, 36166667, 166666, 0xf4, 0x08 },
138 { 999999999, 36166667, 166666, 0xfc, 0x08 },
139 },
140};
141EXPORT_SYMBOL(dvb_pll_unknown_1);
142
776338e1
JS
143/* Infineon TUA6010XS
144 * used in Thomson Cable Tuner
145 */
146struct dvb_pll_desc dvb_pll_tua6010xs = {
147 .name = "Infineon TUA6010XS",
148 .min = 44250000,
149 .max = 858000000,
150 .count = 3,
151 .entries = {
152 { 115750000, 36125000, 62500, 0x8e, 0x03 },
153 { 403250000, 36125000, 62500, 0x8e, 0x06 },
154 { 999999999, 36125000, 62500, 0x8e, 0x85 },
155 },
156};
157EXPORT_SYMBOL(dvb_pll_tua6010xs);
158
159/* Panasonic env57h1xd5 (some Philips PLL ?) */
160struct dvb_pll_desc dvb_pll_env57h1xd5 = {
161 .name = "Panasonic ENV57H1XD5",
162 .min = 44250000,
163 .max = 858000000,
164 .count = 4,
165 .entries = {
166 { 153000000, 36291666, 166666, 0xc2, 0x41 },
167 { 470000000, 36291666, 166666, 0xc2, 0x42 },
168 { 526000000, 36291666, 166666, 0xc2, 0x84 },
169 { 999999999, 36291666, 166666, 0xc2, 0xa4 },
170 },
171};
172EXPORT_SYMBOL(dvb_pll_env57h1xd5);
173
174/* Philips TDA6650/TDA6651
175 * used in Panasonic ENV77H11D5
176 */
49dc82fd 177static void tda665x_bw(u8 *buf, u32 freq, int bandwidth)
776338e1
JS
178{
179 if (bandwidth == BANDWIDTH_8_MHZ)
180 buf[3] |= 0x08;
181}
182
183struct dvb_pll_desc dvb_pll_tda665x = {
184 .name = "Philips TDA6650/TDA6651",
185 .min = 44250000,
186 .max = 858000000,
187 .setbw = tda665x_bw,
188 .count = 12,
189 .entries = {
190 { 93834000, 36249333, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
191 { 123834000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
192 { 161000000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
193 { 163834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
194 { 253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
195 { 383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
196 { 443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
197 { 444000000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0 11 */ },
198 { 583834000, 36249333, 166667, 0xca, 0x63 /* 011 0 0 0 11 */ },
199 { 793834000, 36249333, 166667, 0xca, 0xa3 /* 101 0 0 0 11 */ },
200 { 444834000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0 11 */ },
201 { 861000000, 36249333, 166667, 0xca, 0xe3 /* 111 0 0 0 11 */ },
202 }
203};
204EXPORT_SYMBOL(dvb_pll_tda665x);
205
206/* Infineon TUA6034
207 * used in LG TDTP E102P
208 */
49dc82fd 209static void tua6034_bw(u8 *buf, u32 freq, int bandwidth)
776338e1
JS
210{
211 if (BANDWIDTH_7_MHZ != bandwidth)
212 buf[3] |= 0x08;
213}
214
215struct dvb_pll_desc dvb_pll_tua6034 = {
216 .name = "Infineon TUA6034",
217 .min = 44250000,
218 .max = 858000000,
219 .count = 3,
220 .setbw = tua6034_bw,
221 .entries = {
222 { 174500000, 36166667, 62500, 0xce, 0x01 },
223 { 230000000, 36166667, 62500, 0xce, 0x02 },
224 { 999999999, 36166667, 62500, 0xce, 0x04 },
225 },
226};
227EXPORT_SYMBOL(dvb_pll_tua6034);
228
1963c907 229/* Infineon TUA6034
c0b11b91 230 * used in LG TDVS H061F and LG TDVS H062F
1963c907
MK
231 */
232struct dvb_pll_desc dvb_pll_tdvs_tua6034 = {
233 .name = "LG/Infineon TUA6034",
234 .min = 54000000,
235 .max = 863000000,
236 .count = 3,
237 .entries = {
238 { 160000000, 44000000, 62500, 0xce, 0x01 },
239 { 455000000, 44000000, 62500, 0xce, 0x02 },
240 { 999999999, 44000000, 62500, 0xce, 0x04 },
241 },
242};
243EXPORT_SYMBOL(dvb_pll_tdvs_tua6034);
244
49dc82fd
PB
245/* Philips FMD1216ME
246 * used in Medion Hybrid PCMCIA card and USB Box
247 */
248static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth)
249{
250 if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000)
251 buf[3] |= 0x08;
252}
253
254struct dvb_pll_desc dvb_pll_fmd1216me = {
0589b8e4 255 .name = "Philips FMD1216ME",
49dc82fd
PB
256 .min = 50870000,
257 .max = 858000000,
258 .setbw = fmd1216me_bw,
259 .count = 7,
260 .entries = {
261 { 143870000, 36213333, 166667, 0xbc, 0x41 },
262 { 158870000, 36213333, 166667, 0xf4, 0x41 },
263 { 329870000, 36213333, 166667, 0xbc, 0x42 },
264 { 441870000, 36213333, 166667, 0xf4, 0x42 },
265 { 625870000, 36213333, 166667, 0xbc, 0x44 },
266 { 803870000, 36213333, 166667, 0xf4, 0x44 },
267 { 999999999, 36213333, 166667, 0xfc, 0x44 },
268 }
269};
270EXPORT_SYMBOL(dvb_pll_fmd1216me);
271
0589b8e4
PB
272/* ALPS TDED4
273 * used in Nebula-Cards and USB boxes
274 */
275static void tded4_bw(u8 *buf, u32 freq, int bandwidth)
276{
277 if (bandwidth == BANDWIDTH_8_MHZ)
278 buf[3] |= 0x04;
279}
280
281struct dvb_pll_desc dvb_pll_tded4 = {
282 .name = "ALPS TDED4",
283 .min = 47000000,
284 .max = 863000000,
285 .setbw = tded4_bw,
286 .count = 4,
287 .entries = {
288 { 153000000, 36166667, 166667, 0x85, 0x01 },
289 { 470000000, 36166667, 166667, 0x85, 0x02 },
290 { 823000000, 36166667, 166667, 0x85, 0x08 },
291 { 999999999, 36166667, 166667, 0x85, 0x88 },
292 }
293};
294EXPORT_SYMBOL(dvb_pll_tded4);
295
147418c9
KL
296/* ALPS TDHU2
297 * used in AverTVHD MCE A180
298 */
299struct dvb_pll_desc dvb_pll_tdhu2 = {
300 .name = "ALPS TDHU2",
301 .min = 54000000,
302 .max = 864000000,
303 .count = 4,
304 .entries = {
305 { 162000000, 44000000, 62500, 0x85, 0x01 },
306 { 426000000, 44000000, 62500, 0x85, 0x02 },
307 { 782000000, 44000000, 62500, 0x85, 0x08 },
308 { 999999999, 44000000, 62500, 0x85, 0x88 },
309 }
310};
311EXPORT_SYMBOL(dvb_pll_tdhu2);
312
313/* Philips TUV1236D
314 * used in ATI HDTV Wonder
315 */
316struct dvb_pll_desc dvb_pll_tuv1236d = {
317 .name = "Philips TUV1236D",
04a45929 318 .min = 54000000,
147418c9
KL
319 .max = 864000000,
320 .count = 3,
321 .entries = {
322 { 157250000, 44000000, 62500, 0xc6, 0x41 },
323 { 454000000, 44000000, 62500, 0xc6, 0x42 },
324 { 999999999, 44000000, 62500, 0xc6, 0x44 },
325 },
326};
327EXPORT_SYMBOL(dvb_pll_tuv1236d);
328
329/* Samsung TBMV30111IN
330 * used in Air2PC ATSC - 2nd generation (nxt2002)
331 */
332struct dvb_pll_desc dvb_pll_tbmv30111in = {
333 .name = "Samsung TBMV30111IN",
334 .min = 54000000,
335 .max = 860000000,
336 .count = 4,
337 .entries = {
338 { 172000000, 44000000, 166666, 0xb4, 0x01 },
339 { 214000000, 44000000, 166666, 0xb4, 0x02 },
340 { 467000000, 44000000, 166666, 0xbc, 0x02 },
341 { 721000000, 44000000, 166666, 0xbc, 0x08 },
342 { 841000000, 44000000, 166666, 0xf4, 0x08 },
343 { 999999999, 44000000, 166666, 0xfc, 0x02 },
344 }
345};
346EXPORT_SYMBOL(dvb_pll_tbmv30111in);
347
1da177e4
LT
348/* ----------------------------------------------------------- */
349/* code */
350
351static int debug = 0;
352module_param(debug, int, 0644);
353MODULE_PARM_DESC(debug, "enable verbose debug messages");
354
355int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
356 u32 freq, int bandwidth)
357{
358 u32 div;
359 int i;
360
361 if (freq != 0 && (freq < desc->min || freq > desc->max))
362 return -EINVAL;
363
364 for (i = 0; i < desc->count; i++) {
365 if (freq > desc->entries[i].limit)
366 continue;
367 break;
368 }
369 if (debug)
370 printk("pll: %s: freq=%d bw=%d | i=%d/%d\n",
371 desc->name, freq, bandwidth, i, desc->count);
372 BUG_ON(i == desc->count);
373
374 div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize;
375 buf[0] = div >> 8;
376 buf[1] = div & 0xff;
377 buf[2] = desc->entries[i].cb1;
378 buf[3] = desc->entries[i].cb2;
379
380 if (desc->setbw)
49dc82fd 381 desc->setbw(buf, freq, bandwidth);
1da177e4
LT
382
383 if (debug)
384 printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
385 desc->name, div, buf[0], buf[1], buf[2], buf[3]);
386
387 return 0;
388}
389EXPORT_SYMBOL(dvb_pll_configure);
390
391MODULE_DESCRIPTION("dvb pll library");
392MODULE_AUTHOR("Gerd Knorr");
393MODULE_LICENSE("GPL");
This page took 0.815832 seconds and 5 git commands to generate.