Lines Matching defs:state
42 static int itd1000_write_regs(struct itd1000_state *state, u8 reg, u8 v[], u8 len)
46 .addr = state->cfg->i2c_address, .flags = 0, .buf = buf, .len = len+1
61 if (i2c_transfer(state->i2c, &msg, 1) != 1) {
68 static int itd1000_read_reg(struct itd1000_state *state, u8 reg)
72 { .addr = state->cfg->i2c_address, .flags = 0, .buf = ®, .len = 1 },
73 { .addr = state->cfg->i2c_address, .flags = I2C_M_RD, .buf = &val, .len = 1 },
77 itd1000_write_regs(state, (reg - 1) & 0xff, &state->shadow[(reg - 1) & 0xff], 1);
79 if (i2c_transfer(state->i2c, msg, 2) != 2) {
86 static inline int itd1000_write_reg(struct itd1000_state *state, u8 r, u8 v)
89 int ret = itd1000_write_regs(state, r, &tmp, 1);
90 state->shadow[r] = tmp;
117 static void itd1000_set_lpf_bw(struct itd1000_state *state, u32 symbol_rate)
120 u8 con1 = itd1000_read_reg(state, CON1) & 0xfd;
121 u8 pllfh = itd1000_read_reg(state, PLLFH) & 0x0f;
122 u8 bbgvmin = itd1000_read_reg(state, BBGVMIN) & 0xf0;
123 u8 bw = itd1000_read_reg(state, BW) & 0xf0;
128 itd1000_write_reg(state, CON1, con1 | (1 << 1));
133 itd1000_write_reg(state, PLLFH, pllfh | (itd1000_lpf_pga[i].pgaext << 4));
134 itd1000_write_reg(state, BBGVMIN, bbgvmin | (itd1000_lpf_pga[i].bbgvmin));
135 itd1000_write_reg(state, BW, bw | (i & 0x0f));
139 itd1000_write_reg(state, CON1, con1 | (0 << 1));
163 static void itd1000_set_vco(struct itd1000_state *state, u32 freq_khz)
166 u8 gvbb_i2c = itd1000_read_reg(state, GVBB_I2C) & 0xbf;
167 u8 vco_chp1_i2c = itd1000_read_reg(state, VCO_CHP1_I2C) & 0x0f;
171 itd1000_write_reg(state, GVBB_I2C, gvbb_i2c | (1 << 6));
175 itd1000_write_reg(state, VCO_CHP1_I2C, vco_chp1_i2c | (itd1000_vcorg[i].vcorg << 4));
178 adcout = itd1000_read_reg(state, PLLLOCK) & 0x0f;
184 itd1000_write_reg(state, VCO_CHP1_I2C, vco_chp1_i2c | ((itd1000_vcorg[i].vcorg + 1) << 4));
187 itd1000_write_reg(state, VCO_CHP1_I2C, vco_chp1_i2c | ((itd1000_vcorg[i].vcorg - 1) << 4));
213 static void itd1000_set_lo(struct itd1000_state *state, u32 freq_khz)
229 state->frequency = ((plln * 1000) + (pllf * 1000)/1048576) * 2*FREF;
230 itd_dbg("frequency: %dkHz (wanted) %dkHz (set), PLLF = %d, PLLN = %d\n", freq_khz, state->frequency, pllf, plln);
232 itd1000_write_reg(state, PLLNH, 0x80); /* PLLNH */
233 itd1000_write_reg(state, PLLNL, plln & 0xff);
234 itd1000_write_reg(state, PLLFH, (itd1000_read_reg(state, PLLFH) & 0xf0) | ((pllf >> 16) & 0x0f));
235 itd1000_write_reg(state, PLLFM, (pllf >> 8) & 0xff);
236 itd1000_write_reg(state, PLLFL, (pllf >> 0) & 0xff);
241 itd1000_write_reg(state, RFTR, itd1000_fre_values[i].values[0]);
243 itd1000_write_reg(state, RFST1+j, itd1000_fre_values[i].values[j+1]);
248 itd1000_set_vco(state, freq_khz);
254 struct itd1000_state *state = fe->tuner_priv;
257 itd1000_set_lo(state, c->frequency);
258 itd1000_set_lpf_bw(state, c->symbol_rate);
260 pllcon1 = itd1000_read_reg(state, PLLCON1) & 0x7f;
261 itd1000_write_reg(state, PLLCON1, pllcon1 | (1 << 7));
262 itd1000_write_reg(state, PLLCON1, pllcon1);
269 struct itd1000_state *state = fe->tuner_priv;
270 *frequency = state->frequency;
321 struct itd1000_state *state = fe->tuner_priv;
325 itd1000_write_reg(state, itd1000_init_tab[i][0], itd1000_init_tab[i][1]);
328 itd1000_write_reg(state, itd1000_reinit_tab[i][0], itd1000_reinit_tab[i][1]);
365 struct itd1000_state *state = NULL;
368 state = kzalloc(sizeof(struct itd1000_state), GFP_KERNEL);
369 if (state == NULL)
372 state->cfg = cfg;
373 state->i2c = i2c;
375 i = itd1000_read_reg(state, 0);
377 kfree(state);
382 memset(state->shadow, 0xff, sizeof(state->shadow));
384 state->shadow[i] = itd1000_read_reg(state, i);
388 fe->tuner_priv = state;