Lines Matching defs:state
70 static int cx22700_writereg (struct cx22700_state* state, u8 reg, u8 data)
74 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
78 ret = i2c_transfer (state->i2c, &msg, 1);
87 static int cx22700_readreg (struct cx22700_state* state, u8 reg)
92 struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
93 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
97 ret = i2c_transfer (state->i2c, msg, 2);
104 static int cx22700_set_inversion (struct cx22700_state* state, int inversion)
114 val = cx22700_readreg (state, 0x09);
115 return cx22700_writereg (state, 0x09, val | 0x01);
117 val = cx22700_readreg (state, 0x09);
118 return cx22700_writereg (state, 0x09, val & 0xfe);
124 static int cx22700_set_tps (struct cx22700_state *state, struct dvb_ofdm_parameters *p)
162 cx22700_writereg (state, 0x09, cx22700_readreg (state, 0x09 | 0x10));
164 cx22700_writereg (state, 0x09, cx22700_readreg (state, 0x09 & ~0x10));
169 cx22700_writereg (state, 0x04, val);
174 cx22700_writereg (state, 0x05, val);
179 cx22700_writereg (state, 0x06, val);
181 cx22700_writereg (state, 0x08, 0x04 | 0x02); /* use user tps parameters */
182 cx22700_writereg (state, 0x08, 0x04); /* restart aquisition */
187 static int cx22700_get_tps (struct cx22700_state* state, struct dvb_ofdm_parameters *p)
196 if (!(cx22700_readreg(state, 0x07) & 0x20)) /* tps valid? */
199 val = cx22700_readreg (state, 0x01);
211 val = cx22700_readreg (state, 0x02);
223 val = cx22700_readreg (state, 0x03);
233 { struct cx22700_state* state = fe->demodulator_priv;
238 cx22700_writereg (state, 0x00, 0x02); /* soft reset */
239 cx22700_writereg (state, 0x00, 0x00);
244 cx22700_writereg (state, init_tab[i], init_tab[i+1]);
246 cx22700_writereg (state, 0x00, 0x01);
253 struct cx22700_state* state = fe->demodulator_priv;
255 u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
256 | (cx22700_readreg (state, 0x0e) << 1);
257 u8 sync = cx22700_readreg (state, 0x07);
281 struct cx22700_state* state = fe->demodulator_priv;
283 *ber = cx22700_readreg (state, 0x0c) & 0x7f;
284 cx22700_writereg (state, 0x0c, 0x00);
291 struct cx22700_state* state = fe->demodulator_priv;
293 u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
294 | (cx22700_readreg (state, 0x0e) << 1);
302 struct cx22700_state* state = fe->demodulator_priv;
304 u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
305 | (cx22700_readreg (state, 0x0e) << 1);
313 struct cx22700_state* state = fe->demodulator_priv;
315 *ucblocks = cx22700_readreg (state, 0x0f);
316 cx22700_writereg (state, 0x0f, 0x00);
323 struct cx22700_state* state = fe->demodulator_priv;
325 cx22700_writereg (state, 0x00, 0x02);
326 cx22700_writereg (state, 0x00, 0x00);
333 cx22700_set_inversion (state, p->inversion);
334 cx22700_set_tps (state, &p->u.ofdm);
335 cx22700_writereg (state, 0x37, 0x01); /* PAL loop filter off */
336 cx22700_writereg (state, 0x00, 0x01); /* restart acquire */
343 struct cx22700_state* state = fe->demodulator_priv;
344 u8 reg09 = cx22700_readreg (state, 0x09);
347 return cx22700_get_tps (state, &p->u.ofdm);
352 struct cx22700_state* state = fe->demodulator_priv;
355 return cx22700_writereg(state, 0x0a, 0x00);
357 return cx22700_writereg(state, 0x0a, 0x01);
371 struct cx22700_state* state = fe->demodulator_priv;
372 kfree(state);
380 struct cx22700_state* state = NULL;
382 /* allocate memory for the internal state */
383 state = kzalloc(sizeof(struct cx22700_state), GFP_KERNEL);
384 if (state == NULL) goto error;
386 /* setup the state */
387 state->config = config;
388 state->i2c = i2c;
391 if (cx22700_readreg(state, 0x07) < 0) goto error;
394 memcpy(&state->frontend.ops, &cx22700_ops, sizeof(struct dvb_frontend_ops));
395 state->frontend.demodulator_priv = state;
396 return &state->frontend;
399 kfree(state);