| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 58 | static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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, | 
| Gregory B Frost | 9e00e48 | 2005-07-27 11:45:48 -0700 | [diff] [blame] | 85 | 	.count = 6, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | 	.entries = { | 
 | 87 | 		{          0, 36166667, 166666, 0xbc, 0x03 }, | 
| Gregory B Frost | 9e00e48 | 2005-07-27 11:45:48 -0700 | [diff] [blame] | 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 }, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | 	}, | 
 | 94 | }; | 
 | 95 | EXPORT_SYMBOL(dvb_pll_lg_z201); | 
 | 96 |  | 
| Mac Michaels | d8667cb | 2005-07-07 17:58:29 -0700 | [diff] [blame] | 97 | struct 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 | }; | 
 | 108 | EXPORT_SYMBOL(dvb_pll_microtune_4042); | 
 | 109 |  | 
| Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 110 | struct dvb_pll_desc dvb_pll_thomson_dtt7611 = { | 
 | 111 | 	.name  = "Thomson dtt7611", | 
 | 112 | 	.min   =  44000000, | 
 | 113 | 	.max   = 958000000, | 
 | 114 | 	.count = 3, | 
 | 115 | 	.entries = { | 
 | 116 | 		{ 157250000, 44000000, 62500, 0x8e, 0x39 }, | 
 | 117 | 		{ 454000000, 44000000, 62500, 0x8e, 0x3a }, | 
 | 118 | 		{ 999999999, 44000000, 62500, 0x8e, 0x3c }, | 
 | 119 | 	}, | 
 | 120 | }; | 
 | 121 | EXPORT_SYMBOL(dvb_pll_thomson_dtt7611); | 
 | 122 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | struct dvb_pll_desc dvb_pll_unknown_1 = { | 
 | 124 | 	.name  = "unknown 1", /* used by dntv live dvb-t */ | 
 | 125 | 	.min   = 174000000, | 
 | 126 | 	.max   = 862000000, | 
 | 127 | 	.count = 9, | 
 | 128 | 	.entries = { | 
 | 129 | 		{  150000000, 36166667, 166666, 0xb4, 0x01 }, | 
 | 130 | 		{  173000000, 36166667, 166666, 0xbc, 0x01 }, | 
 | 131 | 		{  250000000, 36166667, 166666, 0xb4, 0x02 }, | 
 | 132 | 		{  400000000, 36166667, 166666, 0xbc, 0x02 }, | 
 | 133 | 		{  420000000, 36166667, 166666, 0xf4, 0x02 }, | 
 | 134 | 		{  470000000, 36166667, 166666, 0xfc, 0x02 }, | 
 | 135 | 		{  600000000, 36166667, 166666, 0xbc, 0x08 }, | 
 | 136 | 		{  730000000, 36166667, 166666, 0xf4, 0x08 }, | 
 | 137 | 		{  999999999, 36166667, 166666, 0xfc, 0x08 }, | 
 | 138 | 	}, | 
 | 139 | }; | 
 | 140 | EXPORT_SYMBOL(dvb_pll_unknown_1); | 
 | 141 |  | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 142 | /* Infineon TUA6010XS | 
 | 143 |  * used in Thomson Cable Tuner | 
 | 144 |  */ | 
 | 145 | struct dvb_pll_desc dvb_pll_tua6010xs = { | 
 | 146 | 	.name  = "Infineon TUA6010XS", | 
 | 147 | 	.min   =  44250000, | 
 | 148 | 	.max   = 858000000, | 
 | 149 | 	.count = 3, | 
 | 150 | 	.entries = { | 
 | 151 | 		{  115750000, 36125000, 62500, 0x8e, 0x03 }, | 
 | 152 | 		{  403250000, 36125000, 62500, 0x8e, 0x06 }, | 
 | 153 | 		{  999999999, 36125000, 62500, 0x8e, 0x85 }, | 
 | 154 | 	}, | 
 | 155 | }; | 
 | 156 | EXPORT_SYMBOL(dvb_pll_tua6010xs); | 
 | 157 |  | 
 | 158 | /* Panasonic env57h1xd5 (some Philips PLL ?) */ | 
 | 159 | struct dvb_pll_desc dvb_pll_env57h1xd5 = { | 
 | 160 | 	.name  = "Panasonic ENV57H1XD5", | 
 | 161 | 	.min   =  44250000, | 
 | 162 | 	.max   = 858000000, | 
 | 163 | 	.count = 4, | 
 | 164 | 	.entries = { | 
 | 165 | 		{  153000000, 36291666, 166666, 0xc2, 0x41 }, | 
 | 166 | 		{  470000000, 36291666, 166666, 0xc2, 0x42 }, | 
 | 167 | 		{  526000000, 36291666, 166666, 0xc2, 0x84 }, | 
 | 168 | 		{  999999999, 36291666, 166666, 0xc2, 0xa4 }, | 
 | 169 | 	}, | 
 | 170 | }; | 
 | 171 | EXPORT_SYMBOL(dvb_pll_env57h1xd5); | 
 | 172 |  | 
 | 173 | /* Philips TDA6650/TDA6651 | 
 | 174 |  * used in Panasonic ENV77H11D5 | 
 | 175 |  */ | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 176 | static void tda665x_bw(u8 *buf, u32 freq, int bandwidth) | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 177 | { | 
 | 178 | 	if (bandwidth == BANDWIDTH_8_MHZ) | 
 | 179 | 		buf[3] |= 0x08; | 
 | 180 | } | 
 | 181 |  | 
 | 182 | struct dvb_pll_desc dvb_pll_tda665x = { | 
 | 183 | 	.name  = "Philips TDA6650/TDA6651", | 
 | 184 | 	.min   =  44250000, | 
 | 185 | 	.max   = 858000000, | 
 | 186 | 	.setbw = tda665x_bw, | 
 | 187 | 	.count = 12, | 
 | 188 | 	.entries = { | 
 | 189 | 		{   93834000, 36249333, 166667, 0xca, 0x61 /* 011 0 0 0  01 */ }, | 
 | 190 | 		{  123834000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0  01 */ }, | 
 | 191 | 		{  161000000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0  01 */ }, | 
 | 192 | 		{  163834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0  10 */ }, | 
 | 193 | 		{  253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0  10 */ }, | 
 | 194 | 		{  383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0  10 */ }, | 
 | 195 | 		{  443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0  10 */ }, | 
 | 196 | 		{  444000000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0  11 */ }, | 
 | 197 | 		{  583834000, 36249333, 166667, 0xca, 0x63 /* 011 0 0 0  11 */ }, | 
 | 198 | 		{  793834000, 36249333, 166667, 0xca, 0xa3 /* 101 0 0 0  11 */ }, | 
 | 199 | 		{  444834000, 36249333, 166667, 0xca, 0xc3 /* 110 0 0 0  11 */ }, | 
 | 200 | 		{  861000000, 36249333, 166667, 0xca, 0xe3 /* 111 0 0 0  11 */ }, | 
 | 201 | 	} | 
 | 202 | }; | 
 | 203 | EXPORT_SYMBOL(dvb_pll_tda665x); | 
 | 204 |  | 
 | 205 | /* Infineon TUA6034 | 
 | 206 |  * used in LG TDTP E102P | 
 | 207 |  */ | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 208 | static void tua6034_bw(u8 *buf, u32 freq, int bandwidth) | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 209 | { | 
 | 210 | 	if (BANDWIDTH_7_MHZ != bandwidth) | 
 | 211 | 		buf[3] |= 0x08; | 
 | 212 | } | 
 | 213 |  | 
 | 214 | struct dvb_pll_desc dvb_pll_tua6034 = { | 
 | 215 | 	.name  = "Infineon TUA6034", | 
 | 216 | 	.min   =  44250000, | 
 | 217 | 	.max   = 858000000, | 
 | 218 | 	.count = 3, | 
 | 219 | 	.setbw = tua6034_bw, | 
 | 220 | 	.entries = { | 
 | 221 | 		{  174500000, 36166667, 62500, 0xce, 0x01 }, | 
 | 222 | 		{  230000000, 36166667, 62500, 0xce, 0x02 }, | 
 | 223 | 		{  999999999, 36166667, 62500, 0xce, 0x04 }, | 
 | 224 | 	}, | 
 | 225 | }; | 
 | 226 | EXPORT_SYMBOL(dvb_pll_tua6034); | 
 | 227 |  | 
| Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 228 | /* Infineon TUA6034 | 
| Michael Krufky | c0b11b9 | 2005-11-08 21:35:32 -0800 | [diff] [blame^] | 229 |  * used in LG TDVS H061F and LG TDVS H062F | 
| Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 230 |  */ | 
 | 231 | struct dvb_pll_desc dvb_pll_tdvs_tua6034 = { | 
 | 232 | 	.name  = "LG/Infineon TUA6034", | 
 | 233 | 	.min   =  54000000, | 
 | 234 | 	.max   = 863000000, | 
 | 235 | 	.count = 3, | 
 | 236 | 	.entries = { | 
 | 237 | 		{  160000000, 44000000, 62500, 0xce, 0x01 }, | 
 | 238 | 		{  455000000, 44000000, 62500, 0xce, 0x02 }, | 
 | 239 | 		{  999999999, 44000000, 62500, 0xce, 0x04 }, | 
 | 240 | 	}, | 
 | 241 | }; | 
 | 242 | EXPORT_SYMBOL(dvb_pll_tdvs_tua6034); | 
 | 243 |  | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 244 | /* Philips FMD1216ME | 
 | 245 |  * used in Medion Hybrid PCMCIA card and USB Box | 
 | 246 |  */ | 
 | 247 | static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth) | 
 | 248 | { | 
 | 249 | 	if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000) | 
 | 250 | 		buf[3] |= 0x08; | 
 | 251 | } | 
 | 252 |  | 
 | 253 | struct dvb_pll_desc dvb_pll_fmd1216me = { | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 254 | 	.name = "Philips FMD1216ME", | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 255 | 	.min = 50870000, | 
 | 256 | 	.max = 858000000, | 
 | 257 | 	.setbw = fmd1216me_bw, | 
 | 258 | 	.count = 7, | 
 | 259 | 	.entries = { | 
 | 260 | 		{ 143870000, 36213333, 166667, 0xbc, 0x41 }, | 
 | 261 | 		{ 158870000, 36213333, 166667, 0xf4, 0x41 }, | 
 | 262 | 		{ 329870000, 36213333, 166667, 0xbc, 0x42 }, | 
 | 263 | 		{ 441870000, 36213333, 166667, 0xf4, 0x42 }, | 
 | 264 | 		{ 625870000, 36213333, 166667, 0xbc, 0x44 }, | 
 | 265 | 		{ 803870000, 36213333, 166667, 0xf4, 0x44 }, | 
 | 266 | 		{ 999999999, 36213333, 166667, 0xfc, 0x44 }, | 
 | 267 | 	} | 
 | 268 | }; | 
 | 269 | EXPORT_SYMBOL(dvb_pll_fmd1216me); | 
 | 270 |  | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 271 | /* ALPS TDED4 | 
 | 272 |  * used in Nebula-Cards and USB boxes | 
 | 273 |  */ | 
 | 274 | static void tded4_bw(u8 *buf, u32 freq, int bandwidth) | 
 | 275 | { | 
 | 276 | 	if (bandwidth == BANDWIDTH_8_MHZ) | 
 | 277 | 		buf[3] |= 0x04; | 
 | 278 | } | 
 | 279 |  | 
 | 280 | struct dvb_pll_desc dvb_pll_tded4 = { | 
 | 281 | 	.name = "ALPS TDED4", | 
 | 282 | 	.min = 47000000, | 
 | 283 | 	.max = 863000000, | 
 | 284 | 	.setbw = tded4_bw, | 
 | 285 | 	.count = 4, | 
 | 286 | 	.entries = { | 
 | 287 | 		{ 153000000, 36166667, 166667, 0x85, 0x01 }, | 
 | 288 | 		{ 470000000, 36166667, 166667, 0x85, 0x02 }, | 
 | 289 | 		{ 823000000, 36166667, 166667, 0x85, 0x08 }, | 
 | 290 | 		{ 999999999, 36166667, 166667, 0x85, 0x88 }, | 
 | 291 | 	} | 
 | 292 | }; | 
 | 293 | EXPORT_SYMBOL(dvb_pll_tded4); | 
 | 294 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | /* ----------------------------------------------------------- */ | 
 | 296 | /* code                                                        */ | 
 | 297 |  | 
 | 298 | static int debug = 0; | 
 | 299 | module_param(debug, int, 0644); | 
 | 300 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 
 | 301 |  | 
 | 302 | int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, | 
 | 303 | 		      u32 freq, int bandwidth) | 
 | 304 | { | 
 | 305 | 	u32 div; | 
 | 306 | 	int i; | 
 | 307 |  | 
 | 308 | 	if (freq != 0 && (freq < desc->min || freq > desc->max)) | 
 | 309 | 	    return -EINVAL; | 
 | 310 |  | 
 | 311 | 	for (i = 0; i < desc->count; i++) { | 
 | 312 | 		if (freq > desc->entries[i].limit) | 
 | 313 | 			continue; | 
 | 314 | 		break; | 
 | 315 | 	} | 
 | 316 | 	if (debug) | 
 | 317 | 		printk("pll: %s: freq=%d bw=%d | i=%d/%d\n", | 
 | 318 | 		       desc->name, freq, bandwidth, i, desc->count); | 
 | 319 | 	BUG_ON(i == desc->count); | 
 | 320 |  | 
 | 321 | 	div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize; | 
 | 322 | 	buf[0] = div >> 8; | 
 | 323 | 	buf[1] = div & 0xff; | 
 | 324 | 	buf[2] = desc->entries[i].cb1; | 
 | 325 | 	buf[3] = desc->entries[i].cb2; | 
 | 326 |  | 
 | 327 | 	if (desc->setbw) | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 328 | 		desc->setbw(buf, freq, bandwidth); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 |  | 
 | 330 | 	if (debug) | 
 | 331 | 		printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", | 
 | 332 | 		       desc->name, div, buf[0], buf[1], buf[2], buf[3]); | 
 | 333 |  | 
 | 334 | 	return 0; | 
 | 335 | } | 
 | 336 | EXPORT_SYMBOL(dvb_pll_configure); | 
 | 337 |  | 
 | 338 | MODULE_DESCRIPTION("dvb pll library"); | 
 | 339 | MODULE_AUTHOR("Gerd Knorr"); | 
 | 340 | MODULE_LICENSE("GPL"); |