Lines Matching full:state
81 static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data) in stv0299_writeregI() argument
85 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; in stv0299_writeregI()
87 ret = i2c_transfer (state->i2c, &msg, 1); in stv0299_writeregI()
98 struct stv0299_state* state = fe->demodulator_priv; in stv0299_write() local
103 return stv0299_writeregI(state, buf[0], buf[1]); in stv0299_write()
106 static u8 stv0299_readreg (struct stv0299_state* state, u8 reg) in stv0299_readreg() argument
111 …struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 … in stv0299_readreg()
112 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; in stv0299_readreg()
114 ret = i2c_transfer (state->i2c, msg, 2); in stv0299_readreg()
123 static int stv0299_readregs (struct stv0299_state* state, u8 reg1, u8 *b, u8 len) in stv0299_readregs() argument
126 …struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = ®1, .len =… in stv0299_readregs()
127 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = len } }; in stv0299_readregs()
129 ret = i2c_transfer (state->i2c, msg, 2); in stv0299_readregs()
137 static int stv0299_set_FEC (struct stv0299_state* state, fe_code_rate_t fec) in stv0299_set_FEC() argument
144 return stv0299_writeregI (state, 0x31, 0x1f); in stv0299_set_FEC()
148 return stv0299_writeregI (state, 0x31, 0x01); in stv0299_set_FEC()
152 return stv0299_writeregI (state, 0x31, 0x02); in stv0299_set_FEC()
156 return stv0299_writeregI (state, 0x31, 0x04); in stv0299_set_FEC()
160 return stv0299_writeregI (state, 0x31, 0x08); in stv0299_set_FEC()
164 return stv0299_writeregI (state, 0x31, 0x10); in stv0299_set_FEC()
173 static fe_code_rate_t stv0299_get_fec (struct stv0299_state* state) in stv0299_get_fec() argument
181 index = stv0299_readreg (state, 0x1b); in stv0299_get_fec()
190 static int stv0299_wait_diseqc_fifo (struct stv0299_state* state, int timeout) in stv0299_wait_diseqc_fifo() argument
196 while (stv0299_readreg(state, 0x0a) & 1) { in stv0299_wait_diseqc_fifo()
207 static int stv0299_wait_diseqc_idle (struct stv0299_state* state, int timeout) in stv0299_wait_diseqc_idle() argument
213 while ((stv0299_readreg(state, 0x0a) & 3) != 2 ) { in stv0299_wait_diseqc_idle()
226 struct stv0299_state* state = fe->demodulator_priv; in stv0299_set_symbolrate() local
235 big += (state->config->mclk-1); // round correctly in stv0299_set_symbolrate()
236 do_div(big, state->config->mclk); in stv0299_set_symbolrate()
239 return state->config->set_symbol_rate(fe, srate, ratio); in stv0299_set_symbolrate()
242 static int stv0299_get_symbolrate (struct stv0299_state* state) in stv0299_get_symbolrate() argument
244 u32 Mclk = state->config->mclk / 4096L; in stv0299_get_symbolrate()
252 stv0299_readregs (state, 0x1f, sfr, 3); in stv0299_get_symbolrate()
253 stv0299_readregs (state, 0x1a, (u8 *)&rtf, 1); in stv0299_get_symbolrate()
277 struct stv0299_state* state = fe->demodulator_priv; in stv0299_send_diseqc_msg() local
283 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_send_diseqc_msg()
286 val = stv0299_readreg (state, 0x08); in stv0299_send_diseqc_msg()
288 if (stv0299_writeregI (state, 0x08, (val & ~0x7) | 0x6)) /* DiSEqC mode */ in stv0299_send_diseqc_msg()
292 if (stv0299_wait_diseqc_fifo (state, 100) < 0) in stv0299_send_diseqc_msg()
295 if (stv0299_writeregI (state, 0x09, m->msg[i])) in stv0299_send_diseqc_msg()
299 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_send_diseqc_msg()
307 struct stv0299_state* state = fe->demodulator_priv; in stv0299_send_diseqc_burst() local
312 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_send_diseqc_burst()
315 val = stv0299_readreg (state, 0x08); in stv0299_send_diseqc_burst()
317 if (stv0299_writeregI (state, 0x08, (val & ~0x7) | 0x2)) /* burst mode */ in stv0299_send_diseqc_burst()
320 if (stv0299_writeregI (state, 0x09, burst == SEC_MINI_A ? 0x00 : 0xff)) in stv0299_send_diseqc_burst()
323 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_send_diseqc_burst()
326 if (stv0299_writeregI (state, 0x08, val)) in stv0299_send_diseqc_burst()
334 struct stv0299_state* state = fe->demodulator_priv; in stv0299_set_tone() local
337 if (stv0299_wait_diseqc_idle (state, 100) < 0) in stv0299_set_tone()
340 val = stv0299_readreg (state, 0x08); in stv0299_set_tone()
344 return stv0299_writeregI (state, 0x08, val | 0x3); in stv0299_set_tone()
347 return stv0299_writeregI (state, 0x08, (val & ~0x3) | 0x02); in stv0299_set_tone()
356 struct stv0299_state* state = fe->demodulator_priv; in stv0299_set_voltage() local
364 reg0x08 = stv0299_readreg (state, 0x08); in stv0299_set_voltage()
365 reg0x0c = stv0299_readreg (state, 0x0c); in stv0299_set_voltage()
371 reg0x08 = (reg0x08 & 0x3f) | (state->config->lock_output << 6); in stv0299_set_voltage()
375 if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0) in stv0299_set_voltage()
392 if (state->config->op0_off) in stv0299_set_voltage()
395 stv0299_writeregI(state, 0x08, reg0x08); in stv0299_set_voltage()
396 return stv0299_writeregI(state, 0x0c, reg0x0c); in stv0299_set_voltage()
401 struct stv0299_state* state = fe->demodulator_priv; in stv0299_send_legacy_dish_cmd() local
410 reg0x08 = stv0299_readreg (state, 0x08); in stv0299_send_legacy_dish_cmd()
411 reg0x0c = stv0299_readreg (state, 0x0c); in stv0299_send_legacy_dish_cmd()
413 stv0299_writeregI (state, 0x08, (reg0x08 & 0x3f) | (state->config->lock_output << 6)); in stv0299_send_legacy_dish_cmd()
414 if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0) in stv0299_send_legacy_dish_cmd()
424 stv0299_writeregI (state, 0x0c, reg0x0c | 0x50); /* set LNB to 18V */ in stv0299_send_legacy_dish_cmd()
433 stv0299_writeregI (state, 0x0c, reg0x0c | (last ? lv_mask : 0x50)); in stv0299_send_legacy_dish_cmd()
454 struct stv0299_state* state = fe->demodulator_priv; in stv0299_init() local
461 stv0299_writeregI(state, 0x02, 0x30 | state->mcr_reg); in stv0299_init()
465 reg = state->config->inittab[i]; in stv0299_init()
466 val = state->config->inittab[i+1]; in stv0299_init()
469 if (reg == 0x0c && state->config->op0_off) in stv0299_init()
472 state->mcr_reg = val & 0xf; in stv0299_init()
473 stv0299_writeregI(state, reg, val); in stv0299_init()
481 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_status() local
483 u8 signal = 0xff - stv0299_readreg (state, 0x18); in stv0299_read_status()
484 u8 sync = stv0299_readreg (state, 0x1b); in stv0299_read_status()
509 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_ber() local
511 if (state->errmode != STATUS_BER) in stv0299_read_ber()
514 *ber = stv0299_readreg(state, 0x1e) | (stv0299_readreg(state, 0x1d) << 8); in stv0299_read_ber()
521 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_signal_strength() local
523 s32 signal = 0xffff - ((stv0299_readreg (state, 0x18) << 8) in stv0299_read_signal_strength()
524 | stv0299_readreg (state, 0x19)); in stv0299_read_signal_strength()
527 stv0299_readreg (state, 0x18), in stv0299_read_signal_strength()
528 stv0299_readreg (state, 0x19), (int) signal); in stv0299_read_signal_strength()
538 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_snr() local
540 s32 xsnr = 0xffff - ((stv0299_readreg (state, 0x24) << 8) in stv0299_read_snr()
541 | stv0299_readreg (state, 0x25)); in stv0299_read_snr()
550 struct stv0299_state* state = fe->demodulator_priv; in stv0299_read_ucblocks() local
552 if (state->errmode != STATUS_UCBLOCKS) in stv0299_read_ucblocks()
555 state->ucblocks += stv0299_readreg(state, 0x1e); in stv0299_read_ucblocks()
556 state->ucblocks += (stv0299_readreg(state, 0x1d) << 8); in stv0299_read_ucblocks()
557 *ucblocks = state->ucblocks; in stv0299_read_ucblocks()
565 struct stv0299_state* state = fe->demodulator_priv; in stv0299_set_frontend() local
569 if (state->config->set_ts_params) in stv0299_set_frontend()
570 state->config->set_ts_params(fe, 0); in stv0299_set_frontend()
579 if (state->config->invert) invval = (~invval) & 1; in stv0299_set_frontend()
580 stv0299_writeregI(state, 0x0c, (stv0299_readreg(state, 0x0c) & 0xfe) | invval); in stv0299_set_frontend()
587 stv0299_set_FEC(state, p->fec_inner); in stv0299_set_frontend()
589 stv0299_writeregI(state, 0x22, 0x00); in stv0299_set_frontend()
590 stv0299_writeregI(state, 0x23, 0x00); in stv0299_set_frontend()
592 state->tuner_frequency = p->frequency; in stv0299_set_frontend()
593 state->fec_inner = p->fec_inner; in stv0299_set_frontend()
594 state->symbol_rate = p->symbol_rate; in stv0299_set_frontend()
602 struct stv0299_state* state = fe->demodulator_priv; in stv0299_get_frontend() local
606 derot_freq = (s32)(s16) ((stv0299_readreg (state, 0x22) << 8) in stv0299_get_frontend()
607 | stv0299_readreg (state, 0x23)); in stv0299_get_frontend()
609 derot_freq *= (state->config->mclk >> 16); in stv0299_get_frontend()
615 invval = stv0299_readreg (state, 0x0c) & 1; in stv0299_get_frontend()
616 if (state->config->invert) invval = (~invval) & 1; in stv0299_get_frontend()
619 p->fec_inner = stv0299_get_fec(state); in stv0299_get_frontend()
620 p->symbol_rate = stv0299_get_symbolrate(state); in stv0299_get_frontend()
627 struct stv0299_state* state = fe->demodulator_priv; in stv0299_sleep() local
629 stv0299_writeregI(state, 0x02, 0xb0 | state->mcr_reg); in stv0299_sleep()
630 state->initialised = 0; in stv0299_sleep()
637 struct stv0299_state* state = fe->demodulator_priv; in stv0299_i2c_gate_ctrl() local
640 stv0299_writeregI(state, 0x05, 0xb5); in stv0299_i2c_gate_ctrl()
642 stv0299_writeregI(state, 0x05, 0x35); in stv0299_i2c_gate_ctrl()
650 struct stv0299_state* state = fe->demodulator_priv; in stv0299_get_tune_settings() local
653 fesettings->min_delay_ms = state->config->min_delay_ms; in stv0299_get_tune_settings()
666 struct stv0299_state* state = fe->demodulator_priv; in stv0299_release() local
667 kfree(state); in stv0299_release()
675 struct stv0299_state* state = NULL; in stv0299_attach() local
678 /* allocate memory for the internal state */ in stv0299_attach()
679 state = kzalloc(sizeof(struct stv0299_state), GFP_KERNEL); in stv0299_attach()
680 if (state == NULL) goto error; in stv0299_attach()
682 /* setup the state */ in stv0299_attach()
683 state->config = config; in stv0299_attach()
684 state->i2c = i2c; in stv0299_attach()
685 state->initialised = 0; in stv0299_attach()
686 state->tuner_frequency = 0; in stv0299_attach()
687 state->symbol_rate = 0; in stv0299_attach()
688 state->fec_inner = 0; in stv0299_attach()
689 state->errmode = STATUS_BER; in stv0299_attach()
692 stv0299_writeregI(state, 0x02, 0x30); /* standby off */ in stv0299_attach()
694 id = stv0299_readreg(state, 0x00); in stv0299_attach()
701 memcpy(&state->frontend.ops, &stv0299_ops, sizeof(struct dvb_frontend_ops)); in stv0299_attach()
702 state->frontend.demodulator_priv = state; in stv0299_attach()
703 return &state->frontend; in stv0299_attach()
706 kfree(state); in stv0299_attach()