Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1 | /* |
Michael Krufky | 6ca04de | 2007-11-23 16:52:15 -0300 | [diff] [blame] | 2 | tda18271-fe.c - driver for the Philips / NXP TDA18271 silicon tuner |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 3 | |
Michael Krufky | 59067f7 | 2008-01-02 01:58:26 -0300 | [diff] [blame] | 4 | Copyright (C) 2007, 2008 Michael Krufky <mkrufky@linuxtv.org> |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 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 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 21 | #include <linux/delay.h> |
| 22 | #include <linux/videodev2.h> |
Michael Krufky | 6ca04de | 2007-11-23 16:52:15 -0300 | [diff] [blame] | 23 | #include "tda18271-priv.h" |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 24 | |
Michael Krufky | b5f3e1e | 2007-12-02 16:36:05 -0300 | [diff] [blame] | 25 | int tda18271_debug; |
Michael Krufky | 54465b0 | 2007-11-23 18:14:53 -0300 | [diff] [blame] | 26 | module_param_named(debug, tda18271_debug, int, 0644); |
Michael Krufky | 0e1fab9 | 2008-01-03 01:40:47 -0300 | [diff] [blame] | 27 | MODULE_PARM_DESC(debug, "set debug level " |
Michael Krufky | cf04d29 | 2008-01-09 00:34:30 -0300 | [diff] [blame] | 28 | "(info=1, map=2, reg=4, adv=8, cal=16 (or-able))"); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 29 | |
Michael Krufky | bc835d8 | 2008-01-14 11:10:54 -0300 | [diff] [blame] | 30 | static int tda18271_cal_on_startup; |
Michael Krufky | 0f96251 | 2008-01-13 22:01:07 -0300 | [diff] [blame] | 31 | module_param_named(cal, tda18271_cal_on_startup, int, 0644); |
| 32 | MODULE_PARM_DESC(cal, "perform RF tracking filter calibration on startup"); |
| 33 | |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 34 | static DEFINE_MUTEX(tda18271_list_mutex); |
Michael Krufky | f9e315a | 2008-04-22 14:41:54 -0300 | [diff] [blame] | 35 | static LIST_HEAD(hybrid_tuner_instance_list); |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 36 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 37 | /*---------------------------------------------------------------------*/ |
| 38 | |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 39 | static int tda18271_channel_configuration(struct dvb_frontend *fe, |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 40 | struct tda18271_std_map_item *map, |
| 41 | u32 freq, u32 bw) |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 42 | { |
| 43 | struct tda18271_priv *priv = fe->tuner_priv; |
| 44 | unsigned char *regs = priv->tda18271_regs; |
| 45 | u32 N; |
| 46 | |
| 47 | /* update TV broadcast parameters */ |
| 48 | |
| 49 | /* set standard */ |
| 50 | regs[R_EP3] &= ~0x1f; /* clear std bits */ |
Michael Krufky | 7f7203d | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 51 | regs[R_EP3] |= (map->agc_mode << 3) | map->std; |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 52 | |
| 53 | /* set cal mode to normal */ |
| 54 | regs[R_EP4] &= ~0x03; |
| 55 | |
| 56 | /* update IF output level & IF notch frequency */ |
| 57 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ |
Michael Krufky | 14c74b2 | 2008-04-22 14:46:21 -0300 | [diff] [blame] | 58 | regs[R_EP4] |= (map->if_lvl << 2); |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 59 | |
| 60 | switch (priv->mode) { |
| 61 | case TDA18271_ANALOG: |
| 62 | regs[R_MPD] &= ~0x80; /* IF notch = 0 */ |
| 63 | break; |
| 64 | case TDA18271_DIGITAL: |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 65 | regs[R_MPD] |= 0x80; /* IF notch = 1 */ |
| 66 | break; |
| 67 | } |
Michael Krufky | c353f42 | 2008-01-08 10:38:10 -0300 | [diff] [blame] | 68 | |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 69 | /* update FM_RFn */ |
| 70 | regs[R_EP4] &= ~0x80; |
| 71 | regs[R_EP4] |= map->fm_rfn << 7; |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 72 | |
Michael Krufky | c0dc0c1 | 2008-04-22 14:46:22 -0300 | [diff] [blame] | 73 | /* update rf top / if top */ |
| 74 | regs[R_EB22] = 0x00; |
| 75 | regs[R_EB22] |= map->rfagc_top; |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 76 | tda18271_write_regs(fe, R_EB22, 1); |
| 77 | |
| 78 | /* --------------------------------------------------------------- */ |
| 79 | |
| 80 | /* disable Power Level Indicator */ |
| 81 | regs[R_EP1] |= 0x40; |
| 82 | |
| 83 | /* frequency dependent parameters */ |
| 84 | |
| 85 | tda18271_calc_ir_measure(fe, &freq); |
| 86 | |
| 87 | tda18271_calc_bp_filter(fe, &freq); |
| 88 | |
| 89 | tda18271_calc_rf_band(fe, &freq); |
| 90 | |
| 91 | tda18271_calc_gain_taper(fe, &freq); |
| 92 | |
| 93 | /* --------------------------------------------------------------- */ |
| 94 | |
| 95 | /* dual tuner and agc1 extra configuration */ |
| 96 | |
| 97 | /* main vco when Master, cal vco when slave */ |
| 98 | regs[R_EB1] |= 0x04; /* FIXME: assumes master */ |
| 99 | |
| 100 | /* agc1 always active */ |
| 101 | regs[R_EB1] &= ~0x02; |
| 102 | |
| 103 | /* agc1 has priority on agc2 */ |
| 104 | regs[R_EB1] &= ~0x01; |
| 105 | |
| 106 | tda18271_write_regs(fe, R_EB1, 1); |
| 107 | |
| 108 | /* --------------------------------------------------------------- */ |
| 109 | |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 110 | N = map->if_freq * 1000 + freq; |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 111 | |
| 112 | /* FIXME: assumes master */ |
| 113 | tda18271_calc_main_pll(fe, N); |
| 114 | tda18271_write_regs(fe, R_MPD, 4); |
| 115 | |
| 116 | tda18271_write_regs(fe, R_TM, 7); |
| 117 | |
| 118 | /* main pll charge pump source */ |
| 119 | regs[R_EB4] |= 0x20; |
| 120 | tda18271_write_regs(fe, R_EB4, 1); |
| 121 | |
| 122 | msleep(1); |
| 123 | |
| 124 | /* normal operation for the main pll */ |
| 125 | regs[R_EB4] &= ~0x20; |
| 126 | tda18271_write_regs(fe, R_EB4, 1); |
| 127 | |
| 128 | msleep(5); |
| 129 | |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | static int tda18271_read_thermometer(struct dvb_frontend *fe) |
| 134 | { |
| 135 | struct tda18271_priv *priv = fe->tuner_priv; |
| 136 | unsigned char *regs = priv->tda18271_regs; |
| 137 | int tm; |
| 138 | |
| 139 | /* switch thermometer on */ |
| 140 | regs[R_TM] |= 0x10; |
| 141 | tda18271_write_regs(fe, R_TM, 1); |
| 142 | |
| 143 | /* read thermometer info */ |
| 144 | tda18271_read_regs(fe); |
| 145 | |
| 146 | if ((((regs[R_TM] & 0x0f) == 0x00) && ((regs[R_TM] & 0x20) == 0x20)) || |
| 147 | (((regs[R_TM] & 0x0f) == 0x08) && ((regs[R_TM] & 0x20) == 0x00))) { |
| 148 | |
| 149 | if ((regs[R_TM] & 0x20) == 0x20) |
| 150 | regs[R_TM] &= ~0x20; |
| 151 | else |
| 152 | regs[R_TM] |= 0x20; |
| 153 | |
| 154 | tda18271_write_regs(fe, R_TM, 1); |
| 155 | |
| 156 | msleep(10); /* temperature sensing */ |
| 157 | |
| 158 | /* read thermometer info */ |
| 159 | tda18271_read_regs(fe); |
| 160 | } |
| 161 | |
| 162 | tm = tda18271_lookup_thermometer(fe); |
| 163 | |
| 164 | /* switch thermometer off */ |
| 165 | regs[R_TM] &= ~0x10; |
| 166 | tda18271_write_regs(fe, R_TM, 1); |
| 167 | |
| 168 | /* set CAL mode to normal */ |
| 169 | regs[R_EP4] &= ~0x03; |
| 170 | tda18271_write_regs(fe, R_EP4, 1); |
| 171 | |
| 172 | return tm; |
| 173 | } |
| 174 | |
Michael Krufky | 12afe37 | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 175 | /* ------------------------------------------------------------------ */ |
| 176 | |
Michael Krufky | d1c5342 | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 177 | static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, |
| 178 | u32 freq) |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 179 | { |
| 180 | struct tda18271_priv *priv = fe->tuner_priv; |
| 181 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; |
| 182 | unsigned char *regs = priv->tda18271_regs; |
| 183 | int tm_current, rfcal_comp, approx, i; |
| 184 | u8 dc_over_dt, rf_tab; |
| 185 | |
| 186 | /* power up */ |
Michael Krufky | 518d873 | 2008-01-13 17:01:01 -0300 | [diff] [blame] | 187 | tda18271_set_standby_mode(fe, 0, 0, 0); |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 188 | |
| 189 | /* read die current temperature */ |
| 190 | tm_current = tda18271_read_thermometer(fe); |
| 191 | |
| 192 | /* frequency dependent parameters */ |
| 193 | |
| 194 | tda18271_calc_rf_cal(fe, &freq); |
| 195 | rf_tab = regs[R_EB14]; |
| 196 | |
| 197 | i = tda18271_lookup_rf_band(fe, &freq, NULL); |
| 198 | if (i < 0) |
| 199 | return -EINVAL; |
| 200 | |
| 201 | if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { |
| 202 | approx = map[i].rf_a1 * |
| 203 | (freq / 1000 - map[i].rf1) + map[i].rf_b1 + rf_tab; |
| 204 | } else { |
| 205 | approx = map[i].rf_a2 * |
| 206 | (freq / 1000 - map[i].rf2) + map[i].rf_b2 + rf_tab; |
| 207 | } |
| 208 | |
| 209 | if (approx < 0) |
| 210 | approx = 0; |
| 211 | if (approx > 255) |
| 212 | approx = 255; |
| 213 | |
| 214 | tda18271_lookup_map(fe, RF_CAL_DC_OVER_DT, &freq, &dc_over_dt); |
| 215 | |
| 216 | /* calculate temperature compensation */ |
Michael Krufky | 09f83c4 | 2008-01-05 20:00:09 -0300 | [diff] [blame] | 217 | rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal); |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 218 | |
| 219 | regs[R_EB14] = approx + rfcal_comp; |
| 220 | tda18271_write_regs(fe, R_EB14, 1); |
| 221 | |
| 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | static int tda18271_por(struct dvb_frontend *fe) |
| 226 | { |
| 227 | struct tda18271_priv *priv = fe->tuner_priv; |
| 228 | unsigned char *regs = priv->tda18271_regs; |
| 229 | |
| 230 | /* power up detector 1 */ |
| 231 | regs[R_EB12] &= ~0x20; |
| 232 | tda18271_write_regs(fe, R_EB12, 1); |
| 233 | |
| 234 | regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ |
| 235 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ |
| 236 | tda18271_write_regs(fe, R_EB18, 1); |
| 237 | |
| 238 | regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ |
| 239 | |
| 240 | /* POR mode */ |
Michael Krufky | 518d873 | 2008-01-13 17:01:01 -0300 | [diff] [blame] | 241 | tda18271_set_standby_mode(fe, 1, 0, 0); |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 242 | |
| 243 | /* disable 1.5 MHz low pass filter */ |
| 244 | regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ |
| 245 | regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ |
| 246 | tda18271_write_regs(fe, R_EB21, 3); |
| 247 | |
| 248 | return 0; |
| 249 | } |
| 250 | |
| 251 | static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) |
| 252 | { |
| 253 | struct tda18271_priv *priv = fe->tuner_priv; |
| 254 | unsigned char *regs = priv->tda18271_regs; |
| 255 | u32 N; |
| 256 | |
| 257 | /* set CAL mode to normal */ |
| 258 | regs[R_EP4] &= ~0x03; |
| 259 | tda18271_write_regs(fe, R_EP4, 1); |
| 260 | |
| 261 | /* switch off agc1 */ |
| 262 | regs[R_EP3] |= 0x40; /* sm_lt = 1 */ |
| 263 | |
| 264 | regs[R_EB18] |= 0x03; /* set agc1_gain to 15 dB */ |
| 265 | tda18271_write_regs(fe, R_EB18, 1); |
| 266 | |
| 267 | /* frequency dependent parameters */ |
| 268 | |
| 269 | tda18271_calc_bp_filter(fe, &freq); |
| 270 | tda18271_calc_gain_taper(fe, &freq); |
| 271 | tda18271_calc_rf_band(fe, &freq); |
| 272 | tda18271_calc_km(fe, &freq); |
| 273 | |
| 274 | tda18271_write_regs(fe, R_EP1, 3); |
| 275 | tda18271_write_regs(fe, R_EB13, 1); |
| 276 | |
| 277 | /* main pll charge pump source */ |
| 278 | regs[R_EB4] |= 0x20; |
| 279 | tda18271_write_regs(fe, R_EB4, 1); |
| 280 | |
| 281 | /* cal pll charge pump source */ |
| 282 | regs[R_EB7] |= 0x20; |
| 283 | tda18271_write_regs(fe, R_EB7, 1); |
| 284 | |
| 285 | /* force dcdc converter to 0 V */ |
| 286 | regs[R_EB14] = 0x00; |
| 287 | tda18271_write_regs(fe, R_EB14, 1); |
| 288 | |
| 289 | /* disable plls lock */ |
| 290 | regs[R_EB20] &= ~0x20; |
| 291 | tda18271_write_regs(fe, R_EB20, 1); |
| 292 | |
| 293 | /* set CAL mode to RF tracking filter calibration */ |
| 294 | regs[R_EP4] |= 0x03; |
| 295 | tda18271_write_regs(fe, R_EP4, 2); |
| 296 | |
| 297 | /* --------------------------------------------------------------- */ |
| 298 | |
| 299 | /* set the internal calibration signal */ |
| 300 | N = freq; |
| 301 | |
Michael Krufky | ae07d04 | 2008-04-22 14:46:21 -0300 | [diff] [blame] | 302 | tda18271_calc_cal_pll(fe, N); |
| 303 | tda18271_write_regs(fe, R_CPD, 4); |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 304 | |
| 305 | /* downconvert internal calibration */ |
| 306 | N += 1000000; |
| 307 | |
| 308 | tda18271_calc_main_pll(fe, N); |
| 309 | tda18271_write_regs(fe, R_MPD, 4); |
| 310 | |
| 311 | msleep(5); |
| 312 | |
| 313 | tda18271_write_regs(fe, R_EP2, 1); |
| 314 | tda18271_write_regs(fe, R_EP1, 1); |
| 315 | tda18271_write_regs(fe, R_EP2, 1); |
| 316 | tda18271_write_regs(fe, R_EP1, 1); |
| 317 | |
| 318 | /* --------------------------------------------------------------- */ |
| 319 | |
| 320 | /* normal operation for the main pll */ |
| 321 | regs[R_EB4] &= ~0x20; |
| 322 | tda18271_write_regs(fe, R_EB4, 1); |
| 323 | |
| 324 | /* normal operation for the cal pll */ |
| 325 | regs[R_EB7] &= ~0x20; |
| 326 | tda18271_write_regs(fe, R_EB7, 1); |
| 327 | |
Michael Krufky | ae07d04 | 2008-04-22 14:46:21 -0300 | [diff] [blame] | 328 | msleep(10); /* plls locking */ |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 329 | |
| 330 | /* launch the rf tracking filters calibration */ |
| 331 | regs[R_EB20] |= 0x20; |
| 332 | tda18271_write_regs(fe, R_EB20, 1); |
| 333 | |
| 334 | msleep(60); /* calibration */ |
| 335 | |
| 336 | /* --------------------------------------------------------------- */ |
| 337 | |
| 338 | /* set CAL mode to normal */ |
| 339 | regs[R_EP4] &= ~0x03; |
| 340 | |
| 341 | /* switch on agc1 */ |
| 342 | regs[R_EP3] &= ~0x40; /* sm_lt = 0 */ |
| 343 | |
| 344 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ |
| 345 | tda18271_write_regs(fe, R_EB18, 1); |
| 346 | |
| 347 | tda18271_write_regs(fe, R_EP3, 2); |
| 348 | |
| 349 | /* synchronization */ |
| 350 | tda18271_write_regs(fe, R_EP1, 1); |
| 351 | |
| 352 | /* get calibration result */ |
| 353 | tda18271_read_extended(fe); |
| 354 | |
| 355 | return regs[R_EB14]; |
| 356 | } |
| 357 | |
| 358 | static int tda18271_powerscan(struct dvb_frontend *fe, |
| 359 | u32 *freq_in, u32 *freq_out) |
| 360 | { |
| 361 | struct tda18271_priv *priv = fe->tuner_priv; |
| 362 | unsigned char *regs = priv->tda18271_regs; |
| 363 | int sgn, bcal, count, wait; |
| 364 | u8 cid_target; |
| 365 | u16 count_limit; |
| 366 | u32 freq; |
| 367 | |
| 368 | freq = *freq_in; |
| 369 | |
| 370 | tda18271_calc_rf_band(fe, &freq); |
| 371 | tda18271_calc_rf_cal(fe, &freq); |
| 372 | tda18271_calc_gain_taper(fe, &freq); |
| 373 | tda18271_lookup_cid_target(fe, &freq, &cid_target, &count_limit); |
| 374 | |
| 375 | tda18271_write_regs(fe, R_EP2, 1); |
| 376 | tda18271_write_regs(fe, R_EB14, 1); |
| 377 | |
| 378 | /* downconvert frequency */ |
| 379 | freq += 1000000; |
| 380 | |
| 381 | tda18271_calc_main_pll(fe, freq); |
| 382 | tda18271_write_regs(fe, R_MPD, 4); |
| 383 | |
| 384 | msleep(5); /* pll locking */ |
| 385 | |
| 386 | /* detection mode */ |
| 387 | regs[R_EP4] &= ~0x03; |
| 388 | regs[R_EP4] |= 0x01; |
| 389 | tda18271_write_regs(fe, R_EP4, 1); |
| 390 | |
| 391 | /* launch power detection measurement */ |
| 392 | tda18271_write_regs(fe, R_EP2, 1); |
| 393 | |
| 394 | /* read power detection info, stored in EB10 */ |
| 395 | tda18271_read_extended(fe); |
| 396 | |
| 397 | /* algorithm initialization */ |
| 398 | sgn = 1; |
| 399 | *freq_out = *freq_in; |
| 400 | bcal = 0; |
| 401 | count = 0; |
| 402 | wait = false; |
| 403 | |
| 404 | while ((regs[R_EB10] & 0x3f) < cid_target) { |
| 405 | /* downconvert updated freq to 1 MHz */ |
| 406 | freq = *freq_in + (sgn * count) + 1000000; |
| 407 | |
| 408 | tda18271_calc_main_pll(fe, freq); |
| 409 | tda18271_write_regs(fe, R_MPD, 4); |
| 410 | |
| 411 | if (wait) { |
| 412 | msleep(5); /* pll locking */ |
| 413 | wait = false; |
| 414 | } else |
| 415 | udelay(100); /* pll locking */ |
| 416 | |
| 417 | /* launch power detection measurement */ |
| 418 | tda18271_write_regs(fe, R_EP2, 1); |
| 419 | |
| 420 | /* read power detection info, stored in EB10 */ |
| 421 | tda18271_read_extended(fe); |
| 422 | |
| 423 | count += 200; |
| 424 | |
Michael Krufky | e7809a0 | 2008-04-22 14:46:22 -0300 | [diff] [blame^] | 425 | if (count <= count_limit) |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 426 | continue; |
| 427 | |
| 428 | if (sgn <= 0) |
| 429 | break; |
| 430 | |
| 431 | sgn = -1 * sgn; |
| 432 | count = 200; |
| 433 | wait = true; |
| 434 | } |
| 435 | |
| 436 | if ((regs[R_EB10] & 0x3f) >= cid_target) { |
| 437 | bcal = 1; |
| 438 | *freq_out = freq - 1000000; |
| 439 | } else |
| 440 | bcal = 0; |
| 441 | |
Michael Krufky | cf04d29 | 2008-01-09 00:34:30 -0300 | [diff] [blame] | 442 | tda_cal("bcal = %d, freq_in = %d, freq_out = %d (freq = %d)\n", |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 443 | bcal, *freq_in, *freq_out, freq); |
| 444 | |
| 445 | return bcal; |
| 446 | } |
| 447 | |
| 448 | static int tda18271_powerscan_init(struct dvb_frontend *fe) |
| 449 | { |
| 450 | struct tda18271_priv *priv = fe->tuner_priv; |
| 451 | unsigned char *regs = priv->tda18271_regs; |
| 452 | |
| 453 | /* set standard to digital */ |
| 454 | regs[R_EP3] &= ~0x1f; /* clear std bits */ |
| 455 | regs[R_EP3] |= 0x12; |
| 456 | |
| 457 | /* set cal mode to normal */ |
| 458 | regs[R_EP4] &= ~0x03; |
| 459 | |
| 460 | /* update IF output level & IF notch frequency */ |
| 461 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ |
| 462 | |
| 463 | tda18271_write_regs(fe, R_EP3, 2); |
| 464 | |
| 465 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ |
| 466 | tda18271_write_regs(fe, R_EB18, 1); |
| 467 | |
| 468 | regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ |
| 469 | |
| 470 | /* 1.5 MHz low pass filter */ |
| 471 | regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */ |
| 472 | regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */ |
| 473 | |
| 474 | tda18271_write_regs(fe, R_EB21, 3); |
| 475 | |
| 476 | return 0; |
| 477 | } |
| 478 | |
| 479 | static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) |
| 480 | { |
| 481 | struct tda18271_priv *priv = fe->tuner_priv; |
| 482 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; |
| 483 | unsigned char *regs = priv->tda18271_regs; |
| 484 | int bcal, rf, i; |
| 485 | #define RF1 0 |
| 486 | #define RF2 1 |
| 487 | #define RF3 2 |
| 488 | u32 rf_default[3]; |
| 489 | u32 rf_freq[3]; |
| 490 | u8 prog_cal[3]; |
| 491 | u8 prog_tab[3]; |
| 492 | |
| 493 | i = tda18271_lookup_rf_band(fe, &freq, NULL); |
| 494 | |
| 495 | if (i < 0) |
| 496 | return i; |
| 497 | |
| 498 | rf_default[RF1] = 1000 * map[i].rf1_def; |
| 499 | rf_default[RF2] = 1000 * map[i].rf2_def; |
| 500 | rf_default[RF3] = 1000 * map[i].rf3_def; |
| 501 | |
| 502 | for (rf = RF1; rf <= RF3; rf++) { |
| 503 | if (0 == rf_default[rf]) |
| 504 | return 0; |
Michael Krufky | cf04d29 | 2008-01-09 00:34:30 -0300 | [diff] [blame] | 505 | tda_cal("freq = %d, rf = %d\n", freq, rf); |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 506 | |
| 507 | /* look for optimized calibration frequency */ |
| 508 | bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); |
| 509 | |
| 510 | tda18271_calc_rf_cal(fe, &rf_freq[rf]); |
| 511 | prog_tab[rf] = regs[R_EB14]; |
| 512 | |
| 513 | if (1 == bcal) |
| 514 | prog_cal[rf] = tda18271_calibrate_rf(fe, rf_freq[rf]); |
| 515 | else |
| 516 | prog_cal[rf] = prog_tab[rf]; |
| 517 | |
| 518 | switch (rf) { |
| 519 | case RF1: |
| 520 | map[i].rf_a1 = 0; |
| 521 | map[i].rf_b1 = prog_cal[RF1] - prog_tab[RF1]; |
| 522 | map[i].rf1 = rf_freq[RF1] / 1000; |
| 523 | break; |
| 524 | case RF2: |
| 525 | map[i].rf_a1 = (prog_cal[RF2] - prog_tab[RF2] - |
| 526 | prog_cal[RF1] + prog_tab[RF1]) / |
| 527 | ((rf_freq[RF2] - rf_freq[RF1]) / 1000); |
| 528 | map[i].rf2 = rf_freq[RF2] / 1000; |
| 529 | break; |
| 530 | case RF3: |
| 531 | map[i].rf_a2 = (prog_cal[RF3] - prog_tab[RF3] - |
| 532 | prog_cal[RF2] + prog_tab[RF2]) / |
| 533 | ((rf_freq[RF3] - rf_freq[RF2]) / 1000); |
| 534 | map[i].rf_b2 = prog_cal[RF2] - prog_tab[RF2]; |
| 535 | map[i].rf3 = rf_freq[RF3] / 1000; |
| 536 | break; |
| 537 | default: |
| 538 | BUG(); |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | return 0; |
| 543 | } |
| 544 | |
Michael Krufky | 09f83c4 | 2008-01-05 20:00:09 -0300 | [diff] [blame] | 545 | static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe) |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 546 | { |
| 547 | struct tda18271_priv *priv = fe->tuner_priv; |
| 548 | unsigned int i; |
| 549 | |
| 550 | tda_info("tda18271: performing RF tracking filter calibration\n"); |
| 551 | |
| 552 | /* wait for die temperature stabilization */ |
| 553 | msleep(200); |
| 554 | |
| 555 | tda18271_powerscan_init(fe); |
| 556 | |
| 557 | /* rf band calibration */ |
| 558 | for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) |
| 559 | tda18271_rf_tracking_filters_init(fe, 1000 * |
| 560 | priv->rf_cal_state[i].rfmax); |
| 561 | |
Michael Krufky | 09f83c4 | 2008-01-05 20:00:09 -0300 | [diff] [blame] | 562 | priv->tm_rfcal = tda18271_read_thermometer(fe); |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 563 | |
| 564 | return 0; |
| 565 | } |
| 566 | |
| 567 | /* ------------------------------------------------------------------ */ |
| 568 | |
Michael Krufky | 12afe37 | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 569 | static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 570 | { |
| 571 | struct tda18271_priv *priv = fe->tuner_priv; |
Michael Krufky | 839c6c9 | 2008-01-13 18:29:44 -0300 | [diff] [blame] | 572 | unsigned char *regs = priv->tda18271_regs; |
| 573 | |
| 574 | /* test RF_CAL_OK to see if we need init */ |
| 575 | if ((regs[R_EP1] & 0x10) == 0) |
| 576 | priv->cal_initialized = false; |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 577 | |
| 578 | if (priv->cal_initialized) |
| 579 | return 0; |
| 580 | |
Michael Krufky | 09f83c4 | 2008-01-05 20:00:09 -0300 | [diff] [blame] | 581 | tda18271_calc_rf_filter_curve(fe); |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 582 | |
| 583 | tda18271_por(fe); |
| 584 | |
Michael Krufky | 6bfa665 | 2008-01-07 00:51:48 -0300 | [diff] [blame] | 585 | tda_info("tda18271: RF tracking filter calibration complete\n"); |
| 586 | |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 587 | priv->cal_initialized = true; |
| 588 | |
| 589 | return 0; |
| 590 | } |
| 591 | |
Michael Krufky | 4d2d42b | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 592 | static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, |
| 593 | u32 freq, u32 bw) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 594 | { |
| 595 | struct tda18271_priv *priv = fe->tuner_priv; |
| 596 | unsigned char *regs = priv->tda18271_regs; |
Michael Krufky | fe0bf6d | 2007-12-24 05:05:05 -0300 | [diff] [blame] | 597 | u32 N = 0; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 598 | |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 599 | /* calculate bp filter */ |
Michael Krufky | b92bf0f | 2007-12-25 18:54:22 -0300 | [diff] [blame] | 600 | tda18271_calc_bp_filter(fe, &freq); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 601 | tda18271_write_regs(fe, R_EP1, 1); |
| 602 | |
| 603 | regs[R_EB4] &= 0x07; |
| 604 | regs[R_EB4] |= 0x60; |
| 605 | tda18271_write_regs(fe, R_EB4, 1); |
| 606 | |
| 607 | regs[R_EB7] = 0x60; |
| 608 | tda18271_write_regs(fe, R_EB7, 1); |
| 609 | |
| 610 | regs[R_EB14] = 0x00; |
| 611 | tda18271_write_regs(fe, R_EB14, 1); |
| 612 | |
| 613 | regs[R_EB20] = 0xcc; |
| 614 | tda18271_write_regs(fe, R_EB20, 1); |
| 615 | |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 616 | /* set cal mode to RF tracking filter calibration */ |
Michael Krufky | 26501a7 | 2007-12-21 14:28:46 -0300 | [diff] [blame] | 617 | regs[R_EP4] |= 0x03; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 618 | |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 619 | /* calculate cal pll */ |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 620 | |
| 621 | switch (priv->mode) { |
| 622 | case TDA18271_ANALOG: |
| 623 | N = freq - 1250000; |
| 624 | break; |
| 625 | case TDA18271_DIGITAL: |
| 626 | N = freq + bw / 2; |
| 627 | break; |
| 628 | } |
| 629 | |
Michael Krufky | fe0bf6d | 2007-12-24 05:05:05 -0300 | [diff] [blame] | 630 | tda18271_calc_cal_pll(fe, N); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 631 | |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 632 | /* calculate main pll */ |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 633 | |
| 634 | switch (priv->mode) { |
| 635 | case TDA18271_ANALOG: |
| 636 | N = freq - 250000; |
| 637 | break; |
| 638 | case TDA18271_DIGITAL: |
| 639 | N = freq + bw / 2 + 1000000; |
| 640 | break; |
| 641 | } |
| 642 | |
Michael Krufky | fe0bf6d | 2007-12-24 05:05:05 -0300 | [diff] [blame] | 643 | tda18271_calc_main_pll(fe, N); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 644 | |
| 645 | tda18271_write_regs(fe, R_EP3, 11); |
| 646 | msleep(5); /* RF tracking filter calibration initialization */ |
| 647 | |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 648 | /* search for K,M,CO for RF calibration */ |
Michael Krufky | b92bf0f | 2007-12-25 18:54:22 -0300 | [diff] [blame] | 649 | tda18271_calc_km(fe, &freq); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 650 | tda18271_write_regs(fe, R_EB13, 1); |
| 651 | |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 652 | /* search for rf band */ |
Michael Krufky | b92bf0f | 2007-12-25 18:54:22 -0300 | [diff] [blame] | 653 | tda18271_calc_rf_band(fe, &freq); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 654 | |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 655 | /* search for gain taper */ |
Michael Krufky | b92bf0f | 2007-12-25 18:54:22 -0300 | [diff] [blame] | 656 | tda18271_calc_gain_taper(fe, &freq); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 657 | |
| 658 | tda18271_write_regs(fe, R_EP2, 1); |
| 659 | tda18271_write_regs(fe, R_EP1, 1); |
| 660 | tda18271_write_regs(fe, R_EP2, 1); |
| 661 | tda18271_write_regs(fe, R_EP1, 1); |
| 662 | |
| 663 | regs[R_EB4] &= 0x07; |
| 664 | regs[R_EB4] |= 0x40; |
| 665 | tda18271_write_regs(fe, R_EB4, 1); |
| 666 | |
| 667 | regs[R_EB7] = 0x40; |
| 668 | tda18271_write_regs(fe, R_EB7, 1); |
Michael Krufky | 4d2d42b | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 669 | msleep(10); /* pll locking */ |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 670 | |
| 671 | regs[R_EB20] = 0xec; |
| 672 | tda18271_write_regs(fe, R_EB20, 1); |
| 673 | msleep(60); /* RF tracking filter calibration completion */ |
| 674 | |
| 675 | regs[R_EP4] &= ~0x03; /* set cal mode to normal */ |
| 676 | tda18271_write_regs(fe, R_EP4, 1); |
| 677 | |
| 678 | tda18271_write_regs(fe, R_EP1, 1); |
| 679 | |
Michael Krufky | b92bf0f | 2007-12-25 18:54:22 -0300 | [diff] [blame] | 680 | /* RF tracking filter correction for VHF_Low band */ |
| 681 | if (0 == tda18271_calc_rf_cal(fe, &freq)) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 682 | tda18271_write_regs(fe, R_EB14, 1); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 683 | |
Michael Krufky | 4d2d42b | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 684 | return 0; |
| 685 | } |
| 686 | |
Michael Krufky | d1c5342 | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 687 | /* ------------------------------------------------------------------ */ |
| 688 | |
Michael Krufky | 12afe37 | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 689 | static int tda18271_ir_cal_init(struct dvb_frontend *fe) |
| 690 | { |
| 691 | struct tda18271_priv *priv = fe->tuner_priv; |
| 692 | unsigned char *regs = priv->tda18271_regs; |
| 693 | |
| 694 | tda18271_read_regs(fe); |
| 695 | |
| 696 | /* test IR_CAL_OK to see if we need init */ |
| 697 | if ((regs[R_EP1] & 0x08) == 0) |
| 698 | tda18271_init_regs(fe); |
| 699 | |
| 700 | return 0; |
| 701 | } |
| 702 | |
| 703 | static int tda18271_init(struct dvb_frontend *fe) |
| 704 | { |
| 705 | struct tda18271_priv *priv = fe->tuner_priv; |
| 706 | |
| 707 | mutex_lock(&priv->lock); |
| 708 | |
| 709 | /* power up */ |
| 710 | tda18271_set_standby_mode(fe, 0, 0, 0); |
| 711 | |
| 712 | /* initialization */ |
| 713 | tda18271_ir_cal_init(fe); |
| 714 | |
| 715 | if (priv->id == TDA18271HDC2) |
| 716 | tda18271c2_rf_cal_init(fe); |
| 717 | |
| 718 | mutex_unlock(&priv->lock); |
| 719 | |
| 720 | return 0; |
| 721 | } |
| 722 | |
Michael Krufky | d1c5342 | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 723 | static int tda18271_tune(struct dvb_frontend *fe, |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 724 | struct tda18271_std_map_item *map, u32 freq, u32 bw) |
Michael Krufky | 4d2d42b | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 725 | { |
| 726 | struct tda18271_priv *priv = fe->tuner_priv; |
| 727 | |
Michael Krufky | 7f7203d | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 728 | tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n", |
| 729 | freq, map->if_freq, bw, map->agc_mode, map->std); |
Michael Krufky | d1c5342 | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 730 | |
Michael Krufky | 4d2d42b | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 731 | tda18271_init(fe); |
| 732 | |
| 733 | mutex_lock(&priv->lock); |
| 734 | |
Michael Krufky | d1c5342 | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 735 | switch (priv->id) { |
| 736 | case TDA18271HDC1: |
| 737 | tda18271c1_rf_tracking_filter_calibration(fe, freq, bw); |
| 738 | break; |
| 739 | case TDA18271HDC2: |
| 740 | tda18271c2_rf_tracking_filters_correction(fe, freq); |
| 741 | break; |
| 742 | } |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 743 | tda18271_channel_configuration(fe, map, freq, bw); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 744 | |
Michael Krufky | 8d316bf | 2008-01-06 15:31:35 -0300 | [diff] [blame] | 745 | mutex_unlock(&priv->lock); |
Michael Krufky | 6ca04de | 2007-11-23 16:52:15 -0300 | [diff] [blame] | 746 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 747 | return 0; |
| 748 | } |
| 749 | |
| 750 | /* ------------------------------------------------------------------ */ |
| 751 | |
| 752 | static int tda18271_set_params(struct dvb_frontend *fe, |
| 753 | struct dvb_frontend_parameters *params) |
| 754 | { |
| 755 | struct tda18271_priv *priv = fe->tuner_priv; |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 756 | struct tda18271_std_map *std_map = &priv->std; |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 757 | struct tda18271_std_map_item *map; |
Michael Krufky | ccbac9b | 2008-01-06 00:55:21 -0300 | [diff] [blame] | 758 | int ret; |
Michael Krufky | 2ba65d5 | 2008-01-03 01:17:45 -0300 | [diff] [blame] | 759 | u32 bw, freq = params->frequency; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 760 | |
| 761 | priv->mode = TDA18271_DIGITAL; |
| 762 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 763 | if (fe->ops.info.type == FE_ATSC) { |
| 764 | switch (params->u.vsb.modulation) { |
| 765 | case VSB_8: |
| 766 | case VSB_16: |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 767 | map = &std_map->atsc_6; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 768 | break; |
| 769 | case QAM_64: |
| 770 | case QAM_256: |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 771 | map = &std_map->qam_6; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 772 | break; |
| 773 | default: |
Michael Krufky | 182519f | 2007-12-25 15:10:11 -0300 | [diff] [blame] | 774 | tda_warn("modulation not set!\n"); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 775 | return -EINVAL; |
| 776 | } |
Michael Krufky | 14e3c15 | 2007-12-07 00:33:08 -0300 | [diff] [blame] | 777 | #if 0 |
| 778 | /* userspace request is already center adjusted */ |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 779 | freq += 1750000; /* Adjust to center (+1.75MHZ) */ |
Michael Krufky | 14e3c15 | 2007-12-07 00:33:08 -0300 | [diff] [blame] | 780 | #endif |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 781 | bw = 6000000; |
| 782 | } else if (fe->ops.info.type == FE_OFDM) { |
| 783 | switch (params->u.ofdm.bandwidth) { |
| 784 | case BANDWIDTH_6_MHZ: |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 785 | bw = 6000000; |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 786 | map = &std_map->dvbt_6; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 787 | break; |
| 788 | case BANDWIDTH_7_MHZ: |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 789 | bw = 7000000; |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 790 | map = &std_map->dvbt_7; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 791 | break; |
| 792 | case BANDWIDTH_8_MHZ: |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 793 | bw = 8000000; |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 794 | map = &std_map->dvbt_8; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 795 | break; |
| 796 | default: |
Michael Krufky | 182519f | 2007-12-25 15:10:11 -0300 | [diff] [blame] | 797 | tda_warn("bandwidth not set!\n"); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 798 | return -EINVAL; |
| 799 | } |
| 800 | } else { |
Michael Krufky | 182519f | 2007-12-25 15:10:11 -0300 | [diff] [blame] | 801 | tda_warn("modulation type not supported!\n"); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 802 | return -EINVAL; |
| 803 | } |
| 804 | |
Michael Krufky | ed73683 | 2008-01-19 17:41:04 -0300 | [diff] [blame] | 805 | /* When tuning digital, the analog demod must be tri-stated */ |
| 806 | if (fe->ops.analog_ops.standby) |
| 807 | fe->ops.analog_ops.standby(fe); |
| 808 | |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 809 | ret = tda18271_tune(fe, map, freq, bw); |
Michael Krufky | ccbac9b | 2008-01-06 00:55:21 -0300 | [diff] [blame] | 810 | |
| 811 | if (ret < 0) |
| 812 | goto fail; |
| 813 | |
| 814 | priv->frequency = freq; |
| 815 | priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? |
| 816 | params->u.ofdm.bandwidth : 0; |
| 817 | fail: |
| 818 | return ret; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | static int tda18271_set_analog_params(struct dvb_frontend *fe, |
| 822 | struct analog_parameters *params) |
| 823 | { |
| 824 | struct tda18271_priv *priv = fe->tuner_priv; |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 825 | struct tda18271_std_map *std_map = &priv->std; |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 826 | struct tda18271_std_map_item *map; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 827 | char *mode; |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 828 | int ret; |
Michael Krufky | 2ba65d5 | 2008-01-03 01:17:45 -0300 | [diff] [blame] | 829 | u32 freq = params->frequency * 62500; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 830 | |
| 831 | priv->mode = TDA18271_ANALOG; |
| 832 | |
Michael Krufky | c353f42 | 2008-01-08 10:38:10 -0300 | [diff] [blame] | 833 | if (params->mode == V4L2_TUNER_RADIO) { |
Michael Krufky | c353f42 | 2008-01-08 10:38:10 -0300 | [diff] [blame] | 834 | freq = freq / 1000; |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 835 | map = &std_map->fm_radio; |
Michael Krufky | c353f42 | 2008-01-08 10:38:10 -0300 | [diff] [blame] | 836 | mode = "fm"; |
| 837 | } else if (params->std & V4L2_STD_MN) { |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 838 | map = &std_map->atv_mn; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 839 | mode = "MN"; |
| 840 | } else if (params->std & V4L2_STD_B) { |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 841 | map = &std_map->atv_b; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 842 | mode = "B"; |
| 843 | } else if (params->std & V4L2_STD_GH) { |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 844 | map = &std_map->atv_gh; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 845 | mode = "GH"; |
| 846 | } else if (params->std & V4L2_STD_PAL_I) { |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 847 | map = &std_map->atv_i; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 848 | mode = "I"; |
| 849 | } else if (params->std & V4L2_STD_DK) { |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 850 | map = &std_map->atv_dk; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 851 | mode = "DK"; |
| 852 | } else if (params->std & V4L2_STD_SECAM_L) { |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 853 | map = &std_map->atv_l; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 854 | mode = "L"; |
| 855 | } else if (params->std & V4L2_STD_SECAM_LC) { |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 856 | map = &std_map->atv_lc; |
Michael Krufky | 95af8a2 | 2008-01-01 18:31:34 -0300 | [diff] [blame] | 857 | mode = "L'"; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 858 | } else { |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 859 | map = &std_map->atv_i; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 860 | mode = "xx"; |
| 861 | } |
| 862 | |
Michael Krufky | 182519f | 2007-12-25 15:10:11 -0300 | [diff] [blame] | 863 | tda_dbg("setting tda18271 to system %s\n", mode); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 864 | |
Michael Krufky | c293d0a | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 865 | ret = tda18271_tune(fe, map, freq, 0); |
Michael Krufky | ccbac9b | 2008-01-06 00:55:21 -0300 | [diff] [blame] | 866 | |
| 867 | if (ret < 0) |
| 868 | goto fail; |
| 869 | |
| 870 | priv->frequency = freq; |
| 871 | priv->bandwidth = 0; |
| 872 | fail: |
| 873 | return ret; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 874 | } |
| 875 | |
Michael Krufky | 518d873 | 2008-01-13 17:01:01 -0300 | [diff] [blame] | 876 | static int tda18271_sleep(struct dvb_frontend *fe) |
| 877 | { |
| 878 | struct tda18271_priv *priv = fe->tuner_priv; |
| 879 | |
| 880 | mutex_lock(&priv->lock); |
| 881 | |
| 882 | /* standby mode w/ slave tuner output |
| 883 | * & loop thru & xtal oscillator on */ |
| 884 | tda18271_set_standby_mode(fe, 1, 0, 0); |
| 885 | |
| 886 | mutex_unlock(&priv->lock); |
| 887 | |
| 888 | return 0; |
| 889 | } |
| 890 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 891 | static int tda18271_release(struct dvb_frontend *fe) |
| 892 | { |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 893 | struct tda18271_priv *priv = fe->tuner_priv; |
| 894 | |
| 895 | mutex_lock(&tda18271_list_mutex); |
| 896 | |
Michael Krufky | f9e315a | 2008-04-22 14:41:54 -0300 | [diff] [blame] | 897 | if (priv) |
| 898 | hybrid_tuner_release_state(priv); |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 899 | |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 900 | mutex_unlock(&tda18271_list_mutex); |
| 901 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 902 | fe->tuner_priv = NULL; |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 903 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 904 | return 0; |
| 905 | } |
| 906 | |
| 907 | static int tda18271_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
| 908 | { |
| 909 | struct tda18271_priv *priv = fe->tuner_priv; |
| 910 | *frequency = priv->frequency; |
| 911 | return 0; |
| 912 | } |
| 913 | |
| 914 | static int tda18271_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) |
| 915 | { |
| 916 | struct tda18271_priv *priv = fe->tuner_priv; |
| 917 | *bandwidth = priv->bandwidth; |
| 918 | return 0; |
| 919 | } |
| 920 | |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 921 | /* ------------------------------------------------------------------ */ |
| 922 | |
| 923 | #define tda18271_update_std(std_cfg, name) do { \ |
Michael Krufky | 7f7203d | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 924 | if (map->std_cfg.if_freq + \ |
| 925 | map->std_cfg.agc_mode + map->std_cfg.std > 0) { \ |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 926 | tda_dbg("Using custom std config for %s\n", name); \ |
| 927 | memcpy(&std->std_cfg, &map->std_cfg, \ |
| 928 | sizeof(struct tda18271_std_map_item)); \ |
| 929 | } } while (0) |
| 930 | |
| 931 | #define tda18271_dump_std_item(std_cfg, name) do { \ |
Michael Krufky | 7f7203d | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 932 | tda_dbg("(%s) if freq = %d, agc_mode = %d, std = %d\n", \ |
| 933 | name, std->std_cfg.if_freq, \ |
| 934 | std->std_cfg.agc_mode, std->std_cfg.std); \ |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 935 | } while (0) |
| 936 | |
| 937 | static int tda18271_dump_std_map(struct dvb_frontend *fe) |
| 938 | { |
| 939 | struct tda18271_priv *priv = fe->tuner_priv; |
| 940 | struct tda18271_std_map *std = &priv->std; |
| 941 | |
| 942 | tda_dbg("========== STANDARD MAP SETTINGS ==========\n"); |
Michael Krufky | c353f42 | 2008-01-08 10:38:10 -0300 | [diff] [blame] | 943 | tda18271_dump_std_item(fm_radio, "fm"); |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 944 | tda18271_dump_std_item(atv_b, "pal b"); |
| 945 | tda18271_dump_std_item(atv_dk, "pal dk"); |
| 946 | tda18271_dump_std_item(atv_gh, "pal gh"); |
| 947 | tda18271_dump_std_item(atv_i, "pal i"); |
| 948 | tda18271_dump_std_item(atv_l, "pal l"); |
| 949 | tda18271_dump_std_item(atv_lc, "pal l'"); |
| 950 | tda18271_dump_std_item(atv_mn, "atv mn"); |
| 951 | tda18271_dump_std_item(atsc_6, "atsc 6"); |
| 952 | tda18271_dump_std_item(dvbt_6, "dvbt 6"); |
| 953 | tda18271_dump_std_item(dvbt_7, "dvbt 7"); |
| 954 | tda18271_dump_std_item(dvbt_8, "dvbt 8"); |
| 955 | tda18271_dump_std_item(qam_6, "qam 6"); |
| 956 | tda18271_dump_std_item(qam_8, "qam 8"); |
| 957 | |
| 958 | return 0; |
| 959 | } |
| 960 | |
| 961 | static int tda18271_update_std_map(struct dvb_frontend *fe, |
| 962 | struct tda18271_std_map *map) |
| 963 | { |
| 964 | struct tda18271_priv *priv = fe->tuner_priv; |
| 965 | struct tda18271_std_map *std = &priv->std; |
| 966 | |
| 967 | if (!map) |
| 968 | return -EINVAL; |
| 969 | |
Michael Krufky | c353f42 | 2008-01-08 10:38:10 -0300 | [diff] [blame] | 970 | tda18271_update_std(fm_radio, "fm"); |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 971 | tda18271_update_std(atv_b, "atv b"); |
| 972 | tda18271_update_std(atv_dk, "atv dk"); |
| 973 | tda18271_update_std(atv_gh, "atv gh"); |
| 974 | tda18271_update_std(atv_i, "atv i"); |
| 975 | tda18271_update_std(atv_l, "atv l"); |
| 976 | tda18271_update_std(atv_lc, "atv l'"); |
| 977 | tda18271_update_std(atv_mn, "atv mn"); |
| 978 | tda18271_update_std(atsc_6, "atsc 6"); |
| 979 | tda18271_update_std(dvbt_6, "dvbt 6"); |
| 980 | tda18271_update_std(dvbt_7, "dvbt 7"); |
| 981 | tda18271_update_std(dvbt_8, "dvbt 8"); |
| 982 | tda18271_update_std(qam_6, "qam 6"); |
| 983 | tda18271_update_std(qam_8, "qam 8"); |
| 984 | |
| 985 | return 0; |
| 986 | } |
| 987 | |
Michael Krufky | 49e7aaf | 2007-12-24 04:15:20 -0300 | [diff] [blame] | 988 | static int tda18271_get_id(struct dvb_frontend *fe) |
| 989 | { |
| 990 | struct tda18271_priv *priv = fe->tuner_priv; |
| 991 | unsigned char *regs = priv->tda18271_regs; |
| 992 | char *name; |
| 993 | int ret = 0; |
| 994 | |
Michael Krufky | 8d316bf | 2008-01-06 15:31:35 -0300 | [diff] [blame] | 995 | mutex_lock(&priv->lock); |
Michael Krufky | 49e7aaf | 2007-12-24 04:15:20 -0300 | [diff] [blame] | 996 | tda18271_read_regs(fe); |
Michael Krufky | 8d316bf | 2008-01-06 15:31:35 -0300 | [diff] [blame] | 997 | mutex_unlock(&priv->lock); |
Michael Krufky | 49e7aaf | 2007-12-24 04:15:20 -0300 | [diff] [blame] | 998 | |
| 999 | switch (regs[R_ID] & 0x7f) { |
| 1000 | case 3: |
| 1001 | name = "TDA18271HD/C1"; |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 1002 | priv->id = TDA18271HDC1; |
Michael Krufky | 49e7aaf | 2007-12-24 04:15:20 -0300 | [diff] [blame] | 1003 | break; |
| 1004 | case 4: |
| 1005 | name = "TDA18271HD/C2"; |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 1006 | priv->id = TDA18271HDC2; |
Michael Krufky | 49e7aaf | 2007-12-24 04:15:20 -0300 | [diff] [blame] | 1007 | break; |
| 1008 | default: |
| 1009 | name = "Unknown device"; |
| 1010 | ret = -EINVAL; |
| 1011 | break; |
| 1012 | } |
| 1013 | |
Michael Krufky | 182519f | 2007-12-25 15:10:11 -0300 | [diff] [blame] | 1014 | tda_info("%s detected @ %d-%04x%s\n", name, |
Michael Krufky | f9e315a | 2008-04-22 14:41:54 -0300 | [diff] [blame] | 1015 | i2c_adapter_id(priv->i2c_props.adap), |
| 1016 | priv->i2c_props.addr, |
Michael Krufky | 49e7aaf | 2007-12-24 04:15:20 -0300 | [diff] [blame] | 1017 | (0 == ret) ? "" : ", device not supported."); |
| 1018 | |
| 1019 | return ret; |
| 1020 | } |
| 1021 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1022 | static struct dvb_tuner_ops tda18271_tuner_ops = { |
| 1023 | .info = { |
| 1024 | .name = "NXP TDA18271HD", |
| 1025 | .frequency_min = 45000000, |
| 1026 | .frequency_max = 864000000, |
| 1027 | .frequency_step = 62500 |
| 1028 | }, |
Michael Krufky | efce841 | 2007-12-01 17:40:16 -0300 | [diff] [blame] | 1029 | .init = tda18271_init, |
Michael Krufky | 518d873 | 2008-01-13 17:01:01 -0300 | [diff] [blame] | 1030 | .sleep = tda18271_sleep, |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1031 | .set_params = tda18271_set_params, |
| 1032 | .set_analog_params = tda18271_set_analog_params, |
| 1033 | .release = tda18271_release, |
| 1034 | .get_frequency = tda18271_get_frequency, |
| 1035 | .get_bandwidth = tda18271_get_bandwidth, |
| 1036 | }; |
| 1037 | |
| 1038 | struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, |
Michael Krufky | e435f95 | 2007-12-09 22:23:30 -0300 | [diff] [blame] | 1039 | struct i2c_adapter *i2c, |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 1040 | struct tda18271_config *cfg) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1041 | { |
| 1042 | struct tda18271_priv *priv = NULL; |
Michael Krufky | f9e315a | 2008-04-22 14:41:54 -0300 | [diff] [blame] | 1043 | int instance; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1044 | |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 1045 | mutex_lock(&tda18271_list_mutex); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1046 | |
Michael Krufky | f9e315a | 2008-04-22 14:41:54 -0300 | [diff] [blame] | 1047 | instance = hybrid_tuner_request_state(struct tda18271_priv, priv, |
| 1048 | hybrid_tuner_instance_list, |
| 1049 | i2c, addr, "tda18271"); |
| 1050 | switch (instance) { |
| 1051 | case 0: |
| 1052 | goto fail; |
| 1053 | break; |
| 1054 | case 1: |
| 1055 | /* new tuner instance */ |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 1056 | priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO; |
| 1057 | priv->cal_initialized = false; |
| 1058 | mutex_init(&priv->lock); |
Michael Krufky | 49e7aaf | 2007-12-24 04:15:20 -0300 | [diff] [blame] | 1059 | |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 1060 | fe->tuner_priv = priv; |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 1061 | |
Michael Krufky | 5555309 | 2008-04-22 14:46:06 -0300 | [diff] [blame] | 1062 | if (cfg) |
| 1063 | priv->small_i2c = cfg->small_i2c; |
| 1064 | |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 1065 | if (tda18271_get_id(fe) < 0) |
| 1066 | goto fail; |
| 1067 | |
| 1068 | if (tda18271_assign_map_layout(fe) < 0) |
| 1069 | goto fail; |
| 1070 | |
| 1071 | mutex_lock(&priv->lock); |
| 1072 | tda18271_init_regs(fe); |
Michael Krufky | 0f96251 | 2008-01-13 22:01:07 -0300 | [diff] [blame] | 1073 | |
| 1074 | if ((tda18271_cal_on_startup) && (priv->id == TDA18271HDC2)) |
Michael Krufky | 12afe37 | 2008-04-22 14:42:07 -0300 | [diff] [blame] | 1075 | tda18271c2_rf_cal_init(fe); |
Michael Krufky | 0f96251 | 2008-01-13 22:01:07 -0300 | [diff] [blame] | 1076 | |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 1077 | mutex_unlock(&priv->lock); |
Michael Krufky | f9e315a | 2008-04-22 14:41:54 -0300 | [diff] [blame] | 1078 | break; |
| 1079 | default: |
| 1080 | /* existing tuner instance */ |
| 1081 | fe->tuner_priv = priv; |
| 1082 | |
| 1083 | /* allow dvb driver to override i2c gate setting */ |
| 1084 | if ((cfg) && (cfg->gate != TDA18271_GATE_ANALOG)) |
| 1085 | priv->gate = cfg->gate; |
| 1086 | break; |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 1087 | } |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1088 | |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 1089 | /* override default std map with values in config struct */ |
| 1090 | if ((cfg) && (cfg->std_map)) |
| 1091 | tda18271_update_std_map(fe, cfg->std_map); |
| 1092 | |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 1093 | mutex_unlock(&tda18271_list_mutex); |
| 1094 | |
| 1095 | memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops, |
| 1096 | sizeof(struct dvb_tuner_ops)); |
| 1097 | |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 1098 | if (tda18271_debug & DBG_MAP) |
| 1099 | tda18271_dump_std_map(fe); |
| 1100 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1101 | return fe; |
Michael Krufky | 49e7aaf | 2007-12-24 04:15:20 -0300 | [diff] [blame] | 1102 | fail: |
Michael Krufky | a4f263b | 2008-01-06 15:52:56 -0300 | [diff] [blame] | 1103 | mutex_unlock(&tda18271_list_mutex); |
| 1104 | |
Michael Krufky | 49e7aaf | 2007-12-24 04:15:20 -0300 | [diff] [blame] | 1105 | tda18271_release(fe); |
| 1106 | return NULL; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1107 | } |
| 1108 | EXPORT_SYMBOL_GPL(tda18271_attach); |
| 1109 | MODULE_DESCRIPTION("NXP TDA18271HD analog / digital tuner driver"); |
| 1110 | MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>"); |
| 1111 | MODULE_LICENSE("GPL"); |
Michael Krufky | 255b511 | 2008-01-01 22:52:09 -0300 | [diff] [blame] | 1112 | MODULE_VERSION("0.2"); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 1113 | |
| 1114 | /* |
| 1115 | * Overrides for Emacs so that we follow Linus's tabbing style. |
| 1116 | * --------------------------------------------------------------------------- |
| 1117 | * Local variables: |
| 1118 | * c-basic-offset: 8 |
| 1119 | * End: |
| 1120 | */ |