23 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/string.h>
27 #include <linux/slab.h>
32 #define REG_RESET 0x02
33 #define REG_RESET_OFF 0x01
42 #define REG_STRENGTH 0x4b
43 #define REG_STRENGTH_MASK 0x7f
44 #define REG_STRENGTH_CARRIER 0x80
45 #define REG_INVERSION 0x7c
46 #define REG_INVERSION_ON 0x80
50 #define REG_STATUS 0xa4
51 #define REG_STATUS_SYNC 0x04
52 #define REG_STATUS_LOCK 0x01
63 #define dprintk(args...) \
66 printk(KERN_DEBUG "lgs8gl5: " args); \
85 dprintk(
"%s: error (reg=0x%02x, val=0x%02x, ret=%i)\n",
86 __func__, reg, data, ret);
87 return (ret != 1) ? -1 : 0;
100 .addr = state->
config->demod_address,
106 .addr = state->
config->demod_address,
124 lgs8gl5_read_reg(state, reg);
125 lgs8gl5_write_reg(state, reg, data);
138 u8 b2[] = {
reg, data};
147 .addr = state->
config->demod_address + 2,
153 .addr = state->
config->demod_address + 2,
161 return (ret != 3) ? -1 : 0;
172 val = lgs8gl5_read_reg(state,
REG_RESET);
188 lgs8gl5_update_alt_reg(state, 0xc2, 0x28);
189 lgs8gl5_soft_reset(state);
190 lgs8gl5_update_reg(state,
REG_07, 0x10);
191 lgs8gl5_update_reg(state,
REG_07, 0x10);
192 lgs8gl5_write_reg(state,
REG_09, 0x0e);
193 lgs8gl5_write_reg(state,
REG_0A, 0xe5);
194 lgs8gl5_write_reg(state,
REG_0B, 0x35);
195 lgs8gl5_write_reg(state,
REG_0C, 0x30);
197 lgs8gl5_update_reg(state,
REG_03, 0x00);
198 lgs8gl5_update_reg(state,
REG_7E, 0x01);
199 lgs8gl5_update_alt_reg(state, 0xc5, 0x00);
200 lgs8gl5_update_reg(state,
REG_04, 0x02);
201 lgs8gl5_update_reg(state,
REG_37, 0x01);
202 lgs8gl5_soft_reset(state);
205 for (n = 0; n < 10; n++) {
207 dprintk(
"Wait for carrier[%d] 0x%02X\n", n, val);
216 for (n = 0; n < 20; n++) {
218 dprintk(
"Wait for lock[%d] 0x%02X\n", n, val);
226 lgs8gl5_write_reg(state,
REG_7D, lgs8gl5_read_reg(state,
REG_A2));
227 lgs8gl5_soft_reset(state);
238 lgs8gl5_update_alt_reg(state, 0xc2, 0x28);
239 lgs8gl5_soft_reset(state);
240 lgs8gl5_update_reg(state,
REG_07, 0x10);
241 lgs8gl5_update_reg(state,
REG_07, 0x10);
242 lgs8gl5_write_reg(state,
REG_09, 0x0e);
243 lgs8gl5_write_reg(state,
REG_0A, 0xe5);
244 lgs8gl5_write_reg(state,
REG_0B, 0x35);
245 lgs8gl5_write_reg(state,
REG_0C, 0x30);
262 if (level & REG_STRENGTH_CARRIER)
266 if (flags & REG_STATUS_LOCK)
283 lgs8gl5_read_signal_strength(
struct dvb_frontend *fe,
u16 *signal_strength)
324 if (fe->
ops.tuner_ops.set_params) {
325 fe->
ops.tuner_ops.set_params(fe);
326 if (fe->
ops.i2c_gate_ctrl)
327 fe->
ops.i2c_gate_ctrl(fe, 0);
332 lgs8gl5_start_demod(state);
398 if (lgs8gl5_read_reg(state,
REG_RESET) < 0)
417 .name =
"Legend Silicon LGS-8GL5 DMB-TH",
418 .frequency_min = 474000000,
419 .frequency_max = 858000000,
420 .frequency_stepsize = 10000,
421 .frequency_tolerance = 0,
432 .release = lgs8gl5_release,
434 .init = lgs8gl5_init,
436 .set_frontend = lgs8gl5_set_frontend,
437 .get_frontend = lgs8gl5_get_frontend,
438 .get_tune_settings = lgs8gl5_get_tune_settings,
440 .read_status = lgs8gl5_read_status,
441 .read_ber = lgs8gl5_read_ber,
442 .read_signal_strength = lgs8gl5_read_signal_strength,
443 .read_snr = lgs8gl5_read_snr,
444 .read_ucblocks = lgs8gl5_read_ucblocks,