Lines Matching refs:state

171 static u16 __dib8000_read_word(struct dib8000_state *state, u16 reg)  in __dib8000_read_word()  argument
175 state->i2c_write_buffer[0] = reg >> 8; in __dib8000_read_word()
176 state->i2c_write_buffer[1] = reg & 0xff; in __dib8000_read_word()
178 memset(state->msg, 0, 2 * sizeof(struct i2c_msg)); in __dib8000_read_word()
179 state->msg[0].addr = state->i2c.addr >> 1; in __dib8000_read_word()
180 state->msg[0].flags = 0; in __dib8000_read_word()
181 state->msg[0].buf = state->i2c_write_buffer; in __dib8000_read_word()
182 state->msg[0].len = 2; in __dib8000_read_word()
183 state->msg[1].addr = state->i2c.addr >> 1; in __dib8000_read_word()
184 state->msg[1].flags = I2C_M_RD; in __dib8000_read_word()
185 state->msg[1].buf = state->i2c_read_buffer; in __dib8000_read_word()
186 state->msg[1].len = 2; in __dib8000_read_word()
188 if (i2c_transfer(state->i2c.adap, state->msg, 2) != 2) in __dib8000_read_word()
191 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1]; in __dib8000_read_word()
196 static u16 dib8000_read_word(struct dib8000_state *state, u16 reg) in dib8000_read_word() argument
200 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib8000_read_word()
205 ret = __dib8000_read_word(state, reg); in dib8000_read_word()
207 mutex_unlock(&state->i2c_buffer_lock); in dib8000_read_word()
212 static u32 dib8000_read32(struct dib8000_state *state, u16 reg) in dib8000_read32() argument
216 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib8000_read32()
221 rw[0] = __dib8000_read_word(state, reg + 0); in dib8000_read32()
222 rw[1] = __dib8000_read_word(state, reg + 1); in dib8000_read32()
224 mutex_unlock(&state->i2c_buffer_lock); in dib8000_read32()
251 static int dib8000_write_word(struct dib8000_state *state, u16 reg, u16 val) in dib8000_write_word() argument
255 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib8000_write_word()
260 state->i2c_write_buffer[0] = (reg >> 8) & 0xff; in dib8000_write_word()
261 state->i2c_write_buffer[1] = reg & 0xff; in dib8000_write_word()
262 state->i2c_write_buffer[2] = (val >> 8) & 0xff; in dib8000_write_word()
263 state->i2c_write_buffer[3] = val & 0xff; in dib8000_write_word()
265 memset(&state->msg[0], 0, sizeof(struct i2c_msg)); in dib8000_write_word()
266 state->msg[0].addr = state->i2c.addr >> 1; in dib8000_write_word()
267 state->msg[0].flags = 0; in dib8000_write_word()
268 state->msg[0].buf = state->i2c_write_buffer; in dib8000_write_word()
269 state->msg[0].len = 4; in dib8000_write_word()
271 ret = (i2c_transfer(state->i2c.adap, state->msg, 1) != 1 ? in dib8000_write_word()
273 mutex_unlock(&state->i2c_buffer_lock); in dib8000_write_word()
379 static u16 fft_to_mode(struct dib8000_state *state) in fft_to_mode() argument
382 switch (state->fe[0]->dtv_property_cache.transmission_mode) { in fft_to_mode()
398 static void dib8000_set_acquisition_mode(struct dib8000_state *state) in dib8000_set_acquisition_mode() argument
400 u16 nud = dib8000_read_word(state, 298); in dib8000_set_acquisition_mode()
403 dib8000_write_word(state, 298, nud); in dib8000_set_acquisition_mode()
407 struct dib8000_state *state = fe->demodulator_priv; in dib8000_set_output_mode() local
410 state->output_mode = mode; in dib8000_set_output_mode()
413 smo_mode = (dib8000_read_word(state, 299) & 0x0050) | (1 << 1); in dib8000_set_output_mode()
416 &state->fe[0], mode); in dib8000_set_output_mode()
429 if (state->cfg.hostbus_diversity) { in dib8000_set_output_mode()
446 dib8000_set_acquisition_mode(state); in dib8000_set_output_mode()
451 &state->fe[0]); in dib8000_set_output_mode()
455 if (state->cfg.output_mpeg2_in_188_bytes) in dib8000_set_output_mode()
458 dib8000_write_word(state, 299, smo_mode); in dib8000_set_output_mode()
459 dib8000_write_word(state, 300, fifo_threshold); /* synchronous fread */ in dib8000_set_output_mode()
460 dib8000_write_word(state, 1286, outreg); in dib8000_set_output_mode()
461 dib8000_write_word(state, 1291, sram); in dib8000_set_output_mode()
468 struct dib8000_state *state = fe->demodulator_priv; in dib8000_set_diversity_in() local
469 u16 tmp, sync_wait = dib8000_read_word(state, 273) & 0xfff0; in dib8000_set_diversity_in()
472 if (!state->differential_constellation) { in dib8000_set_diversity_in()
473 dib8000_write_word(state, 272, 1 << 9); //dvsy_off_lmod4 = 1 in dib8000_set_diversity_in()
474 dib8000_write_word(state, 273, sync_wait | (1 << 2) | 2); // sync_enable = 1; comb_mode = 2 in dib8000_set_diversity_in()
476 dib8000_write_word(state, 272, 0); //dvsy_off_lmod4 = 0 in dib8000_set_diversity_in()
477 dib8000_write_word(state, 273, sync_wait); // sync_enable = 0; comb_mode = 0 in dib8000_set_diversity_in()
479 state->diversity_onoff = onoff; in dib8000_set_diversity_in()
483 dib8000_write_word(state, 270, 1); in dib8000_set_diversity_in()
484 dib8000_write_word(state, 271, 0); in dib8000_set_diversity_in()
487 dib8000_write_word(state, 270, 6); in dib8000_set_diversity_in()
488 dib8000_write_word(state, 271, 6); in dib8000_set_diversity_in()
491 dib8000_write_word(state, 270, 0); in dib8000_set_diversity_in()
492 dib8000_write_word(state, 271, 1); in dib8000_set_diversity_in()
496 if (state->revision == 0x8002) { in dib8000_set_diversity_in()
497 tmp = dib8000_read_word(state, 903); in dib8000_set_diversity_in()
498 dib8000_write_word(state, 903, tmp & ~(1 << 3)); in dib8000_set_diversity_in()
500 dib8000_write_word(state, 903, tmp | (1 << 3)); in dib8000_set_diversity_in()
505 static void dib8000_set_power_mode(struct dib8000_state *state, enum dib8000_power_mode mode) in dib8000_set_power_mode() argument
509 reg_900 = (dib8000_read_word(state, 900) & 0xfffc) | 0x3, in dib8000_set_power_mode()
512 if (state->revision != 0x8090) in dib8000_set_power_mode()
513 reg_1280 = (dib8000_read_word(state, 1280) & 0x00ff) | 0xff00; in dib8000_set_power_mode()
515 reg_1280 = (dib8000_read_word(state, 1280) & 0x707f) | 0x8f80; in dib8000_set_power_mode()
525 if (state->revision != 0x8090) in dib8000_set_power_mode()
531 if (state->revision != 0x8090) in dib8000_set_power_mode()
539 dib8000_write_word(state, 774, reg_774); in dib8000_set_power_mode()
540 dib8000_write_word(state, 775, reg_775); in dib8000_set_power_mode()
541 dib8000_write_word(state, 776, reg_776); in dib8000_set_power_mode()
542 dib8000_write_word(state, 900, reg_900); in dib8000_set_power_mode()
543 dib8000_write_word(state, 1280, reg_1280); in dib8000_set_power_mode()
546 static int dib8000_set_adc_state(struct dib8000_state *state, enum dibx000_adc_states no) in dib8000_set_adc_state() argument
549 u16 reg, reg_907 = dib8000_read_word(state, 907); in dib8000_set_adc_state()
550 u16 reg_908 = dib8000_read_word(state, 908); in dib8000_set_adc_state()
554 if (state->revision != 0x8090) { in dib8000_set_adc_state()
556 ret |= dib8000_write_word(state, 908, reg_908); in dib8000_set_adc_state()
559 reg = dib8000_read_word(state, 1925); in dib8000_set_adc_state()
561 dib8000_write_word(state, 1925, reg | in dib8000_set_adc_state()
565 reg = dib8000_read_word(state, 1925); in dib8000_set_adc_state()
568 dib8000_write_word(state, 1925, reg & ~(1<<4)); in dib8000_set_adc_state()
570 reg = dib8000_read_word(state, 921) & ~((0x3 << 14) in dib8000_set_adc_state()
574 dib8000_write_word(state, 921, reg | (1 << 14) in dib8000_set_adc_state()
580 if (state->revision == 0x8090) { in dib8000_set_adc_state()
581 reg = dib8000_read_word(state, 1925); in dib8000_set_adc_state()
583 dib8000_write_word(state, 1925, in dib8000_set_adc_state()
611 ret |= dib8000_write_word(state, 907, reg_907); in dib8000_set_adc_state()
612 ret |= dib8000_write_word(state, 908, reg_908); in dib8000_set_adc_state()
619 struct dib8000_state *state = fe->demodulator_priv; in dib8000_set_bandwidth() local
625 if (state->timf == 0) { in dib8000_set_bandwidth()
627 timf = state->timf_default; in dib8000_set_bandwidth()
630 timf = state->timf; in dib8000_set_bandwidth()
633 dib8000_write_word(state, 29, (u16) ((timf >> 16) & 0xffff)); in dib8000_set_bandwidth()
634 dib8000_write_word(state, 30, (u16) ((timf) & 0xffff)); in dib8000_set_bandwidth()
639 static int dib8000_sad_calib(struct dib8000_state *state) in dib8000_sad_calib() argument
643 if (state->revision == 0x8090) { in dib8000_sad_calib()
644 dib8000_write_word(state, 922, (sad_sel << 2)); in dib8000_sad_calib()
645 dib8000_write_word(state, 923, 2048); in dib8000_sad_calib()
647 dib8000_write_word(state, 922, (sad_sel << 2) | 0x1); in dib8000_sad_calib()
648 dib8000_write_word(state, 922, (sad_sel << 2)); in dib8000_sad_calib()
651 dib8000_write_word(state, 923, (0 << 1) | (0 << 0)); in dib8000_sad_calib()
652 dib8000_write_word(state, 924, 776); in dib8000_sad_calib()
655 dib8000_write_word(state, 923, (1 << 0)); in dib8000_sad_calib()
656 dib8000_write_word(state, 923, (0 << 0)); in dib8000_sad_calib()
665 struct dib8000_state *state = fe->demodulator_priv; in dib8000_set_wbd_ref() local
668 state->wbd_ref = value; in dib8000_set_wbd_ref()
669 return dib8000_write_word(state, 106, value); in dib8000_set_wbd_ref()
672 static void dib8000_reset_pll_common(struct dib8000_state *state, const struct dibx000_bandwidth_co… in dib8000_reset_pll_common() argument
675 if (state->revision != 0x8090) { in dib8000_reset_pll_common()
676 dib8000_write_word(state, 23, in dib8000_reset_pll_common()
678 dib8000_write_word(state, 24, in dib8000_reset_pll_common()
681 dib8000_write_word(state, 23, (u16) (((bw->internal / 2 * 1000) >> 16) & 0xffff)); in dib8000_reset_pll_common()
682 dib8000_write_word(state, 24, in dib8000_reset_pll_common()
685 dib8000_write_word(state, 27, (u16) ((bw->ifreq >> 16) & 0x01ff)); in dib8000_reset_pll_common()
686 dib8000_write_word(state, 28, (u16) (bw->ifreq & 0xffff)); in dib8000_reset_pll_common()
687 dib8000_write_word(state, 26, (u16) ((bw->ifreq >> 25) & 0x0003)); in dib8000_reset_pll_common()
689 if (state->revision != 0x8090) in dib8000_reset_pll_common()
690 dib8000_write_word(state, 922, bw->sad_cfg); in dib8000_reset_pll_common()
693 static void dib8000_reset_pll(struct dib8000_state *state) in dib8000_reset_pll() argument
695 const struct dibx000_bandwidth_config *pll = state->cfg.pll; in dib8000_reset_pll()
698 if (state->revision != 0x8090) { in dib8000_reset_pll()
699 dib8000_write_word(state, 901, in dib8000_reset_pll()
707 dib8000_write_word(state, 902, clk_cfg1); in dib8000_reset_pll()
709 dib8000_write_word(state, 902, clk_cfg1); in dib8000_reset_pll()
714 if (state->cfg.pll->ADClkSrc == 0) in dib8000_reset_pll()
715 dib8000_write_word(state, 904, in dib8000_reset_pll()
719 else if (state->cfg.refclksel != 0) in dib8000_reset_pll()
720 dib8000_write_word(state, 904, (0 << 15) | (1 << 12) | in dib8000_reset_pll()
721 ((state->cfg.refclksel & 0x3) << 10) | in dib8000_reset_pll()
725 dib8000_write_word(state, 904, (0 << 15) | (1 << 12) | in dib8000_reset_pll()
729 dib8000_write_word(state, 1856, (!pll->pll_reset<<13) | in dib8000_reset_pll()
733 reg = dib8000_read_word(state, 1857); in dib8000_reset_pll()
734 dib8000_write_word(state, 1857, reg|(!pll->pll_bypass<<15)); in dib8000_reset_pll()
736 reg = dib8000_read_word(state, 1858); /* Force clk out pll /2 */ in dib8000_reset_pll()
737 dib8000_write_word(state, 1858, reg | 1); in dib8000_reset_pll()
739 dib8000_write_word(state, 904, (pll->modulo << 8)); in dib8000_reset_pll()
742 dib8000_reset_pll_common(state, pll); in dib8000_reset_pll()
748 struct dib8000_state *state = fe->demodulator_priv; in dib8000_update_pll() local
749 u16 reg_1857, reg_1856 = dib8000_read_word(state, 1856); in dib8000_update_pll()
750 u8 loopdiv, prediv, oldprediv = state->cfg.pll->pll_prediv ; in dib8000_update_pll()
762 if (state->revision == 0x8090) { in dib8000_update_pll()
764 reg_1857 = dib8000_read_word(state, 1857); in dib8000_update_pll()
766 dib8000_write_word(state, 1857, reg_1857 & ~(1 << 15)); in dib8000_update_pll()
768 dib8000_write_word(state, 1856, reg_1856 | in dib8000_update_pll()
773 internal = dib8000_read32(state, 23) / 1000; in dib8000_update_pll()
780 dib8000_write_word(state, 23, in dib8000_update_pll()
782 dib8000_write_word(state, 24, (u16) ((internal / 2) & 0xffff)); in dib8000_update_pll()
784 dib8000_write_word(state, 1857, reg_1857 | (1 << 15)); in dib8000_update_pll()
786 while (((dib8000_read_word(state, 1856)>>15)&0x1) != 1) in dib8000_update_pll()
790 reg_1856 = dib8000_read_word(state, 1856); in dib8000_update_pll()
794 if (bw != state->current_demod_bw) { in dib8000_update_pll()
796 …h Change %d MHz -> %d MHz (prediv: %d->%d)\n", state->current_demod_bw / 1000, bw / 1000, oldpredi… in dib8000_update_pll()
798 if (state->cfg.pll->pll_prediv != oldprediv) { in dib8000_update_pll()
802 …g for %d MHz Bandwidth (prediv: %d, ratio: %d)\n", bw/1000, state->cfg.pll->pll_prediv, state->cfg… in dib8000_update_pll()
803 dib8000_write_word(state, 902, dib8000_read_word(state, 902) | (1<<3)); /* bypass PLL */ in dib8000_update_pll()
804 dib8000_reset_pll(state); in dib8000_update_pll()
805 dib8000_write_word(state, 898, 0x0004); /* sad */ in dib8000_update_pll()
807 ratio = state->cfg.pll->pll_ratio; in dib8000_update_pll()
809 state->current_demod_bw = bw; in dib8000_update_pll()
814 dprintk("PLL: Update ratio (prediv: %d, ratio: %d)\n", state->cfg.pll->pll_prediv, ratio); in dib8000_update_pll()
815 …dib8000_write_word(state, 901, (state->cfg.pll->pll_prediv << 8) | (ratio << 0)); /* only the PLL … in dib8000_update_pll()
855 struct dib8000_state *state = fe->demodulator_priv; in dib8000_set_gpio() local
856 return dib8000_cfg_gpio(state, num, dir, val); in dib8000_set_gpio()
997 struct dib8000_state *state = fe->demodulator_priv; in dib8000_reset_stats() local
998 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_reset_stats()
1025 state->init_ucb = -ucb; in dib8000_reset_stats()
1026 state->ber_jiffies_stats = 0; in dib8000_reset_stats()
1027 state->per_jiffies_stats = 0; in dib8000_reset_stats()
1028 memset(&state->ber_jiffies_stats_layer, 0, in dib8000_reset_stats()
1029 sizeof(state->ber_jiffies_stats_layer)); in dib8000_reset_stats()
1034 struct dib8000_state *state = fe->demodulator_priv; in dib8000_reset() local
1036 if ((state->revision = dib8000_identify(&state->i2c)) == 0) in dib8000_reset()
1040 if (state->revision != 0x8090) in dib8000_reset()
1041 dib8000_write_word(state, 1287, 0x0003); in dib8000_reset()
1043 if (state->revision == 0x8000) in dib8000_reset()
1046 dibx000_reset_i2c_master(&state->i2c_master); in dib8000_reset()
1048 dib8000_set_power_mode(state, DIB8000_POWER_ALL); in dib8000_reset()
1051 dib8000_set_adc_state(state, DIBX000_ADC_OFF); in dib8000_reset()
1054 dib8000_write_word(state, 770, 0xffff); in dib8000_reset()
1055 dib8000_write_word(state, 771, 0xffff); in dib8000_reset()
1056 dib8000_write_word(state, 772, 0xfffc); in dib8000_reset()
1057 dib8000_write_word(state, 898, 0x000c); /* restart sad */ in dib8000_reset()
1058 if (state->revision == 0x8090) in dib8000_reset()
1059 dib8000_write_word(state, 1280, 0x0045); in dib8000_reset()
1061 dib8000_write_word(state, 1280, 0x004d); in dib8000_reset()
1062 dib8000_write_word(state, 1281, 0x000c); in dib8000_reset()
1064 dib8000_write_word(state, 770, 0x0000); in dib8000_reset()
1065 dib8000_write_word(state, 771, 0x0000); in dib8000_reset()
1066 dib8000_write_word(state, 772, 0x0000); in dib8000_reset()
1067 dib8000_write_word(state, 898, 0x0004); // sad in dib8000_reset()
1068 dib8000_write_word(state, 1280, 0x0000); in dib8000_reset()
1069 dib8000_write_word(state, 1281, 0x0000); in dib8000_reset()
1072 if (state->revision != 0x8090) { in dib8000_reset()
1073 if (state->cfg.drives) in dib8000_reset()
1074 dib8000_write_word(state, 906, state->cfg.drives); in dib8000_reset()
1078 dib8000_write_word(state, 906, 0x2d98); in dib8000_reset()
1082 dib8000_reset_pll(state); in dib8000_reset()
1083 if (state->revision != 0x8090) in dib8000_reset()
1084 dib8000_write_word(state, 898, 0x0004); in dib8000_reset()
1086 if (dib8000_reset_gpio(state) != 0) in dib8000_reset()
1089 if ((state->revision != 0x8090) && in dib8000_reset()
1093 state->current_agc = NULL; in dib8000_reset()
1097 if (state->cfg.pll->ifreq == 0) in dib8000_reset()
1098 dib8000_write_word(state, 40, 0x0755); /* P_iqc_corr_inh = 0 enable IQcorr block */ in dib8000_reset()
1100 dib8000_write_word(state, 40, 0x1f55); /* P_iqc_corr_inh = 1 disable IQcorr block */ in dib8000_reset()
1110 dib8000_write_word(state, r, *n++); in dib8000_reset()
1117 state->isdbt_cfg_loaded = 0; in dib8000_reset()
1120 if ((state->revision != 8090) && (state->cfg.div_cfg != 0)) in dib8000_reset()
1121 dib8000_write_word(state, 903, state->cfg.div_cfg); in dib8000_reset()
1124 dib8000_write_word(state, 1285, dib8000_read_word(state, 1285) & ~(1 << 1)); in dib8000_reset()
1128 dib8000_set_adc_state(state, DIBX000_SLOW_ADC_ON); in dib8000_reset()
1129 dib8000_sad_calib(state); in dib8000_reset()
1130 if (state->revision != 0x8090) in dib8000_reset()
1131 dib8000_set_adc_state(state, DIBX000_SLOW_ADC_OFF); in dib8000_reset()
1134 dib8000_write_word(state, 285, (dib8000_read_word(state, 285) & ~0x60) | (3 << 5)); in dib8000_reset()
1136 dib8000_set_power_mode(state, DIB8000_POWER_INTERFACE_ONLY); in dib8000_reset()
1143 static void dib8000_restart_agc(struct dib8000_state *state) in dib8000_restart_agc() argument
1146 dib8000_write_word(state, 770, 0x0a00); in dib8000_restart_agc()
1147 dib8000_write_word(state, 770, 0x0000); in dib8000_restart_agc()
1150 static int dib8000_update_lna(struct dib8000_state *state) in dib8000_update_lna() argument
1154 if (state->cfg.update_lna) { in dib8000_update_lna()
1156 dyn_gain = dib8000_read_word(state, 390); in dib8000_update_lna()
1158 if (state->cfg.update_lna(state->fe[0], dyn_gain)) { in dib8000_update_lna()
1159 dib8000_restart_agc(state); in dib8000_update_lna()
1166 static int dib8000_set_agc_config(struct dib8000_state *state, u8 band) in dib8000_set_agc_config() argument
1172 if (state->current_band == band && state->current_agc != NULL) in dib8000_set_agc_config()
1174 state->current_band = band; in dib8000_set_agc_config()
1176 for (i = 0; i < state->cfg.agc_config_count; i++) in dib8000_set_agc_config()
1177 if (state->cfg.agc[i].band_caps & band) { in dib8000_set_agc_config()
1178 agc = &state->cfg.agc[i]; in dib8000_set_agc_config()
1187 state->current_agc = agc; in dib8000_set_agc_config()
1190 dib8000_write_word(state, 76, agc->setup); in dib8000_set_agc_config()
1191 dib8000_write_word(state, 77, agc->inv_gain); in dib8000_set_agc_config()
1192 dib8000_write_word(state, 78, agc->time_stabiliz); in dib8000_set_agc_config()
1193 dib8000_write_word(state, 101, (agc->alpha_level << 12) | agc->thlock); in dib8000_set_agc_config()
1196 dib8000_write_word(state, 102, (agc->alpha_mant << 5) | agc->alpha_exp); in dib8000_set_agc_config()
1197 dib8000_write_word(state, 103, (agc->beta_mant << 6) | agc->beta_exp); in dib8000_set_agc_config()
1200state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, ag… in dib8000_set_agc_config()
1203 if (state->wbd_ref != 0) in dib8000_set_agc_config()
1204 dib8000_write_word(state, 106, state->wbd_ref); in dib8000_set_agc_config()
1206 dib8000_write_word(state, 106, agc->wbd_ref); in dib8000_set_agc_config()
1208 if (state->revision == 0x8090) { in dib8000_set_agc_config()
1209 reg = dib8000_read_word(state, 922) & (0x3 << 2); in dib8000_set_agc_config()
1210 dib8000_write_word(state, 922, reg | (agc->wbd_sel << 2)); in dib8000_set_agc_config()
1213 dib8000_write_word(state, 107, (agc->wbd_alpha << 9) | (agc->perform_agc_softsplit << 8)); in dib8000_set_agc_config()
1214 dib8000_write_word(state, 108, agc->agc1_max); in dib8000_set_agc_config()
1215 dib8000_write_word(state, 109, agc->agc1_min); in dib8000_set_agc_config()
1216 dib8000_write_word(state, 110, agc->agc2_max); in dib8000_set_agc_config()
1217 dib8000_write_word(state, 111, agc->agc2_min); in dib8000_set_agc_config()
1218 dib8000_write_word(state, 112, (agc->agc1_pt1 << 8) | agc->agc1_pt2); in dib8000_set_agc_config()
1219 dib8000_write_word(state, 113, (agc->agc1_slope1 << 8) | agc->agc1_slope2); in dib8000_set_agc_config()
1220 dib8000_write_word(state, 114, (agc->agc2_pt1 << 8) | agc->agc2_pt2); in dib8000_set_agc_config()
1221 dib8000_write_word(state, 115, (agc->agc2_slope1 << 8) | agc->agc2_slope2); in dib8000_set_agc_config()
1223 dib8000_write_word(state, 75, agc->agc1_pt3); in dib8000_set_agc_config()
1224 if (state->revision != 0x8090) in dib8000_set_agc_config()
1225 dib8000_write_word(state, 923, in dib8000_set_agc_config()
1226 (dib8000_read_word(state, 923) & 0xffe3) | in dib8000_set_agc_config()
1234 struct dib8000_state *state = fe->demodulator_priv; in dib8000_pwm_agc_reset() local
1235 dib8000_set_adc_state(state, DIBX000_ADC_ON); in dib8000_pwm_agc_reset()
1236 …dib8000_set_agc_config(state, (unsigned char)(BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency /… in dib8000_pwm_agc_reset()
1239 static int dib8000_agc_soft_split(struct dib8000_state *state) in dib8000_agc_soft_split() argument
1243 …if (!state->current_agc || !state->current_agc->perform_agc_softsplit || state->current_agc->split… in dib8000_agc_soft_split()
1247 agc = dib8000_read_word(state, 390); in dib8000_agc_soft_split()
1249 if (agc > state->current_agc->split.min_thres) in dib8000_agc_soft_split()
1250 split_offset = state->current_agc->split.min; in dib8000_agc_soft_split()
1251 else if (agc < state->current_agc->split.max_thres) in dib8000_agc_soft_split()
1252 split_offset = state->current_agc->split.max; in dib8000_agc_soft_split()
1254 split_offset = state->current_agc->split.max * in dib8000_agc_soft_split()
1255 (agc - state->current_agc->split.min_thres) / in dib8000_agc_soft_split()
1256 (state->current_agc->split.max_thres - state->current_agc->split.min_thres); in dib8000_agc_soft_split()
1261 dib8000_write_word(state, 107, (dib8000_read_word(state, 107) & 0xff00) | split_offset); in dib8000_agc_soft_split()
1267 struct dib8000_state *state = fe->demodulator_priv; in dib8000_agc_startup() local
1268 enum frontend_tune_state *tune_state = &state->tune_state; in dib8000_agc_startup()
1277 if (state->revision != 0x8090) in dib8000_agc_startup()
1278 dib8000_set_adc_state(state, DIBX000_ADC_ON); in dib8000_agc_startup()
1280 dib8000_set_power_mode(state, DIB8000_POWER_ALL); in dib8000_agc_startup()
1282 reg = dib8000_read_word(state, 1947)&0xff00; in dib8000_agc_startup()
1283 dib8000_write_word(state, 1946, in dib8000_agc_startup()
1286 dib8000_write_word(state, 1947, reg | (1<<14) | in dib8000_agc_startup()
1290 reg = dib8000_read_word(state, 1920); in dib8000_agc_startup()
1291 dib8000_write_word(state, 1920, (reg | 0x3) & in dib8000_agc_startup()
1295 …if (dib8000_set_agc_config(state, (unsigned char)(BAND_OF_FREQUENCY(fe->dtv_property_cache.frequen… in dib8000_agc_startup()
1297 state->status = FE_STATUS_TUNE_FAILED; in dib8000_agc_startup()
1307 if (state->cfg.agc_control) in dib8000_agc_startup()
1308 state->cfg.agc_control(fe, 1); in dib8000_agc_startup()
1310 dib8000_restart_agc(state); in dib8000_agc_startup()
1321 if (dib8000_update_lna(state)) in dib8000_agc_startup()
1329 dib8000_agc_soft_split(state); in dib8000_agc_startup()
1331 if (state->cfg.agc_control) in dib8000_agc_startup()
1332 state->cfg.agc_control(fe, 0); in dib8000_agc_startup()
1337 ret = dib8000_agc_soft_split(state); in dib8000_agc_startup()
1344 static void dib8096p_host_bus_drive(struct dib8000_state *state, u8 drive) in dib8096p_host_bus_drive() argument
1351 reg = dib8000_read_word(state, 1798) & in dib8096p_host_bus_drive()
1354 dib8000_write_word(state, 1798, reg); in dib8096p_host_bus_drive()
1357 reg = dib8000_read_word(state, 1799) & ~((0x7 << 2) | (0x7 << 8)); in dib8096p_host_bus_drive()
1359 dib8000_write_word(state, 1799, reg); in dib8096p_host_bus_drive()
1362 reg = dib8000_read_word(state, 1800) & in dib8096p_host_bus_drive()
1365 dib8000_write_word(state, 1800, reg); in dib8096p_host_bus_drive()
1368 reg = dib8000_read_word(state, 1801) & ~((0x7 << 2) | (0x7 << 8)); in dib8096p_host_bus_drive()
1370 dib8000_write_word(state, 1801, reg); in dib8096p_host_bus_drive()
1373 reg = dib8000_read_word(state, 1802) & in dib8096p_host_bus_drive()
1376 dib8000_write_word(state, 1802, reg); in dib8096p_host_bus_drive()
1398 static void dib8096p_cfg_DibTx(struct dib8000_state *state, u32 P_Kin, in dib8096p_cfg_DibTx() argument
1404 dib8000_write_word(state, 1615, 1); in dib8096p_cfg_DibTx()
1405 dib8000_write_word(state, 1603, P_Kin); in dib8096p_cfg_DibTx()
1406 dib8000_write_word(state, 1605, P_Kout); in dib8096p_cfg_DibTx()
1407 dib8000_write_word(state, 1606, insertExtSynchro); in dib8096p_cfg_DibTx()
1408 dib8000_write_word(state, 1608, synchroMode); in dib8096p_cfg_DibTx()
1409 dib8000_write_word(state, 1609, (syncWord >> 16) & 0xffff); in dib8096p_cfg_DibTx()
1410 dib8000_write_word(state, 1610, syncWord & 0xffff); in dib8096p_cfg_DibTx()
1411 dib8000_write_word(state, 1612, syncSize); in dib8096p_cfg_DibTx()
1412 dib8000_write_word(state, 1615, 0); in dib8096p_cfg_DibTx()
1415 static void dib8096p_cfg_DibRx(struct dib8000_state *state, u32 P_Kin, in dib8096p_cfg_DibRx() argument
1426 dib8000_write_word(state, 1542, syncFreq); in dib8096p_cfg_DibRx()
1429 dib8000_write_word(state, 1554, 1); in dib8096p_cfg_DibRx()
1430 dib8000_write_word(state, 1536, P_Kin); in dib8096p_cfg_DibRx()
1431 dib8000_write_word(state, 1537, P_Kout); in dib8096p_cfg_DibRx()
1432 dib8000_write_word(state, 1539, synchroMode); in dib8096p_cfg_DibRx()
1433 dib8000_write_word(state, 1540, (syncWord >> 16) & 0xffff); in dib8096p_cfg_DibRx()
1434 dib8000_write_word(state, 1541, syncWord & 0xffff); in dib8096p_cfg_DibRx()
1435 dib8000_write_word(state, 1543, syncSize); in dib8096p_cfg_DibRx()
1436 dib8000_write_word(state, 1544, dataOutRate); in dib8096p_cfg_DibRx()
1437 dib8000_write_word(state, 1554, 0); in dib8096p_cfg_DibRx()
1440 static void dib8096p_enMpegMux(struct dib8000_state *state, int onoff) in dib8096p_enMpegMux() argument
1444 reg_1287 = dib8000_read_word(state, 1287); in dib8096p_enMpegMux()
1455 dib8000_write_word(state, 1287, reg_1287); in dib8096p_enMpegMux()
1458 static void dib8096p_configMpegMux(struct dib8000_state *state, in dib8096p_configMpegMux() argument
1465 dib8096p_enMpegMux(state, 0); in dib8096p_configMpegMux()
1468 if ((enSerialMode == 1) && (state->input_mode_mpeg == 1)) in dib8096p_configMpegMux()
1473 dib8000_write_word(state, 1287, reg_1287); in dib8096p_configMpegMux()
1475 dib8096p_enMpegMux(state, 1); in dib8096p_configMpegMux()
1478 static void dib8096p_setDibTxMux(struct dib8000_state *state, int mode) in dib8096p_setDibTxMux() argument
1480 u16 reg_1288 = dib8000_read_word(state, 1288) & ~(0x7 << 7); in dib8096p_setDibTxMux()
1485 dib8096p_cfg_DibTx(state, 8, 5, 0, 0, 0, 0); in dib8096p_setDibTxMux()
1489 dib8096p_cfg_DibTx(state, 5, 5, 0, 0, 0, 0); in dib8096p_setDibTxMux()
1493 dib8096p_cfg_DibTx(state, 20, 5, 10, 0, 0, 0); in dib8096p_setDibTxMux()
1498 dib8000_write_word(state, 1288, reg_1288); in dib8096p_setDibTxMux()
1501 static void dib8096p_setHostBusMux(struct dib8000_state *state, int mode) in dib8096p_setHostBusMux() argument
1503 u16 reg_1288 = dib8000_read_word(state, 1288) & ~(0x7 << 4); in dib8096p_setHostBusMux()
1508 dib8096p_enMpegMux(state, 0); in dib8096p_setHostBusMux()
1513 dib8096p_enMpegMux(state, 0); in dib8096p_setHostBusMux()
1523 dib8000_write_word(state, 1288, reg_1288); in dib8096p_setHostBusMux()
1528 struct dib8000_state *state = fe->demodulator_priv; in dib8096p_set_diversity_in() local
1536 dib8096p_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0); in dib8096p_set_diversity_in()
1540 reg_1287 = dib8000_read_word(state, 1287); in dib8096p_set_diversity_in()
1545 dib8000_write_word(state, 1287, reg_1287); in dib8096p_set_diversity_in()
1547 state->input_mode_mpeg = 1; in dib8096p_set_diversity_in()
1552 dib8096p_cfg_DibRx(state, 5, 5, 0, 0, 0, 0, 0); in dib8096p_set_diversity_in()
1553 state->input_mode_mpeg = 0; in dib8096p_set_diversity_in()
1557 dib8000_set_diversity_in(state->fe[0], onoff); in dib8096p_set_diversity_in()
1563 struct dib8000_state *state = fe->demodulator_priv; in dib8096p_set_output_mode() local
1568 state->output_mode = mode; in dib8096p_set_output_mode()
1569 dib8096p_host_bus_drive(state, 1); in dib8096p_set_output_mode()
1572 smo_mode = (dib8000_read_word(state, 299) & 0x0050) | (1 << 1); in dib8096p_set_output_mode()
1573 outreg = dib8000_read_word(state, 1286) & in dib8096p_set_output_mode()
1584 dib8096p_configMpegMux(state, 3, 1, 1); in dib8096p_set_output_mode()
1585 dib8096p_setHostBusMux(state, MPEG_ON_HOSTBUS); in dib8096p_set_output_mode()
1588 dib8096p_setHostBusMux(state, in dib8096p_set_output_mode()
1597 dib8096p_configMpegMux(state, 2, 0, 0); in dib8096p_set_output_mode()
1598 dib8096p_setHostBusMux(state, MPEG_ON_HOSTBUS); in dib8096p_set_output_mode()
1601 dib8096p_setHostBusMux(state, in dib8096p_set_output_mode()
1609 dib8096p_setHostBusMux(state, DEMOUT_ON_HOSTBUS); in dib8096p_set_output_mode()
1617 dib8096p_setHostBusMux(state, DEMOUT_ON_HOSTBUS); in dib8096p_set_output_mode()
1625 dib8096p_setDibTxMux(state, DIV_ON_DIBTX); in dib8096p_set_output_mode()
1626 dib8096p_setHostBusMux(state, DIBTX_ON_HOSTBUS); in dib8096p_set_output_mode()
1631 dib8096p_setDibTxMux(state, ADC_ON_DIBTX); in dib8096p_set_output_mode()
1632 dib8096p_setHostBusMux(state, DIBTX_ON_HOSTBUS); in dib8096p_set_output_mode()
1640 state->cfg.output_mpeg2_in_188_bytes); in dib8096p_set_output_mode()
1641 if (state->cfg.output_mpeg2_in_188_bytes) in dib8096p_set_output_mode()
1644 ret |= dib8000_write_word(state, 299, smo_mode); in dib8096p_set_output_mode()
1646 ret |= dib8000_write_word(state, 299 + 1, fifo_threshold); in dib8096p_set_output_mode()
1647 ret |= dib8000_write_word(state, 1286, outreg); in dib8096p_set_output_mode()
1676 struct dib8000_state *state = i2c_get_adapdata(i2c_adap); in dib8096p_tuner_write_serpar() local
1682 n_overflow = (dib8000_read_word(state, 1984) >> 1) & 0x1; in dib8096p_tuner_write_serpar()
1687 dib8000_write_word(state, 1985, (1 << 6) | (serpar_num & 0x3f)); in dib8096p_tuner_write_serpar()
1688 dib8000_write_word(state, 1986, (msg[0].buf[1] << 8) | msg[0].buf[2]); in dib8096p_tuner_write_serpar()
1696 struct dib8000_state *state = i2c_get_adapdata(i2c_adap); in dib8096p_tuner_read_serpar() local
1703 n_overflow = (dib8000_read_word(state, 1984) >> 1) & 0x1; in dib8096p_tuner_read_serpar()
1708 dib8000_write_word(state, 1985, (0<<6) | (serpar_num&0x3f)); in dib8096p_tuner_read_serpar()
1712 n_empty = dib8000_read_word(state, 1984)&0x1; in dib8096p_tuner_read_serpar()
1718 read_word = dib8000_read_word(state, 1987); in dib8096p_tuner_read_serpar()
1740 struct dib8000_state *state = i2c_get_adapdata(i2c_adap); in dib8096p_rw_on_apb() local
1744 dib8000_write_word(state, apb_address, in dib8096p_rw_on_apb()
1747 word = dib8000_read_word(state, apb_address); in dib8096p_rw_on_apb()
1757 struct dib8000_state *state = i2c_get_adapdata(i2c_adap); in dib8096p_tuner_xfer() local
1848 i = ((dib8000_read_word(state, 921) >> 12)&0x3); in dib8096p_tuner_xfer()
1849 word = dib8000_read_word(state, 924+i); in dib8096p_tuner_xfer()
1859 word = (dib8000_read_word(state, 921) & in dib8096p_tuner_xfer()
1862 dib8000_write_word(state, 921, word); in dib8096p_tuner_xfer()
1893 struct dib8000_state *state = fe->demodulator_priv; in dib8096p_tuner_sleep() local
1898 en_cur_state = dib8000_read_word(state, 1922); in dib8096p_tuner_sleep()
1902 state->tuner_enable = en_cur_state ; in dib8096p_tuner_sleep()
1907 if (state->tuner_enable != 0) in dib8096p_tuner_sleep()
1908 en_cur_state = state->tuner_enable; in dib8096p_tuner_sleep()
1911 dib8000_write_word(state, 1922, en_cur_state); in dib8096p_tuner_sleep()
1923 struct dib8000_state *state = fe->demodulator_priv; in dib8000_get_adc_power() local
1927 val = dib8000_read32(state, 384); in dib8000_get_adc_power()
1942 struct dib8000_state *state = fe->demodulator_priv; in dib8090p_get_dc_power() local
1947 val = dib8000_read_word(state, 403); in dib8090p_get_dc_power()
1950 val = dib8000_read_word(state, 404); in dib8090p_get_dc_power()
1959 static void dib8000_update_timf(struct dib8000_state *state) in dib8000_update_timf() argument
1961 u32 timf = state->timf = dib8000_read32(state, 435); in dib8000_update_timf()
1963 dib8000_write_word(state, 29, (u16) (timf >> 16)); in dib8000_update_timf()
1964 dib8000_write_word(state, 30, (u16) (timf & 0xffff)); in dib8000_update_timf()
1965 dprintk("Updated timing frequency: %d (default: %d)\n", state->timf, state->timf_default); in dib8000_update_timf()
1970 struct dib8000_state *state = fe->demodulator_priv; in dib8000_ctrl_timf() local
1974 state->timf = timf; in dib8000_ctrl_timf()
1977 dib8000_update_timf(state); in dib8000_ctrl_timf()
1982 dib8000_set_bandwidth(state->fe[0], 6000); in dib8000_ctrl_timf()
1984 return state->timf; in dib8000_ctrl_timf()
1993 static u16 dib8000_set_layer(struct dib8000_state *state, u8 layer_index, u16 max_constellation) in dib8000_set_layer() argument
1996 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_set_layer()
2037 …dib8000_write_word(state, 2 + layer_index, (constellation << 10) | ((c->layer[layer_index].segment… in dib8000_set_layer()
2058 static u16 dib8000_adp_fine_tune(struct dib8000_state *state, u16 max_constellation) in dib8000_adp_fine_tune() argument
2080 dib8000_write_word(state, 215 + i, adp[i]); in dib8000_adp_fine_tune()
2085 static void dib8000_update_ana_gain(struct dib8000_state *state, u16 ana_gain) in dib8000_update_ana_gain() argument
2089 dib8000_write_word(state, 116, ana_gain); in dib8000_update_ana_gain()
2094 dib8000_write_word(state, 80 + i, adc_target_16dB[i]); in dib8000_update_ana_gain()
2097 dib8000_write_word(state, 80 + i, adc_target_16dB[i] - 355); in dib8000_update_ana_gain()
2101 static void dib8000_load_ana_fe_coefs(struct dib8000_state *state, const s16 *ana_fe) in dib8000_load_ana_fe_coefs() argument
2105 if (state->isdbt_cfg_loaded == 0) in dib8000_load_ana_fe_coefs()
2107 dib8000_write_word(state, 117 + mode, ana_fe[mode]); in dib8000_load_ana_fe_coefs()
2134 static u16 dib8000_get_init_prbs(struct dib8000_state *state, u16 subchannel) in dib8000_get_init_prbs() argument
2143 switch (state->fe[0]->dtv_property_cache.transmission_mode) { in dib8000_get_init_prbs()
2161 static void dib8000_set_13seg_channel(struct dib8000_state *state) in dib8000_set_13seg_channel() argument
2166 state->seg_mask = 0x1fff; /* All 13 segments enabled */ in dib8000_set_13seg_channel()
2169 …if (state->isdbt_cfg_loaded == 0) { /* if not Sound Broadcasting mode : put default values for 13… in dib8000_set_13seg_channel()
2170 dib8000_write_word(state, 180, (16 << 6) | 9); in dib8000_set_13seg_channel()
2171 dib8000_write_word(state, 187, (4 << 12) | (8 << 5) | 0x2); in dib8000_set_13seg_channel()
2174 dib8000_write_word(state, 181+i, coff_pow); in dib8000_set_13seg_channel()
2178 dib8000_write_word(state, 338, (1 << 12) | (1 << 10) | (0 << 9) | (3 << 5) | 1); in dib8000_set_13seg_channel()
2181 dib8000_write_word(state, 340, (8 << 6) | (6 << 0)); in dib8000_set_13seg_channel()
2183 dib8000_write_word(state, 341, (4 << 3) | (1 << 2) | (1 << 1) | (1 << 0)); in dib8000_set_13seg_channel()
2185 dib8000_write_word(state, 228, 0); /* default value */ in dib8000_set_13seg_channel()
2186 dib8000_write_word(state, 265, 31); /* default value */ in dib8000_set_13seg_channel()
2187 dib8000_write_word(state, 205, 0x200f); /* init value */ in dib8000_set_13seg_channel()
2195 if (state->cfg.pll->ifreq == 0) in dib8000_set_13seg_channel()
2196 …dib8000_write_word(state, 266, ~state->seg_mask | state->seg_diff_mask | 0x40); /* P_equal_noise_s… in dib8000_set_13seg_channel()
2198 dib8000_load_ana_fe_coefs(state, ana_fe_coeff_13seg); in dib8000_set_13seg_channel()
2201 static void dib8000_set_subchannel_prbs(struct dib8000_state *state, u16 init_prbs) in dib8000_set_subchannel_prbs() argument
2205 reg_1 = dib8000_read_word(state, 1); in dib8000_set_subchannel_prbs()
2206 dib8000_write_word(state, 1, (init_prbs << 2) | (reg_1 & 0x3)); /* ADDR 1 */ in dib8000_set_subchannel_prbs()
2209 static void dib8000_small_fine_tune(struct dib8000_state *state) in dib8000_small_fine_tune() argument
2213 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_small_fine_tune()
2215 dib8000_write_word(state, 352, state->seg_diff_mask); in dib8000_small_fine_tune()
2216 dib8000_write_word(state, 353, state->seg_mask); in dib8000_small_fine_tune()
2219 dib8000_write_word(state, 351, (c->isdbt_sb_mode << 9) | (c->isdbt_sb_mode << 8) | (13 << 4) | 5); in dib8000_small_fine_tune()
2289 dib8000_write_word(state, 343 + i, ncoeff[i]); in dib8000_small_fine_tune()
2295 static void dib8000_set_sb_channel(struct dib8000_state *state) in dib8000_set_sb_channel() argument
2297 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_set_sb_channel()
2302 dib8000_write_word(state, 219, dib8000_read_word(state, 219) | 0x1); /* adp_pass =1 */ in dib8000_set_sb_channel()
2303 …dib8000_write_word(state, 190, dib8000_read_word(state, 190) | (0x1 << 14)); /* pha3_force_pha_shi… in dib8000_set_sb_channel()
2305 dib8000_write_word(state, 219, dib8000_read_word(state, 219) & 0xfffe); /* adp_pass =0 */ in dib8000_set_sb_channel()
2306 …dib8000_write_word(state, 190, dib8000_read_word(state, 190) & 0xbfff); /* pha3_force_pha_shift = … in dib8000_set_sb_channel()
2310 state->seg_mask = 0x00E0; in dib8000_set_sb_channel()
2312 state->seg_mask = 0x0040; in dib8000_set_sb_channel()
2314 dib8000_write_word(state, 268, (dib8000_read_word(state, 268) & 0xF9FF) | 0x0200); in dib8000_set_sb_channel()
2318 …dib8000_write_word(state, 187, (4 << 12) | (0 << 11) | (63 << 5) | (0x3 << 3) | ((~c->isdbt_partia… in dib8000_set_sb_channel()
2320 …dib8000_write_word(state, 340, (16 << 6) | (8 << 0)); /* P_ctrl_pre_freq_win_len=16, P_ctrl_pre_fr… in dib8000_set_sb_channel()
2321 …dib8000_write_word(state, 341, (6 << 3) | (1 << 2) | (1 << 1) | (1 << 0));/* P_ctrl_pre_freq_thres… in dib8000_set_sb_channel()
2326 if (state->mode == 3) in dib8000_set_sb_channel()
2327 dib8000_write_word(state, 180, 0x1fcf | ((state->mode - 1) << 14)); in dib8000_set_sb_channel()
2329 dib8000_write_word(state, 180, 0x0fcf | ((state->mode - 1) << 14)); in dib8000_set_sb_channel()
2332 dib8000_write_word(state, 338, (1 << 12) | (1 << 10) | (0 << 9) | (5 << 5) | 4); in dib8000_set_sb_channel()
2335 dib8000_write_word(state, 180, 0x1fcf | (1 << 14)); in dib8000_set_sb_channel()
2337 dib8000_write_word(state, 338, (1 << 12) | (1 << 10) | (0 << 9) | (4 << 5) | 4); in dib8000_set_sb_channel()
2341 dib8000_write_word(state, 228, 1); /* P_2d_mode_byp=1 */ in dib8000_set_sb_channel()
2342 dib8000_write_word(state, 205, dib8000_read_word(state, 205) & 0xfff0); /* P_cspu_win_cut = 0 */ in dib8000_set_sb_channel()
2345 dib8000_write_word(state, 265, 15); /* P_equal_noise_sel = 15 */ in dib8000_set_sb_channel()
2349 dib8000_write_word(state, 181+i, coff[i]); in dib8000_set_sb_channel()
2350 dib8000_write_word(state, 184+i, coff[i]); in dib8000_set_sb_channel()
2358 …dib8000_write_word(state, 266, ~state->seg_mask | state->seg_diff_mask); /* P_equal_noise_seg_inh … in dib8000_set_sb_channel()
2361 dib8000_write_word(state, 178, 64); /* P_fft_powrange = 64 */ in dib8000_set_sb_channel()
2363 dib8000_write_word(state, 178, 32); /* P_fft_powrange = 32 */ in dib8000_set_sb_channel()
2366 static void dib8000_set_isdbt_common_channel(struct dib8000_state *state, u8 seq, u8 autosearching) in dib8000_set_isdbt_common_channel() argument
2372 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_set_isdbt_common_channel()
2378 dib8000_write_word(state, 10, (seq << 4)); in dib8000_set_isdbt_common_channel()
2381 state->mode = fft_to_mode(state); in dib8000_set_isdbt_common_channel()
2384 tmp = dib8000_read_word(state, 1); in dib8000_set_isdbt_common_channel()
2385 dib8000_write_word(state, 1, (tmp&0xfffc) | (c->guard_interval & 0x3)); in dib8000_set_isdbt_common_channel()
2387 …dib8000_write_word(state, 274, (dib8000_read_word(state, 274) & 0xffcf) | ((c->isdbt_partial_recep… in dib8000_set_isdbt_common_channel()
2391 state->seg_diff_mask = (c->layer[0].modulation == DQPSK) << permu_seg[0]; in dib8000_set_isdbt_common_channel()
2395 state->seg_diff_mask |= 1 << permu_seg[i+1]; in dib8000_set_isdbt_common_channel()
2400 state->seg_diff_mask |= 1 << permu_seg[i]; in dib8000_set_isdbt_common_channel()
2403 if (state->seg_diff_mask) in dib8000_set_isdbt_common_channel()
2404 dib8000_write_word(state, 268, (dib8000_read_word(state, 268) & 0xF9FF) | 0x0200); in dib8000_set_isdbt_common_channel()
2406 dib8000_write_word(state, 268, (2 << 9) | 39); /*init value */ in dib8000_set_isdbt_common_channel()
2409 max_constellation = dib8000_set_layer(state, i, max_constellation); in dib8000_set_isdbt_common_channel()
2411 state->layer_b_nb_seg = c->layer[1].segment_count; in dib8000_set_isdbt_common_channel()
2412 state->layer_c_nb_seg = c->layer[2].segment_count; in dib8000_set_isdbt_common_channel()
2416 dib8000_write_word(state, 0, (state->mode << 13) | state->seg_diff_mask); in dib8000_set_isdbt_common_channel()
2418 state->differential_constellation = (state->seg_diff_mask != 0); in dib8000_set_isdbt_common_channel()
2421 ana_gain = dib8000_adp_fine_tune(state, max_constellation); in dib8000_set_isdbt_common_channel()
2424 dib8000_update_ana_gain(state, ana_gain); in dib8000_set_isdbt_common_channel()
2428 dib8000_load_ana_fe_coefs(state, ana_fe_coeff_3seg); in dib8000_set_isdbt_common_channel()
2430 dib8000_load_ana_fe_coefs(state, ana_fe_coeff_1seg); /* 1-segment */ in dib8000_set_isdbt_common_channel()
2434 dib8000_set_sb_channel(state); in dib8000_set_isdbt_common_channel()
2435 init_prbs = dib8000_get_init_prbs(state, in dib8000_set_isdbt_common_channel()
2438 dib8000_set_13seg_channel(state); in dib8000_set_isdbt_common_channel()
2443 dib8000_small_fine_tune(state); in dib8000_set_isdbt_common_channel()
2445 dib8000_set_subchannel_prbs(state, init_prbs); in dib8000_set_isdbt_common_channel()
2449 if ((((~state->seg_diff_mask) >> i) & 1) == 1) { in dib8000_set_isdbt_common_channel()
2450 …p_cfr_left_edge += (1 << i) * ((i == 0) || ((((state->seg_mask & (~state->seg_diff_mask)) >> (i -… in dib8000_set_isdbt_common_channel()
2451 …p_cfr_right_edge += (1 << i) * ((i == 12) || ((((state->seg_mask & (~state->seg_diff_mask)) >> (i … in dib8000_set_isdbt_common_channel()
2454 dib8000_write_word(state, 222, p_cfr_left_edge); /* p_cfr_left_edge */ in dib8000_set_isdbt_common_channel()
2455 dib8000_write_word(state, 223, p_cfr_right_edge); /* p_cfr_right_edge */ in dib8000_set_isdbt_common_channel()
2458 dib8000_write_word(state, 189, ~state->seg_mask | state->seg_diff_mask); /* P_lmod4_seg_inh */ in dib8000_set_isdbt_common_channel()
2459 dib8000_write_word(state, 192, ~state->seg_mask | state->seg_diff_mask); /* P_pha3_seg_inh */ in dib8000_set_isdbt_common_channel()
2460 dib8000_write_word(state, 225, ~state->seg_mask | state->seg_diff_mask); /* P_tac_seg_inh */ in dib8000_set_isdbt_common_channel()
2463 …dib8000_write_word(state, 288, (~state->seg_mask | state->seg_diff_mask) & 0x1fff); /* P_tmcc_seg_… in dib8000_set_isdbt_common_channel()
2465 …dib8000_write_word(state, 288, 0x1fff); /*disable equalisation of the tmcc when autosearch to be a… in dib8000_set_isdbt_common_channel()
2467 dib8000_write_word(state, 211, state->seg_mask & (~state->seg_diff_mask)); /* P_des_seg_enabled */ in dib8000_set_isdbt_common_channel()
2468 dib8000_write_word(state, 287, ~state->seg_mask | 0x1000); /* P_tmcc_seg_inh */ in dib8000_set_isdbt_common_channel()
2470 dib8000_write_word(state, 178, 32); /* P_fft_powrange = 32 */ in dib8000_set_isdbt_common_channel()
2479 dib8000_write_word(state, 290, tmcc_pow); /* P_tmcc_dec_thres_2k */ in dib8000_set_isdbt_common_channel()
2480 dib8000_write_word(state, 291, tmcc_pow); /* P_tmcc_dec_thres_4k */ in dib8000_set_isdbt_common_channel()
2481 dib8000_write_word(state, 292, tmcc_pow); /* P_tmcc_dec_thres_8k */ in dib8000_set_isdbt_common_channel()
2485 if (state->isdbt_cfg_loaded == 0) in dib8000_set_isdbt_common_channel()
2486 dib8000_write_word(state, 250, 3285); /* p_2d_hspeed_thr0 */ in dib8000_set_isdbt_common_channel()
2488 state->isdbt_cfg_loaded = 0; in dib8000_set_isdbt_common_channel()
2491 static u32 dib8000_wait_lock(struct dib8000_state *state, u32 internal, in dib8000_wait_lock() argument
2499 if (state->revision == 0x8090) in dib8000_wait_lock()
2507 dib8000_write_word(state, reg, (u16)((value >> 16) & 0xffff)); in dib8000_wait_lock()
2508 dib8000_write_word(state, (reg + 1), (u16)(value & 0xffff)); in dib8000_wait_lock()
2515 struct dib8000_state *state = fe->demodulator_priv; in dib8000_autosearch_start() local
2516 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_autosearch_start()
2518 u32 value, internal = state->cfg.pll->internal; in dib8000_autosearch_start()
2520 if (state->revision == 0x8090) in dib8000_autosearch_start()
2521 internal = dib8000_read32(state, 23) / 1000; in dib8000_autosearch_start()
2523 if ((state->revision >= 0x8002) && in dib8000_autosearch_start()
2524 (state->autosearch_state == AS_SEARCHING_FFT)) { in dib8000_autosearch_start()
2525 dib8000_write_word(state, 37, 0x0065); /* P_ctrl_pha_off_max default values */ in dib8000_autosearch_start()
2526 dib8000_write_word(state, 116, 0x0000); /* P_ana_gain to 0 */ in dib8000_autosearch_start()
2528 …dib8000_write_word(state, 0, (dib8000_read_word(state, 0) & 0x1fff) | (0 << 13) | (1 << 15)); /* P… in dib8000_autosearch_start()
2529 dib8000_write_word(state, 1, (dib8000_read_word(state, 1) & 0xfffc) | 0); /* P_guard = 0 */ in dib8000_autosearch_start()
2530 dib8000_write_word(state, 6, 0); /* P_lock0_mask = 0 */ in dib8000_autosearch_start()
2531 dib8000_write_word(state, 7, 0); /* P_lock1_mask = 0 */ in dib8000_autosearch_start()
2532 dib8000_write_word(state, 8, 0); /* P_lock2_mask = 0 */ in dib8000_autosearch_start()
2533 …dib8000_write_word(state, 10, (dib8000_read_word(state, 10) & 0x200) | (16 << 4) | (0 << 0)); /* P… in dib8000_autosearch_start()
2535 if (state->revision == 0x8090) in dib8000_autosearch_start()
2536 …value = dib8000_wait_lock(state, internal, 10, 10, 10); /* time in ms configure P_search_end0 P_se… in dib8000_autosearch_start()
2538 …value = dib8000_wait_lock(state, internal, 20, 20, 20); /* time in ms configure P_search_end0 P_se… in dib8000_autosearch_start()
2540 dib8000_write_word(state, 17, 0); in dib8000_autosearch_start()
2541 dib8000_write_word(state, 18, 200); /* P_search_rstst = 200 */ in dib8000_autosearch_start()
2542 dib8000_write_word(state, 19, 0); in dib8000_autosearch_start()
2543 dib8000_write_word(state, 20, 400); /* P_search_rstend = 400 */ in dib8000_autosearch_start()
2544 dib8000_write_word(state, 21, (value >> 16) & 0xffff); /* P_search_checkst */ in dib8000_autosearch_start()
2545 dib8000_write_word(state, 22, value & 0xffff); in dib8000_autosearch_start()
2547 if (state->revision == 0x8090) in dib8000_autosearch_start()
2548 …dib8000_write_word(state, 32, (dib8000_read_word(state, 32) & 0xf0ff) | (0 << 8)); /* P_corm_alpha… in dib8000_autosearch_start()
2550 …dib8000_write_word(state, 32, (dib8000_read_word(state, 32) & 0xf0ff) | (9 << 8)); /* P_corm_alpha… in dib8000_autosearch_start()
2551 dib8000_write_word(state, 355, 2); /* P_search_param_max = 2 */ in dib8000_autosearch_start()
2554 dib8000_write_word(state, 356, 0); in dib8000_autosearch_start()
2555 dib8000_write_word(state, 357, 0x111); in dib8000_autosearch_start()
2557 …dib8000_write_word(state, 770, (dib8000_read_word(state, 770) & 0xdfff) | (1 << 13)); /* P_restart… in dib8000_autosearch_start()
2558 …dib8000_write_word(state, 770, (dib8000_read_word(state, 770) & 0xdfff) | (0 << 13)); /* P_restart… in dib8000_autosearch_start()
2559 …dib8000_write_word(state, 0, (dib8000_read_word(state, 0) & 0x7ff) | (0 << 15) | (1 << 13)); /* P_… in dib8000_autosearch_start()
2560 } else if ((state->revision >= 0x8002) && in dib8000_autosearch_start()
2561 (state->autosearch_state == AS_SEARCHING_GUARD)) { in dib8000_autosearch_start()
2571 c->transmission_mode = state->found_nfft; in dib8000_autosearch_start()
2573 dib8000_set_isdbt_common_channel(state, slist, 1); in dib8000_autosearch_start()
2576 dib8000_write_word(state, 6, 0x4); in dib8000_autosearch_start()
2577 if (state->revision == 0x8090) in dib8000_autosearch_start()
2578 …dib8000_write_word(state, 7, ((1 << 12) | (1 << 11) | (1 << 10)));/* tmcc_dec_lock, tmcc_sync_lock… in dib8000_autosearch_start()
2580 dib8000_write_word(state, 7, 0x8); in dib8000_autosearch_start()
2581 dib8000_write_word(state, 8, 0x1000); in dib8000_autosearch_start()
2584 if (state->revision == 0x8090) in dib8000_autosearch_start()
2585 …dib8000_wait_lock(state, internal, 50, 100, 1000); /* time in ms configure P_search_end0 P_search_… in dib8000_autosearch_start()
2587 …dib8000_wait_lock(state, internal, 50, 200, 1000); /* time in ms configure P_search_end0 P_search_… in dib8000_autosearch_start()
2589 dib8000_write_word(state, 355, 3); /* P_search_param_max = 3 */ in dib8000_autosearch_start()
2592 dib8000_write_word(state, 356, 0); in dib8000_autosearch_start()
2593 dib8000_write_word(state, 357, 0xf); in dib8000_autosearch_start()
2595 value = dib8000_read_word(state, 0); in dib8000_autosearch_start()
2596 dib8000_write_word(state, 0, (u16)((1 << 15) | value)); in dib8000_autosearch_start()
2597 dib8000_read_word(state, 1284); /* reset the INT. n_irq_pending */ in dib8000_autosearch_start()
2598 dib8000_write_word(state, 0, (u16)value); in dib8000_autosearch_start()
2611 dib8000_write_word(state, 0, (dib8000_read_word(state, 0) & 0x9fff) | (1 << 13)); in dib8000_autosearch_start()
2618 …dib8000_write_word(state, 0, (dib8000_read_word(state, 0) & 0x9fff) | (1 << 13)); /* P_mode = 1 t… in dib8000_autosearch_start()
2627 …dib8000_write_word(state, 0, (dib8000_read_word(state, 0) & 0x9fff) | (1 << 13)); /* P_mode = 1 */ in dib8000_autosearch_start()
2634 dib8000_set_isdbt_common_channel(state, slist, 1); in dib8000_autosearch_start()
2637 dib8000_write_word(state, 6, 0x4); in dib8000_autosearch_start()
2638 if (state->revision == 0x8090) in dib8000_autosearch_start()
2639 dib8000_write_word(state, 7, (1 << 12) | (1 << 11) | (1 << 10)); in dib8000_autosearch_start()
2641 dib8000_write_word(state, 7, 0x8); in dib8000_autosearch_start()
2642 dib8000_write_word(state, 8, 0x1000); in dib8000_autosearch_start()
2645 if (state->revision == 0x8090) in dib8000_autosearch_start()
2646 …dib8000_wait_lock(state, internal, 50, 200, 1000); /* time in ms configure P_search_end0 P_search_… in dib8000_autosearch_start()
2648 …dib8000_wait_lock(state, internal, 50, 100, 1000); /* time in ms configure P_search_end0 P_search_… in dib8000_autosearch_start()
2650 value = dib8000_read_word(state, 0); in dib8000_autosearch_start()
2651 dib8000_write_word(state, 0, (u16)((1 << 15) | value)); in dib8000_autosearch_start()
2652 dib8000_read_word(state, 1284); /* reset the INT. n_irq_pending */ in dib8000_autosearch_start()
2653 dib8000_write_word(state, 0, (u16)value); in dib8000_autosearch_start()
2660 struct dib8000_state *state = fe->demodulator_priv; in dib8000_autosearch_irq() local
2661 u16 irq_pending = dib8000_read_word(state, 1284); in dib8000_autosearch_irq()
2663 if ((state->revision >= 0x8002) && in dib8000_autosearch_irq()
2664 (state->autosearch_state == AS_SEARCHING_FFT)) { in dib8000_autosearch_irq()
2684 static void dib8000_viterbi_state(struct dib8000_state *state, u8 onoff) in dib8000_viterbi_state() argument
2688 tmp = dib8000_read_word(state, 771); in dib8000_viterbi_state()
2690 dib8000_write_word(state, 771, tmp & 0xfffd); in dib8000_viterbi_state()
2692 dib8000_write_word(state, 771, tmp | (1<<1)); in dib8000_viterbi_state()
2695 static void dib8000_set_dds(struct dib8000_state *state, s32 offset_khz) in dib8000_set_dds() argument
2699 u32 dds = state->cfg.pll->ifreq & 0x1ffffff; in dib8000_set_dds()
2700 u8 invert = !!(state->cfg.pll->ifreq & (1 << 25)); in dib8000_set_dds()
2703 if (state->revision == 0x8090) { in dib8000_set_dds()
2705 unit_khz_dds_val = (1<<26) / (dib8000_read32(state, 23) / 1000); in dib8000_set_dds()
2715 unit_khz_dds_val = (u16) (67108864 / state->cfg.pll->internal); in dib8000_set_dds()
2729 if (abs_offset_khz <= (state->cfg.pll->internal / ratio)) { in dib8000_set_dds()
2731 dib8000_write_word(state, 26, invert); in dib8000_set_dds()
2732 dib8000_write_word(state, 27, (u16)(dds >> 16) & 0x1ff); in dib8000_set_dds()
2733 dib8000_write_word(state, 28, (u16)(dds & 0xffff)); in dib8000_set_dds()
2737 static void dib8000_set_frequency_offset(struct dib8000_state *state) in dib8000_set_frequency_offset() argument
2739 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_set_frequency_offset()
2744 if (state->fe[0]->ops.tuner_ops.get_frequency) in dib8000_set_frequency_offset()
2745 state->fe[0]->ops.tuner_ops.get_frequency(state->fe[0], &current_rf); in dib8000_set_frequency_offset()
2752 state->subchannel = c->isdbt_sb_subchannel; in dib8000_set_frequency_offset()
2754 i = dib8000_read_word(state, 26) & 1; /* P_dds_invspec */ in dib8000_set_frequency_offset()
2755 dib8000_write_word(state, 26, c->inversion ^ i); in dib8000_set_frequency_offset()
2757 if (state->cfg.pll->ifreq == 0) { /* low if tuner */ in dib8000_set_frequency_offset()
2759 dib8000_write_word(state, 26, dib8000_read_word(state, 26) | 1); in dib8000_set_frequency_offset()
2769 dib8000_set_dds(state, total_dds_offset_khz); in dib8000_set_frequency_offset()
2774 static u32 dib8000_get_symbol_duration(struct dib8000_state *state) in dib8000_get_symbol_duration() argument
2776 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_get_symbol_duration()
2796 static void dib8000_set_isdbt_loop_params(struct dib8000_state *state, enum param_loop_step loop_st… in dib8000_set_isdbt_loop_params() argument
2798 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_set_isdbt_loop_params()
2805 …reg_32 = ((11 - state->mode) << 12) | (6 << 8) | 0x40; /* P_timf_alpha = (11-P_mode), P_corm_alpha… in dib8000_set_isdbt_loop_params()
2806 …reg_37 = (3 << 5) | (0 << 4) | (10 - state->mode); /* P_ctrl_pha_off_max=3 P_ctrl_sfreq_inh =0 … in dib8000_set_isdbt_loop_params()
2808 …reg_32 = ((10 - state->mode) << 12) | (6 << 8) | 0x60; /* P_timf_alpha = (10-P_mode), P_corm_alpha… in dib8000_set_isdbt_loop_params()
2809 …reg_37 = (3 << 5) | (0 << 4) | (9 - state->mode); /* P_ctrl_pha_off_max=3 P_ctrl_sfreq_inh =0 P… in dib8000_set_isdbt_loop_params()
2812 …reg_32 = ((9 - state->mode) << 12) | (6 << 8) | 0x80; /* P_timf_alpha = (9-P_mode, P_corm_alpha=6,… in dib8000_set_isdbt_loop_params()
2813 …reg_37 = (3 << 5) | (0 << 4) | (8 - state->mode); /* P_ctrl_pha_off_max=3 P_ctrl_sfreq_inh =0 P… in dib8000_set_isdbt_loop_params()
2819 …reg_32 = ((13-state->mode) << 12) | (6 << 8) | 0x40; /* P_timf_alpha = (13-P_mode) , P_corm_alpha=… in dib8000_set_isdbt_loop_params()
2820 reg_37 = (12-state->mode) | ((5 + state->mode) << 5); in dib8000_set_isdbt_loop_params()
2822 …reg_32 = ((12-state->mode) << 12) | (6 << 8) | 0x60; /* P_timf_alpha = (12-P_mode) , P_corm_alpha=… in dib8000_set_isdbt_loop_params()
2823 reg_37 = (11-state->mode) | ((5 + state->mode) << 5); in dib8000_set_isdbt_loop_params()
2826 …reg_32 = ((11-state->mode) << 12) | (6 << 8) | 0x80; /* P_timf_alpha = 8 , P_corm_alpha=6, P_corm_… in dib8000_set_isdbt_loop_params()
2827 reg_37 = ((5+state->mode) << 5) | (10 - state->mode); in dib8000_set_isdbt_loop_params()
2831 dib8000_write_word(state, 32, reg_32); in dib8000_set_isdbt_loop_params()
2832 dib8000_write_word(state, 37, reg_37); in dib8000_set_isdbt_loop_params()
2835 static void dib8000_demod_restart(struct dib8000_state *state) in dib8000_demod_restart() argument
2837 dib8000_write_word(state, 770, 0x4000); in dib8000_demod_restart()
2838 dib8000_write_word(state, 770, 0x0000); in dib8000_demod_restart()
2842 static void dib8000_set_sync_wait(struct dib8000_state *state) in dib8000_set_sync_wait() argument
2844 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_set_sync_wait()
2861 if (state->cfg.diversity_delay == 0) in dib8000_set_sync_wait()
2864 …sync_wait = (sync_wait * (1 << (c->guard_interval)) * 3) / 2 + state->cfg.diversity_delay; /* add … in dib8000_set_sync_wait()
2866 dib8000_write_word(state, 273, (dib8000_read_word(state, 273) & 0x000f) | (sync_wait << 4)); in dib8000_set_sync_wait()
2869 static unsigned long dib8000_get_timeout(struct dib8000_state *state, u32 delay, enum timeout_mode … in dib8000_get_timeout() argument
2872 delay *= state->symbol_duration; in dib8000_get_timeout()
2879 struct dib8000_state *state = fe->demodulator_priv; in dib8000_get_status() local
2880 return state->status; in dib8000_get_status()
2885 struct dib8000_state *state = fe->demodulator_priv; in dib8000_get_tune_state() local
2886 return state->tune_state; in dib8000_get_tune_state()
2891 struct dib8000_state *state = fe->demodulator_priv; in dib8000_set_tune_state() local
2893 state->tune_state = tune_state; in dib8000_set_tune_state()
2899 struct dib8000_state *state = fe->demodulator_priv; in dib8000_tune_restart_from_demod() local
2901 state->status = FE_STATUS_TUNE_PENDING; in dib8000_tune_restart_from_demod()
2902 state->tune_state = CT_DEMOD_START; in dib8000_tune_restart_from_demod()
2908 struct dib8000_state *state = fe->demodulator_priv; in dib8000_read_lock() local
2910 if (state->revision == 0x8090) in dib8000_read_lock()
2911 return dib8000_read_word(state, 570); in dib8000_read_lock()
2912 return dib8000_read_word(state, 568); in dib8000_read_lock()
2915 static int dib8090p_init_sdram(struct dib8000_state *state) in dib8090p_init_sdram() argument
2920 reg = dib8000_read_word(state, 274) & 0xfff0; in dib8090p_init_sdram()
2921 dib8000_write_word(state, 274, reg | 0x7); /* P_dintlv_delay_ram = 7 because of MobileSdram */ in dib8090p_init_sdram()
2923 dib8000_write_word(state, 1803, (7 << 2)); in dib8090p_init_sdram()
2925 reg = dib8000_read_word(state, 1280); in dib8090p_init_sdram()
2926 dib8000_write_word(state, 1280, reg | (1 << 2)); /* force restart P_restart_sdram */ in dib8090p_init_sdram()
2927 dib8000_write_word(state, 1280, reg); /* release restart P_restart_sdram */ in dib8090p_init_sdram()
3019 struct dib8000_state *state = fe->demodulator_priv; in dib8000_tune() local
3020 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_tune()
3021 enum frontend_tune_state *tune_state = &state->tune_state; in dib8000_tune()
3026 unsigned long *timeout = &state->timeout; in dib8000_tune()
3039 state->channel_parameters_set, *tune_state, state->autosearch_state, now); in dib8000_tune()
3046 if (state->revision == 0x8090) in dib8000_tune()
3047 dib8090p_init_sdram(state); in dib8000_tune()
3048 state->status = FE_STATUS_TUNE_PENDING; in dib8000_tune()
3049 state->channel_parameters_set = is_manual_mode(c); in dib8000_tune()
3052 state->channel_parameters_set ? "manual" : "auto"); in dib8000_tune()
3054 dib8000_viterbi_state(state, 0); /* force chan dec in restart */ in dib8000_tune()
3057 dib8000_write_word(state, 285, dib8000_read_word(state, 285) & 0x60); in dib8000_tune()
3059 dib8000_set_frequency_offset(state); in dib8000_tune()
3062 if (state->channel_parameters_set == 0) { /* The channel struct is unknown, search it ! */ in dib8000_tune()
3064 if (state->revision != 0x8090) { in dib8000_tune()
3065 state->agc1_max = dib8000_read_word(state, 108); in dib8000_tune()
3066 state->agc1_min = dib8000_read_word(state, 109); in dib8000_tune()
3067 state->agc2_max = dib8000_read_word(state, 110); in dib8000_tune()
3068 state->agc2_min = dib8000_read_word(state, 111); in dib8000_tune()
3069 agc1 = dib8000_read_word(state, 388); in dib8000_tune()
3070 agc2 = dib8000_read_word(state, 389); in dib8000_tune()
3071 dib8000_write_word(state, 108, agc1); in dib8000_tune()
3072 dib8000_write_word(state, 109, agc1); in dib8000_tune()
3073 dib8000_write_word(state, 110, agc2); in dib8000_tune()
3074 dib8000_write_word(state, 111, agc2); in dib8000_tune()
3077 state->autosearch_state = AS_SEARCHING_FFT; in dib8000_tune()
3078 state->found_nfft = TRANSMISSION_MODE_AUTO; in dib8000_tune()
3079 state->found_guard = GUARD_INTERVAL_AUTO; in dib8000_tune()
3082 state->autosearch_state = AS_DONE; in dib8000_tune()
3085 state->symbol_duration = dib8000_get_symbol_duration(state); in dib8000_tune()
3090 if (state->revision == 0x8090) in dib8000_tune()
3100 state->status = FE_STATUS_TUNE_FAILED; in dib8000_tune()
3101 state->autosearch_state = AS_DONE; in dib8000_tune()
3105state->status = FE_STATUS_FFT_SUCCESS; /* signal to the upper layer, that there was a channel foun… in dib8000_tune()
3107 if (state->autosearch_state == AS_SEARCHING_GUARD) in dib8000_tune()
3110 state->autosearch_state = AS_DONE; in dib8000_tune()
3119 switch (state->autosearch_state) { in dib8000_tune()
3122 if (state->revision == 0x8090) { in dib8000_tune()
3123 corm[2] = (dib8000_read_word(state, 596) << 16) | (dib8000_read_word(state, 597)); in dib8000_tune()
3124 corm[1] = (dib8000_read_word(state, 598) << 16) | (dib8000_read_word(state, 599)); in dib8000_tune()
3125 corm[0] = (dib8000_read_word(state, 600) << 16) | (dib8000_read_word(state, 601)); in dib8000_tune()
3127 corm[2] = (dib8000_read_word(state, 594) << 16) | (dib8000_read_word(state, 595)); in dib8000_tune()
3128 corm[1] = (dib8000_read_word(state, 596) << 16) | (dib8000_read_word(state, 597)); in dib8000_tune()
3129 corm[0] = (dib8000_read_word(state, 598) << 16) | (dib8000_read_word(state, 599)); in dib8000_tune()
3141 state->found_nfft = TRANSMISSION_MODE_2K; in dib8000_tune()
3144 state->found_nfft = TRANSMISSION_MODE_4K; in dib8000_tune()
3148 state->found_nfft = TRANSMISSION_MODE_8K; in dib8000_tune()
3154 state->autosearch_state = AS_SEARCHING_GUARD; in dib8000_tune()
3155 if (state->revision == 0x8090) in dib8000_tune()
3162 if (state->revision == 0x8090) in dib8000_tune()
3163 state->found_guard = dib8000_read_word(state, 572) & 0x3; in dib8000_tune()
3165 state->found_guard = dib8000_read_word(state, 570) & 0x3; in dib8000_tune()
3172 state->status = FE_STATUS_TUNE_FAILED; in dib8000_tune()
3173 state->autosearch_state = AS_DONE; in dib8000_tune()
3180 dib8000_set_isdbt_loop_params(state, LOOP_TUNE_1); in dib8000_tune()
3181 dib8000_set_isdbt_common_channel(state, 0, 0);/* setting the known channel parameters here */ in dib8000_tune()
3186 dib8000_demod_restart(state); in dib8000_tune()
3188 dib8000_set_sync_wait(state); in dib8000_tune()
3189 dib8000_set_diversity_in(state->fe[0], state->diversity_onoff); in dib8000_tune()
3191 locks = (dib8000_read_word(state, 180) >> 6) & 0x3f; /* P_coff_winlen ? */ in dib8000_tune()
3193 *timeout = dib8000_get_timeout(state, 2 * locks, SYMBOL_DEPENDENT_ON); in dib8000_tune()
3200 dib8000_update_timf(state); /* we achieved a coff_cpil_lock - it's time to update the timf */ in dib8000_tune()
3201 if (!state->differential_constellation) { in dib8000_tune()
3203 …*timeout = dib8000_get_timeout(state, (20 * ((dib8000_read_word(state, 188)>>5)&0x1f)), SYMBOL_DEP… in dib8000_tune()
3214 if ((state->fe[1] != NULL) && (state->output_mode != OUTMODE_DIVERSITY)) { in dib8000_tune()
3216 …if (dib8000_get_status(state->fe[1]) <= FE_STATUS_STD_SUCCESS) /* Something is locked on the input… in dib8000_tune()
3218 …else if (dib8000_get_status(state->fe[1]) >= FE_STATUS_TUNE_TIME_TOO_SHORT) { /* fe in input faile… in dib8000_tune()
3220 dib8000_viterbi_state(state, 1); /* start viterbi chandec */ in dib8000_tune()
3221 dib8000_set_isdbt_loop_params(state, LOOP_TUNE_2); in dib8000_tune()
3222 state->status = FE_STATUS_TUNE_FAILED; in dib8000_tune()
3225 dib8000_viterbi_state(state, 1); /* start viterbi chandec */ in dib8000_tune()
3226 dib8000_set_isdbt_loop_params(state, LOOP_TUNE_2); in dib8000_tune()
3228 state->status = FE_STATUS_TUNE_FAILED; in dib8000_tune()
3242 dib8000_viterbi_state(state, 1); /* start viterbi chandec */ in dib8000_tune()
3243 dib8000_set_isdbt_loop_params(state, LOOP_TUNE_2); in dib8000_tune()
3248 && !state->differential_constellation) { in dib8000_tune()
3249 state->subchannel = 0; in dib8000_tune()
3253 state->status = FE_STATUS_LOCKED; in dib8000_tune()
3258 …if ((state->revision == 0x8090) || ((dib8000_read_word(state, 1291) >> 9) & 0x1)) { /* fe capable … in dib8000_tune()
3265 state->longest_intlv_layer = i; in dib8000_tune()
3277 if (state->diversity_onoff != 0) /* because of diversity sync */ in dib8000_tune()
3282 deeper_interleaver, state->longest_intlv_layer, locks, *timeout); in dib8000_tune()
3291 if (locks&(1<<(7-state->longest_intlv_layer))) { /* mpeg lock : check the longest one */ in dib8000_tune()
3298 && !state->differential_constellation) in dib8000_tune()
3300 state->status = FE_STATUS_DEMOD_SUCCESS; in dib8000_tune()
3302 state->status = FE_STATUS_DATA_LOCKED; in dib8000_tune()
3307 && !state->differential_constellation) { /* continue to try init prbs autosearch */ in dib8000_tune()
3308 state->subchannel += 3; in dib8000_tune()
3318 state->status = FE_STATUS_DATA_LOCKED; in dib8000_tune()
3320 state->status = FE_STATUS_TUNE_FAILED; in dib8000_tune()
3327 init_prbs = dib8000_get_init_prbs(state, state->subchannel); in dib8000_tune()
3330 dib8000_set_subchannel_prbs(state, init_prbs); in dib8000_tune()
3334 state->status = FE_STATUS_TUNE_FAILED; in dib8000_tune()
3346 if ((state->revision != 0x8090) && (state->agc1_max != 0)) { in dib8000_tune()
3347 dib8000_write_word(state, 108, state->agc1_max); in dib8000_tune()
3348 dib8000_write_word(state, 109, state->agc1_min); in dib8000_tune()
3349 dib8000_write_word(state, 110, state->agc2_max); in dib8000_tune()
3350 dib8000_write_word(state, 111, state->agc2_min); in dib8000_tune()
3351 state->agc1_max = 0; in dib8000_tune()
3352 state->agc1_min = 0; in dib8000_tune()
3353 state->agc2_max = 0; in dib8000_tune()
3354 state->agc2_min = 0; in dib8000_tune()
3364 return ret * state->symbol_duration; in dib8000_tune()
3365 if ((ret > 0) && (ret < state->symbol_duration)) in dib8000_tune()
3366 return state->symbol_duration; /* at least one symbol */ in dib8000_tune()
3372 struct dib8000_state *state = fe->demodulator_priv; in dib8000_wakeup() local
3376 dib8000_set_power_mode(state, DIB8000_POWER_ALL); in dib8000_wakeup()
3377 dib8000_set_adc_state(state, DIBX000_ADC_ON); in dib8000_wakeup()
3378 if (dib8000_set_adc_state(state, DIBX000_SLOW_ADC_ON) != 0) in dib8000_wakeup()
3381 if (state->revision == 0x8090) in dib8000_wakeup()
3382 dib8000_sad_calib(state); in dib8000_wakeup()
3384 …for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_wakeup()
3385 ret = state->fe[index_frontend]->ops.init(state->fe[index_frontend]); in dib8000_wakeup()
3395 struct dib8000_state *state = fe->demodulator_priv; in dib8000_sleep() local
3399 …for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_sleep()
3400 ret = state->fe[index_frontend]->ops.sleep(state->fe[index_frontend]); in dib8000_sleep()
3405 if (state->revision != 0x8090) in dib8000_sleep()
3407 dib8000_set_power_mode(state, DIB8000_POWER_INTERFACE_ONLY); in dib8000_sleep()
3408 …return dib8000_set_adc_state(state, DIBX000_SLOW_ADC_OFF) | dib8000_set_adc_state(state, DIBX000_A… in dib8000_sleep()
3416 struct dib8000_state *state = fe->demodulator_priv; in dib8000_get_frontend() local
3433 …for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_get_frontend()
3434 state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat); in dib8000_get_frontend()
3438 state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c); in dib8000_get_frontend()
3439 …for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_inde… in dib8000_get_frontend()
3441state->fe[sub_index_frontend]->dtv_property_cache.isdbt_sb_mode = state->fe[index_frontend]->dtv_p… in dib8000_get_frontend()
3442state->fe[sub_index_frontend]->dtv_property_cache.inversion = state->fe[index_frontend]->dtv_prope… in dib8000_get_frontend()
3443state->fe[sub_index_frontend]->dtv_property_cache.transmission_mode = state->fe[index_frontend]->d… in dib8000_get_frontend()
3444state->fe[sub_index_frontend]->dtv_property_cache.guard_interval = state->fe[index_frontend]->dtv_… in dib8000_get_frontend()
3445state->fe[sub_index_frontend]->dtv_property_cache.isdbt_partial_reception = state->fe[index_fronte… in dib8000_get_frontend()
3447state->fe[sub_index_frontend]->dtv_property_cache.layer[i].segment_count = state->fe[index_fronten… in dib8000_get_frontend()
3448state->fe[sub_index_frontend]->dtv_property_cache.layer[i].interleaving = state->fe[index_frontend… in dib8000_get_frontend()
3449state->fe[sub_index_frontend]->dtv_property_cache.layer[i].fec = state->fe[index_frontend]->dtv_pr… in dib8000_get_frontend()
3450state->fe[sub_index_frontend]->dtv_property_cache.layer[i].modulation = state->fe[index_frontend]-… in dib8000_get_frontend()
3458 c->isdbt_sb_mode = dib8000_read_word(state, 508) & 0x1; in dib8000_get_frontend()
3460 if (state->revision == 0x8090) in dib8000_get_frontend()
3461 val = dib8000_read_word(state, 572); in dib8000_get_frontend()
3463 val = dib8000_read_word(state, 570); in dib8000_get_frontend()
3500 val = dib8000_read_word(state, 505); in dib8000_get_frontend()
3507 val = dib8000_read_word(state, 493 + i) & 0x0f; in dib8000_get_frontend()
3519 val = dib8000_read_word(state, 499 + i) & 0x3; in dib8000_get_frontend()
3528 val = dib8000_read_word(state, 481 + i); in dib8000_get_frontend()
3557 val = dib8000_read_word(state, 487 + i); in dib8000_get_frontend()
3584 …for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_get_frontend()
3585 state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode = c->isdbt_sb_mode; in dib8000_get_frontend()
3586 state->fe[index_frontend]->dtv_property_cache.inversion = c->inversion; in dib8000_get_frontend()
3587 state->fe[index_frontend]->dtv_property_cache.transmission_mode = c->transmission_mode; in dib8000_get_frontend()
3588 state->fe[index_frontend]->dtv_property_cache.guard_interval = c->guard_interval; in dib8000_get_frontend()
3589state->fe[index_frontend]->dtv_property_cache.isdbt_partial_reception = c->isdbt_partial_reception; in dib8000_get_frontend()
3591 state->fe[index_frontend]->dtv_property_cache.layer[i].segment_count = c->layer[i].segment_count; in dib8000_get_frontend()
3592 state->fe[index_frontend]->dtv_property_cache.layer[i].interleaving = c->layer[i].interleaving; in dib8000_get_frontend()
3593 state->fe[index_frontend]->dtv_property_cache.layer[i].fec = c->layer[i].fec; in dib8000_get_frontend()
3594 state->fe[index_frontend]->dtv_property_cache.layer[i].modulation = c->layer[i].modulation; in dib8000_get_frontend()
3602 struct dib8000_state *state = fe->demodulator_priv; in dib8000_set_frontend() local
3603 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_set_frontend()
3618 …for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_set_frontend()
3620 state->fe[index_frontend]->dtv_property_cache.delivery_system = SYS_ISDBT; in dib8000_set_frontend()
3621 …memcpy(&state->fe[index_frontend]->dtv_property_cache, &fe->dtv_property_cache, sizeof(struct dtv_… in dib8000_set_frontend()
3624 if (state->revision != 0x8090) { in dib8000_set_frontend()
3625 dib8000_set_diversity_in(state->fe[index_frontend], 1); in dib8000_set_frontend()
3627 dib8000_set_output_mode(state->fe[index_frontend], in dib8000_set_frontend()
3630 dib8000_set_output_mode(state->fe[0], OUTMODE_HIGH_Z); in dib8000_set_frontend()
3632 dib8096p_set_diversity_in(state->fe[index_frontend], 1); in dib8000_set_frontend()
3634 dib8096p_set_output_mode(state->fe[index_frontend], in dib8000_set_frontend()
3637 dib8096p_set_output_mode(state->fe[0], OUTMODE_HIGH_Z); in dib8000_set_frontend()
3641 if (state->fe[index_frontend]->ops.tuner_ops.set_params) in dib8000_set_frontend()
3642 state->fe[index_frontend]->ops.tuner_ops.set_params(state->fe[index_frontend]); in dib8000_set_frontend()
3644 dib8000_set_tune_state(state->fe[index_frontend], CT_AGC_START); in dib8000_set_frontend()
3648 if (state->revision != 0x8090) in dib8000_set_frontend()
3649 dib8000_set_diversity_in(state->fe[index_frontend - 1], 0); in dib8000_set_frontend()
3651 dib8096p_set_diversity_in(state->fe[index_frontend - 1], 0); in dib8000_set_frontend()
3655 time = dib8000_agc_startup(state->fe[0]); in dib8000_set_frontend()
3656 …for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_set_frontend()
3657 time_slave = dib8000_agc_startup(state->fe[index_frontend]); in dib8000_set_frontend()
3677 …for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_set_frontend()
3678 if (dib8000_get_tune_state(state->fe[index_frontend]) != CT_AGC_STOP) { in dib8000_set_frontend()
3685 …for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_set_frontend()
3686 dib8000_set_tune_state(state->fe[index_frontend], CT_DEMOD_START); in dib8000_set_frontend()
3691 …for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_set_frontend()
3692 delay = dib8000_tune(state->fe[index_frontend]); in dib8000_set_frontend()
3700 if (state->channel_parameters_set == 0) { /* searching */ in dib8000_set_frontend()
3701 …if ((dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_DEMOD_SUCCESS) || (dib8000_get_sta… in dib8000_set_frontend()
3703 …dib8000_get_frontend(state->fe[index_frontend], c); /* we read the channel parameters from the fro… in dib8000_set_frontend()
3704 state->channel_parameters_set = 1; in dib8000_set_frontend()
3706 for (l = 0; (l < MAX_NUMBER_OF_FRONTENDS) && (state->fe[l] != NULL); l++) { in dib8000_set_frontend()
3709 dib8000_tune_restart_from_demod(state->fe[l]); in dib8000_set_frontend()
3711state->fe[l]->dtv_property_cache.isdbt_sb_mode = state->fe[index_frontend]->dtv_property_cache.isd… in dib8000_set_frontend()
3712state->fe[l]->dtv_property_cache.inversion = state->fe[index_frontend]->dtv_property_cache.inversi… in dib8000_set_frontend()
3713state->fe[l]->dtv_property_cache.transmission_mode = state->fe[index_frontend]->dtv_property_cache… in dib8000_set_frontend()
3714state->fe[l]->dtv_property_cache.guard_interval = state->fe[index_frontend]->dtv_property_cache.gu… in dib8000_set_frontend()
3715state->fe[l]->dtv_property_cache.isdbt_partial_reception = state->fe[index_frontend]->dtv_property… in dib8000_set_frontend()
3717state->fe[l]->dtv_property_cache.layer[i].segment_count = state->fe[index_frontend]->dtv_property_… in dib8000_set_frontend()
3718state->fe[l]->dtv_property_cache.layer[i].interleaving = state->fe[index_frontend]->dtv_property_c… in dib8000_set_frontend()
3719state->fe[l]->dtv_property_cache.layer[i].fec = state->fe[index_frontend]->dtv_property_cache.laye… in dib8000_set_frontend()
3720state->fe[l]->dtv_property_cache.layer[i].modulation = state->fe[index_frontend]->dtv_property_cac… in dib8000_set_frontend()
3729 if (dib8000_get_status(state->fe[0]) == FE_STATUS_TUNE_FAILED || in dib8000_set_frontend()
3730 dib8000_get_status(state->fe[0]) == FE_STATUS_LOCKED || in dib8000_set_frontend()
3731 dib8000_get_status(state->fe[0]) == FE_STATUS_DATA_LOCKED) { in dib8000_set_frontend()
3734 …for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_set_frontend()
3735 if (dib8000_get_tune_state(state->fe[index_frontend]) != CT_DEMOD_STOP) in dib8000_set_frontend()
3739 dprintk("tuning done with status %d\n", dib8000_get_status(state->fe[0])); in dib8000_set_frontend()
3752 if (state->revision != 0x8090) in dib8000_set_frontend()
3753 dib8000_set_output_mode(state->fe[0], state->cfg.output_mode); in dib8000_set_frontend()
3755 dib8096p_set_output_mode(state->fe[0], state->cfg.output_mode); in dib8000_set_frontend()
3756 if (state->cfg.enMpegOutput == 0) { in dib8000_set_frontend()
3757 dib8096p_setDibTxMux(state, MPEG_ON_DIBTX); in dib8000_set_frontend()
3758 dib8096p_setHostBusMux(state, DIBTX_ON_HOSTBUS); in dib8000_set_frontend()
3769 struct dib8000_state *state = fe->demodulator_priv; in dib8000_read_status() local
3774 …for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_read_status()
3775 lock_slave |= dib8000_read_lock(state->fe[index_frontend]); in dib8000_read_status()
3792 lock = dib8000_read_word(state, 554); /* Viterbi Layer A */ in dib8000_read_status()
3796 lock = dib8000_read_word(state, 555); /* Viterbi Layer B */ in dib8000_read_status()
3800 lock = dib8000_read_word(state, 556); /* Viterbi Layer C */ in dib8000_read_status()
3811 struct dib8000_state *state = fe->demodulator_priv; in dib8000_read_ber() local
3814 if (state->revision == 0x8090) in dib8000_read_ber()
3815 *ber = (dib8000_read_word(state, 562) << 16) | in dib8000_read_ber()
3816 dib8000_read_word(state, 563); in dib8000_read_ber()
3818 *ber = (dib8000_read_word(state, 560) << 16) | in dib8000_read_ber()
3819 dib8000_read_word(state, 561); in dib8000_read_ber()
3825 struct dib8000_state *state = fe->demodulator_priv; in dib8000_read_unc_blocks() local
3828 if (state->revision == 0x8090) in dib8000_read_unc_blocks()
3829 *unc = dib8000_read_word(state, 567); in dib8000_read_unc_blocks()
3831 *unc = dib8000_read_word(state, 565); in dib8000_read_unc_blocks()
3837 struct dib8000_state *state = fe->demodulator_priv; in dib8000_read_signal_strength() local
3842 …for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_read_signal_strength()
3843 state->fe[index_frontend]->ops.read_signal_strength(state->fe[index_frontend], &val); in dib8000_read_signal_strength()
3850 val = 65535 - dib8000_read_word(state, 390); in dib8000_read_signal_strength()
3860 struct dib8000_state *state = fe->demodulator_priv; in dib8000_get_snr() local
3864 if (state->revision != 0x8090) in dib8000_get_snr()
3865 val = dib8000_read_word(state, 542); in dib8000_get_snr()
3867 val = dib8000_read_word(state, 544); in dib8000_get_snr()
3874 if (state->revision != 0x8090) in dib8000_get_snr()
3875 val = dib8000_read_word(state, 543); in dib8000_get_snr()
3877 val = dib8000_read_word(state, 545); in dib8000_get_snr()
3893 struct dib8000_state *state = fe->demodulator_priv; in dib8000_read_snr() local
3898 …for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] … in dib8000_read_snr()
3899 snr_master += dib8000_get_snr(state->fe[index_frontend]); in dib8000_read_snr()
4009 struct dib8000_state *state = fe->demodulator_priv; in dib8000_get_time_us() local
4010 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_get_time_us()
4123 struct dib8000_state *state = fe->demodulator_priv; in dib8000_get_stats() local
4124 struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; in dib8000_get_stats()
4156 if (time_after(jiffies, state->per_jiffies_stats)) { in dib8000_get_stats()
4157 state->per_jiffies_stats = jiffies + msecs_to_jiffies(1000); in dib8000_get_stats()
4162 if (state->fe[i]) in dib8000_get_stats()
4163 snr += dib8000_get_snr(state->fe[i]); in dib8000_get_stats()
4178 if (val < state->init_ucb) in dib8000_get_stats()
4179 state->init_ucb += 0x100000000LL; in dib8000_get_stats()
4182 c->block_error.stat[0].uvalue = val + state->init_ucb; in dib8000_get_stats()
4199 if (time_after(jiffies, state->ber_jiffies_stats)) { in dib8000_get_stats()
4201 state->ber_jiffies_stats = jiffies + msecs_to_jiffies((time_us + 500) / 1000); in dib8000_get_stats()
4213 if (state->revision < 0x8002) in dib8000_get_stats()
4228 if (time_after(jiffies, state->ber_jiffies_stats_layer[i])) { in dib8000_get_stats()
4231 state->ber_jiffies_stats_layer[i] = jiffies + msecs_to_jiffies((time_us + 500) / 1000); in dib8000_get_stats()
4235 val = dib8000_read_word(state, per_layer_regs[i].ber); in dib8000_get_stats()
4244 val = dib8000_read_word(state, per_layer_regs[i].per); in dib8000_get_stats()
4264 struct dib8000_state *state = fe->demodulator_priv; in dib8000_set_slave_frontend() local
4267 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL)) in dib8000_set_slave_frontend()
4271 state->fe[index_frontend] = fe_slave; in dib8000_set_slave_frontend()
4281 struct dib8000_state *state = fe->demodulator_priv; in dib8000_get_slave_frontend() local
4285 return state->fe[slave_index]; in dib8000_get_slave_frontend()
4443 struct dib8000_state *state; in dib8000_init() local
4447 state = kzalloc(sizeof(struct dib8000_state), GFP_KERNEL); in dib8000_init()
4448 if (state == NULL) in dib8000_init()
4454 memcpy(&state->cfg, cfg, sizeof(struct dib8000_config)); in dib8000_init()
4455 state->i2c.adap = i2c_adap; in dib8000_init()
4456 state->i2c.addr = i2c_addr; in dib8000_init()
4457 state->i2c.i2c_write_buffer = state->i2c_write_buffer; in dib8000_init()
4458 state->i2c.i2c_read_buffer = state->i2c_read_buffer; in dib8000_init()
4459 mutex_init(&state->i2c_buffer_lock); in dib8000_init()
4460 state->i2c.i2c_buffer_lock = &state->i2c_buffer_lock; in dib8000_init()
4461 state->gpio_val = cfg->gpio_val; in dib8000_init()
4462 state->gpio_dir = cfg->gpio_dir; in dib8000_init()
4467 …if ((state->cfg.output_mode != OUTMODE_MPEG2_SERIAL) && (state->cfg.output_mode != OUTMODE_MPEG2_P… in dib8000_init()
4468 state->cfg.output_mode = OUTMODE_MPEG2_FIFO; in dib8000_init()
4470 state->fe[0] = fe; in dib8000_init()
4471 fe->demodulator_priv = state; in dib8000_init()
4472 memcpy(&state->fe[0]->ops, &dib8000_ops, sizeof(struct dvb_frontend_ops)); in dib8000_init()
4474 state->timf_default = cfg->pll->timf; in dib8000_init()
4476 if (dib8000_identify(&state->i2c) == 0) { in dib8000_init()
4481 dibx000_init_i2c_master(&state->i2c_master, DIB8000, state->i2c.adap, state->i2c.addr); in dib8000_init()
4484 strscpy(state->dib8096p_tuner_adap.name, "DiB8096P tuner interface", in dib8000_init()
4485 sizeof(state->dib8096p_tuner_adap.name)); in dib8000_init()
4486 state->dib8096p_tuner_adap.algo = &dib8096p_tuner_xfer_algo; in dib8000_init()
4487 state->dib8096p_tuner_adap.algo_data = NULL; in dib8000_init()
4488 state->dib8096p_tuner_adap.dev.parent = state->i2c.adap->dev.parent; in dib8000_init()
4489 i2c_set_adapdata(&state->dib8096p_tuner_adap, state); in dib8000_init()
4490 i2c_add_adapter(&state->dib8096p_tuner_adap); in dib8000_init()
4494 …dib8000_write_word(state, 285, (dib8000_read_word(state, 285) & ~0x60) | (3 << 5)); /* ber_rs_len … in dib8000_init()
4495 state->current_demod_bw = 6000; in dib8000_init()
4500 kfree(state); in dib8000_init()