Lines Matching +full:bypass +full:- +full:attenuator +full:- +full:in

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Linux-DVB Driver for DiBcom's second generation DiB7000P (PC).
5 * Copyright (C) 2005-7 DiBcom (http://www.dibcom.fr/)
27 MODULE_PARM_DESC(buggy_sfn_workaround, "Enable work-around for buggy SFNs (default: 0)");
99 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib7000p_read_word()
104 state->i2c_write_buffer[0] = reg >> 8; in dib7000p_read_word()
105 state->i2c_write_buffer[1] = reg & 0xff; in dib7000p_read_word()
107 memset(state->msg, 0, 2 * sizeof(struct i2c_msg)); in dib7000p_read_word()
108 state->msg[0].addr = state->i2c_addr >> 1; in dib7000p_read_word()
109 state->msg[0].flags = 0; in dib7000p_read_word()
110 state->msg[0].buf = state->i2c_write_buffer; in dib7000p_read_word()
111 state->msg[0].len = 2; in dib7000p_read_word()
112 state->msg[1].addr = state->i2c_addr >> 1; in dib7000p_read_word()
113 state->msg[1].flags = I2C_M_RD; in dib7000p_read_word()
114 state->msg[1].buf = state->i2c_read_buffer; in dib7000p_read_word()
115 state->msg[1].len = 2; in dib7000p_read_word()
117 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2) in dib7000p_read_word()
120 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1]; in dib7000p_read_word()
121 mutex_unlock(&state->i2c_buffer_lock); in dib7000p_read_word()
129 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib7000p_write_word()
131 return -EINVAL; in dib7000p_write_word()
134 state->i2c_write_buffer[0] = (reg >> 8) & 0xff; in dib7000p_write_word()
135 state->i2c_write_buffer[1] = reg & 0xff; in dib7000p_write_word()
136 state->i2c_write_buffer[2] = (val >> 8) & 0xff; in dib7000p_write_word()
137 state->i2c_write_buffer[3] = val & 0xff; in dib7000p_write_word()
139 memset(&state->msg[0], 0, sizeof(struct i2c_msg)); in dib7000p_write_word()
140 state->msg[0].addr = state->i2c_addr >> 1; in dib7000p_write_word()
141 state->msg[0].flags = 0; in dib7000p_write_word()
142 state->msg[0].buf = state->i2c_write_buffer; in dib7000p_write_word()
143 state->msg[0].len = 4; in dib7000p_write_word()
145 ret = (i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ? in dib7000p_write_word()
146 -EREMOTEIO : 0); in dib7000p_write_word()
147 mutex_unlock(&state->i2c_buffer_lock); in dib7000p_write_word()
162 } while (--l); in dib7000p_write_tab()
176 dprintk("setting output mode for demod %p to %d\n", &state->demod, mode); in dib7000p_set_output_mode()
189 if (state->cfg.hostbus_diversity) in dib7000p_set_output_mode()
206 dprintk("Unhandled output_mode passed to be set for demod %p\n", &state->demod); in dib7000p_set_output_mode()
210 if (state->cfg.output_mpeg2_in_188_bytes) in dib7000p_set_output_mode()
215 if (state->version != SOC7090) in dib7000p_set_output_mode()
223 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_set_diversity_in()
225 if (state->div_force_off) { in dib7000p_set_diversity_in()
226 dprintk("diversity combination deactivated - forced by COFDM parameters\n"); in dib7000p_set_diversity_in()
230 dib7000p_write_word(state, 207, (state->div_sync_wait << 4) | (1 << 2) | (2 << 0)); in dib7000p_set_diversity_in()
232 state->div_state = (u8) onoff; in dib7000p_set_diversity_in()
253 /* power up everything in the demod */ in dib7000p_set_power_mode()
259 if (state->version == SOC7090) in dib7000p_set_power_mode()
271 if (state->version != SOC7090) in dib7000p_set_power_mode()
276 /* just leave power on the control-interfaces: GPIO and (I2C or SDIO) */ in dib7000p_set_power_mode()
278 if (state->version == SOC7090) in dib7000p_set_power_mode()
284 /* TODO following stuff is just converted from the dib7000-driver - check when is used what */ in dib7000p_set_power_mode()
291 if (state->version != SOC7090) in dib7000p_set_power_mode()
302 if (state->version != SOC7090) { in dib7000p_set_adc_state()
309 if (state->version == SOC7090) { in dib7000p_set_adc_state()
328 if (state->version == SOC7090) { in dib7000p_set_adc_state()
359 reg_909 |= (state->cfg.disable_sample_and_hold & 1) << 4; in dib7000p_set_adc_state()
360 reg_908 |= (state->cfg.enable_current_mirror & 1) << 7; in dib7000p_set_adc_state()
362 if (state->version != SOC7090) { in dib7000p_set_adc_state()
373 state->current_bandwidth = bw; in dib7000p_set_bandwidth()
375 if (state->timf == 0) { in dib7000p_set_bandwidth()
377 timf = state->cfg.bw->timf; in dib7000p_set_bandwidth()
380 timf = state->timf; in dib7000p_set_bandwidth()
396 if (state->version == SOC7090) in dib7000p_sad_calib()
412 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_set_wbd_ref()
415 state->wbd_ref = value; in dib7000p_set_wbd_ref()
422 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_agc_values()
438 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_set_agc1_min()
444 struct dibx000_bandwidth_config *bw = &state->cfg.bw[0]; in dib7000p_reset_pll()
447 if (state->version == SOC7090) { in dib7000p_reset_pll()
448 …dib7000p_write_word(state, 1856, (!bw->pll_reset << 13) | (bw->pll_range << 12) | (bw->pll_ratio <… in dib7000p_reset_pll()
453 dib7000p_write_word(state, 1857, dib7000p_read_word(state, 1857) | (!bw->pll_bypass << 15)); in dib7000p_reset_pll()
455 /* force PLL bypass */ in dib7000p_reset_pll()
456 clk_cfg0 = (1 << 15) | ((bw->pll_ratio & 0x3f) << 9) | in dib7000p_reset_pll()
457 …(bw->modulo << 7) | (bw->ADClkSrc << 6) | (bw->IO_CLK_en_core << 5) | (bw->bypclk_div << 2) | (bw- in dib7000p_reset_pll()
462 …ib7000p_write_word(state, 903, (bw->pll_prediv << 5) | (((bw->pll_ratio >> 6) & 0x3) << 3) | (bw->… in dib7000p_reset_pll()
463 clk_cfg0 = (bw->pll_bypass << 15) | (clk_cfg0 & 0x7fff); in dib7000p_reset_pll()
467 dib7000p_write_word(state, 18, (u16) (((bw->internal * 1000) >> 16) & 0xffff)); in dib7000p_reset_pll()
468 dib7000p_write_word(state, 19, (u16) ((bw->internal * 1000) & 0xffff)); in dib7000p_reset_pll()
469 dib7000p_write_word(state, 21, (u16) ((bw->ifreq >> 16) & 0xffff)); in dib7000p_reset_pll()
470 dib7000p_write_word(state, 22, (u16) ((bw->ifreq) & 0xffff)); in dib7000p_reset_pll()
472 dib7000p_write_word(state, 72, bw->sad_cfg); in dib7000p_reset_pll()
486 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_update_pll()
495 if (loopdiv && bw && (bw->pll_prediv != prediv || bw->pll_ratio != loopdiv)) { in dib7000p_update_pll()
496 …ld = %d new = %d ; loopdiv : old = %d new = %d)\n", prediv, bw->pll_prediv, loopdiv, bw->pll_rati… in dib7000p_update_pll()
501 …dib7000p_write_word(state, 1856, reg_1856 | ((bw->pll_ratio & 0x3f) << 6) | (bw->pll_prediv & 0x3f… in dib7000p_update_pll()
506 internal = 1000 * (xtal / bw->pll_prediv) * bw->pll_ratio; /* new internal */ in dib7000p_update_pll()
517 return -EIO; in dib7000p_update_pll()
523 dprintk("gpio dir: %x: val: %x, pwm_pos: %x\n", st->gpio_dir, st->gpio_val, st->cfg.gpio_pwm_pos); in dib7000p_reset_gpio()
525 dib7000p_write_word(st, 1029, st->gpio_dir); in dib7000p_reset_gpio()
526 dib7000p_write_word(st, 1030, st->gpio_val); in dib7000p_reset_gpio()
530 dib7000p_write_word(st, 1032, st->cfg.gpio_pwm_pos); in dib7000p_reset_gpio()
532 dib7000p_write_word(st, 1037, st->cfg.pwm_freq_div); in dib7000p_reset_gpio()
538 st->gpio_dir = dib7000p_read_word(st, 1029); in dib7000p_cfg_gpio()
539 st->gpio_dir &= ~(1 << num); /* reset the direction bit */ in dib7000p_cfg_gpio()
540 st->gpio_dir |= (dir & 0x1) << num; /* set the new direction */ in dib7000p_cfg_gpio()
541 dib7000p_write_word(st, 1029, st->gpio_dir); in dib7000p_cfg_gpio()
543 st->gpio_val = dib7000p_read_word(st, 1030); in dib7000p_cfg_gpio()
544 st->gpio_val &= ~(1 << num); /* reset the direction bit */ in dib7000p_cfg_gpio()
545 st->gpio_val |= (val & 0x01) << num; /* set the new value */ in dib7000p_cfg_gpio()
546 dib7000p_write_word(st, 1030, st->gpio_val); in dib7000p_cfg_gpio()
553 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_set_gpio()
581 /* set ADC level to -16 */
583 (1 << 13) - 825 - 117,
584 (1 << 13) - 837 - 117,
585 (1 << 13) - 811 - 117,
586 (1 << 13) - 766 - 117,
587 (1 << 13) - 737 - 117,
588 (1 << 13) - 693 - 117,
589 (1 << 13) - 648 - 117,
590 (1 << 13) - 619 - 117,
591 (1 << 13) - 575 - 117,
592 (1 << 13) - 531 - 117,
593 (1 << 13) - 501 - 117,
646 if (state->version == SOC7090) in dib7000p_demod_reset()
647 dibx000_reset_i2c_master(&state->i2c_master); in dib7000p_demod_reset()
655 dib7000p_write_word(state, 1280, 0x001f - ((1 << 4) | (1 << 3))); in dib7000p_demod_reset()
662 if (state->version != SOC7090) { in dib7000p_demod_reset()
673 if (state->version == SOC7090) { in dib7000p_demod_reset()
678 dib7000p_write_word(state, 43, 0x2d4); /*-300 fag P_iqc_dect_min = -280 */ in dib7000p_demod_reset()
694 if (state->version == SOC7090) { in dib7000p_demod_reset()
697 if (state->cfg.tuner_is_baseband) in dib7000p_demod_reset()
704 if (state->version != SOC7090) { in dib7000p_demod_reset()
735 if (state->cfg.update_lna) { in dib7000p_update_lna()
737 if (state->cfg.update_lna(&state->demod, dyn_gain)) { in dib7000p_update_lna()
750 if (state->current_band == band && state->current_agc != NULL) in dib7000p_set_agc_config()
752 state->current_band = band; in dib7000p_set_agc_config()
754 for (i = 0; i < state->cfg.agc_config_count; i++) in dib7000p_set_agc_config()
755 if (state->cfg.agc[i].band_caps & band) { in dib7000p_set_agc_config()
756 agc = &state->cfg.agc[i]; in dib7000p_set_agc_config()
762 return -EINVAL; in dib7000p_set_agc_config()
765 state->current_agc = agc; in dib7000p_set_agc_config()
768 dib7000p_write_word(state, 75, agc->setup); in dib7000p_set_agc_config()
769 dib7000p_write_word(state, 76, agc->inv_gain); in dib7000p_set_agc_config()
770 dib7000p_write_word(state, 77, agc->time_stabiliz); in dib7000p_set_agc_config()
771 dib7000p_write_word(state, 100, (agc->alpha_level << 12) | agc->thlock); in dib7000p_set_agc_config()
774 dib7000p_write_word(state, 101, (agc->alpha_mant << 5) | agc->alpha_exp); in dib7000p_set_agc_config()
775 dib7000p_write_word(state, 102, (agc->beta_mant << 6) | agc->beta_exp); in dib7000p_set_agc_config()
779 …state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, ag… in dib7000p_set_agc_config()
781 if (state->wbd_ref != 0) in dib7000p_set_agc_config()
782 dib7000p_write_word(state, 105, (agc->wbd_inv << 12) | state->wbd_ref); in dib7000p_set_agc_config()
784 dib7000p_write_word(state, 105, (agc->wbd_inv << 12) | agc->wbd_ref); in dib7000p_set_agc_config()
786 …dib7000p_write_word(state, 106, (agc->wbd_sel << 13) | (agc->wbd_alpha << 9) | (agc->perform_agc_s… in dib7000p_set_agc_config()
788 dib7000p_write_word(state, 107, agc->agc1_max); in dib7000p_set_agc_config()
789 dib7000p_write_word(state, 108, agc->agc1_min); in dib7000p_set_agc_config()
790 dib7000p_write_word(state, 109, agc->agc2_max); in dib7000p_set_agc_config()
791 dib7000p_write_word(state, 110, agc->agc2_min); in dib7000p_set_agc_config()
792 dib7000p_write_word(state, 111, (agc->agc1_pt1 << 8) | agc->agc1_pt2); in dib7000p_set_agc_config()
793 dib7000p_write_word(state, 112, agc->agc1_pt3); in dib7000p_set_agc_config()
794 dib7000p_write_word(state, 113, (agc->agc1_slope1 << 8) | agc->agc1_slope2); in dib7000p_set_agc_config()
795 dib7000p_write_word(state, 114, (agc->agc2_pt1 << 8) | agc->agc2_pt2); in dib7000p_set_agc_config()
796 dib7000p_write_word(state, 115, (agc->agc2_slope1 << 8) | agc->agc2_slope2); in dib7000p_set_agc_config()
805 u32 dds = state->cfg.bw->ifreq & 0x1ffffff; in dib7000p_set_dds()
806 u8 invert = !!(state->cfg.bw->ifreq & (1 << 25)); in dib7000p_set_dds()
809 return -1; in dib7000p_set_dds()
817 unit_khz_dds_val *= -1; in dib7000p_set_dds()
821 …dds -= (abs_offset_khz * unit_khz_dds_val); /* /100 because of /100 on the unit_khz_dds_val line c… in dib7000p_set_dds()
834 struct dtv_frontend_properties *ch = &demod->dtv_property_cache; in dib7000p_agc_startup()
835 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_agc_startup()
836 int ret = -1; in dib7000p_agc_startup()
837 u8 *agc_state = &state->agc_state; in dib7000p_agc_startup()
843 switch (state->agc_state) { in dib7000p_agc_startup()
846 if (state->version == SOC7090) { in dib7000p_agc_startup()
859 if (dib7000p_set_agc_config(state, BAND_OF_FREQUENCY(ch->frequency / 1000)) != 0) in dib7000p_agc_startup()
860 return -1; in dib7000p_agc_startup()
862 if (demod->ops.tuner_ops.get_frequency) { in dib7000p_agc_startup()
865 demod->ops.tuner_ops.get_frequency(demod, &frequency_tuner); in dib7000p_agc_startup()
866 frequency_offset = (s32)frequency_tuner / 1000 - ch->frequency / 1000; in dib7000p_agc_startup()
870 return -1; in dib7000p_agc_startup()
877 if (state->cfg.agc_control) in dib7000p_agc_startup()
878 state->cfg.agc_control(&state->demod, 1); in dib7000p_agc_startup()
881 if (!state->current_agc->perform_agc_softsplit) { in dib7000p_agc_startup()
882 /* we are using the wbd - so slow AGC startup */ in dib7000p_agc_startup()
884 …dib7000p_write_word(state, 106, (state->current_agc->wbd_sel << 13) | (state->current_agc->wbd_alp… in dib7000p_agc_startup()
898 dib7000p_write_word(state, 75, state->current_agc->setup | (1 << 4)); /* freeze AGC loop */ in dib7000p_agc_startup()
899 …dib7000p_write_word(state, 106, (state->current_agc->wbd_sel << 13) | (2 << 9) | (0 << 8)); /* fas… in dib7000p_agc_startup()
908 dib7000p_write_word(state, 75, state->current_agc->setup); /* std AGC loop */ in dib7000p_agc_startup()
909 …dib7000p_write_word(state, 106, (state->current_agc->wbd_sel << 13) | (state->current_agc->wbd_alp… in dib7000p_agc_startup()
929 if (state->cfg.agc_control) in dib7000p_agc_startup()
930 state->cfg.agc_control(&state->demod, 0); in dib7000p_agc_startup()
942 state->timf = timf * 160 / (state->current_bandwidth / 50); in dib7000p_update_timf()
945 dprintk("updated timf_frequency: %d (default: %d)\n", state->timf, state->cfg.bw->timf); in dib7000p_update_timf()
951 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_ctrl_timf()
954 state->timf = timf; in dib7000p_ctrl_timf()
962 dib7000p_set_bandwidth(state, state->current_bandwidth); in dib7000p_ctrl_timf()
963 return state->timf; in dib7000p_ctrl_timf()
971 dib7000p_set_bandwidth(state, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000p_set_channel()
975 switch (ch->transmission_mode) { in dib7000p_set_channel()
987 switch (ch->guard_interval) { in dib7000p_set_channel()
1002 switch (ch->modulation) { in dib7000p_set_channel()
1033 if (ch->hierarchy == 1) in dib7000p_set_channel()
1037 switch ((ch->hierarchy == 0 || 1 == 1) ? ch->code_rate_HP : ch->code_rate_LP) { in dib7000p_set_channel()
1064 switch (ch->transmission_mode) { in dib7000p_set_channel()
1076 switch (ch->guard_interval) { in dib7000p_set_channel()
1091 if (state->cfg.diversity_delay == 0) in dib7000p_set_channel()
1092 state->div_sync_wait = (value * 3) / 2 + 48; in dib7000p_set_channel()
1094 state->div_sync_wait = (value * 3) / 2 + state->cfg.diversity_delay; in dib7000p_set_channel()
1097 state->div_force_off = !1 && ch->transmission_mode != TRANSMISSION_MODE_8K; in dib7000p_set_channel()
1098 dib7000p_set_diversity_in(&state->demod, state->div_state); in dib7000p_set_channel()
1101 switch (ch->modulation) { in dib7000p_set_channel()
1104 est[1] = 0xfff0; /* P_adp_noise_cnt -0.002 */ in dib7000p_set_channel()
1106 est[3] = 0xfff8; /* P_adp_noise_ext -0.001 */ in dib7000p_set_channel()
1110 est[1] = 0xffdf; /* P_adp_noise_cnt -0.004 */ in dib7000p_set_channel()
1112 est[3] = 0xfff0; /* P_adp_noise_ext -0.002 */ in dib7000p_set_channel()
1116 est[1] = 0xffae; /* P_adp_noise_cnt -0.01 */ in dib7000p_set_channel()
1118 est[3] = 0xfff8; /* P_adp_noise_ext -0.002 */ in dib7000p_set_channel()
1127 struct dtv_frontend_properties *ch = &demod->dtv_property_cache; in dib7000p_autosearch_start()
1128 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_autosearch_start()
1143 factor = BANDWIDTH_TO_KHZ(ch->bandwidth_hz); in dib7000p_autosearch_start()
1145 if (state->version == SOC7090) in dib7000p_autosearch_start()
1172 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_autosearch_is_irq()
1186 static const s16 notch[] = { 16143, 14402, 12238, 9713, 6902, 3888, 759, -2392 }; in dib7000p_spur_protect()
1206 u32 xtal = state->cfg.bw->xtal_hz / 1000; in dib7000p_spur_protect()
1207 int f_rel = DIV_ROUND_CLOSEST(rf_khz, xtal) * xtal - rf_khz; in dib7000p_spur_protect()
1215 if (f_rel < -bw_khz / 2 || f_rel > bw_khz / 2) in dib7000p_spur_protect()
1229 coef_re[k] = sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1235 coef_re[k] = -sine[pha & 0xff]; in dib7000p_spur_protect()
1236 coef_im[k] = sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1238 coef_re[k] = -256; in dib7000p_spur_protect()
1241 coef_re[k] = -sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1242 coef_im[k] = -sine[pha & 0xff]; in dib7000p_spur_protect()
1245 coef_im[k] = -256; in dib7000p_spur_protect()
1248 coef_im[k] = -sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1254 coef_re[k] = (1 << 24) - 1; in dib7000p_spur_protect()
1260 coef_im[k] = (1 << 24) - 1; in dib7000p_spur_protect()
1274 struct dtv_frontend_properties *ch = &demod->dtv_property_cache; in dib7000p_tune()
1275 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_tune()
1281 return -EINVAL; in dib7000p_tune()
1290 if (state->sfn_workaround_active) { in dib7000p_tune()
1299 // never achieved a lock with that bandwidth so far - wait for osc-freq to update in dib7000p_tune()
1300 if (state->timf == 0) in dib7000p_tune()
1307 switch (ch->transmission_mode) { in dib7000p_tune()
1323 switch (ch->transmission_mode) { in dib7000p_tune()
1339 switch (ch->transmission_mode) { in dib7000p_tune()
1362 // we achieved a lock - it's time to update the osc freq in dib7000p_tune()
1370 if (state->cfg.spur_protect) in dib7000p_tune()
1371 dib7000p_spur_protect(state, ch->frequency / 1000, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000p_tune()
1373 dib7000p_set_bandwidth(state, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000p_tune()
1382 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_wakeup()
1385 if (state->version == SOC7090) in dib7000p_wakeup()
1392 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_sleep()
1393 if (state->version == SOC7090) in dib7000p_sleep()
1401 dprintk("checking demod on I2C address: %d (%x)\n", st->i2c_addr, st->i2c_addr); in dib7000p_identify()
1405 return -EREMOTEIO; in dib7000p_identify()
1410 return -EREMOTEIO; in dib7000p_identify()
1419 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_frontend()
1422 fep->inversion = INVERSION_AUTO; in dib7000p_get_frontend()
1424 fep->bandwidth_hz = BANDWIDTH_TO_HZ(state->current_bandwidth); in dib7000p_get_frontend()
1428 fep->transmission_mode = TRANSMISSION_MODE_2K; in dib7000p_get_frontend()
1431 fep->transmission_mode = TRANSMISSION_MODE_8K; in dib7000p_get_frontend()
1433 /* case 2: fep->transmission_mode = TRANSMISSION_MODE_4K; break; */ in dib7000p_get_frontend()
1438 fep->guard_interval = GUARD_INTERVAL_1_32; in dib7000p_get_frontend()
1441 fep->guard_interval = GUARD_INTERVAL_1_16; in dib7000p_get_frontend()
1444 fep->guard_interval = GUARD_INTERVAL_1_8; in dib7000p_get_frontend()
1447 fep->guard_interval = GUARD_INTERVAL_1_4; in dib7000p_get_frontend()
1453 fep->modulation = QPSK; in dib7000p_get_frontend()
1456 fep->modulation = QAM_16; in dib7000p_get_frontend()
1460 fep->modulation = QAM_64; in dib7000p_get_frontend()
1467 fep->hierarchy = HIERARCHY_NONE; in dib7000p_get_frontend()
1470 fep->code_rate_HP = FEC_1_2; in dib7000p_get_frontend()
1473 fep->code_rate_HP = FEC_2_3; in dib7000p_get_frontend()
1476 fep->code_rate_HP = FEC_3_4; in dib7000p_get_frontend()
1479 fep->code_rate_HP = FEC_5_6; in dib7000p_get_frontend()
1483 fep->code_rate_HP = FEC_7_8; in dib7000p_get_frontend()
1490 fep->code_rate_LP = FEC_1_2; in dib7000p_get_frontend()
1493 fep->code_rate_LP = FEC_2_3; in dib7000p_get_frontend()
1496 fep->code_rate_LP = FEC_3_4; in dib7000p_get_frontend()
1499 fep->code_rate_LP = FEC_5_6; in dib7000p_get_frontend()
1503 fep->code_rate_LP = FEC_7_8; in dib7000p_get_frontend()
1514 struct dtv_frontend_properties *fep = &fe->dtv_property_cache; in dib7000p_set_frontend()
1515 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_set_frontend()
1518 if (state->version == SOC7090) in dib7000p_set_frontend()
1524 state->sfn_workaround_active = buggy_sfn_workaround; in dib7000p_set_frontend()
1526 if (fe->ops.tuner_ops.set_params) in dib7000p_set_frontend()
1527 fe->ops.tuner_ops.set_params(fe); in dib7000p_set_frontend()
1530 state->agc_state = 0; in dib7000p_set_frontend()
1533 if (time != -1) in dib7000p_set_frontend()
1535 } while (time != -1); in dib7000p_set_frontend()
1537 if (fep->transmission_mode == TRANSMISSION_MODE_AUTO || in dib7000p_set_frontend()
1538 …fep->guard_interval == GUARD_INTERVAL_AUTO || fep->modulation == QAM_AUTO || fep->code_rate_HP == … in dib7000p_set_frontend()
1545 } while (found == 0 && i--); in dib7000p_set_frontend()
1557 if (state->version == SOC7090) { in dib7000p_set_frontend()
1558 dib7090_set_output_mode(fe, state->cfg.output_mode); in dib7000p_set_frontend()
1559 if (state->cfg.enMpegOutput == 0) { in dib7000p_set_frontend()
1564 dib7000p_set_output_mode(state, state->cfg.output_mode); in dib7000p_set_frontend()
1573 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_status()
1596 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_ber()
1603 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_unc_blocks()
1610 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_signal_strength()
1612 *strength = 65535 - val; in dib7000p_read_signal_strength()
1618 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_snr()
1629 noise_exp -= 0x40; in dib7000p_get_snr()
1634 signal_exp -= 0x40; in dib7000p_get_snr()
1639 result = intlog10(2) * 10 * signal_exp - 100; in dib7000p_get_snr()
1642 result -= intlog10(2) * 10 * noise_exp + 10 * intlog10(noise_mant); in dib7000p_get_snr()
1644 result -= intlog10(2) * 10 * noise_exp - 100; in dib7000p_get_snr()
1661 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_reset_stats()
1662 struct dtv_frontend_properties *c = &demod->dtv_property_cache; in dib7000p_reset_stats()
1665 memset(&c->strength, 0, sizeof(c->strength)); in dib7000p_reset_stats()
1666 memset(&c->cnr, 0, sizeof(c->cnr)); in dib7000p_reset_stats()
1667 memset(&c->post_bit_error, 0, sizeof(c->post_bit_error)); in dib7000p_reset_stats()
1668 memset(&c->post_bit_count, 0, sizeof(c->post_bit_count)); in dib7000p_reset_stats()
1669 memset(&c->block_error, 0, sizeof(c->block_error)); in dib7000p_reset_stats()
1671 c->strength.len = 1; in dib7000p_reset_stats()
1672 c->cnr.len = 1; in dib7000p_reset_stats()
1673 c->block_error.len = 1; in dib7000p_reset_stats()
1674 c->block_count.len = 1; in dib7000p_reset_stats()
1675 c->post_bit_error.len = 1; in dib7000p_reset_stats()
1676 c->post_bit_count.len = 1; in dib7000p_reset_stats()
1678 c->strength.stat[0].scale = FE_SCALE_DECIBEL; in dib7000p_reset_stats()
1679 c->strength.stat[0].uvalue = 0; in dib7000p_reset_stats()
1681 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1682 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1683 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1684 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1685 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1689 state->old_ucb = ucb; in dib7000p_reset_stats()
1690 state->ber_jiffies_stats = 0; in dib7000p_reset_stats()
1691 state->per_jiffies_stats = 0; in dib7000p_reset_stats()
1700 * Table to estimate signal strength in dBm.
1705 * by a DTA-2111 RF generator directly connected into a dib7000p device
1706 * (a Hauppauge Nova-TD stick), using a good quality 3 meters length
1708 * As the minimum output power of DTA-2111 is -31dBm, a 16 dBm attenuator
1713 * Yet, it is better to use this measure in dB than a random non-linear
1721 { 63630, DB_OFFSET - 20500},
1722 { 62273, DB_OFFSET - 21000},
1723 { 60162, DB_OFFSET - 22000},
1724 { 58730, DB_OFFSET - 23000},
1725 { 58294, DB_OFFSET - 24000},
1726 { 57778, DB_OFFSET - 25000},
1727 { 57320, DB_OFFSET - 26000},
1728 { 56779, DB_OFFSET - 27000},
1729 { 56293, DB_OFFSET - 28000},
1730 { 55724, DB_OFFSET - 29000},
1731 { 55145, DB_OFFSET - 30000},
1732 { 54680, DB_OFFSET - 31000},
1733 { 54293, DB_OFFSET - 32000},
1734 { 53813, DB_OFFSET - 33000},
1735 { 53427, DB_OFFSET - 34000},
1736 { 52981, DB_OFFSET - 35000},
1738 { 52636, DB_OFFSET - 36000},
1739 { 52014, DB_OFFSET - 37000},
1740 { 51674, DB_OFFSET - 38000},
1741 { 50692, DB_OFFSET - 39000},
1742 { 49824, DB_OFFSET - 40000},
1743 { 49052, DB_OFFSET - 41000},
1744 { 48436, DB_OFFSET - 42000},
1745 { 47836, DB_OFFSET - 43000},
1746 { 47368, DB_OFFSET - 44000},
1747 { 46468, DB_OFFSET - 45000},
1748 { 45597, DB_OFFSET - 46000},
1749 { 44586, DB_OFFSET - 47000},
1750 { 43667, DB_OFFSET - 48000},
1751 { 42673, DB_OFFSET - 49000},
1752 { 41816, DB_OFFSET - 50000},
1753 { 40876, DB_OFFSET - 51000},
1767 if (value < segments[len-1].x) in interpolate_value()
1768 return segments[len-1].y; in interpolate_value()
1770 for (i = 1; i < len - 1; i++) { in interpolate_value()
1779 dy = segments[i - 1].y - segments[i].y; in interpolate_value()
1780 dx = segments[i - 1].x - segments[i].x; in interpolate_value()
1782 tmp64 = value - segments[i].x; in interpolate_value()
1790 /* FIXME: may require changes - this one was borrowed from dib8000 */
1793 struct dtv_frontend_properties *c = &demod->dtv_property_cache; in dib7000p_get_time_us()
1799 switch (c->guard_interval) { in dib7000p_get_time_us()
1815 switch (c->transmission_mode) { in dib7000p_get_time_us()
1828 switch (c->modulation) { in dib7000p_get_time_us()
1842 switch ((c->hierarchy == 0 || 1 == 1) ? c->code_rate_HP : c->code_rate_LP) { in dib7000p_get_time_us()
1893 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_get_stats()
1894 struct dtv_frontend_properties *c = &demod->dtv_property_cache; in dib7000p_get_stats()
1906 ARRAY_SIZE(strength_to_db_table)) - DB_OFFSET; in dib7000p_get_stats()
1907 c->strength.stat[0].svalue = db; in dib7000p_get_stats()
1911 c->cnr.len = 1; in dib7000p_get_stats()
1912 c->block_count.len = 1; in dib7000p_get_stats()
1913 c->block_error.len = 1; in dib7000p_get_stats()
1914 c->post_bit_error.len = 1; in dib7000p_get_stats()
1915 c->post_bit_count.len = 1; in dib7000p_get_stats()
1916 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1917 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1918 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1919 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1920 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1925 if (time_after(jiffies, state->per_jiffies_stats)) { in dib7000p_get_stats()
1926 state->per_jiffies_stats = jiffies + msecs_to_jiffies(1000); in dib7000p_get_stats()
1934 c->cnr.stat[0].svalue = snr; in dib7000p_get_stats()
1935 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; in dib7000p_get_stats()
1939 ucb = val - state->old_ucb; in dib7000p_get_stats()
1940 if (val < state->old_ucb) in dib7000p_get_stats()
1943 c->block_error.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1944 c->block_error.stat[0].uvalue = ucb; in dib7000p_get_stats()
1953 c->block_count.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1954 c->block_count.stat[0].uvalue += blocks; in dib7000p_get_stats()
1960 /* Get post-BER measures */ in dib7000p_get_stats()
1961 if (time_after(jiffies, state->ber_jiffies_stats)) { in dib7000p_get_stats()
1963 state->ber_jiffies_stats = jiffies + msecs_to_jiffies((time_us + 500) / 1000); in dib7000p_get_stats()
1965 dprintk("Next all layers stats available in %u us.\n", time_us); in dib7000p_get_stats()
1968 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1969 c->post_bit_error.stat[0].uvalue += val; in dib7000p_get_stats()
1971 c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1972 c->post_bit_count.stat[0].uvalue += 100000000; in dib7000p_get_stats()
1979 c->block_error.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1980 c->block_error.stat[0].uvalue += val; in dib7000p_get_stats()
1986 c->block_count.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1987 c->block_count.stat[0].uvalue += blocks; in dib7000p_get_stats()
1995 tune->min_delay_ms = 1000; in dib7000p_fe_get_tune_settings()
2001 struct dib7000p_state *st = demod->demodulator_priv; in dib7000p_release()
2002 dibx000_exit_i2c_master(&st->i2c_master); in dib7000p_release()
2003 i2c_del_adapter(&st->dib7090_tuner_adap); in dib7000p_release()
2018 return -ENOMEM; in dib7000pc_detection()
2021 ret = -ENOMEM; in dib7000pc_detection()
2033 dprintk("-D- DiB7000PC detected\n"); in dib7000pc_detection()
2042 dprintk("-D- DiB7000PC detected\n"); in dib7000pc_detection()
2047 dprintk("-D- DiB7000PC not detected\n"); in dib7000pc_detection()
2058 struct dib7000p_state *st = demod->demodulator_priv; in dib7000p_get_i2c_master()
2059 return dibx000_get_i2c_adapter(&st->i2c_master, intf, gating); in dib7000p_get_i2c_master()
2064 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_pid_filter_ctrl()
2073 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_pid_filter()
2086 return -ENOMEM; in dib7000p_i2c_enumeration()
2088 dpst->i2c_adap = i2c; in dib7000p_i2c_enumeration()
2089 mutex_init(&dpst->i2c_buffer_lock); in dib7000p_i2c_enumeration()
2091 for (k = no_of_demods - 1; k >= 0; k--) { in dib7000p_i2c_enumeration()
2092 dpst->cfg = cfg[k]; in dib7000p_i2c_enumeration()
2099 dpst->i2c_addr = new_addr; in dib7000p_i2c_enumeration()
2100 dib7000p_write_word(dpst, 1287, 0x0003); /* sram lead in, rdy */ in dib7000p_i2c_enumeration()
2102 dpst->i2c_addr = default_addr; in dib7000p_i2c_enumeration()
2103 dib7000p_write_word(dpst, 1287, 0x0003); /* sram lead in, rdy */ in dib7000p_i2c_enumeration()
2107 return -EIO; in dib7000p_i2c_enumeration()
2111 /* start diversity to pull_down div_str - just for i2c-enumeration */ in dib7000p_i2c_enumeration()
2121 dpst->cfg = cfg[k]; in dib7000p_i2c_enumeration()
2123 dpst->i2c_addr = (cfg[k].default_i2c_addr + k) << 1; in dib7000p_i2c_enumeration()
2125 dpst->i2c_addr = (0x40 + k) << 1; in dib7000p_i2c_enumeration()
2128 dib7000p_write_word(dpst, 1285, dpst->i2c_addr << 2); in dib7000p_i2c_enumeration()
2130 /* deactivate div - it was just for i2c-enumeration */ in dib7000p_i2c_enumeration()
2144 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_adc_power()
2162 ix = (u8) ((mant - 1000) / 100); /* index of the LUT */ in dib7000p_get_adc_power()
2165 pow_i = (lut_1000ln_mant[ix] + 693 * (exp - 20) - 6908); in dib7000p_get_adc_power()
2174 if ((msg->buf[0] <= 15)) in map_addr_to_serpar_number()
2175 msg->buf[0] -= 1; in map_addr_to_serpar_number()
2176 else if (msg->buf[0] == 17) in map_addr_to_serpar_number()
2177 msg->buf[0] = 15; in map_addr_to_serpar_number()
2178 else if (msg->buf[0] == 16) in map_addr_to_serpar_number()
2179 msg->buf[0] = 17; in map_addr_to_serpar_number()
2180 else if (msg->buf[0] == 19) in map_addr_to_serpar_number()
2181 msg->buf[0] = 16; in map_addr_to_serpar_number()
2182 else if (msg->buf[0] >= 21 && msg->buf[0] <= 25) in map_addr_to_serpar_number()
2183 msg->buf[0] -= 3; in map_addr_to_serpar_number()
2184 else if (msg->buf[0] == 28) in map_addr_to_serpar_number()
2185 msg->buf[0] = 23; in map_addr_to_serpar_number()
2187 return -EINVAL; in map_addr_to_serpar_number()
2200 i--; in w7090p_tuner_write_serpar()
2220 i--; in w7090p_tuner_read_serpar()
2229 i--; in w7090p_tuner_read_serpar()
2396 struct dib7000p_state *st = fe->demodulator_priv; in dib7090_get_i2c_tuner()
2397 return &st->dib7090_tuner_adap; in dib7090_get_i2c_tuner()
2439 if ((syncFreq & ((1 << quantif) - 1)) != 0) in dib7090_calcSyncFreq()
2445 syncFreq = syncFreq - 1; in dib7090_calcSyncFreq()
2514 if ((enSerialMode == 1) && (state->input_mode_mpeg == 1)) in dib7090_configMpegMux()
2577 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_set_diversity_in()
2581 case 0: /* only use the internal way - not the diversity input */ in dib7090_set_diversity_in()
2586 /* in SERIAL MODE in case input mode MPEG is used */ in dib7090_set_diversity_in()
2594 state->input_mode_mpeg = 1; in dib7090_set_diversity_in()
2600 state->input_mode_mpeg = 0; in dib7090_set_diversity_in()
2604 dib7000p_set_diversity_in(&state->demod, onoff); in dib7090_set_diversity_in()
2610 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_set_output_mode()
2680 if (state->cfg.output_mpeg2_in_188_bytes) in dib7090_set_output_mode()
2692 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_tuner_sleep()
2700 state->tuner_enable = en_cur_state; in dib7090_tuner_sleep()
2705 if (state->tuner_enable != 0) in dib7090_tuner_sleep()
2706 en_cur_state = state->tuner_enable; in dib7090_tuner_sleep()
2721 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_slave_reset()
2740 memcpy(&st->cfg, cfg, sizeof(struct dib7000p_config)); in dib7000p_init()
2741 st->i2c_adap = i2c_adap; in dib7000p_init()
2742 st->i2c_addr = i2c_addr; in dib7000p_init()
2743 st->gpio_val = cfg->gpio_val; in dib7000p_init()
2744 st->gpio_dir = cfg->gpio_dir; in dib7000p_init()
2749 …if ((st->cfg.output_mode != OUTMODE_MPEG2_SERIAL) && (st->cfg.output_mode != OUTMODE_MPEG2_PAR_GAT… in dib7000p_init()
2750 st->cfg.output_mode = OUTMODE_MPEG2_FIFO; in dib7000p_init()
2752 demod = &st->demod; in dib7000p_init()
2753 demod->demodulator_priv = st; in dib7000p_init()
2754 memcpy(&st->demod.ops, &dib7000p_ops, sizeof(struct dvb_frontend_ops)); in dib7000p_init()
2755 mutex_init(&st->i2c_buffer_lock); in dib7000p_init()
2757 dib7000p_write_word(st, 1287, 0x0003); /* sram lead in, rdy */ in dib7000p_init()
2762 st->version = dib7000p_read_word(st, 897); in dib7000p_init()
2767 st->i2c_master.gated_tuner_i2c_adap.dev.parent = i2c_adap->dev.parent; in dib7000p_init()
2769 dibx000_init_i2c_master(&st->i2c_master, DIB7000P, st->i2c_adap, st->i2c_addr); in dib7000p_init()
2772 strscpy(st->dib7090_tuner_adap.name, "DiB7090 tuner interface", in dib7000p_init()
2773 sizeof(st->dib7090_tuner_adap.name)); in dib7000p_init()
2774 st->dib7090_tuner_adap.algo = &dib7090_tuner_xfer_algo; in dib7000p_init()
2775 st->dib7090_tuner_adap.algo_data = NULL; in dib7000p_init()
2776 st->dib7090_tuner_adap.dev.parent = st->i2c_adap->dev.parent; in dib7000p_init()
2777 i2c_set_adapdata(&st->dib7090_tuner_adap, st); in dib7000p_init()
2778 i2c_add_adapter(&st->dib7090_tuner_adap); in dib7000p_init()
2784 if (st->version == SOC7090) { in dib7000p_init()
2785 dib7090_set_output_mode(demod, st->cfg.output_mode); in dib7000p_init()
2801 ops->slave_reset = dib7090_slave_reset; in dib7000p_attach()
2802 ops->get_adc_power = dib7090_get_adc_power; in dib7000p_attach()
2803 ops->dib7000pc_detection = dib7000pc_detection; in dib7000p_attach()
2804 ops->get_i2c_tuner = dib7090_get_i2c_tuner; in dib7000p_attach()
2805 ops->tuner_sleep = dib7090_tuner_sleep; in dib7000p_attach()
2806 ops->init = dib7000p_init; in dib7000p_attach()
2807 ops->set_agc1_min = dib7000p_set_agc1_min; in dib7000p_attach()
2808 ops->set_gpio = dib7000p_set_gpio; in dib7000p_attach()
2809 ops->i2c_enumeration = dib7000p_i2c_enumeration; in dib7000p_attach()
2810 ops->pid_filter = dib7000p_pid_filter; in dib7000p_attach()
2811 ops->pid_filter_ctrl = dib7000p_pid_filter_ctrl; in dib7000p_attach()
2812 ops->get_i2c_master = dib7000p_get_i2c_master; in dib7000p_attach()
2813 ops->update_pll = dib7000p_update_pll; in dib7000p_attach()
2814 ops->ctrl_timf = dib7000p_ctrl_timf; in dib7000p_attach()
2815 ops->get_agc_values = dib7000p_get_agc_values; in dib7000p_attach()
2816 ops->set_wbd_ref = dib7000p_set_wbd_ref; in dib7000p_attach()