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