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 | |
Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame^] | 30 | /* Set AGC TOP value to 103 dBuV: |
| 31 | 0x80 = Control Byte |
| 32 | 0x40 = 250 uA charge pump (irrelevant) |
| 33 | 0x18 = Aux Byte to follow |
| 34 | 0x06 = 64.5 kHz divider (irrelevant) |
| 35 | 0x01 = Disable Vt (aka sleep) |
| 36 | |
| 37 | 0x00 = AGC Time constant 2s Iagc = 300 nA (vs 0x80 = 9 nA) |
| 38 | 0x50 = AGC Take over point = 103 dBuV */ |
| 39 | static u8 tua603x_agc103[] = { 2, 0x80|0x40|0x18|0x06|0x01, 0x00|0x50 }; |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { |
| 42 | .name = "Thomson dtt7579", |
| 43 | .min = 177000000, |
| 44 | .max = 858000000, |
| 45 | .count = 5, |
| 46 | .entries = { |
| 47 | { 0, 36166667, 166666, 0xb4, 0x03 }, /* go sleep */ |
| 48 | { 443250000, 36166667, 166666, 0xb4, 0x02 }, |
| 49 | { 542000000, 36166667, 166666, 0xb4, 0x08 }, |
| 50 | { 771000000, 36166667, 166666, 0xbc, 0x08 }, |
| 51 | { 999999999, 36166667, 166666, 0xf4, 0x08 }, |
| 52 | }, |
| 53 | }; |
| 54 | EXPORT_SYMBOL(dvb_pll_thomson_dtt7579); |
| 55 | |
| 56 | struct dvb_pll_desc dvb_pll_thomson_dtt7610 = { |
| 57 | .name = "Thomson dtt7610", |
| 58 | .min = 44000000, |
| 59 | .max = 958000000, |
| 60 | .count = 3, |
| 61 | .entries = { |
| 62 | { 157250000, 44000000, 62500, 0x8e, 0x39 }, |
| 63 | { 454000000, 44000000, 62500, 0x8e, 0x3a }, |
| 64 | { 999999999, 44000000, 62500, 0x8e, 0x3c }, |
| 65 | }, |
| 66 | }; |
| 67 | EXPORT_SYMBOL(dvb_pll_thomson_dtt7610); |
| 68 | |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 69 | static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | { |
| 71 | if (BANDWIDTH_7_MHZ == bandwidth) |
| 72 | buf[3] |= 0x10; |
| 73 | } |
| 74 | |
| 75 | struct dvb_pll_desc dvb_pll_thomson_dtt759x = { |
| 76 | .name = "Thomson dtt759x", |
| 77 | .min = 177000000, |
| 78 | .max = 896000000, |
| 79 | .setbw = thomson_dtt759x_bw, |
| 80 | .count = 6, |
| 81 | .entries = { |
| 82 | { 0, 36166667, 166666, 0x84, 0x03 }, |
| 83 | { 264000000, 36166667, 166666, 0xb4, 0x02 }, |
| 84 | { 470000000, 36166667, 166666, 0xbc, 0x02 }, |
| 85 | { 735000000, 36166667, 166666, 0xbc, 0x08 }, |
| 86 | { 835000000, 36166667, 166666, 0xf4, 0x08 }, |
| 87 | { 999999999, 36166667, 166666, 0xfc, 0x08 }, |
| 88 | }, |
| 89 | }; |
| 90 | EXPORT_SYMBOL(dvb_pll_thomson_dtt759x); |
| 91 | |
| 92 | struct dvb_pll_desc dvb_pll_lg_z201 = { |
| 93 | .name = "LG z201", |
| 94 | .min = 174000000, |
| 95 | .max = 862000000, |
Gregory B Frost | 9e00e48 | 2005-07-27 11:45:48 -0700 | [diff] [blame] | 96 | .count = 6, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | .entries = { |
| 98 | { 0, 36166667, 166666, 0xbc, 0x03 }, |
Gregory B Frost | 9e00e48 | 2005-07-27 11:45:48 -0700 | [diff] [blame] | 99 | { 157500000, 36166667, 166666, 0xbc, 0x01 }, |
| 100 | { 443250000, 36166667, 166666, 0xbc, 0x02 }, |
| 101 | { 542000000, 36166667, 166666, 0xbc, 0x04 }, |
| 102 | { 830000000, 36166667, 166666, 0xf4, 0x04 }, |
| 103 | { 999999999, 36166667, 166666, 0xfc, 0x04 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | }, |
| 105 | }; |
| 106 | EXPORT_SYMBOL(dvb_pll_lg_z201); |
| 107 | |
Mac Michaels | d8667cb | 2005-07-07 17:58:29 -0700 | [diff] [blame] | 108 | struct dvb_pll_desc dvb_pll_microtune_4042 = { |
| 109 | .name = "Microtune 4042 FI5", |
| 110 | .min = 57000000, |
| 111 | .max = 858000000, |
| 112 | .count = 3, |
| 113 | .entries = { |
| 114 | { 162000000, 44000000, 62500, 0x8e, 0xa1 }, |
| 115 | { 457000000, 44000000, 62500, 0x8e, 0x91 }, |
| 116 | { 999999999, 44000000, 62500, 0x8e, 0x31 }, |
| 117 | }, |
| 118 | }; |
| 119 | EXPORT_SYMBOL(dvb_pll_microtune_4042); |
| 120 | |
Michael Krufky | 83ac8722 | 2006-01-09 15:25:29 -0200 | [diff] [blame] | 121 | struct dvb_pll_desc dvb_pll_thomson_dtt761x = { |
| 122 | /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */ |
| 123 | .name = "Thomson dtt761x", |
| 124 | .min = 57000000, |
| 125 | .max = 863000000, |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 126 | .count = 3, |
Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame^] | 127 | .initdata = tua603x_agc103, |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 128 | .entries = { |
Michael Krufky | 83ac8722 | 2006-01-09 15:25:29 -0200 | [diff] [blame] | 129 | { 147000000, 44000000, 62500, 0x8e, 0x39 }, |
| 130 | { 417000000, 44000000, 62500, 0x8e, 0x3a }, |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 131 | { 999999999, 44000000, 62500, 0x8e, 0x3c }, |
| 132 | }, |
| 133 | }; |
Michael Krufky | 83ac8722 | 2006-01-09 15:25:29 -0200 | [diff] [blame] | 134 | EXPORT_SYMBOL(dvb_pll_thomson_dtt761x); |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | struct dvb_pll_desc dvb_pll_unknown_1 = { |
| 137 | .name = "unknown 1", /* used by dntv live dvb-t */ |
| 138 | .min = 174000000, |
| 139 | .max = 862000000, |
| 140 | .count = 9, |
| 141 | .entries = { |
| 142 | { 150000000, 36166667, 166666, 0xb4, 0x01 }, |
| 143 | { 173000000, 36166667, 166666, 0xbc, 0x01 }, |
| 144 | { 250000000, 36166667, 166666, 0xb4, 0x02 }, |
| 145 | { 400000000, 36166667, 166666, 0xbc, 0x02 }, |
| 146 | { 420000000, 36166667, 166666, 0xf4, 0x02 }, |
| 147 | { 470000000, 36166667, 166666, 0xfc, 0x02 }, |
| 148 | { 600000000, 36166667, 166666, 0xbc, 0x08 }, |
| 149 | { 730000000, 36166667, 166666, 0xf4, 0x08 }, |
| 150 | { 999999999, 36166667, 166666, 0xfc, 0x08 }, |
| 151 | }, |
| 152 | }; |
| 153 | EXPORT_SYMBOL(dvb_pll_unknown_1); |
| 154 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 155 | /* Infineon TUA6010XS |
| 156 | * used in Thomson Cable Tuner |
| 157 | */ |
| 158 | struct dvb_pll_desc dvb_pll_tua6010xs = { |
| 159 | .name = "Infineon TUA6010XS", |
| 160 | .min = 44250000, |
| 161 | .max = 858000000, |
| 162 | .count = 3, |
| 163 | .entries = { |
| 164 | { 115750000, 36125000, 62500, 0x8e, 0x03 }, |
| 165 | { 403250000, 36125000, 62500, 0x8e, 0x06 }, |
| 166 | { 999999999, 36125000, 62500, 0x8e, 0x85 }, |
| 167 | }, |
| 168 | }; |
| 169 | EXPORT_SYMBOL(dvb_pll_tua6010xs); |
| 170 | |
| 171 | /* Panasonic env57h1xd5 (some Philips PLL ?) */ |
| 172 | struct dvb_pll_desc dvb_pll_env57h1xd5 = { |
| 173 | .name = "Panasonic ENV57H1XD5", |
| 174 | .min = 44250000, |
| 175 | .max = 858000000, |
| 176 | .count = 4, |
| 177 | .entries = { |
| 178 | { 153000000, 36291666, 166666, 0xc2, 0x41 }, |
| 179 | { 470000000, 36291666, 166666, 0xc2, 0x42 }, |
| 180 | { 526000000, 36291666, 166666, 0xc2, 0x84 }, |
| 181 | { 999999999, 36291666, 166666, 0xc2, 0xa4 }, |
| 182 | }, |
| 183 | }; |
| 184 | EXPORT_SYMBOL(dvb_pll_env57h1xd5); |
| 185 | |
| 186 | /* Philips TDA6650/TDA6651 |
| 187 | * used in Panasonic ENV77H11D5 |
| 188 | */ |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 189 | static void tda665x_bw(u8 *buf, u32 freq, int bandwidth) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 190 | { |
| 191 | if (bandwidth == BANDWIDTH_8_MHZ) |
| 192 | buf[3] |= 0x08; |
| 193 | } |
| 194 | |
| 195 | struct dvb_pll_desc dvb_pll_tda665x = { |
| 196 | .name = "Philips TDA6650/TDA6651", |
| 197 | .min = 44250000, |
| 198 | .max = 858000000, |
| 199 | .setbw = tda665x_bw, |
| 200 | .count = 12, |
| 201 | .entries = { |
| 202 | { 93834000, 36249333, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ }, |
| 203 | { 123834000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ }, |
| 204 | { 161000000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ }, |
| 205 | { 163834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ }, |
| 206 | { 253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ }, |
| 207 | { 383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ }, |
| 208 | { 443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ }, |
Andrew de Quincey | 93e2b1a | 2006-07-10 03:34:15 -0300 | [diff] [blame] | 209 | { 444000000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ }, |
| 210 | { 583834000, 36249333, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ }, |
| 211 | { 793834000, 36249333, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ }, |
| 212 | { 444834000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ }, |
| 213 | { 861000000, 36249333, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ }, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 214 | } |
| 215 | }; |
| 216 | EXPORT_SYMBOL(dvb_pll_tda665x); |
| 217 | |
| 218 | /* Infineon TUA6034 |
| 219 | * used in LG TDTP E102P |
| 220 | */ |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 221 | static void tua6034_bw(u8 *buf, u32 freq, int bandwidth) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 222 | { |
| 223 | if (BANDWIDTH_7_MHZ != bandwidth) |
| 224 | buf[3] |= 0x08; |
| 225 | } |
| 226 | |
| 227 | struct dvb_pll_desc dvb_pll_tua6034 = { |
| 228 | .name = "Infineon TUA6034", |
| 229 | .min = 44250000, |
| 230 | .max = 858000000, |
| 231 | .count = 3, |
| 232 | .setbw = tua6034_bw, |
| 233 | .entries = { |
| 234 | { 174500000, 36166667, 62500, 0xce, 0x01 }, |
| 235 | { 230000000, 36166667, 62500, 0xce, 0x02 }, |
| 236 | { 999999999, 36166667, 62500, 0xce, 0x04 }, |
| 237 | }, |
| 238 | }; |
| 239 | EXPORT_SYMBOL(dvb_pll_tua6034); |
| 240 | |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 241 | /* Infineon TUA6034 |
Michael Krufky | d9e12f2 | 2006-04-22 16:15:11 -0300 | [diff] [blame] | 242 | * used in LG TDVS-H061F, LG TDVS-H062F and LG TDVS-H064F |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 243 | */ |
Michael Krufky | 30fa61a | 2006-04-27 01:31:26 -0300 | [diff] [blame] | 244 | struct dvb_pll_desc dvb_pll_lg_tdvs_h06xf = { |
Michael Krufky | d9e12f2 | 2006-04-22 16:15:11 -0300 | [diff] [blame] | 245 | .name = "LG TDVS-H06xF", |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 246 | .min = 54000000, |
| 247 | .max = 863000000, |
| 248 | .count = 3, |
| 249 | .entries = { |
Rusty Scott | dd31d5ac | 2006-04-22 16:15:07 -0300 | [diff] [blame] | 250 | { 165000000, 44000000, 62500, 0xce, 0x01 }, |
| 251 | { 450000000, 44000000, 62500, 0xce, 0x02 }, |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 252 | { 999999999, 44000000, 62500, 0xce, 0x04 }, |
| 253 | }, |
| 254 | }; |
Michael Krufky | 30fa61a | 2006-04-27 01:31:26 -0300 | [diff] [blame] | 255 | EXPORT_SYMBOL(dvb_pll_lg_tdvs_h06xf); |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 256 | |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 257 | /* Philips FMD1216ME |
| 258 | * used in Medion Hybrid PCMCIA card and USB Box |
| 259 | */ |
| 260 | static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth) |
| 261 | { |
| 262 | if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000) |
| 263 | buf[3] |= 0x08; |
| 264 | } |
| 265 | |
| 266 | struct dvb_pll_desc dvb_pll_fmd1216me = { |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 267 | .name = "Philips FMD1216ME", |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 268 | .min = 50870000, |
| 269 | .max = 858000000, |
| 270 | .setbw = fmd1216me_bw, |
| 271 | .count = 7, |
| 272 | .entries = { |
| 273 | { 143870000, 36213333, 166667, 0xbc, 0x41 }, |
| 274 | { 158870000, 36213333, 166667, 0xf4, 0x41 }, |
| 275 | { 329870000, 36213333, 166667, 0xbc, 0x42 }, |
| 276 | { 441870000, 36213333, 166667, 0xf4, 0x42 }, |
| 277 | { 625870000, 36213333, 166667, 0xbc, 0x44 }, |
| 278 | { 803870000, 36213333, 166667, 0xf4, 0x44 }, |
| 279 | { 999999999, 36213333, 166667, 0xfc, 0x44 }, |
| 280 | } |
| 281 | }; |
| 282 | EXPORT_SYMBOL(dvb_pll_fmd1216me); |
| 283 | |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 284 | /* ALPS TDED4 |
| 285 | * used in Nebula-Cards and USB boxes |
| 286 | */ |
| 287 | static void tded4_bw(u8 *buf, u32 freq, int bandwidth) |
| 288 | { |
| 289 | if (bandwidth == BANDWIDTH_8_MHZ) |
| 290 | buf[3] |= 0x04; |
| 291 | } |
| 292 | |
| 293 | struct dvb_pll_desc dvb_pll_tded4 = { |
| 294 | .name = "ALPS TDED4", |
| 295 | .min = 47000000, |
| 296 | .max = 863000000, |
| 297 | .setbw = tded4_bw, |
| 298 | .count = 4, |
| 299 | .entries = { |
| 300 | { 153000000, 36166667, 166667, 0x85, 0x01 }, |
| 301 | { 470000000, 36166667, 166667, 0x85, 0x02 }, |
| 302 | { 823000000, 36166667, 166667, 0x85, 0x08 }, |
| 303 | { 999999999, 36166667, 166667, 0x85, 0x88 }, |
| 304 | } |
| 305 | }; |
| 306 | EXPORT_SYMBOL(dvb_pll_tded4); |
| 307 | |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 308 | /* ALPS TDHU2 |
| 309 | * used in AverTVHD MCE A180 |
| 310 | */ |
| 311 | struct dvb_pll_desc dvb_pll_tdhu2 = { |
| 312 | .name = "ALPS TDHU2", |
| 313 | .min = 54000000, |
| 314 | .max = 864000000, |
| 315 | .count = 4, |
| 316 | .entries = { |
| 317 | { 162000000, 44000000, 62500, 0x85, 0x01 }, |
| 318 | { 426000000, 44000000, 62500, 0x85, 0x02 }, |
| 319 | { 782000000, 44000000, 62500, 0x85, 0x08 }, |
| 320 | { 999999999, 44000000, 62500, 0x85, 0x88 }, |
| 321 | } |
| 322 | }; |
| 323 | EXPORT_SYMBOL(dvb_pll_tdhu2); |
| 324 | |
| 325 | /* Philips TUV1236D |
| 326 | * used in ATI HDTV Wonder |
| 327 | */ |
| 328 | struct dvb_pll_desc dvb_pll_tuv1236d = { |
| 329 | .name = "Philips TUV1236D", |
Kirk Lapray | 04a4592 | 2005-11-08 21:35:46 -0800 | [diff] [blame] | 330 | .min = 54000000, |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 331 | .max = 864000000, |
| 332 | .count = 3, |
| 333 | .entries = { |
| 334 | { 157250000, 44000000, 62500, 0xc6, 0x41 }, |
| 335 | { 454000000, 44000000, 62500, 0xc6, 0x42 }, |
| 336 | { 999999999, 44000000, 62500, 0xc6, 0x44 }, |
| 337 | }, |
| 338 | }; |
| 339 | EXPORT_SYMBOL(dvb_pll_tuv1236d); |
| 340 | |
Michael Krufky | d76a617 | 2006-01-23 17:11:06 -0200 | [diff] [blame] | 341 | /* Samsung TBMV30111IN / TBMV30712IN1 |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 342 | * used in Air2PC ATSC - 2nd generation (nxt2002) |
| 343 | */ |
Michael Krufky | 28f3d4b | 2006-01-23 17:11:07 -0200 | [diff] [blame] | 344 | struct dvb_pll_desc dvb_pll_samsung_tbmv = { |
| 345 | .name = "Samsung TBMV30111IN / TBMV30712IN1", |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 346 | .min = 54000000, |
| 347 | .max = 860000000, |
Michael Krufky | 17c37ef | 2006-01-15 19:04:04 -0200 | [diff] [blame] | 348 | .count = 6, |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 349 | .entries = { |
| 350 | { 172000000, 44000000, 166666, 0xb4, 0x01 }, |
| 351 | { 214000000, 44000000, 166666, 0xb4, 0x02 }, |
| 352 | { 467000000, 44000000, 166666, 0xbc, 0x02 }, |
| 353 | { 721000000, 44000000, 166666, 0xbc, 0x08 }, |
| 354 | { 841000000, 44000000, 166666, 0xf4, 0x08 }, |
| 355 | { 999999999, 44000000, 166666, 0xfc, 0x02 }, |
| 356 | } |
| 357 | }; |
Michael Krufky | 28f3d4b | 2006-01-23 17:11:07 -0200 | [diff] [blame] | 358 | EXPORT_SYMBOL(dvb_pll_samsung_tbmv); |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 359 | |
Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 360 | /* |
| 361 | * Philips SD1878 Tuner. |
| 362 | */ |
| 363 | struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = { |
| 364 | .name = "Philips SD1878", |
| 365 | .min = 950000, |
| 366 | .max = 2150000, |
| 367 | .count = 4, |
| 368 | .entries = { |
| 369 | { 1250000, 499, 500, 0xc4, 0x00}, |
| 370 | { 1550000, 499, 500, 0xc4, 0x40}, |
| 371 | { 2050000, 499, 500, 0xc4, 0x80}, |
| 372 | { 2150000, 499, 500, 0xc4, 0xc0}, |
| 373 | }, |
| 374 | }; |
| 375 | EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261); |
| 376 | |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 377 | /* |
| 378 | * Philips TD1316 Tuner. |
| 379 | */ |
| 380 | static void td1316_bw(u8 *buf, u32 freq, int bandwidth) |
| 381 | { |
| 382 | u8 band; |
| 383 | |
| 384 | /* determine band */ |
| 385 | if (freq < 161000000) |
| 386 | band = 1; |
| 387 | else if (freq < 444000000) |
| 388 | band = 2; |
| 389 | else |
| 390 | band = 4; |
| 391 | |
| 392 | buf[3] |= band; |
| 393 | |
| 394 | /* setup PLL filter */ |
| 395 | if (bandwidth == BANDWIDTH_8_MHZ) |
| 396 | buf[3] |= 1 << 3; |
| 397 | } |
| 398 | |
| 399 | struct dvb_pll_desc dvb_pll_philips_td1316 = { |
| 400 | .name = "Philips TD1316", |
| 401 | .min = 87000000, |
| 402 | .max = 895000000, |
| 403 | .setbw = td1316_bw, |
| 404 | .count = 9, |
| 405 | .entries = { |
| 406 | { 93834000, 36166000, 166666, 0xca, 0x60}, |
| 407 | { 123834000, 36166000, 166666, 0xca, 0xa0}, |
| 408 | { 163834000, 36166000, 166666, 0xca, 0xc0}, |
| 409 | { 253834000, 36166000, 166666, 0xca, 0x60}, |
| 410 | { 383834000, 36166000, 166666, 0xca, 0xa0}, |
| 411 | { 443834000, 36166000, 166666, 0xca, 0xc0}, |
| 412 | { 583834000, 36166000, 166666, 0xca, 0x60}, |
| 413 | { 793834000, 36166000, 166666, 0xca, 0xa0}, |
| 414 | { 858834000, 36166000, 166666, 0xca, 0xe0}, |
| 415 | }, |
| 416 | }; |
| 417 | EXPORT_SYMBOL(dvb_pll_philips_td1316); |
| 418 | |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 419 | /* FE6600 used on DViCO Hybrid */ |
Michael Krufky | 91ae329 | 2006-03-01 00:04:42 -0300 | [diff] [blame] | 420 | struct dvb_pll_desc dvb_pll_thomson_fe6600 = { |
| 421 | .name = "Thomson FE6600", |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 422 | .min = 44250000, |
| 423 | .max = 858000000, |
| 424 | .count = 4, |
| 425 | .entries = { |
| 426 | { 250000000, 36213333, 166667, 0xb4, 0x12 }, |
| 427 | { 455000000, 36213333, 166667, 0xfe, 0x11 }, |
| 428 | { 775500000, 36213333, 166667, 0xbc, 0x18 }, |
| 429 | { 999999999, 36213333, 166667, 0xf4, 0x18 }, |
| 430 | } |
| 431 | }; |
Michael Krufky | 91ae329 | 2006-03-01 00:04:42 -0300 | [diff] [blame] | 432 | EXPORT_SYMBOL(dvb_pll_thomson_fe6600); |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 433 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 434 | struct dvb_pll_priv { |
| 435 | /* i2c details */ |
| 436 | int pll_i2c_address; |
| 437 | struct i2c_adapter *i2c; |
| 438 | |
| 439 | /* the PLL descriptor */ |
| 440 | struct dvb_pll_desc *pll_desc; |
| 441 | |
| 442 | /* cached frequency/bandwidth */ |
| 443 | u32 frequency; |
| 444 | u32 bandwidth; |
| 445 | }; |
| 446 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | /* ----------------------------------------------------------- */ |
| 448 | /* code */ |
| 449 | |
| 450 | static int debug = 0; |
| 451 | module_param(debug, int, 0644); |
| 452 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 453 | |
| 454 | int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, |
| 455 | u32 freq, int bandwidth) |
| 456 | { |
| 457 | u32 div; |
| 458 | int i; |
| 459 | |
| 460 | if (freq != 0 && (freq < desc->min || freq > desc->max)) |
| 461 | return -EINVAL; |
| 462 | |
| 463 | for (i = 0; i < desc->count; i++) { |
| 464 | if (freq > desc->entries[i].limit) |
| 465 | continue; |
| 466 | break; |
| 467 | } |
| 468 | if (debug) |
| 469 | printk("pll: %s: freq=%d bw=%d | i=%d/%d\n", |
| 470 | desc->name, freq, bandwidth, i, desc->count); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 471 | if (i == desc->count) |
| 472 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | |
| 474 | div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize; |
| 475 | buf[0] = div >> 8; |
| 476 | buf[1] = div & 0xff; |
Michael Krufky | ab66b22 | 2006-01-23 17:11:11 -0200 | [diff] [blame] | 477 | buf[2] = desc->entries[i].config; |
| 478 | buf[3] = desc->entries[i].cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | |
| 480 | if (desc->setbw) |
Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 481 | desc->setbw(buf, freq, bandwidth); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | |
| 483 | if (debug) |
| 484 | printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", |
| 485 | desc->name, div, buf[0], buf[1], buf[2], buf[3]); |
| 486 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 487 | // calculate the frequency we set it to |
| 488 | return (div * desc->entries[i].stepsize) - desc->entries[i].offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | } |
| 490 | EXPORT_SYMBOL(dvb_pll_configure); |
| 491 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 492 | static int dvb_pll_release(struct dvb_frontend *fe) |
| 493 | { |
Michael Krufky | 2213918 | 2006-11-19 19:49:11 -0300 | [diff] [blame] | 494 | kfree(fe->tuner_priv); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 495 | fe->tuner_priv = NULL; |
| 496 | return 0; |
| 497 | } |
| 498 | |
| 499 | static int dvb_pll_sleep(struct dvb_frontend *fe) |
| 500 | { |
| 501 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 502 | u8 buf[4]; |
| 503 | struct i2c_msg msg = |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 504 | { .addr = priv->pll_i2c_address, .flags = 0, |
| 505 | .buf = buf, .len = sizeof(buf) }; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 506 | int i; |
| 507 | int result; |
| 508 | |
Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 509 | if (priv->i2c == NULL) |
| 510 | return -EINVAL; |
| 511 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 512 | for (i = 0; i < priv->pll_desc->count; i++) { |
| 513 | if (priv->pll_desc->entries[i].limit == 0) |
| 514 | break; |
| 515 | } |
| 516 | if (i == priv->pll_desc->count) |
| 517 | return 0; |
| 518 | |
| 519 | buf[0] = 0; |
| 520 | buf[1] = 0; |
| 521 | buf[2] = priv->pll_desc->entries[i].config; |
| 522 | buf[3] = priv->pll_desc->entries[i].cb; |
| 523 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 524 | if (fe->ops.i2c_gate_ctrl) |
| 525 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 526 | if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { |
| 527 | return result; |
| 528 | } |
| 529 | |
| 530 | return 0; |
| 531 | } |
| 532 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 533 | static int dvb_pll_set_params(struct dvb_frontend *fe, |
| 534 | struct dvb_frontend_parameters *params) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 535 | { |
| 536 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 537 | u8 buf[4]; |
| 538 | struct i2c_msg msg = |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 539 | { .addr = priv->pll_i2c_address, .flags = 0, |
| 540 | .buf = buf, .len = sizeof(buf) }; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 541 | int result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 542 | u32 bandwidth = 0, frequency = 0; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 543 | |
| 544 | if (priv->i2c == NULL) |
| 545 | return -EINVAL; |
| 546 | |
| 547 | // DVBT bandwidth only just now |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 548 | if (fe->ops.info.type == FE_OFDM) { |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 549 | bandwidth = params->u.ofdm.bandwidth; |
| 550 | } |
| 551 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 552 | if ((result = dvb_pll_configure(priv->pll_desc, buf, |
| 553 | params->frequency, bandwidth)) < 0) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 554 | return result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 555 | else |
| 556 | frequency = result; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 557 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 558 | if (fe->ops.i2c_gate_ctrl) |
| 559 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 560 | if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { |
| 561 | return result; |
| 562 | } |
| 563 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 564 | priv->frequency = frequency; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 565 | priv->bandwidth = bandwidth; |
| 566 | |
| 567 | return 0; |
| 568 | } |
| 569 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 570 | static int dvb_pll_calc_regs(struct dvb_frontend *fe, |
| 571 | struct dvb_frontend_parameters *params, |
| 572 | u8 *buf, int buf_len) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 573 | { |
| 574 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 575 | int result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 576 | u32 bandwidth = 0, frequency = 0; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 577 | |
| 578 | if (buf_len < 5) |
| 579 | return -EINVAL; |
| 580 | |
| 581 | // DVBT bandwidth only just now |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 582 | if (fe->ops.info.type == FE_OFDM) { |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 583 | bandwidth = params->u.ofdm.bandwidth; |
| 584 | } |
| 585 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 586 | if ((result = dvb_pll_configure(priv->pll_desc, buf+1, |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 587 | params->frequency, bandwidth)) < 0) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 588 | return result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 589 | else |
| 590 | frequency = result; |
| 591 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 592 | buf[0] = priv->pll_i2c_address; |
| 593 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 594 | priv->frequency = frequency; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 595 | priv->bandwidth = bandwidth; |
| 596 | |
| 597 | return 5; |
| 598 | } |
| 599 | |
| 600 | static int dvb_pll_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
| 601 | { |
| 602 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 603 | *frequency = priv->frequency; |
| 604 | return 0; |
| 605 | } |
| 606 | |
| 607 | static int dvb_pll_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) |
| 608 | { |
| 609 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 610 | *bandwidth = priv->bandwidth; |
| 611 | return 0; |
| 612 | } |
| 613 | |
Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame^] | 614 | static int dvb_pll_init(struct dvb_frontend *fe) |
| 615 | { |
| 616 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 617 | |
| 618 | if (priv->i2c == NULL) |
| 619 | return -EINVAL; |
| 620 | |
| 621 | if (priv->pll_desc->initdata) { |
| 622 | struct i2c_msg msg = { .flags = 0, |
| 623 | .addr = priv->pll_i2c_address, |
| 624 | .buf = priv->pll_desc->initdata + 1, |
| 625 | .len = priv->pll_desc->initdata[0] }; |
| 626 | |
| 627 | int result; |
| 628 | if (fe->ops.i2c_gate_ctrl) |
| 629 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 630 | if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { |
| 631 | return result; |
| 632 | } |
| 633 | return 0; |
| 634 | } |
| 635 | /* Shouldn't be called when initdata is NULL, maybe BUG()? */ |
| 636 | return -EINVAL; |
| 637 | } |
| 638 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 639 | static struct dvb_tuner_ops dvb_pll_tuner_ops = { |
| 640 | .release = dvb_pll_release, |
| 641 | .sleep = dvb_pll_sleep, |
| 642 | .set_params = dvb_pll_set_params, |
Andrew de Quincey | bd4956b | 2006-04-18 21:38:49 -0300 | [diff] [blame] | 643 | .calc_regs = dvb_pll_calc_regs, |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 644 | .get_frequency = dvb_pll_get_frequency, |
| 645 | .get_bandwidth = dvb_pll_get_bandwidth, |
| 646 | }; |
| 647 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 648 | struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, |
| 649 | struct i2c_adapter *i2c, |
| 650 | struct dvb_pll_desc *desc) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 651 | { |
Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 652 | u8 b1 [] = { 0 }; |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 653 | struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, |
| 654 | .buf = b1, .len = 1 }; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 655 | struct dvb_pll_priv *priv = NULL; |
Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 656 | int ret; |
| 657 | |
Andrew de Quincey | 55c05b6 | 2006-07-16 19:41:41 -0300 | [diff] [blame] | 658 | if (i2c != NULL) { |
| 659 | if (fe->ops.i2c_gate_ctrl) |
| 660 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 661 | |
Andrew de Quincey | 95faba2 | 2006-07-18 16:37:13 -0300 | [diff] [blame] | 662 | ret = i2c_transfer (i2c, &msg, 1); |
| 663 | if (ret != 1) |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 664 | return NULL; |
Andrew de Quincey | 55c05b6 | 2006-07-16 19:41:41 -0300 | [diff] [blame] | 665 | if (fe->ops.i2c_gate_ctrl) |
| 666 | fe->ops.i2c_gate_ctrl(fe, 0); |
| 667 | } |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 668 | |
| 669 | priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL); |
| 670 | if (priv == NULL) |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 671 | return NULL; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 672 | |
| 673 | priv->pll_i2c_address = pll_addr; |
| 674 | priv->i2c = i2c; |
| 675 | priv->pll_desc = desc; |
| 676 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 677 | memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops, |
| 678 | sizeof(struct dvb_tuner_ops)); |
| 679 | |
Trent Piepho | 982dd1b | 2007-04-27 12:31:27 -0300 | [diff] [blame] | 680 | strncpy(fe->ops.tuner_ops.info.name, desc->name, |
| 681 | sizeof(fe->ops.tuner_ops.info.name)); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 682 | fe->ops.tuner_ops.info.frequency_min = desc->min; |
| 683 | fe->ops.tuner_ops.info.frequency_min = desc->max; |
Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame^] | 684 | if (desc->initdata) |
| 685 | fe->ops.tuner_ops.init = dvb_pll_init; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 686 | |
| 687 | fe->tuner_priv = priv; |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 688 | return fe; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 689 | } |
| 690 | EXPORT_SYMBOL(dvb_pll_attach); |
| 691 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | MODULE_DESCRIPTION("dvb pll library"); |
| 693 | MODULE_AUTHOR("Gerd Knorr"); |
| 694 | MODULE_LICENSE("GPL"); |