Lines Matching refs:state
82 static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data) in stv0299_writeregI() argument
86 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; in stv0299_writeregI()
88 ret = i2c_transfer (state->i2c, &msg, 1); in stv0299_writeregI()
99 struct stv0299_state* state = fe->demodulator_priv; in stv0299_write() local
104 return stv0299_writeregI(state, buf[0], buf[1]); in stv0299_write()
107 static u8 stv0299_readreg (struct stv0299_state* state, u8 reg) in stv0299_readreg() argument
112 …struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 … in stv0299_readreg()
113 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; in stv0299_readreg()
115 ret = i2c_transfer (state->i2c, msg, 2); in stv0299_readreg()
124 static int stv0299_readregs (struct stv0299_state* state, u8 reg1, u8 *b, u8 len) in stv0299_readregs() argument
127 …struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = ®1, .len =… in stv0299_readregs()
128 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = len } }; in stv0299_readregs()
130 ret = i2c_transfer (state->i2c, msg, 2); in stv0299_readregs()
138 static int stv0299_set_FEC(struct stv0299_state *state, enum fe_code_rate fec) in stv0299_set_FEC() argument
145 return stv0299_writeregI (state, 0x31, 0x1f); in stv0299_set_FEC()
149 return stv0299_writeregI (state, 0x31, 0x01); in stv0299_set_FEC()
153 return stv0299_writeregI (state, 0x31, 0x02); in stv0299_set_FEC()
157 return stv0299_writeregI (state, 0x31, 0x04); in stv0299_set_FEC()
161 return stv0299_writeregI (state, 0x31, 0x08); in stv0299_set_FEC()
165 return stv0299_writeregI (state, 0x31, 0x10); in stv0299_set_FEC()
174 static enum fe_code_rate stv0299_get_fec(struct stv0299_state *state) in stv0299_get_fec() argument
182 index = stv0299_readreg (state, 0x1b); in stv0299_get_fec()
191 static int stv0299_wait_diseqc_fifo (struct stv0299_state* state, int timeout) in stv0299_wait_diseqc_fifo() argument
197 while (stv0299_readreg(state, 0x0a) & 1) { in stv0299_wait_diseqc_fifo()
208 static int stv0299_wait_diseqc_idle (struct stv0299_state* state, int timeout) in stv0299_wait_diseqc_idle() argument
214 while ((stv0299_readreg(state, 0x0a) & 3) != 2 ) { in stv0299_wait_diseqc_idle()
227 struct stv0299_state* state = fe->demodulator_priv; in stv0299_set_symbolrate() local
236 big += (state->config->mclk-1); // round correctly in stv0299_set_symbolrate()
237 do_div(big, state->config->mclk); in stv0299_set_symbolrate()
240 return state->config->set_symbol_rate(fe, srate, ratio); in stv0299_set_symbolrate()
243 static int stv0299_get_symbolrate (struct stv0299_state* state) in stv0299_get_symbolrate() argument
245 u32 Mclk = state->config->mclk / 4096L; in stv0299_get_symbolrate()
253 stv0299_readregs (state, 0x1f, sfr, 3); in stv0299_get_symbolrate()
254 stv0299_readregs (state, 0x1a, (u8 *)&rtf, 1); in stv0299_get_symbolrate()
278 struct stv0299_state* state = fe->demodulator_priv; in stv0299_send_diseqc_msg() local
284 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_send_diseqc_msg()
287 val = stv0299_readreg (state, 0x08); in stv0299_send_diseqc_msg()
289 if (stv0299_writeregI (state, 0x08, (val & ~0x7) | 0x6)) /* DiSEqC mode */ in stv0299_send_diseqc_msg()
293 if (stv0299_wait_diseqc_fifo (state, 100) < 0) in stv0299_send_diseqc_msg()
296 if (stv0299_writeregI (state, 0x09, m->msg[i])) in stv0299_send_diseqc_msg()
300 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_send_diseqc_msg()
309 struct stv0299_state* state = fe->demodulator_priv; in stv0299_send_diseqc_burst() local
314 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_send_diseqc_burst()
317 val = stv0299_readreg (state, 0x08); in stv0299_send_diseqc_burst()
319 if (stv0299_writeregI (state, 0x08, (val & ~0x7) | 0x2)) /* burst mode */ in stv0299_send_diseqc_burst()
322 if (stv0299_writeregI (state, 0x09, burst == SEC_MINI_A ? 0x00 : 0xff)) in stv0299_send_diseqc_burst()
325 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_send_diseqc_burst()
328 if (stv0299_writeregI (state, 0x08, val)) in stv0299_send_diseqc_burst()
337 struct stv0299_state* state = fe->demodulator_priv; in stv0299_set_tone() local
340 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_set_tone()
343 val = stv0299_readreg (state, 0x08); in stv0299_set_tone()
347 return stv0299_writeregI (state, 0x08, val | 0x3); in stv0299_set_tone()
350 return stv0299_writeregI (state, 0x08, (val & ~0x3) | 0x02); in stv0299_set_tone()
360 struct stv0299_state* state = fe->demodulator_priv; in stv0299_set_voltage() local
368 reg0x08 = stv0299_readreg (state, 0x08); in stv0299_set_voltage()
369 reg0x0c = stv0299_readreg (state, 0x0c); in stv0299_set_voltage()
375 reg0x08 = (reg0x08 & 0x3f) | (state->config->lock_output << 6); in stv0299_set_voltage()
379 if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0) in stv0299_set_voltage()
396 if (state->config->op0_off) in stv0299_set_voltage()
399 stv0299_writeregI(state, 0x08, reg0x08); in stv0299_set_voltage()
400 return stv0299_writeregI(state, 0x0c, reg0x0c); in stv0299_set_voltage()
405 struct stv0299_state* state = fe->demodulator_priv; in stv0299_send_legacy_dish_cmd() local
414 reg0x08 = stv0299_readreg (state, 0x08); in stv0299_send_legacy_dish_cmd()
415 reg0x0c = stv0299_readreg (state, 0x0c); in stv0299_send_legacy_dish_cmd()
417 stv0299_writeregI (state, 0x08, (reg0x08 & 0x3f) | (state->config->lock_output << 6)); in stv0299_send_legacy_dish_cmd()
418 if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0) in stv0299_send_legacy_dish_cmd()
428 stv0299_writeregI (state, 0x0c, reg0x0c | 0x50); /* set LNB to 18V */ in stv0299_send_legacy_dish_cmd()
437 stv0299_writeregI (state, 0x0c, reg0x0c | (last ? lv_mask : 0x50)); in stv0299_send_legacy_dish_cmd()
459 struct stv0299_state* state = fe->demodulator_priv; in stv0299_init() local
466 stv0299_writeregI(state, 0x02, 0x30 | state->mcr_reg); in stv0299_init()
470 reg = state->config->inittab[i]; in stv0299_init()
471 val = state->config->inittab[i+1]; in stv0299_init()
474 if (reg == 0x0c && state->config->op0_off) in stv0299_init()
477 state->mcr_reg = val & 0xf; in stv0299_init()
478 stv0299_writeregI(state, reg, val); in stv0299_init()
487 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_status() local
489 u8 signal = 0xff - stv0299_readreg (state, 0x18); in stv0299_read_status()
490 u8 sync = stv0299_readreg (state, 0x1b); in stv0299_read_status()
515 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_ber() local
517 if (state->errmode != STATUS_BER) in stv0299_read_ber()
520 *ber = stv0299_readreg(state, 0x1e) | (stv0299_readreg(state, 0x1d) << 8); in stv0299_read_ber()
527 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_signal_strength() local
529 s32 signal = 0xffff - ((stv0299_readreg (state, 0x18) << 8) in stv0299_read_signal_strength()
530 | stv0299_readreg (state, 0x19)); in stv0299_read_signal_strength()
533 stv0299_readreg (state, 0x18), in stv0299_read_signal_strength()
534 stv0299_readreg (state, 0x19), (int) signal); in stv0299_read_signal_strength()
544 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_snr() local
546 s32 xsnr = 0xffff - ((stv0299_readreg (state, 0x24) << 8) in stv0299_read_snr()
547 | stv0299_readreg (state, 0x25)); in stv0299_read_snr()
556 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_ucblocks() local
558 if (state->errmode != STATUS_UCBLOCKS) in stv0299_read_ucblocks()
561 state->ucblocks += stv0299_readreg(state, 0x1e); in stv0299_read_ucblocks()
562 state->ucblocks += (stv0299_readreg(state, 0x1d) << 8); in stv0299_read_ucblocks()
563 *ucblocks = state->ucblocks; in stv0299_read_ucblocks()
571 struct stv0299_state* state = fe->demodulator_priv; in stv0299_set_frontend() local
575 if (state->config->set_ts_params) in stv0299_set_frontend()
576 state->config->set_ts_params(fe, 0); in stv0299_set_frontend()
585 if (state->config->invert) invval = (~invval) & 1; in stv0299_set_frontend()
586 stv0299_writeregI(state, 0x0c, (stv0299_readreg(state, 0x0c) & 0xfe) | invval); in stv0299_set_frontend()
593 stv0299_set_FEC(state, p->fec_inner); in stv0299_set_frontend()
595 stv0299_writeregI(state, 0x22, 0x00); in stv0299_set_frontend()
596 stv0299_writeregI(state, 0x23, 0x00); in stv0299_set_frontend()
598 state->tuner_frequency = p->frequency; in stv0299_set_frontend()
599 state->fec_inner = p->fec_inner; in stv0299_set_frontend()
600 state->symbol_rate = p->symbol_rate; in stv0299_set_frontend()
608 struct stv0299_state* state = fe->demodulator_priv; in stv0299_get_frontend() local
612 derot_freq = (s32)(s16) ((stv0299_readreg (state, 0x22) << 8) in stv0299_get_frontend()
613 | stv0299_readreg (state, 0x23)); in stv0299_get_frontend()
615 derot_freq *= (state->config->mclk >> 16); in stv0299_get_frontend()
621 invval = stv0299_readreg (state, 0x0c) & 1; in stv0299_get_frontend()
622 if (state->config->invert) invval = (~invval) & 1; in stv0299_get_frontend()
625 p->fec_inner = stv0299_get_fec(state); in stv0299_get_frontend()
626 p->symbol_rate = stv0299_get_symbolrate(state); in stv0299_get_frontend()
633 struct stv0299_state* state = fe->demodulator_priv; in stv0299_sleep() local
635 stv0299_writeregI(state, 0x02, 0xb0 | state->mcr_reg); in stv0299_sleep()
636 state->initialised = 0; in stv0299_sleep()
643 struct stv0299_state* state = fe->demodulator_priv; in stv0299_i2c_gate_ctrl() local
646 stv0299_writeregI(state, 0x05, 0xb5); in stv0299_i2c_gate_ctrl()
648 stv0299_writeregI(state, 0x05, 0x35); in stv0299_i2c_gate_ctrl()
656 struct stv0299_state* state = fe->demodulator_priv; in stv0299_get_tune_settings() local
659 fesettings->min_delay_ms = state->config->min_delay_ms; in stv0299_get_tune_settings()
672 struct stv0299_state* state = fe->demodulator_priv; in stv0299_release() local
673 kfree(state); in stv0299_release()
681 struct stv0299_state* state = NULL; in stv0299_attach() local
685 state = kzalloc(sizeof(struct stv0299_state), GFP_KERNEL); in stv0299_attach()
686 if (state == NULL) goto error; in stv0299_attach()
689 state->config = config; in stv0299_attach()
690 state->i2c = i2c; in stv0299_attach()
691 state->initialised = 0; in stv0299_attach()
692 state->tuner_frequency = 0; in stv0299_attach()
693 state->symbol_rate = 0; in stv0299_attach()
694 state->fec_inner = 0; in stv0299_attach()
695 state->errmode = STATUS_BER; in stv0299_attach()
698 stv0299_writeregI(state, 0x02, 0x30); /* standby off */ in stv0299_attach()
700 id = stv0299_readreg(state, 0x00); in stv0299_attach()
707 memcpy(&state->frontend.ops, &stv0299_ops, sizeof(struct dvb_frontend_ops)); in stv0299_attach()
708 state->frontend.demodulator_priv = state; in stv0299_attach()
709 return &state->frontend; in stv0299_attach()
712 kfree(state); in stv0299_attach()