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
;
49 /*---------------------------------------------------------------------*/
51 static void tda8290_i2c_bridge(struct tuner
*t
, int close
)
53 struct tda8290_priv
*priv
= t
->priv
;
55 unsigned char enable
[2] = { 0x21, 0xC0 };
56 unsigned char disable
[2] = { 0x21, 0x00 };
60 tuner_i2c_xfer_send(&priv
->i2c_props
, msg
, 2);
61 /* let the bridge stabilize */
65 tuner_i2c_xfer_send(&priv
->i2c_props
, msg
, 2);
69 static void tda8295_i2c_bridge(struct tuner
*t
, int close
)
71 struct tda8290_priv
*priv
= t
->priv
;
73 unsigned char enable
[2] = { 0x45, 0xc1 };
74 unsigned char disable
[2] = { 0x46, 0x00 };
75 unsigned char buf
[3] = { 0x45, 0x01, 0x00 };
79 tuner_i2c_xfer_send(&priv
->i2c_props
, msg
, 2);
80 /* let the bridge stabilize */
84 tuner_i2c_xfer_send(&priv
->i2c_props
, msg
, 1);
85 tuner_i2c_xfer_recv(&priv
->i2c_props
, &msg
[1], 1);
89 tuner_i2c_xfer_send(&priv
->i2c_props
, buf
, 3);
93 tuner_i2c_xfer_send(&priv
->i2c_props
, msg
, 2);
97 /*---------------------------------------------------------------------*/
99 static void set_audio(struct tuner
*t
)
101 struct tda8290_priv
*priv
= t
->priv
;
104 priv
->cfg
.tda827x_lpsel
= 0;
105 if (t
->std
& V4L2_STD_MN
) {
107 priv
->tda8290_easy_mode
= 0x01;
108 priv
->cfg
.tda827x_lpsel
= 1;
110 } else if (t
->std
& V4L2_STD_B
) {
111 priv
->cfg
.sgIF
= 108;
112 priv
->tda8290_easy_mode
= 0x02;
114 } else if (t
->std
& V4L2_STD_GH
) {
115 priv
->cfg
.sgIF
= 124;
116 priv
->tda8290_easy_mode
= 0x04;
118 } else if (t
->std
& V4L2_STD_PAL_I
) {
119 priv
->cfg
.sgIF
= 124;
120 priv
->tda8290_easy_mode
= 0x08;
122 } else if (t
->std
& V4L2_STD_DK
) {
123 priv
->cfg
.sgIF
= 124;
124 priv
->tda8290_easy_mode
= 0x10;
126 } else if (t
->std
& V4L2_STD_SECAM_L
) {
127 priv
->cfg
.sgIF
= 124;
128 priv
->tda8290_easy_mode
= 0x20;
130 } else if (t
->std
& V4L2_STD_SECAM_LC
) {
132 priv
->tda8290_easy_mode
= 0x40;
135 priv
->cfg
.sgIF
= 124;
136 priv
->tda8290_easy_mode
= 0x10;
140 if (t
->mode
== V4L2_TUNER_RADIO
)
141 priv
->cfg
.sgIF
= 88; /* if frequency is 5.5 MHz */
143 tuner_dbg("setting tda8290 to system %s\n", mode
);
146 static void tda8290_set_freq(struct tuner
*t
, unsigned int freq
)
148 struct tda8290_priv
*priv
= t
->priv
;
149 unsigned char soft_reset
[] = { 0x00, 0x00 };
150 unsigned char easy_mode
[] = { 0x01, priv
->tda8290_easy_mode
};
151 unsigned char expert_mode
[] = { 0x01, 0x80 };
152 unsigned char agc_out_on
[] = { 0x02, 0x00 };
153 unsigned char gainset_off
[] = { 0x28, 0x14 };
154 unsigned char if_agc_spd
[] = { 0x0f, 0x88 };
155 unsigned char adc_head_6
[] = { 0x05, 0x04 };
156 unsigned char adc_head_9
[] = { 0x05, 0x02 };
157 unsigned char adc_head_12
[] = { 0x05, 0x01 };
158 unsigned char pll_bw_nom
[] = { 0x0d, 0x47 };
159 unsigned char pll_bw_low
[] = { 0x0d, 0x27 };
160 unsigned char gainset_2
[] = { 0x28, 0x64 };
161 unsigned char agc_rst_on
[] = { 0x0e, 0x0b };
162 unsigned char agc_rst_off
[] = { 0x0e, 0x09 };
163 unsigned char if_agc_set
[] = { 0x0f, 0x81 };
164 unsigned char addr_adc_sat
= 0x1a;
165 unsigned char addr_agc_stat
= 0x1d;
166 unsigned char addr_pll_stat
= 0x1b;
167 unsigned char adc_sat
, agc_stat
,
171 struct analog_parameters params
= {
174 .audmode
= t
->audmode
,
180 tuner_dbg("tda827xa config is 0x%02x\n", t
->config
);
181 tuner_i2c_xfer_send(&priv
->i2c_props
, easy_mode
, 2);
182 tuner_i2c_xfer_send(&priv
->i2c_props
, agc_out_on
, 2);
183 tuner_i2c_xfer_send(&priv
->i2c_props
, soft_reset
, 2);
186 expert_mode
[1] = priv
->tda8290_easy_mode
+ 0x80;
187 tuner_i2c_xfer_send(&priv
->i2c_props
, expert_mode
, 2);
188 tuner_i2c_xfer_send(&priv
->i2c_props
, gainset_off
, 2);
189 tuner_i2c_xfer_send(&priv
->i2c_props
, if_agc_spd
, 2);
190 if (priv
->tda8290_easy_mode
& 0x60)
191 tuner_i2c_xfer_send(&priv
->i2c_props
, adc_head_9
, 2);
193 tuner_i2c_xfer_send(&priv
->i2c_props
, adc_head_6
, 2);
194 tuner_i2c_xfer_send(&priv
->i2c_props
, pll_bw_nom
, 2);
196 tda8290_i2c_bridge(t
, 1);
198 if (t
->fe
.ops
.tuner_ops
.set_analog_params
)
199 t
->fe
.ops
.tuner_ops
.set_analog_params(&t
->fe
, ¶ms
);
201 for (i
= 0; i
< 3; i
++) {
202 tuner_i2c_xfer_send(&priv
->i2c_props
, &addr_pll_stat
, 1);
203 tuner_i2c_xfer_recv(&priv
->i2c_props
, &pll_stat
, 1);
204 if (pll_stat
& 0x80) {
205 tuner_i2c_xfer_send(&priv
->i2c_props
, &addr_adc_sat
, 1);
206 tuner_i2c_xfer_recv(&priv
->i2c_props
, &adc_sat
, 1);
207 tuner_i2c_xfer_send(&priv
->i2c_props
, &addr_agc_stat
, 1);
208 tuner_i2c_xfer_recv(&priv
->i2c_props
, &agc_stat
, 1);
209 tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat
);
212 tuner_dbg("tda8290 not locked, no signal?\n");
216 /* adjust headroom resp. gain */
217 if ((agc_stat
> 115) || (!(pll_stat
& 0x80) && (adc_sat
< 20))) {
218 tuner_dbg("adjust gain, step 1. Agc: %d, ADC stat: %d, lock: %d\n",
219 agc_stat
, adc_sat
, pll_stat
& 0x80);
220 tuner_i2c_xfer_send(&priv
->i2c_props
, gainset_2
, 2);
222 tuner_i2c_xfer_send(&priv
->i2c_props
, &addr_agc_stat
, 1);
223 tuner_i2c_xfer_recv(&priv
->i2c_props
, &agc_stat
, 1);
224 tuner_i2c_xfer_send(&priv
->i2c_props
, &addr_pll_stat
, 1);
225 tuner_i2c_xfer_recv(&priv
->i2c_props
, &pll_stat
, 1);
226 if ((agc_stat
> 115) || !(pll_stat
& 0x80)) {
227 tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n",
228 agc_stat
, pll_stat
& 0x80);
230 priv
->cfg
.agcf(&t
->fe
);
232 tuner_i2c_xfer_send(&priv
->i2c_props
, &addr_agc_stat
, 1);
233 tuner_i2c_xfer_recv(&priv
->i2c_props
, &agc_stat
, 1);
234 tuner_i2c_xfer_send(&priv
->i2c_props
, &addr_pll_stat
, 1);
235 tuner_i2c_xfer_recv(&priv
->i2c_props
, &pll_stat
, 1);
236 if((agc_stat
> 115) || !(pll_stat
& 0x80)) {
237 tuner_dbg("adjust gain, step 3. Agc: %d\n", agc_stat
);
238 tuner_i2c_xfer_send(&priv
->i2c_props
, adc_head_12
, 2);
239 tuner_i2c_xfer_send(&priv
->i2c_props
, pll_bw_low
, 2);
245 /* l/ l' deadlock? */
246 if(priv
->tda8290_easy_mode
& 0x60) {
247 tuner_i2c_xfer_send(&priv
->i2c_props
, &addr_adc_sat
, 1);
248 tuner_i2c_xfer_recv(&priv
->i2c_props
, &adc_sat
, 1);
249 tuner_i2c_xfer_send(&priv
->i2c_props
, &addr_pll_stat
, 1);
250 tuner_i2c_xfer_recv(&priv
->i2c_props
, &pll_stat
, 1);
251 if ((adc_sat
> 20) || !(pll_stat
& 0x80)) {
252 tuner_dbg("trying to resolve SECAM L deadlock\n");
253 tuner_i2c_xfer_send(&priv
->i2c_props
, agc_rst_on
, 2);
255 tuner_i2c_xfer_send(&priv
->i2c_props
, agc_rst_off
, 2);
259 tda8290_i2c_bridge(t
, 0);
260 tuner_i2c_xfer_send(&priv
->i2c_props
, if_agc_set
, 2);
263 /*---------------------------------------------------------------------*/
265 static void tda8295_power(struct tuner
*t
, int enable
)
267 struct tda8290_priv
*priv
= t
->priv
;
268 unsigned char buf
[] = { 0x30, 0x00 }; /* clb_stdbt */
270 tuner_i2c_xfer_send(&priv
->i2c_props
, &buf
[0], 1);
271 tuner_i2c_xfer_recv(&priv
->i2c_props
, &buf
[1], 1);
278 tuner_i2c_xfer_send(&priv
->i2c_props
, buf
, 2);
281 static void tda8295_set_easy_mode(struct tuner
*t
, int enable
)
283 struct tda8290_priv
*priv
= t
->priv
;
284 unsigned char buf
[] = { 0x01, 0x00 };
286 tuner_i2c_xfer_send(&priv
->i2c_props
, &buf
[0], 1);
287 tuner_i2c_xfer_recv(&priv
->i2c_props
, &buf
[1], 1);
290 buf
[1] = 0x01; /* rising edge sets regs 0x02 - 0x23 */
292 buf
[1] = 0x00; /* reset active bit */
294 tuner_i2c_xfer_send(&priv
->i2c_props
, buf
, 2);
297 static void tda8295_set_video_std(struct tuner
*t
)
299 struct tda8290_priv
*priv
= t
->priv
;
300 unsigned char buf
[] = { 0x00, priv
->tda8290_easy_mode
};
302 tuner_i2c_xfer_send(&priv
->i2c_props
, buf
, 2);
304 tda8295_set_easy_mode(t
, 1);
306 tda8295_set_easy_mode(t
, 0);
309 /*---------------------------------------------------------------------*/
311 static void tda8295_agc1_out(struct tuner
*t
, int enable
)
313 struct tda8290_priv
*priv
= t
->priv
;
314 unsigned char buf
[] = { 0x02, 0x00 }; /* DIV_FUNC */
316 tuner_i2c_xfer_send(&priv
->i2c_props
, &buf
[0], 1);
317 tuner_i2c_xfer_recv(&priv
->i2c_props
, &buf
[1], 1);
324 tuner_i2c_xfer_send(&priv
->i2c_props
, buf
, 2);
327 static void tda8295_agc2_out(struct tuner
*t
, int enable
)
329 struct tda8290_priv
*priv
= t
->priv
;
330 unsigned char set_gpio_cf
[] = { 0x44, 0x00 };
331 unsigned char set_gpio_val
[] = { 0x46, 0x00 };
333 tuner_i2c_xfer_send(&priv
->i2c_props
, &set_gpio_cf
[0], 1);
334 tuner_i2c_xfer_recv(&priv
->i2c_props
, &set_gpio_cf
[1], 1);
335 tuner_i2c_xfer_send(&priv
->i2c_props
, &set_gpio_val
[0], 1);
336 tuner_i2c_xfer_recv(&priv
->i2c_props
, &set_gpio_val
[1], 1);
338 set_gpio_cf
[1] &= 0xf0; /* clear GPIO_0 bits 3-0 */
341 set_gpio_cf
[1] |= 0x01; /* config GPIO_0 as Open Drain Out */
342 set_gpio_val
[1] &= 0xfe; /* set GPIO_0 pin low */
344 tuner_i2c_xfer_send(&priv
->i2c_props
, set_gpio_cf
, 2);
345 tuner_i2c_xfer_send(&priv
->i2c_props
, set_gpio_val
, 2);
348 static int tda8295_has_signal(struct tuner
*t
)
350 struct tda8290_priv
*priv
= t
->priv
;
352 unsigned char hvpll_stat
= 0x26;
355 tuner_i2c_xfer_send(&priv
->i2c_props
, &hvpll_stat
, 1);
356 tuner_i2c_xfer_recv(&priv
->i2c_props
, &ret
, 1);
357 return (ret
& 0x01) ? 65535 : 0;
360 /*---------------------------------------------------------------------*/
362 static void tda8295_set_freq(struct tuner
*t
, unsigned int freq
)
364 struct tda8290_priv
*priv
= t
->priv
;
367 unsigned char blanking_mode
[] = { 0x1d, 0x00 };
369 struct analog_parameters params
= {
372 .audmode
= t
->audmode
,
378 ifc
= priv
->cfg
.sgIF
; /* FIXME */
380 tuner_dbg("%s: ifc = %u, freq = %d\n", __FUNCTION__
, ifc
, freq
);
383 tda8295_agc1_out(t
, 1);
385 tuner_i2c_xfer_send(&priv
->i2c_props
, &blanking_mode
[0], 1);
386 tuner_i2c_xfer_recv(&priv
->i2c_props
, &blanking_mode
[1], 1);
388 tda8295_set_video_std(t
);
390 blanking_mode
[1] = 0x03;
391 tuner_i2c_xfer_send(&priv
->i2c_props
, blanking_mode
, 2);
394 tda8295_i2c_bridge(t
, 1);
396 if (t
->fe
.ops
.tuner_ops
.set_analog_params
)
397 t
->fe
.ops
.tuner_ops
.set_analog_params(&t
->fe
, ¶ms
);
400 priv
->cfg
.agcf(&t
->fe
);
402 if (tda8295_has_signal(t
))
403 tuner_dbg("tda8295 is locked\n");
405 tuner_dbg("tda8295 not locked, no signal?\n");
407 tda8295_i2c_bridge(t
, 0);
410 /*---------------------------------------------------------------------*/
412 static int tda8290_has_signal(struct tuner
*t
)
414 struct tda8290_priv
*priv
= t
->priv
;
416 unsigned char i2c_get_afc
[1] = { 0x1B };
417 unsigned char afc
= 0;
419 tuner_i2c_xfer_send(&priv
->i2c_props
, i2c_get_afc
, ARRAY_SIZE(i2c_get_afc
));
420 tuner_i2c_xfer_recv(&priv
->i2c_props
, &afc
, 1);
421 return (afc
& 0x80)? 65535:0;
424 /*---------------------------------------------------------------------*/
426 static void tda8290_standby(struct tuner
*t
)
428 struct tda8290_priv
*priv
= t
->priv
;
429 unsigned char cb1
[] = { 0x30, 0xD0 };
430 unsigned char tda8290_standby
[] = { 0x00, 0x02 };
431 unsigned char tda8290_agc_tri
[] = { 0x02, 0x20 };
432 struct i2c_msg msg
= {.addr
= priv
->tda827x_addr
, .flags
=0, .buf
=cb1
, .len
= 2};
434 tda8290_i2c_bridge(t
, 1);
435 if (priv
->tda827x_ver
!= 0)
437 i2c_transfer(priv
->i2c_props
.adap
, &msg
, 1);
438 tda8290_i2c_bridge(t
, 0);
439 tuner_i2c_xfer_send(&priv
->i2c_props
, tda8290_agc_tri
, 2);
440 tuner_i2c_xfer_send(&priv
->i2c_props
, tda8290_standby
, 2);
443 static void tda8295_standby(struct tuner
*t
)
445 tda8295_agc1_out(t
, 0); /* Put AGC in tri-state */
450 static void tda8290_init_if(struct tuner
*t
)
452 struct tda8290_priv
*priv
= t
->priv
;
454 unsigned char set_VS
[] = { 0x30, 0x6F };
455 unsigned char set_GP00_CF
[] = { 0x20, 0x01 };
456 unsigned char set_GP01_CF
[] = { 0x20, 0x0B };
458 if ((t
->config
== 1) || (t
->config
== 2))
459 tuner_i2c_xfer_send(&priv
->i2c_props
, set_GP00_CF
, 2);
461 tuner_i2c_xfer_send(&priv
->i2c_props
, set_GP01_CF
, 2);
462 tuner_i2c_xfer_send(&priv
->i2c_props
, set_VS
, 2);
465 static void tda8295_init_if(struct tuner
*t
)
467 struct tda8290_priv
*priv
= t
->priv
;
469 static unsigned char set_adc_ctl
[] = { 0x33, 0x14 };
470 static unsigned char set_adc_ctl2
[] = { 0x34, 0x00 };
471 static unsigned char set_pll_reg6
[] = { 0x3e, 0x63 };
472 static unsigned char set_pll_reg0
[] = { 0x38, 0x23 };
473 static unsigned char set_pll_reg7
[] = { 0x3f, 0x01 };
474 static unsigned char set_pll_reg10
[] = { 0x42, 0x61 };
475 static unsigned char set_gpio_reg0
[] = { 0x44, 0x0b };
479 tda8295_set_easy_mode(t
, 0);
480 tda8295_set_video_std(t
);
482 tuner_i2c_xfer_send(&priv
->i2c_props
, set_adc_ctl
, 2);
483 tuner_i2c_xfer_send(&priv
->i2c_props
, set_adc_ctl2
, 2);
484 tuner_i2c_xfer_send(&priv
->i2c_props
, set_pll_reg6
, 2);
485 tuner_i2c_xfer_send(&priv
->i2c_props
, set_pll_reg0
, 2);
486 tuner_i2c_xfer_send(&priv
->i2c_props
, set_pll_reg7
, 2);
487 tuner_i2c_xfer_send(&priv
->i2c_props
, set_pll_reg10
, 2);
488 tuner_i2c_xfer_send(&priv
->i2c_props
, set_gpio_reg0
, 2);
490 tda8295_agc1_out(t
, 0);
491 tda8295_agc2_out(t
, 0);
494 static void tda8290_init_tuner(struct tuner
*t
)
496 struct tda8290_priv
*priv
= t
->priv
;
497 unsigned char tda8275_init
[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf,
498 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 };
499 unsigned char tda8275a_init
[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b,
500 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b };
501 struct i2c_msg msg
= {.addr
= priv
->tda827x_addr
, .flags
=0,
502 .buf
=tda8275_init
, .len
= 14};
503 if (priv
->tda827x_ver
!= 0)
504 msg
.buf
= tda8275a_init
;
506 tda8290_i2c_bridge(t
, 1);
507 i2c_transfer(priv
->i2c_props
.adap
, &msg
, 1);
508 tda8290_i2c_bridge(t
, 0);
511 /*---------------------------------------------------------------------*/
513 static void tda829x_release(struct tuner
*t
)
515 if (t
->fe
.ops
.tuner_ops
.release
)
516 t
->fe
.ops
.tuner_ops
.release(&t
->fe
);
522 static struct tuner_operations tda8290_tuner_ops
= {
523 .set_tv_freq
= tda8290_set_freq
,
524 .set_radio_freq
= tda8290_set_freq
,
525 .has_signal
= tda8290_has_signal
,
526 .standby
= tda8290_standby
,
527 .release
= tda829x_release
,
530 static struct tuner_operations tda8295_tuner_ops
= {
531 .set_tv_freq
= tda8295_set_freq
,
532 .set_radio_freq
= tda8295_set_freq
,
533 .has_signal
= tda8295_has_signal
,
534 .standby
= tda8295_standby
,
535 .release
= tda829x_release
,
538 int tda8290_attach(struct tuner
*t
)
540 struct tda8290_priv
*priv
= NULL
;
542 int i
, ret
, tuners_found
;
544 struct i2c_msg msg
= {.flags
=I2C_M_RD
, .buf
=&data
, .len
= 1};
546 priv
= kzalloc(sizeof(struct tda8290_priv
), GFP_KERNEL
);
551 priv
->i2c_props
.addr
= t
->i2c
.addr
;
552 priv
->i2c_props
.adap
= t
->i2c
.adapter
;
553 priv
->cfg
.config
= &t
->config
;
554 priv
->cfg
.tuner_callback
= t
->tuner_callback
;
556 tda8290_i2c_bridge(t
, 1);
557 /* probe for tuner chip */
560 for (i
=0x60; i
<= 0x63; i
++) {
562 ret
= i2c_transfer(priv
->i2c_props
.adap
, &msg
, 1);
565 tuner_addrs
= (tuner_addrs
<< 8) + i
;
568 /* if there is more than one tuner, we expect the right one is
569 behind the bridge and we choose the highest address that doesn't
572 tda8290_i2c_bridge(t
, 0);
574 for (i
= 0; i
< tuners_found
; i
++) {
575 msg
.addr
= tuner_addrs
& 0xff;
576 ret
= i2c_transfer(priv
->i2c_props
.adap
, &msg
, 1);
578 tuner_addrs
= tuner_addrs
>> 8;
582 if (tuner_addrs
== 0) {
584 tuner_info("could not clearly identify tuner address, defaulting to %x\n",
587 tuner_addrs
= tuner_addrs
& 0xff;
588 tuner_info("setting tuner address to %x\n", tuner_addrs
);
590 priv
->tda827x_addr
= tuner_addrs
;
591 msg
.addr
= tuner_addrs
;
593 tda8290_i2c_bridge(t
, 1);
595 ret
= i2c_transfer(priv
->i2c_props
.adap
, &msg
, 1);
597 tuner_warn("TDA827x access failed!\n");
599 if ((data
& 0x3c) == 0) {
600 strlcpy(t
->i2c
.name
, "tda8290+75", sizeof(t
->i2c
.name
));
601 priv
->tda827x_ver
= 0;
603 strlcpy(t
->i2c
.name
, "tda8290+75a", sizeof(t
->i2c
.name
));
604 priv
->tda827x_ver
= 2;
606 tda827x_attach(&t
->fe
, priv
->tda827x_addr
,
607 priv
->i2c_props
.adap
, &priv
->cfg
);
609 /* FIXME: tda827x module doesn't probe the tuner until
610 * tda827x_initial_sleep is called
612 if (t
->fe
.ops
.tuner_ops
.sleep
)
613 t
->fe
.ops
.tuner_ops
.sleep(&t
->fe
);
615 memcpy(&t
->ops
, &tda8290_tuner_ops
, sizeof(struct tuner_operations
));
617 tuner_info("type set to %s\n", t
->i2c
.name
);
619 priv
->cfg
.tda827x_lpsel
= 0;
620 t
->mode
= V4L2_TUNER_ANALOG_TV
;
622 tda8290_init_tuner(t
);
626 EXPORT_SYMBOL_GPL(tda8290_attach
);
628 int tda8295_attach(struct tuner
*t
)
630 struct tda8290_priv
*priv
= NULL
;
632 int i
, ret
, tuners_found
;
634 struct i2c_msg msg
= { .flags
= I2C_M_RD
, .buf
= &data
, .len
= 1 };
636 priv
= kzalloc(sizeof(struct tda8290_priv
), GFP_KERNEL
);
641 priv
->i2c_props
.addr
= t
->i2c
.addr
;
642 priv
->i2c_props
.adap
= t
->i2c
.adapter
;
644 tda8295_i2c_bridge(t
, 1);
645 /* probe for tuner chip */
648 for (i
= 0x60; i
<= 0x63; i
++) {
650 ret
= i2c_transfer(priv
->i2c_props
.adap
, &msg
, 1);
653 tuner_addrs
= (tuner_addrs
<< 8) + i
;
656 /* if there is more than one tuner, we expect the right one is
657 behind the bridge and we choose the highest address that doesn't
660 tda8295_i2c_bridge(t
, 0);
661 if (tuners_found
> 1)
662 for (i
= 0; i
< tuners_found
; i
++) {
663 msg
.addr
= tuner_addrs
& 0xff;
664 ret
= i2c_transfer(priv
->i2c_props
.adap
, &msg
, 1);
666 tuner_addrs
= tuner_addrs
>> 8;
670 if (tuner_addrs
== 0) {
672 tuner_info("could not clearly identify tuner address, "
673 "defaulting to %x\n", tuner_addrs
);
675 tuner_addrs
= tuner_addrs
& 0xff;
676 tuner_info("setting tuner address to %x\n", tuner_addrs
);
678 priv
->tda827x_addr
= tuner_addrs
;
679 msg
.addr
= tuner_addrs
;
681 tda8295_i2c_bridge(t
, 1);
682 ret
= i2c_transfer(priv
->i2c_props
.adap
, &msg
, 1);
683 tda8295_i2c_bridge(t
, 0);
685 tuner_warn("TDA827x access failed!\n");
686 if ((data
& 0x3c) == 0) {
687 strlcpy(t
->i2c
.name
, "tda8295+18271", sizeof(t
->i2c
.name
));
688 tda18271_attach(&t
->fe
, priv
->tda827x_addr
,
689 priv
->i2c_props
.adap
);
690 priv
->tda827x_ver
= 4;
692 strlcpy(t
->i2c
.name
, "tda8295+75a", sizeof(t
->i2c
.name
));
693 tda827x_attach(&t
->fe
, priv
->tda827x_addr
,
694 priv
->i2c_props
.adap
, &priv
->cfg
);
696 /* FIXME: tda827x module doesn't probe the tuner until
697 * tda827x_initial_sleep is called
699 if (t
->fe
.ops
.tuner_ops
.sleep
)
700 t
->fe
.ops
.tuner_ops
.sleep(&t
->fe
);
701 priv
->tda827x_ver
= 2;
703 priv
->tda827x_ver
|= 1; /* signifies 8295 vs 8290 */
704 tuner_info("type set to %s\n", t
->i2c
.name
);
706 memcpy(&t
->ops
, &tda8295_tuner_ops
, sizeof(struct tuner_operations
));
708 priv
->cfg
.tda827x_lpsel
= 0;
709 t
->mode
= V4L2_TUNER_ANALOG_TV
;
714 EXPORT_SYMBOL_GPL(tda8295_attach
);
716 int tda8290_probe(struct tuner
*t
)
718 struct tuner_i2c_props i2c_props
= {
719 .adap
= t
->i2c
.adapter
,
723 unsigned char soft_reset
[] = { 0x00, 0x00 };
724 unsigned char easy_mode_b
[] = { 0x01, 0x02 };
725 unsigned char easy_mode_g
[] = { 0x01, 0x04 };
726 unsigned char restore_9886
[] = { 0x00, 0xd6, 0x30 };
727 unsigned char addr_dto_lsb
= 0x07;
730 tuner_i2c_xfer_send(&i2c_props
, easy_mode_b
, 2);
731 tuner_i2c_xfer_send(&i2c_props
, soft_reset
, 2);
732 tuner_i2c_xfer_send(&i2c_props
, &addr_dto_lsb
, 1);
733 tuner_i2c_xfer_recv(&i2c_props
, &data
, 1);
735 tuner_i2c_xfer_send(&i2c_props
, easy_mode_g
, 2);
736 tuner_i2c_xfer_send(&i2c_props
, soft_reset
, 2);
737 tuner_i2c_xfer_send(&i2c_props
, &addr_dto_lsb
, 1);
738 tuner_i2c_xfer_recv(&i2c_props
, &data
, 1);
743 tuner_i2c_xfer_send(&i2c_props
, restore_9886
, 3);
746 EXPORT_SYMBOL_GPL(tda8290_probe
);
748 MODULE_DESCRIPTION("Philips TDA8290 + TDA8275 / TDA8275a tuner driver");
749 MODULE_AUTHOR("Gerd Knorr, Hartmut Hackmann, Michael Krufky");
750 MODULE_LICENSE("GPL");
753 * Overrides for Emacs so that we follow Linus's tabbing style.
754 * ---------------------------------------------------------------------------