2 Driver for Samsung S5H1420 QPSK Demodulator
4 Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net>
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 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/string.h>
27 #include <linux/slab.h>
28 #include <linux/delay.h>
29 #include <linux/jiffies.h>
30 #include <asm/div64.h>
32 #include "dvb_frontend.h"
37 #define TONE_FREQ 22000
39 struct s5h1420_state
{
40 struct i2c_adapter
* i2c
;
41 const struct s5h1420_config
* config
;
42 struct dvb_frontend frontend
;
47 fe_code_rate_t fec_inner
;
51 static u32
s5h1420_getsymbolrate(struct s5h1420_state
* state
);
52 static int s5h1420_get_tune_settings(struct dvb_frontend
* fe
,
53 struct dvb_frontend_tune_settings
* fesettings
);
57 #define dprintk if (debug) printk
59 static int s5h1420_writereg (struct s5h1420_state
* state
, u8 reg
, u8 data
)
61 u8 buf
[] = { reg
, data
};
62 struct i2c_msg msg
= { .addr
= state
->config
->demod_address
, .flags
= 0, .buf
= buf
, .len
= 2 };
65 if ((err
= i2c_transfer (state
->i2c
, &msg
, 1)) != 1) {
66 dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__
, err
, reg
, data
);
73 static u8
s5h1420_readreg (struct s5h1420_state
* state
, u8 reg
)
78 struct i2c_msg msg1
= { .addr
= state
->config
->demod_address
, .flags
= 0, .buf
= b0
, .len
= 1 };
79 struct i2c_msg msg2
= { .addr
= state
->config
->demod_address
, .flags
= I2C_M_RD
, .buf
= b1
, .len
= 1 };
81 if ((ret
= i2c_transfer (state
->i2c
, &msg1
, 1)) != 1)
84 if ((ret
= i2c_transfer (state
->i2c
, &msg2
, 1)) != 1)
90 static int s5h1420_set_voltage (struct dvb_frontend
* fe
, fe_sec_voltage_t voltage
)
92 struct s5h1420_state
* state
= fe
->demodulator_priv
;
96 s5h1420_writereg(state
, 0x3c,
97 (s5h1420_readreg(state
, 0x3c) & 0xfe) | 0x02);
101 s5h1420_writereg(state
, 0x3c, s5h1420_readreg(state
, 0x3c) | 0x03);
104 case SEC_VOLTAGE_OFF
:
105 s5h1420_writereg(state
, 0x3c, s5h1420_readreg(state
, 0x3c) & 0xfd);
112 static int s5h1420_set_tone (struct dvb_frontend
* fe
, fe_sec_tone_mode_t tone
)
114 struct s5h1420_state
* state
= fe
->demodulator_priv
;
118 s5h1420_writereg(state
, 0x3b,
119 (s5h1420_readreg(state
, 0x3b) & 0x74) | 0x08);
123 s5h1420_writereg(state
, 0x3b,
124 (s5h1420_readreg(state
, 0x3b) & 0x74) | 0x01);
131 static int s5h1420_send_master_cmd (struct dvb_frontend
* fe
,
132 struct dvb_diseqc_master_cmd
* cmd
)
134 struct s5h1420_state
* state
= fe
->demodulator_priv
;
137 unsigned long timeout
;
140 if (cmd
->msg_len
> 8)
143 /* setup for DISEQC */
144 val
= s5h1420_readreg(state
, 0x3b);
145 s5h1420_writereg(state
, 0x3b, 0x02);
148 /* write the DISEQC command bytes */
149 for(i
=0; i
< cmd
->msg_len
; i
++) {
150 s5h1420_writereg(state
, 0x3d + i
, cmd
->msg
[i
]);
153 /* kick off transmission */
154 s5h1420_writereg(state
, 0x3b, s5h1420_readreg(state
, 0x3b) |
155 ((cmd
->msg_len
-1) << 4) | 0x08);
157 /* wait for transmission to complete */
158 timeout
= jiffies
+ ((100*HZ
) / 1000);
159 while(time_before(jiffies
, timeout
)) {
160 if (!(s5h1420_readreg(state
, 0x3b) & 0x08))
165 if (time_after(jiffies
, timeout
))
168 /* restore original settings */
169 s5h1420_writereg(state
, 0x3b, val
);
174 static int s5h1420_recv_slave_reply (struct dvb_frontend
* fe
,
175 struct dvb_diseqc_slave_reply
* reply
)
177 struct s5h1420_state
* state
= fe
->demodulator_priv
;
181 unsigned long timeout
;
184 /* setup for DISEQC recieve */
185 val
= s5h1420_readreg(state
, 0x3b);
186 s5h1420_writereg(state
, 0x3b, 0x82); /* FIXME: guess - do we need to set DIS_RDY(0x08) in receive mode? */
189 /* wait for reception to complete */
190 timeout
= jiffies
+ ((reply
->timeout
*HZ
) / 1000);
191 while(time_before(jiffies
, timeout
)) {
192 if (!(s5h1420_readreg(state
, 0x3b) & 0x80)) /* FIXME: do we test DIS_RDY(0x08) or RCV_EN(0x80)? */
197 if (time_after(jiffies
, timeout
)) {
202 /* check error flag - FIXME: not sure what this does - docs do not describe
203 * beyond "error flag for diseqc receive data :( */
204 if (s5h1420_readreg(state
, 0x49)) {
210 length
= (s5h1420_readreg(state
, 0x3b) & 0x70) >> 4;
211 if (length
> sizeof(reply
->msg
)) {
215 reply
->msg_len
= length
;
218 for(i
=0; i
< length
; i
++) {
219 reply
->msg
[i
] = s5h1420_readreg(state
, 0x3d + i
);
223 /* restore original settings */
224 s5h1420_writereg(state
, 0x3b, val
);
229 static int s5h1420_send_burst (struct dvb_frontend
* fe
, fe_sec_mini_cmd_t minicmd
)
231 struct s5h1420_state
* state
= fe
->demodulator_priv
;
234 unsigned long timeout
;
236 /* setup for tone burst */
237 val
= s5h1420_readreg(state
, 0x3b);
238 s5h1420_writereg(state
, 0x3b, (s5h1420_readreg(state
, 0x3b) & 0x70) | 0x01);
240 /* set value for B position if requested */
241 if (minicmd
== SEC_MINI_B
) {
242 s5h1420_writereg(state
, 0x3b, s5h1420_readreg(state
, 0x3b) | 0x04);
246 /* start transmission */
247 s5h1420_writereg(state
, 0x3b, s5h1420_readreg(state
, 0x3b) | 0x08);
249 /* wait for transmission to complete */
250 timeout
= jiffies
+ ((100*HZ
) / 1000);
251 while(time_before(jiffies
, timeout
)) {
252 if (!(s5h1420_readreg(state
, 0x3b) & 0x08))
257 if (time_after(jiffies
, timeout
))
260 /* restore original settings */
261 s5h1420_writereg(state
, 0x3b, val
);
266 static fe_status_t
s5h1420_get_status_bits(struct s5h1420_state
* state
)
269 fe_status_t status
= 0;
271 val
= s5h1420_readreg(state
, 0x14);
273 status
|= FE_HAS_SIGNAL
;
275 status
|= FE_HAS_CARRIER
;
276 val
= s5h1420_readreg(state
, 0x36);
278 status
|= FE_HAS_VITERBI
;
280 status
|= FE_HAS_SYNC
;
281 if (status
== (FE_HAS_SIGNAL
|FE_HAS_CARRIER
|FE_HAS_VITERBI
|FE_HAS_SYNC
))
282 status
|= FE_HAS_LOCK
;
287 static int s5h1420_read_status(struct dvb_frontend
* fe
, fe_status_t
* status
)
289 struct s5h1420_state
* state
= fe
->demodulator_priv
;
295 /* determine lock state */
296 *status
= s5h1420_get_status_bits(state
);
298 /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert
299 the inversion, wait a bit and check again */
300 if (*status
== (FE_HAS_SIGNAL
|FE_HAS_CARRIER
|FE_HAS_VITERBI
)) {
301 val
= s5h1420_readreg(state
, 0x32);
302 if ((val
& 0x07) == 0x03) {
304 s5h1420_writereg(state
, 0x31, 0x13);
306 s5h1420_writereg(state
, 0x31, 0x1b);
308 /* wait a bit then update lock status */
310 *status
= s5h1420_get_status_bits(state
);
314 /* perform post lock setup */
315 if ((*status
& FE_HAS_LOCK
) && (!state
->postlocked
)) {
317 /* calculate the data rate */
318 u32 tmp
= s5h1420_getsymbolrate(state
);
319 switch(s5h1420_readreg(state
, 0x32) & 0x07) {
321 tmp
= (tmp
* 2 * 1) / 2;
325 tmp
= (tmp
* 2 * 2) / 3;
329 tmp
= (tmp
* 2 * 3) / 4;
333 tmp
= (tmp
* 2 * 5) / 6;
337 tmp
= (tmp
* 2 * 6) / 7;
341 tmp
= (tmp
* 2 * 7) / 8;
345 printk("s5h1420: avoided division by 0\n");
348 tmp
= state
->fclk
/ tmp
;
350 /* set the MPEG_CLK_INTL for the calculated data rate */
365 s5h1420_writereg(state
, 0x22, val
);
368 s5h1420_writereg(state
, 0x1f, s5h1420_readreg(state
, 0x1f) | 0x01);
370 /* kicker disable + remove DC offset */
371 s5h1420_writereg(state
, 0x05, s5h1420_readreg(state
, 0x05) & 0x6f);
373 /* post-lock processing has been done! */
374 state
->postlocked
= 1;
380 static int s5h1420_read_ber(struct dvb_frontend
* fe
, u32
* ber
)
382 struct s5h1420_state
* state
= fe
->demodulator_priv
;
384 s5h1420_writereg(state
, 0x46, 0x1d);
387 *ber
= (s5h1420_readreg(state
, 0x48) << 8) | s5h1420_readreg(state
, 0x47);
392 static int s5h1420_read_signal_strength(struct dvb_frontend
* fe
, u16
* strength
)
394 struct s5h1420_state
* state
= fe
->demodulator_priv
;
396 u8 val
= s5h1420_readreg(state
, 0x15);
398 *strength
= (u16
) ((val
<< 8) | val
);
403 static int s5h1420_read_ucblocks(struct dvb_frontend
* fe
, u32
* ucblocks
)
405 struct s5h1420_state
* state
= fe
->demodulator_priv
;
407 s5h1420_writereg(state
, 0x46, 0x1f);
410 *ucblocks
= (s5h1420_readreg(state
, 0x48) << 8) | s5h1420_readreg(state
, 0x47);
415 static void s5h1420_reset(struct s5h1420_state
* state
)
417 s5h1420_writereg (state
, 0x01, 0x08);
418 s5h1420_writereg (state
, 0x01, 0x00);
422 static void s5h1420_setsymbolrate(struct s5h1420_state
* state
,
423 struct dvb_frontend_parameters
*p
)
427 val
= ((u64
) p
->u
.qpsk
.symbol_rate
/ 1000ULL) * (1ULL<<24);
428 if (p
->u
.qpsk
.symbol_rate
<= 21000000) {
431 do_div(val
, (state
->fclk
/ 1000));
433 s5h1420_writereg(state
, 0x09, s5h1420_readreg(state
, 0x09) & 0x7f);
434 s5h1420_writereg(state
, 0x11, val
>> 16);
435 s5h1420_writereg(state
, 0x12, val
>> 8);
436 s5h1420_writereg(state
, 0x13, val
& 0xff);
437 s5h1420_writereg(state
, 0x09, s5h1420_readreg(state
, 0x09) | 0x80);
440 static u32
s5h1420_getsymbolrate(struct s5h1420_state
* state
)
445 if (s5h1420_readreg(state
, 0x05) & 0x2)
448 s5h1420_writereg(state
, 0x06, s5h1420_readreg(state
, 0x06) | 0x08);
449 val
= s5h1420_readreg(state
, 0x11) << 16;
450 val
|= s5h1420_readreg(state
, 0x12) << 8;
451 val
|= s5h1420_readreg(state
, 0x13);
452 s5h1420_writereg(state
, 0x06, s5h1420_readreg(state
, 0x06) & 0xf7);
454 val
*= (state
->fclk
/ 1000ULL);
455 do_div(val
, ((1<<24) * sampling
));
457 return (u32
) (val
* 1000ULL);
460 static void s5h1420_setfreqoffset(struct s5h1420_state
* state
, int freqoffset
)
464 /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so
465 * divide fclk by 1000000 to get the correct value. */
466 val
= -(int) ((freqoffset
* (1<<24)) / (state
->fclk
/ 1000000));
468 s5h1420_writereg(state
, 0x09, s5h1420_readreg(state
, 0x09) & 0xbf);
469 s5h1420_writereg(state
, 0x0e, val
>> 16);
470 s5h1420_writereg(state
, 0x0f, val
>> 8);
471 s5h1420_writereg(state
, 0x10, val
& 0xff);
472 s5h1420_writereg(state
, 0x09, s5h1420_readreg(state
, 0x09) | 0x40);
475 static int s5h1420_getfreqoffset(struct s5h1420_state
* state
)
479 s5h1420_writereg(state
, 0x06, s5h1420_readreg(state
, 0x06) | 0x08);
480 val
= s5h1420_readreg(state
, 0x0e) << 16;
481 val
|= s5h1420_readreg(state
, 0x0f) << 8;
482 val
|= s5h1420_readreg(state
, 0x10);
483 s5h1420_writereg(state
, 0x06, s5h1420_readreg(state
, 0x06) & 0xf7);
488 /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so
489 * divide fclk by 1000000 to get the correct value. */
490 val
= (((-val
) * (state
->fclk
/1000000)) / (1<<24));
495 static void s5h1420_setfec_inversion(struct s5h1420_state
* state
,
496 struct dvb_frontend_parameters
*p
)
500 if (p
->inversion
== INVERSION_OFF
) {
501 inversion
= state
->config
->invert
? 0x08 : 0;
502 } else if (p
->inversion
== INVERSION_ON
) {
503 inversion
= state
->config
->invert
? 0 : 0x08;
506 if ((p
->u
.qpsk
.fec_inner
== FEC_AUTO
) || (p
->inversion
== INVERSION_AUTO
)) {
507 s5h1420_writereg(state
, 0x30, 0x3f);
508 s5h1420_writereg(state
, 0x31, 0x00 | inversion
);
510 switch(p
->u
.qpsk
.fec_inner
) {
512 s5h1420_writereg(state
, 0x30, 0x01);
513 s5h1420_writereg(state
, 0x31, 0x10 | inversion
);
517 s5h1420_writereg(state
, 0x30, 0x02);
518 s5h1420_writereg(state
, 0x31, 0x11 | inversion
);
522 s5h1420_writereg(state
, 0x30, 0x04);
523 s5h1420_writereg(state
, 0x31, 0x12 | inversion
);
527 s5h1420_writereg(state
, 0x30, 0x08);
528 s5h1420_writereg(state
, 0x31, 0x13 | inversion
);
532 s5h1420_writereg(state
, 0x30, 0x10);
533 s5h1420_writereg(state
, 0x31, 0x14 | inversion
);
537 s5h1420_writereg(state
, 0x30, 0x20);
538 s5h1420_writereg(state
, 0x31, 0x15 | inversion
);
547 static fe_code_rate_t
s5h1420_getfec(struct s5h1420_state
* state
)
549 switch(s5h1420_readreg(state
, 0x32) & 0x07) {
572 static fe_spectral_inversion_t
s5h1420_getinversion(struct s5h1420_state
* state
)
574 if (s5h1420_readreg(state
, 0x32) & 0x08)
577 return INVERSION_OFF
;
580 static int s5h1420_set_frontend(struct dvb_frontend
* fe
,
581 struct dvb_frontend_parameters
*p
)
583 struct s5h1420_state
* state
= fe
->demodulator_priv
;
585 struct dvb_frontend_tune_settings fesettings
;
587 /* check if we should do a fast-tune */
588 memcpy(&fesettings
.parameters
, p
, sizeof(struct dvb_frontend_parameters
));
589 s5h1420_get_tune_settings(fe
, &fesettings
);
590 frequency_delta
= p
->frequency
- state
->tunedfreq
;
591 if ((frequency_delta
> -fesettings
.max_drift
) &&
592 (frequency_delta
< fesettings
.max_drift
) &&
593 (frequency_delta
!= 0) &&
594 (state
->fec_inner
== p
->u
.qpsk
.fec_inner
) &&
595 (state
->symbol_rate
== p
->u
.qpsk
.symbol_rate
)) {
597 if (fe
->ops
.tuner_ops
.set_params
) {
598 fe
->ops
.tuner_ops
.set_params(fe
, p
);
599 if (fe
->ops
.i2c_gate_ctrl
) fe
->ops
.i2c_gate_ctrl(fe
, 0);
601 if (fe
->ops
.tuner_ops
.get_frequency
) {
603 fe
->ops
.tuner_ops
.get_frequency(fe
, &tmp
);
604 if (fe
->ops
.i2c_gate_ctrl
) fe
->ops
.i2c_gate_ctrl(fe
, 0);
605 s5h1420_setfreqoffset(state
, p
->frequency
- tmp
);
607 s5h1420_setfreqoffset(state
, 0);
612 /* first of all, software reset */
613 s5h1420_reset(state
);
615 /* set s5h1420 fclk PLL according to desired symbol rate */
616 if (p
->u
.qpsk
.symbol_rate
> 28000000) {
617 state
->fclk
= 88000000;
618 s5h1420_writereg(state
, 0x03, 0x50);
619 s5h1420_writereg(state
, 0x04, 0x40);
620 s5h1420_writereg(state
, 0x05, 0xae);
621 } else if (p
->u
.qpsk
.symbol_rate
> 21000000) {
622 state
->fclk
= 59000000;
623 s5h1420_writereg(state
, 0x03, 0x33);
624 s5h1420_writereg(state
, 0x04, 0x40);
625 s5h1420_writereg(state
, 0x05, 0xae);
627 state
->fclk
= 88000000;
628 s5h1420_writereg(state
, 0x03, 0x50);
629 s5h1420_writereg(state
, 0x04, 0x40);
630 s5h1420_writereg(state
, 0x05, 0xac);
633 /* set misc registers */
634 s5h1420_writereg(state
, 0x02, 0x00);
635 s5h1420_writereg(state
, 0x06, 0x00);
636 s5h1420_writereg(state
, 0x07, 0xb0);
637 s5h1420_writereg(state
, 0x0a, 0xe7);
638 s5h1420_writereg(state
, 0x0b, 0x78);
639 s5h1420_writereg(state
, 0x0c, 0x48);
640 s5h1420_writereg(state
, 0x0d, 0x6b);
641 s5h1420_writereg(state
, 0x2e, 0x8e);
642 s5h1420_writereg(state
, 0x35, 0x33);
643 s5h1420_writereg(state
, 0x38, 0x01);
644 s5h1420_writereg(state
, 0x39, 0x7d);
645 s5h1420_writereg(state
, 0x3a, (state
->fclk
+ (TONE_FREQ
* 32) - 1) / (TONE_FREQ
* 32));
646 s5h1420_writereg(state
, 0x3c, 0x00);
647 s5h1420_writereg(state
, 0x45, 0x61);
648 s5h1420_writereg(state
, 0x46, 0x1d);
651 s5h1420_writereg(state
, 0x05, s5h1420_readreg(state
, 0x05) | 1);
654 if (fe
->ops
.tuner_ops
.set_params
) {
655 fe
->ops
.tuner_ops
.set_params(fe
, p
);
656 if (fe
->ops
.i2c_gate_ctrl
) fe
->ops
.i2c_gate_ctrl(fe
, 0);
657 s5h1420_setfreqoffset(state
, 0);
660 /* set the reset of the parameters */
661 s5h1420_setsymbolrate(state
, p
);
662 s5h1420_setfec_inversion(state
, p
);
664 state
->fec_inner
= p
->u
.qpsk
.fec_inner
;
665 state
->symbol_rate
= p
->u
.qpsk
.symbol_rate
;
666 state
->postlocked
= 0;
667 state
->tunedfreq
= p
->frequency
;
671 static int s5h1420_get_frontend(struct dvb_frontend
* fe
,
672 struct dvb_frontend_parameters
*p
)
674 struct s5h1420_state
* state
= fe
->demodulator_priv
;
676 p
->frequency
= state
->tunedfreq
+ s5h1420_getfreqoffset(state
);
677 p
->inversion
= s5h1420_getinversion(state
);
678 p
->u
.qpsk
.symbol_rate
= s5h1420_getsymbolrate(state
);
679 p
->u
.qpsk
.fec_inner
= s5h1420_getfec(state
);
684 static int s5h1420_get_tune_settings(struct dvb_frontend
* fe
,
685 struct dvb_frontend_tune_settings
* fesettings
)
687 if (fesettings
->parameters
.u
.qpsk
.symbol_rate
> 20000000) {
688 fesettings
->min_delay_ms
= 50;
689 fesettings
->step_size
= 2000;
690 fesettings
->max_drift
= 8000;
691 } else if (fesettings
->parameters
.u
.qpsk
.symbol_rate
> 12000000) {
692 fesettings
->min_delay_ms
= 100;
693 fesettings
->step_size
= 1500;
694 fesettings
->max_drift
= 9000;
695 } else if (fesettings
->parameters
.u
.qpsk
.symbol_rate
> 8000000) {
696 fesettings
->min_delay_ms
= 100;
697 fesettings
->step_size
= 1000;
698 fesettings
->max_drift
= 8000;
699 } else if (fesettings
->parameters
.u
.qpsk
.symbol_rate
> 4000000) {
700 fesettings
->min_delay_ms
= 100;
701 fesettings
->step_size
= 500;
702 fesettings
->max_drift
= 7000;
703 } else if (fesettings
->parameters
.u
.qpsk
.symbol_rate
> 2000000) {
704 fesettings
->min_delay_ms
= 200;
705 fesettings
->step_size
= (fesettings
->parameters
.u
.qpsk
.symbol_rate
/ 8000);
706 fesettings
->max_drift
= 14 * fesettings
->step_size
;
708 fesettings
->min_delay_ms
= 200;
709 fesettings
->step_size
= (fesettings
->parameters
.u
.qpsk
.symbol_rate
/ 8000);
710 fesettings
->max_drift
= 18 * fesettings
->step_size
;
716 static int s5h1420_i2c_gate_ctrl(struct dvb_frontend
* fe
, int enable
)
718 struct s5h1420_state
* state
= fe
->demodulator_priv
;
721 return s5h1420_writereg (state
, 0x02, s5h1420_readreg(state
,0x02) | 1);
723 return s5h1420_writereg (state
, 0x02, s5h1420_readreg(state
,0x02) & 0xfe);
727 static int s5h1420_init (struct dvb_frontend
* fe
)
729 struct s5h1420_state
* state
= fe
->demodulator_priv
;
731 /* disable power down and do reset */
732 s5h1420_writereg(state
, 0x02, 0x10);
734 s5h1420_reset(state
);
739 static int s5h1420_sleep(struct dvb_frontend
* fe
)
741 struct s5h1420_state
* state
= fe
->demodulator_priv
;
743 return s5h1420_writereg(state
, 0x02, 0x12);
746 static void s5h1420_release(struct dvb_frontend
* fe
)
748 struct s5h1420_state
* state
= fe
->demodulator_priv
;
752 static struct dvb_frontend_ops s5h1420_ops
;
754 struct dvb_frontend
* s5h1420_attach(const struct s5h1420_config
* config
,
755 struct i2c_adapter
* i2c
)
757 struct s5h1420_state
* state
= NULL
;
760 /* allocate memory for the internal state */
761 state
= kmalloc(sizeof(struct s5h1420_state
), GFP_KERNEL
);
765 /* setup the state */
766 state
->config
= config
;
768 state
->postlocked
= 0;
769 state
->fclk
= 88000000;
770 state
->tunedfreq
= 0;
771 state
->fec_inner
= FEC_NONE
;
772 state
->symbol_rate
= 0;
774 /* check if the demod is there + identify it */
775 identity
= s5h1420_readreg(state
, 0x00);
776 if (identity
!= 0x03)
779 /* create dvb_frontend */
780 memcpy(&state
->frontend
.ops
, &s5h1420_ops
, sizeof(struct dvb_frontend_ops
));
781 state
->frontend
.demodulator_priv
= state
;
782 return &state
->frontend
;
789 static struct dvb_frontend_ops s5h1420_ops
= {
792 .name
= "Samsung S5H1420 DVB-S",
794 .frequency_min
= 950000,
795 .frequency_max
= 2150000,
796 .frequency_stepsize
= 125, /* kHz for QPSK frontends */
797 .frequency_tolerance
= 29500,
798 .symbol_rate_min
= 1000000,
799 .symbol_rate_max
= 45000000,
800 /* .symbol_rate_tolerance = ???,*/
801 .caps
= FE_CAN_INVERSION_AUTO
|
802 FE_CAN_FEC_1_2
| FE_CAN_FEC_2_3
| FE_CAN_FEC_3_4
|
803 FE_CAN_FEC_5_6
| FE_CAN_FEC_6_7
| FE_CAN_FEC_7_8
| FE_CAN_FEC_AUTO
|
807 .release
= s5h1420_release
,
809 .init
= s5h1420_init
,
810 .sleep
= s5h1420_sleep
,
811 .i2c_gate_ctrl
= s5h1420_i2c_gate_ctrl
,
813 .set_frontend
= s5h1420_set_frontend
,
814 .get_frontend
= s5h1420_get_frontend
,
815 .get_tune_settings
= s5h1420_get_tune_settings
,
817 .read_status
= s5h1420_read_status
,
818 .read_ber
= s5h1420_read_ber
,
819 .read_signal_strength
= s5h1420_read_signal_strength
,
820 .read_ucblocks
= s5h1420_read_ucblocks
,
822 .diseqc_send_master_cmd
= s5h1420_send_master_cmd
,
823 .diseqc_recv_slave_reply
= s5h1420_recv_slave_reply
,
824 .diseqc_send_burst
= s5h1420_send_burst
,
825 .set_tone
= s5h1420_set_tone
,
826 .set_voltage
= s5h1420_set_voltage
,
829 module_param(debug
, int, 0644);
831 MODULE_DESCRIPTION("Samsung S5H1420 DVB-S Demodulator driver");
832 MODULE_AUTHOR("Andrew de Quincey");
833 MODULE_LICENSE("GPL");
835 EXPORT_SYMBOL(s5h1420_attach
);