Lines Matching refs:state

103 static int cx24110_writereg (struct cx24110_state* state, int reg, int data)  in cx24110_writereg()  argument
106 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; in cx24110_writereg()
109 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { in cx24110_writereg()
118 static int cx24110_readreg (struct cx24110_state* state, u8 reg) in cx24110_readreg() argument
123 …struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 … in cx24110_readreg()
124 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; in cx24110_readreg()
126 ret = i2c_transfer(state->i2c, msg, 2); in cx24110_readreg()
133 static int cx24110_set_inversion(struct cx24110_state *state, in cx24110_set_inversion() argument
140 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1); in cx24110_set_inversion()
142 cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)&0xf7); in cx24110_set_inversion()
144 cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)&0xef); in cx24110_set_inversion()
150 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1); in cx24110_set_inversion()
152 cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)|0x08); in cx24110_set_inversion()
154 cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)|0x10); in cx24110_set_inversion()
158 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xfe); in cx24110_set_inversion()
168 static int cx24110_set_fec(struct cx24110_state *state, enum fe_code_rate fec) in cx24110_set_fec() argument
182 cx24110_writereg(state, 0x37, cx24110_readreg(state, 0x37) & 0xdf); in cx24110_set_fec()
184 cx24110_writereg(state, 0x18, 0xae); in cx24110_set_fec()
186 cx24110_writereg(state, 0x05, (cx24110_readreg(state, 0x05) & 0xf0) | 0x3); in cx24110_set_fec()
188 cx24110_writereg(state, 0x22, (cx24110_readreg(state, 0x22) & 0xf0) | 0x3); in cx24110_set_fec()
190 cx24110_writereg(state, 0x1a, 0x05); in cx24110_set_fec()
191 cx24110_writereg(state, 0x1b, 0x06); in cx24110_set_fec()
195 cx24110_writereg(state, 0x37, cx24110_readreg(state, 0x37) | 0x20); in cx24110_set_fec()
200 cx24110_writereg(state, 0x05, (cx24110_readreg(state, 0x05) & 0xf0) | rate[fec]); in cx24110_set_fec()
202 cx24110_writereg(state, 0x22, (cx24110_readreg(state, 0x22) & 0xf0) | rate[fec]); in cx24110_set_fec()
204 cx24110_writereg(state, 0x1a, g1[fec]); in cx24110_set_fec()
205 cx24110_writereg(state, 0x1b, g2[fec]); in cx24110_set_fec()
211 static enum fe_code_rate cx24110_get_fec(struct cx24110_state *state) in cx24110_get_fec() argument
215 i=cx24110_readreg(state,0x22)&0x0f; in cx24110_get_fec()
227 static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate) in cx24110_set_symbolrate() argument
247 tmp=cx24110_readreg(state,0x07)&0xfc; in cx24110_set_symbolrate()
249 cx24110_writereg(state,0x07,tmp); in cx24110_set_symbolrate()
250 cx24110_writereg(state,0x06,0x78); in cx24110_set_symbolrate()
253 cx24110_writereg(state,0x07,tmp|0x1); in cx24110_set_symbolrate()
254 cx24110_writereg(state,0x06,0xa5); in cx24110_set_symbolrate()
257 cx24110_writereg(state,0x07,tmp|0x2); in cx24110_set_symbolrate()
258 cx24110_writereg(state,0x06,0x87); in cx24110_set_symbolrate()
261 cx24110_writereg(state,0x07,tmp|0x3); in cx24110_set_symbolrate()
262 cx24110_writereg(state,0x06,0x78); in cx24110_set_symbolrate()
291 cx24110_writereg(state, 0x1, (ratio>>16)&0xff); in cx24110_set_symbolrate()
292 cx24110_writereg(state, 0x2, (ratio>>8)&0xff); in cx24110_set_symbolrate()
293 cx24110_writereg(state, 0x3, (ratio)&0xff); in cx24110_set_symbolrate()
301 struct cx24110_state *state = fe->demodulator_priv; in _cx24110_pll_write() local
310 cx24110_writereg(state,0x6d,0x30); /* auto mode at 62kHz */ in _cx24110_pll_write()
311 cx24110_writereg(state,0x70,0x15); /* auto mode 21 bits */ in _cx24110_pll_write()
314 while (cx24110_readreg(state,0x6d)&0x80) in _cx24110_pll_write()
315 cx24110_writereg(state,0x72,0); in _cx24110_pll_write()
318 cx24110_writereg(state,0x72,buf[0]); in _cx24110_pll_write()
321 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80) in _cx24110_pll_write()
325 cx24110_writereg(state,0x72,buf[1]); in _cx24110_pll_write()
326 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80) in _cx24110_pll_write()
330 cx24110_writereg(state,0x72,buf[2]); in _cx24110_pll_write()
331 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80) in _cx24110_pll_write()
335 cx24110_writereg(state,0x6d,0x32); in _cx24110_pll_write()
336 cx24110_writereg(state,0x6d,0x30); in _cx24110_pll_write()
343 struct cx24110_state *state = fe->demodulator_priv; in cx24110_initfe() local
350 cx24110_writereg(state, cx24110_regdata[i].reg, cx24110_regdata[i].data); in cx24110_initfe()
359 struct cx24110_state *state = fe->demodulator_priv; in cx24110_set_voltage() local
363 return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&0x3b)|0xc0); in cx24110_set_voltage()
365 return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&0x3b)|0x40); in cx24110_set_voltage()
375 struct cx24110_state *state = fe->demodulator_priv; in cx24110_diseqc_send_burst() local
385 rv = cx24110_readreg(state, 0x77); in cx24110_diseqc_send_burst()
387 cx24110_writereg(state, 0x77, rv | 0x04); in cx24110_diseqc_send_burst()
389 rv = cx24110_readreg(state, 0x76); in cx24110_diseqc_send_burst()
390 cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); in cx24110_diseqc_send_burst()
392 while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) in cx24110_diseqc_send_burst()
402 struct cx24110_state *state = fe->demodulator_priv; in cx24110_send_diseqc_msg() local
409 cx24110_writereg(state, 0x79 + i, cmd->msg[i]); in cx24110_send_diseqc_msg()
411 rv = cx24110_readreg(state, 0x77); in cx24110_send_diseqc_msg()
413 cx24110_writereg(state, 0x77, rv & ~0x04); in cx24110_send_diseqc_msg()
417 rv = cx24110_readreg(state, 0x76); in cx24110_send_diseqc_msg()
419 cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); in cx24110_send_diseqc_msg()
421 while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) in cx24110_send_diseqc_msg()
430 struct cx24110_state *state = fe->demodulator_priv; in cx24110_read_status() local
432 int sync = cx24110_readreg (state, 0x55); in cx24110_read_status()
442 sync = cx24110_readreg (state, 0x08); in cx24110_read_status()
458 struct cx24110_state *state = fe->demodulator_priv; in cx24110_read_ber() local
461 if(cx24110_readreg(state,0x24)&0x10) { in cx24110_read_ber()
463 cx24110_writereg(state,0x24,0x04); /* select the ber reg */ in cx24110_read_ber()
464 state->lastber=cx24110_readreg(state,0x25)| in cx24110_read_ber()
465 (cx24110_readreg(state,0x26)<<8); in cx24110_read_ber()
466 cx24110_writereg(state,0x24,0x04); /* start new count window */ in cx24110_read_ber()
467 cx24110_writereg(state,0x24,0x14); in cx24110_read_ber()
469 *ber = state->lastber; in cx24110_read_ber()
476 struct cx24110_state *state = fe->demodulator_priv; in cx24110_read_signal_strength() local
479 u8 signal = cx24110_readreg (state, 0x27)+128; in cx24110_read_signal_strength()
487 struct cx24110_state *state = fe->demodulator_priv; in cx24110_read_snr() local
490 if(cx24110_readreg(state,0x6a)&0x80) { in cx24110_read_snr()
492 state->lastesn0=cx24110_readreg(state,0x69)| in cx24110_read_snr()
493 (cx24110_readreg(state,0x68)<<8); in cx24110_read_snr()
494 cx24110_writereg(state,0x6a,0x84); /* start new count window */ in cx24110_read_snr()
496 *snr = state->lastesn0; in cx24110_read_snr()
503 struct cx24110_state *state = fe->demodulator_priv; in cx24110_read_ucblocks() local
505 if(cx24110_readreg(state,0x10)&0x40) { in cx24110_read_ucblocks()
507 cx24110_writereg(state,0x10,0x60); /* select the byer reg */ in cx24110_read_ucblocks()
508 (void)(cx24110_readreg(state, 0x12) | in cx24110_read_ucblocks()
509 (cx24110_readreg(state, 0x13) << 8) | in cx24110_read_ucblocks()
510 (cx24110_readreg(state, 0x14) << 16)); in cx24110_read_ucblocks()
511 cx24110_writereg(state,0x10,0x70); /* select the bler reg */ in cx24110_read_ucblocks()
512 state->lastbler=cx24110_readreg(state,0x12)| in cx24110_read_ucblocks()
513 (cx24110_readreg(state,0x13)<<8)| in cx24110_read_ucblocks()
514 (cx24110_readreg(state,0x14)<<16); in cx24110_read_ucblocks()
515 cx24110_writereg(state,0x10,0x20); /* start new count window */ in cx24110_read_ucblocks()
517 *ucblocks = state->lastbler; in cx24110_read_ucblocks()
524 struct cx24110_state *state = fe->demodulator_priv; in cx24110_set_frontend() local
532 cx24110_set_inversion(state, p->inversion); in cx24110_set_frontend()
533 cx24110_set_fec(state, p->fec_inner); in cx24110_set_frontend()
534 cx24110_set_symbolrate(state, p->symbol_rate); in cx24110_set_frontend()
535 cx24110_writereg(state,0x04,0x05); /* start acquisition */ in cx24110_set_frontend()
543 struct cx24110_state *state = fe->demodulator_priv; in cx24110_get_frontend() local
548 sclk = cx24110_readreg (state, 0x07) & 0x03; in cx24110_get_frontend()
556 afc = sclk*(cx24110_readreg (state, 0x44)&0x1f)+ in cx24110_get_frontend()
557 ((sclk*cx24110_readreg (state, 0x45))>>8)+ in cx24110_get_frontend()
558 ((sclk*cx24110_readreg (state, 0x46))>>16); in cx24110_get_frontend()
561 p->inversion = (cx24110_readreg (state, 0x22) & 0x10) ? in cx24110_get_frontend()
563 p->fec_inner = cx24110_get_fec(state); in cx24110_get_frontend()
571 struct cx24110_state *state = fe->demodulator_priv; in cx24110_set_tone() local
573 …return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&~0x10)|(((tone==SEC_TONE_ON))?0x10… in cx24110_set_tone()
578 struct cx24110_state* state = fe->demodulator_priv; in cx24110_release() local
579 kfree(state); in cx24110_release()
587 struct cx24110_state* state = NULL; in cx24110_attach() local
591 state = kzalloc(sizeof(struct cx24110_state), GFP_KERNEL); in cx24110_attach()
592 if (state == NULL) goto error; in cx24110_attach()
595 state->config = config; in cx24110_attach()
596 state->i2c = i2c; in cx24110_attach()
597 state->lastber = 0; in cx24110_attach()
598 state->lastbler = 0; in cx24110_attach()
599 state->lastesn0 = 0; in cx24110_attach()
602 ret = cx24110_readreg(state, 0x00); in cx24110_attach()
606 memcpy(&state->frontend.ops, &cx24110_ops, sizeof(struct dvb_frontend_ops)); in cx24110_attach()
607 state->frontend.demodulator_priv = state; in cx24110_attach()
608 return &state->frontend; in cx24110_attach()
611 kfree(state); in cx24110_attach()