• Home
  • Raw
  • Download

Lines Matching +full:dout +full:- +full:gpios

2  * Linux-DVB Driver for DiBcom's second generation DiB7000P (PC).
4 * Copyright (C) 2005-7 DiBcom (http://www.dibcom.fr/)
30 MODULE_PARM_DESC(buggy_sfn_workaround, "Enable work-around for buggy SFNs (default: 0)");
107 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib7000p_read_word()
112 state->i2c_write_buffer[0] = reg >> 8; in dib7000p_read_word()
113 state->i2c_write_buffer[1] = reg & 0xff; in dib7000p_read_word()
115 memset(state->msg, 0, 2 * sizeof(struct i2c_msg)); in dib7000p_read_word()
116 state->msg[0].addr = state->i2c_addr >> 1; in dib7000p_read_word()
117 state->msg[0].flags = 0; in dib7000p_read_word()
118 state->msg[0].buf = state->i2c_write_buffer; in dib7000p_read_word()
119 state->msg[0].len = 2; in dib7000p_read_word()
120 state->msg[1].addr = state->i2c_addr >> 1; in dib7000p_read_word()
121 state->msg[1].flags = I2C_M_RD; in dib7000p_read_word()
122 state->msg[1].buf = state->i2c_read_buffer; in dib7000p_read_word()
123 state->msg[1].len = 2; in dib7000p_read_word()
125 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2) in dib7000p_read_word()
128 ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1]; in dib7000p_read_word()
129 mutex_unlock(&state->i2c_buffer_lock); in dib7000p_read_word()
137 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib7000p_write_word()
139 return -EINVAL; in dib7000p_write_word()
142 state->i2c_write_buffer[0] = (reg >> 8) & 0xff; in dib7000p_write_word()
143 state->i2c_write_buffer[1] = reg & 0xff; in dib7000p_write_word()
144 state->i2c_write_buffer[2] = (val >> 8) & 0xff; in dib7000p_write_word()
145 state->i2c_write_buffer[3] = val & 0xff; in dib7000p_write_word()
147 memset(&state->msg[0], 0, sizeof(struct i2c_msg)); in dib7000p_write_word()
148 state->msg[0].addr = state->i2c_addr >> 1; in dib7000p_write_word()
149 state->msg[0].flags = 0; in dib7000p_write_word()
150 state->msg[0].buf = state->i2c_write_buffer; in dib7000p_write_word()
151 state->msg[0].len = 4; in dib7000p_write_word()
153 ret = (i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ? in dib7000p_write_word()
154 -EREMOTEIO : 0); in dib7000p_write_word()
155 mutex_unlock(&state->i2c_buffer_lock); in dib7000p_write_word()
170 } while (--l); in dib7000p_write_tab()
184 dprintk("setting output mode for demod %p to %d\n", &state->demod, mode); in dib7000p_set_output_mode()
197 if (state->cfg.hostbus_diversity) in dib7000p_set_output_mode()
214 dprintk("Unhandled output_mode passed to be set for demod %p\n", &state->demod); in dib7000p_set_output_mode()
218 if (state->cfg.output_mpeg2_in_188_bytes) in dib7000p_set_output_mode()
223 if (state->version != SOC7090) in dib7000p_set_output_mode()
231 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_set_diversity_in()
233 if (state->div_force_off) { in dib7000p_set_diversity_in()
234 dprintk("diversity combination deactivated - forced by COFDM parameters\n"); in dib7000p_set_diversity_in()
238 dib7000p_write_word(state, 207, (state->div_sync_wait << 4) | (1 << 2) | (2 << 0)); in dib7000p_set_diversity_in()
240 state->div_state = (u8) onoff; in dib7000p_set_diversity_in()
267 if (state->version == SOC7090) in dib7000p_set_power_mode()
278 /* Dout */ in dib7000p_set_power_mode()
279 if (state->version != SOC7090) in dib7000p_set_power_mode()
282 /* fall-through */ in dib7000p_set_power_mode()
284 /* just leave power on the control-interfaces: GPIO and (I2C or SDIO) */ in dib7000p_set_power_mode()
286 if (state->version == SOC7090) in dib7000p_set_power_mode()
292 /* TODO following stuff is just converted from the dib7000-driver - check when is used what */ in dib7000p_set_power_mode()
299 if (state->version != SOC7090) in dib7000p_set_power_mode()
310 if (state->version != SOC7090) { in dib7000p_set_adc_state()
317 if (state->version == SOC7090) { in dib7000p_set_adc_state()
336 if (state->version == SOC7090) { in dib7000p_set_adc_state()
367 reg_909 |= (state->cfg.disable_sample_and_hold & 1) << 4; in dib7000p_set_adc_state()
368 reg_908 |= (state->cfg.enable_current_mirror & 1) << 7; in dib7000p_set_adc_state()
370 if (state->version != SOC7090) { in dib7000p_set_adc_state()
381 state->current_bandwidth = bw; in dib7000p_set_bandwidth()
383 if (state->timf == 0) { in dib7000p_set_bandwidth()
385 timf = state->cfg.bw->timf; in dib7000p_set_bandwidth()
388 timf = state->timf; in dib7000p_set_bandwidth()
404 if (state->version == SOC7090) in dib7000p_sad_calib()
420 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_set_wbd_ref()
423 state->wbd_ref = value; in dib7000p_set_wbd_ref()
430 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_agc_values()
446 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_set_agc1_min()
452 struct dibx000_bandwidth_config *bw = &state->cfg.bw[0]; in dib7000p_reset_pll()
455 if (state->version == SOC7090) { in dib7000p_reset_pll()
456 …dib7000p_write_word(state, 1856, (!bw->pll_reset << 13) | (bw->pll_range << 12) | (bw->pll_ratio <… in dib7000p_reset_pll()
461 dib7000p_write_word(state, 1857, dib7000p_read_word(state, 1857) | (!bw->pll_bypass << 15)); in dib7000p_reset_pll()
464 clk_cfg0 = (1 << 15) | ((bw->pll_ratio & 0x3f) << 9) | in dib7000p_reset_pll()
465 …(bw->modulo << 7) | (bw->ADClkSrc << 6) | (bw->IO_CLK_en_core << 5) | (bw->bypclk_div << 2) | (bw- in dib7000p_reset_pll()
470 …ib7000p_write_word(state, 903, (bw->pll_prediv << 5) | (((bw->pll_ratio >> 6) & 0x3) << 3) | (bw->… in dib7000p_reset_pll()
471 clk_cfg0 = (bw->pll_bypass << 15) | (clk_cfg0 & 0x7fff); in dib7000p_reset_pll()
475 dib7000p_write_word(state, 18, (u16) (((bw->internal * 1000) >> 16) & 0xffff)); in dib7000p_reset_pll()
476 dib7000p_write_word(state, 19, (u16) ((bw->internal * 1000) & 0xffff)); in dib7000p_reset_pll()
477 dib7000p_write_word(state, 21, (u16) ((bw->ifreq >> 16) & 0xffff)); in dib7000p_reset_pll()
478 dib7000p_write_word(state, 22, (u16) ((bw->ifreq) & 0xffff)); in dib7000p_reset_pll()
480 dib7000p_write_word(state, 72, bw->sad_cfg); in dib7000p_reset_pll()
494 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_update_pll()
503 if ((bw != NULL) && (bw->pll_prediv != prediv || bw->pll_ratio != loopdiv)) { in dib7000p_update_pll()
504 …ld = %d new = %d ; loopdiv : old = %d new = %d)\n", prediv, bw->pll_prediv, loopdiv, bw->pll_rati… in dib7000p_update_pll()
509 …dib7000p_write_word(state, 1856, reg_1856 | ((bw->pll_ratio & 0x3f) << 6) | (bw->pll_prediv & 0x3f… in dib7000p_update_pll()
514 internal = 1000 * (xtal / bw->pll_prediv) * bw->pll_ratio; /* new internal */ in dib7000p_update_pll()
525 return -EIO; in dib7000p_update_pll()
530 /* reset the GPIOs */ in dib7000p_reset_gpio()
531 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()
533 dib7000p_write_word(st, 1029, st->gpio_dir); in dib7000p_reset_gpio()
534 dib7000p_write_word(st, 1030, st->gpio_val); in dib7000p_reset_gpio()
538 dib7000p_write_word(st, 1032, st->cfg.gpio_pwm_pos); in dib7000p_reset_gpio()
540 dib7000p_write_word(st, 1037, st->cfg.pwm_freq_div); in dib7000p_reset_gpio()
546 st->gpio_dir = dib7000p_read_word(st, 1029); in dib7000p_cfg_gpio()
547 st->gpio_dir &= ~(1 << num); /* reset the direction bit */ in dib7000p_cfg_gpio()
548 st->gpio_dir |= (dir & 0x1) << num; /* set the new direction */ in dib7000p_cfg_gpio()
549 dib7000p_write_word(st, 1029, st->gpio_dir); in dib7000p_cfg_gpio()
551 st->gpio_val = dib7000p_read_word(st, 1030); in dib7000p_cfg_gpio()
552 st->gpio_val &= ~(1 << num); /* reset the direction bit */ in dib7000p_cfg_gpio()
553 st->gpio_val |= (val & 0x01) << num; /* set the new value */ in dib7000p_cfg_gpio()
554 dib7000p_write_word(st, 1030, st->gpio_val); in dib7000p_cfg_gpio()
561 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_set_gpio()
589 /* set ADC level to -16 */
591 (1 << 13) - 825 - 117,
592 (1 << 13) - 837 - 117,
593 (1 << 13) - 811 - 117,
594 (1 << 13) - 766 - 117,
595 (1 << 13) - 737 - 117,
596 (1 << 13) - 693 - 117,
597 (1 << 13) - 648 - 117,
598 (1 << 13) - 619 - 117,
599 (1 << 13) - 575 - 117,
600 (1 << 13) - 531 - 117,
601 (1 << 13) - 501 - 117,
654 if (state->version == SOC7090) in dib7000p_demod_reset()
655 dibx000_reset_i2c_master(&state->i2c_master); in dib7000p_demod_reset()
663 dib7000p_write_word(state, 1280, 0x001f - ((1 << 4) | (1 << 3))); in dib7000p_demod_reset()
670 if (state->version != SOC7090) { in dib7000p_demod_reset()
681 if (state->version == SOC7090) { in dib7000p_demod_reset()
686 dib7000p_write_word(state, 43, 0x2d4); /*-300 fag P_iqc_dect_min = -280 */ in dib7000p_demod_reset()
702 if (state->version == SOC7090) { in dib7000p_demod_reset()
705 if (state->cfg.tuner_is_baseband) in dib7000p_demod_reset()
712 if (state->version != SOC7090) { in dib7000p_demod_reset()
743 if (state->cfg.update_lna) { in dib7000p_update_lna()
745 if (state->cfg.update_lna(&state->demod, dyn_gain)) { in dib7000p_update_lna()
758 if (state->current_band == band && state->current_agc != NULL) in dib7000p_set_agc_config()
760 state->current_band = band; in dib7000p_set_agc_config()
762 for (i = 0; i < state->cfg.agc_config_count; i++) in dib7000p_set_agc_config()
763 if (state->cfg.agc[i].band_caps & band) { in dib7000p_set_agc_config()
764 agc = &state->cfg.agc[i]; in dib7000p_set_agc_config()
770 return -EINVAL; in dib7000p_set_agc_config()
773 state->current_agc = agc; in dib7000p_set_agc_config()
776 dib7000p_write_word(state, 75, agc->setup); in dib7000p_set_agc_config()
777 dib7000p_write_word(state, 76, agc->inv_gain); in dib7000p_set_agc_config()
778 dib7000p_write_word(state, 77, agc->time_stabiliz); in dib7000p_set_agc_config()
779 dib7000p_write_word(state, 100, (agc->alpha_level << 12) | agc->thlock); in dib7000p_set_agc_config()
782 dib7000p_write_word(state, 101, (agc->alpha_mant << 5) | agc->alpha_exp); in dib7000p_set_agc_config()
783 dib7000p_write_word(state, 102, (agc->beta_mant << 6) | agc->beta_exp); in dib7000p_set_agc_config()
787 …state->wbd_ref != 0 ? state->wbd_ref : agc->wbd_ref, agc->wbd_sel, !agc->perform_agc_softsplit, ag… in dib7000p_set_agc_config()
789 if (state->wbd_ref != 0) in dib7000p_set_agc_config()
790 dib7000p_write_word(state, 105, (agc->wbd_inv << 12) | state->wbd_ref); in dib7000p_set_agc_config()
792 dib7000p_write_word(state, 105, (agc->wbd_inv << 12) | agc->wbd_ref); in dib7000p_set_agc_config()
794 …dib7000p_write_word(state, 106, (agc->wbd_sel << 13) | (agc->wbd_alpha << 9) | (agc->perform_agc_s… in dib7000p_set_agc_config()
796 dib7000p_write_word(state, 107, agc->agc1_max); in dib7000p_set_agc_config()
797 dib7000p_write_word(state, 108, agc->agc1_min); in dib7000p_set_agc_config()
798 dib7000p_write_word(state, 109, agc->agc2_max); in dib7000p_set_agc_config()
799 dib7000p_write_word(state, 110, agc->agc2_min); in dib7000p_set_agc_config()
800 dib7000p_write_word(state, 111, (agc->agc1_pt1 << 8) | agc->agc1_pt2); in dib7000p_set_agc_config()
801 dib7000p_write_word(state, 112, agc->agc1_pt3); in dib7000p_set_agc_config()
802 dib7000p_write_word(state, 113, (agc->agc1_slope1 << 8) | agc->agc1_slope2); in dib7000p_set_agc_config()
803 dib7000p_write_word(state, 114, (agc->agc2_pt1 << 8) | agc->agc2_pt2); in dib7000p_set_agc_config()
804 dib7000p_write_word(state, 115, (agc->agc2_slope1 << 8) | agc->agc2_slope2); in dib7000p_set_agc_config()
813 u32 dds = state->cfg.bw->ifreq & 0x1ffffff; in dib7000p_set_dds()
814 u8 invert = !!(state->cfg.bw->ifreq & (1 << 25)); in dib7000p_set_dds()
817 return -1; in dib7000p_set_dds()
825 unit_khz_dds_val *= -1; in dib7000p_set_dds()
829 …dds -= (abs_offset_khz * unit_khz_dds_val); /* /100 because of /100 on the unit_khz_dds_val line c… in dib7000p_set_dds()
842 struct dtv_frontend_properties *ch = &demod->dtv_property_cache; in dib7000p_agc_startup()
843 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_agc_startup()
844 int ret = -1; in dib7000p_agc_startup()
845 u8 *agc_state = &state->agc_state; in dib7000p_agc_startup()
851 switch (state->agc_state) { in dib7000p_agc_startup()
854 if (state->version == SOC7090) { in dib7000p_agc_startup()
867 if (dib7000p_set_agc_config(state, BAND_OF_FREQUENCY(ch->frequency / 1000)) != 0) in dib7000p_agc_startup()
868 return -1; in dib7000p_agc_startup()
870 if (demod->ops.tuner_ops.get_frequency) { in dib7000p_agc_startup()
873 demod->ops.tuner_ops.get_frequency(demod, &frequency_tuner); in dib7000p_agc_startup()
874 frequency_offset = (s32)frequency_tuner / 1000 - ch->frequency / 1000; in dib7000p_agc_startup()
878 return -1; in dib7000p_agc_startup()
885 if (state->cfg.agc_control) in dib7000p_agc_startup()
886 state->cfg.agc_control(&state->demod, 1); in dib7000p_agc_startup()
889 if (!state->current_agc->perform_agc_softsplit) { in dib7000p_agc_startup()
890 /* we are using the wbd - so slow AGC startup */ in dib7000p_agc_startup()
892 …dib7000p_write_word(state, 106, (state->current_agc->wbd_sel << 13) | (state->current_agc->wbd_alp… in dib7000p_agc_startup()
906 dib7000p_write_word(state, 75, state->current_agc->setup | (1 << 4)); /* freeze AGC loop */ in dib7000p_agc_startup()
907 …dib7000p_write_word(state, 106, (state->current_agc->wbd_sel << 13) | (2 << 9) | (0 << 8)); /* fas… in dib7000p_agc_startup()
916 dib7000p_write_word(state, 75, state->current_agc->setup); /* std AGC loop */ in dib7000p_agc_startup()
917 …dib7000p_write_word(state, 106, (state->current_agc->wbd_sel << 13) | (state->current_agc->wbd_alp… in dib7000p_agc_startup()
937 if (state->cfg.agc_control) in dib7000p_agc_startup()
938 state->cfg.agc_control(&state->demod, 0); in dib7000p_agc_startup()
950 state->timf = timf * 160 / (state->current_bandwidth / 50); in dib7000p_update_timf()
953 dprintk("updated timf_frequency: %d (default: %d)\n", state->timf, state->cfg.bw->timf); in dib7000p_update_timf()
959 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_ctrl_timf()
962 state->timf = timf; in dib7000p_ctrl_timf()
970 dib7000p_set_bandwidth(state, state->current_bandwidth); in dib7000p_ctrl_timf()
971 return state->timf; in dib7000p_ctrl_timf()
979 dib7000p_set_bandwidth(state, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000p_set_channel()
983 switch (ch->transmission_mode) { in dib7000p_set_channel()
995 switch (ch->guard_interval) { in dib7000p_set_channel()
1010 switch (ch->modulation) { in dib7000p_set_channel()
1041 if (ch->hierarchy == 1) in dib7000p_set_channel()
1045 switch ((ch->hierarchy == 0 || 1 == 1) ? ch->code_rate_HP : ch->code_rate_LP) { in dib7000p_set_channel()
1072 switch (ch->transmission_mode) { in dib7000p_set_channel()
1084 switch (ch->guard_interval) { in dib7000p_set_channel()
1099 if (state->cfg.diversity_delay == 0) in dib7000p_set_channel()
1100 state->div_sync_wait = (value * 3) / 2 + 48; in dib7000p_set_channel()
1102 state->div_sync_wait = (value * 3) / 2 + state->cfg.diversity_delay; in dib7000p_set_channel()
1105 state->div_force_off = !1 && ch->transmission_mode != TRANSMISSION_MODE_8K; in dib7000p_set_channel()
1106 dib7000p_set_diversity_in(&state->demod, state->div_state); in dib7000p_set_channel()
1109 switch (ch->modulation) { in dib7000p_set_channel()
1112 est[1] = 0xfff0; /* P_adp_noise_cnt -0.002 */ in dib7000p_set_channel()
1114 est[3] = 0xfff8; /* P_adp_noise_ext -0.001 */ in dib7000p_set_channel()
1118 est[1] = 0xffdf; /* P_adp_noise_cnt -0.004 */ in dib7000p_set_channel()
1120 est[3] = 0xfff0; /* P_adp_noise_ext -0.002 */ in dib7000p_set_channel()
1124 est[1] = 0xffae; /* P_adp_noise_cnt -0.01 */ in dib7000p_set_channel()
1126 est[3] = 0xfff8; /* P_adp_noise_ext -0.002 */ in dib7000p_set_channel()
1135 struct dtv_frontend_properties *ch = &demod->dtv_property_cache; in dib7000p_autosearch_start()
1136 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_autosearch_start()
1151 factor = BANDWIDTH_TO_KHZ(ch->bandwidth_hz); in dib7000p_autosearch_start()
1153 if (state->version == SOC7090) in dib7000p_autosearch_start()
1180 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_autosearch_is_irq()
1194 static s16 notch[] = { 16143, 14402, 12238, 9713, 6902, 3888, 759, -2392 }; in dib7000p_spur_protect()
1214 u32 xtal = state->cfg.bw->xtal_hz / 1000; in dib7000p_spur_protect()
1215 int f_rel = DIV_ROUND_CLOSEST(rf_khz, xtal) * xtal - rf_khz; in dib7000p_spur_protect()
1223 if (f_rel < -bw_khz / 2 || f_rel > bw_khz / 2) in dib7000p_spur_protect()
1237 coef_re[k] = sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1243 coef_re[k] = -sine[pha & 0xff]; in dib7000p_spur_protect()
1244 coef_im[k] = sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1246 coef_re[k] = -256; in dib7000p_spur_protect()
1249 coef_re[k] = -sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1250 coef_im[k] = -sine[pha & 0xff]; in dib7000p_spur_protect()
1253 coef_im[k] = -256; in dib7000p_spur_protect()
1256 coef_im[k] = -sine[256 - (pha & 0xff)]; in dib7000p_spur_protect()
1262 coef_re[k] = (1 << 24) - 1; in dib7000p_spur_protect()
1268 coef_im[k] = (1 << 24) - 1; in dib7000p_spur_protect()
1282 struct dtv_frontend_properties *ch = &demod->dtv_property_cache; in dib7000p_tune()
1283 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_tune()
1289 return -EINVAL; in dib7000p_tune()
1298 if (state->sfn_workaround_active) { in dib7000p_tune()
1307 // never achieved a lock with that bandwidth so far - wait for osc-freq to update in dib7000p_tune()
1308 if (state->timf == 0) in dib7000p_tune()
1315 switch (ch->transmission_mode) { in dib7000p_tune()
1331 switch (ch->transmission_mode) { in dib7000p_tune()
1347 switch (ch->transmission_mode) { in dib7000p_tune()
1370 // we achieved a lock - it's time to update the osc freq in dib7000p_tune()
1378 if (state->cfg.spur_protect) in dib7000p_tune()
1379 dib7000p_spur_protect(state, ch->frequency / 1000, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000p_tune()
1381 dib7000p_set_bandwidth(state, BANDWIDTH_TO_KHZ(ch->bandwidth_hz)); in dib7000p_tune()
1390 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_wakeup()
1393 if (state->version == SOC7090) in dib7000p_wakeup()
1400 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_sleep()
1401 if (state->version == SOC7090) in dib7000p_sleep()
1409 dprintk("checking demod on I2C address: %d (%x)\n", st->i2c_addr, st->i2c_addr); in dib7000p_identify()
1413 return -EREMOTEIO; in dib7000p_identify()
1418 return -EREMOTEIO; in dib7000p_identify()
1427 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_frontend()
1430 fep->inversion = INVERSION_AUTO; in dib7000p_get_frontend()
1432 fep->bandwidth_hz = BANDWIDTH_TO_HZ(state->current_bandwidth); in dib7000p_get_frontend()
1436 fep->transmission_mode = TRANSMISSION_MODE_2K; in dib7000p_get_frontend()
1439 fep->transmission_mode = TRANSMISSION_MODE_8K; in dib7000p_get_frontend()
1441 /* case 2: fep->transmission_mode = TRANSMISSION_MODE_4K; break; */ in dib7000p_get_frontend()
1446 fep->guard_interval = GUARD_INTERVAL_1_32; in dib7000p_get_frontend()
1449 fep->guard_interval = GUARD_INTERVAL_1_16; in dib7000p_get_frontend()
1452 fep->guard_interval = GUARD_INTERVAL_1_8; in dib7000p_get_frontend()
1455 fep->guard_interval = GUARD_INTERVAL_1_4; in dib7000p_get_frontend()
1461 fep->modulation = QPSK; in dib7000p_get_frontend()
1464 fep->modulation = QAM_16; in dib7000p_get_frontend()
1468 fep->modulation = QAM_64; in dib7000p_get_frontend()
1475 fep->hierarchy = HIERARCHY_NONE; in dib7000p_get_frontend()
1478 fep->code_rate_HP = FEC_1_2; in dib7000p_get_frontend()
1481 fep->code_rate_HP = FEC_2_3; in dib7000p_get_frontend()
1484 fep->code_rate_HP = FEC_3_4; in dib7000p_get_frontend()
1487 fep->code_rate_HP = FEC_5_6; in dib7000p_get_frontend()
1491 fep->code_rate_HP = FEC_7_8; in dib7000p_get_frontend()
1498 fep->code_rate_LP = FEC_1_2; in dib7000p_get_frontend()
1501 fep->code_rate_LP = FEC_2_3; in dib7000p_get_frontend()
1504 fep->code_rate_LP = FEC_3_4; in dib7000p_get_frontend()
1507 fep->code_rate_LP = FEC_5_6; in dib7000p_get_frontend()
1511 fep->code_rate_LP = FEC_7_8; in dib7000p_get_frontend()
1522 struct dtv_frontend_properties *fep = &fe->dtv_property_cache; in dib7000p_set_frontend()
1523 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_set_frontend()
1526 if (state->version == SOC7090) in dib7000p_set_frontend()
1532 state->sfn_workaround_active = buggy_sfn_workaround; in dib7000p_set_frontend()
1534 if (fe->ops.tuner_ops.set_params) in dib7000p_set_frontend()
1535 fe->ops.tuner_ops.set_params(fe); in dib7000p_set_frontend()
1538 state->agc_state = 0; in dib7000p_set_frontend()
1541 if (time != -1) in dib7000p_set_frontend()
1543 } while (time != -1); in dib7000p_set_frontend()
1545 if (fep->transmission_mode == TRANSMISSION_MODE_AUTO || in dib7000p_set_frontend()
1546 …fep->guard_interval == GUARD_INTERVAL_AUTO || fep->modulation == QAM_AUTO || fep->code_rate_HP == … in dib7000p_set_frontend()
1553 } while (found == 0 && i--); in dib7000p_set_frontend()
1565 if (state->version == SOC7090) { in dib7000p_set_frontend()
1566 dib7090_set_output_mode(fe, state->cfg.output_mode); in dib7000p_set_frontend()
1567 if (state->cfg.enMpegOutput == 0) { in dib7000p_set_frontend()
1572 dib7000p_set_output_mode(state, state->cfg.output_mode); in dib7000p_set_frontend()
1581 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_status()
1604 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_ber()
1611 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_unc_blocks()
1618 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_read_signal_strength()
1620 *strength = 65535 - val; in dib7000p_read_signal_strength()
1626 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_snr()
1637 noise_exp -= 0x40; in dib7000p_get_snr()
1642 signal_exp -= 0x40; in dib7000p_get_snr()
1647 result = intlog10(2) * 10 * signal_exp - 100; in dib7000p_get_snr()
1650 result -= intlog10(2) * 10 * noise_exp + 10 * intlog10(noise_mant); in dib7000p_get_snr()
1652 result -= intlog10(2) * 10 * noise_exp - 100; in dib7000p_get_snr()
1669 struct dib7000p_state *state = demod->demodulator_priv; in dib7000p_reset_stats()
1670 struct dtv_frontend_properties *c = &demod->dtv_property_cache; in dib7000p_reset_stats()
1673 memset(&c->strength, 0, sizeof(c->strength)); in dib7000p_reset_stats()
1674 memset(&c->cnr, 0, sizeof(c->cnr)); in dib7000p_reset_stats()
1675 memset(&c->post_bit_error, 0, sizeof(c->post_bit_error)); in dib7000p_reset_stats()
1676 memset(&c->post_bit_count, 0, sizeof(c->post_bit_count)); in dib7000p_reset_stats()
1677 memset(&c->block_error, 0, sizeof(c->block_error)); in dib7000p_reset_stats()
1679 c->strength.len = 1; in dib7000p_reset_stats()
1680 c->cnr.len = 1; in dib7000p_reset_stats()
1681 c->block_error.len = 1; in dib7000p_reset_stats()
1682 c->block_count.len = 1; in dib7000p_reset_stats()
1683 c->post_bit_error.len = 1; in dib7000p_reset_stats()
1684 c->post_bit_count.len = 1; in dib7000p_reset_stats()
1686 c->strength.stat[0].scale = FE_SCALE_DECIBEL; in dib7000p_reset_stats()
1687 c->strength.stat[0].uvalue = 0; in dib7000p_reset_stats()
1689 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1690 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1691 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1692 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1693 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in dib7000p_reset_stats()
1697 state->old_ucb = ucb; in dib7000p_reset_stats()
1698 state->ber_jiffies_stats = 0; in dib7000p_reset_stats()
1699 state->per_jiffies_stats = 0; in dib7000p_reset_stats()
1713 * by a DTA-2111 RF generator directly connected into a dib7000p device
1714 * (a Hauppauge Nova-TD stick), using a good quality 3 meters length
1716 * As the minimum output power of DTA-2111 is -31dBm, a 16 dBm attenuator
1721 * Yet, it is better to use this measure in dB than a random non-linear
1729 { 63630, DB_OFFSET - 20500},
1730 { 62273, DB_OFFSET - 21000},
1731 { 60162, DB_OFFSET - 22000},
1732 { 58730, DB_OFFSET - 23000},
1733 { 58294, DB_OFFSET - 24000},
1734 { 57778, DB_OFFSET - 25000},
1735 { 57320, DB_OFFSET - 26000},
1736 { 56779, DB_OFFSET - 27000},
1737 { 56293, DB_OFFSET - 28000},
1738 { 55724, DB_OFFSET - 29000},
1739 { 55145, DB_OFFSET - 30000},
1740 { 54680, DB_OFFSET - 31000},
1741 { 54293, DB_OFFSET - 32000},
1742 { 53813, DB_OFFSET - 33000},
1743 { 53427, DB_OFFSET - 34000},
1744 { 52981, DB_OFFSET - 35000},
1746 { 52636, DB_OFFSET - 36000},
1747 { 52014, DB_OFFSET - 37000},
1748 { 51674, DB_OFFSET - 38000},
1749 { 50692, DB_OFFSET - 39000},
1750 { 49824, DB_OFFSET - 40000},
1751 { 49052, DB_OFFSET - 41000},
1752 { 48436, DB_OFFSET - 42000},
1753 { 47836, DB_OFFSET - 43000},
1754 { 47368, DB_OFFSET - 44000},
1755 { 46468, DB_OFFSET - 45000},
1756 { 45597, DB_OFFSET - 46000},
1757 { 44586, DB_OFFSET - 47000},
1758 { 43667, DB_OFFSET - 48000},
1759 { 42673, DB_OFFSET - 49000},
1760 { 41816, DB_OFFSET - 50000},
1761 { 40876, DB_OFFSET - 51000},
1775 if (value < segments[len-1].x) in interpolate_value()
1776 return segments[len-1].y; in interpolate_value()
1778 for (i = 1; i < len - 1; i++) { in interpolate_value()
1787 dy = segments[i - 1].y - segments[i].y; in interpolate_value()
1788 dx = segments[i - 1].x - segments[i].x; in interpolate_value()
1790 tmp64 = value - segments[i].x; in interpolate_value()
1798 /* FIXME: may require changes - this one was borrowed from dib8000 */
1801 struct dtv_frontend_properties *c = &demod->dtv_property_cache; in dib7000p_get_time_us()
1807 switch (c->guard_interval) { in dib7000p_get_time_us()
1823 switch (c->transmission_mode) { in dib7000p_get_time_us()
1836 switch (c->modulation) { in dib7000p_get_time_us()
1850 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()
2046 dprintk("-D- DiB7000PC detected\n"); in dib7000pc_detection()
2050 dprintk("-D- DiB7000PC not detected\n"); in dib7000pc_detection()
2060 struct dib7000p_state *st = demod->demodulator_priv; in dib7000p_get_i2c_master()
2061 return dibx000_get_i2c_adapter(&st->i2c_master, intf, gating); in dib7000p_get_i2c_master()
2066 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_pid_filter_ctrl()
2075 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_pid_filter()
2088 return -ENOMEM; in dib7000p_i2c_enumeration()
2090 dpst->i2c_adap = i2c; in dib7000p_i2c_enumeration()
2091 mutex_init(&dpst->i2c_buffer_lock); in dib7000p_i2c_enumeration()
2093 for (k = no_of_demods - 1; k >= 0; k--) { in dib7000p_i2c_enumeration()
2094 dpst->cfg = cfg[k]; in dib7000p_i2c_enumeration()
2101 dpst->i2c_addr = new_addr; in dib7000p_i2c_enumeration()
2104 dpst->i2c_addr = default_addr; in dib7000p_i2c_enumeration()
2109 return -EIO; in dib7000p_i2c_enumeration()
2113 /* start diversity to pull_down div_str - just for i2c-enumeration */ in dib7000p_i2c_enumeration()
2123 dpst->cfg = cfg[k]; in dib7000p_i2c_enumeration()
2125 dpst->i2c_addr = (cfg[k].default_i2c_addr + k) << 1; in dib7000p_i2c_enumeration()
2127 dpst->i2c_addr = (0x40 + k) << 1; in dib7000p_i2c_enumeration()
2130 dib7000p_write_word(dpst, 1285, dpst->i2c_addr << 2); in dib7000p_i2c_enumeration()
2132 /* deactivate div - it was just for i2c-enumeration */ in dib7000p_i2c_enumeration()
2146 struct dib7000p_state *state = fe->demodulator_priv; in dib7000p_get_adc_power()
2164 ix = (u8) ((mant - 1000) / 100); /* index of the LUT */ in dib7000p_get_adc_power()
2167 pow_i = (lut_1000ln_mant[ix] + 693 * (exp - 20) - 6908); in dib7000p_get_adc_power()
2176 if ((msg->buf[0] <= 15)) in map_addr_to_serpar_number()
2177 msg->buf[0] -= 1; in map_addr_to_serpar_number()
2178 else if (msg->buf[0] == 17) in map_addr_to_serpar_number()
2179 msg->buf[0] = 15; in map_addr_to_serpar_number()
2180 else if (msg->buf[0] == 16) in map_addr_to_serpar_number()
2181 msg->buf[0] = 17; in map_addr_to_serpar_number()
2182 else if (msg->buf[0] == 19) in map_addr_to_serpar_number()
2183 msg->buf[0] = 16; in map_addr_to_serpar_number()
2184 else if (msg->buf[0] >= 21 && msg->buf[0] <= 25) in map_addr_to_serpar_number()
2185 msg->buf[0] -= 3; in map_addr_to_serpar_number()
2186 else if (msg->buf[0] == 28) in map_addr_to_serpar_number()
2187 msg->buf[0] = 23; in map_addr_to_serpar_number()
2189 return -EINVAL; in map_addr_to_serpar_number()
2202 i--; in w7090p_tuner_write_serpar()
2222 i--; in w7090p_tuner_read_serpar()
2231 i--; in w7090p_tuner_read_serpar()
2398 struct dib7000p_state *st = fe->demodulator_priv; in dib7090_get_i2c_tuner()
2399 return &st->dib7090_tuner_adap; in dib7090_get_i2c_tuner()
2441 if ((syncFreq & ((1 << quantif) - 1)) != 0) in dib7090_calcSyncFreq()
2447 syncFreq = syncFreq - 1; in dib7090_calcSyncFreq()
2516 if ((enSerialMode == 1) && (state->input_mode_mpeg == 1)) in dib7090_configMpegMux()
2579 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_set_diversity_in()
2583 case 0: /* only use the internal way - not the diversity input */ in dib7090_set_diversity_in()
2596 state->input_mode_mpeg = 1; in dib7090_set_diversity_in()
2602 state->input_mode_mpeg = 0; in dib7090_set_diversity_in()
2606 dib7000p_set_diversity_in(&state->demod, onoff); in dib7090_set_diversity_in()
2612 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_set_output_mode()
2682 if (state->cfg.output_mpeg2_in_188_bytes) in dib7090_set_output_mode()
2694 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_tuner_sleep()
2702 state->tuner_enable = en_cur_state; in dib7090_tuner_sleep()
2707 if (state->tuner_enable != 0) in dib7090_tuner_sleep()
2708 en_cur_state = state->tuner_enable; in dib7090_tuner_sleep()
2723 struct dib7000p_state *state = fe->demodulator_priv; in dib7090_slave_reset()
2742 memcpy(&st->cfg, cfg, sizeof(struct dib7000p_config)); in dib7000p_init()
2743 st->i2c_adap = i2c_adap; in dib7000p_init()
2744 st->i2c_addr = i2c_addr; in dib7000p_init()
2745 st->gpio_val = cfg->gpio_val; in dib7000p_init()
2746 st->gpio_dir = cfg->gpio_dir; in dib7000p_init()
2751 …if ((st->cfg.output_mode != OUTMODE_MPEG2_SERIAL) && (st->cfg.output_mode != OUTMODE_MPEG2_PAR_GAT… in dib7000p_init()
2752 st->cfg.output_mode = OUTMODE_MPEG2_FIFO; in dib7000p_init()
2754 demod = &st->demod; in dib7000p_init()
2755 demod->demodulator_priv = st; in dib7000p_init()
2756 memcpy(&st->demod.ops, &dib7000p_ops, sizeof(struct dvb_frontend_ops)); in dib7000p_init()
2757 mutex_init(&st->i2c_buffer_lock); in dib7000p_init()
2764 st->version = dib7000p_read_word(st, 897); in dib7000p_init()
2769 st->i2c_master.gated_tuner_i2c_adap.dev.parent = i2c_adap->dev.parent; in dib7000p_init()
2771 dibx000_init_i2c_master(&st->i2c_master, DIB7000P, st->i2c_adap, st->i2c_addr); in dib7000p_init()
2774 …strncpy(st->dib7090_tuner_adap.name, "DiB7090 tuner interface", sizeof(st->dib7090_tuner_adap.name… in dib7000p_init()
2775 st->dib7090_tuner_adap.algo = &dib7090_tuner_xfer_algo; in dib7000p_init()
2776 st->dib7090_tuner_adap.algo_data = NULL; in dib7000p_init()
2777 st->dib7090_tuner_adap.dev.parent = st->i2c_adap->dev.parent; in dib7000p_init()
2778 i2c_set_adapdata(&st->dib7090_tuner_adap, st); in dib7000p_init()
2779 i2c_add_adapter(&st->dib7090_tuner_adap); in dib7000p_init()
2785 if (st->version == SOC7090) { in dib7000p_init()
2786 dib7090_set_output_mode(demod, st->cfg.output_mode); in dib7000p_init()
2802 ops->slave_reset = dib7090_slave_reset; in dib7000p_attach()
2803 ops->get_adc_power = dib7090_get_adc_power; in dib7000p_attach()
2804 ops->dib7000pc_detection = dib7000pc_detection; in dib7000p_attach()
2805 ops->get_i2c_tuner = dib7090_get_i2c_tuner; in dib7000p_attach()
2806 ops->tuner_sleep = dib7090_tuner_sleep; in dib7000p_attach()
2807 ops->init = dib7000p_init; in dib7000p_attach()
2808 ops->set_agc1_min = dib7000p_set_agc1_min; in dib7000p_attach()
2809 ops->set_gpio = dib7000p_set_gpio; in dib7000p_attach()
2810 ops->i2c_enumeration = dib7000p_i2c_enumeration; in dib7000p_attach()
2811 ops->pid_filter = dib7000p_pid_filter; in dib7000p_attach()
2812 ops->pid_filter_ctrl = dib7000p_pid_filter_ctrl; in dib7000p_attach()
2813 ops->get_i2c_master = dib7000p_get_i2c_master; in dib7000p_attach()
2814 ops->update_pll = dib7000p_update_pll; in dib7000p_attach()
2815 ops->ctrl_timf = dib7000p_ctrl_timf; in dib7000p_attach()
2816 ops->get_agc_values = dib7000p_get_agc_values; in dib7000p_attach()
2817 ops->set_wbd_ref = dib7000p_set_wbd_ref; in dib7000p_attach()