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