Lines Matching defs:state
77 static int i2c_write_demod_bytes (struct lgdt330x_state* state,
82 { .addr = state->config->demod_address,
90 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
107 static u8 i2c_read_demod_bytes (struct lgdt330x_state* state,
112 { .addr = state->config->demod_address,
114 { .addr = state->config->demod_address,
118 ret = i2c_transfer(state->i2c, msg, 2);
120 printk(KERN_WARNING "lgdt330x: %s: addr 0x%02x select 0x%02x error (ret == %i)\n", __func__, state->config->demod_address, reg, ret);
128 static int lgdt3302_SwReset(struct lgdt330x_state* state)
137 ret = i2c_write_demod_bytes(state,
143 ret = i2c_write_demod_bytes(state,
149 static int lgdt3303_SwReset(struct lgdt330x_state* state)
157 ret = i2c_write_demod_bytes(state,
163 ret = i2c_write_demod_bytes(state,
169 static int lgdt330x_SwReset(struct lgdt330x_state* state)
171 switch (state->config->demod_chip) {
173 return lgdt3302_SwReset(state);
175 return lgdt3303_SwReset(state);
239 struct lgdt330x_state* state = fe->demodulator_priv;
243 switch (state->config->demod_chip) {
246 err = i2c_write_demod_bytes(state, lgdt3302_init_data,
251 switch (state->config->clock_polarity_flip) {
253 err = i2c_write_demod_bytes(state,
258 err = i2c_write_demod_bytes(state,
264 err = i2c_write_demod_bytes(state, lgdt3303_init_data,
276 return lgdt330x_SwReset(state);
287 struct lgdt330x_state* state = fe->demodulator_priv;
291 switch (state->config->demod_chip) {
293 err = i2c_read_demod_bytes(state, LGDT3302_PACKET_ERR_COUNTER1,
297 err = i2c_read_demod_bytes(state, LGDT3303_PACKET_ERR_COUNTER1,
342 struct lgdt330x_state* state = fe->demodulator_priv;
348 if (state->current_modulation != param->u.vsb.modulation) {
357 if (state->config->pll_rf_set)
358 state->config->pll_rf_set(fe, 1);
360 if (state->config->demod_chip == LGDT3303) {
361 err = i2c_write_demod_bytes(state, lgdt3303_8vsb_44_data,
373 if (state->config->pll_rf_set)
374 state->config->pll_rf_set(fe, 0);
376 if (state->config->demod_chip == LGDT3303) {
377 err = i2c_write_demod_bytes(state, lgdt3303_qam_data,
389 if (state->config->pll_rf_set)
390 state->config->pll_rf_set(fe, 0);
392 if (state->config->demod_chip == LGDT3303) {
393 err = i2c_write_demod_bytes(state, lgdt3303_qam_data,
406 top_ctrl_cfg[1] |= state->config->serial_mpeg;
409 i2c_write_demod_bytes(state, top_ctrl_cfg,
411 if (state->config->set_ts_params)
412 state->config->set_ts_params(fe, 0);
413 state->current_modulation = param->u.vsb.modulation;
424 state->current_frequency = param->frequency;
426 lgdt330x_SwReset(state);
433 struct lgdt330x_state *state = fe->demodulator_priv;
434 param->frequency = state->current_frequency;
440 struct lgdt330x_state* state = fe->demodulator_priv;
446 i2c_read_demod_bytes(state, AGC_STATUS, buf, 1);
460 i2c_read_demod_bytes(state, TOP_CONTROL, buf, sizeof(buf));
476 i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1);
478 switch (state->current_modulation) {
498 struct lgdt330x_state* state = fe->demodulator_priv;
505 err = i2c_read_demod_bytes(state, 0x58, buf, 1);
517 i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1);
519 switch (state->current_modulation) {
527 i2c_read_demod_bytes(state, 0x8a, buf, 1);
540 i2c_read_demod_bytes(state, 0x38, buf, 1);
594 struct lgdt330x_state* state = (struct lgdt330x_state*) fe->demodulator_priv;
599 switch(state->current_modulation) {
601 i2c_read_demod_bytes(state, LGDT3302_EQPH_ERR0, buf, 5);
616 i2c_read_demod_bytes(state, CARRIER_MSEQAM1, buf, 2);
618 c = state->current_modulation == QAM_64 ? 97939837 : 98026066;
627 state->snr = calculate_snr(noise, c);
628 *snr = (state->snr) >> 16; /* Convert from 8.24 fixed-point to 8.8 */
631 state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16);
638 struct lgdt330x_state* state = (struct lgdt330x_state*) fe->demodulator_priv;
643 switch(state->current_modulation) {
645 i2c_read_demod_bytes(state, LGDT3303_EQPH_ERR0, buf, 5);
660 i2c_read_demod_bytes(state, CARRIER_MSEQAM1, buf, 2);
662 c = state->current_modulation == QAM_64 ? 97939837 : 98026066;
671 state->snr = calculate_snr(noise, c);
672 *snr = (state->snr) >> 16; /* Convert from 8.24 fixed-point to 8.8 */
675 state->snr >> 24, (((state->snr >> 8) & 0xffff) * 100) >> 16);
685 struct lgdt330x_state* state = (struct lgdt330x_state*) fe->demodulator_priv;
692 /* Rather than use the 8.8 value snr, use state->snr which is 8.24 */
694 if (state->snr >= 8960 * 0x10000)
697 *strength = state->snr / 8960;
713 struct lgdt330x_state* state = (struct lgdt330x_state*) fe->demodulator_priv;
714 kfree(state);
723 struct lgdt330x_state* state = NULL;
726 /* Allocate memory for the internal state */
727 state = kzalloc(sizeof(struct lgdt330x_state), GFP_KERNEL);
728 if (state == NULL)
731 /* Setup the state */
732 state->config = config;
733 state->i2c = i2c;
738 memcpy(&state->frontend.ops, &lgdt3302_ops, sizeof(struct dvb_frontend_ops));
741 memcpy(&state->frontend.ops, &lgdt3303_ops, sizeof(struct dvb_frontend_ops));
746 state->frontend.demodulator_priv = state;
749 if (i2c_read_demod_bytes(state, 2, buf, 1))
752 state->current_frequency = -1;
753 state->current_modulation = -1;
755 return &state->frontend;
758 kfree(state);