Lines Matching refs:state
52 static int tda10086_write_byte(struct tda10086_state *state, int reg, int data) in tda10086_write_byte() argument
58 msg.addr = state->config->demod_address; in tda10086_write_byte()
59 ret = i2c_transfer(state->i2c, &msg, 1); in tda10086_write_byte()
68 static int tda10086_read_byte(struct tda10086_state *state, int reg) in tda10086_read_byte() argument
76 msg[0].addr = state->config->demod_address; in tda10086_read_byte()
77 msg[1].addr = state->config->demod_address; in tda10086_read_byte()
78 ret = i2c_transfer(state->i2c, msg, 2); in tda10086_read_byte()
89 static int tda10086_write_mask(struct tda10086_state *state, int reg, int mask, int data) in tda10086_write_mask() argument
94 val = tda10086_read_byte(state, reg); in tda10086_write_mask()
103 return tda10086_write_byte(state, reg, val); in tda10086_write_mask()
108 struct tda10086_state* state = fe->demodulator_priv; in tda10086_init() local
113 if (state->config->diseqc_tone) in tda10086_init()
116 tda10086_write_byte(state, 0x00, 0x00); in tda10086_init()
120 tda10086_write_byte(state, 0x01, 0x94); in tda10086_init()
121 tda10086_write_byte(state, 0x02, 0x35); /* NOTE: TT drivers appear to disable CSWP */ in tda10086_init()
122 tda10086_write_byte(state, 0x03, 0xe4); in tda10086_init()
123 tda10086_write_byte(state, 0x04, 0x43); in tda10086_init()
124 tda10086_write_byte(state, 0x0c, 0x0c); in tda10086_init()
125 tda10086_write_byte(state, 0x1b, 0xb0); /* noise threshold */ in tda10086_init()
126 tda10086_write_byte(state, 0x20, 0x89); /* misc */ in tda10086_init()
127 tda10086_write_byte(state, 0x30, 0x04); /* acquisition period length */ in tda10086_init()
128 tda10086_write_byte(state, 0x32, 0x00); /* irq off */ in tda10086_init()
129 tda10086_write_byte(state, 0x31, 0x56); /* setup AFC */ in tda10086_init()
132 tda10086_write_byte(state, 0x55, 0x2c); /* misc PLL setup */ in tda10086_init()
133 if (state->config->xtal_freq == TDA10086_XTAL_16M) { in tda10086_init()
134 tda10086_write_byte(state, 0x3a, 0x0b); /* M=12 */ in tda10086_init()
135 tda10086_write_byte(state, 0x3b, 0x01); /* P=2 */ in tda10086_init()
137 tda10086_write_byte(state, 0x3a, 0x17); /* M=24 */ in tda10086_init()
138 tda10086_write_byte(state, 0x3b, 0x00); /* P=1 */ in tda10086_init()
140 tda10086_write_mask(state, 0x55, 0x20, 0x00); /* powerup PLL */ in tda10086_init()
143 tda10086_write_byte(state, 0x11, 0x81); in tda10086_init()
144 tda10086_write_byte(state, 0x12, 0x81); in tda10086_init()
145 tda10086_write_byte(state, 0x19, 0x40); /* parallel mode A + MSBFIRST */ in tda10086_init()
146 tda10086_write_byte(state, 0x56, 0x80); /* powerdown WPLL - unused in the mode we use */ in tda10086_init()
147 tda10086_write_byte(state, 0x57, 0x08); /* bypass WPLL - unused in the mode we use */ in tda10086_init()
148 tda10086_write_byte(state, 0x10, 0x2a); in tda10086_init()
151 tda10086_write_byte(state, 0x58, 0x61); /* ADC setup */ in tda10086_init()
152 tda10086_write_mask(state, 0x58, 0x01, 0x00); /* powerup ADC */ in tda10086_init()
155 tda10086_write_byte(state, 0x05, 0x0B); in tda10086_init()
156 tda10086_write_byte(state, 0x37, 0x63); in tda10086_init()
157 tda10086_write_byte(state, 0x3f, 0x0a); /* NOTE: flydvb varies it */ in tda10086_init()
158 tda10086_write_byte(state, 0x40, 0x64); in tda10086_init()
159 tda10086_write_byte(state, 0x41, 0x4f); in tda10086_init()
160 tda10086_write_byte(state, 0x42, 0x43); in tda10086_init()
163 tda10086_write_byte(state, 0x1a, 0x11); /* VBER 10^6, DVB, QPSK */ in tda10086_init()
166 tda10086_write_byte(state, 0x3d, 0x80); in tda10086_init()
169 tda10086_write_byte(state, 0x36, t22k_off); /* all SEC off, 22k tone */ in tda10086_init()
170 tda10086_write_byte(state, 0x34, (((1<<19) * (22000/1000)) / (SACLK/1000))); in tda10086_init()
171 tda10086_write_byte(state, 0x35, (((1<<19) * (22000/1000)) / (SACLK/1000)) >> 8); in tda10086_init()
176 static void tda10086_diseqc_wait(struct tda10086_state *state) in tda10086_diseqc_wait() argument
179 while (!(tda10086_read_byte(state, 0x50) & 0x01)) { in tda10086_diseqc_wait()
190 struct tda10086_state* state = fe->demodulator_priv; in tda10086_set_tone() local
195 if (state->config->diseqc_tone) in tda10086_set_tone()
200 tda10086_write_byte(state, 0x36, t22k_off); in tda10086_set_tone()
204 tda10086_write_byte(state, 0x36, 0x01 + t22k_off); in tda10086_set_tone()
214 struct tda10086_state* state = fe->demodulator_priv; in tda10086_send_master_cmd() local
221 if (state->config->diseqc_tone) in tda10086_send_master_cmd()
226 oldval = tda10086_read_byte(state, 0x36); in tda10086_send_master_cmd()
229 tda10086_write_byte(state, 0x48+i, cmd->msg[i]); in tda10086_send_master_cmd()
231 tda10086_write_byte(state, 0x36, (0x08 + t22k_off) in tda10086_send_master_cmd()
234 tda10086_diseqc_wait(state); in tda10086_send_master_cmd()
236 tda10086_write_byte(state, 0x36, oldval); in tda10086_send_master_cmd()
243 struct tda10086_state* state = fe->demodulator_priv; in tda10086_send_burst() local
244 u8 oldval = tda10086_read_byte(state, 0x36); in tda10086_send_burst()
249 if (state->config->diseqc_tone) in tda10086_send_burst()
254 tda10086_write_byte(state, 0x36, 0x04 + t22k_off); in tda10086_send_burst()
258 tda10086_write_byte(state, 0x36, 0x06 + t22k_off); in tda10086_send_burst()
262 tda10086_diseqc_wait(state); in tda10086_send_burst()
264 tda10086_write_byte(state, 0x36, oldval); in tda10086_send_burst()
269 static int tda10086_set_inversion(struct tda10086_state *state, in tda10086_set_inversion() argument
274 dprintk ("%s %i %i\n", __func__, fe_params->inversion, state->config->invert); in tda10086_set_inversion()
278 if (state->config->invert) in tda10086_set_inversion()
282 if (!state->config->invert) in tda10086_set_inversion()
289 tda10086_write_mask(state, 0x0c, 0xc0, invval); in tda10086_set_inversion()
294 static int tda10086_set_symbol_rate(struct tda10086_state *state, in tda10086_set_symbol_rate() argument
357 tda10086_write_byte(state, 0x21, (afs << 7) | dfn); in tda10086_set_symbol_rate()
358 tda10086_write_mask(state, 0x20, 0x08, byp << 3); in tda10086_set_symbol_rate()
359 tda10086_write_byte(state, 0x06, bdr); in tda10086_set_symbol_rate()
360 tda10086_write_byte(state, 0x07, bdr >> 8); in tda10086_set_symbol_rate()
361 tda10086_write_byte(state, 0x08, bdr >> 16); in tda10086_set_symbol_rate()
362 tda10086_write_byte(state, 0x09, bdri); in tda10086_set_symbol_rate()
363 tda10086_write_byte(state, 0x37, reg37); in tda10086_set_symbol_rate()
364 tda10086_write_byte(state, 0x42, reg42); in tda10086_set_symbol_rate()
369 static int tda10086_set_fec(struct tda10086_state *state, in tda10086_set_fec() argument
407 tda10086_write_byte(state, 0x0d, fecval); in tda10086_set_fec()
415 struct tda10086_state *state = fe->demodulator_priv; in tda10086_set_frontend() local
423 tda10086_write_byte(state, 0x02, 0x35); in tda10086_set_frontend()
424 state->has_lock = false; in tda10086_set_frontend()
441 tda10086_write_byte(state, 0x3d, 0x80 | ((freqoff >> 8) & 0x7f)); in tda10086_set_frontend()
442 tda10086_write_byte(state, 0x3e, freqoff); in tda10086_set_frontend()
444 if ((ret = tda10086_set_inversion(state, fe_params)) < 0) in tda10086_set_frontend()
446 if ((ret = tda10086_set_symbol_rate(state, fe_params)) < 0) in tda10086_set_frontend()
448 if ((ret = tda10086_set_fec(state, fe_params)) < 0) in tda10086_set_frontend()
452 tda10086_write_mask(state, 0x10, 0x40, 0x40); in tda10086_set_frontend()
453 tda10086_write_mask(state, 0x00, 0x01, 0x00); in tda10086_set_frontend()
455 state->symbol_rate = fe_params->symbol_rate; in tda10086_set_frontend()
456 state->frequency = fe_params->frequency; in tda10086_set_frontend()
463 struct tda10086_state* state = fe->demodulator_priv; in tda10086_get_frontend() local
475 tmp64 = tda10086_read_byte(state, 0x52); in tda10086_get_frontend()
476 tmp64 |= (tda10086_read_byte(state, 0x51) << 8); in tda10086_get_frontend()
481 fe_params->frequency = (int) state->frequency + (int) tmp64; in tda10086_get_frontend()
484 val = tda10086_read_byte(state, 0x0c); in tda10086_get_frontend()
489 if (state->config->invert) in tda10086_get_frontend()
494 if (state->config->invert) in tda10086_get_frontend()
499 tda10086_read_byte(state, 0x0f); in tda10086_get_frontend()
503 if (state->config->invert) in tda10086_get_frontend()
508 if (state->config->invert) in tda10086_get_frontend()
515 tmp = tda10086_read_byte(state, 0x1d); in tda10086_get_frontend()
519 tmp = ((state->symbol_rate/1000) * tmp) / (1000000/1000); in tda10086_get_frontend()
520 fe_params->symbol_rate = state->symbol_rate + tmp; in tda10086_get_frontend()
523 val = (tda10086_read_byte(state, 0x0d) & 0x70) >> 4; in tda10086_get_frontend()
556 struct tda10086_state* state = fe->demodulator_priv; in tda10086_read_status() local
561 val = tda10086_read_byte(state, 0x0e); in tda10086_read_status()
573 if (!state->has_lock) { in tda10086_read_status()
574 state->has_lock = true; in tda10086_read_status()
576 tda10086_write_byte(state, 0x02, 0x00); in tda10086_read_status()
585 struct tda10086_state* state = fe->demodulator_priv; in tda10086_read_signal_strength() local
590 _str = 0xff - tda10086_read_byte(state, 0x43); in tda10086_read_signal_strength()
598 struct tda10086_state* state = fe->demodulator_priv; in tda10086_read_snr() local
603 _snr = 0xff - tda10086_read_byte(state, 0x1c); in tda10086_read_snr()
611 struct tda10086_state* state = fe->demodulator_priv; in tda10086_read_ucblocks() local
616 *ucblocks = tda10086_read_byte(state, 0x18) & 0x7f; in tda10086_read_ucblocks()
619 tda10086_write_byte(state, 0x18, 0x00); in tda10086_read_ucblocks()
620 tda10086_write_byte(state, 0x18, 0x80); in tda10086_read_ucblocks()
627 struct tda10086_state* state = fe->demodulator_priv; in tda10086_read_ber() local
633 *ber |= tda10086_read_byte(state, 0x15); in tda10086_read_ber()
634 *ber |= tda10086_read_byte(state, 0x16) << 8; in tda10086_read_ber()
635 *ber |= (tda10086_read_byte(state, 0x17) & 0xf) << 16; in tda10086_read_ber()
642 struct tda10086_state* state = fe->demodulator_priv; in tda10086_sleep() local
646 tda10086_write_mask(state, 0x00, 0x08, 0x08); in tda10086_sleep()
653 struct tda10086_state* state = fe->demodulator_priv; in tda10086_i2c_gate_ctrl() local
658 tda10086_write_mask(state, 0x00, 0x10, 0x10); in tda10086_i2c_gate_ctrl()
660 tda10086_write_mask(state, 0x00, 0x10, 0x00); in tda10086_i2c_gate_ctrl()
701 struct tda10086_state *state = fe->demodulator_priv; in tda10086_release() local
703 kfree(state); in tda10086_release()
745 struct tda10086_state *state; in tda10086_attach() local
750 state = kzalloc(sizeof(struct tda10086_state), GFP_KERNEL); in tda10086_attach()
751 if (!state) in tda10086_attach()
755 state->config = config; in tda10086_attach()
756 state->i2c = i2c; in tda10086_attach()
759 if (tda10086_read_byte(state, 0x1e) != 0xe1) { in tda10086_attach()
760 kfree(state); in tda10086_attach()
765 memcpy(&state->frontend.ops, &tda10086_ops, sizeof(struct dvb_frontend_ops)); in tda10086_attach()
766 state->frontend.demodulator_priv = state; in tda10086_attach()
767 return &state->frontend; in tda10086_attach()