Lines Matching +full:dout +full:- +full:gpios
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)");
104 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib7000p_read_word()
109 state->i2c_write_buffer[0] = reg >> 8; in dib7000p_read_word()
110 state->i2c_write_buffer[1] = reg & 0xff; in dib7000p_read_word()
112 memset(state->msg, 0, 2 * sizeof(struct i2c_msg)); in dib7000p_read_word()
113 state->msg[0].addr = state->i2c_addr >> 1; in dib7000p_read_word()
114 state->msg[0].flags = 0; in dib7000p_read_word()
115 state->msg[0].buf = state->i2c_write_buffer; in dib7000p_read_word()
116 state->msg[0].len = 2; in dib7000p_read_word()
117 state->msg[1].addr = state->i2c_addr >> 1; in dib7000p_read_word()
118 state->msg[1].flags = I2C_M_RD; in dib7000p_read_word()
119 state->msg[1].buf = state->i2c_read_buffer; in dib7000p_read_word()
120 state->msg[1].len = 2; in dib7000p_read_word()
122 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2) in dib7000p_read_word()
125 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1]; in dib7000p_read_word()
126 mutex_unlock(&state->i2c_buffer_lock); in dib7000p_read_word()
134 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib7000p_write_word()
136 return -EINVAL; in dib7000p_write_word()
139 state->i2c_write_buffer[0] = (reg >> 8) & 0xff; in dib7000p_write_word()
140 state->i2c_write_buffer[1] = reg & 0xff; in dib7000p_write_word()
141 state->i2c_write_buffer[2] = (val >> 8) & 0xff; in dib7000p_write_word()
142 state->i2c_write_buffer[3] = val & 0xff; in dib7000p_write_word()
144 memset(&state->msg[0], 0, sizeof(struct i2c_msg)); in dib7000p_write_word()
145 state->msg[0].addr = state->i2c_addr >> 1; in dib7000p_write_word()
146 state->msg[0].flags = 0; in dib7000p_write_word()
147 state->msg[0].buf = state->i2c_write_buffer; in dib7000p_write_word()
148 state->msg[0].len = 4; in dib7000p_write_word()
150 ret = (i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ? in dib7000p_write_word()
151 -EREMOTEIO : 0); in dib7000p_write_word()
152 mutex_unlock(&state->i2c_buffer_lock); in dib7000p_write_word()
167 } while (--l); in dib7000p_write_tab()
181 dprintk("setting output mode for demod %p to %d\n", &state->demod, mode); in dib7000p_set_output_mode()
194 if (state->cfg.hostbus_diversity) in dib7000p_set_output_mode()
211 dprintk("Unhandled output_mode passed to be set for demod %p\n", &state->demod); in dib7000p_set_output_mode()
215 if (state->cfg.output_mpeg2_in_188_bytes) in dib7000p_set_output_mode()
220 if (state->version != SOC7090) in dib7000p_set_output_mode()
228 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_set_diversity_in()
230 if (state->div_force_off) { in dib7000p_set_diversity_in()
231 dprintk("diversity combination deactivated - forced by COFDM parameters\n"); in dib7000p_set_diversity_in()
235 dib7000p_write_word(state, 207, (state->div_sync_wait << 4) | (1 << 2) | (2 << 0)); in dib7000p_set_diversity_in()
237 state->div_state = (u8) onoff; in dib7000p_set_diversity_in()
264 if (state->version == SOC7090) in dib7000p_set_power_mode()
275 /* Dout */ in dib7000p_set_power_mode()
276 if (state->version != SOC7090) in dib7000p_set_power_mode()
281 /* just leave power on the control-interfaces: GPIO and (I2C or SDIO) */ in dib7000p_set_power_mode()
283 if (state->version == SOC7090) in dib7000p_set_power_mode()
289 /* TODO following stuff is just converted from the dib7000-driver - check when is used what */ in dib7000p_set_power_mode()
296 if (state->version != SOC7090) in dib7000p_set_power_mode()
307 if (state->version != SOC7090) { in dib7000p_set_adc_state()
314 if (state->version == SOC7090) { in dib7000p_set_adc_state()
333 if (state->version == SOC7090) { in dib7000p_set_adc_state()
364 reg_909 |= (state->cfg.disable_sample_and_hold & 1) << 4; in dib7000p_set_adc_state()
365 reg_908 |= (state->cfg.enable_current_mirror & 1) << 7; in dib7000p_set_adc_state()
367 if (state->version != SOC7090) { in dib7000p_set_adc_state()
378 state->current_bandwidth = bw; in dib7000p_set_bandwidth()
380 if (state->timf == 0) { in dib7000p_set_bandwidth()
382 timf = state->cfg.bw->timf; in dib7000p_set_bandwidth()
385 timf = state->timf; in dib7000p_set_bandwidth()
401 if (state->version == SOC7090) in dib7000p_sad_calib()
417 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_set_wbd_ref()
420 state->wbd_ref = value; in dib7000p_set_wbd_ref()
427 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_agc_values()
443 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_set_agc1_min()
449 struct dibx000_bandwidth_config *bw = &state->cfg.bw[0]; in dib7000p_reset_pll()
452 if (state->version == SOC7090) { in dib7000p_reset_pll()
453 …dib7000p_write_word(state, 1856, (!bw->pll_reset << 13) | (bw->pll_range << 12) | (bw->pll_ratio <… in dib7000p_reset_pll()
458 dib7000p_write_word(state, 1857, dib7000p_read_word(state, 1857) | (!bw->pll_bypass << 15)); in dib7000p_reset_pll()
461 clk_cfg0 = (1 << 15) | ((bw->pll_ratio & 0x3f) << 9) | in dib7000p_reset_pll()
462 …(bw->modulo << 7) | (bw->ADClkSrc << 6) | (bw->IO_CLK_en_core << 5) | (bw->bypclk_div << 2) | (bw-… in dib7000p_reset_pll()
467 …ib7000p_write_word(state, 903, (bw->pll_prediv << 5) | (((bw->pll_ratio >> 6) & 0x3) << 3) | (bw->… in dib7000p_reset_pll()
468 clk_cfg0 = (bw->pll_bypass << 15) | (clk_cfg0 & 0x7fff); in dib7000p_reset_pll()
472 dib7000p_write_word(state, 18, (u16) (((bw->internal * 1000) >> 16) & 0xffff)); in dib7000p_reset_pll()
473 dib7000p_write_word(state, 19, (u16) ((bw->internal * 1000) & 0xffff)); in dib7000p_reset_pll()
474 dib7000p_write_word(state, 21, (u16) ((bw->ifreq >> 16) & 0xffff)); in dib7000p_reset_pll()
475 dib7000p_write_word(state, 22, (u16) ((bw->ifreq) & 0xffff)); in dib7000p_reset_pll()
477 dib7000p_write_word(state, 72, bw->sad_cfg); in dib7000p_reset_pll()
491 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_update_pll()
500 if (loopdiv && bw && (bw->pll_prediv != prediv || bw->pll_ratio != loopdiv)) { in dib7000p_update_pll()
501 …ld = %d new = %d ; loopdiv : old = %d new = %d)\n", prediv, bw->pll_prediv, loopdiv, bw->pll_rati… in dib7000p_update_pll()
506 …dib7000p_write_word(state, 1856, reg_1856 | ((bw->pll_ratio & 0x3f) << 6) | (bw->pll_prediv & 0x3f… in dib7000p_update_pll()
511 internal = 1000 * (xtal / bw->pll_prediv) * bw->pll_ratio; /* new internal */ in dib7000p_update_pll()
522 return -EIO; in dib7000p_update_pll()
527 /* reset the GPIOs */ in dib7000p_reset_gpio()
528 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()
530 dib7000p_write_word(st, 1029, st->gpio_dir); in dib7000p_reset_gpio()
531 dib7000p_write_word(st, 1030, st->gpio_val); in dib7000p_reset_gpio()
535 dib7000p_write_word(st, 1032, st->cfg.gpio_pwm_pos); in dib7000p_reset_gpio()
537 dib7000p_write_word(st, 1037, st->cfg.pwm_freq_div); in dib7000p_reset_gpio()
543 st->gpio_dir = dib7000p_read_word(st, 1029); in dib7000p_cfg_gpio()
544 st->gpio_dir &= ~(1 << num); /* reset the direction bit */ in dib7000p_cfg_gpio()
545 st->gpio_dir |= (dir & 0x1) << num; /* set the new direction */ in dib7000p_cfg_gpio()
546 dib7000p_write_word(st, 1029, st->gpio_dir); in dib7000p_cfg_gpio()
548 st->gpio_val = dib7000p_read_word(st, 1030); in dib7000p_cfg_gpio()
549 st->gpio_val &= ~(1 << num); /* reset the direction bit */ in dib7000p_cfg_gpio()
550 st->gpio_val |= (val & 0x01) << num; /* set the new value */ in dib7000p_cfg_gpio()
551 dib7000p_write_word(st, 1030, st->gpio_val); in dib7000p_cfg_gpio()
558 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_set_gpio()
586 /* set ADC level to -16 */
588 (1 << 13) - 825 - 117,
589 (1 << 13) - 837 - 117,
590 (1 << 13) - 811 - 117,
591 (1 << 13) - 766 - 117,
592 (1 << 13) - 737 - 117,
593 (1 << 13) - 693 - 117,
594 (1 << 13) - 648 - 117,
595 (1 << 13) - 619 - 117,
596 (1 << 13) - 575 - 117,
597 (1 << 13) - 531 - 117,
598 (1 << 13) - 501 - 117,
651 if (state->version == SOC7090) in dib7000p_demod_reset()
652 dibx000_reset_i2c_master(&state->i2c_master); in dib7000p_demod_reset()
660 dib7000p_write_word(state, 1280, 0x001f - ((1 << 4) | (1 << 3))); in dib7000p_demod_reset()
667 if (state->version != SOC7090) { in dib7000p_demod_reset()
678 if (state->version == SOC7090) { in dib7000p_demod_reset()
683 dib7000p_write_word(state, 43, 0x2d4); /*-300 fag P_iqc_dect_min = -280 */ in dib7000p_demod_reset()
699 if (state->version == SOC7090) { in dib7000p_demod_reset()
702 if (state->cfg.tuner_is_baseband) in dib7000p_demod_reset()
709 if (state->version != SOC7090) { in dib7000p_demod_reset()
740 if (state->cfg.update_lna) { in dib7000p_update_lna()
742 if (state->cfg.update_lna(&state->demod, dyn_gain)) { in dib7000p_update_lna()
755 if (state->current_band == band && state->current_agc != NULL) in dib7000p_set_agc_config()
757 state->current_band = band; in dib7000p_set_agc_config()
759 for (i = 0; i < state->cfg.agc_config_count; i++) in dib7000p_set_agc_config()
760 if (state->cfg.agc[i].band_caps & band) { in dib7000p_set_agc_config()
761 agc = &state->cfg.agc[i]; in dib7000p_set_agc_config()
767 return -EINVAL; in dib7000p_set_agc_config()
770 state->current_agc = agc; in dib7000p_set_agc_config()
773 dib7000p_write_word(state, 75, agc->setup); in dib7000p_set_agc_config()
774 dib7000p_write_word(state, 76, agc->inv_gain); in dib7000p_set_agc_config()
775 dib7000p_write_word(state, 77, agc->time_stabiliz); in dib7000p_set_agc_config()
776 dib7000p_write_word(state, 100, (agc->alpha_level << 12) | agc->thlock); in dib7000p_set_agc_config()
779 dib7000p_write_word(state, 101, (agc->alpha_mant << 5) | agc->alpha_exp); in dib7000p_set_agc_config()
780 dib7000p_write_word(state, 102, (agc->beta_mant << 6) | agc->beta_exp); in dib7000p_set_agc_config()
784 …state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, ag… in dib7000p_set_agc_config()
786 if (state->wbd_ref != 0) in dib7000p_set_agc_config()
787 dib7000p_write_word(state, 105, (agc->wbd_inv << 12) | state->wbd_ref); in dib7000p_set_agc_config()
789 dib7000p_write_word(state, 105, (agc->wbd_inv << 12) | agc->wbd_ref); in dib7000p_set_agc_config()
791 …dib7000p_write_word(state, 106, (agc->wbd_sel << 13) | (agc->wbd_alpha << 9) | (agc->perform_agc_s… in dib7000p_set_agc_config()
793 dib7000p_write_word(state, 107, agc->agc1_max); in dib7000p_set_agc_config()
794 dib7000p_write_word(state, 108, agc->agc1_min); in dib7000p_set_agc_config()
795 dib7000p_write_word(state, 109, agc->agc2_max); in dib7000p_set_agc_config()
796 dib7000p_write_word(state, 110, agc->agc2_min); in dib7000p_set_agc_config()
797 dib7000p_write_word(state, 111, (agc->agc1_pt1 << 8) | agc->agc1_pt2); in dib7000p_set_agc_config()
798 dib7000p_write_word(state, 112, agc->agc1_pt3); in dib7000p_set_agc_config()
799 dib7000p_write_word(state, 113, (agc->agc1_slope1 << 8) | agc->agc1_slope2); in dib7000p_set_agc_config()
800 dib7000p_write_word(state, 114, (agc->agc2_pt1 << 8) | agc->agc2_pt2); in dib7000p_set_agc_config()
801 dib7000p_write_word(state, 115, (agc->agc2_slope1 << 8) | agc->agc2_slope2); in dib7000p_set_agc_config()
810 u32 dds = state->cfg.bw->ifreq & 0x1ffffff; in dib7000p_set_dds()
811 u8 invert = !!(state->cfg.bw->ifreq & (1 << 25)); in dib7000p_set_dds()
814 return -1; in dib7000p_set_dds()
822 unit_khz_dds_val *= -1; in dib7000p_set_dds()
826 …dds -= (abs_offset_khz * unit_khz_dds_val); /* /100 because of /100 on the unit_khz_dds_val line c… in dib7000p_set_dds()
839 struct dtv_frontend_properties *ch = &demod->dtv_property_cache; in dib7000p_agc_startup()
840 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_agc_startup()
841 int ret = -1; in dib7000p_agc_startup()
842 u8 *agc_state = &state->agc_state; in dib7000p_agc_startup()
848 switch (state->agc_state) { in dib7000p_agc_startup()
851 if (state->version == SOC7090) { in dib7000p_agc_startup()
864 if (dib7000p_set_agc_config(state, BAND_OF_FREQUENCY(ch->frequency / 1000)) != 0) in dib7000p_agc_startup()
865 return -1; in dib7000p_agc_startup()
867 if (demod->ops.tuner_ops.get_frequency) { in dib7000p_agc_startup()
870 demod->ops.tuner_ops.get_frequency(demod, &frequency_tuner); in dib7000p_agc_startup()
871 frequency_offset = (s32)frequency_tuner / 1000 - ch->frequency / 1000; in dib7000p_agc_startup()
875 return -1; in dib7000p_agc_startup()
882 if (state->cfg.agc_control) in dib7000p_agc_startup()
883 state->cfg.agc_control(&state->demod, 1); in dib7000p_agc_startup()
886 if (!state->current_agc->perform_agc_softsplit) { in dib7000p_agc_startup()
887 /* we are using the wbd - so slow AGC startup */ in dib7000p_agc_startup()
889 …dib7000p_write_word(state, 106, (state->current_agc->wbd_sel << 13) | (state->current_agc->wbd_alp… in dib7000p_agc_startup()
903 dib7000p_write_word(state, 75, state->current_agc->setup | (1 << 4)); /* freeze AGC loop */ in dib7000p_agc_startup()
904 …dib7000p_write_word(state, 106, (state->current_agc->wbd_sel << 13) | (2 << 9) | (0 << 8)); /* fas… in dib7000p_agc_startup()
913 dib7000p_write_word(state, 75, state->current_agc->setup); /* std AGC loop */ in dib7000p_agc_startup()
914 …dib7000p_write_word(state, 106, (state->current_agc->wbd_sel << 13) | (state->current_agc->wbd_alp… in dib7000p_agc_startup()
934 if (state->cfg.agc_control) in dib7000p_agc_startup()
935 state->cfg.agc_control(&state->demod, 0); in dib7000p_agc_startup()
947 state->timf = timf * 160 / (state->current_bandwidth / 50); in dib7000p_update_timf()
950 dprintk("updated timf_frequency: %d (default: %d)\n", state->timf, state->cfg.bw->timf); in dib7000p_update_timf()
956 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_ctrl_timf()
959 state->timf = timf; in dib7000p_ctrl_timf()
967 dib7000p_set_bandwidth(state, state->current_bandwidth); in dib7000p_ctrl_timf()
968 return state->timf; in dib7000p_ctrl_timf()
976 dib7000p_set_bandwidth(state, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000p_set_channel()
980 switch (ch->transmission_mode) { in dib7000p_set_channel()
992 switch (ch->guard_interval) { in dib7000p_set_channel()
1007 switch (ch->modulation) { in dib7000p_set_channel()
1038 if (ch->hierarchy == 1) in dib7000p_set_channel()
1042 switch ((ch->hierarchy == 0 || 1 == 1) ? ch->code_rate_HP : ch->code_rate_LP) { in dib7000p_set_channel()
1069 switch (ch->transmission_mode) { in dib7000p_set_channel()
1081 switch (ch->guard_interval) { in dib7000p_set_channel()
1096 if (state->cfg.diversity_delay == 0) in dib7000p_set_channel()
1097 state->div_sync_wait = (value * 3) / 2 + 48; in dib7000p_set_channel()
1099 state->div_sync_wait = (value * 3) / 2 + state->cfg.diversity_delay; in dib7000p_set_channel()
1102 state->div_force_off = !1 && ch->transmission_mode != TRANSMISSION_MODE_8K; in dib7000p_set_channel()
1103 dib7000p_set_diversity_in(&state->demod, state->div_state); in dib7000p_set_channel()
1106 switch (ch->modulation) { in dib7000p_set_channel()
1109 est[1] = 0xfff0; /* P_adp_noise_cnt -0.002 */ in dib7000p_set_channel()
1111 est[3] = 0xfff8; /* P_adp_noise_ext -0.001 */ in dib7000p_set_channel()
1115 est[1] = 0xffdf; /* P_adp_noise_cnt -0.004 */ in dib7000p_set_channel()
1117 est[3] = 0xfff0; /* P_adp_noise_ext -0.002 */ in dib7000p_set_channel()
1121 est[1] = 0xffae; /* P_adp_noise_cnt -0.01 */ in dib7000p_set_channel()
1123 est[3] = 0xfff8; /* P_adp_noise_ext -0.002 */ in dib7000p_set_channel()
1132 struct dtv_frontend_properties *ch = &demod->dtv_property_cache; in dib7000p_autosearch_start()
1133 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_autosearch_start()
1148 factor = BANDWIDTH_TO_KHZ(ch->bandwidth_hz); in dib7000p_autosearch_start()
1150 if (state->version == SOC7090) in dib7000p_autosearch_start()
1177 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_autosearch_is_irq()
1191 static const s16 notch[] = { 16143, 14402, 12238, 9713, 6902, 3888, 759, -2392 }; in dib7000p_spur_protect()
1211 u32 xtal = state->cfg.bw->xtal_hz / 1000; in dib7000p_spur_protect()
1212 int f_rel = DIV_ROUND_CLOSEST(rf_khz, xtal) * xtal - rf_khz; in dib7000p_spur_protect()
1220 if (f_rel < -bw_khz / 2 || f_rel > bw_khz / 2) in dib7000p_spur_protect()
1234 coef_re[k] = sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1240 coef_re[k] = -sine[pha & 0xff]; in dib7000p_spur_protect()
1241 coef_im[k] = sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1243 coef_re[k] = -256; in dib7000p_spur_protect()
1246 coef_re[k] = -sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1247 coef_im[k] = -sine[pha & 0xff]; in dib7000p_spur_protect()
1250 coef_im[k] = -256; in dib7000p_spur_protect()
1253 coef_im[k] = -sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1259 coef_re[k] = (1 << 24) - 1; in dib7000p_spur_protect()
1265 coef_im[k] = (1 << 24) - 1; in dib7000p_spur_protect()
1279 struct dtv_frontend_properties *ch = &demod->dtv_property_cache; in dib7000p_tune()
1280 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_tune()
1286 return -EINVAL; in dib7000p_tune()
1295 if (state->sfn_workaround_active) { in dib7000p_tune()
1304 // never achieved a lock with that bandwidth so far - wait for osc-freq to update in dib7000p_tune()
1305 if (state->timf == 0) in dib7000p_tune()
1312 switch (ch->transmission_mode) { in dib7000p_tune()
1328 switch (ch->transmission_mode) { in dib7000p_tune()
1344 switch (ch->transmission_mode) { in dib7000p_tune()
1367 // we achieved a lock - it's time to update the osc freq in dib7000p_tune()
1375 if (state->cfg.spur_protect) in dib7000p_tune()
1376 dib7000p_spur_protect(state, ch->frequency / 1000, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000p_tune()
1378 dib7000p_set_bandwidth(state, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000p_tune()
1387 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_wakeup()
1390 if (state->version == SOC7090) in dib7000p_wakeup()
1397 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_sleep()
1398 if (state->version == SOC7090) in dib7000p_sleep()
1406 dprintk("checking demod on I2C address: %d (%x)\n", st->i2c_addr, st->i2c_addr); in dib7000p_identify()
1410 return -EREMOTEIO; in dib7000p_identify()
1415 return -EREMOTEIO; in dib7000p_identify()
1424 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_frontend()
1427 fep->inversion = INVERSION_AUTO; in dib7000p_get_frontend()
1429 fep->bandwidth_hz = BANDWIDTH_TO_HZ(state->current_bandwidth); in dib7000p_get_frontend()
1433 fep->transmission_mode = TRANSMISSION_MODE_2K; in dib7000p_get_frontend()
1436 fep->transmission_mode = TRANSMISSION_MODE_8K; in dib7000p_get_frontend()
1438 /* case 2: fep->transmission_mode = TRANSMISSION_MODE_4K; break; */ in dib7000p_get_frontend()
1443 fep->guard_interval = GUARD_INTERVAL_1_32; in dib7000p_get_frontend()
1446 fep->guard_interval = GUARD_INTERVAL_1_16; in dib7000p_get_frontend()
1449 fep->guard_interval = GUARD_INTERVAL_1_8; in dib7000p_get_frontend()
1452 fep->guard_interval = GUARD_INTERVAL_1_4; in dib7000p_get_frontend()
1458 fep->modulation = QPSK; in dib7000p_get_frontend()
1461 fep->modulation = QAM_16; in dib7000p_get_frontend()
1465 fep->modulation = QAM_64; in dib7000p_get_frontend()
1472 fep->hierarchy = HIERARCHY_NONE; in dib7000p_get_frontend()
1475 fep->code_rate_HP = FEC_1_2; in dib7000p_get_frontend()
1478 fep->code_rate_HP = FEC_2_3; in dib7000p_get_frontend()
1481 fep->code_rate_HP = FEC_3_4; in dib7000p_get_frontend()
1484 fep->code_rate_HP = FEC_5_6; in dib7000p_get_frontend()
1488 fep->code_rate_HP = FEC_7_8; in dib7000p_get_frontend()
1495 fep->code_rate_LP = FEC_1_2; in dib7000p_get_frontend()
1498 fep->code_rate_LP = FEC_2_3; in dib7000p_get_frontend()
1501 fep->code_rate_LP = FEC_3_4; in dib7000p_get_frontend()
1504 fep->code_rate_LP = FEC_5_6; in dib7000p_get_frontend()
1508 fep->code_rate_LP = FEC_7_8; in dib7000p_get_frontend()
1519 struct dtv_frontend_properties *fep = &fe->dtv_property_cache; in dib7000p_set_frontend()
1520 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_set_frontend()
1523 if (state->version == SOC7090) in dib7000p_set_frontend()
1529 state->sfn_workaround_active = buggy_sfn_workaround; in dib7000p_set_frontend()
1531 if (fe->ops.tuner_ops.set_params) in dib7000p_set_frontend()
1532 fe->ops.tuner_ops.set_params(fe); in dib7000p_set_frontend()
1535 state->agc_state = 0; in dib7000p_set_frontend()
1538 if (time != -1) in dib7000p_set_frontend()
1540 } while (time != -1); in dib7000p_set_frontend()
1542 if (fep->transmission_mode == TRANSMISSION_MODE_AUTO || in dib7000p_set_frontend()
1543 …fep->guard_interval == GUARD_INTERVAL_AUTO || fep->modulation == QAM_AUTO || fep->code_rate_HP == … in dib7000p_set_frontend()
1550 } while (found == 0 && i--); in dib7000p_set_frontend()
1562 if (state->version == SOC7090) { in dib7000p_set_frontend()
1563 dib7090_set_output_mode(fe, state->cfg.output_mode); in dib7000p_set_frontend()
1564 if (state->cfg.enMpegOutput == 0) { in dib7000p_set_frontend()
1569 dib7000p_set_output_mode(state, state->cfg.output_mode); in dib7000p_set_frontend()
1578 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_status()
1601 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_ber()
1608 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_unc_blocks()
1615 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_signal_strength()
1617 *strength = 65535 - val; in dib7000p_read_signal_strength()
1623 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_snr()
1634 noise_exp -= 0x40; in dib7000p_get_snr()
1639 signal_exp -= 0x40; in dib7000p_get_snr()
1644 result = intlog10(2) * 10 * signal_exp - 100; in dib7000p_get_snr()
1647 result -= intlog10(2) * 10 * noise_exp + 10 * intlog10(noise_mant); in dib7000p_get_snr()
1649 result -= intlog10(2) * 10 * noise_exp - 100; in dib7000p_get_snr()
1666 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_reset_stats()
1667 struct dtv_frontend_properties *c = &demod->dtv_property_cache; in dib7000p_reset_stats()
1670 memset(&c->strength, 0, sizeof(c->strength)); in dib7000p_reset_stats()
1671 memset(&c->cnr, 0, sizeof(c->cnr)); in dib7000p_reset_stats()
1672 memset(&c->post_bit_error, 0, sizeof(c->post_bit_error)); in dib7000p_reset_stats()
1673 memset(&c->post_bit_count, 0, sizeof(c->post_bit_count)); in dib7000p_reset_stats()
1674 memset(&c->block_error, 0, sizeof(c->block_error)); in dib7000p_reset_stats()
1676 c->strength.len = 1; in dib7000p_reset_stats()
1677 c->cnr.len = 1; in dib7000p_reset_stats()
1678 c->block_error.len = 1; in dib7000p_reset_stats()
1679 c->block_count.len = 1; in dib7000p_reset_stats()
1680 c->post_bit_error.len = 1; in dib7000p_reset_stats()
1681 c->post_bit_count.len = 1; in dib7000p_reset_stats()
1683 c->strength.stat[0].scale = FE_SCALE_DECIBEL; in dib7000p_reset_stats()
1684 c->strength.stat[0].uvalue = 0; in dib7000p_reset_stats()
1686 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1687 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1688 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1689 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1690 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1694 state->old_ucb = ucb; in dib7000p_reset_stats()
1695 state->ber_jiffies_stats = 0; in dib7000p_reset_stats()
1696 state->per_jiffies_stats = 0; in dib7000p_reset_stats()
1710 * by a DTA-2111 RF generator directly connected into a dib7000p device
1711 * (a Hauppauge Nova-TD stick), using a good quality 3 meters length
1713 * As the minimum output power of DTA-2111 is -31dBm, a 16 dBm attenuator
1718 * Yet, it is better to use this measure in dB than a random non-linear
1726 { 63630, DB_OFFSET - 20500},
1727 { 62273, DB_OFFSET - 21000},
1728 { 60162, DB_OFFSET - 22000},
1729 { 58730, DB_OFFSET - 23000},
1730 { 58294, DB_OFFSET - 24000},
1731 { 57778, DB_OFFSET - 25000},
1732 { 57320, DB_OFFSET - 26000},
1733 { 56779, DB_OFFSET - 27000},
1734 { 56293, DB_OFFSET - 28000},
1735 { 55724, DB_OFFSET - 29000},
1736 { 55145, DB_OFFSET - 30000},
1737 { 54680, DB_OFFSET - 31000},
1738 { 54293, DB_OFFSET - 32000},
1739 { 53813, DB_OFFSET - 33000},
1740 { 53427, DB_OFFSET - 34000},
1741 { 52981, DB_OFFSET - 35000},
1743 { 52636, DB_OFFSET - 36000},
1744 { 52014, DB_OFFSET - 37000},
1745 { 51674, DB_OFFSET - 38000},
1746 { 50692, DB_OFFSET - 39000},
1747 { 49824, DB_OFFSET - 40000},
1748 { 49052, DB_OFFSET - 41000},
1749 { 48436, DB_OFFSET - 42000},
1750 { 47836, DB_OFFSET - 43000},
1751 { 47368, DB_OFFSET - 44000},
1752 { 46468, DB_OFFSET - 45000},
1753 { 45597, DB_OFFSET - 46000},
1754 { 44586, DB_OFFSET - 47000},
1755 { 43667, DB_OFFSET - 48000},
1756 { 42673, DB_OFFSET - 49000},
1757 { 41816, DB_OFFSET - 50000},
1758 { 40876, DB_OFFSET - 51000},
1772 if (value < segments[len-1].x) in interpolate_value()
1773 return segments[len-1].y; in interpolate_value()
1775 for (i = 1; i < len - 1; i++) { in interpolate_value()
1784 dy = segments[i - 1].y - segments[i].y; in interpolate_value()
1785 dx = segments[i - 1].x - segments[i].x; in interpolate_value()
1787 tmp64 = value - segments[i].x; in interpolate_value()
1795 /* FIXME: may require changes - this one was borrowed from dib8000 */
1798 struct dtv_frontend_properties *c = &demod->dtv_property_cache; in dib7000p_get_time_us()
1804 switch (c->guard_interval) { in dib7000p_get_time_us()
1820 switch (c->transmission_mode) { in dib7000p_get_time_us()
1833 switch (c->modulation) { in dib7000p_get_time_us()
1847 switch ((c->hierarchy == 0 || 1 == 1) ? c->code_rate_HP : c->code_rate_LP) { in dib7000p_get_time_us()
1898 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_get_stats()
1899 struct dtv_frontend_properties *c = &demod->dtv_property_cache; in dib7000p_get_stats()
1911 ARRAY_SIZE(strength_to_db_table)) - DB_OFFSET; in dib7000p_get_stats()
1912 c->strength.stat[0].svalue = db; in dib7000p_get_stats()
1916 c->cnr.len = 1; in dib7000p_get_stats()
1917 c->block_count.len = 1; in dib7000p_get_stats()
1918 c->block_error.len = 1; in dib7000p_get_stats()
1919 c->post_bit_error.len = 1; in dib7000p_get_stats()
1920 c->post_bit_count.len = 1; in dib7000p_get_stats()
1921 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1922 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1923 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1924 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1925 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_get_stats()
1930 if (time_after(jiffies, state->per_jiffies_stats)) { in dib7000p_get_stats()
1931 state->per_jiffies_stats = jiffies + msecs_to_jiffies(1000); in dib7000p_get_stats()
1939 c->cnr.stat[0].svalue = snr; in dib7000p_get_stats()
1940 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; in dib7000p_get_stats()
1944 ucb = val - state->old_ucb; in dib7000p_get_stats()
1945 if (val < state->old_ucb) in dib7000p_get_stats()
1948 c->block_error.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1949 c->block_error.stat[0].uvalue = ucb; in dib7000p_get_stats()
1958 c->block_count.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1959 c->block_count.stat[0].uvalue += blocks; in dib7000p_get_stats()
1965 /* Get post-BER measures */ in dib7000p_get_stats()
1966 if (time_after(jiffies, state->ber_jiffies_stats)) { in dib7000p_get_stats()
1968 state->ber_jiffies_stats = jiffies + msecs_to_jiffies((time_us + 500) / 1000); in dib7000p_get_stats()
1973 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1974 c->post_bit_error.stat[0].uvalue += val; in dib7000p_get_stats()
1976 c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1977 c->post_bit_count.stat[0].uvalue += 100000000; in dib7000p_get_stats()
1984 c->block_error.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1985 c->block_error.stat[0].uvalue += val; in dib7000p_get_stats()
1991 c->block_count.stat[0].scale = FE_SCALE_COUNTER; in dib7000p_get_stats()
1992 c->block_count.stat[0].uvalue += blocks; in dib7000p_get_stats()
2000 tune->min_delay_ms = 1000; in dib7000p_fe_get_tune_settings()
2006 struct dib7000p_state *st = demod->demodulator_priv; in dib7000p_release()
2007 dibx000_exit_i2c_master(&st->i2c_master); in dib7000p_release()
2008 i2c_del_adapter(&st->dib7090_tuner_adap); in dib7000p_release()
2023 return -ENOMEM; in dib7000pc_detection()
2026 ret = -ENOMEM; in dib7000pc_detection()
2038 dprintk("-D- DiB7000PC detected\n"); in dib7000pc_detection()
2047 dprintk("-D- DiB7000PC detected\n"); in dib7000pc_detection()
2052 dprintk("-D- DiB7000PC not detected\n"); in dib7000pc_detection()
2063 struct dib7000p_state *st = demod->demodulator_priv; in dib7000p_get_i2c_master()
2064 return dibx000_get_i2c_adapter(&st->i2c_master, intf, gating); in dib7000p_get_i2c_master()
2069 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_pid_filter_ctrl()
2078 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_pid_filter()
2091 return -ENOMEM; in dib7000p_i2c_enumeration()
2093 dpst->i2c_adap = i2c; in dib7000p_i2c_enumeration()
2094 mutex_init(&dpst->i2c_buffer_lock); in dib7000p_i2c_enumeration()
2096 for (k = no_of_demods - 1; k >= 0; k--) { in dib7000p_i2c_enumeration()
2097 dpst->cfg = cfg[k]; in dib7000p_i2c_enumeration()
2104 dpst->i2c_addr = new_addr; in dib7000p_i2c_enumeration()
2107 dpst->i2c_addr = default_addr; in dib7000p_i2c_enumeration()
2112 return -EIO; in dib7000p_i2c_enumeration()
2116 /* start diversity to pull_down div_str - just for i2c-enumeration */ in dib7000p_i2c_enumeration()
2126 dpst->cfg = cfg[k]; in dib7000p_i2c_enumeration()
2128 dpst->i2c_addr = (cfg[k].default_i2c_addr + k) << 1; in dib7000p_i2c_enumeration()
2130 dpst->i2c_addr = (0x40 + k) << 1; in dib7000p_i2c_enumeration()
2133 dib7000p_write_word(dpst, 1285, dpst->i2c_addr << 2); in dib7000p_i2c_enumeration()
2135 /* deactivate div - it was just for i2c-enumeration */ in dib7000p_i2c_enumeration()
2149 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_adc_power()
2167 ix = (u8) ((mant - 1000) / 100); /* index of the LUT */ in dib7000p_get_adc_power()
2170 pow_i = (lut_1000ln_mant[ix] + 693 * (exp - 20) - 6908); in dib7000p_get_adc_power()
2179 if ((msg->buf[0] <= 15)) in map_addr_to_serpar_number()
2180 msg->buf[0] -= 1; in map_addr_to_serpar_number()
2181 else if (msg->buf[0] == 17) in map_addr_to_serpar_number()
2182 msg->buf[0] = 15; in map_addr_to_serpar_number()
2183 else if (msg->buf[0] == 16) in map_addr_to_serpar_number()
2184 msg->buf[0] = 17; in map_addr_to_serpar_number()
2185 else if (msg->buf[0] == 19) in map_addr_to_serpar_number()
2186 msg->buf[0] = 16; in map_addr_to_serpar_number()
2187 else if (msg->buf[0] >= 21 && msg->buf[0] <= 25) in map_addr_to_serpar_number()
2188 msg->buf[0] -= 3; in map_addr_to_serpar_number()
2189 else if (msg->buf[0] == 28) in map_addr_to_serpar_number()
2190 msg->buf[0] = 23; in map_addr_to_serpar_number()
2192 return -EINVAL; in map_addr_to_serpar_number()
2205 i--; in w7090p_tuner_write_serpar()
2225 i--; in w7090p_tuner_read_serpar()
2234 i--; in w7090p_tuner_read_serpar()
2401 struct dib7000p_state *st = fe->demodulator_priv; in dib7090_get_i2c_tuner()
2402 return &st->dib7090_tuner_adap; in dib7090_get_i2c_tuner()
2444 if ((syncFreq & ((1 << quantif) - 1)) != 0) in dib7090_calcSyncFreq()
2450 syncFreq = syncFreq - 1; in dib7090_calcSyncFreq()
2519 if ((enSerialMode == 1) && (state->input_mode_mpeg == 1)) in dib7090_configMpegMux()
2582 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_set_diversity_in()
2586 case 0: /* only use the internal way - not the diversity input */ in dib7090_set_diversity_in()
2599 state->input_mode_mpeg = 1; in dib7090_set_diversity_in()
2605 state->input_mode_mpeg = 0; in dib7090_set_diversity_in()
2609 dib7000p_set_diversity_in(&state->demod, onoff); in dib7090_set_diversity_in()
2615 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_set_output_mode()
2685 if (state->cfg.output_mpeg2_in_188_bytes) in dib7090_set_output_mode()
2697 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_tuner_sleep()
2705 state->tuner_enable = en_cur_state; in dib7090_tuner_sleep()
2710 if (state->tuner_enable != 0) in dib7090_tuner_sleep()
2711 en_cur_state = state->tuner_enable; in dib7090_tuner_sleep()
2726 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_slave_reset()
2745 memcpy(&st->cfg, cfg, sizeof(struct dib7000p_config)); in dib7000p_init()
2746 st->i2c_adap = i2c_adap; in dib7000p_init()
2747 st->i2c_addr = i2c_addr; in dib7000p_init()
2748 st->gpio_val = cfg->gpio_val; in dib7000p_init()
2749 st->gpio_dir = cfg->gpio_dir; in dib7000p_init()
2754 …if ((st->cfg.output_mode != OUTMODE_MPEG2_SERIAL) && (st->cfg.output_mode != OUTMODE_MPEG2_PAR_GAT… in dib7000p_init()
2755 st->cfg.output_mode = OUTMODE_MPEG2_FIFO; in dib7000p_init()
2757 demod = &st->demod; in dib7000p_init()
2758 demod->demodulator_priv = st; in dib7000p_init()
2759 memcpy(&st->demod.ops, &dib7000p_ops, sizeof(struct dvb_frontend_ops)); in dib7000p_init()
2760 mutex_init(&st->i2c_buffer_lock); in dib7000p_init()
2767 st->version = dib7000p_read_word(st, 897); in dib7000p_init()
2772 st->i2c_master.gated_tuner_i2c_adap.dev.parent = i2c_adap->dev.parent; in dib7000p_init()
2774 dibx000_init_i2c_master(&st->i2c_master, DIB7000P, st->i2c_adap, st->i2c_addr); in dib7000p_init()
2777 strscpy(st->dib7090_tuner_adap.name, "DiB7090 tuner interface", in dib7000p_init()
2778 sizeof(st->dib7090_tuner_adap.name)); in dib7000p_init()
2779 st->dib7090_tuner_adap.algo = &dib7090_tuner_xfer_algo; in dib7000p_init()
2780 st->dib7090_tuner_adap.algo_data = NULL; in dib7000p_init()
2781 st->dib7090_tuner_adap.dev.parent = st->i2c_adap->dev.parent; in dib7000p_init()
2782 i2c_set_adapdata(&st->dib7090_tuner_adap, st); in dib7000p_init()
2783 i2c_add_adapter(&st->dib7090_tuner_adap); in dib7000p_init()
2789 if (st->version == SOC7090) { in dib7000p_init()
2790 dib7090_set_output_mode(demod, st->cfg.output_mode); in dib7000p_init()
2806 ops->slave_reset = dib7090_slave_reset; in dib7000p_attach()
2807 ops->get_adc_power = dib7090_get_adc_power; in dib7000p_attach()
2808 ops->dib7000pc_detection = dib7000pc_detection; in dib7000p_attach()
2809 ops->get_i2c_tuner = dib7090_get_i2c_tuner; in dib7000p_attach()
2810 ops->tuner_sleep = dib7090_tuner_sleep; in dib7000p_attach()
2811 ops->init = dib7000p_init; in dib7000p_attach()
2812 ops->set_agc1_min = dib7000p_set_agc1_min; in dib7000p_attach()
2813 ops->set_gpio = dib7000p_set_gpio; in dib7000p_attach()
2814 ops->i2c_enumeration = dib7000p_i2c_enumeration; in dib7000p_attach()
2815 ops->pid_filter = dib7000p_pid_filter; in dib7000p_attach()
2816 ops->pid_filter_ctrl = dib7000p_pid_filter_ctrl; in dib7000p_attach()
2817 ops->get_i2c_master = dib7000p_get_i2c_master; in dib7000p_attach()
2818 ops->update_pll = dib7000p_update_pll; in dib7000p_attach()
2819 ops->ctrl_timf = dib7000p_ctrl_timf; in dib7000p_attach()
2820 ops->get_agc_values = dib7000p_get_agc_values; in dib7000p_attach()
2821 ops->set_wbd_ref = dib7000p_set_wbd_ref; in dib7000p_attach()