Lines Matching refs:state

76 static u16 dib7000m_read_word(struct dib7000m_state *state, u16 reg)  in dib7000m_read_word()  argument
80 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib7000m_read_word()
85 state->i2c_write_buffer[0] = (reg >> 8) | 0x80; in dib7000m_read_word()
86 state->i2c_write_buffer[1] = reg & 0xff; in dib7000m_read_word()
88 memset(state->msg, 0, 2 * sizeof(struct i2c_msg)); in dib7000m_read_word()
89 state->msg[0].addr = state->i2c_addr >> 1; in dib7000m_read_word()
90 state->msg[0].flags = 0; in dib7000m_read_word()
91 state->msg[0].buf = state->i2c_write_buffer; in dib7000m_read_word()
92 state->msg[0].len = 2; in dib7000m_read_word()
93 state->msg[1].addr = state->i2c_addr >> 1; in dib7000m_read_word()
94 state->msg[1].flags = I2C_M_RD; in dib7000m_read_word()
95 state->msg[1].buf = state->i2c_read_buffer; in dib7000m_read_word()
96 state->msg[1].len = 2; in dib7000m_read_word()
98 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2) in dib7000m_read_word()
101 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1]; in dib7000m_read_word()
102 mutex_unlock(&state->i2c_buffer_lock); in dib7000m_read_word()
107 static int dib7000m_write_word(struct dib7000m_state *state, u16 reg, u16 val) in dib7000m_write_word() argument
111 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib7000m_write_word()
116 state->i2c_write_buffer[0] = (reg >> 8) & 0xff; in dib7000m_write_word()
117 state->i2c_write_buffer[1] = reg & 0xff; in dib7000m_write_word()
118 state->i2c_write_buffer[2] = (val >> 8) & 0xff; in dib7000m_write_word()
119 state->i2c_write_buffer[3] = val & 0xff; in dib7000m_write_word()
121 memset(&state->msg[0], 0, sizeof(struct i2c_msg)); in dib7000m_write_word()
122 state->msg[0].addr = state->i2c_addr >> 1; in dib7000m_write_word()
123 state->msg[0].flags = 0; in dib7000m_write_word()
124 state->msg[0].buf = state->i2c_write_buffer; in dib7000m_write_word()
125 state->msg[0].len = 4; in dib7000m_write_word()
127 ret = (i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ? in dib7000m_write_word()
129 mutex_unlock(&state->i2c_buffer_lock); in dib7000m_write_word()
132 static void dib7000m_write_tab(struct dib7000m_state *state, u16 *buf) in dib7000m_write_tab() argument
140 if (state->reg_offs && (r >= 112 && r <= 331)) // compensate for 7000MC in dib7000m_write_tab()
144 dib7000m_write_word(state, r, *n++); in dib7000m_write_tab()
151 static int dib7000m_set_output_mode(struct dib7000m_state *state, int mode) in dib7000m_set_output_mode() argument
159 smo_mode = (dib7000m_read_word(state, 294 + state->reg_offs) & 0x0010) | (1 << 1); in dib7000m_set_output_mode()
161 dprintk("setting output mode for demod %p to %d\n", &state->demod, mode); in dib7000m_set_output_mode()
174 if (state->cfg.hostbus_diversity) in dib7000m_set_output_mode()
188 dprintk("Unhandled output_mode passed to be set for demod %p\n", &state->demod); in dib7000m_set_output_mode()
192 if (state->cfg.output_mpeg2_in_188_bytes) in dib7000m_set_output_mode()
195 ret |= dib7000m_write_word(state, 294 + state->reg_offs, smo_mode); in dib7000m_set_output_mode()
196 ret |= dib7000m_write_word(state, 295 + state->reg_offs, fifo_threshold); /* synchronous fread */ in dib7000m_set_output_mode()
197 ret |= dib7000m_write_word(state, 1795, outreg); in dib7000m_set_output_mode()
198 ret |= dib7000m_write_word(state, 1805, sram); in dib7000m_set_output_mode()
200 if (state->revision == 0x4003) { in dib7000m_set_output_mode()
201 u16 clk_cfg1 = dib7000m_read_word(state, 909) & 0xfffd; in dib7000m_set_output_mode()
204 dib7000m_write_word(state, 909, clk_cfg1); in dib7000m_set_output_mode()
209 static void dib7000m_set_power_mode(struct dib7000m_state *state, enum dib7000m_power_mode mode) in dib7000m_set_power_mode() argument
245 if (!state->cfg.mobile_mode) in dib7000m_set_power_mode()
249 if (state->revision != 0x4000) in dib7000m_set_power_mode()
252 if (state->revision == 0x4003) in dib7000m_set_power_mode()
255 dib7000m_write_word(state, 903 + offset, reg_903); in dib7000m_set_power_mode()
256 dib7000m_write_word(state, 904 + offset, reg_904); in dib7000m_set_power_mode()
257 dib7000m_write_word(state, 905 + offset, reg_905); in dib7000m_set_power_mode()
258 dib7000m_write_word(state, 906 + offset, reg_906); in dib7000m_set_power_mode()
261 static int dib7000m_set_adc_state(struct dib7000m_state *state, enum dibx000_adc_states no) in dib7000m_set_adc_state() argument
264 u16 reg_913 = dib7000m_read_word(state, 913), in dib7000m_set_adc_state()
265 reg_914 = dib7000m_read_word(state, 914); in dib7000m_set_adc_state()
270 ret |= dib7000m_write_word(state, 914, reg_914); in dib7000m_set_adc_state()
279 if (state->revision == 0x4000) { // workaround for PA/MA in dib7000m_set_adc_state()
281 dib7000m_write_word(state, 913, 0); in dib7000m_set_adc_state()
282 dib7000m_write_word(state, 914, reg_914 & 0x3); in dib7000m_set_adc_state()
284 dib7000m_write_word(state, 913, (1 << 15)); in dib7000m_set_adc_state()
285 dib7000m_write_word(state, 914, reg_914 & 0x3); in dib7000m_set_adc_state()
310 ret |= dib7000m_write_word(state, 913, reg_913); in dib7000m_set_adc_state()
311 ret |= dib7000m_write_word(state, 914, reg_914); in dib7000m_set_adc_state()
316 static int dib7000m_set_bandwidth(struct dib7000m_state *state, u32 bw) in dib7000m_set_bandwidth() argument
324 state->current_bandwidth = bw; in dib7000m_set_bandwidth()
326 if (state->timf == 0) { in dib7000m_set_bandwidth()
328 timf = state->timf_default; in dib7000m_set_bandwidth()
331 timf = state->timf; in dib7000m_set_bandwidth()
336 dib7000m_write_word(state, 23, (u16) ((timf >> 16) & 0xffff)); in dib7000m_set_bandwidth()
337 dib7000m_write_word(state, 24, (u16) ((timf ) & 0xffff)); in dib7000m_set_bandwidth()
344 struct dib7000m_state *state = demod->demodulator_priv; in dib7000m_set_diversity_in() local
346 if (state->div_force_off) { in dib7000m_set_diversity_in()
350 state->div_state = (u8)onoff; in dib7000m_set_diversity_in()
353 dib7000m_write_word(state, 263 + state->reg_offs, 6); in dib7000m_set_diversity_in()
354 dib7000m_write_word(state, 264 + state->reg_offs, 6); in dib7000m_set_diversity_in()
355 …dib7000m_write_word(state, 266 + state->reg_offs, (state->div_sync_wait << 4) | (1 << 2) | (2 << 0… in dib7000m_set_diversity_in()
357 dib7000m_write_word(state, 263 + state->reg_offs, 1); in dib7000m_set_diversity_in()
358 dib7000m_write_word(state, 264 + state->reg_offs, 0); in dib7000m_set_diversity_in()
359 dib7000m_write_word(state, 266 + state->reg_offs, 0); in dib7000m_set_diversity_in()
365 static int dib7000m_sad_calib(struct dib7000m_state *state) in dib7000m_sad_calib() argument
370 dib7000m_write_word(state, 929, (0 << 1) | (0 << 0)); in dib7000m_sad_calib()
371 dib7000m_write_word(state, 930, 776); // 0.625*3.3 / 4096 in dib7000m_sad_calib()
374 dib7000m_write_word(state, 929, (1 << 0)); in dib7000m_sad_calib()
375 dib7000m_write_word(state, 929, (0 << 0)); in dib7000m_sad_calib()
382 static void dib7000m_reset_pll_common(struct dib7000m_state *state, const struct dibx000_bandwidth_… in dib7000m_reset_pll_common() argument
384 dib7000m_write_word(state, 18, (u16) (((bw->internal*1000) >> 16) & 0xffff)); in dib7000m_reset_pll_common()
385 dib7000m_write_word(state, 19, (u16) ( (bw->internal*1000) & 0xffff)); in dib7000m_reset_pll_common()
386 dib7000m_write_word(state, 21, (u16) ( (bw->ifreq >> 16) & 0xffff)); in dib7000m_reset_pll_common()
387 dib7000m_write_word(state, 22, (u16) ( bw->ifreq & 0xffff)); in dib7000m_reset_pll_common()
389 dib7000m_write_word(state, 928, bw->sad_cfg); in dib7000m_reset_pll_common()
392 static void dib7000m_reset_pll(struct dib7000m_state *state) in dib7000m_reset_pll() argument
394 const struct dibx000_bandwidth_config *bw = state->cfg.bw; in dib7000m_reset_pll()
405 if (!state->cfg.quartz_direct) { in dib7000m_reset_pll()
409 if(state->cfg.input_clk_is_div_2) in dib7000m_reset_pll()
418 dib7000m_write_word(state, 910, reg_910); // pll cfg in dib7000m_reset_pll()
419 dib7000m_write_word(state, 907, reg_907); // clk cfg0 in dib7000m_reset_pll()
420 dib7000m_write_word(state, 908, 0x0006); // clk_cfg1 in dib7000m_reset_pll()
422 dib7000m_reset_pll_common(state, bw); in dib7000m_reset_pll()
425 static void dib7000mc_reset_pll(struct dib7000m_state *state) in dib7000mc_reset_pll() argument
427 const struct dibx000_bandwidth_config *bw = state->cfg.bw; in dib7000mc_reset_pll()
431 dib7000m_write_word(state, 907, (bw->pll_prediv << 8) | (bw->pll_ratio << 0)); in dib7000mc_reset_pll()
438 dib7000m_write_word(state, 908, clk_cfg1); in dib7000mc_reset_pll()
440 dib7000m_write_word(state, 908, clk_cfg1); in dib7000mc_reset_pll()
443 dib7000m_write_word(state, 910, (1 << 12) | (2 << 10) | (bw->modulo << 8) | (bw->ADClkSrc << 7)); in dib7000mc_reset_pll()
445 dib7000m_reset_pll_common(state, bw); in dib7000mc_reset_pll()
563 static int dib7000m_demod_reset(struct dib7000m_state *state) in dib7000m_demod_reset() argument
565 dib7000m_set_power_mode(state, DIB7000M_POWER_ALL); in dib7000m_demod_reset()
568 dib7000m_set_adc_state(state, DIBX000_VBG_ENABLE); in dib7000m_demod_reset()
571 dib7000m_write_word(state, 898, 0xffff); in dib7000m_demod_reset()
572 dib7000m_write_word(state, 899, 0xffff); in dib7000m_demod_reset()
573 dib7000m_write_word(state, 900, 0xff0f); in dib7000m_demod_reset()
574 dib7000m_write_word(state, 901, 0xfffc); in dib7000m_demod_reset()
576 dib7000m_write_word(state, 898, 0); in dib7000m_demod_reset()
577 dib7000m_write_word(state, 899, 0); in dib7000m_demod_reset()
578 dib7000m_write_word(state, 900, 0); in dib7000m_demod_reset()
579 dib7000m_write_word(state, 901, 0); in dib7000m_demod_reset()
581 if (state->revision == 0x4000) in dib7000m_demod_reset()
582 dib7000m_reset_pll(state); in dib7000m_demod_reset()
584 dib7000mc_reset_pll(state); in dib7000m_demod_reset()
586 if (dib7000m_reset_gpio(state) != 0) in dib7000m_demod_reset()
589 if (dib7000m_set_output_mode(state, OUTMODE_HIGH_Z) != 0) in dib7000m_demod_reset()
593 dib7000m_write_word(state, 1794, dib7000m_read_word(state, 1794) & ~(1 << 1) ); in dib7000m_demod_reset()
595 dib7000m_set_bandwidth(state, 8000); in dib7000m_demod_reset()
597 dib7000m_set_adc_state(state, DIBX000_SLOW_ADC_ON); in dib7000m_demod_reset()
598 dib7000m_sad_calib(state); in dib7000m_demod_reset()
599 dib7000m_set_adc_state(state, DIBX000_SLOW_ADC_OFF); in dib7000m_demod_reset()
601 if (state->cfg.dvbt_mode) in dib7000m_demod_reset()
602 dib7000m_write_word(state, 1796, 0x0); // select DVB-T output in dib7000m_demod_reset()
604 if (state->cfg.mobile_mode) in dib7000m_demod_reset()
605 dib7000m_write_word(state, 261 + state->reg_offs, 2); in dib7000m_demod_reset()
607 dib7000m_write_word(state, 224 + state->reg_offs, 1); in dib7000m_demod_reset()
610 if(state->cfg.tuner_is_baseband) in dib7000m_demod_reset()
611 dib7000m_write_word(state, 36, 0x0755); in dib7000m_demod_reset()
613 dib7000m_write_word(state, 36, 0x1f55); in dib7000m_demod_reset()
616 if (state->revision == 0x4000) in dib7000m_demod_reset()
617 dib7000m_write_word(state, 909, (3 << 10) | (1 << 6)); in dib7000m_demod_reset()
619 dib7000m_write_word(state, 909, (3 << 4) | 1); in dib7000m_demod_reset()
621 dib7000m_write_tab(state, dib7000m_defaults_common); in dib7000m_demod_reset()
622 dib7000m_write_tab(state, dib7000m_defaults); in dib7000m_demod_reset()
624 dib7000m_set_power_mode(state, DIB7000M_POWER_INTERFACE_ONLY); in dib7000m_demod_reset()
626 state->internal_clk = state->cfg.bw->internal; in dib7000m_demod_reset()
631 static void dib7000m_restart_agc(struct dib7000m_state *state) in dib7000m_restart_agc() argument
634 dib7000m_write_word(state, 898, 0x0c00); in dib7000m_restart_agc()
635 dib7000m_write_word(state, 898, 0x0000); in dib7000m_restart_agc()
638 static int dib7000m_agc_soft_split(struct dib7000m_state *state) in dib7000m_agc_soft_split() argument
642 …if(!state->current_agc || !state->current_agc->perform_agc_softsplit || state->current_agc->split.… in dib7000m_agc_soft_split()
646 agc = dib7000m_read_word(state, 390); in dib7000m_agc_soft_split()
648 if (agc > state->current_agc->split.min_thres) in dib7000m_agc_soft_split()
649 split_offset = state->current_agc->split.min; in dib7000m_agc_soft_split()
650 else if (agc < state->current_agc->split.max_thres) in dib7000m_agc_soft_split()
651 split_offset = state->current_agc->split.max; in dib7000m_agc_soft_split()
653 split_offset = state->current_agc->split.max * in dib7000m_agc_soft_split()
654 (agc - state->current_agc->split.min_thres) / in dib7000m_agc_soft_split()
655 (state->current_agc->split.max_thres - state->current_agc->split.min_thres); in dib7000m_agc_soft_split()
660 return dib7000m_write_word(state, 103, (dib7000m_read_word(state, 103) & 0xff00) | split_offset); in dib7000m_agc_soft_split()
663 static int dib7000m_update_lna(struct dib7000m_state *state) in dib7000m_update_lna() argument
667 if (state->cfg.update_lna) { in dib7000m_update_lna()
669 dyn_gain = dib7000m_read_word(state, 390); in dib7000m_update_lna()
671 if (state->cfg.update_lna(&state->demod,dyn_gain)) { // LNA has changed in dib7000m_update_lna()
672 dib7000m_restart_agc(state); in dib7000m_update_lna()
679 static int dib7000m_set_agc_config(struct dib7000m_state *state, u8 band) in dib7000m_set_agc_config() argument
683 if (state->current_band == band && state->current_agc != NULL) in dib7000m_set_agc_config()
685 state->current_band = band; in dib7000m_set_agc_config()
687 for (i = 0; i < state->cfg.agc_config_count; i++) in dib7000m_set_agc_config()
688 if (state->cfg.agc[i].band_caps & band) { in dib7000m_set_agc_config()
689 agc = &state->cfg.agc[i]; in dib7000m_set_agc_config()
698 state->current_agc = agc; in dib7000m_set_agc_config()
701 dib7000m_write_word(state, 72 , agc->setup); in dib7000m_set_agc_config()
702 dib7000m_write_word(state, 73 , agc->inv_gain); in dib7000m_set_agc_config()
703 dib7000m_write_word(state, 74 , agc->time_stabiliz); in dib7000m_set_agc_config()
704 dib7000m_write_word(state, 97 , (agc->alpha_level << 12) | agc->thlock); in dib7000m_set_agc_config()
707 dib7000m_write_word(state, 98, (agc->alpha_mant << 5) | agc->alpha_exp); in dib7000m_set_agc_config()
708 dib7000m_write_word(state, 99, (agc->beta_mant << 6) | agc->beta_exp); in dib7000m_set_agc_config()
711state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, ag… in dib7000m_set_agc_config()
714 if (state->wbd_ref != 0) in dib7000m_set_agc_config()
715 dib7000m_write_word(state, 102, state->wbd_ref); in dib7000m_set_agc_config()
717 dib7000m_write_word(state, 102, agc->wbd_ref); in dib7000m_set_agc_config()
719 dib7000m_write_word(state, 103, (agc->wbd_alpha << 9) | (agc->perform_agc_softsplit << 8) ); in dib7000m_set_agc_config()
720 dib7000m_write_word(state, 104, agc->agc1_max); in dib7000m_set_agc_config()
721 dib7000m_write_word(state, 105, agc->agc1_min); in dib7000m_set_agc_config()
722 dib7000m_write_word(state, 106, agc->agc2_max); in dib7000m_set_agc_config()
723 dib7000m_write_word(state, 107, agc->agc2_min); in dib7000m_set_agc_config()
724 dib7000m_write_word(state, 108, (agc->agc1_pt1 << 8) | agc->agc1_pt2 ); in dib7000m_set_agc_config()
725 dib7000m_write_word(state, 109, (agc->agc1_slope1 << 8) | agc->agc1_slope2); in dib7000m_set_agc_config()
726 dib7000m_write_word(state, 110, (agc->agc2_pt1 << 8) | agc->agc2_pt2); in dib7000m_set_agc_config()
727 dib7000m_write_word(state, 111, (agc->agc2_slope1 << 8) | agc->agc2_slope2); in dib7000m_set_agc_config()
729 if (state->revision > 0x4000) { // settings for the MC in dib7000m_set_agc_config()
730 dib7000m_write_word(state, 71, agc->agc1_pt3); in dib7000m_set_agc_config()
733 …dib7000m_write_word(state, 929, (dib7000m_read_word(state, 929) & 0xffe3) | (agc->wbd_inv << 4) | … in dib7000m_set_agc_config()
738 dib7000m_write_word(state, 88 + i, b[i]); in dib7000m_set_agc_config()
743 static void dib7000m_update_timf(struct dib7000m_state *state) in dib7000m_update_timf() argument
745 u32 timf = (dib7000m_read_word(state, 436) << 16) | dib7000m_read_word(state, 437); in dib7000m_update_timf()
746 state->timf = timf * 160 / (state->current_bandwidth / 50); in dib7000m_update_timf()
747 dib7000m_write_word(state, 23, (u16) (timf >> 16)); in dib7000m_update_timf()
748 dib7000m_write_word(state, 24, (u16) (timf & 0xffff)); in dib7000m_update_timf()
749 dprintk("updated timf_frequency: %d (default: %d)\n", state->timf, state->timf_default); in dib7000m_update_timf()
755 struct dib7000m_state *state = demod->demodulator_priv; in dib7000m_agc_startup() local
756 u16 cfg_72 = dib7000m_read_word(state, 72); in dib7000m_agc_startup()
758 u8 *agc_state = &state->agc_state; in dib7000m_agc_startup()
761 switch (state->agc_state) { in dib7000m_agc_startup()
764 dib7000m_set_power_mode(state, DIB7000M_POWER_INTERF_ANALOG_AGC); in dib7000m_agc_startup()
765 dib7000m_set_adc_state(state, DIBX000_ADC_ON); in dib7000m_agc_startup()
767 if (dib7000m_set_agc_config(state, BAND_OF_FREQUENCY(ch->frequency/1000)) != 0) in dib7000m_agc_startup()
776 if (state->cfg.agc_control) in dib7000m_agc_startup()
777 state->cfg.agc_control(&state->demod, 1); in dib7000m_agc_startup()
779 dib7000m_write_word(state, 75, 32768); in dib7000m_agc_startup()
780 if (!state->current_agc->perform_agc_softsplit) { in dib7000m_agc_startup()
782 dib7000m_write_word(state, 103, 1 << 8); /* force 0 split on WBD and restart AGC */ in dib7000m_agc_startup()
792 dib7000m_restart_agc(state); in dib7000m_agc_startup()
796 dib7000m_write_word(state, 72, cfg_72 | (1 << 4)); /* freeze AGC loop */ in dib7000m_agc_startup()
797 dib7000m_write_word(state, 103, 2 << 9); /* fast split search 0.25kHz */ in dib7000m_agc_startup()
803 agc_split = (u8)dib7000m_read_word(state, 392); /* store the split value for the next time */ in dib7000m_agc_startup()
804 dib7000m_write_word(state, 75, dib7000m_read_word(state, 390)); /* set AGC gain start value */ in dib7000m_agc_startup()
806 dib7000m_write_word(state, 72, cfg_72 & ~(1 << 4)); /* std AGC loop */ in dib7000m_agc_startup()
807 …dib7000m_write_word(state, 103, (state->current_agc->wbd_alpha << 9) | agc_split); /* standard spl… in dib7000m_agc_startup()
809 dib7000m_restart_agc(state); in dib7000m_agc_startup()
821 if (dib7000m_update_lna(state)) in dib7000m_agc_startup()
829 dib7000m_agc_soft_split(state); in dib7000m_agc_startup()
831 if (state->cfg.agc_control) in dib7000m_agc_startup()
832 state->cfg.agc_control(&state->demod, 0); in dib7000m_agc_startup()
843 static void dib7000m_set_channel(struct dib7000m_state *state, struct dtv_frontend_properties *ch, in dib7000m_set_channel() argument
848 dib7000m_set_bandwidth(state, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000m_set_channel()
877 dib7000m_write_word(state, 0, value); in dib7000m_set_channel()
878 dib7000m_write_word(state, 5, (seq << 4)); in dib7000m_set_channel()
896 dib7000m_write_word(state, 267 + state->reg_offs, value); in dib7000m_set_channel()
901 dib7000m_write_word(state, 26, (6 << 12) | (6 << 8) | 0x80); in dib7000m_set_channel()
904 dib7000m_write_word(state, 29, (0 << 14) | (4 << 10) | (1 << 9) | (3 << 5) | (1 << 4) | (0x3)); in dib7000m_set_channel()
907 dib7000m_write_word(state, 32, (0 << 4) | 0x3); in dib7000m_set_channel()
910 dib7000m_write_word(state, 33, (0 << 4) | 0x5); in dib7000m_set_channel()
926state->div_sync_wait = (value * 3) / 2 + 32; // add 50% SFN margin + compensate for one DVSY-fifo … in dib7000m_set_channel()
930 if (1 == 1 || state->revision > 0x4000) in dib7000m_set_channel()
931 state->div_force_off = 0; in dib7000m_set_channel()
933 state->div_force_off = 1; in dib7000m_set_channel()
934 dib7000m_set_diversity_in(&state->demod, state->div_state); in dib7000m_set_channel()
958 dib7000m_write_word(state, 214 + value + state->reg_offs, est[value]); in dib7000m_set_channel()
961 dib7000m_set_power_mode(state, DIB7000M_POWER_COR4_DINTLV_ICIRM_EQUAL_CFROD); in dib7000m_set_channel()
967 struct dib7000m_state *state = demod->demodulator_priv; in dib7000m_autosearch_start() local
981 dib7000m_set_channel(state, &schan, 7); in dib7000m_autosearch_start()
990 value = 30 * state->internal_clk * factor; in dib7000m_autosearch_start()
991 ret |= dib7000m_write_word(state, 6, (u16) ((value >> 16) & 0xffff)); // lock0 wait time in dib7000m_autosearch_start()
992 ret |= dib7000m_write_word(state, 7, (u16) (value & 0xffff)); // lock0 wait time in dib7000m_autosearch_start()
993 value = 100 * state->internal_clk * factor; in dib7000m_autosearch_start()
994 ret |= dib7000m_write_word(state, 8, (u16) ((value >> 16) & 0xffff)); // lock1 wait time in dib7000m_autosearch_start()
995 ret |= dib7000m_write_word(state, 9, (u16) (value & 0xffff)); // lock1 wait time in dib7000m_autosearch_start()
996 value = 500 * state->internal_clk * factor; in dib7000m_autosearch_start()
997 ret |= dib7000m_write_word(state, 10, (u16) ((value >> 16) & 0xffff)); // lock2 wait time in dib7000m_autosearch_start()
998 ret |= dib7000m_write_word(state, 11, (u16) (value & 0xffff)); // lock2 wait time in dib7000m_autosearch_start()
1001 value = dib7000m_read_word(state, 0); in dib7000m_autosearch_start()
1002 ret |= dib7000m_write_word(state, 0, (u16) (value | (1 << 9))); in dib7000m_autosearch_start()
1005 if (state->revision == 0x4000) in dib7000m_autosearch_start()
1006 dib7000m_write_word(state, 1793, 0); in dib7000m_autosearch_start()
1008 dib7000m_read_word(state, 537); in dib7000m_autosearch_start()
1010 ret |= dib7000m_write_word(state, 0, (u16) value); in dib7000m_autosearch_start()
1015 static int dib7000m_autosearch_irq(struct dib7000m_state *state, u16 reg) in dib7000m_autosearch_irq() argument
1017 u16 irq_pending = dib7000m_read_word(state, reg); in dib7000m_autosearch_irq()
1033 struct dib7000m_state *state = demod->demodulator_priv; in dib7000m_autosearch_is_irq() local
1034 if (state->revision == 0x4000) in dib7000m_autosearch_is_irq()
1035 return dib7000m_autosearch_irq(state, 1793); in dib7000m_autosearch_is_irq()
1037 return dib7000m_autosearch_irq(state, 537); in dib7000m_autosearch_is_irq()
1043 struct dib7000m_state *state = demod->demodulator_priv; in dib7000m_tune() local
1048 dib7000m_set_channel(state, ch, 0); in dib7000m_tune()
1051 ret |= dib7000m_write_word(state, 898, 0x4000); in dib7000m_tune()
1052 ret |= dib7000m_write_word(state, 898, 0x0000); in dib7000m_tune()
1055 dib7000m_set_power_mode(state, DIB7000M_POWER_COR4_CRY_ESRAM_MOUT_NUD); in dib7000m_tune()
1057 …ret |= dib7000m_write_word(state, 29, (0 << 14) | (4 << 10) | (0 << 9) | (3 << 5) | (1 << 4) | (0x… in dib7000m_tune()
1060 if (state->timf == 0) in dib7000m_tune()
1072 ret |= dib7000m_write_word(state, 26, value); in dib7000m_tune()
1082 ret |= dib7000m_write_word(state, 32, value); in dib7000m_tune()
1092 ret |= dib7000m_write_word(state, 33, value); in dib7000m_tune()
1095 if ((dib7000m_read_word(state, 535) >> 6) & 0x1) in dib7000m_tune()
1096 dib7000m_update_timf(state); in dib7000m_tune()
1098 dib7000m_set_bandwidth(state, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000m_tune()
1104 struct dib7000m_state *state = demod->demodulator_priv; in dib7000m_wakeup() local
1106 dib7000m_set_power_mode(state, DIB7000M_POWER_ALL); in dib7000m_wakeup()
1108 if (dib7000m_set_adc_state(state, DIBX000_SLOW_ADC_ON) != 0) in dib7000m_wakeup()
1123 static int dib7000m_identify(struct dib7000m_state *state) in dib7000m_identify() argument
1127 if ((value = dib7000m_read_word(state, 896)) != 0x01b3) { in dib7000m_identify()
1132 state->revision = dib7000m_read_word(state, 897); in dib7000m_identify()
1133 if (state->revision != 0x4000 && in dib7000m_identify()
1134 state->revision != 0x4001 && in dib7000m_identify()
1135 state->revision != 0x4002 && in dib7000m_identify()
1136 state->revision != 0x4003) { in dib7000m_identify()
1142 if (state->revision == 0x4000 && dib7000m_read_word(state, 769) == 0x4000) { in dib7000m_identify()
1147 switch (state->revision) { in dib7000m_identify()
1149 case 0x4001: state->reg_offs = 1; dprintk("found DiB7000HC\n"); break; in dib7000m_identify()
1150 case 0x4002: state->reg_offs = 1; dprintk("found DiB7000MC\n"); break; in dib7000m_identify()
1151 case 0x4003: state->reg_offs = 1; dprintk("found DiB9000\n"); break; in dib7000m_identify()
1161 struct dib7000m_state *state = fe->demodulator_priv; in dib7000m_get_frontend() local
1162 u16 tps = dib7000m_read_word(state,480); in dib7000m_get_frontend()
1166 fep->bandwidth_hz = BANDWIDTH_TO_HZ(state->current_bandwidth); in dib7000m_get_frontend()
1219 struct dib7000m_state *state = fe->demodulator_priv; in dib7000m_set_frontend() local
1222 dib7000m_set_output_mode(state, OUTMODE_HIGH_Z); in dib7000m_set_frontend()
1224 dib7000m_set_bandwidth(state, BANDWIDTH_TO_KHZ(fep->bandwidth_hz)); in dib7000m_set_frontend()
1230 state->agc_state = 0; in dib7000m_set_frontend()
1259 dib7000m_set_output_mode(state, OUTMODE_MPEG2_FIFO); in dib7000m_set_frontend()
1265 struct dib7000m_state *state = fe->demodulator_priv; in dib7000m_read_status() local
1266 u16 lock = dib7000m_read_word(state, 535); in dib7000m_read_status()
1286 struct dib7000m_state *state = fe->demodulator_priv; in dib7000m_read_ber() local
1287 *ber = (dib7000m_read_word(state, 526) << 16) | dib7000m_read_word(state, 527); in dib7000m_read_ber()
1293 struct dib7000m_state *state = fe->demodulator_priv; in dib7000m_read_unc_blocks() local
1294 *unc = dib7000m_read_word(state, 534); in dib7000m_read_unc_blocks()
1300 struct dib7000m_state *state = fe->demodulator_priv; in dib7000m_read_signal_strength() local
1301 u16 val = dib7000m_read_word(state, 390); in dib7000m_read_signal_strength()
1334 struct dib7000m_state *state = fe->demodulator_priv; in dib7000m_pid_filter_ctrl() local
1335 u16 val = dib7000m_read_word(state, 294 + state->reg_offs) & 0xffef; in dib7000m_pid_filter_ctrl()
1338 return dib7000m_write_word(state, 294 + state->reg_offs, val); in dib7000m_pid_filter_ctrl()
1344 struct dib7000m_state *state = fe->demodulator_priv; in dib7000m_pid_filter() local
1346 return dib7000m_write_word(state, 300 + state->reg_offs + id, in dib7000m_pid_filter()