3 i2c tv tuner chip device driver
4 controls the philips tda8290+75 tuner chip combo.
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.
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.
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.
20 This "tda8290" module was split apart from the original "tuner" module.
23 #include <linux/i2c.h>
24 #include <linux/delay.h>
25 #include <linux/videodev.h>
30 static int tuner_debug;
31 module_param_named(debug, tuner_debug, int, 0644);
32 MODULE_PARM_DESC(debug, "enable verbose debug messages");
34 #define PREFIX "tda8290 "
36 /* ---------------------------------------------------------------------- */
39 struct tuner_i2c_props i2c_props;
41 unsigned char tda8290_easy_mode;
43 unsigned char tda827x_addr;
44 unsigned char tda827x_ver;
46 struct tda827x_config cfg;
51 /*---------------------------------------------------------------------*/
53 static void tda8290_i2c_bridge(struct dvb_frontend *fe, int close)
55 struct tda8290_priv *priv = fe->analog_demod_priv;
57 unsigned char enable[2] = { 0x21, 0xC0 };
58 unsigned char disable[2] = { 0x21, 0x00 };
62 tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
63 /* let the bridge stabilize */
67 tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
71 static void tda8295_i2c_bridge(struct dvb_frontend *fe, int close)
73 struct tda8290_priv *priv = fe->analog_demod_priv;
75 unsigned char enable[2] = { 0x45, 0xc1 };
76 unsigned char disable[2] = { 0x46, 0x00 };
77 unsigned char buf[3] = { 0x45, 0x01, 0x00 };
81 tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
82 /* let the bridge stabilize */
86 tuner_i2c_xfer_send(&priv->i2c_props, msg, 1);
87 tuner_i2c_xfer_recv(&priv->i2c_props, &msg[1], 1);
91 tuner_i2c_xfer_send(&priv->i2c_props, buf, 3);
95 tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
99 /*---------------------------------------------------------------------*/
101 static void set_audio(struct dvb_frontend *fe)
103 struct tda8290_priv *priv = fe->analog_demod_priv;
104 struct tuner *t = priv->t;
107 if (t->std & V4L2_STD_MN) {
108 priv->tda8290_easy_mode = 0x01;
110 } else if (t->std & V4L2_STD_B) {
111 priv->tda8290_easy_mode = 0x02;
113 } else if (t->std & V4L2_STD_GH) {
114 priv->tda8290_easy_mode = 0x04;
116 } else if (t->std & V4L2_STD_PAL_I) {
117 priv->tda8290_easy_mode = 0x08;
119 } else if (t->std & V4L2_STD_DK) {
120 priv->tda8290_easy_mode = 0x10;
122 } else if (t->std & V4L2_STD_SECAM_L) {
123 priv->tda8290_easy_mode = 0x20;
125 } else if (t->std & V4L2_STD_SECAM_LC) {
126 priv->tda8290_easy_mode = 0x40;
129 priv->tda8290_easy_mode = 0x10;
133 tuner_dbg("setting tda8290 to system %s\n", mode);
136 static void tda8290_set_freq(struct dvb_frontend *fe, unsigned int freq)
138 struct tda8290_priv *priv = fe->analog_demod_priv;
139 struct tuner *t = priv->t;
141 unsigned char soft_reset[] = { 0x00, 0x00 };
142 unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode };
143 unsigned char expert_mode[] = { 0x01, 0x80 };
144 unsigned char agc_out_on[] = { 0x02, 0x00 };
145 unsigned char gainset_off[] = { 0x28, 0x14 };
146 unsigned char if_agc_spd[] = { 0x0f, 0x88 };
147 unsigned char adc_head_6[] = { 0x05, 0x04 };
148 unsigned char adc_head_9[] = { 0x05, 0x02 };
149 unsigned char adc_head_12[] = { 0x05, 0x01 };
150 unsigned char pll_bw_nom[] = { 0x0d, 0x47 };
151 unsigned char pll_bw_low[] = { 0x0d, 0x27 };
152 unsigned char gainset_2[] = { 0x28, 0x64 };
153 unsigned char agc_rst_on[] = { 0x0e, 0x0b };
154 unsigned char agc_rst_off[] = { 0x0e, 0x09 };
155 unsigned char if_agc_set[] = { 0x0f, 0x81 };
156 unsigned char addr_adc_sat = 0x1a;
157 unsigned char addr_agc_stat = 0x1d;
158 unsigned char addr_pll_stat = 0x1b;
159 unsigned char adc_sat, agc_stat,
163 struct analog_parameters params = {
166 .audmode = t->audmode,
172 tuner_dbg("tda827xa config is 0x%02x\n", t->config);
173 tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2);
174 tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2);
175 tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2);
178 expert_mode[1] = priv->tda8290_easy_mode + 0x80;
179 tuner_i2c_xfer_send(&priv->i2c_props, expert_mode, 2);
180 tuner_i2c_xfer_send(&priv->i2c_props, gainset_off, 2);
181 tuner_i2c_xfer_send(&priv->i2c_props, if_agc_spd, 2);
182 if (priv->tda8290_easy_mode & 0x60)
183 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_9, 2);
185 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2);
186 tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2);
188 tda8290_i2c_bridge(fe, 1);
190 if (fe->ops.tuner_ops.set_analog_params)
191 fe->ops.tuner_ops.set_analog_params(fe, ¶ms);
193 for (i = 0; i < 3; i++) {
194 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
195 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1);
196 if (pll_stat & 0x80) {
197 tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1);
198 tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1);
199 tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1);
200 tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1);
201 tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat);
204 tuner_dbg("tda8290 not locked, no signal?\n");
208 /* adjust headroom resp. gain */
209 if ((agc_stat > 115) || (!(pll_stat & 0x80) && (adc_sat < 20))) {
210 tuner_dbg("adjust gain, step 1. Agc: %d, ADC stat: %d, lock: %d\n",
211 agc_stat, adc_sat, pll_stat & 0x80);
212 tuner_i2c_xfer_send(&priv->i2c_props, gainset_2, 2);
214 tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1);
215 tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1);
216 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
217 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1);
218 if ((agc_stat > 115) || !(pll_stat & 0x80)) {
219 tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n",
220 agc_stat, pll_stat & 0x80);
224 tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1);
225 tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1);
226 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
227 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1);
228 if((agc_stat > 115) || !(pll_stat & 0x80)) {
229 tuner_dbg("adjust gain, step 3. Agc: %d\n", agc_stat);
230 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_12, 2);
231 tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_low, 2);
237 /* l/ l' deadlock? */
238 if(priv->tda8290_easy_mode & 0x60) {
239 tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1);
240 tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1);
241 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
242 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1);
243 if ((adc_sat > 20) || !(pll_stat & 0x80)) {
244 tuner_dbg("trying to resolve SECAM L deadlock\n");
245 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_on, 2);
247 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_off, 2);
251 tda8290_i2c_bridge(fe, 0);
252 tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2);
255 /*---------------------------------------------------------------------*/
257 static void tda8295_power(struct dvb_frontend *fe, int enable)
259 struct tda8290_priv *priv = fe->analog_demod_priv;
260 unsigned char buf[] = { 0x30, 0x00 }; /* clb_stdbt */
262 tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1);
263 tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1);
270 tuner_i2c_xfer_send(&priv->i2c_props, buf, 2);
273 static void tda8295_set_easy_mode(struct dvb_frontend *fe, int enable)
275 struct tda8290_priv *priv = fe->analog_demod_priv;
276 unsigned char buf[] = { 0x01, 0x00 };
278 tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1);
279 tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1);
282 buf[1] = 0x01; /* rising edge sets regs 0x02 - 0x23 */
284 buf[1] = 0x00; /* reset active bit */
286 tuner_i2c_xfer_send(&priv->i2c_props, buf, 2);
289 static void tda8295_set_video_std(struct dvb_frontend *fe)
291 struct tda8290_priv *priv = fe->analog_demod_priv;
292 unsigned char buf[] = { 0x00, priv->tda8290_easy_mode };
294 tuner_i2c_xfer_send(&priv->i2c_props, buf, 2);
296 tda8295_set_easy_mode(fe, 1);
298 tda8295_set_easy_mode(fe, 0);
301 /*---------------------------------------------------------------------*/
303 static void tda8295_agc1_out(struct dvb_frontend *fe, int enable)
305 struct tda8290_priv *priv = fe->analog_demod_priv;
306 unsigned char buf[] = { 0x02, 0x00 }; /* DIV_FUNC */
308 tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1);
309 tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1);
316 tuner_i2c_xfer_send(&priv->i2c_props, buf, 2);
319 static void tda8295_agc2_out(struct dvb_frontend *fe, int enable)
321 struct tda8290_priv *priv = fe->analog_demod_priv;
322 unsigned char set_gpio_cf[] = { 0x44, 0x00 };
323 unsigned char set_gpio_val[] = { 0x46, 0x00 };
325 tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_cf[0], 1);
326 tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_cf[1], 1);
327 tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_val[0], 1);
328 tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_val[1], 1);
330 set_gpio_cf[1] &= 0xf0; /* clear GPIO_0 bits 3-0 */
333 set_gpio_cf[1] |= 0x01; /* config GPIO_0 as Open Drain Out */
334 set_gpio_val[1] &= 0xfe; /* set GPIO_0 pin low */
336 tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_cf, 2);
337 tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_val, 2);
340 static int tda8295_has_signal(struct dvb_frontend *fe)
342 struct tda8290_priv *priv = fe->analog_demod_priv;
344 unsigned char hvpll_stat = 0x26;
347 tuner_i2c_xfer_send(&priv->i2c_props, &hvpll_stat, 1);
348 tuner_i2c_xfer_recv(&priv->i2c_props, &ret, 1);
349 return (ret & 0x01) ? 65535 : 0;
352 /*---------------------------------------------------------------------*/
354 static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq)
356 struct tda8290_priv *priv = fe->analog_demod_priv;
357 struct tuner *t = priv->t;
359 unsigned char blanking_mode[] = { 0x1d, 0x00 };
361 struct analog_parameters params = {
364 .audmode = t->audmode,
370 tuner_dbg("%s: freq = %d\n", __FUNCTION__, freq);
372 tda8295_power(fe, 1);
373 tda8295_agc1_out(fe, 1);
375 tuner_i2c_xfer_send(&priv->i2c_props, &blanking_mode[0], 1);
376 tuner_i2c_xfer_recv(&priv->i2c_props, &blanking_mode[1], 1);
378 tda8295_set_video_std(fe);
380 blanking_mode[1] = 0x03;
381 tuner_i2c_xfer_send(&priv->i2c_props, blanking_mode, 2);
384 tda8295_i2c_bridge(fe, 1);
386 if (fe->ops.tuner_ops.set_analog_params)
387 fe->ops.tuner_ops.set_analog_params(fe, ¶ms);
392 if (tda8295_has_signal(fe))
393 tuner_dbg("tda8295 is locked\n");
395 tuner_dbg("tda8295 not locked, no signal?\n");
397 tda8295_i2c_bridge(fe, 0);
400 /*---------------------------------------------------------------------*/
402 static int tda8290_has_signal(struct dvb_frontend *fe)
404 struct tda8290_priv *priv = fe->analog_demod_priv;
406 unsigned char i2c_get_afc[1] = { 0x1B };
407 unsigned char afc = 0;
409 tuner_i2c_xfer_send(&priv->i2c_props, i2c_get_afc, ARRAY_SIZE(i2c_get_afc));
410 tuner_i2c_xfer_recv(&priv->i2c_props, &afc, 1);
411 return (afc & 0x80)? 65535:0;
414 /*---------------------------------------------------------------------*/
416 static void tda8290_standby(struct dvb_frontend *fe)
418 struct tda8290_priv *priv = fe->analog_demod_priv;
420 unsigned char cb1[] = { 0x30, 0xD0 };
421 unsigned char tda8290_standby[] = { 0x00, 0x02 };
422 unsigned char tda8290_agc_tri[] = { 0x02, 0x20 };
423 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2};
425 tda8290_i2c_bridge(fe, 1);
426 if (priv->tda827x_ver != 0)
428 i2c_transfer(priv->i2c_props.adap, &msg, 1);
429 tda8290_i2c_bridge(fe, 0);
430 tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2);
431 tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2);
434 static void tda8295_standby(struct dvb_frontend *fe)
436 tda8295_agc1_out(fe, 0); /* Put AGC in tri-state */
438 tda8295_power(fe, 0);
441 static void tda8290_init_if(struct dvb_frontend *fe)
443 struct tda8290_priv *priv = fe->analog_demod_priv;
444 struct tuner *t = priv->t;
446 unsigned char set_VS[] = { 0x30, 0x6F };
447 unsigned char set_GP00_CF[] = { 0x20, 0x01 };
448 unsigned char set_GP01_CF[] = { 0x20, 0x0B };
450 if ((t->config == 1) || (t->config == 2))
451 tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2);
453 tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2);
454 tuner_i2c_xfer_send(&priv->i2c_props, set_VS, 2);
457 static void tda8295_init_if(struct dvb_frontend *fe)
459 struct tda8290_priv *priv = fe->analog_demod_priv;
461 static unsigned char set_adc_ctl[] = { 0x33, 0x14 };
462 static unsigned char set_adc_ctl2[] = { 0x34, 0x00 };
463 static unsigned char set_pll_reg6[] = { 0x3e, 0x63 };
464 static unsigned char set_pll_reg0[] = { 0x38, 0x23 };
465 static unsigned char set_pll_reg7[] = { 0x3f, 0x01 };
466 static unsigned char set_pll_reg10[] = { 0x42, 0x61 };
467 static unsigned char set_gpio_reg0[] = { 0x44, 0x0b };
469 tda8295_power(fe, 1);
471 tda8295_set_easy_mode(fe, 0);
472 tda8295_set_video_std(fe);
474 tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl, 2);
475 tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl2, 2);
476 tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg6, 2);
477 tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg0, 2);
478 tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg7, 2);
479 tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg10, 2);
480 tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_reg0, 2);
482 tda8295_agc1_out(fe, 0);
483 tda8295_agc2_out(fe, 0);
486 static void tda8290_init_tuner(struct dvb_frontend *fe)
488 struct tda8290_priv *priv = fe->analog_demod_priv;
489 unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf,
490 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 };
491 unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b,
492 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b };
493 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0,
494 .buf=tda8275_init, .len = 14};
495 if (priv->tda827x_ver != 0)
496 msg.buf = tda8275a_init;
498 tda8290_i2c_bridge(fe, 1);
499 i2c_transfer(priv->i2c_props.adap, &msg, 1);
500 tda8290_i2c_bridge(fe, 0);
503 /*---------------------------------------------------------------------*/
505 static void tda829x_release(struct dvb_frontend *fe)
507 if (fe->ops.tuner_ops.release)
508 fe->ops.tuner_ops.release(fe);
510 kfree(fe->analog_demod_priv);
511 fe->analog_demod_priv = NULL;
514 static struct analog_tuner_ops tda8290_tuner_ops = {
515 .set_tv_freq = tda8290_set_freq,
516 .set_radio_freq = tda8290_set_freq,
517 .has_signal = tda8290_has_signal,
518 .standby = tda8290_standby,
519 .release = tda829x_release,
522 static struct analog_tuner_ops tda8295_tuner_ops = {
523 .set_tv_freq = tda8295_set_freq,
524 .set_radio_freq = tda8295_set_freq,
525 .has_signal = tda8295_has_signal,
526 .standby = tda8295_standby,
527 .release = tda829x_release,
530 int tda8290_attach(struct tuner *t)
532 struct tda8290_priv *priv = NULL;
534 int i, ret, tuners_found;
536 struct i2c_msg msg = {.flags=I2C_M_RD, .buf=&data, .len = 1};
538 priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL);
541 t->fe.analog_demod_priv = priv;
543 priv->i2c_props.addr = t->i2c.addr;
544 priv->i2c_props.adap = t->i2c.adapter;
545 priv->cfg.config = &t->config;
546 priv->cfg.tuner_callback = t->tuner_callback;
549 tda8290_i2c_bridge(&t->fe, 1);
550 /* probe for tuner chip */
553 for (i=0x60; i<= 0x63; i++) {
555 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
558 tuner_addrs = (tuner_addrs << 8) + i;
561 /* if there is more than one tuner, we expect the right one is
562 behind the bridge and we choose the highest address that doesn't
565 tda8290_i2c_bridge(&t->fe, 0);
567 for (i = 0; i < tuners_found; i++) {
568 msg.addr = tuner_addrs & 0xff;
569 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
571 tuner_addrs = tuner_addrs >> 8;
575 if (tuner_addrs == 0) {
577 tuner_info("could not clearly identify tuner address, defaulting to %x\n",
580 tuner_addrs = tuner_addrs & 0xff;
581 tuner_info("setting tuner address to %x\n", tuner_addrs);
583 priv->tda827x_addr = tuner_addrs;
584 msg.addr = tuner_addrs;
586 tda8290_i2c_bridge(&t->fe, 1);
588 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
590 tuner_warn("TDA827x access failed!\n");
592 if ((data & 0x3c) == 0) {
593 strlcpy(t->i2c.name, "tda8290+75", sizeof(t->i2c.name));
594 priv->tda827x_ver = 0;
596 strlcpy(t->i2c.name, "tda8290+75a", sizeof(t->i2c.name));
597 priv->tda827x_ver = 2;
599 tda827x_attach(&t->fe, priv->tda827x_addr,
600 priv->i2c_props.adap, &priv->cfg);
602 /* FIXME: tda827x module doesn't probe the tuner until
603 * tda827x_initial_sleep is called
605 if (t->fe.ops.tuner_ops.sleep)
606 t->fe.ops.tuner_ops.sleep(&t->fe);
608 t->fe.ops.analog_demod_ops = &tda8290_tuner_ops;
610 tuner_info("type set to %s\n", t->i2c.name);
612 t->mode = V4L2_TUNER_ANALOG_TV;
614 tda8290_init_tuner(&t->fe);
615 tda8290_init_if(&t->fe);
618 EXPORT_SYMBOL_GPL(tda8290_attach);
620 int tda8295_attach(struct tuner *t)
622 struct tda8290_priv *priv = NULL;
624 int i, ret, tuners_found;
626 struct i2c_msg msg = { .flags = I2C_M_RD, .buf = &data, .len = 1 };
628 priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL);
631 t->fe.analog_demod_priv = priv;
633 priv->i2c_props.addr = t->i2c.addr;
634 priv->i2c_props.adap = t->i2c.adapter;
637 tda8295_i2c_bridge(&t->fe, 1);
638 /* probe for tuner chip */
641 for (i = 0x60; i <= 0x63; i++) {
643 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
646 tuner_addrs = (tuner_addrs << 8) + i;
649 /* if there is more than one tuner, we expect the right one is
650 behind the bridge and we choose the highest address that doesn't
653 tda8295_i2c_bridge(&t->fe, 0);
654 if (tuners_found > 1)
655 for (i = 0; i < tuners_found; i++) {
656 msg.addr = tuner_addrs & 0xff;
657 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
659 tuner_addrs = tuner_addrs >> 8;
663 if (tuner_addrs == 0) {
665 tuner_info("could not clearly identify tuner address, "
666 "defaulting to %x\n", tuner_addrs);
668 tuner_addrs = tuner_addrs & 0xff;
669 tuner_info("setting tuner address to %x\n", tuner_addrs);
671 priv->tda827x_addr = tuner_addrs;
672 msg.addr = tuner_addrs;
674 tda8295_i2c_bridge(&t->fe, 1);
675 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
676 tda8295_i2c_bridge(&t->fe, 0);
678 tuner_warn("TDA827x access failed!\n");
679 if ((data & 0x3c) == 0) {
680 strlcpy(t->i2c.name, "tda8295+18271", sizeof(t->i2c.name));
681 tda18271_attach(&t->fe, priv->tda827x_addr,
682 priv->i2c_props.adap);
683 priv->tda827x_ver = 4;
685 strlcpy(t->i2c.name, "tda8295+75a", sizeof(t->i2c.name));
686 tda827x_attach(&t->fe, priv->tda827x_addr,
687 priv->i2c_props.adap, &priv->cfg);
689 /* FIXME: tda827x module doesn't probe the tuner until
690 * tda827x_initial_sleep is called
692 if (t->fe.ops.tuner_ops.sleep)
693 t->fe.ops.tuner_ops.sleep(&t->fe);
694 priv->tda827x_ver = 2;
696 priv->tda827x_ver |= 1; /* signifies 8295 vs 8290 */
697 tuner_info("type set to %s\n", t->i2c.name);
699 t->fe.ops.analog_demod_ops = &tda8295_tuner_ops;
701 t->mode = V4L2_TUNER_ANALOG_TV;
703 tda8295_init_if(&t->fe);
706 EXPORT_SYMBOL_GPL(tda8295_attach);
708 int tda8290_probe(struct tuner *t)
710 struct tuner_i2c_props i2c_props = {
711 .adap = t->i2c.adapter,
715 unsigned char soft_reset[] = { 0x00, 0x00 };
716 unsigned char easy_mode_b[] = { 0x01, 0x02 };
717 unsigned char easy_mode_g[] = { 0x01, 0x04 };
718 unsigned char restore_9886[] = { 0x00, 0xd6, 0x30 };
719 unsigned char addr_dto_lsb = 0x07;
722 tuner_i2c_xfer_send(&i2c_props, easy_mode_b, 2);
723 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2);
724 tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1);
725 tuner_i2c_xfer_recv(&i2c_props, &data, 1);
727 tuner_i2c_xfer_send(&i2c_props, easy_mode_g, 2);
728 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2);
729 tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1);
730 tuner_i2c_xfer_recv(&i2c_props, &data, 1);
735 tuner_i2c_xfer_send(&i2c_props, restore_9886, 3);
738 EXPORT_SYMBOL_GPL(tda8290_probe);
740 MODULE_DESCRIPTION("Philips TDA8290 + TDA8275 / TDA8275a tuner driver");
741 MODULE_AUTHOR("Gerd Knorr, Hartmut Hackmann, Michael Krufky");
742 MODULE_LICENSE("GPL");
745 * Overrides for Emacs so that we follow Linus's tabbing style.
746 * ---------------------------------------------------------------------------