diff options
Diffstat (limited to 'drivers/media/dvb/frontends/dvb-pll.c')
-rw-r--r-- | drivers/media/dvb/frontends/dvb-pll.c | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c new file mode 100644 index 000000000000..2a3c2ce7b2aa --- /dev/null +++ b/drivers/media/dvb/frontends/dvb-pll.c | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | * $Id: dvb-pll.c,v 1.7 2005/02/10 11:52:02 kraxel Exp $ | ||
3 | * | ||
4 | * descriptions + helper functions for simple dvb plls. | ||
5 | * | ||
6 | * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/dvb/frontend.h> | ||
25 | #include <asm/types.h> | ||
26 | |||
27 | #include "dvb-pll.h" | ||
28 | |||
29 | /* ----------------------------------------------------------- */ | ||
30 | /* descriptions */ | ||
31 | |||
32 | struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { | ||
33 | .name = "Thomson dtt7579", | ||
34 | .min = 177000000, | ||
35 | .max = 858000000, | ||
36 | .count = 5, | ||
37 | .entries = { | ||
38 | { 0, 36166667, 166666, 0xb4, 0x03 }, /* go sleep */ | ||
39 | { 443250000, 36166667, 166666, 0xb4, 0x02 }, | ||
40 | { 542000000, 36166667, 166666, 0xb4, 0x08 }, | ||
41 | { 771000000, 36166667, 166666, 0xbc, 0x08 }, | ||
42 | { 999999999, 36166667, 166666, 0xf4, 0x08 }, | ||
43 | }, | ||
44 | }; | ||
45 | EXPORT_SYMBOL(dvb_pll_thomson_dtt7579); | ||
46 | |||
47 | struct dvb_pll_desc dvb_pll_thomson_dtt7610 = { | ||
48 | .name = "Thomson dtt7610", | ||
49 | .min = 44000000, | ||
50 | .max = 958000000, | ||
51 | .count = 3, | ||
52 | .entries = { | ||
53 | { 157250000, 44000000, 62500, 0x8e, 0x39 }, | ||
54 | { 454000000, 44000000, 62500, 0x8e, 0x3a }, | ||
55 | { 999999999, 44000000, 62500, 0x8e, 0x3c }, | ||
56 | }, | ||
57 | }; | ||
58 | EXPORT_SYMBOL(dvb_pll_thomson_dtt7610); | ||
59 | |||
60 | static void thomson_dtt759x_bw(u8 *buf, int bandwidth) | ||
61 | { | ||
62 | if (BANDWIDTH_7_MHZ == bandwidth) | ||
63 | buf[3] |= 0x10; | ||
64 | } | ||
65 | |||
66 | struct dvb_pll_desc dvb_pll_thomson_dtt759x = { | ||
67 | .name = "Thomson dtt759x", | ||
68 | .min = 177000000, | ||
69 | .max = 896000000, | ||
70 | .setbw = thomson_dtt759x_bw, | ||
71 | .count = 6, | ||
72 | .entries = { | ||
73 | { 0, 36166667, 166666, 0x84, 0x03 }, | ||
74 | { 264000000, 36166667, 166666, 0xb4, 0x02 }, | ||
75 | { 470000000, 36166667, 166666, 0xbc, 0x02 }, | ||
76 | { 735000000, 36166667, 166666, 0xbc, 0x08 }, | ||
77 | { 835000000, 36166667, 166666, 0xf4, 0x08 }, | ||
78 | { 999999999, 36166667, 166666, 0xfc, 0x08 }, | ||
79 | }, | ||
80 | }; | ||
81 | EXPORT_SYMBOL(dvb_pll_thomson_dtt759x); | ||
82 | |||
83 | struct dvb_pll_desc dvb_pll_lg_z201 = { | ||
84 | .name = "LG z201", | ||
85 | .min = 174000000, | ||
86 | .max = 862000000, | ||
87 | .count = 5, | ||
88 | .entries = { | ||
89 | { 0, 36166667, 166666, 0xbc, 0x03 }, | ||
90 | { 443250000, 36166667, 166666, 0xbc, 0x01 }, | ||
91 | { 542000000, 36166667, 166666, 0xbc, 0x02 }, | ||
92 | { 830000000, 36166667, 166666, 0xf4, 0x02 }, | ||
93 | { 999999999, 36166667, 166666, 0xfc, 0x02 }, | ||
94 | }, | ||
95 | }; | ||
96 | EXPORT_SYMBOL(dvb_pll_lg_z201); | ||
97 | |||
98 | struct dvb_pll_desc dvb_pll_unknown_1 = { | ||
99 | .name = "unknown 1", /* used by dntv live dvb-t */ | ||
100 | .min = 174000000, | ||
101 | .max = 862000000, | ||
102 | .count = 9, | ||
103 | .entries = { | ||
104 | { 150000000, 36166667, 166666, 0xb4, 0x01 }, | ||
105 | { 173000000, 36166667, 166666, 0xbc, 0x01 }, | ||
106 | { 250000000, 36166667, 166666, 0xb4, 0x02 }, | ||
107 | { 400000000, 36166667, 166666, 0xbc, 0x02 }, | ||
108 | { 420000000, 36166667, 166666, 0xf4, 0x02 }, | ||
109 | { 470000000, 36166667, 166666, 0xfc, 0x02 }, | ||
110 | { 600000000, 36166667, 166666, 0xbc, 0x08 }, | ||
111 | { 730000000, 36166667, 166666, 0xf4, 0x08 }, | ||
112 | { 999999999, 36166667, 166666, 0xfc, 0x08 }, | ||
113 | }, | ||
114 | }; | ||
115 | EXPORT_SYMBOL(dvb_pll_unknown_1); | ||
116 | |||
117 | /* ----------------------------------------------------------- */ | ||
118 | /* code */ | ||
119 | |||
120 | static int debug = 0; | ||
121 | module_param(debug, int, 0644); | ||
122 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | ||
123 | |||
124 | int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, | ||
125 | u32 freq, int bandwidth) | ||
126 | { | ||
127 | u32 div; | ||
128 | int i; | ||
129 | |||
130 | if (freq != 0 && (freq < desc->min || freq > desc->max)) | ||
131 | return -EINVAL; | ||
132 | |||
133 | for (i = 0; i < desc->count; i++) { | ||
134 | if (freq > desc->entries[i].limit) | ||
135 | continue; | ||
136 | break; | ||
137 | } | ||
138 | if (debug) | ||
139 | printk("pll: %s: freq=%d bw=%d | i=%d/%d\n", | ||
140 | desc->name, freq, bandwidth, i, desc->count); | ||
141 | BUG_ON(i == desc->count); | ||
142 | |||
143 | div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize; | ||
144 | buf[0] = div >> 8; | ||
145 | buf[1] = div & 0xff; | ||
146 | buf[2] = desc->entries[i].cb1; | ||
147 | buf[3] = desc->entries[i].cb2; | ||
148 | |||
149 | if (desc->setbw) | ||
150 | desc->setbw(buf, bandwidth); | ||
151 | |||
152 | if (debug) | ||
153 | printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", | ||
154 | desc->name, div, buf[0], buf[1], buf[2], buf[3]); | ||
155 | |||
156 | return 0; | ||
157 | } | ||
158 | EXPORT_SYMBOL(dvb_pll_configure); | ||
159 | |||
160 | MODULE_DESCRIPTION("dvb pll library"); | ||
161 | MODULE_AUTHOR("Gerd Knorr"); | ||
162 | MODULE_LICENSE("GPL"); | ||
163 | |||
164 | /* | ||
165 | * Local variables: | ||
166 | * c-basic-offset: 8 | ||
167 | * End: | ||
168 | */ | ||