Lines Matching refs:state
39 static int i2c_writebytes (struct sp887x_state* state, u8 *buf, u8 len) in i2c_writebytes() argument
41 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = len }; in i2c_writebytes()
44 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { in i2c_writebytes()
46 __func__, state->config->demod_address, err); in i2c_writebytes()
53 static int sp887x_writereg (struct sp887x_state* state, u16 reg, u16 data) in sp887x_writereg() argument
56 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 4 }; in sp887x_writereg()
59 if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) { in sp887x_writereg()
76 static int sp887x_readreg (struct sp887x_state* state, u16 reg) in sp887x_readreg() argument
81 struct i2c_msg msg[] = {{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 }, in sp887x_readreg()
82 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }}; in sp887x_readreg()
84 if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { in sp887x_readreg()
92 static void sp887x_microcontroller_stop (struct sp887x_state* state) in sp887x_microcontroller_stop() argument
95 sp887x_writereg(state, 0xf08, 0x000); in sp887x_microcontroller_stop()
96 sp887x_writereg(state, 0xf09, 0x000); in sp887x_microcontroller_stop()
99 sp887x_writereg(state, 0xf00, 0x000); in sp887x_microcontroller_stop()
102 static void sp887x_microcontroller_start (struct sp887x_state* state) in sp887x_microcontroller_start() argument
105 sp887x_writereg(state, 0xf08, 0x000); in sp887x_microcontroller_start()
106 sp887x_writereg(state, 0xf09, 0x000); in sp887x_microcontroller_start()
109 sp887x_writereg(state, 0xf00, 0x001); in sp887x_microcontroller_start()
112 static void sp887x_setup_agc (struct sp887x_state* state) in sp887x_setup_agc() argument
116 sp887x_writereg(state, 0x33c, 0x054); in sp887x_setup_agc()
117 sp887x_writereg(state, 0x33b, 0x04c); in sp887x_setup_agc()
118 sp887x_writereg(state, 0x328, 0x000); in sp887x_setup_agc()
119 sp887x_writereg(state, 0x327, 0x005); in sp887x_setup_agc()
120 sp887x_writereg(state, 0x326, 0x001); in sp887x_setup_agc()
121 sp887x_writereg(state, 0x325, 0x001); in sp887x_setup_agc()
122 sp887x_writereg(state, 0x324, 0x001); in sp887x_setup_agc()
123 sp887x_writereg(state, 0x318, 0x050); in sp887x_setup_agc()
124 sp887x_writereg(state, 0x317, 0x3fe); in sp887x_setup_agc()
125 sp887x_writereg(state, 0x316, 0x001); in sp887x_setup_agc()
126 sp887x_writereg(state, 0x313, 0x005); in sp887x_setup_agc()
127 sp887x_writereg(state, 0x312, 0x002); in sp887x_setup_agc()
128 sp887x_writereg(state, 0x306, 0x000); in sp887x_setup_agc()
129 sp887x_writereg(state, 0x303, 0x000); in sp887x_setup_agc()
139 struct sp887x_state* state = fe->demodulator_priv; in sp887x_initial_setup() local
154 sp887x_writereg(state, 0xf1a, 0x000); in sp887x_initial_setup()
156 sp887x_microcontroller_stop (state); in sp887x_initial_setup()
162 sp887x_writereg(state, 0x8f08, 0x1fff); in sp887x_initial_setup()
165 sp887x_writereg(state, 0x8f0a, 0x0000); in sp887x_initial_setup()
182 if ((err = i2c_writebytes (state, buf, c+2)) < 0) { in sp887x_initial_setup()
190 sp887x_writereg(state, 0xc13, 0x001); in sp887x_initial_setup()
193 sp887x_writereg(state, 0xc14, 0x000); in sp887x_initial_setup()
196 sp887x_writereg(state, 0xc1a, 0x872); in sp887x_initial_setup()
197 sp887x_writereg(state, 0xc1b, 0x001); in sp887x_initial_setup()
198 sp887x_writereg(state, 0xc1c, 0x000); /* parallel mode (serial mode == 1) */ in sp887x_initial_setup()
199 sp887x_writereg(state, 0xc1a, 0x871); in sp887x_initial_setup()
202 sp887x_writereg(state, 0x301, 0x002); in sp887x_initial_setup()
204 sp887x_setup_agc(state); in sp887x_initial_setup()
207 sp887x_writereg(state, 0xd00, 0x010); in sp887x_initial_setup()
208 sp887x_writereg(state, 0x0d1, 0x000); in sp887x_initial_setup()
305 static void sp887x_correct_offsets (struct sp887x_state* state, in sp887x_correct_offsets() argument
341 sp887x_writereg(state, 0x319, srate_correction[bw_index] >> 12); in sp887x_correct_offsets()
342 sp887x_writereg(state, 0x31a, srate_correction[bw_index] & 0xfff); in sp887x_correct_offsets()
345 sp887x_writereg(state, 0x309, frequency_shift >> 12); in sp887x_correct_offsets()
346 sp887x_writereg(state, 0x30a, frequency_shift & 0xfff); in sp887x_correct_offsets()
352 struct sp887x_state* state = fe->demodulator_priv; in sp887x_setup_frontend_parameters() local
365 sp887x_microcontroller_stop(state); in sp887x_setup_frontend_parameters()
380 sp887x_readreg(state, 0x200); in sp887x_setup_frontend_parameters()
382 sp887x_correct_offsets(state, p, actual_freq); in sp887x_setup_frontend_parameters()
392 sp887x_writereg(state, 0x311, val); in sp887x_setup_frontend_parameters()
396 sp887x_writereg(state, 0x338, 0x000); in sp887x_setup_frontend_parameters()
398 sp887x_writereg(state, 0x338, 0x001); in sp887x_setup_frontend_parameters()
400 sp887x_writereg(state, 0xc05, reg0xc05); in sp887x_setup_frontend_parameters()
412 sp887x_writereg(state, 0xf14, 0x160 | val); in sp887x_setup_frontend_parameters()
413 sp887x_writereg(state, 0xf15, 0x000); in sp887x_setup_frontend_parameters()
415 sp887x_microcontroller_start(state); in sp887x_setup_frontend_parameters()
421 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_status() local
422 u16 snr12 = sp887x_readreg(state, 0xf16); in sp887x_read_status()
423 u16 sync0x200 = sp887x_readreg(state, 0x200); in sp887x_read_status()
424 u16 sync0xf17 = sp887x_readreg(state, 0xf17); in sp887x_read_status()
455 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_ber() local
457 *ber = (sp887x_readreg(state, 0xc08) & 0x3f) | in sp887x_read_ber()
458 (sp887x_readreg(state, 0xc07) << 6); in sp887x_read_ber()
459 sp887x_writereg(state, 0xc08, 0x000); in sp887x_read_ber()
460 sp887x_writereg(state, 0xc07, 0x000); in sp887x_read_ber()
469 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_signal_strength() local
471 u16 snr12 = sp887x_readreg(state, 0xf16); in sp887x_read_signal_strength()
480 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_snr() local
482 u16 snr12 = sp887x_readreg(state, 0xf16); in sp887x_read_snr()
490 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_ucblocks() local
492 *ucblocks = sp887x_readreg(state, 0xc0c); in sp887x_read_ucblocks()
501 struct sp887x_state* state = fe->demodulator_priv; in sp887x_i2c_gate_ctrl() local
504 return sp887x_writereg(state, 0x206, 0x001); in sp887x_i2c_gate_ctrl()
506 return sp887x_writereg(state, 0x206, 0x000); in sp887x_i2c_gate_ctrl()
512 struct sp887x_state* state = fe->demodulator_priv; in sp887x_sleep() local
515 sp887x_writereg(state, 0xc18, 0x000); in sp887x_sleep()
522 struct sp887x_state* state = fe->demodulator_priv; in sp887x_init() local
526 if (!state->initialised) { in sp887x_init()
529 ret = state->config->request_firmware(fe, &fw, SP887X_DEFAULT_FIRMWARE); in sp887x_init()
542 state->initialised = 1; in sp887x_init()
546 sp887x_writereg(state, 0xc18, 0x00d); in sp887x_init()
561 struct sp887x_state* state = fe->demodulator_priv; in sp887x_release() local
562 kfree(state); in sp887x_release()
570 struct sp887x_state* state = NULL; in sp887x_attach() local
573 state = kzalloc(sizeof(struct sp887x_state), GFP_KERNEL); in sp887x_attach()
574 if (state == NULL) goto error; in sp887x_attach()
577 state->config = config; in sp887x_attach()
578 state->i2c = i2c; in sp887x_attach()
579 state->initialised = 0; in sp887x_attach()
582 if (sp887x_readreg(state, 0x0200) < 0) goto error; in sp887x_attach()
585 memcpy(&state->frontend.ops, &sp887x_ops, sizeof(struct dvb_frontend_ops)); in sp887x_attach()
586 state->frontend.demodulator_priv = state; in sp887x_attach()
587 return &state->frontend; in sp887x_attach()
590 kfree(state); in sp887x_attach()