Lines Matching defs:state
52 static int l64781_writereg (struct l64781_state* state, u8 reg, u8 data)
56 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
58 if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1)
65 static int l64781_readreg (struct l64781_state* state, u8 reg)
70 struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
71 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
73 ret = i2c_transfer(state->i2c, msg, 2);
80 static void apply_tps (struct l64781_state* state)
82 l64781_writereg (state, 0x2a, 0x00);
83 l64781_writereg (state, 0x2a, 0x01);
90 l64781_writereg (state, 0x2a, 0x02);
94 static void reset_afc (struct l64781_state* state)
98 l64781_writereg (state, 0x07, 0x9e); /* stall AFC */
99 l64781_writereg (state, 0x08, 0); /* AFC INIT FREQ */
100 l64781_writereg (state, 0x09, 0);
101 l64781_writereg (state, 0x0a, 0);
102 l64781_writereg (state, 0x07, 0x8e);
103 l64781_writereg (state, 0x0e, 0); /* AGC gain to zero in beginning */
104 l64781_writereg (state, 0x11, 0x80); /* stall TIM */
105 l64781_writereg (state, 0x10, 0); /* TIM_OFFSET_LSB */
106 l64781_writereg (state, 0x12, 0);
107 l64781_writereg (state, 0x13, 0);
108 l64781_writereg (state, 0x11, 0x00);
111 static int reset_and_configure (struct l64781_state* state)
117 return (i2c_transfer(state->i2c, &msg, 1) == 1) ? 0 : -ENODEV;
122 struct l64781_state* state = fe->demodulator_priv;
207 l64781_writereg (state, 0x04, val0x04);
208 l64781_writereg (state, 0x05, val0x05);
209 l64781_writereg (state, 0x06, val0x06);
211 reset_afc (state);
214 l64781_writereg (state, 0x15,
216 l64781_writereg (state, 0x16, init_freq & 0xff);
217 l64781_writereg (state, 0x17, (init_freq >> 8) & 0xff);
218 l64781_writereg (state, 0x18, (init_freq >> 16) & 0xff);
220 l64781_writereg (state, 0x1b, spi_bias & 0xff);
221 l64781_writereg (state, 0x1c, (spi_bias >> 8) & 0xff);
222 l64781_writereg (state, 0x1d, ((spi_bias >> 16) & 0x7f) |
225 l64781_writereg (state, 0x22, ddfs_offset_fixed & 0xff);
226 l64781_writereg (state, 0x23, (ddfs_offset_fixed >> 8) & 0x3f);
228 l64781_readreg (state, 0x00); /* clear interrupt registers... */
229 l64781_readreg (state, 0x01); /* dto. */
231 apply_tps (state);
238 struct l64781_state* state = fe->demodulator_priv;
242 tmp = l64781_readreg(state, 0x04);
270 tmp = l64781_readreg(state, 0x05);
311 tmp = l64781_readreg(state, 0x06);
343 tmp = l64781_readreg (state, 0x1d);
346 tmp = (int) (l64781_readreg (state, 0x08) |
347 (l64781_readreg (state, 0x09) << 8) |
348 (l64781_readreg (state, 0x0a) << 16));
356 struct l64781_state* state = fe->demodulator_priv;
357 int sync = l64781_readreg (state, 0x32);
358 int gain = l64781_readreg (state, 0x0e);
360 l64781_readreg (state, 0x00); /* clear interrupt registers... */
361 l64781_readreg (state, 0x01); /* dto. */
385 struct l64781_state* state = fe->demodulator_priv;
387 *ber = l64781_readreg (state, 0x39)
388 | (l64781_readreg (state, 0x3a) << 8);
395 struct l64781_state* state = fe->demodulator_priv;
397 u8 gain = l64781_readreg (state, 0x0e);
405 struct l64781_state* state = fe->demodulator_priv;
407 u8 avg_quality = 0xff - l64781_readreg (state, 0x33);
415 struct l64781_state* state = fe->demodulator_priv;
417 *ucblocks = l64781_readreg (state, 0x37)
418 | (l64781_readreg (state, 0x38) << 8);
425 struct l64781_state* state = fe->demodulator_priv;
428 return l64781_writereg (state, 0x3e, 0x5a);
433 struct l64781_state* state = fe->demodulator_priv;
435 reset_and_configure (state);
438 l64781_writereg (state, 0x3e, 0xa5);
441 l64781_writereg (state, 0x2a, 0x04);
442 l64781_writereg (state, 0x2a, 0x00);
446 l64781_writereg (state, 0x07, 0x8e);
449 l64781_writereg (state, 0x0b, 0x81);
452 l64781_writereg (state, 0x0c, 0x84);
455 l64781_writereg (state, 0x0d, 0x8c);
460 /*l64781_writereg (state, 0x19, 0x92);*/
463 l64781_writereg (state, 0x1e, 0x09);
466 if (state->first) {
467 state->first = 0;
485 struct l64781_state* state = fe->demodulator_priv;
486 kfree(state);
494 struct l64781_state* state = NULL;
501 /* allocate memory for the internal state */
502 state = kzalloc(sizeof(struct l64781_state), GFP_KERNEL);
503 if (state == NULL) goto error;
505 /* setup the state */
506 state->config = config;
507 state->i2c = i2c;
508 state->first = 1;
514 if (reset_and_configure(state) < 0) {
520 if (i2c_transfer(state->i2c, msg, 2) != 2) {
526 reg0x3e = l64781_readreg(state, 0x3e);
535 l64781_writereg (state, 0x3e, 0x5a);
538 if (l64781_readreg(state, 0x1a) != 0) {
544 l64781_writereg (state, 0x3e, 0xa5);
547 if (l64781_readreg(state, 0x1a) != 0xa1) {
553 memcpy(&state->frontend.ops, &l64781_ops, sizeof(struct dvb_frontend_ops));
554 state->frontend.demodulator_priv = state;
555 return &state->frontend;
559 l64781_writereg (state, 0x3e, reg0x3e); /* restore reg 0x3e */
560 kfree(state);