Lines Matching refs:state
39 static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data) in stv0297_writereg() argument
43 struct i2c_msg msg = {.addr = state->config->demod_address,.flags = 0,.buf = buf,.len = 2 }; in stv0297_writereg()
45 ret = i2c_transfer(state->i2c, &msg, 1); in stv0297_writereg()
54 static int stv0297_readreg(struct stv0297_state *state, u8 reg) in stv0297_readreg() argument
59 struct i2c_msg msg[] = { {.addr = state->config->demod_address,.flags = 0,.buf = b0,.len = 1}, in stv0297_readreg()
60 {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b1,.len = 1} in stv0297_readreg()
64 if (state->config->stop_during_read) { in stv0297_readreg()
65 if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) { in stv0297_readreg()
69 if ((ret = i2c_transfer(state->i2c, &msg[1], 1)) != 1) { in stv0297_readreg()
74 if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { in stv0297_readreg()
83 static int stv0297_writereg_mask(struct stv0297_state *state, u8 reg, u8 mask, u8 data) in stv0297_writereg_mask() argument
87 val = stv0297_readreg(state, reg); in stv0297_writereg_mask()
90 stv0297_writereg(state, reg, val); in stv0297_writereg_mask()
95 static int stv0297_readregs(struct stv0297_state *state, u8 reg1, u8 * b, u8 len) in stv0297_readregs() argument
98 struct i2c_msg msg[] = { {.addr = state->config->demod_address,.flags = 0,.buf = in stv0297_readregs()
100 {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b,.len = len} in stv0297_readregs()
104 if (state->config->stop_during_read) { in stv0297_readregs()
105 if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) { in stv0297_readregs()
109 if ((ret = i2c_transfer(state->i2c, &msg[1], 1)) != 1) { in stv0297_readregs()
114 if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { in stv0297_readregs()
123 static u32 stv0297_get_symbolrate(struct stv0297_state *state) in stv0297_get_symbolrate() argument
127 tmp = (u64)(stv0297_readreg(state, 0x55) in stv0297_get_symbolrate()
128 | (stv0297_readreg(state, 0x56) << 8) in stv0297_get_symbolrate()
129 | (stv0297_readreg(state, 0x57) << 16) in stv0297_get_symbolrate()
130 | (stv0297_readreg(state, 0x58) << 24)); in stv0297_get_symbolrate()
138 static void stv0297_set_symbolrate(struct stv0297_state *state, u32 srate) in stv0297_set_symbolrate() argument
146 stv0297_writereg(state, 0x55, (unsigned char) (tmp & 0xFF)); in stv0297_set_symbolrate()
147 stv0297_writereg(state, 0x56, (unsigned char) (tmp >> 8)); in stv0297_set_symbolrate()
148 stv0297_writereg(state, 0x57, (unsigned char) (tmp >> 16)); in stv0297_set_symbolrate()
149 stv0297_writereg(state, 0x58, (unsigned char) (tmp >> 24)); in stv0297_set_symbolrate()
152 static void stv0297_set_sweeprate(struct stv0297_state *state, short fshift, long symrate) in stv0297_set_sweeprate() argument
168 stv0297_writereg(state, 0x60, tmp & 0xFF); in stv0297_set_sweeprate()
169 stv0297_writereg_mask(state, 0x69, 0xF0, (tmp >> 4) & 0xf0); in stv0297_set_sweeprate()
172 static void stv0297_set_carrieroffset(struct stv0297_state *state, long offset) in stv0297_set_carrieroffset() argument
182 stv0297_writereg(state, 0x66, (unsigned char) (tmp & 0xFF)); in stv0297_set_carrieroffset()
183 stv0297_writereg(state, 0x67, (unsigned char) (tmp >> 8)); in stv0297_set_carrieroffset()
184 stv0297_writereg(state, 0x68, (unsigned char) (tmp >> 16)); in stv0297_set_carrieroffset()
185 stv0297_writereg_mask(state, 0x69, 0x0F, (tmp >> 24) & 0x0f); in stv0297_set_carrieroffset()
207 static void stv0297_set_initialdemodfreq(struct stv0297_state *state, long freq) in stv0297_set_initialdemodfreq() argument
219 stv0297_writereg_mask(state, 0x25, 0x80, 0x80); in stv0297_set_initialdemodfreq()
220 stv0297_writereg(state, 0x21, tmp >> 8); in stv0297_set_initialdemodfreq()
221 stv0297_writereg(state, 0x20, tmp); in stv0297_set_initialdemodfreq()
224 static int stv0297_set_qam(struct stv0297_state *state, in stv0297_set_qam() argument
254 stv0297_writereg_mask(state, 0x00, 0x70, val << 4); in stv0297_set_qam()
259 static int stv0297_set_inversion(struct stv0297_state *state, in stv0297_set_inversion() argument
277 stv0297_writereg_mask(state, 0x83, 0x08, val << 3); in stv0297_set_inversion()
284 struct stv0297_state *state = fe->demodulator_priv; in stv0297_i2c_gate_ctrl() local
287 stv0297_writereg(state, 0x87, 0x78); in stv0297_i2c_gate_ctrl()
288 stv0297_writereg(state, 0x86, 0xc8); in stv0297_i2c_gate_ctrl()
296 struct stv0297_state *state = fe->demodulator_priv; in stv0297_init() local
300 for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2) in stv0297_init()
301 stv0297_writereg(state, state->config->inittab[i], state->config->inittab[i+1]); in stv0297_init()
304 state->last_ber = 0; in stv0297_init()
311 struct stv0297_state *state = fe->demodulator_priv; in stv0297_sleep() local
313 stv0297_writereg_mask(state, 0x80, 1, 1); in stv0297_sleep()
321 struct stv0297_state *state = fe->demodulator_priv; in stv0297_read_status() local
323 u8 sync = stv0297_readreg(state, 0xDF); in stv0297_read_status()
334 struct stv0297_state *state = fe->demodulator_priv; in stv0297_read_ber() local
337 stv0297_readregs(state, 0xA0, BER, 3); in stv0297_read_ber()
339 state->last_ber = BER[2] << 8 | BER[1]; in stv0297_read_ber()
340 stv0297_writereg_mask(state, 0xA0, 0x80, 0x80); in stv0297_read_ber()
343 *ber = state->last_ber; in stv0297_read_ber()
351 struct stv0297_state *state = fe->demodulator_priv; in stv0297_read_signal_strength() local
355 stv0297_readregs(state, 0x41, STRENGTH, 3); in stv0297_read_signal_strength()
374 struct stv0297_state *state = fe->demodulator_priv; in stv0297_read_snr() local
377 stv0297_readregs(state, 0x07, SNR, 2); in stv0297_read_snr()
385 struct stv0297_state *state = fe->demodulator_priv; in stv0297_read_ucblocks() local
387 stv0297_writereg_mask(state, 0xDF, 0x03, 0x03); /* freeze the counters */ in stv0297_read_ucblocks()
389 *ucblocks = (stv0297_readreg(state, 0xD5) << 8) in stv0297_read_ucblocks()
390 | stv0297_readreg(state, 0xD4); in stv0297_read_ucblocks()
392 stv0297_writereg_mask(state, 0xDF, 0x03, 0x02); /* clear the counters */ in stv0297_read_ucblocks()
393 stv0297_writereg_mask(state, 0xDF, 0x03, 0x01); /* re-enable the counters */ in stv0297_read_ucblocks()
401 struct stv0297_state *state = fe->demodulator_priv; in stv0297_set_frontend() local
431 if (state->config->invert) in stv0297_set_frontend()
454 stv0297_writereg(state, 0x82, 0x0); in stv0297_set_frontend()
457 stv0297_set_initialdemodfreq(state, 7250); in stv0297_set_frontend()
460 stv0297_writereg_mask(state, 0x43, 0x10, 0x00); in stv0297_set_frontend()
461 stv0297_writereg(state, 0x41, 0x00); in stv0297_set_frontend()
462 stv0297_writereg_mask(state, 0x42, 0x03, 0x01); in stv0297_set_frontend()
463 stv0297_writereg_mask(state, 0x36, 0x60, 0x00); in stv0297_set_frontend()
464 stv0297_writereg_mask(state, 0x36, 0x18, 0x00); in stv0297_set_frontend()
465 stv0297_writereg_mask(state, 0x71, 0x80, 0x80); in stv0297_set_frontend()
466 stv0297_writereg(state, 0x72, 0x00); in stv0297_set_frontend()
467 stv0297_writereg(state, 0x73, 0x00); in stv0297_set_frontend()
468 stv0297_writereg_mask(state, 0x74, 0x0F, 0x00); in stv0297_set_frontend()
469 stv0297_writereg_mask(state, 0x43, 0x08, 0x00); in stv0297_set_frontend()
470 stv0297_writereg_mask(state, 0x71, 0x80, 0x00); in stv0297_set_frontend()
473 stv0297_writereg_mask(state, 0x5a, 0x20, 0x20); in stv0297_set_frontend()
474 stv0297_writereg_mask(state, 0x5b, 0x02, 0x02); in stv0297_set_frontend()
475 stv0297_writereg_mask(state, 0x5b, 0x02, 0x00); in stv0297_set_frontend()
476 stv0297_writereg_mask(state, 0x5b, 0x01, 0x00); in stv0297_set_frontend()
477 stv0297_writereg_mask(state, 0x5a, 0x40, 0x40); in stv0297_set_frontend()
480 stv0297_writereg_mask(state, 0x6a, 0x01, 0x00); in stv0297_set_frontend()
483 stv0297_writereg_mask(state, 0x81, 0x01, 0x01); in stv0297_set_frontend()
484 stv0297_writereg_mask(state, 0x81, 0x01, 0x00); in stv0297_set_frontend()
487 stv0297_writereg_mask(state, 0x83, 0x20, 0x20); in stv0297_set_frontend()
488 stv0297_writereg_mask(state, 0x83, 0x20, 0x00); in stv0297_set_frontend()
491 u_threshold = stv0297_readreg(state, 0x00) & 0xf; in stv0297_set_frontend()
492 initial_u = stv0297_readreg(state, 0x01) >> 4; in stv0297_set_frontend()
493 blind_u = stv0297_readreg(state, 0x01) & 0xf; in stv0297_set_frontend()
494 stv0297_writereg_mask(state, 0x84, 0x01, 0x01); in stv0297_set_frontend()
495 stv0297_writereg_mask(state, 0x84, 0x01, 0x00); in stv0297_set_frontend()
496 stv0297_writereg_mask(state, 0x00, 0x0f, u_threshold); in stv0297_set_frontend()
497 stv0297_writereg_mask(state, 0x01, 0xf0, initial_u << 4); in stv0297_set_frontend()
498 stv0297_writereg_mask(state, 0x01, 0x0f, blind_u); in stv0297_set_frontend()
501 stv0297_writereg_mask(state, 0x87, 0x80, 0x00); in stv0297_set_frontend()
504 stv0297_writereg(state, 0x63, 0x00); in stv0297_set_frontend()
505 stv0297_writereg(state, 0x64, 0x00); in stv0297_set_frontend()
506 stv0297_writereg(state, 0x65, 0x00); in stv0297_set_frontend()
507 stv0297_writereg(state, 0x66, 0x00); in stv0297_set_frontend()
508 stv0297_writereg(state, 0x67, 0x00); in stv0297_set_frontend()
509 stv0297_writereg(state, 0x68, 0x00); in stv0297_set_frontend()
510 stv0297_writereg_mask(state, 0x69, 0x0f, 0x00); in stv0297_set_frontend()
513 stv0297_set_qam(state, p->modulation); in stv0297_set_frontend()
514 stv0297_set_symbolrate(state, p->symbol_rate / 1000); in stv0297_set_frontend()
515 stv0297_set_sweeprate(state, sweeprate, p->symbol_rate / 1000); in stv0297_set_frontend()
516 stv0297_set_carrieroffset(state, carrieroffset); in stv0297_set_frontend()
517 stv0297_set_inversion(state, inversion); in stv0297_set_frontend()
523 stv0297_writereg_mask(state, 0x88, 0x08, 0x00); in stv0297_set_frontend()
525 stv0297_writereg_mask(state, 0x88, 0x08, 0x08); in stv0297_set_frontend()
527 stv0297_writereg_mask(state, 0x5a, 0x20, 0x00); in stv0297_set_frontend()
528 stv0297_writereg_mask(state, 0x6a, 0x01, 0x01); in stv0297_set_frontend()
529 stv0297_writereg_mask(state, 0x43, 0x40, 0x40); in stv0297_set_frontend()
530 stv0297_writereg_mask(state, 0x5b, 0x30, 0x00); in stv0297_set_frontend()
531 stv0297_writereg_mask(state, 0x03, 0x0c, 0x0c); in stv0297_set_frontend()
532 stv0297_writereg_mask(state, 0x03, 0x03, 0x03); in stv0297_set_frontend()
533 stv0297_writereg_mask(state, 0x43, 0x10, 0x10); in stv0297_set_frontend()
539 if (stv0297_readreg(state, 0x43) & 0x08) in stv0297_set_frontend()
552 if (stv0297_readreg(state, 0x82) & 0x04) { in stv0297_set_frontend()
565 if (stv0297_readreg(state, 0x82) & 0x08) { in stv0297_set_frontend()
574 stv0297_writereg_mask(state, 0x6a, 1, 0); in stv0297_set_frontend()
575 stv0297_writereg_mask(state, 0x88, 8, 0); in stv0297_set_frontend()
582 if (stv0297_readreg(state, 0xDF) & 0x80) { in stv0297_set_frontend()
592 if (!(stv0297_readreg(state, 0xDF) & 0x80)) { in stv0297_set_frontend()
597 stv0297_writereg_mask(state, 0x5a, 0x40, 0x00); in stv0297_set_frontend()
598 state->base_freq = p->frequency; in stv0297_set_frontend()
602 stv0297_writereg_mask(state, 0x6a, 0x01, 0x00); in stv0297_set_frontend()
609 struct stv0297_state *state = fe->demodulator_priv; in stv0297_get_frontend() local
612 reg_00 = stv0297_readreg(state, 0x00); in stv0297_get_frontend()
613 reg_83 = stv0297_readreg(state, 0x83); in stv0297_get_frontend()
615 p->frequency = state->base_freq; in stv0297_get_frontend()
617 if (state->config->invert) in stv0297_get_frontend()
619 p->symbol_rate = stv0297_get_symbolrate(state) * 1000; in stv0297_get_frontend()
645 struct stv0297_state *state = fe->demodulator_priv; in stv0297_release() local
646 kfree(state); in stv0297_release()
654 struct stv0297_state *state = NULL; in stv0297_attach() local
657 state = kzalloc(sizeof(struct stv0297_state), GFP_KERNEL); in stv0297_attach()
658 if (state == NULL) in stv0297_attach()
662 state->config = config; in stv0297_attach()
663 state->i2c = i2c; in stv0297_attach()
664 state->last_ber = 0; in stv0297_attach()
665 state->base_freq = 0; in stv0297_attach()
668 if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20) in stv0297_attach()
672 memcpy(&state->frontend.ops, &stv0297_ops, sizeof(struct dvb_frontend_ops)); in stv0297_attach()
673 state->frontend.demodulator_priv = state; in stv0297_attach()
674 return &state->frontend; in stv0297_attach()
677 kfree(state); in stv0297_attach()