2 Driver for Philips tda1004xh OFDM Demodulator
4 (c) 2003, 2004 Andrew de Quincey & Robert Schlabbach
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
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * This driver needs external firmware. Please use the commands
24 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",
25 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to
26 * download/extract them, and then copy them to /usr/lib/hotplug/firmware
27 * or /lib/firmware (depending on configuration of firmware hotplug).
29 #define TDA10045_DEFAULT_FIRMWARE "dvb-fe-tda10045.fw"
30 #define TDA10046_DEFAULT_FIRMWARE "dvb-fe-tda10046.fw"
32 #include <linux/init.h>
33 #include <linux/module.h>
34 #include <linux/moduleparam.h>
35 #include <linux/device.h>
36 #include <linux/jiffies.h>
37 #include <linux/string.h>
38 #include <linux/slab.h>
40 #include "dvb_frontend.h"
44 #define dprintk(args...) \
46 if (debug) printk(KERN_DEBUG "tda1004x: " args); \
49 #define TDA1004X_CHIPID 0x00
50 #define TDA1004X_AUTO 0x01
51 #define TDA1004X_IN_CONF1 0x02
52 #define TDA1004X_IN_CONF2 0x03
53 #define TDA1004X_OUT_CONF1 0x04
54 #define TDA1004X_OUT_CONF2 0x05
55 #define TDA1004X_STATUS_CD 0x06
56 #define TDA1004X_CONFC4 0x07
57 #define TDA1004X_DSSPARE2 0x0C
58 #define TDA10045H_CODE_IN 0x0D
59 #define TDA10045H_FWPAGE 0x0E
60 #define TDA1004X_SCAN_CPT 0x10
61 #define TDA1004X_DSP_CMD 0x11
62 #define TDA1004X_DSP_ARG 0x12
63 #define TDA1004X_DSP_DATA1 0x13
64 #define TDA1004X_DSP_DATA2 0x14
65 #define TDA1004X_CONFADC1 0x15
66 #define TDA1004X_CONFC1 0x16
67 #define TDA10045H_S_AGC 0x1a
68 #define TDA10046H_AGC_TUN_LEVEL 0x1a
69 #define TDA1004X_SNR 0x1c
70 #define TDA1004X_CONF_TS1 0x1e
71 #define TDA1004X_CONF_TS2 0x1f
72 #define TDA1004X_CBER_RESET 0x20
73 #define TDA1004X_CBER_MSB 0x21
74 #define TDA1004X_CBER_LSB 0x22
75 #define TDA1004X_CVBER_LUT 0x23
76 #define TDA1004X_VBER_MSB 0x24
77 #define TDA1004X_VBER_MID 0x25
78 #define TDA1004X_VBER_LSB 0x26
79 #define TDA1004X_UNCOR 0x27
81 #define TDA10045H_CONFPLL_P 0x2D
82 #define TDA10045H_CONFPLL_M_MSB 0x2E
83 #define TDA10045H_CONFPLL_M_LSB 0x2F
84 #define TDA10045H_CONFPLL_N 0x30
86 #define TDA10046H_CONFPLL1 0x2D
87 #define TDA10046H_CONFPLL2 0x2F
88 #define TDA10046H_CONFPLL3 0x30
89 #define TDA10046H_TIME_WREF1 0x31
90 #define TDA10046H_TIME_WREF2 0x32
91 #define TDA10046H_TIME_WREF3 0x33
92 #define TDA10046H_TIME_WREF4 0x34
93 #define TDA10046H_TIME_WREF5 0x35
95 #define TDA10045H_UNSURW_MSB 0x31
96 #define TDA10045H_UNSURW_LSB 0x32
97 #define TDA10045H_WREF_MSB 0x33
98 #define TDA10045H_WREF_MID 0x34
99 #define TDA10045H_WREF_LSB 0x35
100 #define TDA10045H_MUXOUT 0x36
101 #define TDA1004X_CONFADC2 0x37
103 #define TDA10045H_IOFFSET 0x38
105 #define TDA10046H_CONF_TRISTATE1 0x3B
106 #define TDA10046H_CONF_TRISTATE2 0x3C
107 #define TDA10046H_CONF_POLARITY 0x3D
108 #define TDA10046H_FREQ_OFFSET 0x3E
109 #define TDA10046H_GPIO_OUT_SEL 0x41
110 #define TDA10046H_GPIO_SELECT 0x42
111 #define TDA10046H_AGC_CONF 0x43
112 #define TDA10046H_AGC_THR 0x44
113 #define TDA10046H_AGC_RENORM 0x45
114 #define TDA10046H_AGC_GAINS 0x46
115 #define TDA10046H_AGC_TUN_MIN 0x47
116 #define TDA10046H_AGC_TUN_MAX 0x48
117 #define TDA10046H_AGC_IF_MIN 0x49
118 #define TDA10046H_AGC_IF_MAX 0x4A
120 #define TDA10046H_FREQ_PHY2_MSB 0x4D
121 #define TDA10046H_FREQ_PHY2_LSB 0x4E
123 #define TDA10046H_CVBER_CTRL 0x4F
124 #define TDA10046H_AGC_IF_LEVEL 0x52
125 #define TDA10046H_CODE_CPT 0x57
126 #define TDA10046H_CODE_IN 0x58
129 static int tda1004x_write_byteI(struct tda1004x_state
*state
, int reg
, int data
)
132 u8 buf
[] = { reg
, data
};
133 struct i2c_msg msg
= { .flags
= 0, .buf
= buf
, .len
= 2 };
135 dprintk("%s: reg=0x%x, data=0x%x\n", __FUNCTION__
, reg
, data
);
137 msg
.addr
= state
->config
->demod_address
;
138 ret
= i2c_transfer(state
->i2c
, &msg
, 1);
141 dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n",
142 __FUNCTION__
, reg
, data
, ret
);
144 dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __FUNCTION__
,
146 return (ret
!= 1) ? -1 : 0;
149 static int tda1004x_read_byte(struct tda1004x_state
*state
, int reg
)
154 struct i2c_msg msg
[] = {{ .flags
= 0, .buf
= b0
, .len
= 1 },
155 { .flags
= I2C_M_RD
, .buf
= b1
, .len
= 1 }};
157 dprintk("%s: reg=0x%x\n", __FUNCTION__
, reg
);
159 msg
[0].addr
= state
->config
->demod_address
;
160 msg
[1].addr
= state
->config
->demod_address
;
161 ret
= i2c_transfer(state
->i2c
, msg
, 2);
164 dprintk("%s: error reg=0x%x, ret=%i\n", __FUNCTION__
, reg
,
169 dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __FUNCTION__
,
174 static int tda1004x_write_mask(struct tda1004x_state
*state
, int reg
, int mask
, int data
)
177 dprintk("%s: reg=0x%x, mask=0x%x, data=0x%x\n", __FUNCTION__
, reg
,
180 // read a byte and check
181 val
= tda1004x_read_byte(state
, reg
);
189 // write it out again
190 return tda1004x_write_byteI(state
, reg
, val
);
193 static int tda1004x_write_buf(struct tda1004x_state
*state
, int reg
, unsigned char *buf
, int len
)
198 dprintk("%s: reg=0x%x, len=0x%x\n", __FUNCTION__
, reg
, len
);
201 for (i
= 0; i
< len
; i
++) {
202 result
= tda1004x_write_byteI(state
, reg
+ i
, buf
[i
]);
210 static int tda1004x_enable_tuner_i2c(struct tda1004x_state
*state
)
213 dprintk("%s\n", __FUNCTION__
);
215 result
= tda1004x_write_mask(state
, TDA1004X_CONFC4
, 2, 2);
220 static int tda1004x_disable_tuner_i2c(struct tda1004x_state
*state
)
222 dprintk("%s\n", __FUNCTION__
);
224 return tda1004x_write_mask(state
, TDA1004X_CONFC4
, 2, 0);
227 static int tda10045h_set_bandwidth(struct tda1004x_state
*state
,
228 fe_bandwidth_t bandwidth
)
230 static u8 bandwidth_6mhz
[] = { 0x02, 0x00, 0x3d, 0x00, 0x60, 0x1e, 0xa7, 0x45, 0x4f };
231 static u8 bandwidth_7mhz
[] = { 0x02, 0x00, 0x37, 0x00, 0x4a, 0x2f, 0x6d, 0x76, 0xdb };
232 static u8 bandwidth_8mhz
[] = { 0x02, 0x00, 0x3d, 0x00, 0x48, 0x17, 0x89, 0xc7, 0x14 };
235 case BANDWIDTH_6_MHZ
:
236 tda1004x_write_buf(state
, TDA10045H_CONFPLL_P
, bandwidth_6mhz
, sizeof(bandwidth_6mhz
));
239 case BANDWIDTH_7_MHZ
:
240 tda1004x_write_buf(state
, TDA10045H_CONFPLL_P
, bandwidth_7mhz
, sizeof(bandwidth_7mhz
));
243 case BANDWIDTH_8_MHZ
:
244 tda1004x_write_buf(state
, TDA10045H_CONFPLL_P
, bandwidth_8mhz
, sizeof(bandwidth_8mhz
));
251 tda1004x_write_byteI(state
, TDA10045H_IOFFSET
, 0);
256 static int tda10046h_set_bandwidth(struct tda1004x_state
*state
,
257 fe_bandwidth_t bandwidth
)
259 static u8 bandwidth_6mhz_53M
[] = { 0x7b, 0x2e, 0x11, 0xf0, 0xd2 };
260 static u8 bandwidth_7mhz_53M
[] = { 0x6a, 0x02, 0x6a, 0x43, 0x9f };
261 static u8 bandwidth_8mhz_53M
[] = { 0x5c, 0x32, 0xc2, 0x96, 0x6d };
263 static u8 bandwidth_6mhz_48M
[] = { 0x70, 0x02, 0x49, 0x24, 0x92 };
264 static u8 bandwidth_7mhz_48M
[] = { 0x60, 0x02, 0xaa, 0xaa, 0xab };
265 static u8 bandwidth_8mhz_48M
[] = { 0x54, 0x03, 0x0c, 0x30, 0xc3 };
268 if ((state
->config
->if_freq
== TDA10046_FREQ_045
) ||
269 (state
->config
->if_freq
== TDA10046_FREQ_052
))
274 case BANDWIDTH_6_MHZ
:
276 tda1004x_write_buf(state
, TDA10046H_TIME_WREF1
, bandwidth_6mhz_53M
,
277 sizeof(bandwidth_6mhz_53M
));
279 tda1004x_write_buf(state
, TDA10046H_TIME_WREF1
, bandwidth_6mhz_48M
,
280 sizeof(bandwidth_6mhz_48M
));
281 if (state
->config
->if_freq
== TDA10046_FREQ_045
) {
282 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_MSB
, 0x0a);
283 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_LSB
, 0xab);
287 case BANDWIDTH_7_MHZ
:
289 tda1004x_write_buf(state
, TDA10046H_TIME_WREF1
, bandwidth_7mhz_53M
,
290 sizeof(bandwidth_7mhz_53M
));
292 tda1004x_write_buf(state
, TDA10046H_TIME_WREF1
, bandwidth_7mhz_48M
,
293 sizeof(bandwidth_7mhz_48M
));
294 if (state
->config
->if_freq
== TDA10046_FREQ_045
) {
295 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_MSB
, 0x0c);
296 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_LSB
, 0x00);
300 case BANDWIDTH_8_MHZ
:
302 tda1004x_write_buf(state
, TDA10046H_TIME_WREF1
, bandwidth_8mhz_53M
,
303 sizeof(bandwidth_8mhz_53M
));
305 tda1004x_write_buf(state
, TDA10046H_TIME_WREF1
, bandwidth_8mhz_48M
,
306 sizeof(bandwidth_8mhz_48M
));
307 if (state
->config
->if_freq
== TDA10046_FREQ_045
) {
308 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_MSB
, 0x0d);
309 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_LSB
, 0x55);
320 static int tda1004x_do_upload(struct tda1004x_state
*state
,
321 unsigned char *mem
, unsigned int len
,
322 u8 dspCodeCounterReg
, u8 dspCodeInReg
)
325 struct i2c_msg fw_msg
= { .flags
= 0, .buf
= buf
, .len
= 0 };
329 /* clear code counter */
330 tda1004x_write_byteI(state
, dspCodeCounterReg
, 0);
331 fw_msg
.addr
= state
->config
->demod_address
;
333 buf
[0] = dspCodeInReg
;
335 // work out how much to send this time
341 memcpy(buf
+ 1, mem
+ pos
, tx_size
);
342 fw_msg
.len
= tx_size
+ 1;
343 if (i2c_transfer(state
->i2c
, &fw_msg
, 1) != 1) {
344 printk(KERN_ERR
"tda1004x: Error during firmware upload\n");
349 dprintk("%s: fw_pos=0x%x\n", __FUNCTION__
, pos
);
351 // give the DSP a chance to settle 03/10/05 Hac
357 static int tda1004x_check_upload_ok(struct tda1004x_state
*state
)
360 unsigned long timeout
;
362 if (state
->demod_type
== TDA1004X_DEMOD_TDA10046
) {
363 timeout
= jiffies
+ 2 * HZ
;
364 while(!(tda1004x_read_byte(state
, TDA1004X_STATUS_CD
) & 0x20)) {
365 if (time_after(jiffies
, timeout
)) {
366 printk(KERN_ERR
"tda1004x: timeout waiting for DSP ready\n");
374 // check upload was OK
375 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 0x10, 0); // we want to read from the DSP
376 tda1004x_write_byteI(state
, TDA1004X_DSP_CMD
, 0x67);
378 data1
= tda1004x_read_byte(state
, TDA1004X_DSP_DATA1
);
379 data2
= tda1004x_read_byte(state
, TDA1004X_DSP_DATA2
);
380 if (data1
!= 0x67 || data2
< 0x20 || data2
> 0x2e) {
381 printk(KERN_INFO
"tda1004x: found firmware revision %x -- invalid\n", data2
);
384 printk(KERN_INFO
"tda1004x: found firmware revision %x -- ok\n", data2
);
388 static int tda10045_fwupload(struct dvb_frontend
* fe
)
390 struct tda1004x_state
* state
= fe
->demodulator_priv
;
392 const struct firmware
*fw
;
394 /* don't re-upload unless necessary */
395 if (tda1004x_check_upload_ok(state
) == 0)
398 /* request the firmware, this will block until someone uploads it */
399 printk(KERN_INFO
"tda1004x: waiting for firmware upload (%s)...\n", TDA10045_DEFAULT_FIRMWARE
);
400 ret
= state
->config
->request_firmware(fe
, &fw
, TDA10045_DEFAULT_FIRMWARE
);
402 printk(KERN_ERR
"tda1004x: no firmware upload (timeout or file not found?)\n");
407 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 0x10, 0);
408 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 8, 8);
409 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 8, 0);
413 tda10045h_set_bandwidth(state
, BANDWIDTH_8_MHZ
);
415 ret
= tda1004x_do_upload(state
, fw
->data
, fw
->size
, TDA10045H_FWPAGE
, TDA10045H_CODE_IN
);
416 release_firmware(fw
);
419 printk(KERN_INFO
"tda1004x: firmware upload complete\n");
421 /* wait for DSP to initialise */
422 /* DSPREADY doesn't seem to work on the TDA10045H */
425 return tda1004x_check_upload_ok(state
);
428 static void tda10046_init_plls(struct dvb_frontend
* fe
)
430 struct tda1004x_state
* state
= fe
->demodulator_priv
;
433 if ((state
->config
->if_freq
== TDA10046_FREQ_045
) ||
434 (state
->config
->if_freq
== TDA10046_FREQ_052
))
439 tda1004x_write_byteI(state
, TDA10046H_CONFPLL1
, 0xf0);
440 if(tda10046_clk53m
) {
441 printk(KERN_INFO
"tda1004x: setting up plls for 53MHz sampling clock\n");
442 tda1004x_write_byteI(state
, TDA10046H_CONFPLL2
, 0x08); // PLL M = 8
444 printk(KERN_INFO
"tda1004x: setting up plls for 48MHz sampling clock\n");
445 tda1004x_write_byteI(state
, TDA10046H_CONFPLL2
, 0x03); // PLL M = 3
447 if (state
->config
->xtal_freq
== TDA10046_XTAL_4M
) {
448 dprintk("%s: setting up PLLs for a 4 MHz Xtal\n", __FUNCTION__
);
449 tda1004x_write_byteI(state
, TDA10046H_CONFPLL3
, 0); // PLL P = N = 0
451 dprintk("%s: setting up PLLs for a 16 MHz Xtal\n", __FUNCTION__
);
452 tda1004x_write_byteI(state
, TDA10046H_CONFPLL3
, 3); // PLL P = 0, N = 3
455 tda1004x_write_byteI(state
, TDA10046H_FREQ_OFFSET
, 0x67);
457 tda1004x_write_byteI(state
, TDA10046H_FREQ_OFFSET
, 0x72);
458 /* Note clock frequency is handled implicitly */
459 switch (state
->config
->if_freq
) {
460 case TDA10046_FREQ_045
:
461 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_MSB
, 0x0c);
462 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_LSB
, 0x00);
464 case TDA10046_FREQ_052
:
465 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_MSB
, 0x0d);
466 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_LSB
, 0xc7);
468 case TDA10046_FREQ_3617
:
469 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_MSB
, 0xd7);
470 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_LSB
, 0x59);
472 case TDA10046_FREQ_3613
:
473 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_MSB
, 0xd7);
474 tda1004x_write_byteI(state
, TDA10046H_FREQ_PHY2_LSB
, 0x3f);
477 tda10046h_set_bandwidth(state
, BANDWIDTH_8_MHZ
); // default bandwidth 8 MHz
478 /* let the PLLs settle */
482 static int tda10046_fwupload(struct dvb_frontend
* fe
)
484 struct tda1004x_state
* state
= fe
->demodulator_priv
;
486 const struct firmware
*fw
;
488 /* reset + wake up chip */
489 if (state
->config
->xtal_freq
== TDA10046_XTAL_4M
) {
490 tda1004x_write_byteI(state
, TDA1004X_CONFC4
, 0);
492 dprintk("%s: 16MHz Xtal, reducing I2C speed\n", __FUNCTION__
);
493 tda1004x_write_byteI(state
, TDA1004X_CONFC4
, 0x80);
495 tda1004x_write_mask(state
, TDA10046H_CONF_TRISTATE1
, 1, 0);
496 /* set GPIO 1 and 3 */
497 if (state
->config
->gpio_config
!= TDA10046_GPTRI
) {
498 tda1004x_write_byteI(state
, TDA10046H_CONF_TRISTATE2
, 0x33);
499 tda1004x_write_mask(state
, TDA10046H_CONF_POLARITY
, 0x0f, state
->config
->gpio_config
&0x0f);
501 /* let the clocks recover from sleep */
504 /* The PLLs need to be reprogrammed after sleep */
505 tda10046_init_plls(fe
);
506 tda1004x_write_mask(state
, TDA1004X_CONFADC2
, 0xc0, 0);
508 /* don't re-upload unless necessary */
509 if (tda1004x_check_upload_ok(state
) == 0)
512 printk(KERN_INFO
"tda1004x: trying to boot from eeprom\n");
513 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 4, 4);
515 /* don't re-upload unless necessary */
516 if (tda1004x_check_upload_ok(state
) == 0)
519 if (state
->config
->request_firmware
!= NULL
) {
520 /* request the firmware, this will block until someone uploads it */
521 printk(KERN_INFO
"tda1004x: waiting for firmware upload...\n");
522 ret
= state
->config
->request_firmware(fe
, &fw
, TDA10046_DEFAULT_FIRMWARE
);
524 /* remain compatible to old bug: try to load with tda10045 image name */
525 ret
= state
->config
->request_firmware(fe
, &fw
, TDA10045_DEFAULT_FIRMWARE
);
527 printk(KERN_ERR
"tda1004x: no firmware upload (timeout or file not found?)\n");
530 printk(KERN_INFO
"tda1004x: please rename the firmware file to %s\n",
531 TDA10046_DEFAULT_FIRMWARE
);
535 printk(KERN_ERR
"tda1004x: no request function defined, can't upload from file\n");
538 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 8, 8); // going to boot from HOST
539 ret
= tda1004x_do_upload(state
, fw
->data
, fw
->size
, TDA10046H_CODE_CPT
, TDA10046H_CODE_IN
);
540 release_firmware(fw
);
541 return tda1004x_check_upload_ok(state
);
544 static int tda1004x_encode_fec(int fec
)
546 // convert known FEC values
564 static int tda1004x_decode_fec(int tdafec
)
566 // convert known FEC values
584 static int tda1004x_write(struct dvb_frontend
* fe
, u8
*buf
, int len
)
586 struct tda1004x_state
* state
= fe
->demodulator_priv
;
591 return tda1004x_write_byteI(state
, buf
[0], buf
[1]);
594 static int tda10045_init(struct dvb_frontend
* fe
)
596 struct tda1004x_state
* state
= fe
->demodulator_priv
;
598 dprintk("%s\n", __FUNCTION__
);
600 if (tda10045_fwupload(fe
)) {
601 printk("tda1004x: firmware upload failed\n");
605 tda1004x_write_mask(state
, TDA1004X_CONFADC1
, 0x10, 0); // wake up the ADC
608 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 0x20, 0); // disable DSP watchdog timer
609 tda1004x_write_mask(state
, TDA1004X_AUTO
, 8, 0); // select HP stream
610 tda1004x_write_mask(state
, TDA1004X_CONFC1
, 0x40, 0); // set polarity of VAGC signal
611 tda1004x_write_mask(state
, TDA1004X_CONFC1
, 0x80, 0x80); // enable pulse killer
612 tda1004x_write_mask(state
, TDA1004X_AUTO
, 0x10, 0x10); // enable auto offset
613 tda1004x_write_mask(state
, TDA1004X_IN_CONF2
, 0xC0, 0x0); // no frequency offset
614 tda1004x_write_byteI(state
, TDA1004X_CONF_TS1
, 0); // setup MPEG2 TS interface
615 tda1004x_write_byteI(state
, TDA1004X_CONF_TS2
, 0); // setup MPEG2 TS interface
616 tda1004x_write_mask(state
, TDA1004X_VBER_MSB
, 0xe0, 0xa0); // 10^6 VBER measurement bits
617 tda1004x_write_mask(state
, TDA1004X_CONFC1
, 0x10, 0); // VAGC polarity
618 tda1004x_write_byteI(state
, TDA1004X_CONFADC1
, 0x2e);
620 tda1004x_write_mask(state
, 0x1f, 0x01, state
->config
->invert_oclk
);
625 static int tda10046_init(struct dvb_frontend
* fe
)
627 struct tda1004x_state
* state
= fe
->demodulator_priv
;
628 dprintk("%s\n", __FUNCTION__
);
630 if (tda10046_fwupload(fe
)) {
631 printk("tda1004x: firmware upload failed\n");
636 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 0x20, 0); // disable DSP watchdog timer
637 tda1004x_write_byteI(state
, TDA1004X_AUTO
, 0x87); // 100 ppm crystal, select HP stream
638 tda1004x_write_byteI(state
, TDA1004X_CONFC1
, 0x88); // enable pulse killer
640 switch (state
->config
->agc_config
) {
641 case TDA10046_AGC_DEFAULT
:
642 tda1004x_write_byteI(state
, TDA10046H_AGC_CONF
, 0x00); // AGC setup
643 tda1004x_write_mask(state
, TDA10046H_CONF_POLARITY
, 0xf0, 0x60); // set AGC polarities
645 case TDA10046_AGC_IFO_AUTO_NEG
:
646 tda1004x_write_byteI(state
, TDA10046H_AGC_CONF
, 0x0a); // AGC setup
647 tda1004x_write_mask(state
, TDA10046H_CONF_POLARITY
, 0xf0, 0x60); // set AGC polarities
649 case TDA10046_AGC_IFO_AUTO_POS
:
650 tda1004x_write_byteI(state
, TDA10046H_AGC_CONF
, 0x0a); // AGC setup
651 tda1004x_write_mask(state
, TDA10046H_CONF_POLARITY
, 0xf0, 0x00); // set AGC polarities
653 case TDA10046_AGC_TDA827X
:
654 tda1004x_write_byteI(state
, TDA10046H_AGC_CONF
, 0x02); // AGC setup
655 tda1004x_write_byteI(state
, TDA10046H_AGC_THR
, 0x70); // AGC Threshold
656 tda1004x_write_byteI(state
, TDA10046H_AGC_RENORM
, 0x08); // Gain Renormalize
657 tda1004x_write_mask(state
, TDA10046H_CONF_POLARITY
, 0xf0, 0x60); // set AGC polarities
660 if (state
->config
->ts_mode
== 0) {
661 tda1004x_write_mask(state
, TDA10046H_CONF_TRISTATE1
, 0xc0, 0x40);
662 tda1004x_write_mask(state
, 0x3a, 0x80, state
->config
->invert_oclk
<< 7);
664 tda1004x_write_mask(state
, TDA10046H_CONF_TRISTATE1
, 0xc0, 0x80);
665 tda1004x_write_mask(state
, TDA10046H_CONF_POLARITY
, 0x10,
666 state
->config
->invert_oclk
<< 4);
668 tda1004x_write_byteI(state
, TDA1004X_CONFADC2
, 0x38);
669 tda1004x_write_mask (state
, TDA10046H_CONF_TRISTATE1
, 0x3e, 0x38); // Turn IF AGC output on
670 tda1004x_write_byteI(state
, TDA10046H_AGC_TUN_MIN
, 0); // }
671 tda1004x_write_byteI(state
, TDA10046H_AGC_TUN_MAX
, 0xff); // } AGC min/max values
672 tda1004x_write_byteI(state
, TDA10046H_AGC_IF_MIN
, 0); // }
673 tda1004x_write_byteI(state
, TDA10046H_AGC_IF_MAX
, 0xff); // }
674 tda1004x_write_byteI(state
, TDA10046H_AGC_GAINS
, 0x12); // IF gain 2, TUN gain 1
675 tda1004x_write_byteI(state
, TDA10046H_CVBER_CTRL
, 0x1a); // 10^6 VBER measurement bits
676 tda1004x_write_byteI(state
, TDA1004X_CONF_TS1
, 7); // MPEG2 interface config
677 tda1004x_write_byteI(state
, TDA1004X_CONF_TS2
, 0xc0); // MPEG2 interface config
678 // tda1004x_write_mask(state, 0x50, 0x80, 0x80); // handle out of guard echoes
683 static int tda1004x_set_fe(struct dvb_frontend
* fe
,
684 struct dvb_frontend_parameters
*fe_params
)
686 struct tda1004x_state
* state
= fe
->demodulator_priv
;
690 dprintk("%s\n", __FUNCTION__
);
692 if (state
->demod_type
== TDA1004X_DEMOD_TDA10046
) {
694 tda1004x_write_mask(state
, TDA1004X_AUTO
, 0x10, 0x10);
695 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x80, 0);
696 tda1004x_write_mask(state
, TDA1004X_IN_CONF2
, 0xC0, 0);
698 // disable agc_conf[2]
699 tda1004x_write_mask(state
, TDA10046H_AGC_CONF
, 4, 0);
703 if (fe
->ops
.tuner_ops
.set_params
) {
704 fe
->ops
.tuner_ops
.set_params(fe
, fe_params
);
705 if (fe
->ops
.i2c_gate_ctrl
)
706 fe
->ops
.i2c_gate_ctrl(fe
, 0);
709 // Hardcoded to use auto as much as possible on the TDA10045 as it
710 // is very unreliable if AUTO mode is _not_ used.
711 if (state
->demod_type
== TDA1004X_DEMOD_TDA10045
) {
712 fe_params
->u
.ofdm
.code_rate_HP
= FEC_AUTO
;
713 fe_params
->u
.ofdm
.guard_interval
= GUARD_INTERVAL_AUTO
;
714 fe_params
->u
.ofdm
.transmission_mode
= TRANSMISSION_MODE_AUTO
;
717 // Set standard params.. or put them to auto
718 if ((fe_params
->u
.ofdm
.code_rate_HP
== FEC_AUTO
) ||
719 (fe_params
->u
.ofdm
.code_rate_LP
== FEC_AUTO
) ||
720 (fe_params
->u
.ofdm
.constellation
== QAM_AUTO
) ||
721 (fe_params
->u
.ofdm
.hierarchy_information
== HIERARCHY_AUTO
)) {
722 tda1004x_write_mask(state
, TDA1004X_AUTO
, 1, 1); // enable auto
723 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x03, 0); // turn off constellation bits
724 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x60, 0); // turn off hierarchy bits
725 tda1004x_write_mask(state
, TDA1004X_IN_CONF2
, 0x3f, 0); // turn off FEC bits
727 tda1004x_write_mask(state
, TDA1004X_AUTO
, 1, 0); // disable auto
730 tmp
= tda1004x_encode_fec(fe_params
->u
.ofdm
.code_rate_HP
);
733 tda1004x_write_mask(state
, TDA1004X_IN_CONF2
, 7, tmp
);
736 tmp
= tda1004x_encode_fec(fe_params
->u
.ofdm
.code_rate_LP
);
739 tda1004x_write_mask(state
, TDA1004X_IN_CONF2
, 0x38, tmp
<< 3);
742 switch (fe_params
->u
.ofdm
.constellation
) {
744 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 3, 0);
748 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 3, 1);
752 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 3, 2);
760 switch (fe_params
->u
.ofdm
.hierarchy_information
) {
762 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x60, 0 << 5);
766 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x60, 1 << 5);
770 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x60, 2 << 5);
774 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x60, 3 << 5);
783 switch (state
->demod_type
) {
784 case TDA1004X_DEMOD_TDA10045
:
785 tda10045h_set_bandwidth(state
, fe_params
->u
.ofdm
.bandwidth
);
788 case TDA1004X_DEMOD_TDA10046
:
789 tda10046h_set_bandwidth(state
, fe_params
->u
.ofdm
.bandwidth
);
794 inversion
= fe_params
->inversion
;
795 if (state
->config
->invert
)
796 inversion
= inversion
? INVERSION_OFF
: INVERSION_ON
;
799 tda1004x_write_mask(state
, TDA1004X_CONFC1
, 0x20, 0);
803 tda1004x_write_mask(state
, TDA1004X_CONFC1
, 0x20, 0x20);
810 // set guard interval
811 switch (fe_params
->u
.ofdm
.guard_interval
) {
812 case GUARD_INTERVAL_1_32
:
813 tda1004x_write_mask(state
, TDA1004X_AUTO
, 2, 0);
814 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x0c, 0 << 2);
817 case GUARD_INTERVAL_1_16
:
818 tda1004x_write_mask(state
, TDA1004X_AUTO
, 2, 0);
819 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x0c, 1 << 2);
822 case GUARD_INTERVAL_1_8
:
823 tda1004x_write_mask(state
, TDA1004X_AUTO
, 2, 0);
824 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x0c, 2 << 2);
827 case GUARD_INTERVAL_1_4
:
828 tda1004x_write_mask(state
, TDA1004X_AUTO
, 2, 0);
829 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x0c, 3 << 2);
832 case GUARD_INTERVAL_AUTO
:
833 tda1004x_write_mask(state
, TDA1004X_AUTO
, 2, 2);
834 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x0c, 0 << 2);
841 // set transmission mode
842 switch (fe_params
->u
.ofdm
.transmission_mode
) {
843 case TRANSMISSION_MODE_2K
:
844 tda1004x_write_mask(state
, TDA1004X_AUTO
, 4, 0);
845 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x10, 0 << 4);
848 case TRANSMISSION_MODE_8K
:
849 tda1004x_write_mask(state
, TDA1004X_AUTO
, 4, 0);
850 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x10, 1 << 4);
853 case TRANSMISSION_MODE_AUTO
:
854 tda1004x_write_mask(state
, TDA1004X_AUTO
, 4, 4);
855 tda1004x_write_mask(state
, TDA1004X_IN_CONF1
, 0x10, 0);
863 switch (state
->demod_type
) {
864 case TDA1004X_DEMOD_TDA10045
:
865 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 8, 8);
866 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 8, 0);
869 case TDA1004X_DEMOD_TDA10046
:
870 tda1004x_write_mask(state
, TDA1004X_AUTO
, 0x40, 0x40);
872 tda1004x_write_mask(state
, TDA10046H_AGC_CONF
, 4, 1);
881 static int tda1004x_get_fe(struct dvb_frontend
* fe
, struct dvb_frontend_parameters
*fe_params
)
883 struct tda1004x_state
* state
= fe
->demodulator_priv
;
885 dprintk("%s\n", __FUNCTION__
);
888 fe_params
->inversion
= INVERSION_OFF
;
889 if (tda1004x_read_byte(state
, TDA1004X_CONFC1
) & 0x20)
890 fe_params
->inversion
= INVERSION_ON
;
891 if (state
->config
->invert
)
892 fe_params
->inversion
= fe_params
->inversion
? INVERSION_OFF
: INVERSION_ON
;
895 switch (state
->demod_type
) {
896 case TDA1004X_DEMOD_TDA10045
:
897 switch (tda1004x_read_byte(state
, TDA10045H_WREF_LSB
)) {
899 fe_params
->u
.ofdm
.bandwidth
= BANDWIDTH_8_MHZ
;
902 fe_params
->u
.ofdm
.bandwidth
= BANDWIDTH_7_MHZ
;
905 fe_params
->u
.ofdm
.bandwidth
= BANDWIDTH_6_MHZ
;
909 case TDA1004X_DEMOD_TDA10046
:
910 switch (tda1004x_read_byte(state
, TDA10046H_TIME_WREF1
)) {
913 fe_params
->u
.ofdm
.bandwidth
= BANDWIDTH_8_MHZ
;
917 fe_params
->u
.ofdm
.bandwidth
= BANDWIDTH_7_MHZ
;
921 fe_params
->u
.ofdm
.bandwidth
= BANDWIDTH_6_MHZ
;
928 fe_params
->u
.ofdm
.code_rate_HP
=
929 tda1004x_decode_fec(tda1004x_read_byte(state
, TDA1004X_OUT_CONF2
) & 7);
930 fe_params
->u
.ofdm
.code_rate_LP
=
931 tda1004x_decode_fec((tda1004x_read_byte(state
, TDA1004X_OUT_CONF2
) >> 3) & 7);
934 switch (tda1004x_read_byte(state
, TDA1004X_OUT_CONF1
) & 3) {
936 fe_params
->u
.ofdm
.constellation
= QPSK
;
939 fe_params
->u
.ofdm
.constellation
= QAM_16
;
942 fe_params
->u
.ofdm
.constellation
= QAM_64
;
947 fe_params
->u
.ofdm
.transmission_mode
= TRANSMISSION_MODE_2K
;
948 if (tda1004x_read_byte(state
, TDA1004X_OUT_CONF1
) & 0x10)
949 fe_params
->u
.ofdm
.transmission_mode
= TRANSMISSION_MODE_8K
;
952 switch ((tda1004x_read_byte(state
, TDA1004X_OUT_CONF1
) & 0x0c) >> 2) {
954 fe_params
->u
.ofdm
.guard_interval
= GUARD_INTERVAL_1_32
;
957 fe_params
->u
.ofdm
.guard_interval
= GUARD_INTERVAL_1_16
;
960 fe_params
->u
.ofdm
.guard_interval
= GUARD_INTERVAL_1_8
;
963 fe_params
->u
.ofdm
.guard_interval
= GUARD_INTERVAL_1_4
;
968 switch ((tda1004x_read_byte(state
, TDA1004X_OUT_CONF1
) & 0x60) >> 5) {
970 fe_params
->u
.ofdm
.hierarchy_information
= HIERARCHY_NONE
;
973 fe_params
->u
.ofdm
.hierarchy_information
= HIERARCHY_1
;
976 fe_params
->u
.ofdm
.hierarchy_information
= HIERARCHY_2
;
979 fe_params
->u
.ofdm
.hierarchy_information
= HIERARCHY_4
;
986 static int tda1004x_read_status(struct dvb_frontend
* fe
, fe_status_t
* fe_status
)
988 struct tda1004x_state
* state
= fe
->demodulator_priv
;
993 dprintk("%s\n", __FUNCTION__
);
996 status
= tda1004x_read_byte(state
, TDA1004X_STATUS_CD
);
1003 *fe_status
|= FE_HAS_SIGNAL
;
1005 *fe_status
|= FE_HAS_CARRIER
;
1007 *fe_status
|= FE_HAS_VITERBI
| FE_HAS_SYNC
| FE_HAS_LOCK
;
1009 // if we don't already have VITERBI (i.e. not LOCKED), see if the viterbi
1010 // is getting anything valid
1011 if (!(*fe_status
& FE_HAS_VITERBI
)) {
1013 cber
= tda1004x_read_byte(state
, TDA1004X_CBER_LSB
);
1016 status
= tda1004x_read_byte(state
, TDA1004X_CBER_MSB
);
1019 cber
|= (status
<< 8);
1020 // The address 0x20 should be read to cope with a TDA10046 bug
1021 tda1004x_read_byte(state
, TDA1004X_CBER_RESET
);
1024 *fe_status
|= FE_HAS_VITERBI
;
1027 // if we DO have some valid VITERBI output, but don't already have SYNC
1028 // bytes (i.e. not LOCKED), see if the RS decoder is getting anything valid.
1029 if ((*fe_status
& FE_HAS_VITERBI
) && (!(*fe_status
& FE_HAS_SYNC
))) {
1031 vber
= tda1004x_read_byte(state
, TDA1004X_VBER_LSB
);
1034 status
= tda1004x_read_byte(state
, TDA1004X_VBER_MID
);
1037 vber
|= (status
<< 8);
1038 status
= tda1004x_read_byte(state
, TDA1004X_VBER_MSB
);
1041 vber
|= (status
& 0x0f) << 16;
1042 // The CVBER_LUT should be read to cope with TDA10046 hardware bug
1043 tda1004x_read_byte(state
, TDA1004X_CVBER_LUT
);
1045 // if RS has passed some valid TS packets, then we must be
1046 // getting some SYNC bytes
1048 *fe_status
|= FE_HAS_SYNC
;
1052 dprintk("%s: fe_status=0x%x\n", __FUNCTION__
, *fe_status
);
1056 static int tda1004x_read_signal_strength(struct dvb_frontend
* fe
, u16
* signal
)
1058 struct tda1004x_state
* state
= fe
->demodulator_priv
;
1062 dprintk("%s\n", __FUNCTION__
);
1064 // determine the register to use
1065 switch (state
->demod_type
) {
1066 case TDA1004X_DEMOD_TDA10045
:
1067 reg
= TDA10045H_S_AGC
;
1070 case TDA1004X_DEMOD_TDA10046
:
1071 reg
= TDA10046H_AGC_IF_LEVEL
;
1076 tmp
= tda1004x_read_byte(state
, reg
);
1080 *signal
= (tmp
<< 8) | tmp
;
1081 dprintk("%s: signal=0x%x\n", __FUNCTION__
, *signal
);
1085 static int tda1004x_read_snr(struct dvb_frontend
* fe
, u16
* snr
)
1087 struct tda1004x_state
* state
= fe
->demodulator_priv
;
1090 dprintk("%s\n", __FUNCTION__
);
1093 tmp
= tda1004x_read_byte(state
, TDA1004X_SNR
);
1098 *snr
= ((tmp
<< 8) | tmp
);
1099 dprintk("%s: snr=0x%x\n", __FUNCTION__
, *snr
);
1103 static int tda1004x_read_ucblocks(struct dvb_frontend
* fe
, u32
* ucblocks
)
1105 struct tda1004x_state
* state
= fe
->demodulator_priv
;
1110 dprintk("%s\n", __FUNCTION__
);
1112 // read the UCBLOCKS and reset
1114 tmp
= tda1004x_read_byte(state
, TDA1004X_UNCOR
);
1118 while (counter
++ < 5) {
1119 tda1004x_write_mask(state
, TDA1004X_UNCOR
, 0x80, 0);
1120 tda1004x_write_mask(state
, TDA1004X_UNCOR
, 0x80, 0);
1121 tda1004x_write_mask(state
, TDA1004X_UNCOR
, 0x80, 0);
1123 tmp2
= tda1004x_read_byte(state
, TDA1004X_UNCOR
);
1127 if ((tmp2
< tmp
) || (tmp2
== 0))
1134 *ucblocks
= 0xffffffff;
1136 dprintk("%s: ucblocks=0x%x\n", __FUNCTION__
, *ucblocks
);
1140 static int tda1004x_read_ber(struct dvb_frontend
* fe
, u32
* ber
)
1142 struct tda1004x_state
* state
= fe
->demodulator_priv
;
1145 dprintk("%s\n", __FUNCTION__
);
1148 tmp
= tda1004x_read_byte(state
, TDA1004X_CBER_LSB
);
1152 tmp
= tda1004x_read_byte(state
, TDA1004X_CBER_MSB
);
1156 // The address 0x20 should be read to cope with a TDA10046 bug
1157 tda1004x_read_byte(state
, TDA1004X_CBER_RESET
);
1159 dprintk("%s: ber=0x%x\n", __FUNCTION__
, *ber
);
1163 static int tda1004x_sleep(struct dvb_frontend
* fe
)
1165 struct tda1004x_state
* state
= fe
->demodulator_priv
;
1168 switch (state
->demod_type
) {
1169 case TDA1004X_DEMOD_TDA10045
:
1170 tda1004x_write_mask(state
, TDA1004X_CONFADC1
, 0x10, 0x10);
1173 case TDA1004X_DEMOD_TDA10046
:
1174 /* set outputs to tristate */
1175 tda1004x_write_byteI(state
, TDA10046H_CONF_TRISTATE1
, 0xff);
1176 /* invert GPIO 1 and 3 if desired*/
1177 gpio_conf
= state
->config
->gpio_config
;
1178 if (gpio_conf
>= TDA10046_GP00_I
)
1179 tda1004x_write_mask(state
, TDA10046H_CONF_POLARITY
, 0x0f,
1180 (gpio_conf
& 0x0f) ^ 0x0a);
1182 tda1004x_write_mask(state
, TDA1004X_CONFADC2
, 0xc0, 0xc0);
1183 tda1004x_write_mask(state
, TDA1004X_CONFC4
, 1, 1);
1190 static int tda1004x_i2c_gate_ctrl(struct dvb_frontend
* fe
, int enable
)
1192 struct tda1004x_state
* state
= fe
->demodulator_priv
;
1195 return tda1004x_enable_tuner_i2c(state
);
1197 return tda1004x_disable_tuner_i2c(state
);
1201 static int tda1004x_get_tune_settings(struct dvb_frontend
* fe
, struct dvb_frontend_tune_settings
* fesettings
)
1203 fesettings
->min_delay_ms
= 800;
1204 /* Drift compensation makes no sense for DVB-T */
1205 fesettings
->step_size
= 0;
1206 fesettings
->max_drift
= 0;
1210 static void tda1004x_release(struct dvb_frontend
* fe
)
1212 struct tda1004x_state
*state
= fe
->demodulator_priv
;
1216 static struct dvb_frontend_ops tda10045_ops
= {
1218 .name
= "Philips TDA10045H DVB-T",
1220 .frequency_min
= 51000000,
1221 .frequency_max
= 858000000,
1222 .frequency_stepsize
= 166667,
1224 FE_CAN_FEC_1_2
| FE_CAN_FEC_2_3
| FE_CAN_FEC_3_4
|
1225 FE_CAN_FEC_5_6
| FE_CAN_FEC_7_8
| FE_CAN_FEC_AUTO
|
1226 FE_CAN_QPSK
| FE_CAN_QAM_16
| FE_CAN_QAM_64
| FE_CAN_QAM_AUTO
|
1227 FE_CAN_TRANSMISSION_MODE_AUTO
| FE_CAN_GUARD_INTERVAL_AUTO
1230 .release
= tda1004x_release
,
1232 .init
= tda10045_init
,
1233 .sleep
= tda1004x_sleep
,
1234 .write
= tda1004x_write
,
1235 .i2c_gate_ctrl
= tda1004x_i2c_gate_ctrl
,
1237 .set_frontend
= tda1004x_set_fe
,
1238 .get_frontend
= tda1004x_get_fe
,
1239 .get_tune_settings
= tda1004x_get_tune_settings
,
1241 .read_status
= tda1004x_read_status
,
1242 .read_ber
= tda1004x_read_ber
,
1243 .read_signal_strength
= tda1004x_read_signal_strength
,
1244 .read_snr
= tda1004x_read_snr
,
1245 .read_ucblocks
= tda1004x_read_ucblocks
,
1248 struct dvb_frontend
* tda10045_attach(const struct tda1004x_config
* config
,
1249 struct i2c_adapter
* i2c
)
1251 struct tda1004x_state
*state
;
1253 /* allocate memory for the internal state */
1254 state
= kmalloc(sizeof(struct tda1004x_state
), GFP_KERNEL
);
1258 /* setup the state */
1259 state
->config
= config
;
1261 state
->demod_type
= TDA1004X_DEMOD_TDA10045
;
1263 /* check if the demod is there */
1264 if (tda1004x_read_byte(state
, TDA1004X_CHIPID
) != 0x25) {
1269 /* create dvb_frontend */
1270 memcpy(&state
->frontend
.ops
, &tda10045_ops
, sizeof(struct dvb_frontend_ops
));
1271 state
->frontend
.demodulator_priv
= state
;
1272 return &state
->frontend
;
1275 static struct dvb_frontend_ops tda10046_ops
= {
1277 .name
= "Philips TDA10046H DVB-T",
1279 .frequency_min
= 51000000,
1280 .frequency_max
= 858000000,
1281 .frequency_stepsize
= 166667,
1283 FE_CAN_FEC_1_2
| FE_CAN_FEC_2_3
| FE_CAN_FEC_3_4
|
1284 FE_CAN_FEC_5_6
| FE_CAN_FEC_7_8
| FE_CAN_FEC_AUTO
|
1285 FE_CAN_QPSK
| FE_CAN_QAM_16
| FE_CAN_QAM_64
| FE_CAN_QAM_AUTO
|
1286 FE_CAN_TRANSMISSION_MODE_AUTO
| FE_CAN_GUARD_INTERVAL_AUTO
1289 .release
= tda1004x_release
,
1291 .init
= tda10046_init
,
1292 .sleep
= tda1004x_sleep
,
1293 .write
= tda1004x_write
,
1294 .i2c_gate_ctrl
= tda1004x_i2c_gate_ctrl
,
1296 .set_frontend
= tda1004x_set_fe
,
1297 .get_frontend
= tda1004x_get_fe
,
1298 .get_tune_settings
= tda1004x_get_tune_settings
,
1300 .read_status
= tda1004x_read_status
,
1301 .read_ber
= tda1004x_read_ber
,
1302 .read_signal_strength
= tda1004x_read_signal_strength
,
1303 .read_snr
= tda1004x_read_snr
,
1304 .read_ucblocks
= tda1004x_read_ucblocks
,
1307 struct dvb_frontend
* tda10046_attach(const struct tda1004x_config
* config
,
1308 struct i2c_adapter
* i2c
)
1310 struct tda1004x_state
*state
;
1312 /* allocate memory for the internal state */
1313 state
= kmalloc(sizeof(struct tda1004x_state
), GFP_KERNEL
);
1317 /* setup the state */
1318 state
->config
= config
;
1320 state
->demod_type
= TDA1004X_DEMOD_TDA10046
;
1322 /* check if the demod is there */
1323 if (tda1004x_read_byte(state
, TDA1004X_CHIPID
) != 0x46) {
1328 /* create dvb_frontend */
1329 memcpy(&state
->frontend
.ops
, &tda10046_ops
, sizeof(struct dvb_frontend_ops
));
1330 state
->frontend
.demodulator_priv
= state
;
1331 return &state
->frontend
;
1334 module_param(debug
, int, 0644);
1335 MODULE_PARM_DESC(debug
, "Turn on/off frontend debugging (default:off).");
1337 MODULE_DESCRIPTION("Philips TDA10045H & TDA10046H DVB-T Demodulator");
1338 MODULE_AUTHOR("Andrew de Quincey & Robert Schlabbach");
1339 MODULE_LICENSE("GPL");
1341 EXPORT_SYMBOL(tda10045_attach
);
1342 EXPORT_SYMBOL(tda10046_attach
);