3 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
5 * Extended 3 / 2005 by Hartmut Hackmann to support various
6 * cards with the tda10046 DVB-T channel decoder
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/init.h>
24 #include <linux/list.h>
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/slab.h>
28 #include <linux/delay.h>
29 #include <linux/kthread.h>
30 #include <linux/suspend.h>
32 #include "saa7134-reg.h"
37 # include "mt352_priv.h" /* FIXME */
40 # include "tda1004x.h"
47 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
48 MODULE_LICENSE("GPL");
50 static unsigned int antenna_pwr
= 0;
52 module_param(antenna_pwr
, int, 0444);
53 MODULE_PARM_DESC(antenna_pwr
,"enable antenna power (Pinnacle 300i)");
55 /* ------------------------------------------------------------------ */
58 static int pinnacle_antenna_pwr(struct saa7134_dev
*dev
, int on
)
63 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
64 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
68 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 26));
69 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
72 saa_setl(SAA7134_GPIO_GPMODE0
>> 2, (1 << 28));
73 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
75 saa_setl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 28));
77 ok
= saa_readl(SAA7134_GPIO_GPSTATUS0
) & (1 << 27);
78 printk("%s: %s %s\n", dev
->name
, __FUNCTION__
,
82 saa_clearl(SAA7134_GPIO_GPSTATUS0
>> 2, (1 << 26));
86 static int mt352_pinnacle_init(struct dvb_frontend
* fe
)
88 static u8 clock_config
[] = { CLOCK_CTL
, 0x3d, 0x28 };
89 static u8 reset
[] = { RESET
, 0x80 };
90 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
91 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0xa0 };
92 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x31 };
93 static u8 fsm_ctl_cfg
[] = { 0x7b, 0x04 };
94 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x0f };
95 static u8 scan_ctl_cfg
[] = { SCAN_CTL
, 0x0d };
96 static u8 irq_cfg
[] = { INTERRUPT_EN_0
, 0x00, 0x00, 0x00, 0x00 };
97 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
99 printk("%s: %s called\n",dev
->name
,__FUNCTION__
);
101 mt352_write(fe
, clock_config
, sizeof(clock_config
));
103 mt352_write(fe
, reset
, sizeof(reset
));
104 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
105 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
106 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
107 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
109 mt352_write(fe
, fsm_ctl_cfg
, sizeof(fsm_ctl_cfg
));
110 mt352_write(fe
, scan_ctl_cfg
, sizeof(scan_ctl_cfg
));
111 mt352_write(fe
, irq_cfg
, sizeof(irq_cfg
));
115 static int mt352_pinnacle_pll_set(struct dvb_frontend
* fe
,
116 struct dvb_frontend_parameters
* params
,
119 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
120 static int off
= TDA9887_PRESENT
| TDA9887_PORT2_ACTIVE
;
121 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
122 struct v4l2_frequency f
;
124 /* set frequency (mt2050) */
126 f
.type
= V4L2_TUNER_DIGITAL_TV
;
127 f
.frequency
= params
->frequency
/ 1000 * 16 / 1000;
128 saa7134_i2c_call_clients(dev
,TDA9887_SET_CONFIG
,&on
);
129 saa7134_i2c_call_clients(dev
,VIDIOC_S_FREQUENCY
,&f
);
130 saa7134_i2c_call_clients(dev
,TDA9887_SET_CONFIG
,&off
);
132 pinnacle_antenna_pwr(dev
, antenna_pwr
);
135 mt352_pinnacle_init(fe
);
144 static struct mt352_config pinnacle_300i
= {
145 .demod_address
= 0x3c >> 1,
149 .demod_init
= mt352_pinnacle_init
,
150 .pll_set
= mt352_pinnacle_pll_set
,
154 /* ------------------------------------------------------------------ */
158 static int philips_tda6651_pll_set(u8 addr
, struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
160 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
162 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tuner_buf
,.len
=
164 int tuner_frequency
= 0;
167 /* determine charge pump */
168 tuner_frequency
= params
->frequency
+ 36166000;
169 if (tuner_frequency
< 87000000)
171 else if (tuner_frequency
< 130000000)
173 else if (tuner_frequency
< 160000000)
175 else if (tuner_frequency
< 200000000)
177 else if (tuner_frequency
< 290000000)
179 else if (tuner_frequency
< 420000000)
181 else if (tuner_frequency
< 480000000)
183 else if (tuner_frequency
< 620000000)
185 else if (tuner_frequency
< 830000000)
187 else if (tuner_frequency
< 895000000)
193 if (params
->frequency
< 49000000)
195 else if (params
->frequency
< 161000000)
197 else if (params
->frequency
< 444000000)
199 else if (params
->frequency
< 861000000)
204 /* setup PLL filter */
205 switch (params
->u
.ofdm
.bandwidth
) {
206 case BANDWIDTH_6_MHZ
:
210 case BANDWIDTH_7_MHZ
:
214 case BANDWIDTH_8_MHZ
:
223 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
225 tuner_frequency
= (((params
->frequency
/ 1000) * 6) + 217496) / 1000;
227 /* setup tuner buffer */
228 tuner_buf
[0] = (tuner_frequency
>> 8) & 0x7f;
229 tuner_buf
[1] = tuner_frequency
& 0xff;
231 tuner_buf
[3] = (cp
<< 5) | (filter
<< 3) | band
;
233 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
239 static int philips_tda6651_pll_init(u8 addr
, struct dvb_frontend
*fe
)
241 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
242 static u8 tu1216_init
[] = { 0x0b, 0xf5, 0x85, 0xab };
243 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tu1216_init
,.len
= sizeof(tu1216_init
) };
245 /* setup PLL configuration */
246 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
253 /* ------------------------------------------------------------------ */
255 static int philips_tu1216_pll_60_init(struct dvb_frontend
*fe
)
257 return philips_tda6651_pll_init(0x60, fe
);
260 static int philips_tu1216_pll_60_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
262 return philips_tda6651_pll_set(0x60, fe
, params
);
265 static int philips_tu1216_request_firmware(struct dvb_frontend
*fe
,
266 const struct firmware
**fw
, char *name
)
268 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
269 return request_firmware(fw
, name
, &dev
->pci
->dev
);
272 static struct tda1004x_config philips_tu1216_60_config
= {
274 .demod_address
= 0x8,
277 .xtal_freq
= TDA10046_XTAL_4M
,
278 .agc_config
= TDA10046_AGC_DEFAULT
,
279 .if_freq
= TDA10046_FREQ_3617
,
280 .pll_init
= philips_tu1216_pll_60_init
,
281 .pll_set
= philips_tu1216_pll_60_set
,
283 .request_firmware
= philips_tu1216_request_firmware
,
286 /* ------------------------------------------------------------------ */
288 static int philips_tu1216_pll_61_init(struct dvb_frontend
*fe
)
290 return philips_tda6651_pll_init(0x61, fe
);
293 static int philips_tu1216_pll_61_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
295 return philips_tda6651_pll_set(0x61, fe
, params
);
298 static struct tda1004x_config philips_tu1216_61_config
= {
300 .demod_address
= 0x8,
303 .xtal_freq
= TDA10046_XTAL_4M
,
304 .agc_config
= TDA10046_AGC_DEFAULT
,
305 .if_freq
= TDA10046_FREQ_3617
,
306 .pll_init
= philips_tu1216_pll_61_init
,
307 .pll_set
= philips_tu1216_pll_61_set
,
309 .request_firmware
= philips_tu1216_request_firmware
,
312 /* ------------------------------------------------------------------ */
314 static int philips_europa_pll_init(struct dvb_frontend
*fe
)
316 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
317 static u8 msg
[] = { 0x0b, 0xf5, 0x86, 0xab };
318 struct i2c_msg init_msg
= {.addr
= 0x61,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
320 /* setup PLL configuration */
321 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
325 /* switch the board to dvb mode */
326 init_msg
.addr
= 0x43;
330 if (i2c_transfer(&dev
->i2c_adap
, &init_msg
, 1) != 1)
336 static int philips_td1316_pll_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
338 return philips_tda6651_pll_set(0x61, fe
, params
);
341 static void philips_europa_analog(struct dvb_frontend
*fe
)
343 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
344 /* this message actually turns the tuner back to analog mode */
345 static u8 msg
[] = { 0x0b, 0xdc, 0x86, 0xa4 };
346 struct i2c_msg analog_msg
= {.addr
= 0x61,.flags
= 0,.buf
= msg
,.len
= sizeof(msg
) };
348 i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1);
351 /* switch the board to analog mode */
352 analog_msg
.addr
= 0x43;
353 analog_msg
.len
= 0x02;
356 i2c_transfer(&dev
->i2c_adap
, &analog_msg
, 1);
359 static struct tda1004x_config philips_europa_config
= {
361 .demod_address
= 0x8,
364 .xtal_freq
= TDA10046_XTAL_4M
,
365 .agc_config
= TDA10046_AGC_IFO_AUTO_POS
,
366 .if_freq
= TDA10046_FREQ_052
,
367 .pll_init
= philips_europa_pll_init
,
368 .pll_set
= philips_td1316_pll_set
,
369 .pll_sleep
= philips_europa_analog
,
370 .request_firmware
= NULL
,
373 /* ------------------------------------------------------------------ */
375 static int philips_fmd1216_pll_init(struct dvb_frontend
*fe
)
377 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
378 /* this message is to set up ATC and ALC */
379 static u8 fmd1216_init
[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
380 struct i2c_msg tuner_msg
= {.addr
= 0x61,.flags
= 0,.buf
= fmd1216_init
,.len
= sizeof(fmd1216_init
) };
382 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
389 static void philips_fmd1216_analog(struct dvb_frontend
*fe
)
391 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
392 /* this message actually turns the tuner back to analog mode */
393 static u8 fmd1216_init
[] = { 0x0b, 0xdc, 0x9c, 0x60 };
394 struct i2c_msg tuner_msg
= {.addr
= 0x61,.flags
= 0,.buf
= fmd1216_init
,.len
= sizeof(fmd1216_init
) };
396 i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1);
398 fmd1216_init
[2] = 0x86;
399 fmd1216_init
[3] = 0x54;
400 i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1);
404 static int philips_fmd1216_pll_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
406 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
408 struct i2c_msg tuner_msg
= {.addr
= 0x61,.flags
= 0,.buf
= tuner_buf
,.len
=
410 int tuner_frequency
= 0;
414 /* determine charge pump */
415 tuner_frequency
= params
->frequency
+ 36130000;
416 if (tuner_frequency
< 87000000)
419 else if (tuner_frequency
< 180000000) {
423 } else if (tuner_frequency
< 195000000) {
428 } else if (tuner_frequency
< 366000000) {
429 if (params
->u
.ofdm
.bandwidth
== BANDWIDTH_8_MHZ
) {
436 } else if (tuner_frequency
< 478000000) {
437 if (params
->u
.ofdm
.bandwidth
== BANDWIDTH_8_MHZ
) {
445 } else if (tuner_frequency
< 662000000) {
446 if (params
->u
.ofdm
.bandwidth
== BANDWIDTH_8_MHZ
) {
453 } else if (tuner_frequency
< 840000000) {
454 if (params
->u
.ofdm
.bandwidth
== BANDWIDTH_8_MHZ
) {
462 if (params
->u
.ofdm
.bandwidth
== BANDWIDTH_8_MHZ
) {
471 /* calculate divisor */
472 /* ((36166000 + Finput) / 166666) rounded! */
473 divider
= (tuner_frequency
+ 83333) / 166667;
475 /* setup tuner buffer */
476 tuner_buf
[0] = (divider
>> 8) & 0x7f;
477 tuner_buf
[1] = divider
& 0xff;
478 tuner_buf
[2] = 0x80 | (cp
<< 6) | (mode
<< 3) | 4;
479 tuner_buf
[3] = 0x40 | band
;
481 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
486 static struct tda1004x_config medion_cardbus
= {
487 .demod_address
= 0x08,
490 .xtal_freq
= TDA10046_XTAL_16M
,
491 .agc_config
= TDA10046_AGC_IFO_AUTO_NEG
,
492 .if_freq
= TDA10046_FREQ_3613
,
493 .pll_init
= philips_fmd1216_pll_init
,
494 .pll_set
= philips_fmd1216_pll_set
,
495 .pll_sleep
= philips_fmd1216_analog
,
496 .request_firmware
= NULL
,
499 /* ------------------------------------------------------------------ */
501 struct tda827x_data
{
511 static struct tda827x_data tda827x_dvbt
[] = {
512 { .lomax
= 62000000, .spd
= 3, .bs
= 2, .bp
= 0, .cp
= 0, .gc3
= 3, .div1p5
= 1},
513 { .lomax
= 66000000, .spd
= 3, .bs
= 3, .bp
= 0, .cp
= 0, .gc3
= 3, .div1p5
= 1},
514 { .lomax
= 76000000, .spd
= 3, .bs
= 1, .bp
= 0, .cp
= 0, .gc3
= 3, .div1p5
= 0},
515 { .lomax
= 84000000, .spd
= 3, .bs
= 2, .bp
= 0, .cp
= 0, .gc3
= 3, .div1p5
= 0},
516 { .lomax
= 93000000, .spd
= 3, .bs
= 2, .bp
= 0, .cp
= 0, .gc3
= 1, .div1p5
= 0},
517 { .lomax
= 98000000, .spd
= 3, .bs
= 3, .bp
= 0, .cp
= 0, .gc3
= 1, .div1p5
= 0},
518 { .lomax
= 109000000, .spd
= 3, .bs
= 3, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 0},
519 { .lomax
= 123000000, .spd
= 2, .bs
= 2, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 1},
520 { .lomax
= 133000000, .spd
= 2, .bs
= 3, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 1},
521 { .lomax
= 151000000, .spd
= 2, .bs
= 1, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 0},
522 { .lomax
= 154000000, .spd
= 2, .bs
= 2, .bp
= 1, .cp
= 0, .gc3
= 1, .div1p5
= 0},
523 { .lomax
= 181000000, .spd
= 2, .bs
= 2, .bp
= 1, .cp
= 0, .gc3
= 0, .div1p5
= 0},
524 { .lomax
= 185000000, .spd
= 2, .bs
= 2, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 0},
525 { .lomax
= 217000000, .spd
= 2, .bs
= 3, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 0},
526 { .lomax
= 244000000, .spd
= 1, .bs
= 2, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 1},
527 { .lomax
= 265000000, .spd
= 1, .bs
= 3, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 1},
528 { .lomax
= 302000000, .spd
= 1, .bs
= 1, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 0},
529 { .lomax
= 324000000, .spd
= 1, .bs
= 2, .bp
= 2, .cp
= 0, .gc3
= 1, .div1p5
= 0},
530 { .lomax
= 370000000, .spd
= 1, .bs
= 2, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 0},
531 { .lomax
= 454000000, .spd
= 1, .bs
= 3, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 0},
532 { .lomax
= 493000000, .spd
= 0, .bs
= 2, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 1},
533 { .lomax
= 530000000, .spd
= 0, .bs
= 3, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 1},
534 { .lomax
= 554000000, .spd
= 0, .bs
= 1, .bp
= 3, .cp
= 0, .gc3
= 1, .div1p5
= 0},
535 { .lomax
= 604000000, .spd
= 0, .bs
= 1, .bp
= 4, .cp
= 0, .gc3
= 0, .div1p5
= 0},
536 { .lomax
= 696000000, .spd
= 0, .bs
= 2, .bp
= 4, .cp
= 0, .gc3
= 0, .div1p5
= 0},
537 { .lomax
= 740000000, .spd
= 0, .bs
= 2, .bp
= 4, .cp
= 1, .gc3
= 0, .div1p5
= 0},
538 { .lomax
= 820000000, .spd
= 0, .bs
= 3, .bp
= 4, .cp
= 0, .gc3
= 0, .div1p5
= 0},
539 { .lomax
= 865000000, .spd
= 0, .bs
= 3, .bp
= 4, .cp
= 1, .gc3
= 0, .div1p5
= 0},
540 { .lomax
= 0, .spd
= 0, .bs
= 0, .bp
= 0, .cp
= 0, .gc3
= 0, .div1p5
= 0}
543 static int philips_tda827x_pll_init(struct dvb_frontend
*fe
)
548 static int philips_tda827x_pll_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
550 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
553 struct i2c_msg tuner_msg
= {.addr
= 0x60,.flags
= 0,.buf
= tuner_buf
,
554 .len
= sizeof(tuner_buf
) };
555 int i
, tuner_freq
, if_freq
;
557 switch (params
->u
.ofdm
.bandwidth
) {
558 case BANDWIDTH_6_MHZ
:
561 case BANDWIDTH_7_MHZ
:
564 default: /* 8 MHz or Auto */
568 tuner_freq
= params
->frequency
+ if_freq
;
571 while (tda827x_dvbt
[i
].lomax
< tuner_freq
) {
572 if(tda827x_dvbt
[i
+ 1].lomax
== 0)
577 N
= ((tuner_freq
+ 125000) / 250000) << (tda827x_dvbt
[i
].spd
+ 2);
579 tuner_buf
[1] = (N
>>8) | 0x40;
580 tuner_buf
[2] = N
& 0xff;
583 tuner_buf
[5] = (tda827x_dvbt
[i
].spd
<< 6) + (tda827x_dvbt
[i
].div1p5
<< 5) +
584 (tda827x_dvbt
[i
].bs
<< 3) + tda827x_dvbt
[i
].bp
;
585 tuner_buf
[6] = (tda827x_dvbt
[i
].gc3
<< 4) + 0x8f;
589 tuner_buf
[10] = 0xff;
590 tuner_buf
[11] = 0x00;
591 tuner_buf
[12] = 0x00;
592 tuner_buf
[13] = 0x40;
595 if (i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1) != 1)
599 /* correct CP value */
601 tuner_buf
[1] = 0x50 + tda827x_dvbt
[i
].cp
;
603 i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1);
608 static void philips_tda827x_pll_sleep(struct dvb_frontend
*fe
)
610 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
611 static u8 tda827x_sleep
[] = { 0x30, 0xd0};
612 struct i2c_msg tuner_msg
= {.addr
= 0x60,.flags
= 0,.buf
= tda827x_sleep
,
613 .len
= sizeof(tda827x_sleep
) };
614 i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1);
617 static struct tda1004x_config tda827x_lifeview_config
= {
618 .demod_address
= 0x08,
621 .xtal_freq
= TDA10046_XTAL_16M
,
622 .agc_config
= TDA10046_AGC_TDA827X
,
623 .if_freq
= TDA10046_FREQ_045
,
624 .pll_init
= philips_tda827x_pll_init
,
625 .pll_set
= philips_tda827x_pll_set
,
626 .pll_sleep
= philips_tda827x_pll_sleep
,
627 .request_firmware
= NULL
,
630 /* ------------------------------------------------------------------ */
632 struct tda827xa_data
{
641 static struct tda827xa_data tda827xa_dvbt
[] = {
642 { .lomax
= 56875000, .svco
= 3, .spd
= 4, .scr
= 0, .sbs
= 0, .gc3
= 1},
643 { .lomax
= 67250000, .svco
= 0, .spd
= 3, .scr
= 0, .sbs
= 0, .gc3
= 1},
644 { .lomax
= 81250000, .svco
= 1, .spd
= 3, .scr
= 0, .sbs
= 0, .gc3
= 1},
645 { .lomax
= 97500000, .svco
= 2, .spd
= 3, .scr
= 0, .sbs
= 0, .gc3
= 1},
646 { .lomax
= 113750000, .svco
= 3, .spd
= 3, .scr
= 0, .sbs
= 1, .gc3
= 1},
647 { .lomax
= 134500000, .svco
= 0, .spd
= 2, .scr
= 0, .sbs
= 1, .gc3
= 1},
648 { .lomax
= 154000000, .svco
= 1, .spd
= 2, .scr
= 0, .sbs
= 1, .gc3
= 1},
649 { .lomax
= 162500000, .svco
= 1, .spd
= 2, .scr
= 0, .sbs
= 1, .gc3
= 1},
650 { .lomax
= 183000000, .svco
= 2, .spd
= 2, .scr
= 0, .sbs
= 1, .gc3
= 1},
651 { .lomax
= 195000000, .svco
= 2, .spd
= 2, .scr
= 0, .sbs
= 2, .gc3
= 1},
652 { .lomax
= 227500000, .svco
= 3, .spd
= 2, .scr
= 0, .sbs
= 2, .gc3
= 1},
653 { .lomax
= 269000000, .svco
= 0, .spd
= 1, .scr
= 0, .sbs
= 2, .gc3
= 1},
654 { .lomax
= 290000000, .svco
= 1, .spd
= 1, .scr
= 0, .sbs
= 2, .gc3
= 1},
655 { .lomax
= 325000000, .svco
= 1, .spd
= 1, .scr
= 0, .sbs
= 3, .gc3
= 1},
656 { .lomax
= 390000000, .svco
= 2, .spd
= 1, .scr
= 0, .sbs
= 3, .gc3
= 1},
657 { .lomax
= 455000000, .svco
= 3, .spd
= 1, .scr
= 0, .sbs
= 3, .gc3
= 1},
658 { .lomax
= 520000000, .svco
= 0, .spd
= 0, .scr
= 0, .sbs
= 3, .gc3
= 1},
659 { .lomax
= 538000000, .svco
= 0, .spd
= 0, .scr
= 1, .sbs
= 3, .gc3
= 1},
660 { .lomax
= 550000000, .svco
= 1, .spd
= 0, .scr
= 0, .sbs
= 3, .gc3
= 1},
661 { .lomax
= 620000000, .svco
= 1, .spd
= 0, .scr
= 0, .sbs
= 4, .gc3
= 0},
662 { .lomax
= 650000000, .svco
= 1, .spd
= 0, .scr
= 1, .sbs
= 4, .gc3
= 0},
663 { .lomax
= 700000000, .svco
= 2, .spd
= 0, .scr
= 0, .sbs
= 4, .gc3
= 0},
664 { .lomax
= 780000000, .svco
= 2, .spd
= 0, .scr
= 1, .sbs
= 4, .gc3
= 0},
665 { .lomax
= 820000000, .svco
= 3, .spd
= 0, .scr
= 0, .sbs
= 4, .gc3
= 0},
666 { .lomax
= 870000000, .svco
= 3, .spd
= 0, .scr
= 1, .sbs
= 4, .gc3
= 0},
667 { .lomax
= 911000000, .svco
= 3, .spd
= 0, .scr
= 2, .sbs
= 4, .gc3
= 0},
668 { .lomax
= 0, .svco
= 0, .spd
= 0, .scr
= 0, .sbs
= 0, .gc3
= 0}};
671 static int philips_tda827xa_pll_set(u8 addr
, struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
673 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
675 unsigned char reg2
[2];
677 struct i2c_msg msg
= {.addr
= addr
,.flags
= 0,.buf
= tuner_buf
};
678 int i
, tuner_freq
, if_freq
;
681 switch (params
->u
.ofdm
.bandwidth
) {
682 case BANDWIDTH_6_MHZ
:
685 case BANDWIDTH_7_MHZ
:
688 default: /* 8 MHz or Auto */
692 tuner_freq
= params
->frequency
+ if_freq
;
695 while (tda827xa_dvbt
[i
].lomax
< tuner_freq
) {
696 if(tda827xa_dvbt
[i
+ 1].lomax
== 0)
701 N
= ((tuner_freq
+ 31250) / 62500) << tda827xa_dvbt
[i
].spd
;
702 tuner_buf
[0] = 0; // subaddress
703 tuner_buf
[1] = N
>> 8;
704 tuner_buf
[2] = N
& 0xff;
707 tuner_buf
[5] = (tda827xa_dvbt
[i
].spd
<< 5) + (tda827xa_dvbt
[i
].svco
<< 3) +
708 tda827xa_dvbt
[i
].sbs
;
709 tuner_buf
[6] = 0x4b + (tda827xa_dvbt
[i
].gc3
<< 4);
713 tuner_buf
[10] = 0xff;
714 tuner_buf
[11] = 0x60;
715 tuner_buf
[12] = 0x00;
716 tuner_buf
[13] = 0x39; // lpsel
718 if (i2c_transfer(&dev
->i2c_adap
, &msg
, 1) != 1)
725 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
729 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
732 /* correct CP value */
734 reg2
[1] = 0x10 + tda827xa_dvbt
[i
].scr
;
736 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
740 reg2
[1] = 0x4f + (tda827xa_dvbt
[i
].gc3
<< 4);
741 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
747 static void philips_tda827xa_pll_sleep(u8 addr
, struct dvb_frontend
*fe
)
749 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
750 static u8 tda827xa_sleep
[] = { 0x30, 0x90};
751 struct i2c_msg tuner_msg
= {.addr
= addr
,.flags
= 0,.buf
= tda827xa_sleep
,
752 .len
= sizeof(tda827xa_sleep
) };
753 i2c_transfer(&dev
->i2c_adap
, &tuner_msg
, 1);
757 /* ------------------------------------------------------------------ */
759 static int philips_tiger_pll_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
762 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
763 static u8 tda8290_close
[] = { 0x21, 0xc0};
764 static u8 tda8290_open
[] = { 0x21, 0x80};
765 struct i2c_msg tda8290_msg
= {.addr
= 0x4b,.flags
= 0, .len
= 2};
766 /* close tda8290 i2c bridge */
767 tda8290_msg
.buf
= tda8290_close
;
768 ret
= i2c_transfer(&dev
->i2c_adap
, &tda8290_msg
, 1);
772 ret
= philips_tda827xa_pll_set(0x61, fe
, params
);
775 /* open tda8290 i2c bridge */
776 tda8290_msg
.buf
= tda8290_open
;
777 i2c_transfer(&dev
->i2c_adap
, &tda8290_msg
, 1);
781 static int philips_tiger_dvb_mode(struct dvb_frontend
*fe
)
783 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
784 static u8 data
[] = { 0x3c, 0x33, 0x6a};
785 struct i2c_msg msg
= {.addr
=0x08, .flags
=0, .buf
=data
, .len
= sizeof(data
)};
787 if (i2c_transfer(&dev
->i2c_adap
, &msg
, 1) != 1)
792 static void philips_tiger_analog_mode(struct dvb_frontend
*fe
)
794 struct saa7134_dev
*dev
= fe
->dvb
->priv
;
795 static u8 data
[] = { 0x3c, 0x33, 0x68};
796 struct i2c_msg msg
= {.addr
=0x08, .flags
=0, .buf
=data
, .len
= sizeof(data
)};
798 i2c_transfer(&dev
->i2c_adap
, &msg
, 1);
799 philips_tda827xa_pll_sleep( 0x61, fe
);
802 static struct tda1004x_config philips_tiger_config
= {
803 .demod_address
= 0x08,
806 .xtal_freq
= TDA10046_XTAL_16M
,
807 .agc_config
= TDA10046_AGC_TDA827X
,
808 .if_freq
= TDA10046_FREQ_045
,
809 .pll_init
= philips_tiger_dvb_mode
,
810 .pll_set
= philips_tiger_pll_set
,
811 .pll_sleep
= philips_tiger_analog_mode
,
812 .request_firmware
= NULL
,
817 /* ------------------------------------------------------------------ */
820 static struct nxt200x_config avertvhda180
= {
821 .demod_address
= 0x0a,
823 .pll_desc
= &dvb_pll_tdhu2
,
827 /* ------------------------------------------------------------------ */
829 static int dvb_init(struct saa7134_dev
*dev
)
831 /* init struct videobuf_dvb */
832 dev
->ts
.nr_bufs
= 32;
833 dev
->ts
.nr_packets
= 32*4;
834 dev
->dvb
.name
= dev
->name
;
835 videobuf_queue_init(&dev
->dvb
.dvbq
, &saa7134_ts_qops
,
836 dev
->pci
, &dev
->slock
,
837 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
838 V4L2_FIELD_ALTERNATE
,
839 sizeof(struct saa7134_buf
),
842 switch (dev
->board
) {
844 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
845 printk("%s: pinnacle 300i dvb setup\n",dev
->name
);
846 dev
->dvb
.frontend
= mt352_attach(&pinnacle_300i
,
851 case SAA7134_BOARD_MD7134
:
852 dev
->dvb
.frontend
= tda10046_attach(&medion_cardbus
,
855 case SAA7134_BOARD_PHILIPS_TOUGH
:
856 dev
->dvb
.frontend
= tda10046_attach(&philips_tu1216_60_config
,
859 case SAA7134_BOARD_FLYDVBTDUO
:
860 dev
->dvb
.frontend
= tda10046_attach(&tda827x_lifeview_config
,
863 case SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS
:
864 dev
->dvb
.frontend
= tda10046_attach(&tda827x_lifeview_config
,
867 case SAA7134_BOARD_PHILIPS_EUROPA
:
868 dev
->dvb
.frontend
= tda10046_attach(&philips_europa_config
,
871 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
872 dev
->dvb
.frontend
= tda10046_attach(&philips_europa_config
,
875 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
876 dev
->dvb
.frontend
= tda10046_attach(&philips_tu1216_61_config
,
879 case SAA7134_BOARD_PHILIPS_TIGER
:
880 dev
->dvb
.frontend
= tda10046_attach(&philips_tiger_config
,
883 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
884 dev
->dvb
.frontend
= tda10046_attach(&philips_tiger_config
,
889 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180
:
890 dev
->dvb
.frontend
= nxt200x_attach(&avertvhda180
, &dev
->i2c_adap
);
894 printk("%s: Huh? unknown DVB card?\n",dev
->name
);
898 if (NULL
== dev
->dvb
.frontend
) {
899 printk("%s: frontend initialization failed\n",dev
->name
);
903 /* register everything else */
904 return videobuf_dvb_register(&dev
->dvb
, THIS_MODULE
, dev
);
907 static int dvb_fini(struct saa7134_dev
*dev
)
909 static int on
= TDA9887_PRESENT
| TDA9887_PORT2_INACTIVE
;
911 switch (dev
->board
) {
912 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL
:
913 /* otherwise we don't detect the tuner on next insmod */
914 saa7134_i2c_call_clients(dev
,TDA9887_SET_CONFIG
,&on
);
917 videobuf_dvb_unregister(&dev
->dvb
);
921 static struct saa7134_mpeg_ops dvb_ops
= {
922 .type
= SAA7134_MPEG_DVB
,
927 static int __init
dvb_register(void)
929 return saa7134_ts_register(&dvb_ops
);
932 static void __exit
dvb_unregister(void)
934 saa7134_ts_unregister(&dvb_ops
);
937 module_init(dvb_register
);
938 module_exit(dvb_unregister
);
940 /* ------------------------------------------------------------------ */