28 #include <linux/kernel.h>
29 #include <linux/module.h>
30 #include <linux/string.h>
31 #include <linux/slab.h>
45 #define dprintk(args...) \
47 if (debug) printk(KERN_DEBUG "tda8083: " args); \
51 static u8 tda8083_init_tab [] = {
52 0x04, 0x00, 0x4a, 0x79, 0x04, 0x00, 0xff, 0xea,
53 0x48, 0x42, 0x79, 0x60, 0x70, 0x52, 0x9a, 0x10,
54 0x0e, 0x10, 0xf2, 0xa7, 0x93, 0x0b, 0x05, 0xc8,
55 0x9d, 0x00, 0x42, 0x80, 0x00, 0x60, 0x40, 0x00,
56 0x00, 0x75, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00
65 struct i2c_msg msg = { .addr = state->
config->demod_address, .flags = 0, .buf =
buf, .len = 2 };
70 dprintk (
"%s: writereg error (reg %02x, ret == %i)\n",
73 return (ret != 1) ? -1 : 0;
79 struct i2c_msg msg [] = { { .
addr = state->
config->demod_address, .flags = 0, .buf = &
reg1, .len = 1 },
80 { .addr = state->
config->demod_address, .flags =
I2C_M_RD, .buf =
b, .len = len } };
85 dprintk (
"%s: readreg error (reg %02x, ret == %i)\n",
88 return ret == 2 ? 0 : -1;
95 tda8083_readregs (state, reg, &val, 1);
112 return tda8083_writereg (state, 0x07, 0xff);
115 return tda8083_writereg (state, 0x07, 1 << (
FEC_8_9 - fec));
126 index = tda8083_readreg(state, 0x0e) & 0x07;
128 return fec_tab [
index];
137 if (srate > 32000000)
143 if (srate < 24000000)
145 if (srate < 16000000)
151 tmp = (tmp % srate) << 8;
152 ratio = (ratio << 8) + tmp / srate;
154 tmp = (tmp % srate) << 8;
155 ratio = (ratio << 8) + tmp / srate;
157 dprintk(
"tda8083: ratio == %08x\n", (
unsigned int) ratio);
159 tda8083_writereg (state, 0x05, filter);
160 tda8083_writereg (state, 0x02, (ratio >> 16) & 0xff);
161 tda8083_writereg (state, 0x03, (ratio >> 8) & 0xff);
162 tda8083_writereg (state, 0x04, (ratio ) & 0xff);
164 tda8083_writereg (state, 0x00, 0x3c);
165 tda8083_writereg (state, 0x00, 0x04);
170 static void tda8083_wait_diseqc_fifo (
struct tda8083_state* state,
int timeout)
174 while (jiffies - start < timeout &&
175 !(tda8083_readreg(state, 0x02) & 0x80))
183 tda8083_writereg (state, 0x26, 0xf1);
187 return tda8083_writereg (state, 0x29, 0x00);
189 return tda8083_writereg (state, 0x29, 0x80);
199 return tda8083_writereg (state, 0x20, 0x00);
201 return tda8083_writereg (state, 0x20, 0x11);
211 tda8083_writereg (state, 0x29, (5 << 2));
214 tda8083_writereg (state, 0x29, (7 << 2));
220 tda8083_wait_diseqc_fifo (state, 100);
225 static int tda8083_send_diseqc_msg (
struct dvb_frontend* fe,
231 tda8083_writereg (state, 0x29, (m->
msg_len - 3) | (1 << 2));
234 tda8083_writereg (state, 0x23 + i, m->
msg[i]);
236 tda8083_writereg (state, 0x29, (m->
msg_len - 3) | (3 << 2));
238 tda8083_wait_diseqc_fifo (state, 100);
247 u8 signal = ~tda8083_readreg (state, 0x01);
248 u8 sync = tda8083_readreg (state, 0x02);
267 if ((sync & 0x1f) == 0x1f)
279 if ((ret = tda8083_readregs(state, 0x0b, buf,
sizeof(buf))))
282 *ber = ((buf[0] & 0x1f) << 16) | (buf[1] << 8) | buf[2];
287 static int tda8083_read_signal_strength(
struct dvb_frontend* fe,
u16* strength)
291 u8 signal = ~tda8083_readreg (state, 0x01);
292 *strength = (signal << 8) | signal;
301 u8 _snr = tda8083_readreg (state, 0x08);
302 *snr = (_snr << 8) | _snr;
307 static int tda8083_read_ucblocks(
struct dvb_frontend* fe,
u32* ucblocks)
311 *ucblocks = tda8083_readreg(state, 0x0f);
312 if (*ucblocks == 0xff)
313 *ucblocks = 0xffffffff;
318 static int tda8083_set_frontend(
struct dvb_frontend *fe)
323 if (fe->
ops.tuner_ops.set_params) {
324 fe->
ops.tuner_ops.set_params(fe);
325 if (fe->
ops.i2c_gate_ctrl) fe->
ops.i2c_gate_ctrl(fe, 0);
328 tda8083_set_inversion (state, p->
inversion);
332 tda8083_writereg (state, 0x00, 0x3c);
333 tda8083_writereg (state, 0x00, 0x04);
338 static int tda8083_get_frontend(
struct dvb_frontend *fe)
345 p->
inversion = (tda8083_readreg (state, 0x0e) & 0x80) ?
357 tda8083_writereg (state, 0x00, 0x02);
367 tda8083_writereg (state, i, tda8083_init_tab[i]);
369 tda8083_writereg (state, 0x00, 0x3c);
370 tda8083_writereg (state, 0x00, 0x04);
379 tda8083_send_diseqc_burst (state, burst);
380 tda8083_writereg (state, 0x00, 0x3c);
381 tda8083_writereg (state, 0x00, 0x04);
390 tda8083_set_tone (state, tone);
391 tda8083_writereg (state, 0x00, 0x3c);
392 tda8083_writereg (state, 0x00, 0x04);
401 tda8083_set_voltage (state, voltage);
402 tda8083_writereg (state, 0x00, 0x3c);
403 tda8083_writereg (state, 0x00, 0x04);
430 if ((tda8083_readreg(state, 0x00)) != 0x05)
goto error;
445 .name =
"Philips TDA8083 DVB-S",
446 .frequency_min = 920000,
447 .frequency_max = 2200000,
448 .frequency_stepsize = 125,
450 .symbol_rate_min = 12000000,
451 .symbol_rate_max = 30000000,
460 .release = tda8083_release,
462 .init = tda8083_init,
463 .sleep = tda8083_sleep,
465 .set_frontend = tda8083_set_frontend,
466 .get_frontend = tda8083_get_frontend,
468 .read_status = tda8083_read_status,
469 .read_signal_strength = tda8083_read_signal_strength,
470 .read_snr = tda8083_read_snr,
471 .read_ber = tda8083_read_ber,
472 .read_ucblocks = tda8083_read_ucblocks,
474 .diseqc_send_master_cmd = tda8083_send_diseqc_msg,
475 .diseqc_send_burst = tda8083_diseqc_send_burst,
476 .set_tone = tda8083_diseqc_set_tone,
477 .set_voltage = tda8083_diseqc_set_voltage,