Lines Matching defs:state
56 static int itd1000_write_regs(struct itd1000_state *state, u8 reg, u8 v[], u8 len)
60 .addr = state->cfg->i2c_address, .flags = 0, .buf = buf, .len = len+1
67 if (i2c_transfer(state->i2c, &msg, 1) != 1) {
74 static int itd1000_read_reg(struct itd1000_state *state, u8 reg)
78 { .addr = state->cfg->i2c_address, .flags = 0, .buf = ®, .len = 1 },
79 { .addr = state->cfg->i2c_address, .flags = I2C_M_RD, .buf = &val, .len = 1 },
82 itd1000_write_regs(state, (reg - 1) & 0xff, &state->shadow[(reg - 1) & 0xff], 1);
84 if (i2c_transfer(state->i2c, msg, 2) != 2) {
91 static inline int itd1000_write_reg(struct itd1000_state *state, u8 r, u8 v)
93 int ret = itd1000_write_regs(state, r, &v, 1);
94 state->shadow[r] = v;
121 static void itd1000_set_lpf_bw(struct itd1000_state *state, u32 symbol_rate)
124 u8 con1 = itd1000_read_reg(state, CON1) & 0xfd;
125 u8 pllfh = itd1000_read_reg(state, PLLFH) & 0x0f;
126 u8 bbgvmin = itd1000_read_reg(state, BBGVMIN) & 0xf0;
127 u8 bw = itd1000_read_reg(state, BW) & 0xf0;
132 itd1000_write_reg(state, CON1, con1 | (1 << 1));
137 itd1000_write_reg(state, PLLFH, pllfh | (itd1000_lpf_pga[i].pgaext << 4));
138 itd1000_write_reg(state, BBGVMIN, bbgvmin | (itd1000_lpf_pga[i].bbgvmin));
139 itd1000_write_reg(state, BW, bw | (i & 0x0f));
143 itd1000_write_reg(state, CON1, con1 | (0 << 1));
167 static void itd1000_set_vco(struct itd1000_state *state, u32 freq_khz)
170 u8 gvbb_i2c = itd1000_read_reg(state, GVBB_I2C) & 0xbf;
171 u8 vco_chp1_i2c = itd1000_read_reg(state, VCO_CHP1_I2C) & 0x0f;
175 itd1000_write_reg(state, GVBB_I2C, gvbb_i2c | (1 << 6));
179 itd1000_write_reg(state, VCO_CHP1_I2C, vco_chp1_i2c | (itd1000_vcorg[i].vcorg << 4));
182 adcout = itd1000_read_reg(state, PLLLOCK) & 0x0f;
188 itd1000_write_reg(state, VCO_CHP1_I2C, vco_chp1_i2c | ((itd1000_vcorg[i].vcorg + 1) << 4));
191 itd1000_write_reg(state, VCO_CHP1_I2C, vco_chp1_i2c | ((itd1000_vcorg[i].vcorg - 1) << 4));
217 static void itd1000_set_lo(struct itd1000_state *state, u32 freq_khz)
233 state->frequency = ((plln * 1000) + (pllf * 1000)/1048576) * 2*FREF;
234 deb("frequency: %dkHz (wanted) %dkHz (set), PLLF = %d, PLLN = %d", freq_khz, state->frequency, pllf, plln);
236 itd1000_write_reg(state, PLLNH, 0x80); /* PLLNH */;
237 itd1000_write_reg(state, PLLNL, plln & 0xff);
238 itd1000_write_reg(state, PLLFH, (itd1000_read_reg(state, PLLFH) & 0xf0) | ((pllf >> 16) & 0x0f));
239 itd1000_write_reg(state, PLLFM, (pllf >> 8) & 0xff);
240 itd1000_write_reg(state, PLLFL, (pllf >> 0) & 0xff);
245 itd1000_write_reg(state, RFTR, itd1000_fre_values[i].values[0]);
247 itd1000_write_reg(state, RFST1+j, itd1000_fre_values[i].values[j+1]);
252 itd1000_set_vco(state, freq_khz);
257 struct itd1000_state *state = fe->tuner_priv;
260 itd1000_set_lo(state, p->frequency);
261 itd1000_set_lpf_bw(state, p->u.qpsk.symbol_rate);
263 pllcon1 = itd1000_read_reg(state, PLLCON1) & 0x7f;
264 itd1000_write_reg(state, PLLCON1, pllcon1 | (1 << 7));
265 itd1000_write_reg(state, PLLCON1, pllcon1);
272 struct itd1000_state *state = fe->tuner_priv;
273 *frequency = state->frequency;
324 struct itd1000_state *state = fe->tuner_priv;
328 itd1000_write_reg(state, itd1000_init_tab[i][0], itd1000_init_tab[i][1]);
331 itd1000_write_reg(state, itd1000_reinit_tab[i][0], itd1000_reinit_tab[i][1]);
369 struct itd1000_state *state = NULL;
372 state = kzalloc(sizeof(struct itd1000_state), GFP_KERNEL);
373 if (state == NULL)
376 state->cfg = cfg;
377 state->i2c = i2c;
379 i = itd1000_read_reg(state, 0);
381 kfree(state);
386 memset(state->shadow, 0xff, sizeof(state->shadow));
388 state->shadow[i] = itd1000_read_reg(state, i);
392 fe->tuner_priv = state;