Lines Matching defs:state
60 static int or51132_writebuf(struct or51132_state *state, const u8 *buf, int len)
63 struct i2c_msg msg = { .addr = state->config->demod_address,
67 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
75 /* Write constant bytes, e.g. or51132_writebytes(state, 0x04, 0x42, 0x00);
78 #define or51132_writebytes(state, data...) \
80 or51132_writebuf(state, _data, sizeof(_data)); })
83 static int or51132_readbuf(struct or51132_state *state, u8 *buf, int len)
86 struct i2c_msg msg = { .addr = state->config->demod_address,
90 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
99 static int or51132_readreg(struct or51132_state *state, u8 reg)
103 {.addr = state->config->demod_address, .flags = 0,
105 {.addr = state->config->demod_address, .flags = I2C_M_RD,
109 if ((err = i2c_transfer(state->i2c, msg, 2)) != 2) {
119 struct or51132_state* state = fe->demodulator_priv;
134 if ((ret = or51132_writebuf(state, &fw->data[8], firmwareAsize))) {
138 if ((ret = or51132_writebuf(state, &fw->data[8+firmwareAsize],
144 if ((ret = or51132_writebuf(state, run_buf, 2))) {
148 if ((ret = or51132_writebuf(state, run_buf, 2))) {
158 if ((ret = or51132_writebytes(state, 0x10, 0x10, 0x00))) {
162 if ((ret = or51132_writebytes(state, 0x04, 0x17))) {
166 if ((ret = or51132_writebytes(state, 0x00, 0x00))) {
176 if ((ret = or51132_readbuf(state, &rec_buf[i*2], 2))) {
190 if ((ret = or51132_writebytes(state, 0x10, 0x00, 0x00))) {
221 struct or51132_state* state = fe->demodulator_priv;
225 dprintk("setmode %d\n",(int)state->current_modulation);
227 switch (state->current_modulation) {
254 state->current_modulation);
259 if (or51132_writebuf(state, cmd_buf1, 3)) {
266 if (or51132_writebuf(state, cmd_buf2, 3)) {
298 struct or51132_state* state = fe->demodulator_priv;
304 if (modulation_fw_class(state->current_modulation) !=
328 ret = request_firmware(&fw, fwname, state->i2c->dev.parent);
340 state->config->set_ts_params(fe, clock_mode);
343 if (state->current_modulation != p->modulation) {
344 state->current_modulation = p->modulation;
357 state->current_frequency = p->frequency;
364 struct or51132_state* state = fe->demodulator_priv;
370 if ((status = or51132_readreg(state, 0x00)) < 0) {
393 p->frequency = state->current_frequency;
403 struct or51132_state* state = fe->demodulator_priv;
407 if ((reg = or51132_readreg(state, 0x00)) < 0) {
460 struct or51132_state* state = fe->demodulator_priv;
467 noise = or51132_readreg(state, 0x02);
476 reg = or51132_readreg(state, 0x00);
501 state->snr = calculate_snr(noise, c) - usK;
502 *snr = (state->snr) >> 16;
505 state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16);
515 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
522 /* Rather than use the 8.8 value snr, use state->snr which is 8.24 */
524 if (state->snr >= 8960 * 0x10000)
527 *strength = state->snr / 8960;
543 struct or51132_state* state = fe->demodulator_priv;
544 kfree(state);
552 struct or51132_state* state = NULL;
554 /* Allocate memory for the internal state */
555 state = kzalloc(sizeof(struct or51132_state), GFP_KERNEL);
556 if (state == NULL)
559 /* Setup the state */
560 state->config = config;
561 state->i2c = i2c;
562 state->current_frequency = -1;
563 state->current_modulation = -1;
566 memcpy(&state->frontend.ops, &or51132_ops, sizeof(struct dvb_frontend_ops));
567 state->frontend.demodulator_priv = state;
568 return &state->frontend;