Lines Matching defs:state
75 static int or51132_writebuf(struct or51132_state *state, const u8 *buf, int len)
78 struct i2c_msg msg = { .addr = state->config->demod_address,
82 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
90 /* Write constant bytes, e.g. or51132_writebytes(state, 0x04, 0x42, 0x00);
93 #define or51132_writebytes(state, data...) \
95 or51132_writebuf(state, _data, sizeof(_data)); })
98 static int or51132_readbuf(struct or51132_state *state, u8 *buf, int len)
101 struct i2c_msg msg = { .addr = state->config->demod_address,
105 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
114 static int or51132_readreg(struct or51132_state *state, u8 reg)
118 {.addr = state->config->demod_address, .flags = 0,
120 {.addr = state->config->demod_address, .flags = I2C_M_RD,
124 if ((err = i2c_transfer(state->i2c, msg, 2)) != 2) {
134 struct or51132_state* state = fe->demodulator_priv;
149 if ((ret = or51132_writebuf(state, &fw->data[8], firmwareAsize))) {
153 if ((ret = or51132_writebuf(state, &fw->data[8+firmwareAsize],
159 if ((ret = or51132_writebuf(state, run_buf, 2))) {
163 if ((ret = or51132_writebuf(state, run_buf, 2))) {
173 if ((ret = or51132_writebytes(state, 0x10, 0x10, 0x00))) {
177 if ((ret = or51132_writebytes(state, 0x04, 0x17))) {
181 if ((ret = or51132_writebytes(state, 0x00, 0x00))) {
191 if ((ret = or51132_readbuf(state, &rec_buf[i*2], 2))) {
205 if ((ret = or51132_writebytes(state, 0x10, 0x00, 0x00))) {
236 struct or51132_state* state = fe->demodulator_priv;
240 dprintk("setmode %d\n",(int)state->current_modulation);
242 switch (state->current_modulation) {
269 state->current_modulation);
274 if (or51132_writebuf(state, cmd_buf1, 3)) {
281 if (or51132_writebuf(state, cmd_buf2, 3)) {
313 struct or51132_state* state = fe->demodulator_priv;
319 if (modulation_fw_class(state->current_modulation) !=
343 ret = request_firmware(&fw, fwname, state->i2c->dev.parent);
357 state->config->set_ts_params(fe, clock_mode);
360 if (state->current_modulation != param->u.vsb.modulation) {
361 state->current_modulation = param->u.vsb.modulation;
374 state->current_frequency = param->frequency;
381 struct or51132_state* state = fe->demodulator_priv;
387 if ((status = or51132_readreg(state, 0x00)) < 0) {
402 param->frequency = state->current_frequency;
411 struct or51132_state* state = fe->demodulator_priv;
415 if ((reg = or51132_readreg(state, 0x00)) < 0) {
468 struct or51132_state* state = fe->demodulator_priv;
475 noise = or51132_readreg(state, 0x02);
484 reg = or51132_readreg(state, 0x00);
509 state->snr = calculate_snr(noise, c) - usK;
510 *snr = (state->snr) >> 16;
513 state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16);
523 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
530 /* Rather than use the 8.8 value snr, use state->snr which is 8.24 */
532 if (state->snr >= 8960 * 0x10000)
535 *strength = state->snr / 8960;
551 struct or51132_state* state = fe->demodulator_priv;
552 kfree(state);
560 struct or51132_state* state = NULL;
562 /* Allocate memory for the internal state */
563 state = kzalloc(sizeof(struct or51132_state), GFP_KERNEL);
564 if (state == NULL)
567 /* Setup the state */
568 state->config = config;
569 state->i2c = i2c;
570 state->current_frequency = -1;
571 state->current_modulation = -1;
574 memcpy(&state->frontend.ops, &or51132_ops, sizeof(struct dvb_frontend_ops));
575 state->frontend.demodulator_priv = state;
576 return &state->frontend;