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>
26 #include "tuner-driver.h"
27 #include "tuner-i2c.h"
33 module_param(debug, int, 0644);
34 MODULE_PARM_DESC(debug, "enable verbose debug messages");
36 #define PREFIX "tda8290"
38 /* ---------------------------------------------------------------------- */
41 struct tuner_i2c_props i2c_props;
43 unsigned char tda8290_easy_mode;
45 unsigned char tda827x_addr;
54 struct tda827x_config cfg;
57 /*---------------------------------------------------------------------*/
59 static int tda8290_i2c_bridge(struct dvb_frontend *fe, int close)
61 struct tda8290_priv *priv = fe->analog_demod_priv;
63 unsigned char enable[2] = { 0x21, 0xC0 };
64 unsigned char disable[2] = { 0x21, 0x00 };
69 tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
70 /* let the bridge stabilize */
74 tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
80 static int tda8295_i2c_bridge(struct dvb_frontend *fe, int close)
82 struct tda8290_priv *priv = fe->analog_demod_priv;
84 unsigned char enable[2] = { 0x45, 0xc1 };
85 unsigned char disable[2] = { 0x46, 0x00 };
86 unsigned char buf[3] = { 0x45, 0x01, 0x00 };
91 tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
92 /* let the bridge stabilize */
96 tuner_i2c_xfer_send(&priv->i2c_props, msg, 1);
97 tuner_i2c_xfer_recv(&priv->i2c_props, &msg[1], 1);
101 tuner_i2c_xfer_send(&priv->i2c_props, buf, 3);
105 tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
111 /*---------------------------------------------------------------------*/
113 static void set_audio(struct dvb_frontend *fe,
114 struct analog_parameters *params)
116 struct tda8290_priv *priv = fe->analog_demod_priv;
119 if (params->std & V4L2_STD_MN) {
120 priv->tda8290_easy_mode = 0x01;
122 } else if (params->std & V4L2_STD_B) {
123 priv->tda8290_easy_mode = 0x02;
125 } else if (params->std & V4L2_STD_GH) {
126 priv->tda8290_easy_mode = 0x04;
128 } else if (params->std & V4L2_STD_PAL_I) {
129 priv->tda8290_easy_mode = 0x08;
131 } else if (params->std & V4L2_STD_DK) {
132 priv->tda8290_easy_mode = 0x10;
134 } else if (params->std & V4L2_STD_SECAM_L) {
135 priv->tda8290_easy_mode = 0x20;
137 } else if (params->std & V4L2_STD_SECAM_LC) {
138 priv->tda8290_easy_mode = 0x40;
141 priv->tda8290_easy_mode = 0x10;
145 tuner_dbg("setting tda829x to system %s\n", mode);
148 static void tda8290_set_params(struct dvb_frontend *fe,
149 struct analog_parameters *params)
151 struct tda8290_priv *priv = fe->analog_demod_priv;
153 unsigned char soft_reset[] = { 0x00, 0x00 };
154 unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode };
155 unsigned char expert_mode[] = { 0x01, 0x80 };
156 unsigned char agc_out_on[] = { 0x02, 0x00 };
157 unsigned char gainset_off[] = { 0x28, 0x14 };
158 unsigned char if_agc_spd[] = { 0x0f, 0x88 };
159 unsigned char adc_head_6[] = { 0x05, 0x04 };
160 unsigned char adc_head_9[] = { 0x05, 0x02 };
161 unsigned char adc_head_12[] = { 0x05, 0x01 };
162 unsigned char pll_bw_nom[] = { 0x0d, 0x47 };
163 unsigned char pll_bw_low[] = { 0x0d, 0x27 };
164 unsigned char gainset_2[] = { 0x28, 0x64 };
165 unsigned char agc_rst_on[] = { 0x0e, 0x0b };
166 unsigned char agc_rst_off[] = { 0x0e, 0x09 };
167 unsigned char if_agc_set[] = { 0x0f, 0x81 };
168 unsigned char addr_adc_sat = 0x1a;
169 unsigned char addr_agc_stat = 0x1d;
170 unsigned char addr_pll_stat = 0x1b;
171 unsigned char adc_sat, agc_stat,
175 set_audio(fe, params);
177 if (priv->cfg.config)
178 tuner_dbg("tda827xa config is 0x%02x\n", *priv->cfg.config);
179 tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2);
180 tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2);
181 tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2);
184 expert_mode[1] = priv->tda8290_easy_mode + 0x80;
185 tuner_i2c_xfer_send(&priv->i2c_props, expert_mode, 2);
186 tuner_i2c_xfer_send(&priv->i2c_props, gainset_off, 2);
187 tuner_i2c_xfer_send(&priv->i2c_props, if_agc_spd, 2);
188 if (priv->tda8290_easy_mode & 0x60)
189 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_9, 2);
191 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2);
192 tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2);
194 tda8290_i2c_bridge(fe, 1);
196 if (fe->ops.tuner_ops.set_analog_params)
197 fe->ops.tuner_ops.set_analog_params(fe, params);
199 for (i = 0; i < 3; i++) {
200 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
201 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1);
202 if (pll_stat & 0x80) {
203 tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1);
204 tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1);
205 tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1);
206 tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1);
207 tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat);
210 tuner_dbg("tda8290 not locked, no signal?\n");
214 /* adjust headroom resp. gain */
215 if ((agc_stat > 115) || (!(pll_stat & 0x80) && (adc_sat < 20))) {
216 tuner_dbg("adjust gain, step 1. Agc: %d, ADC stat: %d, lock: %d\n",
217 agc_stat, adc_sat, pll_stat & 0x80);
218 tuner_i2c_xfer_send(&priv->i2c_props, gainset_2, 2);
220 tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1);
221 tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1);
222 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
223 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1);
224 if ((agc_stat > 115) || !(pll_stat & 0x80)) {
225 tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n",
226 agc_stat, pll_stat & 0x80);
230 tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1);
231 tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1);
232 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
233 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1);
234 if((agc_stat > 115) || !(pll_stat & 0x80)) {
235 tuner_dbg("adjust gain, step 3. Agc: %d\n", agc_stat);
236 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_12, 2);
237 tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_low, 2);
243 /* l/ l' deadlock? */
244 if(priv->tda8290_easy_mode & 0x60) {
245 tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1);
246 tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1);
247 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
248 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1);
249 if ((adc_sat > 20) || !(pll_stat & 0x80)) {
250 tuner_dbg("trying to resolve SECAM L deadlock\n");
251 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_on, 2);
253 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_off, 2);
257 tda8290_i2c_bridge(fe, 0);
258 tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2);
261 /*---------------------------------------------------------------------*/
263 static void tda8295_power(struct dvb_frontend *fe, int enable)
265 struct tda8290_priv *priv = fe->analog_demod_priv;
266 unsigned char buf[] = { 0x30, 0x00 }; /* clb_stdbt */
268 tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1);
269 tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1);
276 tuner_i2c_xfer_send(&priv->i2c_props, buf, 2);
279 static void tda8295_set_easy_mode(struct dvb_frontend *fe, int enable)
281 struct tda8290_priv *priv = fe->analog_demod_priv;
282 unsigned char buf[] = { 0x01, 0x00 };
284 tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1);
285 tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1);
288 buf[1] = 0x01; /* rising edge sets regs 0x02 - 0x23 */
290 buf[1] = 0x00; /* reset active bit */
292 tuner_i2c_xfer_send(&priv->i2c_props, buf, 2);
295 static void tda8295_set_video_std(struct dvb_frontend *fe)
297 struct tda8290_priv *priv = fe->analog_demod_priv;
298 unsigned char buf[] = { 0x00, priv->tda8290_easy_mode };
300 tuner_i2c_xfer_send(&priv->i2c_props, buf, 2);
302 tda8295_set_easy_mode(fe, 1);
304 tda8295_set_easy_mode(fe, 0);
307 /*---------------------------------------------------------------------*/
309 static void tda8295_agc1_out(struct dvb_frontend *fe, int enable)
311 struct tda8290_priv *priv = fe->analog_demod_priv;
312 unsigned char buf[] = { 0x02, 0x00 }; /* DIV_FUNC */
314 tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1);
315 tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1);
322 tuner_i2c_xfer_send(&priv->i2c_props, buf, 2);
325 static void tda8295_agc2_out(struct dvb_frontend *fe, int enable)
327 struct tda8290_priv *priv = fe->analog_demod_priv;
328 unsigned char set_gpio_cf[] = { 0x44, 0x00 };
329 unsigned char set_gpio_val[] = { 0x46, 0x00 };
331 tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_cf[0], 1);
332 tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_cf[1], 1);
333 tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_val[0], 1);
334 tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_val[1], 1);
336 set_gpio_cf[1] &= 0xf0; /* clear GPIO_0 bits 3-0 */
339 set_gpio_cf[1] |= 0x01; /* config GPIO_0 as Open Drain Out */
340 set_gpio_val[1] &= 0xfe; /* set GPIO_0 pin low */
342 tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_cf, 2);
343 tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_val, 2);
346 static int tda8295_has_signal(struct dvb_frontend *fe)
348 struct tda8290_priv *priv = fe->analog_demod_priv;
350 unsigned char hvpll_stat = 0x26;
353 tuner_i2c_xfer_send(&priv->i2c_props, &hvpll_stat, 1);
354 tuner_i2c_xfer_recv(&priv->i2c_props, &ret, 1);
355 return (ret & 0x01) ? 65535 : 0;
358 /*---------------------------------------------------------------------*/
360 static void tda8295_set_params(struct dvb_frontend *fe,
361 struct analog_parameters *params)
363 struct tda8290_priv *priv = fe->analog_demod_priv;
365 unsigned char blanking_mode[] = { 0x1d, 0x00 };
367 set_audio(fe, params);
369 tuner_dbg("%s: freq = %d\n", __FUNCTION__, params->frequency);
371 tda8295_power(fe, 1);
372 tda8295_agc1_out(fe, 1);
374 tuner_i2c_xfer_send(&priv->i2c_props, &blanking_mode[0], 1);
375 tuner_i2c_xfer_recv(&priv->i2c_props, &blanking_mode[1], 1);
377 tda8295_set_video_std(fe);
379 blanking_mode[1] = 0x03;
380 tuner_i2c_xfer_send(&priv->i2c_props, blanking_mode, 2);
383 tda8295_i2c_bridge(fe, 1);
385 if (fe->ops.tuner_ops.set_analog_params)
386 fe->ops.tuner_ops.set_analog_params(fe, params);
391 if (tda8295_has_signal(fe))
392 tuner_dbg("tda8295 is locked\n");
394 tuner_dbg("tda8295 not locked, no signal?\n");
396 tda8295_i2c_bridge(fe, 0);
399 /*---------------------------------------------------------------------*/
401 static int tda8290_has_signal(struct dvb_frontend *fe)
403 struct tda8290_priv *priv = fe->analog_demod_priv;
405 unsigned char i2c_get_afc[1] = { 0x1B };
406 unsigned char afc = 0;
408 tuner_i2c_xfer_send(&priv->i2c_props, i2c_get_afc, ARRAY_SIZE(i2c_get_afc));
409 tuner_i2c_xfer_recv(&priv->i2c_props, &afc, 1);
410 return (afc & 0x80)? 65535:0;
413 /*---------------------------------------------------------------------*/
415 static void tda8290_standby(struct dvb_frontend *fe)
417 struct tda8290_priv *priv = fe->analog_demod_priv;
419 unsigned char cb1[] = { 0x30, 0xD0 };
420 unsigned char tda8290_standby[] = { 0x00, 0x02 };
421 unsigned char tda8290_agc_tri[] = { 0x02, 0x20 };
422 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2};
424 tda8290_i2c_bridge(fe, 1);
425 if (priv->ver & TDA8275A)
427 i2c_transfer(priv->i2c_props.adap, &msg, 1);
428 tda8290_i2c_bridge(fe, 0);
429 tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2);
430 tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2);
433 static void tda8295_standby(struct dvb_frontend *fe)
435 tda8295_agc1_out(fe, 0); /* Put AGC in tri-state */
437 tda8295_power(fe, 0);
440 static void tda8290_init_if(struct dvb_frontend *fe)
442 struct tda8290_priv *priv = fe->analog_demod_priv;
444 unsigned char set_VS[] = { 0x30, 0x6F };
445 unsigned char set_GP00_CF[] = { 0x20, 0x01 };
446 unsigned char set_GP01_CF[] = { 0x20, 0x0B };
448 if ((priv->cfg.config) &&
449 ((*priv->cfg.config == 1) || (*priv->cfg.config == 2)))
450 tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2);
452 tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2);
453 tuner_i2c_xfer_send(&priv->i2c_props, set_VS, 2);
456 static void tda8295_init_if(struct dvb_frontend *fe)
458 struct tda8290_priv *priv = fe->analog_demod_priv;
460 static unsigned char set_adc_ctl[] = { 0x33, 0x14 };
461 static unsigned char set_adc_ctl2[] = { 0x34, 0x00 };
462 static unsigned char set_pll_reg6[] = { 0x3e, 0x63 };
463 static unsigned char set_pll_reg0[] = { 0x38, 0x23 };
464 static unsigned char set_pll_reg7[] = { 0x3f, 0x01 };
465 static unsigned char set_pll_reg10[] = { 0x42, 0x61 };
466 static unsigned char set_gpio_reg0[] = { 0x44, 0x0b };
468 tda8295_power(fe, 1);
470 tda8295_set_easy_mode(fe, 0);
471 tda8295_set_video_std(fe);
473 tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl, 2);
474 tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl2, 2);
475 tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg6, 2);
476 tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg0, 2);
477 tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg7, 2);
478 tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg10, 2);
479 tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_reg0, 2);
481 tda8295_agc1_out(fe, 0);
482 tda8295_agc2_out(fe, 0);
485 static void tda8290_init_tuner(struct dvb_frontend *fe)
487 struct tda8290_priv *priv = fe->analog_demod_priv;
488 unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf,
489 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 };
490 unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b,
491 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b };
492 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0,
493 .buf=tda8275_init, .len = 14};
494 if (priv->ver & TDA8275A)
495 msg.buf = tda8275a_init;
497 tda8290_i2c_bridge(fe, 1);
498 i2c_transfer(priv->i2c_props.adap, &msg, 1);
499 tda8290_i2c_bridge(fe, 0);
502 /*---------------------------------------------------------------------*/
504 static void tda829x_release(struct dvb_frontend *fe)
506 if (fe->ops.tuner_ops.release)
507 fe->ops.tuner_ops.release(fe);
509 kfree(fe->analog_demod_priv);
510 fe->analog_demod_priv = NULL;
513 static int tda829x_find_tuner(struct dvb_frontend *fe)
515 struct tda8290_priv *priv = fe->analog_demod_priv;
516 struct analog_tuner_ops *ops = fe->ops.analog_demod_ops;
517 int i, ret, tuners_found;
520 struct i2c_msg msg = { .flags = I2C_M_RD, .buf = &data, .len = 1 };
525 ops->i2c_gate_ctrl(fe, 1);
527 /* probe for tuner chip */
530 for (i = 0x60; i <= 0x63; i++) {
532 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
535 tuner_addrs = (tuner_addrs << 8) + i;
538 /* if there is more than one tuner, we expect the right one is
539 behind the bridge and we choose the highest address that doesn't
543 ops->i2c_gate_ctrl(fe, 0);
545 if (tuners_found > 1)
546 for (i = 0; i < tuners_found; i++) {
547 msg.addr = tuner_addrs & 0xff;
548 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
550 tuner_addrs = tuner_addrs >> 8;
555 if (tuner_addrs == 0) {
557 tuner_info("could not clearly identify tuner address, "
558 "defaulting to %x\n", tuner_addrs);
560 tuner_addrs = tuner_addrs & 0xff;
561 tuner_info("setting tuner address to %x\n", tuner_addrs);
563 priv->tda827x_addr = tuner_addrs;
564 msg.addr = tuner_addrs;
566 ops->i2c_gate_ctrl(fe, 1);
567 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
570 tuner_warn("tuner access failed!\n");
575 priv->ver |= TDA18271;
576 tda18271_attach(fe, priv->tda827x_addr,
577 priv->i2c_props.adap);
579 if ((data & 0x3c) == 0)
580 priv->ver |= TDA8275;
582 priv->ver |= TDA8275A;
584 tda827x_attach(fe, priv->tda827x_addr,
585 priv->i2c_props.adap, &priv->cfg);
587 if (fe->ops.tuner_ops.init)
588 fe->ops.tuner_ops.init(fe);
590 if (fe->ops.tuner_ops.sleep)
591 fe->ops.tuner_ops.sleep(fe);
593 ops->i2c_gate_ctrl(fe, 0);
598 static int tda8290_probe(struct tuner_i2c_props *i2c_props)
600 #define TDA8290_ID 0x89
601 unsigned char tda8290_id[] = { 0x1f, 0x00 };
604 tuner_i2c_xfer_send(i2c_props, &tda8290_id[0], 1);
605 tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1);
607 if (tda8290_id[1] == TDA8290_ID) {
609 printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n",
610 __FUNCTION__, i2c_adapter_id(i2c_props->adap),
618 static int tda8295_probe(struct tuner_i2c_props *i2c_props)
620 #define TDA8295_ID 0x8a
621 unsigned char tda8295_id[] = { 0x2f, 0x00 };
624 tuner_i2c_xfer_send(i2c_props, &tda8295_id[0], 1);
625 tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1);
627 if (tda8295_id[1] == TDA8295_ID) {
629 printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n",
630 __FUNCTION__, i2c_adapter_id(i2c_props->adap),
638 static struct analog_tuner_ops tda8290_tuner_ops = {
642 .set_params = tda8290_set_params,
643 .has_signal = tda8290_has_signal,
644 .standby = tda8290_standby,
645 .release = tda829x_release,
646 .i2c_gate_ctrl = tda8290_i2c_bridge,
649 static struct analog_tuner_ops tda8295_tuner_ops = {
653 .set_params = tda8295_set_params,
654 .has_signal = tda8295_has_signal,
655 .standby = tda8295_standby,
656 .release = tda829x_release,
657 .i2c_gate_ctrl = tda8295_i2c_bridge,
660 struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
661 struct i2c_adapter *i2c_adap, u8 i2c_addr,
662 struct tda829x_config *cfg)
664 struct tda8290_priv *priv = NULL;
667 priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL);
670 fe->analog_demod_priv = priv;
672 priv->i2c_props.addr = i2c_addr;
673 priv->i2c_props.adap = i2c_adap;
675 priv->cfg.config = cfg->lna_cfg;
676 priv->cfg.tuner_callback = cfg->tuner_callback;
679 if (tda8290_probe(&priv->i2c_props) == 0) {
681 fe->ops.analog_demod_ops = &tda8290_tuner_ops;
684 if (tda8295_probe(&priv->i2c_props) == 0) {
686 fe->ops.analog_demod_ops = &tda8295_tuner_ops;
689 if (tda829x_find_tuner(fe) < 0)
693 case TDA8290 | TDA8275:
696 case TDA8295 | TDA8275:
699 case TDA8290 | TDA8275A:
700 name = "tda8290+75a";
702 case TDA8295 | TDA8275A:
703 name = "tda8295+75a";
705 case TDA8290 | TDA18271:
706 name = "tda8290+18271";
708 case TDA8295 | TDA18271:
709 name = "tda8295+18271";
714 tuner_info("type set to %s\n", name);
716 if (priv->ver & TDA8290) {
717 tda8290_init_tuner(fe);
719 } else if (priv->ver & TDA8295)
726 fe->ops.analog_demod_ops = NULL;
729 EXPORT_SYMBOL_GPL(tda829x_attach);
731 int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr)
733 struct tuner_i2c_props i2c_props = {
738 unsigned char soft_reset[] = { 0x00, 0x00 };
739 unsigned char easy_mode_b[] = { 0x01, 0x02 };
740 unsigned char easy_mode_g[] = { 0x01, 0x04 };
741 unsigned char restore_9886[] = { 0x00, 0xd6, 0x30 };
742 unsigned char addr_dto_lsb = 0x07;
744 #define PROBE_BUFFER_SIZE 8
745 unsigned char buf[PROBE_BUFFER_SIZE];
748 /* rule out tda9887, which would return the same byte repeatedly */
749 tuner_i2c_xfer_send(&i2c_props, soft_reset, 1);
750 tuner_i2c_xfer_recv(&i2c_props, buf, PROBE_BUFFER_SIZE);
751 for (i = 1; i < PROBE_BUFFER_SIZE; i++) {
752 if (buf[i] != buf[0])
756 /* all bytes are equal, not a tda829x - probably a tda9887 */
757 if (i == PROBE_BUFFER_SIZE)
760 if ((tda8290_probe(&i2c_props) == 0) ||
761 (tda8295_probe(&i2c_props) == 0))
764 /* fall back to old probing method */
765 tuner_i2c_xfer_send(&i2c_props, easy_mode_b, 2);
766 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2);
767 tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1);
768 tuner_i2c_xfer_recv(&i2c_props, &data, 1);
770 tuner_i2c_xfer_send(&i2c_props, easy_mode_g, 2);
771 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2);
772 tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1);
773 tuner_i2c_xfer_recv(&i2c_props, &data, 1);
778 tuner_i2c_xfer_send(&i2c_props, restore_9886, 3);
781 EXPORT_SYMBOL_GPL(tda829x_probe);
783 MODULE_DESCRIPTION("Philips/NXP TDA8290/TDA8295 analog IF demodulator driver");
784 MODULE_AUTHOR("Gerd Knorr, Hartmut Hackmann, Michael Krufky");
785 MODULE_LICENSE("GPL");
788 * Overrides for Emacs so that we follow Linus's tabbing style.
789 * ---------------------------------------------------------------------------