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.
21 #include <linux/i2c.h>
22 #include <linux/videodev.h>
23 #include <linux/delay.h>
24 #include <media/tuner.h>
26 /* ---------------------------------------------------------------------- */
38 /* Note lomax entry is lo / 62500 */
40 static struct tda827x_data tda827x_analog
[] = {
41 { .lomax
= 992, .spd
= 3, .bs
= 2, .bp
= 0, .cp
= 0, .gc3
= 3, .div1p5
= 1}, /* 62 MHz */
42 { .lomax
= 1056, .spd
= 3, .bs
= 3, .bp
= 0, .cp
= 0, .gc3
= 3, .div1p5
= 1}, /* 66 MHz */
43 { .lomax
= 1216, .spd
= 3, .bs
= 1, .bp
= 0, .cp
= 0, .gc3
= 3, .div1p5
= 0}, /* 76 MHz */
44 { .lomax
= 1344, .spd
= 3, .bs
= 2, .bp
= 0, .cp
= 0, .gc3
= 3, .div1p5
= 0}, /* 84 MHz */
45 { .lomax
= 1488, .spd
= 3, .bs
= 2, .bp
= 0, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 93 MHz */
46 { .lomax
= 1568, .spd
= 3, .bs
= 3, .bp
= 0, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 98 MHz */
47 { .lomax
= 1744, .spd
= 3, .bs
= 3, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 109 MHz */
48 { .lomax
= 1968, .spd
= 2, .bs
= 2, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 1}, /* 123 MHz */
49 { .lomax
= 2128, .spd
= 2, .bs
= 3, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 1}, /* 133 MHz */
50 { .lomax
= 2416, .spd
= 2, .bs
= 1, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 151 MHz */
51 { .lomax
= 2464, .spd
= 2, .bs
= 2, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 154 MHz */
52 { .lomax
= 2896, .spd
= 2, .bs
= 2, .bp
= 1, .cp
= 0, .gc3
= 0, .div1p5
= 0}, /* 181 MHz */
53 { .lomax
= 2960, .spd
= 2, .bs
= 2, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 185 MHz */
54 { .lomax
= 3472, .spd
= 2, .bs
= 3, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 217 MHz */
55 { .lomax
= 3904, .spd
= 1, .bs
= 2, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 1}, /* 244 MHz */
56 { .lomax
= 4240, .spd
= 1, .bs
= 3, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 1}, /* 265 MHz */
57 { .lomax
= 4832, .spd
= 1, .bs
= 1, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 302 MHz */
58 { .lomax
= 5184, .spd
= 1, .bs
= 2, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 324 MHz */
59 { .lomax
= 5920, .spd
= 1, .bs
= 2, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 370 MHz */
60 { .lomax
= 7264, .spd
= 1, .bs
= 3, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 454 MHz */
61 { .lomax
= 7888, .spd
= 0, .bs
= 2, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 1}, /* 493 MHz */
62 { .lomax
= 8480, .spd
= 0, .bs
= 3, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 1}, /* 530 MHz */
63 { .lomax
= 8864, .spd
= 0, .bs
= 1, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 0}, /* 554 MHz */
64 { .lomax
= 9664, .spd
= 0, .bs
= 1, .bp
= 4, .cp
= 0, .gc3
= 0, .div1p5
= 0}, /* 604 MHz */
65 { .lomax
= 11088, .spd
= 0, .bs
= 2, .bp
= 4, .cp
= 0, .gc3
= 0, .div1p5
= 0}, /* 696 MHz */
66 { .lomax
= 11840, .spd
= 0, .bs
= 2, .bp
= 4, .cp
= 1, .gc3
= 0, .div1p5
= 0}, /* 740 MHz */
67 { .lomax
= 13120, .spd
= 0, .bs
= 3, .bp
= 4, .cp
= 0, .gc3
= 0, .div1p5
= 0}, /* 820 MHz */
68 { .lomax
= 13840, .spd
= 0, .bs
= 3, .bp
= 4, .cp
= 1, .gc3
= 0, .div1p5
= 0}, /* 865 MHz */
69 { .lomax
= 0, .spd
= 0, .bs
= 0, .bp
= 0, .cp
= 0, .gc3
= 0, .div1p5
= 0} /* End */
72 static void tda827x_tune(struct i2c_client
*c
, u16 ifc
, unsigned int freq
)
74 unsigned char tuner_reg
[8];
75 unsigned char reg2
[2];
78 struct tuner
*t
= i2c_get_clientdata(c
);
79 struct i2c_msg msg
= {.addr
= t
->tda827x_addr
, .flags
= 0};
81 if (t
->mode
== V4L2_TUNER_RADIO
)
86 while (tda827x_analog
[i
].lomax
< N
) {
87 if(tda827x_analog
[i
+ 1].lomax
== 0)
92 N
= N
<< tda827x_analog
[i
].spd
;
95 tuner_reg
[1] = (unsigned char)(N
>>8);
96 tuner_reg
[2] = (unsigned char) N
;
98 tuner_reg
[4] = 0x52 + (t
->tda827x_lpsel
<< 5);
99 tuner_reg
[5] = (tda827x_analog
[i
].spd
<< 6) + (tda827x_analog
[i
].div1p5
<<5) +
100 (tda827x_analog
[i
].bs
<<3) + tda827x_analog
[i
].bp
;
101 tuner_reg
[6] = 0x8f + (tda827x_analog
[i
].gc3
<< 4);
106 i2c_transfer(c
->adapter
, &msg
, 1);
112 i2c_transfer(c
->adapter
, &msg
, 1);
116 i2c_transfer(c
->adapter
, &msg
, 1);
119 reg2
[1] = tuner_reg
[4] + 0x80;
120 i2c_transfer(c
->adapter
, &msg
, 1);
124 reg2
[1] = tuner_reg
[4] + 4;
125 i2c_transfer(c
->adapter
, &msg
, 1);
129 reg2
[1] = tuner_reg
[4];
130 i2c_transfer(c
->adapter
, &msg
, 1);
134 reg2
[1] = (tuner_reg
[4] & 0xfc) + tda827x_analog
[i
].cp
;
135 i2c_transfer(c
->adapter
, &msg
, 1);
139 i2c_transfer(c
->adapter
, &msg
, 1);
142 reg2
[1] = 0x08; // Vsync en
143 i2c_transfer(c
->adapter
, &msg
, 1);
146 static void tda827x_agcf(struct i2c_client
*c
)
148 struct tuner
*t
= i2c_get_clientdata(c
);
149 unsigned char data
[] = {0x80, 0x0c};
150 struct i2c_msg msg
= {.addr
= t
->tda827x_addr
, .buf
= data
,
151 .flags
= 0, .len
= 2};
152 i2c_transfer(c
->adapter
, &msg
, 1);
155 /* ---------------------------------------------------------------------- */
157 struct tda827xa_data
{
166 static struct tda827xa_data tda827xa_analog
[] = {
167 { .lomax
= 910, .svco
= 3, .spd
= 4, .scr
= 0, .sbs
= 0, .gc3
= 3}, /* 56.875 MHz */
168 { .lomax
= 1076, .svco
= 0, .spd
= 3, .scr
= 0, .sbs
= 0, .gc3
= 3}, /* 67.25 MHz */
169 { .lomax
= 1300, .svco
= 1, .spd
= 3, .scr
= 0, .sbs
= 0, .gc3
= 3}, /* 81.25 MHz */
170 { .lomax
= 1560, .svco
= 2, .spd
= 3, .scr
= 0, .sbs
= 0, .gc3
= 3}, /* 97.5 MHz */
171 { .lomax
= 1820, .svco
= 3, .spd
= 3, .scr
= 0, .sbs
= 1, .gc3
= 1}, /* 113.75 MHz */
172 { .lomax
= 2152, .svco
= 0, .spd
= 2, .scr
= 0, .sbs
= 1, .gc3
= 1}, /* 134.5 MHz */
173 { .lomax
= 2464, .svco
= 1, .spd
= 2, .scr
= 0, .sbs
= 1, .gc3
= 1}, /* 154 MHz */
174 { .lomax
= 2600, .svco
= 1, .spd
= 2, .scr
= 0, .sbs
= 1, .gc3
= 1}, /* 162.5 MHz */
175 { .lomax
= 2928, .svco
= 2, .spd
= 2, .scr
= 0, .sbs
= 1, .gc3
= 1}, /* 183 MHz */
176 { .lomax
= 3120, .svco
= 2, .spd
= 2, .scr
= 0, .sbs
= 2, .gc3
= 1}, /* 195 MHz */
177 { .lomax
= 3640, .svco
= 3, .spd
= 2, .scr
= 0, .sbs
= 2, .gc3
= 3}, /* 227.5 MHz */
178 { .lomax
= 4304, .svco
= 0, .spd
= 1, .scr
= 0, .sbs
= 2, .gc3
= 3}, /* 269 MHz */
179 { .lomax
= 5200, .svco
= 1, .spd
= 1, .scr
= 0, .sbs
= 2, .gc3
= 1}, /* 325 MHz */
180 { .lomax
= 6240, .svco
= 2, .spd
= 1, .scr
= 0, .sbs
= 3, .gc3
= 3}, /* 390 MHz */
181 { .lomax
= 7280, .svco
= 3, .spd
= 1, .scr
= 0, .sbs
= 3, .gc3
= 3}, /* 455 MHz */
182 { .lomax
= 8320, .svco
= 0, .spd
= 0, .scr
= 0, .sbs
= 3, .gc3
= 1}, /* 520 MHz */
183 { .lomax
= 8608, .svco
= 0, .spd
= 0, .scr
= 1, .sbs
= 3, .gc3
= 1}, /* 538 MHz */
184 { .lomax
= 8864, .svco
= 1, .spd
= 0, .scr
= 0, .sbs
= 3, .gc3
= 1}, /* 554 MHz */
185 { .lomax
= 9920, .svco
= 1, .spd
= 0, .scr
= 0, .sbs
= 4, .gc3
= 0}, /* 620 MHz */
186 { .lomax
= 10400, .svco
= 1, .spd
= 0, .scr
= 1, .sbs
= 4, .gc3
= 0}, /* 650 MHz */
187 { .lomax
= 11200, .svco
= 2, .spd
= 0, .scr
= 0, .sbs
= 4, .gc3
= 0}, /* 700 MHz */
188 { .lomax
= 12480, .svco
= 2, .spd
= 0, .scr
= 1, .sbs
= 4, .gc3
= 0}, /* 780 MHz */
189 { .lomax
= 13120, .svco
= 3, .spd
= 0, .scr
= 0, .sbs
= 4, .gc3
= 0}, /* 820 MHz */
190 { .lomax
= 13920, .svco
= 3, .spd
= 0, .scr
= 1, .sbs
= 4, .gc3
= 0}, /* 870 MHz */
191 { .lomax
= 14576, .svco
= 3, .spd
= 0, .scr
= 2, .sbs
= 4, .gc3
= 0}, /* 911 MHz */
192 { .lomax
= 0, .svco
= 0, .spd
= 0, .scr
= 0, .sbs
= 0, .gc3
= 0} /* End */
195 static void tda827xa_tune(struct i2c_client
*c
, u16 ifc
, unsigned int freq
)
197 unsigned char tuner_reg
[14];
198 unsigned char reg2
[2];
201 struct tuner
*t
= i2c_get_clientdata(c
);
202 struct i2c_msg msg
= {.addr
= t
->tda827x_addr
, .flags
= 0};
204 if (t
->mode
== V4L2_TUNER_RADIO
)
209 while (tda827xa_analog
[i
].lomax
< N
) {
210 if(tda827xa_analog
[i
+ 1].lomax
== 0)
215 N
= N
<< tda827xa_analog
[i
].spd
;
218 tuner_reg
[1] = (unsigned char)(N
>>8);
219 tuner_reg
[2] = (unsigned char) N
;
222 tuner_reg
[5] = (tda827xa_analog
[i
].spd
<< 5) + (tda827xa_analog
[i
].svco
<< 3) +
223 tda827xa_analog
[i
].sbs
;
224 tuner_reg
[6] = 0x8b + (tda827xa_analog
[i
].gc3
<< 4);
228 tuner_reg
[10] = 0xff;
229 tuner_reg
[11] = 0xe0;
231 tuner_reg
[13] = 0x39 + (t
->tda827x_lpsel
<< 1);
235 i2c_transfer(c
->adapter
, &msg
, 1);
241 i2c_transfer(c
->adapter
, &msg
, 1);
245 i2c_transfer(c
->adapter
, &msg
, 1);
249 reg2
[1] = 0x10 + tda827xa_analog
[i
].scr
;
250 i2c_transfer(c
->adapter
, &msg
, 1);
254 reg2
[1] = 0x8f + (tda827xa_analog
[i
].gc3
<< 4);
255 i2c_transfer(c
->adapter
, &msg
, 1);
259 i2c_transfer(c
->adapter
, &msg
, 1);
263 i2c_transfer(c
->adapter
, &msg
, 1);
266 reg2
[1] = 0x19 + (t
->tda827x_lpsel
<< 1);
267 i2c_transfer(c
->adapter
, &msg
, 1);
270 static void tda827xa_agcf(struct i2c_client
*c
)
272 struct tuner
*t
= i2c_get_clientdata(c
);
273 unsigned char data
[] = {0x80, 0x2c};
274 struct i2c_msg msg
= {.addr
= t
->tda827x_addr
, .buf
= data
,
275 .flags
= 0, .len
= 2};
276 i2c_transfer(c
->adapter
, &msg
, 1);
279 /*---------------------------------------------------------------------*/
281 static void tda8290_i2c_bridge(struct i2c_client
*c
, int close
)
283 unsigned char enable
[2] = { 0x21, 0xC0 };
284 unsigned char disable
[2] = { 0x21, 0x00 };
288 i2c_master_send(c
, msg
, 2);
289 /* let the bridge stabilize */
293 i2c_master_send(c
, msg
, 2);
297 /*---------------------------------------------------------------------*/
299 static int tda8290_tune(struct i2c_client
*c
, u16 ifc
, unsigned int freq
)
301 struct tuner
*t
= i2c_get_clientdata(c
);
302 unsigned char soft_reset
[] = { 0x00, 0x00 };
303 unsigned char easy_mode
[] = { 0x01, t
->tda8290_easy_mode
};
304 unsigned char expert_mode
[] = { 0x01, 0x80 };
305 unsigned char agc_out_on
[] = { 0x02, 0x00 };
306 unsigned char gainset_off
[] = { 0x28, 0x14 };
307 unsigned char if_agc_spd
[] = { 0x0f, 0x88 };
308 unsigned char adc_head_6
[] = { 0x05, 0x04 };
309 unsigned char adc_head_9
[] = { 0x05, 0x02 };
310 unsigned char adc_head_12
[] = { 0x05, 0x01 };
311 unsigned char pll_bw_nom
[] = { 0x0d, 0x47 };
312 unsigned char pll_bw_low
[] = { 0x0d, 0x27 };
313 unsigned char gainset_2
[] = { 0x28, 0x64 };
314 unsigned char agc_rst_on
[] = { 0x0e, 0x0b };
315 unsigned char agc_rst_off
[] = { 0x0e, 0x09 };
316 unsigned char if_agc_set
[] = { 0x0f, 0x81 };
317 unsigned char addr_adc_sat
= 0x1a;
318 unsigned char addr_agc_stat
= 0x1d;
319 unsigned char addr_pll_stat
= 0x1b;
320 unsigned char adc_sat
, agc_stat
,
323 i2c_master_send(c
, easy_mode
, 2);
324 i2c_master_send(c
, agc_out_on
, 2);
325 i2c_master_send(c
, soft_reset
, 2);
328 expert_mode
[1] = t
->tda8290_easy_mode
+ 0x80;
329 i2c_master_send(c
, expert_mode
, 2);
330 i2c_master_send(c
, gainset_off
, 2);
331 i2c_master_send(c
, if_agc_spd
, 2);
332 if (t
->tda8290_easy_mode
& 0x60)
333 i2c_master_send(c
, adc_head_9
, 2);
335 i2c_master_send(c
, adc_head_6
, 2);
336 i2c_master_send(c
, pll_bw_nom
, 2);
338 tda8290_i2c_bridge(c
, 1);
339 if (t
->tda827x_ver
!= 0)
340 tda827xa_tune(c
, ifc
, freq
);
342 tda827x_tune(c
, ifc
, freq
);
343 /* adjust headroom resp. gain */
344 i2c_master_send(c
, &addr_adc_sat
, 1);
345 i2c_master_recv(c
, &adc_sat
, 1);
346 i2c_master_send(c
, &addr_agc_stat
, 1);
347 i2c_master_recv(c
, &agc_stat
, 1);
348 i2c_master_send(c
, &addr_pll_stat
, 1);
349 i2c_master_recv(c
, &pll_stat
, 1);
351 tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat
);
353 tuner_dbg("tda8290 not locked, no signal?\n");
354 if ((agc_stat
> 115) || (!(pll_stat
& 0x80) && (adc_sat
< 20))) {
355 tuner_dbg("adjust gain, step 1. Agc: %d, ADC stat: %d, lock: %d\n",
356 agc_stat
, adc_sat
, pll_stat
& 0x80);
357 i2c_master_send(c
, gainset_2
, 2);
359 i2c_master_send(c
, &addr_agc_stat
, 1);
360 i2c_master_recv(c
, &agc_stat
, 1);
361 i2c_master_send(c
, &addr_pll_stat
, 1);
362 i2c_master_recv(c
, &pll_stat
, 1);
363 if ((agc_stat
> 115) || !(pll_stat
& 0x80)) {
364 tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n",
365 agc_stat
, pll_stat
& 0x80);
366 if (t
->tda827x_ver
!= 0)
371 i2c_master_send(c
, &addr_agc_stat
, 1);
372 i2c_master_recv(c
, &agc_stat
, 1);
373 i2c_master_send(c
, &addr_pll_stat
, 1);
374 i2c_master_recv(c
, &pll_stat
, 1);
375 if((agc_stat
> 115) || !(pll_stat
& 0x80)) {
376 tuner_dbg("adjust gain, step 3. Agc: %d\n", agc_stat
);
377 i2c_master_send(c
, adc_head_12
, 2);
378 i2c_master_send(c
, pll_bw_low
, 2);
384 /* l/ l' deadlock? */
385 if(t
->tda8290_easy_mode
& 0x60) {
386 i2c_master_send(c
, &addr_adc_sat
, 1);
387 i2c_master_recv(c
, &adc_sat
, 1);
388 i2c_master_send(c
, &addr_pll_stat
, 1);
389 i2c_master_recv(c
, &pll_stat
, 1);
390 if ((adc_sat
> 20) || !(pll_stat
& 0x80)) {
391 tuner_dbg("trying to resolve SECAM L deadlock\n");
392 i2c_master_send(c
, agc_rst_on
, 2);
394 i2c_master_send(c
, agc_rst_off
, 2);
398 tda8290_i2c_bridge(c
, 0);
399 i2c_master_send(c
, if_agc_set
, 2);
403 /*---------------------------------------------------------------------*/
405 static void set_audio(struct tuner
*t
)
409 t
->tda827x_lpsel
= 0;
411 if (t
->std
& V4L2_STD_MN
) {
413 t
->tda8290_easy_mode
= 0x01;
414 t
->tda827x_lpsel
= 1;
416 } else if (t
->std
& V4L2_STD_B
) {
418 t
->tda8290_easy_mode
= 0x02;
420 } else if (t
->std
& V4L2_STD_GH
) {
422 t
->tda8290_easy_mode
= 0x04;
424 } else if (t
->std
& V4L2_STD_PAL_I
) {
426 t
->tda8290_easy_mode
= 0x08;
428 } else if (t
->std
& V4L2_STD_DK
) {
430 t
->tda8290_easy_mode
= 0x10;
432 } else if (t
->std
& V4L2_STD_SECAM_L
) {
434 t
->tda8290_easy_mode
= 0x20;
436 } else if (t
->std
& V4L2_STD_SECAM_LC
) {
438 t
->tda8290_easy_mode
= 0x40;
441 tuner_dbg("setting tda8290 to system %s\n", mode
);
444 static void set_tv_freq(struct i2c_client
*c
, unsigned int freq
)
446 struct tuner
*t
= i2c_get_clientdata(c
);
449 tda8290_tune(c
, t
->sgIF
, freq
);
452 static void set_radio_freq(struct i2c_client
*c
, unsigned int freq
)
454 /* if frequency is 5.5 MHz */
455 tda8290_tune(c
, 88, freq
);
458 static int has_signal(struct i2c_client
*c
)
460 unsigned char i2c_get_afc
[1] = { 0x1B };
461 unsigned char afc
= 0;
463 i2c_master_send(c
, i2c_get_afc
, ARRAY_SIZE(i2c_get_afc
));
464 i2c_master_recv(c
, &afc
, 1);
465 return (afc
& 0x80)? 65535:0;
468 /*---------------------------------------------------------------------*/
470 static void standby(struct i2c_client
*c
)
472 struct tuner
*t
= i2c_get_clientdata(c
);
473 unsigned char cb1
[] = { 0x30, 0xD0 };
474 unsigned char tda8290_standby
[] = { 0x00, 0x02 };
475 unsigned char tda8290_agc_tri
[] = { 0x02, 0x20 };
476 struct i2c_msg msg
= {.addr
= t
->tda827x_addr
, .flags
=0, .buf
=cb1
, .len
= 2};
478 tda8290_i2c_bridge(c
, 1);
479 if (t
->tda827x_ver
!= 0)
481 i2c_transfer(c
->adapter
, &msg
, 1);
482 tda8290_i2c_bridge(c
, 0);
483 i2c_master_send(c
, tda8290_agc_tri
, 2);
484 i2c_master_send(c
, tda8290_standby
, 2);
488 static void tda8290_init_if(struct i2c_client
*c
)
490 unsigned char set_VS
[] = { 0x30, 0x6F };
491 unsigned char set_GP01_CF
[] = { 0x20, 0x0B };
493 i2c_master_send(c
, set_VS
, 2);
494 i2c_master_send(c
, set_GP01_CF
, 2);
497 static void tda8290_init_tuner(struct i2c_client
*c
)
499 struct tuner
*t
= i2c_get_clientdata(c
);
500 unsigned char tda8275_init
[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf,
501 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 };
502 unsigned char tda8275a_init
[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b,
503 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b };
504 struct i2c_msg msg
= {.addr
= t
->tda827x_addr
, .flags
=0,
505 .buf
=tda8275_init
, .len
= 14};
506 if (t
->tda827x_ver
!= 0)
507 msg
.buf
= tda8275a_init
;
509 tda8290_i2c_bridge(c
, 1);
510 i2c_transfer(c
->adapter
, &msg
, 1);
511 tda8290_i2c_bridge(c
, 0);
514 /*---------------------------------------------------------------------*/
516 int tda8290_init(struct i2c_client
*c
)
518 struct tuner
*t
= i2c_get_clientdata(c
);
520 int i
, ret
, tuners_found
;
522 struct i2c_msg msg
= {.flags
=I2C_M_RD
, .buf
=&data
, .len
= 1};
524 tda8290_i2c_bridge(c
, 1);
525 /* probe for tuner chip */
528 for (i
=0x60; i
<= 0x63; i
++) {
530 ret
= i2c_transfer(c
->adapter
, &msg
, 1);
533 tuner_addrs
= (tuner_addrs
<< 8) + i
;
536 /* if there is more than one tuner, we expect the right one is
537 behind the bridge and we choose the highest address that doesn't
540 tda8290_i2c_bridge(c
, 0);
542 for (i
= 0; i
< tuners_found
; i
++) {
543 msg
.addr
= tuner_addrs
& 0xff;
544 ret
= i2c_transfer(c
->adapter
, &msg
, 1);
546 tuner_addrs
= tuner_addrs
>> 8;
550 if (tuner_addrs
== 0) {
552 tuner_info ("could not clearly identify tuner address, defaulting to %x\n",
555 tuner_addrs
= tuner_addrs
& 0xff;
556 tuner_info ("setting tuner address to %x\n", tuner_addrs
);
558 t
->tda827x_addr
= tuner_addrs
;
559 msg
.addr
= tuner_addrs
;
561 tda8290_i2c_bridge(c
, 1);
562 ret
= i2c_transfer(c
->adapter
, &msg
, 1);
564 tuner_warn ("TDA827x access failed!\n");
565 if ((data
& 0x3c) == 0) {
566 strlcpy(c
->name
, "tda8290+75", sizeof(c
->name
));
569 strlcpy(c
->name
, "tda8290+75a", sizeof(c
->name
));
572 tuner_info("type set to %s\n", c
->name
);
574 t
->set_tv_freq
= set_tv_freq
;
575 t
->set_radio_freq
= set_radio_freq
;
576 t
->has_signal
= has_signal
;
577 t
->standby
= standby
;
578 t
->tda827x_lpsel
= 0;
580 tda8290_init_tuner(c
);
585 int tda8290_probe(struct i2c_client
*c
)
587 unsigned char soft_reset
[] = { 0x00, 0x00 };
588 unsigned char easy_mode_b
[] = { 0x01, 0x02 };
589 unsigned char easy_mode_g
[] = { 0x01, 0x04 };
590 unsigned char restore_9886
[] = { 0x00, 0xd6, 0x30 };
591 unsigned char addr_dto_lsb
= 0x07;
594 i2c_master_send(c
, easy_mode_b
, 2);
595 i2c_master_send(c
, soft_reset
, 2);
596 i2c_master_send(c
, &addr_dto_lsb
, 1);
597 i2c_master_recv(c
, &data
, 1);
599 i2c_master_send(c
, easy_mode_g
, 2);
600 i2c_master_send(c
, soft_reset
, 2);
601 i2c_master_send(c
, &addr_dto_lsb
, 1);
602 i2c_master_recv(c
, &data
, 1);
607 i2c_master_send(c
, restore_9886
, 3);
612 * Overrides for Emacs so that we follow Linus's tabbing style.
613 * ---------------------------------------------------------------------------