Lines Matching refs:state
75 static int or51132_writebuf(struct or51132_state *state, const u8 *buf, int len) in or51132_writebuf() argument
78 struct i2c_msg msg = { .addr = state->config->demod_address, in or51132_writebuf()
82 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { in or51132_writebuf()
93 #define or51132_writebytes(state, data...) \ argument
95 or51132_writebuf(state, _data, sizeof(_data)); })
98 static int or51132_readbuf(struct or51132_state *state, u8 *buf, int len) in or51132_readbuf() argument
101 struct i2c_msg msg = { .addr = state->config->demod_address, in or51132_readbuf()
105 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { in or51132_readbuf()
114 static int or51132_readreg(struct or51132_state *state, u8 reg) in or51132_readreg() argument
118 {.addr = state->config->demod_address, .flags = 0, in or51132_readreg()
120 {.addr = state->config->demod_address, .flags = I2C_M_RD, in or51132_readreg()
124 if ((err = i2c_transfer(state->i2c, msg, 2)) != 2) { in or51132_readreg()
134 struct or51132_state* state = fe->demodulator_priv; in or51132_load_firmware() local
149 if ((ret = or51132_writebuf(state, &fw->data[8], firmwareAsize))) { in or51132_load_firmware()
153 if ((ret = or51132_writebuf(state, &fw->data[8+firmwareAsize], in or51132_load_firmware()
159 if ((ret = or51132_writebuf(state, run_buf, 2))) { in or51132_load_firmware()
163 if ((ret = or51132_writebuf(state, run_buf, 2))) { in or51132_load_firmware()
173 if ((ret = or51132_writebytes(state, 0x10, 0x10, 0x00))) { in or51132_load_firmware()
177 if ((ret = or51132_writebytes(state, 0x04, 0x17))) { in or51132_load_firmware()
181 if ((ret = or51132_writebytes(state, 0x00, 0x00))) { in or51132_load_firmware()
191 if ((ret = or51132_readbuf(state, &rec_buf[i*2], 2))) { in or51132_load_firmware()
205 if ((ret = or51132_writebytes(state, 0x10, 0x00, 0x00))) { in or51132_load_firmware()
236 struct or51132_state* state = fe->demodulator_priv; in or51132_setmode() local
240 dprintk("setmode %d\n",(int)state->current_modulation); in or51132_setmode()
242 switch (state->current_modulation) { in or51132_setmode()
269 state->current_modulation); in or51132_setmode()
274 if (or51132_writebuf(state, cmd_buf1, 3)) { in or51132_setmode()
281 if (or51132_writebuf(state, cmd_buf2, 3)) { in or51132_setmode()
313 struct or51132_state* state = fe->demodulator_priv; in or51132_set_parameters() local
319 if (modulation_fw_class(state->current_modulation) != in or51132_set_parameters()
343 ret = request_firmware(&fw, fwname, state->i2c->dev.parent); in or51132_set_parameters()
357 state->config->set_ts_params(fe, clock_mode); in or51132_set_parameters()
360 if (state->current_modulation != p->modulation) { in or51132_set_parameters()
361 state->current_modulation = p->modulation; in or51132_set_parameters()
374 state->current_frequency = p->frequency; in or51132_set_parameters()
381 struct or51132_state* state = fe->demodulator_priv; in or51132_get_parameters() local
387 if ((status = or51132_readreg(state, 0x00)) < 0) { in or51132_get_parameters()
410 p->frequency = state->current_frequency; in or51132_get_parameters()
420 struct or51132_state* state = fe->demodulator_priv; in or51132_read_status() local
424 if ((reg = or51132_readreg(state, 0x00)) < 0) { in or51132_read_status()
477 struct or51132_state* state = fe->demodulator_priv; in or51132_read_snr() local
484 noise = or51132_readreg(state, 0x02); in or51132_read_snr()
493 reg = or51132_readreg(state, 0x00); in or51132_read_snr()
518 state->snr = calculate_snr(noise, c) - usK; in or51132_read_snr()
519 *snr = (state->snr) >> 16; in or51132_read_snr()
522 state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); in or51132_read_snr()
532 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv; in or51132_read_signal_strength() local
541 if (state->snr >= 8960 * 0x10000) in or51132_read_signal_strength()
544 *strength = state->snr / 8960; in or51132_read_signal_strength()
560 struct or51132_state* state = fe->demodulator_priv; in or51132_release() local
561 kfree(state); in or51132_release()
569 struct or51132_state* state = NULL; in or51132_attach() local
572 state = kzalloc(sizeof(struct or51132_state), GFP_KERNEL); in or51132_attach()
573 if (state == NULL) in or51132_attach()
577 state->config = config; in or51132_attach()
578 state->i2c = i2c; in or51132_attach()
579 state->current_frequency = -1; in or51132_attach()
580 state->current_modulation = -1; in or51132_attach()
583 memcpy(&state->frontend.ops, &or51132_ops, sizeof(struct dvb_frontend_ops)); in or51132_attach()
584 state->frontend.demodulator_priv = state; in or51132_attach()
585 return &state->frontend; in or51132_attach()