Lines Matching defs:state
38 static int nxt6000_writereg(struct nxt6000_state* state, u8 reg, u8 data)
41 struct i2c_msg msg = {.addr = state->config->demod_address,.flags = 0,.buf = buf,.len = 2 };
44 if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1)
50 static u8 nxt6000_readreg(struct nxt6000_state* state, u8 reg)
56 {.addr = state->config->demod_address,.flags = 0,.buf = b0,.len = 1},
57 {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b1,.len = 1}
60 ret = i2c_transfer(state->i2c, msgs, 2);
68 static void nxt6000_reset(struct nxt6000_state* state)
72 val = nxt6000_readreg(state, OFDM_COR_CTL);
74 nxt6000_writereg(state, OFDM_COR_CTL, val & ~COREACT);
75 nxt6000_writereg(state, OFDM_COR_CTL, val | COREACT);
78 static int nxt6000_set_bandwidth(struct nxt6000_state *state, u32 bandwidth)
100 if ((result = nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_1, nominal_rate & 0xFF)) < 0)
103 return nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_2, (nominal_rate >> 8) & 0xFF);
106 static int nxt6000_set_guard_interval(struct nxt6000_state *state,
112 return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x00 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
115 return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x01 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
119 return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x02 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
122 return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x03 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
129 static int nxt6000_set_inversion(struct nxt6000_state *state,
135 return nxt6000_writereg(state, OFDM_ITB_CTL, 0x00);
138 return nxt6000_writereg(state, OFDM_ITB_CTL, ITBINV);
147 nxt6000_set_transmission_mode(struct nxt6000_state *state,
155 if ((result = nxt6000_writereg(state, EN_DMD_RACQ, 0x00 | (nxt6000_readreg(state, EN_DMD_RACQ) & ~0x03))) < 0)
158 return nxt6000_writereg(state, OFDM_COR_MODEGUARD, (0x00 << 2) | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x04));
162 if ((result = nxt6000_writereg(state, EN_DMD_RACQ, 0x02 | (nxt6000_readreg(state, EN_DMD_RACQ) & ~0x03))) < 0)
165 return nxt6000_writereg(state, OFDM_COR_MODEGUARD, (0x01 << 2) | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x04));
175 struct nxt6000_state* state = fe->demodulator_priv;
177 nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM);
178 nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01);
179 nxt6000_writereg(state, VIT_BERTIME_2, 0x00); // BER Timer = 0x000200 * 256 = 131072 bits
180 nxt6000_writereg(state, VIT_BERTIME_1, 0x02); //
181 nxt6000_writereg(state, VIT_BERTIME_0, 0x00); //
182 nxt6000_writereg(state, VIT_COR_INTEN, 0x98); // Enable BER interrupts
183 nxt6000_writereg(state, VIT_COR_CTL, 0x82); // Enable BER measurement
184 nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC | 0x02 );
185 nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F));
186 nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02);
187 nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW);
188 nxt6000_writereg(state, OFDM_ITB_FREQ_1, 0x06);
189 nxt6000_writereg(state, OFDM_ITB_FREQ_2, 0x31);
190 nxt6000_writereg(state, OFDM_CAS_CTL, (0x01 << 7) | (0x02 << 3) | 0x04);
191 nxt6000_writereg(state, CAS_FREQ, 0xBB); /* CHECKME */
192 nxt6000_writereg(state, OFDM_SYR_CTL, 1 << 2);
193 nxt6000_writereg(state, OFDM_PPM_CTL_1, PPM256);
194 nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_1, 0x49);
195 nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_2, 0x72);
196 nxt6000_writereg(state, ANALOG_CONTROL_0, 1 << 5);
197 nxt6000_writereg(state, EN_DMD_RACQ, (1 << 7) | (3 << 4) | 2);
198 nxt6000_writereg(state, DIAG_CONFIG, TB_SET);
200 if (state->config->clock_inversion)
201 nxt6000_writereg(state, SUB_DIAG_MODE_SEL, CLKINVERSION);
203 nxt6000_writereg(state, SUB_DIAG_MODE_SEL, 0);
205 nxt6000_writereg(state, TS_FORMAT, 0);
208 static void nxt6000_dump_status(struct nxt6000_state *state)
236 val = nxt6000_readreg(state, RS_COR_STAT);
241 val = nxt6000_readreg(state, VIT_SYNC_STATUS);
272 val = nxt6000_readreg(state, OFDM_COR_STAT);
314 val = nxt6000_readreg(state, OFDM_SYR_STAT);
338 val = nxt6000_readreg(state, OFDM_TPS_RCVD_3);
394 val = nxt6000_readreg(state, OFDM_TPS_RCVD_4);
419 nxt6000_readreg(state, RF_AGC_VAL_1);
420 val = nxt6000_readreg(state, RF_AGC_STATUS);
421 val = nxt6000_readreg(state, RF_AGC_STATUS);
430 struct nxt6000_state* state = fe->demodulator_priv;
434 core_status = nxt6000_readreg(state, OFDM_COR_STAT);
439 if (nxt6000_readreg(state, OFDM_SYR_STAT) & GI14_SYR_LOCK)
442 if (nxt6000_readreg(state, VIT_SYNC_STATUS) & VITINSYNC)
445 if (nxt6000_readreg(state, RS_COR_STAT) & RSCORESTATUS)
452 nxt6000_dump_status(state);
459 struct nxt6000_state* state = fe->demodulator_priv;
461 nxt6000_reset(state);
470 struct nxt6000_state* state = fe->demodulator_priv;
478 result = nxt6000_set_bandwidth(state, p->bandwidth_hz);
482 result = nxt6000_set_guard_interval(state, p->guard_interval);
486 result = nxt6000_set_transmission_mode(state, p->transmission_mode);
490 result = nxt6000_set_inversion(state, p->inversion);
500 struct nxt6000_state* state = fe->demodulator_priv;
501 kfree(state);
506 struct nxt6000_state* state = fe->demodulator_priv;
508 *snr = nxt6000_readreg( state, OFDM_CHC_SNR) / 8;
515 struct nxt6000_state* state = fe->demodulator_priv;
517 nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18 );
519 *ber = (nxt6000_readreg( state, VIT_BER_1 ) << 8 ) |
520 nxt6000_readreg( state, VIT_BER_0 );
522 nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18); // Clear BER Done interrupts
529 struct nxt6000_state* state = fe->demodulator_priv;
532 (nxt6000_readreg(state, AGC_GAIN_1) +
533 ((nxt6000_readreg(state, AGC_GAIN_2) & 0x03) << 8)));
546 struct nxt6000_state* state = fe->demodulator_priv;
549 return nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01);
551 return nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x00);
560 struct nxt6000_state* state = NULL;
562 /* allocate memory for the internal state */
563 state = kzalloc(sizeof(struct nxt6000_state), GFP_KERNEL);
564 if (state == NULL) goto error;
566 /* setup the state */
567 state->config = config;
568 state->i2c = i2c;
571 if (nxt6000_readreg(state, OFDM_MSC_REV) != NXT6000ASICDEVICE) goto error;
574 memcpy(&state->frontend.ops, &nxt6000_ops, sizeof(struct dvb_frontend_ops));
575 state->frontend.demodulator_priv = state;
576 return &state->frontend;
579 kfree(state);