Lines Matching +full:i2c +full:- +full:lt +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Linux-DVB Driver for DiBcom's DiB0090 base-band RF Tuner.
5 * Copyright (C) 2005-9 DiBcom (http://www.dibcom.fr/)
15 #include <linux/i2c.h>
90 #define MP008 0x6 /* Dual diversity VHF-UHF-LBAND */
91 #define MP009 0x7 /* Dual diversity 29098 CBAND-UHF-LBAND-SBAND */
124 struct i2c_adapter *i2c; member
135 s16 rf_gain_limit; /* take-over-point: where to split between bb and rf gain */
149 /* for the captrim/dc-offset search */
180 /* for the I2C transfer */
188 struct i2c_adapter *i2c; member
193 /* for the I2C transfer */
204 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib0090_read_reg()
209 state->i2c_write_buffer[0] = reg; in dib0090_read_reg()
211 memset(state->msg, 0, 2 * sizeof(struct i2c_msg)); in dib0090_read_reg()
212 state->msg[0].addr = state->config->i2c_address; in dib0090_read_reg()
213 state->msg[0].flags = 0; in dib0090_read_reg()
214 state->msg[0].buf = state->i2c_write_buffer; in dib0090_read_reg()
215 state->msg[0].len = 1; in dib0090_read_reg()
216 state->msg[1].addr = state->config->i2c_address; in dib0090_read_reg()
217 state->msg[1].flags = I2C_M_RD; in dib0090_read_reg()
218 state->msg[1].buf = state->i2c_read_buffer; in dib0090_read_reg()
219 state->msg[1].len = 2; in dib0090_read_reg()
221 if (i2c_transfer(state->i2c, state->msg, 2) != 2) { in dib0090_read_reg()
222 pr_warn("DiB0090 I2C read failed\n"); in dib0090_read_reg()
225 ret = (state->i2c_read_buffer[0] << 8) in dib0090_read_reg()
226 | state->i2c_read_buffer[1]; in dib0090_read_reg()
228 mutex_unlock(&state->i2c_buffer_lock); in dib0090_read_reg()
236 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib0090_write_reg()
238 return -EINVAL; in dib0090_write_reg()
241 state->i2c_write_buffer[0] = reg & 0xff; in dib0090_write_reg()
242 state->i2c_write_buffer[1] = val >> 8; in dib0090_write_reg()
243 state->i2c_write_buffer[2] = val & 0xff; in dib0090_write_reg()
245 memset(state->msg, 0, sizeof(struct i2c_msg)); in dib0090_write_reg()
246 state->msg[0].addr = state->config->i2c_address; in dib0090_write_reg()
247 state->msg[0].flags = 0; in dib0090_write_reg()
248 state->msg[0].buf = state->i2c_write_buffer; in dib0090_write_reg()
249 state->msg[0].len = 3; in dib0090_write_reg()
251 if (i2c_transfer(state->i2c, state->msg, 1) != 1) { in dib0090_write_reg()
252 pr_warn("DiB0090 I2C write failed\n"); in dib0090_write_reg()
253 ret = -EREMOTEIO; in dib0090_write_reg()
257 mutex_unlock(&state->i2c_buffer_lock); in dib0090_write_reg()
265 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib0090_fw_read_reg()
270 state->i2c_write_buffer[0] = reg; in dib0090_fw_read_reg()
272 memset(&state->msg, 0, sizeof(struct i2c_msg)); in dib0090_fw_read_reg()
273 state->msg.addr = reg; in dib0090_fw_read_reg()
274 state->msg.flags = I2C_M_RD; in dib0090_fw_read_reg()
275 state->msg.buf = state->i2c_read_buffer; in dib0090_fw_read_reg()
276 state->msg.len = 2; in dib0090_fw_read_reg()
277 if (i2c_transfer(state->i2c, &state->msg, 1) != 1) { in dib0090_fw_read_reg()
278 pr_warn("DiB0090 I2C read failed\n"); in dib0090_fw_read_reg()
281 ret = (state->i2c_read_buffer[0] << 8) in dib0090_fw_read_reg()
282 | state->i2c_read_buffer[1]; in dib0090_fw_read_reg()
284 mutex_unlock(&state->i2c_buffer_lock); in dib0090_fw_read_reg()
292 if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) { in dib0090_fw_write_reg()
294 return -EINVAL; in dib0090_fw_write_reg()
297 state->i2c_write_buffer[0] = val >> 8; in dib0090_fw_write_reg()
298 state->i2c_write_buffer[1] = val & 0xff; in dib0090_fw_write_reg()
300 memset(&state->msg, 0, sizeof(struct i2c_msg)); in dib0090_fw_write_reg()
301 state->msg.addr = reg; in dib0090_fw_write_reg()
302 state->msg.flags = 0; in dib0090_fw_write_reg()
303 state->msg.buf = state->i2c_write_buffer; in dib0090_fw_write_reg()
304 state->msg.len = 2; in dib0090_fw_write_reg()
305 if (i2c_transfer(state->i2c, &state->msg, 1) != 1) { in dib0090_fw_write_reg()
306 pr_warn("DiB0090 I2C write failed\n"); in dib0090_fw_write_reg()
307 ret = -EREMOTEIO; in dib0090_fw_write_reg()
311 mutex_unlock(&state->i2c_buffer_lock); in dib0090_fw_write_reg()
315 …D_RESET(state) do { if (cfg->reset) { if (cfg->sleep) cfg->sleep(fe, 0); msleep(10); cfg->reset…
316 #define ADC_TARGET -220
324 } while (--c); in dib0090_write_regs()
329 struct dib0090_state *state = fe->tuner_priv; in dib0090_identify()
331 struct dib0090_identity *identity = &state->identity; in dib0090_identify()
335 identity->p1g = 0; in dib0090_identify()
336 identity->in_soc = 0; in dib0090_identify()
343 identity->version = v & 0xff; in dib0090_identify()
344 identity->product = (v >> 8) & 0xf; in dib0090_identify()
346 if (identity->product != KROSUS) in dib0090_identify()
349 if ((identity->version & 0x3) == SOC) { in dib0090_identify()
350 identity->in_soc = 1; in dib0090_identify()
351 switch (identity->version) { in dib0090_identify()
353 dprintk("SOC 8090 P1-G11R1 Has been detected\n"); in dib0090_identify()
354 identity->p1g = 1; in dib0090_identify()
357 dprintk("SOC 8090 P1-G21R1 Has been detected\n"); in dib0090_identify()
358 identity->p1g = 1; in dib0090_identify()
361 dprintk("SOC 7090 P1-G11R1 Has been detected\n"); in dib0090_identify()
362 identity->p1g = 1; in dib0090_identify()
365 dprintk("SOC 7090 P1-G21R1 Has been detected\n"); in dib0090_identify()
366 identity->p1g = 1; in dib0090_identify()
372 switch ((identity->version >> 5) & 0x7) { in dib0090_identify()
380 dprintk("MP008 : diversity VHF-UHF-LBAND\n"); in dib0090_identify()
383 dprintk("MP009 : diversity 29098 CBAND-UHF-LBAND-SBAND\n"); in dib0090_identify()
389 switch (identity->version & 0x1f) { in dib0090_identify()
392 identity->p1g = 1; in dib0090_identify()
396 identity->p1g = 1; in dib0090_identify()
405 dprintk("P1-A/B detected: driver is deactivated - not available\n"); in dib0090_identify()
416 return -EIO; in dib0090_identify()
421 struct dib0090_fw_state *state = fe->tuner_priv; in dib0090_fw_identify()
422 struct dib0090_identity *identity = &state->identity; in dib0090_fw_identify()
425 identity->p1g = 0; in dib0090_fw_identify()
426 identity->in_soc = 0; in dib0090_fw_identify()
433 identity->version = v & 0xff; in dib0090_fw_identify()
434 identity->product = (v >> 8) & 0xf; in dib0090_fw_identify()
436 if (identity->product != KROSUS) in dib0090_fw_identify()
439 if ((identity->version & 0x3) == SOC) { in dib0090_fw_identify()
440 identity->in_soc = 1; in dib0090_fw_identify()
441 switch (identity->version) { in dib0090_fw_identify()
443 dprintk("SOC 8090 P1-G11R1 Has been detected\n"); in dib0090_fw_identify()
444 identity->p1g = 1; in dib0090_fw_identify()
447 dprintk("SOC 8090 P1-G21R1 Has been detected\n"); in dib0090_fw_identify()
448 identity->p1g = 1; in dib0090_fw_identify()
451 dprintk("SOC 7090 P1-G11R1 Has been detected\n"); in dib0090_fw_identify()
452 identity->p1g = 1; in dib0090_fw_identify()
455 dprintk("SOC 7090 P1-G21R1 Has been detected\n"); in dib0090_fw_identify()
456 identity->p1g = 1; in dib0090_fw_identify()
462 switch ((identity->version >> 5) & 0x7) { in dib0090_fw_identify()
470 dprintk("MP008 : diversity VHF-UHF-LBAND\n"); in dib0090_fw_identify()
473 dprintk("MP009 : diversity 29098 CBAND-UHF-LBAND-SBAND\n"); in dib0090_fw_identify()
479 switch (identity->version & 0x1f) { in dib0090_fw_identify()
482 identity->p1g = 1; in dib0090_fw_identify()
486 identity->p1g = 1; in dib0090_fw_identify()
495 dprintk("P1-A/B detected: driver is deactivated - not available\n"); in dib0090_fw_identify()
506 return -EIO; in dib0090_fw_identify()
511 struct dib0090_state *state = fe->tuner_priv; in dib0090_reset_digital()
516 if (cfg->in_soc) in dib0090_reset_digital()
520 /* adcClkOutRatio=8->7, release reset */ in dib0090_reset_digital()
521 …dib0090_write_reg(state, 0x20, ((cfg->io.adc_clock_ratio - 1) << 11) | (0 << 10) | (1 << 9) | (1 <… in dib0090_reset_digital()
522 if (cfg->clkoutdrive != 0) in dib0090_reset_digital()
523 …dib0090_write_reg(state, 0x23, (0 << 15) | ((!cfg->analog_output) << 14) | (2 << 10) | (1 << 9) | … in dib0090_reset_digital()
524 | (cfg->clkoutdrive << 5) | (cfg->clkouttobamse << 4) | (0 << 2) | (0)); in dib0090_reset_digital()
526 …dib0090_write_reg(state, 0x23, (0 << 15) | ((!cfg->analog_output) << 14) | (2 << 10) | (1 << 9) | … in dib0090_reset_digital()
527 | (7 << 5) | (cfg->clkouttobamse << 4) | (0 << 2) | (0)); in dib0090_reset_digital()
533 …if ((PllCfg & 0x1FFF) != ((cfg->io.pll_range << 12) | (cfg->io.pll_loopdiv << 6) | (cfg->io.pll_pr… in dib0090_reset_digital()
534 && !cfg->io.pll_bypass) { in dib0090_reset_digital()
545 …PllCfg = (1 << 15) | (0 << 13) | (cfg->io.pll_range << 12) | (cfg->io.pll_loopdiv << 6) | (cfg->io… in dib0090_reset_digital()
558 } while (--i); in dib0090_reset_digital()
570 if (cfg->io.pll_bypass) { in dib0090_reset_digital()
571 PllCfg |= (cfg->io.pll_bypass << 15); in dib0090_reset_digital()
578 struct dib0090_fw_state *state = fe->tuner_priv; in dib0090_fw_reset_digital()
590 …((cfg->io.adc_clock_ratio - 1) << 11) | (0 << 10) | (1 << 9) | (1 << 8) | (cfg->data_tx_drv << 4) … in dib0090_fw_reset_digital()
592 …v = (0 << 15) | ((!cfg->analog_output) << 14) | (1 << 9) | (0 << 8) | (cfg->clkouttobamse << 4) | … in dib0090_fw_reset_digital()
593 if (cfg->clkoutdrive != 0) in dib0090_fw_reset_digital()
594 v |= cfg->clkoutdrive << 5; in dib0090_fw_reset_digital()
605 …if ((PllCfg & 0x1FFF) != ((cfg->io.pll_range << 12) | (cfg->io.pll_loopdiv << 6) | (cfg->io.pll_pr… in dib0090_fw_reset_digital()
616 …PllCfg = (1 << 15) | (0 << 13) | (cfg->io.pll_range << 12) | (cfg->io.pll_loopdiv << 6) | (cfg->io… in dib0090_fw_reset_digital()
629 } while (--i); in dib0090_fw_reset_digital()
633 return -EIO; in dib0090_fw_reset_digital()
641 if (cfg->io.pll_bypass) { in dib0090_fw_reset_digital()
642 PllCfg |= (cfg->io.pll_bypass << 15); in dib0090_fw_reset_digital()
651 struct dib0090_state *state = fe->tuner_priv; in dib0090_wakeup()
652 if (state->config->sleep) in dib0090_wakeup()
653 state->config->sleep(fe, 0); in dib0090_wakeup()
655 /* enable dataTX in case we have been restarted in the wrong moment */ in dib0090_wakeup()
662 struct dib0090_state *state = fe->tuner_priv; in dib0090_sleep()
663 if (state->config->sleep) in dib0090_sleep()
664 state->config->sleep(fe, 1); in dib0090_sleep()
670 struct dib0090_state *state = fe->tuner_priv; in dib0090_dcc_freq()
681 (1<<9) | 8, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> BB_RAMP2 */
691 18, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
705 40, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
719 40, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
733 29, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
747 13, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
761 26, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
776 8, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> BB_RAMP2 */
788 8, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> BB_RAMP2 */
799 33, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
813 24, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
827 24, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
843 38, /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> RF_RAMP2 */
871 val -= rest; in slopes_to_scale()
877 {66, 120}, /* -64,-52: offset - 65 */
878 {600, 170}, /* -52,-35: 65 - 665 */
879 {170, 250}, /* -45,-10: 665 - 835 */
885 if (wbd < state->wbd_offset) in dib0090_wbd_to_db()
888 wbd -= state->wbd_offset; in dib0090_wbd_to_db()
889 /* -64dB is the floor */ in dib0090_wbd_to_db()
890 return -640 + (s16) slopes_to_scale(dib0090_wbd_slopes, ARRAY_SIZE(dib0090_wbd_slopes), wbd); in dib0090_wbd_to_db()
897 /* TODO : DAB digital N+/-1 interferer perfs : offset = 10 */ in dib0090_wbd_target()
899 if (state->current_band == BAND_VHF) in dib0090_wbd_target()
902 if (state->current_band == BAND_VHF) in dib0090_wbd_target()
903 offset = state->config->wbd_vhf_offset; in dib0090_wbd_target()
904 if (state->current_band == BAND_CBAND) in dib0090_wbd_target()
905 offset = state->config->wbd_cband_offset; in dib0090_wbd_target()
908 state->wbd_target = dib0090_wbd_to_db(state, state->wbd_offset + offset); in dib0090_wbd_target()
909 dprintk("wbd-target: %d dB\n", (u32) state->wbd_target); in dib0090_wbd_target()
922 if (top_delta < -511) in dib0090_gain_apply()
923 top_delta = -511; in dib0090_gain_apply()
932 if (top_delta >= ((s16) (state->rf_ramp[0] << WBD_ALPHA) - state->rf_gain_limit)) /* overflow */ in dib0090_gain_apply()
933 state->rf_gain_limit = state->rf_ramp[0] << WBD_ALPHA; in dib0090_gain_apply()
935 state->rf_gain_limit += top_delta; in dib0090_gain_apply()
937 if (state->rf_gain_limit < 0) /*underflow */ in dib0090_gain_apply()
938 state->rf_gain_limit = 0; in dib0090_gain_apply()
941 gain = ((state->rf_gain_limit >> WBD_ALPHA) + state->bb_ramp[0]) << GAIN_ALPHA; in dib0090_gain_apply()
942 if (gain_delta >= ((s16) gain - state->current_gain)) /* overflow */ in dib0090_gain_apply()
943 state->current_gain = gain; in dib0090_gain_apply()
945 state->current_gain += gain_delta; in dib0090_gain_apply()
947 if (state->current_gain < 0) in dib0090_gain_apply()
948 state->current_gain = 0; in dib0090_gain_apply()
951 gain = state->current_gain >> GAIN_ALPHA; in dib0090_gain_apply()
953 /* requested gain is bigger than rf gain limit - ACI/WBD adjustment */ in dib0090_gain_apply()
954 if (gain > (state->rf_gain_limit >> WBD_ALPHA)) { in dib0090_gain_apply()
955 rf = state->rf_gain_limit >> WBD_ALPHA; in dib0090_gain_apply()
956 bb = gain - rf; in dib0090_gain_apply()
957 if (bb > state->bb_ramp[0]) in dib0090_gain_apply()
958 bb = state->bb_ramp[0]; in dib0090_gain_apply()
959 } else { /* high signal level -> all gains put on RF */ in dib0090_gain_apply()
964 state->gain[0] = rf; in dib0090_gain_apply()
965 state->gain[1] = bb; in dib0090_gain_apply()
969 g = state->rf_ramp + 1; /* point on RF LNA1 max gain */ in dib0090_gain_apply()
972 …if (g[0] == 0 || ref < (g[1] - g[0])) /* if total gain of the current amp is null or this amp is n… in dib0090_gain_apply()
977 v = ((ref - (g[1] - g[0])) * g[2]) / g[0]; in dib0090_gain_apply()
988 gain_reg[2] = v | state->rf_lt_def; in dib0090_gain_apply()
998 g = state->bb_ramp + 1; /* point on BB gain 1 max gain */ in dib0090_gain_apply()
1002 gain_reg[3] |= state->bb_1_def; in dib0090_gain_apply()
1013 if (force || state->gain_reg[i] != v) { in dib0090_gain_apply()
1014 state->gain_reg[i] = v; in dib0090_gain_apply()
1022 state->bb_1_def &= 0xdfff; in dib0090_set_boost()
1023 state->bb_1_def |= onoff << 13; in dib0090_set_boost()
1028 state->rf_ramp = cfg; in dib0090_set_rframp()
1033 state->rf_ramp = cfg; in dib0090_set_rframp_pwm()
1045 state->bb_ramp = cfg; in dib0090_set_bbramp()
1051 state->bb_ramp = cfg; in dib0090_set_bbramp_pwm()
1062 struct dib0090_state *state = fe->tuner_priv; in dib0090_pwm_gain_reset()
1068 if (state->config->use_pwm_agc) { in dib0090_pwm_gain_reset()
1069 if (state->current_band == BAND_CBAND) { in dib0090_pwm_gain_reset()
1070 if (state->identity.in_soc) { in dib0090_pwm_gain_reset()
1072 … if (state->identity.version == SOC_8090_P1G_11R1 || state->identity.version == SOC_8090_P1G_21R1) in dib0090_pwm_gain_reset()
1074 …else if (state->identity.version == SOC_7090_P1G_11R1 || state->identity.version == SOC_7090_P1G_2… in dib0090_pwm_gain_reset()
1075 if (state->config->is_dib7090e) { in dib0090_pwm_gain_reset()
1076 if (state->rf_ramp == NULL) in dib0090_pwm_gain_reset()
1079 rf_ramp = state->rf_ramp; in dib0090_pwm_gain_reset()
1087 if (state->current_band == BAND_VHF) { in dib0090_pwm_gain_reset()
1088 if (state->identity.in_soc) { in dib0090_pwm_gain_reset()
1093 } else if (state->current_band == BAND_UHF) { in dib0090_pwm_gain_reset()
1094 if (state->identity.in_soc) { in dib0090_pwm_gain_reset()
1096 … if (state->identity.version == SOC_8090_P1G_11R1 || state->identity.version == SOC_8090_P1G_21R1) in dib0090_pwm_gain_reset()
1098 …else if (state->identity.version == SOC_7090_P1G_11R1 || state->identity.version == SOC_7090_P1G_2… in dib0090_pwm_gain_reset()
1108 if (state->rf_ramp) in dib0090_pwm_gain_reset()
1110 state->rf_ramp[0], in dib0090_pwm_gain_reset()
1111 (state->current_band == BAND_CBAND) ? "CBAND" : "NOT CBAND", in dib0090_pwm_gain_reset()
1112 state->identity.version & 0x1f); in dib0090_pwm_gain_reset()
1114 if (rf_ramp && ((state->rf_ramp && state->rf_ramp[0] == 0) || in dib0090_pwm_gain_reset()
1115 (state->current_band == BAND_CBAND && in dib0090_pwm_gain_reset()
1116 (state->identity.version & 0x1f) <= P1D_E_F))) { in dib0090_pwm_gain_reset()
1117 dprintk("DE-Engage mux for direct gain reg control\n"); in dib0090_pwm_gain_reset()
1125 if (state->identity.version == SOC_7090_P1G_11R1 || state->identity.version == SOC_7090_P1G_21R1) in dib0090_pwm_gain_reset()
1136 struct dib0090_state *state = fe->tuner_priv; in dib0090_set_dc_servo()
1145 if (state->identity.in_soc) in dib0090_get_slow_adc_val()
1152 struct dib0090_state *state = fe->tuner_priv; in dib0090_gain_control()
1153 enum frontend_tune_state *tune_state = &state->tune_state; in dib0090_gain_control()
1161 state->agc_freeze = 0; in dib0090_gain_control()
1165 if (state->current_band == BAND_SBAND) { in dib0090_gain_control()
1171 if (state->current_band == BAND_VHF && !state->identity.p1g) { in dib0090_gain_control()
1177 if (state->current_band == BAND_CBAND && !state->identity.p1g) { in dib0090_gain_control()
1182 …if ((state->current_band == BAND_CBAND || state->current_band == BAND_VHF) && state->identity.p1g)… in dib0090_gain_control()
1193 dib0090_wbd_target(state, state->current_rf); in dib0090_gain_control()
1195 state->rf_gain_limit = state->rf_ramp[0] << WBD_ALPHA; in dib0090_gain_control()
1196 state->current_gain = ((state->rf_ramp[0] + state->bb_ramp[0]) / 2) << GAIN_ALPHA; in dib0090_gain_control()
1199 } else if (!state->agc_freeze) { in dib0090_gain_control()
1215 wbd_error = state->wbd_target - wbd; in dib0090_gain_control()
1218 if (wbd_error < 0 && state->rf_gain_limit > 0 && !state->identity.p1g) { in dib0090_gain_control()
1221 u8 ltg2 = (state->rf_lt_def >> 10) & 0x7; in dib0090_gain_control()
1222 if (state->current_band == BAND_CBAND && ltg2) { in dib0090_gain_control()
1224 state->rf_lt_def &= ltg2 << 10; /* reduce in 3 steps from 7 to 0 */ in dib0090_gain_control()
1228 state->agc_step = 0; in dib0090_gain_control()
1233 adc = state->config->get_adc_power(fe); in dib0090_gain_control()
1234 adc = (adc * ((s32) 355774) + (((s32) 1) << 20)) >> 21; /* included in [0:-700] */ in dib0090_gain_control()
1236 adc_error = (s16) (((s32) ADC_TARGET) - adc); in dib0090_gain_control()
1238 if (state->fe->dtv_property_cache.delivery_system == STANDARD_DAB) in dib0090_gain_control()
1239 adc_error -= 10; in dib0090_gain_control()
1242 if (state->fe->dtv_property_cache.delivery_system == STANDARD_DVBT && in dib0090_gain_control()
1243 …(state->fe->dtv_property_cache.modulation == QAM_64 || state->fe->dtv_property_cache.modulation ==… in dib0090_gain_control()
1247 …if ((state->fe->dtv_property_cache.delivery_system == SYS_ISDBT) && (((state->fe->dtv_property_cac… in dib0090_gain_control()
1250 ((state->fe->dtv_property_cache.layer[0].modulation == in dib0090_gain_control()
1252 || (state->fe->dtv_property_cache. in dib0090_gain_control()
1255 ((state->fe->dtv_property_cache.layer[1].segment_count > in dib0090_gain_control()
1258 ((state->fe->dtv_property_cache.layer[1].modulation == in dib0090_gain_control()
1260 || (state->fe->dtv_property_cache. in dib0090_gain_control()
1263 ((state->fe->dtv_property_cache.layer[2].segment_count > in dib0090_gain_control()
1266 ((state->fe->dtv_property_cache.layer[2].modulation == in dib0090_gain_control()
1268 || (state->fe->dtv_property_cache. in dib0090_gain_control()
1276 if (abs(adc_error) < 50 || state->agc_step++ > 5) { in dib0090_gain_control()
1279 if (state->fe->dtv_property_cache.delivery_system == STANDARD_DAB) { in dib0090_gain_control()
1301 (u32) state->rf_gain_limit >> WBD_ALPHA, (s32) 200 + adc - (state->current_gain >> GAIN_ALPHA)); in dib0090_gain_control()
1306 if (!state->agc_freeze) in dib0090_gain_control()
1315 struct dib0090_state *state = fe->tuner_priv; in dib0090_get_current_gain()
1317 *rf = state->gain[0]; in dib0090_get_current_gain()
1319 *bb = state->gain[1]; in dib0090_get_current_gain()
1321 *rf_gain_limit = state->rf_gain_limit; in dib0090_get_current_gain()
1323 *rflt = (state->rf_lt_def >> 10) & 0x7; in dib0090_get_current_gain()
1330 struct dib0090_state *state = fe->tuner_priv; in dib0090_get_wbd_target()
1331 u32 f_MHz = state->fe->dtv_property_cache.frequency / 1000000; in dib0090_get_wbd_target()
1332 s32 current_temp = state->temperature; in dib0090_get_wbd_target()
1334 const struct dib0090_wbd_slope *wbd = state->current_wbd_table; in dib0090_get_wbd_target()
1336 while (f_MHz > wbd->max_freq) in dib0090_get_wbd_target()
1339 dprintk("using wbd-table-entry with max freq %d\n", wbd->max_freq); in dib0090_get_wbd_target()
1346 state->wbdmux &= ~(7 << 13); in dib0090_get_wbd_target()
1347 if (wbd->wbd_gain != 0) in dib0090_get_wbd_target()
1348 state->wbdmux |= (wbd->wbd_gain << 13); in dib0090_get_wbd_target()
1350 state->wbdmux |= (4 << 13); in dib0090_get_wbd_target()
1352 dib0090_write_reg(state, 0x10, state->wbdmux); in dib0090_get_wbd_target()
1354 wbd_thot = wbd->offset_hot - (((u32) wbd->slope_hot * f_MHz) >> 6); in dib0090_get_wbd_target()
1355 wbd_tcold = wbd->offset_cold - (((u32) wbd->slope_cold * f_MHz) >> 6); in dib0090_get_wbd_target()
1357 wbd_tcold += ((wbd_thot - wbd_tcold) * current_temp) >> 7; in dib0090_get_wbd_target()
1359 state->wbd_target = dib0090_wbd_to_db(state, state->wbd_offset + wbd_tcold); in dib0090_get_wbd_target()
1360 dprintk("wbd-target: %d dB\n", (u32) state->wbd_target); in dib0090_get_wbd_target()
1363 return state->wbd_offset + wbd_tcold; in dib0090_get_wbd_target()
1369 struct dib0090_state *state = fe->tuner_priv; in dib0090_get_wbd_offset()
1370 return state->wbd_offset; in dib0090_get_wbd_offset()
1376 struct dib0090_state *state = fe->tuner_priv; in dib0090_set_switch()
1387 struct dib0090_state *state = fe->tuner_priv; in dib0090_set_vga()
1397 struct dib0090_state *state = fe->tuner_priv; in dib0090_update_rframp_7090()
1399 if ((!state->identity.p1g) || (!state->identity.in_soc) in dib0090_update_rframp_7090()
1400 || ((state->identity.version != SOC_7090_P1G_21R1) in dib0090_update_rframp_7090()
1401 && (state->identity.version != SOC_7090_P1G_11R1))) { in dib0090_update_rframp_7090()
1403 return -ENODEV; in dib0090_update_rframp_7090()
1407 state->rf_ramp = rf_ramp_pwm_cband_7090e_sensitivity; in dib0090_update_rframp_7090()
1409 state->rf_ramp = rf_ramp_pwm_cband_7090e_aci; in dib0090_update_rframp_7090()
1489 } while (--l); in dib0090_set_default_config()
1510 if ((state->identity.version == P1D_E_F) || in dib0090_set_EFUSE()
1511 (state->identity.version == P1G) || (e2 == 0xffff)) { in dib0090_set_EFUSE()
1518 n = 165 - ((cal * 10)>>6) ; in dib0090_set_EFUSE()
1547 struct dib0090_state *state = fe->tuner_priv; in dib0090_reset()
1549 dib0090_reset_digital(fe, state->config); in dib0090_reset()
1551 return -EIO; in dib0090_reset()
1554 if (!(state->identity.version & 0x1)) /* it is P1B - reset is already done */ in dib0090_reset()
1558 if (!state->identity.in_soc) { in dib0090_reset()
1567 if (state->identity.in_soc) in dib0090_reset()
1570 if (state->identity.p1g) in dib0090_reset()
1574 if (((state->identity.version & 0x1f) >= P1D_E_F) || (state->identity.in_soc)) in dib0090_reset()
1578 if (state->config->force_crystal_mode != 0) in dib0090_reset()
1580 state->config->force_crystal_mode & 3); in dib0090_reset()
1581 else if (state->config->io.clock_khz >= 24000) in dib0090_reset()
1587 …state->calibrate = DC_CAL | WBD_CAL | TEMP_CAL; /* enable iq-offset-calibration and wbd-calibratio… in dib0090_reset()
1592 #define steps(u) (((u) > 15) ? ((u)-16) : (u))
1606 state->adc_diff = dib0090_read_reg(state, 0x1d); in dib0090_get_offset()
1614 state->adc_diff -= dib0090_read_reg(state, 0x1d); in dib0090_get_offset()
1659 if (state->dc->addr == 0x07) in dib0090_set_trim()
1660 val = &state->bb7; in dib0090_set_trim()
1662 val = &state->bb6; in dib0090_set_trim()
1664 *val &= ~(0x1f << state->dc->offset); in dib0090_set_trim()
1665 *val |= state->step << state->dc->offset; in dib0090_set_trim()
1667 dib0090_write_reg(state, state->dc->addr, *val); in dib0090_set_trim()
1680 state->bb6 = 0; in dib0090_dc_offset_calibration()
1681 state->bb7 = 0x040d; in dib0090_dc_offset_calibration()
1687 state->wbdmux = dib0090_read_reg(state, 0x10); in dib0090_dc_offset_calibration()
1688 dib0090_write_reg(state, 0x10, (state->wbdmux & ~(0xff << 3)) | (0x7 << 3) | 0x3); in dib0090_dc_offset_calibration()
1691 state->dc = dc_table; in dib0090_dc_offset_calibration()
1693 if (state->identity.p1g) in dib0090_dc_offset_calibration()
1694 state->dc = dc_p1g_table; in dib0090_dc_offset_calibration()
1699 (state->dc->i == 1) ? "I" : "Q"); in dib0090_dc_offset_calibration()
1700 dib0090_write_reg(state, 0x01, state->dc->bb1); in dib0090_dc_offset_calibration()
1701 dib0090_write_reg(state, 0x07, state->bb7 | (state->dc->i << 7)); in dib0090_dc_offset_calibration()
1703 state->step = 0; in dib0090_dc_offset_calibration()
1704 state->min_adc_diff = 1023; in dib0090_dc_offset_calibration()
1721 dprintk("adc_diff = %d, current step= %d\n", (u32) state->adc_diff, state->step); in dib0090_dc_offset_calibration()
1722 if (state->step == 0 && state->adc_diff < 0) { in dib0090_dc_offset_calibration()
1723 state->min_adc_diff = -1023; in dib0090_dc_offset_calibration()
1727 …_diff = %d, min_adc_diff = %d current_step = %d\n", state->adc_diff, state->min_adc_diff, state->s… in dib0090_dc_offset_calibration()
1730 if (state->step == 0) { in dib0090_dc_offset_calibration()
1731 if (state->dc->pga && state->adc_diff < 0) in dib0090_dc_offset_calibration()
1732 state->step = 0x10; in dib0090_dc_offset_calibration()
1733 if (state->dc->pga == 0 && state->adc_diff > 0) in dib0090_dc_offset_calibration()
1734 state->step = 0x10; in dib0090_dc_offset_calibration()
1737 /* Look for a change of Sign in the Adc_diff.min_adc_diff is used to STORE the setp N-1 */ in dib0090_dc_offset_calibration()
1738 if ((state->adc_diff & 0x8000) == (state->min_adc_diff & 0x8000) && steps(state->step) < 15) { in dib0090_dc_offset_calibration()
1740 state->step++; in dib0090_dc_offset_calibration()
1741 state->min_adc_diff = state->adc_diff; in dib0090_dc_offset_calibration()
1745 if (abs(state->adc_diff) > abs(state->min_adc_diff)) { in dib0090_dc_offset_calibration()
1746 …dprintk("Since adc_diff N = %d > adc_diff step N-1 = %d, Come back one step\n", state->adc_diff, … in dib0090_dc_offset_calibration()
1747 state->step--; in dib0090_dc_offset_calibration()
1752 state->dc->addr, state->adc_diff, state->step); in dib0090_dc_offset_calibration()
1754 state->dc++; in dib0090_dc_offset_calibration()
1755 if (state->dc->addr == 0) /* done */ in dib0090_dc_offset_calibration()
1764 dib0090_write_reg(state, 0x07, state->bb7 & ~0x0008); in dib0090_dc_offset_calibration()
1766 *tune_state = CT_TUNER_START; /* reset done -> real tuning can now begin */ in dib0090_dc_offset_calibration()
1767 state->calibrate &= ~DC_CAL; in dib0090_dc_offset_calibration()
1779 const struct dib0090_wbd_slope *wbd = state->current_wbd_table; in dib0090_wbd_calibration()
1783 while (state->current_rf / 1000 > wbd->max_freq) in dib0090_wbd_calibration()
1785 if (wbd->wbd_gain != 0) in dib0090_wbd_calibration()
1786 wbd_gain = wbd->wbd_gain; in dib0090_wbd_calibration()
1790 if ((state->current_band == BAND_LBAND) || (state->current_band == BAND_SBAND)) in dib0090_wbd_calibration()
1795 if (wbd_gain == state->wbd_calibration_gain) { /* the WBD calibration has already been done */ in dib0090_wbd_calibration()
1797 state->calibrate &= ~WBD_CAL; in dib0090_wbd_calibration()
1805 state->wbd_calibration_gain = wbd_gain; in dib0090_wbd_calibration()
1809 state->wbd_offset = dib0090_get_slow_adc_val(state); in dib0090_wbd_calibration()
1810 dprintk("WBD calibration offset = %d\n", state->wbd_offset); in dib0090_wbd_calibration()
1811 *tune_state = CT_TUNER_START; /* reset done -> real tuning can now begin */ in dib0090_wbd_calibration()
1812 state->calibrate &= ~WBD_CAL; in dib0090_wbd_calibration()
1825 if (state->fe->dtv_property_cache.bandwidth_hz / 1000 <= 5000) in dib0090_set_bandwidth()
1827 else if (state->fe->dtv_property_cache.bandwidth_hz / 1000 <= 6000) in dib0090_set_bandwidth()
1829 else if (state->fe->dtv_property_cache.bandwidth_hz / 1000 <= 7000) in dib0090_set_bandwidth()
1834 state->bb_1_def &= 0x3fff; in dib0090_set_bandwidth()
1835 state->bb_1_def |= tmp; in dib0090_set_bandwidth()
1837 dib0090_write_reg(state, 0x01, state->bb_1_def); /* be sure that we have the right bb-filter */ in dib0090_set_bandwidth()
1841 if (state->identity.in_soc) { in dib0090_set_bandwidth()
2043 struct dib0090_state *state = fe->tuner_priv; in dib0090_update_tuning_table_7090()
2052 if ((!state->identity.p1g) || (!state->identity.in_soc) in dib0090_update_tuning_table_7090()
2053 || ((state->identity.version != SOC_7090_P1G_21R1) in dib0090_update_tuning_table_7090()
2054 && (state->identity.version != SOC_7090_P1G_11R1))) { in dib0090_update_tuning_table_7090()
2056 return -ENODEV; in dib0090_update_tuning_table_7090()
2064 while (state->rf_request > tune->max_freq) in dib0090_update_tuning_table_7090()
2068 | (tune->lna_bias & 0x7fff)); in dib0090_update_tuning_table_7090()
2070 | ((tune->lna_tune << 6) & 0x07c0)); in dib0090_update_tuning_table_7090()
2085 if (state->identity.version == SOC_8090_P1G_11R1 || state->identity.version == SOC_8090_P1G_21R1) in dib0090_captrim_search()
2094 if (!state->tuner_is_tuned) { in dib0090_captrim_search()
2096 if (!state->identity.p1g || force_soft_search) in dib0090_captrim_search()
2097 state->step = state->captrim = state->fcaptrim = 64; in dib0090_captrim_search()
2099 state->current_rf = state->rf_request; in dib0090_captrim_search()
2100 } else { /* we are already tuned to this frequency - the configuration is correct */ in dib0090_captrim_search()
2101 if (!state->identity.p1g || force_soft_search) { in dib0090_captrim_search()
2103 state->step = 4; in dib0090_captrim_search()
2104 state->captrim = state->fcaptrim = dib0090_read_reg(state, 0x18) & 0x7f; in dib0090_captrim_search()
2107 state->adc_diff = 3000; in dib0090_captrim_search()
2111 if (state->identity.p1g && !force_soft_search) { in dib0090_captrim_search()
2118 state->step /= 2; in dib0090_captrim_search()
2119 dib0090_write_reg(state, 0x18, lo4 | state->captrim); in dib0090_captrim_search()
2121 if (state->identity.in_soc) in dib0090_captrim_search()
2127 if (state->identity.p1g && !force_soft_search) { in dib0090_captrim_search()
2131 state->fcaptrim = dib0090_read_reg(state, 0x18) & 0x7F; in dib0090_captrim_search()
2132 dprintk("***Final Captrim= 0x%x\n", state->fcaptrim); in dib0090_captrim_search()
2138 …dprintk("CAPTRIM=%d; ADC = %d (ADC) & %dmV\n", (u32) state->captrim, (u32) adc, (u32) (adc) * (u32… in dib0090_captrim_search()
2140 …if (state->rest == 0 || state->identity.in_soc) { /* Just for 8090P SOCS where auto captrim HW bug… in dib0090_captrim_search()
2146 adc -= adc_target; in dib0090_captrim_search()
2147 step_sign = -1; in dib0090_captrim_search()
2149 adc = adc_target - adc; in dib0090_captrim_search()
2153 if (adc < state->adc_diff) { in dib0090_captrim_search()
2154 …ntk("CAPTRIM=%d is closer to target (%d/%d)\n", (u32) state->captrim, (u32) adc, (u32) state->adc_… in dib0090_captrim_search()
2155 state->adc_diff = adc; in dib0090_captrim_search()
2156 state->fcaptrim = state->captrim; in dib0090_captrim_search()
2159 state->captrim += step_sign * state->step; in dib0090_captrim_search()
2160 if (state->step >= 1) in dib0090_captrim_search()
2169 dib0090_write_reg(state, 0x18, lo4 | state->fcaptrim); in dib0090_captrim_search()
2174 state->calibrate &= ~CAPTRIM_CAL; in dib0090_captrim_search()
2188 state->wbdmux = dib0090_read_reg(state, 0x10); in dib0090_get_temperature()
2189 dib0090_write_reg(state, 0x10, (state->wbdmux & ~(0xff << 3)) | (0x8 << 3)); in dib0090_get_temperature()
2191 state->bias = dib0090_read_reg(state, 0x13); in dib0090_get_temperature()
2192 dib0090_write_reg(state, 0x13, state->bias | (0x3 << 8)); in dib0090_get_temperature()
2199 state->adc_diff = dib0090_get_slow_adc_val(state); in dib0090_get_temperature()
2200 dib0090_write_reg(state, 0x13, (state->bias & ~(0x3 << 8)) | (0x2 << 8)); in dib0090_get_temperature()
2206 state->temperature = ((s16) ((val - state->adc_diff) * 180) >> 8) + 55; in dib0090_get_temperature()
2208 dprintk("temperature: %d C\n", state->temperature - 30); in dib0090_get_temperature()
2214 dib0090_write_reg(state, 0x13, state->bias); in dib0090_get_temperature()
2215 dib0090_write_reg(state, 0x10, state->wbdmux); /* write back original WBDMUX */ in dib0090_get_temperature()
2218 state->calibrate &= ~TEMP_CAL; in dib0090_get_temperature()
2219 if (state->config->analog_output == 0) in dib0090_get_temperature()
2234 struct dib0090_state *state = fe->tuner_priv; in dib0090_tune()
2235 const struct dib0090_tuning *tune = state->current_tune_table_index; in dib0090_tune()
2236 const struct dib0090_pll *pll = state->current_pll_table_index; in dib0090_tune()
2237 enum frontend_tune_state *tune_state = &state->tune_state; in dib0090_tune()
2252 if (state->calibrate & (DC_CAL | TEMP_CAL | WBD_CAL)) in dib0090_tune()
2256 if (state->config->analog_output == 0) in dib0090_tune()
2260 if (state->calibrate & DC_CAL) in dib0090_tune()
2262 else if (state->calibrate & WBD_CAL) { in dib0090_tune()
2263 if (state->current_rf == 0) in dib0090_tune()
2264 state->current_rf = state->fe->dtv_property_cache.frequency / 1000; in dib0090_tune()
2266 } else if (state->calibrate & TEMP_CAL) in dib0090_tune()
2268 else if (state->calibrate & CAPTRIM_CAL) in dib0090_tune()
2273 if (state->config->use_pwm_agc && state->identity.in_soc) { in dib0090_tune()
2279 state->current_band = (u8) BAND_OF_FREQUENCY(state->fe->dtv_property_cache.frequency / 1000); in dib0090_tune()
2280 state->rf_request = in dib0090_tune()
2281 state->fe->dtv_property_cache.frequency / 1000 + (state->current_band == in dib0090_tune()
2282 BAND_UHF ? state->config->freq_offset_khz_uhf : state->config-> in dib0090_tune()
2285 /* in ISDB-T 1seg we shift tuning frequency */ in dib0090_tune()
2286 …if ((state->fe->dtv_property_cache.delivery_system == SYS_ISDBT && state->fe->dtv_property_cache.i… in dib0090_tune()
2287 && state->fe->dtv_property_cache.isdbt_partial_reception == 0)) { in dib0090_tune()
2288 const struct dib0090_low_if_offset_table *LUT_offset = state->config->low_if; in dib0090_tune()
2293 while (LUT_offset->RF_freq != 0xffff) { in dib0090_tune()
2294 if (((state->rf_request > (LUT_offset->RF_freq - margin_khz)) in dib0090_tune()
2295 && (state->rf_request < (LUT_offset->RF_freq + margin_khz))) in dib0090_tune()
2296 && LUT_offset->std == state->fe->dtv_property_cache.delivery_system) { in dib0090_tune()
2297 state->rf_request += LUT_offset->offset_khz; in dib0090_tune()
2306 state->rf_request += 400; in dib0090_tune()
2308 …if (state->current_rf != state->rf_request || (state->current_standard != state->fe->dtv_property_… in dib0090_tune()
2309 state->tuner_is_tuned = 0; in dib0090_tune()
2310 state->current_rf = 0; in dib0090_tune()
2311 state->current_standard = 0; in dib0090_tune()
2314 if (state->identity.p1g) in dib0090_tune()
2317 tmp = (state->identity.version >> 5) & 0x7; in dib0090_tune()
2319 if (state->identity.in_soc) { in dib0090_tune()
2320 if (state->config->force_cband_input) { /* Use the CBAND input for all band */ in dib0090_tune()
2321 …if (state->current_band & BAND_CBAND || state->current_band & BAND_FM || state->current_band & BAN… in dib0090_tune()
2322 || state->current_band & BAND_UHF) { in dib0090_tune()
2323 state->current_band = BAND_CBAND; in dib0090_tune()
2324 if (state->config->is_dib7090e) in dib0090_tune()
2330 …if (state->current_band & BAND_CBAND || state->current_band & BAND_FM || state->current_band & BAN… in dib0090_tune()
2331 state->current_band = BAND_CBAND; in dib0090_tune()
2332 if (state->config->is_dib7090e) in dib0090_tune()
2341 …if (state->current_band == BAND_FM || state->current_band == BAND_CBAND || state->current_band == … in dib0090_tune()
2342 state->current_band = BAND_CBAND; /* Force CBAND */ in dib0090_tune()
2345 if (state->identity.p1g) in dib0090_tune()
2351 if (state->identity.p1g) in dib0090_tune()
2355 while (state->rf_request > tune->max_freq) in dib0090_tune()
2357 while (state->rf_request > pll->max_freq) in dib0090_tune()
2360 state->current_tune_table_index = tune; in dib0090_tune()
2361 state->current_pll_table_index = pll; in dib0090_tune()
2363 dib0090_write_reg(state, 0x0b, 0xb800 | (tune->switch_trim)); in dib0090_tune()
2365 VCOF_kHz = (pll->hfdiv * state->rf_request) * 2; in dib0090_tune()
2367 FREF = state->config->io.clock_khz; in dib0090_tune()
2368 if (state->config->fref_clock_ratio != 0) in dib0090_tune()
2369 FREF /= state->config->fref_clock_ratio; in dib0090_tune()
2371 FBDiv = (VCOF_kHz / pll->topresc / FREF); in dib0090_tune()
2372 Rest = (VCOF_kHz / pll->topresc) - FBDiv * FREF; in dib0090_tune()
2378 else if (Rest > (FREF - LPF)) { in dib0090_tune()
2381 } else if (Rest > (FREF - 2 * LPF)) in dib0090_tune()
2382 Rest = FREF - 2 * LPF; in dib0090_tune()
2384 state->rest = Rest; in dib0090_tune()
2391 if (pll->vco_band) in dib0090_tune()
2396 if (pll->vco_band) in dib0090_tune()
2398 else if (state->config->analog_output) in dib0090_tune()
2404 if (state->identity.p1g) { /* Bias is done automatically in P1G */ in dib0090_tune()
2405 if (state->identity.in_soc) { in dib0090_tune()
2406 if (state->identity.version == SOC_8090_P1G_11R1) in dib0090_tune()
2414 …lo5 |= (pll->hfdiv_code << 11) | (pll->vco_band << 7); /* bit 15 is the split to the slave, we do … in dib0090_tune()
2416 if (!state->config->io.pll_int_loop_filt) { in dib0090_tune()
2417 if (state->identity.in_soc) in dib0090_tune()
2419 else if (state->identity.p1g || (Rest == 0)) in dib0090_tune()
2424 lo6 = (state->config->io.pll_int_loop_filt << 3); in dib0090_tune()
2433 if (state->config->fref_clock_ratio != 0) in dib0090_tune()
2434 dib0090_write_reg(state, 0x16, (Den << 8) | state->config->fref_clock_ratio); in dib0090_tune()
2441 lo6 = tune->tuner_enable; in dib0090_tune()
2442 if (state->config->analog_output) in dib0090_tune()
2445 dib0090_write_reg(state, 0x24, lo6 | EN_LO | state->config->use_pwm_agc * EN_CRYSTAL); in dib0090_tune()
2449 state->current_rf = state->rf_request; in dib0090_tune()
2450 state->current_standard = state->fe->dtv_property_cache.delivery_system; in dib0090_tune()
2453 state->calibrate = CAPTRIM_CAL; /* captrim search now */ in dib0090_tune()
2457 const struct dib0090_wbd_slope *wbd = state->current_wbd_table; in dib0090_tune()
2459 while (state->current_rf / 1000 > wbd->max_freq) in dib0090_tune()
2463 dprintk("Final Captrim: %d\n", (u32) state->fcaptrim); in dib0090_tune()
2464 dprintk("HFDIV code: %d\n", (u32) pll->hfdiv_code); in dib0090_tune()
2465 dprintk("VCO = %d\n", (u32) pll->vco_band); in dib0090_tune()
2466 …F in kHz: %d ((%d*%d) << 1))\n", (u32) ((pll->hfdiv * state->rf_request) * 2), (u32) pll->hfdiv, (… in dib0090_tune()
2467 dprintk("REFDIV: %d, FREF: %d\n", (u32) 1, (u32) state->config->io.clock_khz); in dib0090_tune()
2476 if (wbd->wbd_gain != 0) in dib0090_tune()
2477 c = wbd->wbd_gain; in dib0090_tune()
2479 state->wbdmux = (c << 13) | (i << 11) | (WBD | (state->config->use_pwm_agc << 1)); in dib0090_tune()
2480 dib0090_write_reg(state, 0x10, state->wbdmux); in dib0090_tune()
2482 if ((tune->tuner_enable == EN_CAB) && state->identity.p1g) { in dib0090_tune()
2483 dprintk("P1G : The cable band is selected and lna_tune = %d\n", tune->lna_tune); in dib0090_tune()
2484 dib0090_write_reg(state, 0x09, tune->lna_bias); in dib0090_tune()
2485 dib0090_write_reg(state, 0x0b, 0xb800 | (tune->lna_tune << 6) | (tune->switch_trim)); in dib0090_tune()
2487 dib0090_write_reg(state, 0x09, (tune->lna_tune << 5) | tune->lna_bias); in dib0090_tune()
2489 dib0090_write_reg(state, 0x0c, tune->v2i); in dib0090_tune()
2490 dib0090_write_reg(state, 0x0d, tune->mix); in dib0090_tune()
2491 dib0090_write_reg(state, 0x0e, tune->load); in dib0090_tune()
2495 /* initialize the lt gain register */ in dib0090_tune()
2496 state->rf_lt_def = 0x7c00; in dib0090_tune()
2499 state->tuner_is_tuned = 1; in dib0090_tune()
2501 state->calibrate |= WBD_CAL; in dib0090_tune()
2502 state->calibrate |= TEMP_CAL; in dib0090_tune()
2511 kfree(fe->tuner_priv); in dib0090_release()
2512 fe->tuner_priv = NULL; in dib0090_release()
2517 struct dib0090_state *state = fe->tuner_priv; in dib0090_get_tune_state()
2519 return state->tune_state; in dib0090_get_tune_state()
2526 struct dib0090_state *state = fe->tuner_priv; in dib0090_set_tune_state()
2528 state->tune_state = tune_state; in dib0090_set_tune_state()
2536 struct dib0090_state *state = fe->tuner_priv; in dib0090_get_frequency()
2538 *frequency = 1000 * state->current_rf; in dib0090_get_frequency()
2544 struct dib0090_state *state = fe->tuner_priv; in dib0090_set_params()
2547 state->tune_state = CT_TUNER_START; in dib0090_set_params()
2564 } while (state->tune_state != CT_TUNER_STOP); in dib0090_set_params()
2607 struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struc… in dib0090_register() argument
2613 st->config = config; in dib0090_register()
2614 st->i2c = i2c; in dib0090_register()
2615 st->fe = fe; in dib0090_register()
2616 mutex_init(&st->i2c_buffer_lock); in dib0090_register()
2617 fe->tuner_priv = st; in dib0090_register()
2619 if (config->wbd == NULL) in dib0090_register()
2620 st->current_wbd_table = dib0090_wbd_table_default; in dib0090_register()
2622 st->current_wbd_table = config->wbd; in dib0090_register()
2628 memcpy(&fe->ops.tuner_ops, &dib0090_ops, sizeof(struct dvb_tuner_ops)); in dib0090_register()
2633 fe->tuner_priv = NULL; in dib0090_register()
2639 struct dvb_frontend *dib0090_fw_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, const st… in dib0090_fw_register() argument
2645 st->config = config; in dib0090_fw_register()
2646 st->i2c = i2c; in dib0090_fw_register()
2647 st->fe = fe; in dib0090_fw_register()
2648 mutex_init(&st->i2c_buffer_lock); in dib0090_fw_register()
2649 fe->tuner_priv = st; in dib0090_fw_register()
2651 if (dib0090_fw_reset_digital(fe, st->config) != 0) in dib0090_fw_register()
2655 memcpy(&fe->ops.tuner_ops, &dib0090_fw_ops, sizeof(struct dvb_tuner_ops)); in dib0090_fw_register()
2660 fe->tuner_priv = NULL; in dib0090_fw_register()
2667 MODULE_DESCRIPTION("Driver for the DiBcom 0090 base-band RF Tuner");