Lines Matching defs:state
66 static int sp8870_writereg (struct sp8870_state* state, u16 reg, u16 data)
69 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 4 };
72 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
80 static int sp8870_readreg (struct sp8870_state* state, u16 reg)
85 struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
86 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 } };
88 ret = i2c_transfer (state->i2c, msg, 2);
98 static int sp8870_firmware_upload (struct sp8870_state* state, const struct firmware *fw)
113 sp8870_writereg(state, 0x0F00, 0x0000);
116 sp8870_writereg(state, 0x8F08, ((SP8870_FIRMWARE_SIZE / 2) & 0xFFFF));
119 sp8870_writereg(state, 0x8F0A, ((SP8870_FIRMWARE_SIZE / 2) >> 16));
129 msg.addr = state->config->demod_address;
133 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
145 static void sp8870_microcontroller_stop (struct sp8870_state* state)
147 sp8870_writereg(state, 0x0F08, 0x000);
148 sp8870_writereg(state, 0x0F09, 0x000);
151 sp8870_writereg(state, 0x0F00, 0x000);
154 static void sp8870_microcontroller_start (struct sp8870_state* state)
156 sp8870_writereg(state, 0x0F08, 0x000);
157 sp8870_writereg(state, 0x0F09, 0x000);
160 sp8870_writereg(state, 0x0F00, 0x001);
163 sp8870_readreg(state, 0x0D01);
166 static int sp8870_read_data_valid_signal(struct sp8870_state* state)
168 return (sp8870_readreg(state, 0x0D02) > 0);
242 static int sp8870_wake_up(struct sp8870_state* state)
245 return sp8870_writereg(state, 0xC18, 0x00D);
251 struct sp8870_state* state = fe->demodulator_priv;
259 sp8870_microcontroller_stop(state);
268 sp8870_writereg(state, 0x0319, 0x000A);
271 sp8870_writereg(state, 0x031A, 0x0AAB);
274 sp8870_writereg(state, 0x0309, 0x0400);
277 sp8870_writereg(state, 0x030A, 0x0000);
281 sp8870_writereg(state, 0x0311, 0x0002);
283 sp8870_writereg(state, 0x0311, 0x0001);
285 sp8870_writereg(state, 0x0311, 0x0000);
289 sp8870_writereg(state, 0x0338, 0x0000);
291 sp8870_writereg(state, 0x0338, 0x0001);
293 sp8870_writereg(state, 0xc05, reg0xc05);
296 sp8870_readreg(state, 0x200);
299 sp8870_microcontroller_start(state);
306 struct sp8870_state* state = fe->demodulator_priv;
309 sp8870_wake_up(state);
310 if (state->initialised) return 0;
311 state->initialised = 1;
318 if (state->config->request_firmware(fe, &fw, SP8870_DEFAULT_FIRMWARE)) {
323 if (sp8870_firmware_upload(state, fw)) {
332 sp8870_writereg(state, 0xc18, 0x00d);
335 sp8870_microcontroller_stop(state);
338 sp8870_writereg(state, 0x0301, 0x0003);
341 sp8870_writereg(state, 0x0C13, 0x0001);
344 sp8870_writereg(state, 0x0C14, 0x0001);
347 sp8870_writereg(state, 0x0D00, 0x010);
348 sp8870_writereg(state, 0x0D01, 0x000);
355 struct sp8870_state* state = fe->demodulator_priv;
361 status = sp8870_readreg (state, 0x0200);
365 signal = sp8870_readreg (state, 0x0303);
381 struct sp8870_state* state = fe->demodulator_priv;
387 ret = sp8870_readreg(state, 0xC08);
393 ret = sp8870_readreg(state, 0xC07);
409 struct sp8870_state* state = fe->demodulator_priv;
415 ret = sp8870_readreg (state, 0x306);
421 ret = sp8870_readreg (state, 0x303);
435 struct sp8870_state* state = fe->demodulator_priv;
440 ret = sp8870_readreg(state, 0xC0C);
464 struct sp8870_state* state = fe->demodulator_priv;
487 valid = sp8870_read_data_valid_signal(state);
521 struct sp8870_state* state = fe->demodulator_priv;
524 return sp8870_writereg(state, 0xC18, 0x000);
537 struct sp8870_state* state = fe->demodulator_priv;
540 return sp8870_writereg(state, 0x206, 0x001);
542 return sp8870_writereg(state, 0x206, 0x000);
548 struct sp8870_state* state = fe->demodulator_priv;
549 kfree(state);
557 struct sp8870_state* state = NULL;
559 /* allocate memory for the internal state */
560 state = kzalloc(sizeof(struct sp8870_state), GFP_KERNEL);
561 if (state == NULL) goto error;
563 /* setup the state */
564 state->config = config;
565 state->i2c = i2c;
566 state->initialised = 0;
569 if (sp8870_readreg(state, 0x0200) < 0) goto error;
572 memcpy(&state->frontend.ops, &sp8870_ops, sizeof(struct dvb_frontend_ops));
573 state->frontend.demodulator_priv = state;
574 return &state->frontend;
577 kfree(state);