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