blob: 71e06ec7925aa834208751ac00c951d012f99b40 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * 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
Patrick Boettcher49dc82f2005-07-07 17:58:09 -070058static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059{
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,
85 .count = 5,
86 .entries = {
87 { 0, 36166667, 166666, 0xbc, 0x03 },
88 { 443250000, 36166667, 166666, 0xbc, 0x01 },
89 { 542000000, 36166667, 166666, 0xbc, 0x02 },
90 { 830000000, 36166667, 166666, 0xf4, 0x02 },
91 { 999999999, 36166667, 166666, 0xfc, 0x02 },
92 },
93};
94EXPORT_SYMBOL(dvb_pll_lg_z201);
95
Mac Michaelsd8667cb2005-07-07 17:58:29 -070096struct dvb_pll_desc dvb_pll_microtune_4042 = {
97 .name = "Microtune 4042 FI5",
98 .min = 57000000,
99 .max = 858000000,
100 .count = 3,
101 .entries = {
102 { 162000000, 44000000, 62500, 0x8e, 0xa1 },
103 { 457000000, 44000000, 62500, 0x8e, 0x91 },
104 { 999999999, 44000000, 62500, 0x8e, 0x31 },
105 },
106};
107EXPORT_SYMBOL(dvb_pll_microtune_4042);
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109struct dvb_pll_desc dvb_pll_unknown_1 = {
110 .name = "unknown 1", /* used by dntv live dvb-t */
111 .min = 174000000,
112 .max = 862000000,
113 .count = 9,
114 .entries = {
115 { 150000000, 36166667, 166666, 0xb4, 0x01 },
116 { 173000000, 36166667, 166666, 0xbc, 0x01 },
117 { 250000000, 36166667, 166666, 0xb4, 0x02 },
118 { 400000000, 36166667, 166666, 0xbc, 0x02 },
119 { 420000000, 36166667, 166666, 0xf4, 0x02 },
120 { 470000000, 36166667, 166666, 0xfc, 0x02 },
121 { 600000000, 36166667, 166666, 0xbc, 0x08 },
122 { 730000000, 36166667, 166666, 0xf4, 0x08 },
123 { 999999999, 36166667, 166666, 0xfc, 0x08 },
124 },
125};
126EXPORT_SYMBOL(dvb_pll_unknown_1);
127
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700128/* Infineon TUA6010XS
129 * used in Thomson Cable Tuner
130 */
131struct dvb_pll_desc dvb_pll_tua6010xs = {
132 .name = "Infineon TUA6010XS",
133 .min = 44250000,
134 .max = 858000000,
135 .count = 3,
136 .entries = {
137 { 115750000, 36125000, 62500, 0x8e, 0x03 },
138 { 403250000, 36125000, 62500, 0x8e, 0x06 },
139 { 999999999, 36125000, 62500, 0x8e, 0x85 },
140 },
141};
142EXPORT_SYMBOL(dvb_pll_tua6010xs);
143
144/* Panasonic env57h1xd5 (some Philips PLL ?) */
145struct dvb_pll_desc dvb_pll_env57h1xd5 = {
146 .name = "Panasonic ENV57H1XD5",
147 .min = 44250000,
148 .max = 858000000,
149 .count = 4,
150 .entries = {
151 { 153000000, 36291666, 166666, 0xc2, 0x41 },
152 { 470000000, 36291666, 166666, 0xc2, 0x42 },
153 { 526000000, 36291666, 166666, 0xc2, 0x84 },
154 { 999999999, 36291666, 166666, 0xc2, 0xa4 },
155 },
156};
157EXPORT_SYMBOL(dvb_pll_env57h1xd5);
158
159/* Philips TDA6650/TDA6651
160 * used in Panasonic ENV77H11D5
161 */
Patrick Boettcher49dc82f2005-07-07 17:58:09 -0700162static void tda665x_bw(u8 *buf, u32 freq, int bandwidth)
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700163{
164 if (bandwidth == BANDWIDTH_8_MHZ)
165 buf[3] |= 0x08;
166}
167
168struct 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};
189EXPORT_SYMBOL(dvb_pll_tda665x);
190
191/* Infineon TUA6034
192 * used in LG TDTP E102P
193 */
Patrick Boettcher49dc82f2005-07-07 17:58:09 -0700194static void tua6034_bw(u8 *buf, u32 freq, int bandwidth)
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700195{
196 if (BANDWIDTH_7_MHZ != bandwidth)
197 buf[3] |= 0x08;
198}
199
200struct dvb_pll_desc dvb_pll_tua6034 = {
201 .name = "Infineon TUA6034",
202 .min = 44250000,
203 .max = 858000000,
204 .count = 3,
205 .setbw = tua6034_bw,
206 .entries = {
207 { 174500000, 36166667, 62500, 0xce, 0x01 },
208 { 230000000, 36166667, 62500, 0xce, 0x02 },
209 { 999999999, 36166667, 62500, 0xce, 0x04 },
210 },
211};
212EXPORT_SYMBOL(dvb_pll_tua6034);
213
Patrick Boettcher49dc82f2005-07-07 17:58:09 -0700214/* Philips FMD1216ME
215 * used in Medion Hybrid PCMCIA card and USB Box
216 */
217static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth)
218{
219 if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000)
220 buf[3] |= 0x08;
221}
222
223struct dvb_pll_desc dvb_pll_fmd1216me = {
Patrick Boettcher0589b8e2005-07-07 17:58:12 -0700224 .name = "Philips FMD1216ME",
Patrick Boettcher49dc82f2005-07-07 17:58:09 -0700225 .min = 50870000,
226 .max = 858000000,
227 .setbw = fmd1216me_bw,
228 .count = 7,
229 .entries = {
230 { 143870000, 36213333, 166667, 0xbc, 0x41 },
231 { 158870000, 36213333, 166667, 0xf4, 0x41 },
232 { 329870000, 36213333, 166667, 0xbc, 0x42 },
233 { 441870000, 36213333, 166667, 0xf4, 0x42 },
234 { 625870000, 36213333, 166667, 0xbc, 0x44 },
235 { 803870000, 36213333, 166667, 0xf4, 0x44 },
236 { 999999999, 36213333, 166667, 0xfc, 0x44 },
237 }
238};
239EXPORT_SYMBOL(dvb_pll_fmd1216me);
240
Patrick Boettcher0589b8e2005-07-07 17:58:12 -0700241/* ALPS TDED4
242 * used in Nebula-Cards and USB boxes
243 */
244static void tded4_bw(u8 *buf, u32 freq, int bandwidth)
245{
246 if (bandwidth == BANDWIDTH_8_MHZ)
247 buf[3] |= 0x04;
248}
249
250struct dvb_pll_desc dvb_pll_tded4 = {
251 .name = "ALPS TDED4",
252 .min = 47000000,
253 .max = 863000000,
254 .setbw = tded4_bw,
255 .count = 4,
256 .entries = {
257 { 153000000, 36166667, 166667, 0x85, 0x01 },
258 { 470000000, 36166667, 166667, 0x85, 0x02 },
259 { 823000000, 36166667, 166667, 0x85, 0x08 },
260 { 999999999, 36166667, 166667, 0x85, 0x88 },
261 }
262};
263EXPORT_SYMBOL(dvb_pll_tded4);
264
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265/* ----------------------------------------------------------- */
266/* code */
267
268static int debug = 0;
269module_param(debug, int, 0644);
270MODULE_PARM_DESC(debug, "enable verbose debug messages");
271
272int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
273 u32 freq, int bandwidth)
274{
275 u32 div;
276 int i;
277
278 if (freq != 0 && (freq < desc->min || freq > desc->max))
279 return -EINVAL;
280
281 for (i = 0; i < desc->count; i++) {
282 if (freq > desc->entries[i].limit)
283 continue;
284 break;
285 }
286 if (debug)
287 printk("pll: %s: freq=%d bw=%d | i=%d/%d\n",
288 desc->name, freq, bandwidth, i, desc->count);
289 BUG_ON(i == desc->count);
290
291 div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize;
292 buf[0] = div >> 8;
293 buf[1] = div & 0xff;
294 buf[2] = desc->entries[i].cb1;
295 buf[3] = desc->entries[i].cb2;
296
297 if (desc->setbw)
Patrick Boettcher49dc82f2005-07-07 17:58:09 -0700298 desc->setbw(buf, freq, bandwidth);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
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
304 return 0;
305}
306EXPORT_SYMBOL(dvb_pll_configure);
307
308MODULE_DESCRIPTION("dvb pll library");
309MODULE_AUTHOR("Gerd Knorr");
310MODULE_LICENSE("GPL");