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 | 83ac8722 | 2006-01-09 15:25:29 -0200 | [diff] [blame] | 110 | struct 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, |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 115 | .count = 3, |
| 116 | .entries = { |
Michael Krufky | 83ac8722 | 2006-01-09 15:25:29 -0200 | [diff] [blame] | 117 | { 147000000, 44000000, 62500, 0x8e, 0x39 }, |
| 118 | { 417000000, 44000000, 62500, 0x8e, 0x3a }, |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 119 | { 999999999, 44000000, 62500, 0x8e, 0x3c }, |
| 120 | }, |
| 121 | }; |
Michael Krufky | 83ac8722 | 2006-01-09 15:25:29 -0200 | [diff] [blame] | 122 | EXPORT_SYMBOL(dvb_pll_thomson_dtt761x); |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | struct 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 | }; |
| 141 | EXPORT_SYMBOL(dvb_pll_unknown_1); |
| 142 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 143 | /* Infineon TUA6010XS |
| 144 | * used in Thomson Cable Tuner |
| 145 | */ |
| 146 | struct 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 | }; |
| 157 | EXPORT_SYMBOL(dvb_pll_tua6010xs); |
| 158 | |
| 159 | /* Panasonic env57h1xd5 (some Philips PLL ?) */ |
| 160 | struct 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 | }; |
| 172 | EXPORT_SYMBOL(dvb_pll_env57h1xd5); |
| 173 | |
| 174 | /* Philips TDA6650/TDA6651 |
| 175 | * used in Panasonic ENV77H11D5 |
| 176 | */ |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 177 | static void tda665x_bw(u8 *buf, u32 freq, int bandwidth) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 178 | { |
| 179 | if (bandwidth == BANDWIDTH_8_MHZ) |
| 180 | buf[3] |= 0x08; |
| 181 | } |
| 182 | |
| 183 | struct 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 */ }, |
Andrew de Quincey | 93e2b1a | 2006-07-10 03:34:15 -0300 | [diff] [blame] | 197 | { 444000000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ }, |
| 198 | { 583834000, 36249333, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ }, |
| 199 | { 793834000, 36249333, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ }, |
| 200 | { 444834000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ }, |
| 201 | { 861000000, 36249333, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ }, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 202 | } |
| 203 | }; |
| 204 | EXPORT_SYMBOL(dvb_pll_tda665x); |
| 205 | |
| 206 | /* Infineon TUA6034 |
| 207 | * used in LG TDTP E102P |
| 208 | */ |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 209 | static void tua6034_bw(u8 *buf, u32 freq, int bandwidth) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 210 | { |
| 211 | if (BANDWIDTH_7_MHZ != bandwidth) |
| 212 | buf[3] |= 0x08; |
| 213 | } |
| 214 | |
| 215 | struct 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 | }; |
| 227 | EXPORT_SYMBOL(dvb_pll_tua6034); |
| 228 | |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 229 | /* Infineon TUA6034 |
Michael Krufky | d9e12f2 | 2006-04-22 16:15:11 -0300 | [diff] [blame] | 230 | * used in LG TDVS-H061F, LG TDVS-H062F and LG TDVS-H064F |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 231 | */ |
Michael Krufky | 30fa61a | 2006-04-27 01:31:26 -0300 | [diff] [blame] | 232 | struct dvb_pll_desc dvb_pll_lg_tdvs_h06xf = { |
Michael Krufky | d9e12f2 | 2006-04-22 16:15:11 -0300 | [diff] [blame] | 233 | .name = "LG TDVS-H06xF", |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 234 | .min = 54000000, |
| 235 | .max = 863000000, |
| 236 | .count = 3, |
| 237 | .entries = { |
Rusty Scott | dd31d5ac | 2006-04-22 16:15:07 -0300 | [diff] [blame] | 238 | { 165000000, 44000000, 62500, 0xce, 0x01 }, |
| 239 | { 450000000, 44000000, 62500, 0xce, 0x02 }, |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 240 | { 999999999, 44000000, 62500, 0xce, 0x04 }, |
| 241 | }, |
| 242 | }; |
Michael Krufky | 30fa61a | 2006-04-27 01:31:26 -0300 | [diff] [blame] | 243 | EXPORT_SYMBOL(dvb_pll_lg_tdvs_h06xf); |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 244 | |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 245 | /* Philips FMD1216ME |
| 246 | * used in Medion Hybrid PCMCIA card and USB Box |
| 247 | */ |
| 248 | static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth) |
| 249 | { |
| 250 | if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000) |
| 251 | buf[3] |= 0x08; |
| 252 | } |
| 253 | |
| 254 | struct dvb_pll_desc dvb_pll_fmd1216me = { |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 255 | .name = "Philips FMD1216ME", |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 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 | }; |
| 270 | EXPORT_SYMBOL(dvb_pll_fmd1216me); |
| 271 | |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 272 | /* ALPS TDED4 |
| 273 | * used in Nebula-Cards and USB boxes |
| 274 | */ |
| 275 | static void tded4_bw(u8 *buf, u32 freq, int bandwidth) |
| 276 | { |
| 277 | if (bandwidth == BANDWIDTH_8_MHZ) |
| 278 | buf[3] |= 0x04; |
| 279 | } |
| 280 | |
| 281 | struct 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 | }; |
| 294 | EXPORT_SYMBOL(dvb_pll_tded4); |
| 295 | |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 296 | /* ALPS TDHU2 |
| 297 | * used in AverTVHD MCE A180 |
| 298 | */ |
| 299 | struct 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 | }; |
| 311 | EXPORT_SYMBOL(dvb_pll_tdhu2); |
| 312 | |
| 313 | /* Philips TUV1236D |
| 314 | * used in ATI HDTV Wonder |
| 315 | */ |
| 316 | struct dvb_pll_desc dvb_pll_tuv1236d = { |
| 317 | .name = "Philips TUV1236D", |
Kirk Lapray | 04a4592 | 2005-11-08 21:35:46 -0800 | [diff] [blame] | 318 | .min = 54000000, |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 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 | }; |
| 327 | EXPORT_SYMBOL(dvb_pll_tuv1236d); |
| 328 | |
Michael Krufky | d76a617 | 2006-01-23 17:11:06 -0200 | [diff] [blame] | 329 | /* Samsung TBMV30111IN / TBMV30712IN1 |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 330 | * used in Air2PC ATSC - 2nd generation (nxt2002) |
| 331 | */ |
Michael Krufky | 28f3d4b | 2006-01-23 17:11:07 -0200 | [diff] [blame] | 332 | struct dvb_pll_desc dvb_pll_samsung_tbmv = { |
| 333 | .name = "Samsung TBMV30111IN / TBMV30712IN1", |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 334 | .min = 54000000, |
| 335 | .max = 860000000, |
Michael Krufky | 17c37ef | 2006-01-15 19:04:04 -0200 | [diff] [blame] | 336 | .count = 6, |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 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 | }; |
Michael Krufky | 28f3d4b | 2006-01-23 17:11:07 -0200 | [diff] [blame] | 346 | EXPORT_SYMBOL(dvb_pll_samsung_tbmv); |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 347 | |
Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 348 | /* |
| 349 | * Philips SD1878 Tuner. |
| 350 | */ |
| 351 | struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = { |
| 352 | .name = "Philips SD1878", |
| 353 | .min = 950000, |
| 354 | .max = 2150000, |
| 355 | .count = 4, |
| 356 | .entries = { |
| 357 | { 1250000, 499, 500, 0xc4, 0x00}, |
| 358 | { 1550000, 499, 500, 0xc4, 0x40}, |
| 359 | { 2050000, 499, 500, 0xc4, 0x80}, |
| 360 | { 2150000, 499, 500, 0xc4, 0xc0}, |
| 361 | }, |
| 362 | }; |
| 363 | EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261); |
| 364 | |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 365 | /* |
| 366 | * Philips TD1316 Tuner. |
| 367 | */ |
| 368 | static void td1316_bw(u8 *buf, u32 freq, int bandwidth) |
| 369 | { |
| 370 | u8 band; |
| 371 | |
| 372 | /* determine band */ |
| 373 | if (freq < 161000000) |
| 374 | band = 1; |
| 375 | else if (freq < 444000000) |
| 376 | band = 2; |
| 377 | else |
| 378 | band = 4; |
| 379 | |
| 380 | buf[3] |= band; |
| 381 | |
| 382 | /* setup PLL filter */ |
| 383 | if (bandwidth == BANDWIDTH_8_MHZ) |
| 384 | buf[3] |= 1 << 3; |
| 385 | } |
| 386 | |
| 387 | struct dvb_pll_desc dvb_pll_philips_td1316 = { |
| 388 | .name = "Philips TD1316", |
| 389 | .min = 87000000, |
| 390 | .max = 895000000, |
| 391 | .setbw = td1316_bw, |
| 392 | .count = 9, |
| 393 | .entries = { |
| 394 | { 93834000, 36166000, 166666, 0xca, 0x60}, |
| 395 | { 123834000, 36166000, 166666, 0xca, 0xa0}, |
| 396 | { 163834000, 36166000, 166666, 0xca, 0xc0}, |
| 397 | { 253834000, 36166000, 166666, 0xca, 0x60}, |
| 398 | { 383834000, 36166000, 166666, 0xca, 0xa0}, |
| 399 | { 443834000, 36166000, 166666, 0xca, 0xc0}, |
| 400 | { 583834000, 36166000, 166666, 0xca, 0x60}, |
| 401 | { 793834000, 36166000, 166666, 0xca, 0xa0}, |
| 402 | { 858834000, 36166000, 166666, 0xca, 0xe0}, |
| 403 | }, |
| 404 | }; |
| 405 | EXPORT_SYMBOL(dvb_pll_philips_td1316); |
| 406 | |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 407 | /* FE6600 used on DViCO Hybrid */ |
Michael Krufky | 91ae329 | 2006-03-01 00:04:42 -0300 | [diff] [blame] | 408 | struct dvb_pll_desc dvb_pll_thomson_fe6600 = { |
| 409 | .name = "Thomson FE6600", |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 410 | .min = 44250000, |
| 411 | .max = 858000000, |
| 412 | .count = 4, |
| 413 | .entries = { |
| 414 | { 250000000, 36213333, 166667, 0xb4, 0x12 }, |
| 415 | { 455000000, 36213333, 166667, 0xfe, 0x11 }, |
| 416 | { 775500000, 36213333, 166667, 0xbc, 0x18 }, |
| 417 | { 999999999, 36213333, 166667, 0xf4, 0x18 }, |
| 418 | } |
| 419 | }; |
Michael Krufky | 91ae329 | 2006-03-01 00:04:42 -0300 | [diff] [blame] | 420 | EXPORT_SYMBOL(dvb_pll_thomson_fe6600); |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 421 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 422 | struct dvb_pll_priv { |
| 423 | /* i2c details */ |
| 424 | int pll_i2c_address; |
| 425 | struct i2c_adapter *i2c; |
| 426 | |
| 427 | /* the PLL descriptor */ |
| 428 | struct dvb_pll_desc *pll_desc; |
| 429 | |
| 430 | /* cached frequency/bandwidth */ |
| 431 | u32 frequency; |
| 432 | u32 bandwidth; |
| 433 | }; |
| 434 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | /* ----------------------------------------------------------- */ |
| 436 | /* code */ |
| 437 | |
| 438 | static int debug = 0; |
| 439 | module_param(debug, int, 0644); |
| 440 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 441 | |
| 442 | int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, |
| 443 | u32 freq, int bandwidth) |
| 444 | { |
| 445 | u32 div; |
| 446 | int i; |
| 447 | |
| 448 | if (freq != 0 && (freq < desc->min || freq > desc->max)) |
| 449 | return -EINVAL; |
| 450 | |
| 451 | for (i = 0; i < desc->count; i++) { |
| 452 | if (freq > desc->entries[i].limit) |
| 453 | continue; |
| 454 | break; |
| 455 | } |
| 456 | if (debug) |
| 457 | printk("pll: %s: freq=%d bw=%d | i=%d/%d\n", |
| 458 | desc->name, freq, bandwidth, i, desc->count); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 459 | if (i == desc->count) |
| 460 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
| 462 | div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize; |
| 463 | buf[0] = div >> 8; |
| 464 | buf[1] = div & 0xff; |
Michael Krufky | ab66b22 | 2006-01-23 17:11:11 -0200 | [diff] [blame] | 465 | buf[2] = desc->entries[i].config; |
| 466 | buf[3] = desc->entries[i].cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | |
| 468 | if (desc->setbw) |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 469 | desc->setbw(buf, freq, bandwidth); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | |
| 471 | if (debug) |
| 472 | printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", |
| 473 | desc->name, div, buf[0], buf[1], buf[2], buf[3]); |
| 474 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 475 | // calculate the frequency we set it to |
| 476 | return (div * desc->entries[i].stepsize) - desc->entries[i].offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | } |
| 478 | EXPORT_SYMBOL(dvb_pll_configure); |
| 479 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 480 | static int dvb_pll_release(struct dvb_frontend *fe) |
| 481 | { |
Michael Krufky | 2213918 | 2006-11-19 19:49:11 -0300 | [diff] [blame] | 482 | kfree(fe->tuner_priv); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 483 | fe->tuner_priv = NULL; |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | static int dvb_pll_sleep(struct dvb_frontend *fe) |
| 488 | { |
| 489 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 490 | u8 buf[4]; |
| 491 | struct i2c_msg msg = |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 492 | { .addr = priv->pll_i2c_address, .flags = 0, |
| 493 | .buf = buf, .len = sizeof(buf) }; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 494 | int i; |
| 495 | int result; |
| 496 | |
Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 497 | if (priv->i2c == NULL) |
| 498 | return -EINVAL; |
| 499 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 500 | for (i = 0; i < priv->pll_desc->count; i++) { |
| 501 | if (priv->pll_desc->entries[i].limit == 0) |
| 502 | break; |
| 503 | } |
| 504 | if (i == priv->pll_desc->count) |
| 505 | return 0; |
| 506 | |
| 507 | buf[0] = 0; |
| 508 | buf[1] = 0; |
| 509 | buf[2] = priv->pll_desc->entries[i].config; |
| 510 | buf[3] = priv->pll_desc->entries[i].cb; |
| 511 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 512 | if (fe->ops.i2c_gate_ctrl) |
| 513 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 514 | if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { |
| 515 | return result; |
| 516 | } |
| 517 | |
| 518 | return 0; |
| 519 | } |
| 520 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 521 | static int dvb_pll_set_params(struct dvb_frontend *fe, |
| 522 | struct dvb_frontend_parameters *params) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 523 | { |
| 524 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 525 | u8 buf[4]; |
| 526 | struct i2c_msg msg = |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 527 | { .addr = priv->pll_i2c_address, .flags = 0, |
| 528 | .buf = buf, .len = sizeof(buf) }; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 529 | int result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 530 | u32 bandwidth = 0, frequency = 0; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 531 | |
| 532 | if (priv->i2c == NULL) |
| 533 | return -EINVAL; |
| 534 | |
| 535 | // DVBT bandwidth only just now |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 536 | if (fe->ops.info.type == FE_OFDM) { |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 537 | bandwidth = params->u.ofdm.bandwidth; |
| 538 | } |
| 539 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 540 | if ((result = dvb_pll_configure(priv->pll_desc, buf, |
| 541 | params->frequency, bandwidth)) < 0) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 542 | return result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 543 | else |
| 544 | frequency = result; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 545 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 546 | if (fe->ops.i2c_gate_ctrl) |
| 547 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 548 | if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { |
| 549 | return result; |
| 550 | } |
| 551 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 552 | priv->frequency = frequency; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 553 | priv->bandwidth = bandwidth; |
| 554 | |
| 555 | return 0; |
| 556 | } |
| 557 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 558 | static int dvb_pll_calc_regs(struct dvb_frontend *fe, |
| 559 | struct dvb_frontend_parameters *params, |
| 560 | u8 *buf, int buf_len) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 561 | { |
| 562 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 563 | int result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 564 | u32 bandwidth = 0, frequency = 0; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 565 | |
| 566 | if (buf_len < 5) |
| 567 | return -EINVAL; |
| 568 | |
| 569 | // DVBT bandwidth only just now |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 570 | if (fe->ops.info.type == FE_OFDM) { |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 571 | bandwidth = params->u.ofdm.bandwidth; |
| 572 | } |
| 573 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 574 | if ((result = dvb_pll_configure(priv->pll_desc, buf+1, |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 575 | params->frequency, bandwidth)) < 0) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 576 | return result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 577 | else |
| 578 | frequency = result; |
| 579 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 580 | buf[0] = priv->pll_i2c_address; |
| 581 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 582 | priv->frequency = frequency; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 583 | priv->bandwidth = bandwidth; |
| 584 | |
| 585 | return 5; |
| 586 | } |
| 587 | |
| 588 | static int dvb_pll_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
| 589 | { |
| 590 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 591 | *frequency = priv->frequency; |
| 592 | return 0; |
| 593 | } |
| 594 | |
| 595 | static int dvb_pll_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) |
| 596 | { |
| 597 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 598 | *bandwidth = priv->bandwidth; |
| 599 | return 0; |
| 600 | } |
| 601 | |
| 602 | static struct dvb_tuner_ops dvb_pll_tuner_ops = { |
| 603 | .release = dvb_pll_release, |
| 604 | .sleep = dvb_pll_sleep, |
| 605 | .set_params = dvb_pll_set_params, |
Andrew de Quincey | bd4956b | 2006-04-18 21:38:49 -0300 | [diff] [blame] | 606 | .calc_regs = dvb_pll_calc_regs, |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 607 | .get_frequency = dvb_pll_get_frequency, |
| 608 | .get_bandwidth = dvb_pll_get_bandwidth, |
| 609 | }; |
| 610 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 611 | struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, |
| 612 | struct i2c_adapter *i2c, |
| 613 | struct dvb_pll_desc *desc) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 614 | { |
Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 615 | u8 b1 [] = { 0 }; |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 616 | struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, |
| 617 | .buf = b1, .len = 1 }; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 618 | struct dvb_pll_priv *priv = NULL; |
Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 619 | int ret; |
| 620 | |
Andrew de Quincey | 55c05b6 | 2006-07-16 19:41:41 -0300 | [diff] [blame] | 621 | if (i2c != NULL) { |
| 622 | if (fe->ops.i2c_gate_ctrl) |
| 623 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 624 | |
Andrew de Quincey | 95faba2 | 2006-07-18 16:37:13 -0300 | [diff] [blame] | 625 | ret = i2c_transfer (i2c, &msg, 1); |
| 626 | if (ret != 1) |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 627 | return NULL; |
Andrew de Quincey | 55c05b6 | 2006-07-16 19:41:41 -0300 | [diff] [blame] | 628 | if (fe->ops.i2c_gate_ctrl) |
| 629 | fe->ops.i2c_gate_ctrl(fe, 0); |
| 630 | } |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 631 | |
| 632 | priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL); |
| 633 | if (priv == NULL) |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 634 | return NULL; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 635 | |
| 636 | priv->pll_i2c_address = pll_addr; |
| 637 | priv->i2c = i2c; |
| 638 | priv->pll_desc = desc; |
| 639 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 640 | memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops, |
| 641 | sizeof(struct dvb_tuner_ops)); |
| 642 | |
Trent Piepho | 982dd1b | 2007-04-27 12:31:27 -0300 | [diff] [blame^] | 643 | strncpy(fe->ops.tuner_ops.info.name, desc->name, |
| 644 | sizeof(fe->ops.tuner_ops.info.name)); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 645 | fe->ops.tuner_ops.info.frequency_min = desc->min; |
| 646 | fe->ops.tuner_ops.info.frequency_min = desc->max; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 647 | |
| 648 | fe->tuner_priv = priv; |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 649 | return fe; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 650 | } |
| 651 | EXPORT_SYMBOL(dvb_pll_attach); |
| 652 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | MODULE_DESCRIPTION("dvb pll library"); |
| 654 | MODULE_AUTHOR("Gerd Knorr"); |
| 655 | MODULE_LICENSE("GPL"); |