Lines Matching +full:sense +full:- +full:freq

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Driver for ST STV0367 DVB-T & DVB-C demodulator IC.
39 /* DVB-C */
58 /* DVB-T */
65 enum fe_spectral_inversion sense; /* current search spectrum */ member
84 /* DVB-C */
86 /* DVB-T */
98 /* RF Level (for RF AGC->AGC1) Lookup Table, depends on the board and tuner.*/
110 /* RF Level (for IF AGC->AGC2) Lookup Table, depends on the board and tuner.*/
126 .addr = state->config->demod_address, in stv0367_writeregs()
137 return -EINVAL; in stv0367_writeregs()
147 state->config->demod_address, reg, buf[2]); in stv0367_writeregs()
149 ret = i2c_transfer(state->i2c, &msg, 1); in stv0367_writeregs()
152 __func__, state->config->demod_address, reg, buf[2]); in stv0367_writeregs()
154 return (ret != 1) ? -EREMOTEIO : 0; in stv0367_writeregs()
170 .addr = state->config->demod_address, in stv0367_readreg()
175 .addr = state->config->demod_address, in stv0367_readreg()
186 ret = i2c_transfer(state->i2c, msg, 2); in stv0367_readreg()
189 __func__, state->config->demod_address, reg, b1[0]); in stv0367_readreg()
193 state->config->demod_address, reg, b1[0]); in stv0367_readreg()
209 (*pos) = (i - 1); in extract_mask_pos()
296 /* set internal freq to 53.125MHz */ in stv0367_pll_setup()
323 if (state->auto_if_khz && state->fe.ops.tuner_ops.get_if_frequency) { in stv0367_get_if_khz()
324 state->fe.ops.tuner_ops.get_if_frequency(&state->fe, ifkhz); in stv0367_get_if_khz()
325 *ifkhz = *ifkhz / 1000; /* hz -> khz */ in stv0367_get_if_khz()
327 *ifkhz = state->config->if_khz; in stv0367_get_if_khz()
334 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_gate_ctrl()
354 struct dvb_frontend_ops *frontend_ops = &fe->ops; in stv0367_get_tuner_freq()
355 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; in stv0367_get_tuner_freq()
356 u32 freq = 0; in stv0367_get_tuner_freq() local
361 if (tuner_ops->get_frequency) { in stv0367_get_tuner_freq()
362 err = tuner_ops->get_frequency(fe, &freq); in stv0367_get_tuner_freq()
368 dprintk("%s: frequency=%d\n", __func__, freq); in stv0367_get_tuner_freq()
371 return -1; in stv0367_get_tuner_freq()
373 return freq; in stv0367_get_tuner_freq()
487 int i, j, k, freq; in stv0367ter_filt_coeff_init() local
491 freq = stv0367ter_get_mclk(state, DemodXtal); in stv0367ter_filt_coeff_init()
493 if (freq == 53125000) in stv0367ter_filt_coeff_init()
495 else if (freq == 54000000) in stv0367ter_filt_coeff_init()
497 else if (freq == 52500000) in stv0367ter_filt_coeff_init()
503 stv0367_writebits(state, F367TER_IIR_CELL_NB, i - 1); in stv0367ter_filt_coeff_init()
507 (R367TER_IIRCX_COEFF1_MSB + 2 * (j - 1)), in stv0367ter_filt_coeff_init()
508 MSB(CellsCoeffs[k][i-1][j-1])); in stv0367ter_filt_coeff_init()
510 (R367TER_IIRCX_COEFF1_LSB + 2 * (j - 1)), in stv0367ter_filt_coeff_init()
511 LSB(CellsCoeffs[k][i-1][j-1])); in stv0367ter_filt_coeff_init()
638 wd -= 2; in stv0367ter_check_syr()
686 wd -= 1; in stv0367ter_check_cpamp()
721 if (state->config->if_iq_mode != 0) in stv0367ter_lock_algo()
806 wd -= tempo; in stv0367ter_lock_algo()
858 wd -= tempo; in stv0367ter_lock_algo()
866 /*if(ter_state->if_iq_mode!=FE_TER_NORMAL_IF_TUNER) { in stv0367ter_lock_algo()
945 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_standby()
969 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_init()
970 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_init()
974 ter_state->pBER = 0; in stv0367ter_init()
977 stv0367_deftabs[state->deftabs][STV0367_TAB_TER]); in stv0367ter_init()
979 stv0367_pll_setup(state, STV0367_ICSPEED_53125, state->config->xtal); in stv0367ter_init()
985 stv0367ter_set_ts_mode(state, state->config->ts_mode); in stv0367ter_init()
986 stv0367ter_set_clk_pol(state, state->config->clk_pol); in stv0367ter_init()
988 state->chip_id = stv0367_readreg(state, R367TER_ID); in stv0367ter_init()
989 ter_state->first_lock = 0; in stv0367ter_init()
990 ter_state->unlock_counter = 2; in stv0367ter_init()
997 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ter_algo()
998 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_algo()
999 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_algo()
1011 ter_state->frequency = p->frequency; in stv0367ter_algo()
1012 ter_state->force = FE_TER_FORCENONE in stv0367ter_algo()
1014 ter_state->if_iq_mode = state->config->if_iq_mode; in stv0367ter_algo()
1015 switch (state->config->if_iq_mode) { in stv0367ter_algo()
1035 return -EINVAL; in stv0367ter_algo()
1040 switch (p->inversion) { in stv0367ter_algo()
1044 if (ter_state->if_iq_mode == FE_TER_IQ_TUNER) in stv0367ter_algo()
1046 ter_state->sense); in stv0367ter_algo()
1049 ter_state->sense); in stv0367ter_algo()
1054 if (ter_state->if_iq_mode == FE_TER_IQ_TUNER) in stv0367ter_algo()
1056 p->inversion); in stv0367ter_algo()
1059 p->inversion); in stv0367ter_algo()
1064 if ((ter_state->if_iq_mode != FE_TER_NORMAL_IF_TUNER) && in stv0367ter_algo()
1065 (ter_state->pBW != ter_state->bw)) { in stv0367ter_algo()
1079 if (!stv0367_iir_filt_init(state, ter_state->bw, in stv0367ter_algo()
1080 state->config->xtal)) in stv0367ter_algo()
1081 return -EINVAL; in stv0367ter_algo()
1083 ter_state->pBW = ter_state->bw; in stv0367ter_algo()
1088 if (ter_state->hierarchy == FE_TER_HIER_LOW_PRIO) in stv0367ter_algo()
1093 InternalFreq = stv0367ter_get_mclk(state, state->config->xtal) / 1000; in stv0367ter_algo()
1095 ((((ter_state->bw * 64 * (1 << 15) * 100) in stv0367ter_algo()
1106 temp = (int)(((1 << 17) * ter_state->bw * 1000) / (7 * (InternalFreq))); in stv0367ter_algo()
1113 ((InternalFreq - ifkhz) * (1 << 16) / (InternalFreq)); in stv0367ter_algo()
1119 ter_state->echo_pos = 0; in stv0367ter_algo()
1120 ter_state->ucblocks = 0; /* liplianin */ in stv0367ter_algo()
1121 ter_state->pBER = 0; /* liplianin */ in stv0367ter_algo()
1122 stv0367_writebits(state, F367TER_LONG_ECHO, ter_state->echo_pos); in stv0367ter_algo()
1127 ter_state->state = FE_TER_LOCKOK; in stv0367ter_algo()
1129 ter_state->mode = stv0367_readbits(state, F367TER_SYR_MODE); in stv0367ter_algo()
1130 ter_state->guard = stv0367_readbits(state, F367TER_SYR_GUARD); in stv0367ter_algo()
1132 ter_state->first_lock = 1; /* we know sense now :) */ in stv0367ter_algo()
1134 ter_state->agc_val = in stv0367ter_algo()
1147 offset -= 16777216; in stv0367ter_algo()
1151 if (ter_state->mode == FE_TER_MODE_2K) in stv0367ter_algo()
1153 else if (ter_state->mode == FE_TER_MODE_4K) in stv0367ter_algo()
1155 else if (ter_state->mode == FE_TER_MODE_8K) in stv0367ter_algo()
1162 offset = offset * -1; in stv0367ter_algo()
1165 if (ter_state->bw == 6) in stv0367ter_algo()
1167 else if (ter_state->bw == 7) in stv0367ter_algo()
1170 ter_state->frequency += offset; in stv0367ter_algo()
1180 timing_offset -= 65536; in stv0367ter_algo()
1188 tempo--; in stv0367ter_algo()
1192 timing_offset = (timing_offset - 11) / 22; in stv0367ter_algo()
1193 step = -1; in stv0367ter_algo()
1224 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ter_set_frontend()
1225 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_set_frontend()
1226 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_set_frontend()
1232 if (state->reinit_on_setfrontend) in stv0367ter_set_frontend()
1235 if (fe->ops.tuner_ops.set_params) { in stv0367ter_set_frontend()
1236 if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) in stv0367ter_set_frontend()
1237 fe->ops.i2c_gate_ctrl(fe, 1); in stv0367ter_set_frontend()
1238 fe->ops.tuner_ops.set_params(fe); in stv0367ter_set_frontend()
1239 if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) in stv0367ter_set_frontend()
1240 fe->ops.i2c_gate_ctrl(fe, 0); in stv0367ter_set_frontend()
1243 switch (p->transmission_mode) { in stv0367ter_set_frontend()
1247 ter_state->mode = FE_TER_MODE_2K; in stv0367ter_set_frontend()
1253 ter_state->mode = FE_TER_MODE_8K; in stv0367ter_set_frontend()
1257 switch (p->guard_interval) { in stv0367ter_set_frontend()
1263 ter_state->guard = p->guard_interval; in stv0367ter_set_frontend()
1266 ter_state->guard = GUARD_INTERVAL_1_32; in stv0367ter_set_frontend()
1270 switch (p->bandwidth_hz) { in stv0367ter_set_frontend()
1272 ter_state->bw = FE_TER_CHAN_BW_6M; in stv0367ter_set_frontend()
1275 ter_state->bw = FE_TER_CHAN_BW_7M; in stv0367ter_set_frontend()
1279 ter_state->bw = FE_TER_CHAN_BW_8M; in stv0367ter_set_frontend()
1282 ter_state->hierarchy = FE_TER_HIER_NONE; in stv0367ter_set_frontend()
1284 switch (p->inversion) { in stv0367ter_set_frontend()
1291 if (ter_state->first_lock) in stv0367ter_set_frontend()
1296 ter_state->state = FE_TER_NOLOCK; in stv0367ter_set_frontend()
1299 while (((index) < num_trials) && (ter_state->state != FE_TER_LOCKOK)) { in stv0367ter_set_frontend()
1300 if (!ter_state->first_lock) { in stv0367ter_set_frontend()
1301 if (p->inversion == INVERSION_AUTO) in stv0367ter_set_frontend()
1302 ter_state->sense = SenseTrials[index]; in stv0367ter_set_frontend()
1307 if ((ter_state->state == FE_TER_LOCKOK) && in stv0367ter_set_frontend()
1308 (p->inversion == INVERSION_AUTO) && in stv0367ter_set_frontend()
1310 /* invert spectrum sense */ in stv0367ter_set_frontend()
1323 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_read_ucblocks()
1324 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_read_ucblocks()
1335 ter_state->ucblocks = errs; in stv0367ter_read_ucblocks()
1338 (*ucblocks) = ter_state->ucblocks; in stv0367ter_read_ucblocks()
1346 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_get_frontend()
1347 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_get_frontend()
1351 p->frequency = stv0367_get_tuner_freq(fe); in stv0367ter_get_frontend()
1352 if ((int)p->frequency < 0) in stv0367ter_get_frontend()
1353 p->frequency = -p->frequency; in stv0367ter_get_frontend()
1357 p->modulation = QPSK; in stv0367ter_get_frontend()
1359 p->modulation = QAM_16; in stv0367ter_get_frontend()
1361 p->modulation = QAM_64; in stv0367ter_get_frontend()
1363 p->inversion = stv0367_readbits(state, F367TER_INV_SPECTR); in stv0367ter_get_frontend()
1370 p->hierarchy = HIERARCHY_NONE; in stv0367ter_get_frontend()
1373 p->hierarchy = HIERARCHY_1; in stv0367ter_get_frontend()
1376 p->hierarchy = HIERARCHY_2; in stv0367ter_get_frontend()
1379 p->hierarchy = HIERARCHY_4; in stv0367ter_get_frontend()
1382 p->hierarchy = HIERARCHY_AUTO; in stv0367ter_get_frontend()
1387 if (ter_state->hierarchy == FE_TER_HIER_LOW_PRIO) in stv0367ter_get_frontend()
1394 p->code_rate_HP = FEC_1_2; in stv0367ter_get_frontend()
1397 p->code_rate_HP = FEC_2_3; in stv0367ter_get_frontend()
1400 p->code_rate_HP = FEC_3_4; in stv0367ter_get_frontend()
1403 p->code_rate_HP = FEC_5_6; in stv0367ter_get_frontend()
1406 p->code_rate_HP = FEC_7_8; in stv0367ter_get_frontend()
1409 p->code_rate_HP = FEC_AUTO; in stv0367ter_get_frontend()
1417 p->transmission_mode = TRANSMISSION_MODE_2K; in stv0367ter_get_frontend()
1420 p->transmission_mode = TRANSMISSION_MODE_4K; in stv0367ter_get_frontend()
1423 p->transmission_mode = TRANSMISSION_MODE_8K; in stv0367ter_get_frontend()
1426 p->transmission_mode = TRANSMISSION_MODE_AUTO; in stv0367ter_get_frontend()
1429 p->guard_interval = stv0367_readbits(state, F367TER_SYR_GUARD); in stv0367ter_get_frontend()
1436 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_snr_readreg()
1468 struct stv0367_state *state = fe->demodulator_priv;
1469 struct stv0367ter_state *ter_state = state->ter_state;
1474 ter_state->unlock_counter += 1;
1476 ter_state->unlock_counter = 0;
1478 if (ter_state->unlock_counter > 2) {
1497 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_read_status()
1514 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_read_ber()
1515 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_read_ber()
1530 tber = ter_state->pBER; in stv0367ter_read_ber()
1588 ter_state->pBER = tber; in stv0367ter_read_ber()
1597 struct stv0367ter_state *ter_state = state->ter_state;
1657 ter_state->pPER = Per;
1666 fe_tune_settings->min_delay_ms = 1000; in stv0367_get_tune_settings()
1667 fe_tune_settings->step_size = 0; in stv0367_get_tune_settings()
1668 fe_tune_settings->max_drift = 0; in stv0367_get_tune_settings()
1675 struct stv0367_state *state = fe->demodulator_priv; in stv0367_release()
1677 kfree(state->ter_state); in stv0367_release()
1678 kfree(state->cab_state); in stv0367_release()
1685 .name = "ST STV0367 DVB-T",
1727 state->i2c = i2c; in stv0367ter_attach()
1728 state->config = config; in stv0367ter_attach()
1729 state->ter_state = ter_state; in stv0367ter_attach()
1730 state->fe.ops = stv0367ter_ops; in stv0367ter_attach()
1731 state->fe.demodulator_priv = state; in stv0367ter_attach()
1732 state->chip_id = stv0367_readreg(state, 0xf000); in stv0367ter_attach()
1735 state->use_i2c_gatectrl = 1; in stv0367ter_attach()
1736 state->deftabs = STV0367_DEFTAB_GENERIC; in stv0367ter_attach()
1737 state->reinit_on_setfrontend = 1; in stv0367ter_attach()
1738 state->auto_if_khz = 0; in stv0367ter_attach()
1740 dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id); in stv0367ter_attach()
1743 if ((state->chip_id != 0x50) && (state->chip_id != 0x60)) in stv0367ter_attach()
1746 return &state->fe; in stv0367ter_attach()
1757 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_gate_ctrl()
1768 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_get_mclk()
1918 derot_hz = derot_hz - adc_hz; in stv0367cab_set_derot_freq()
2149 (state->cab_state->qamfec_status_reg ? in stv0367cab_qamfec_lock()
2150 state->cab_state->qamfec_status_reg : in stv0367cab_qamfec_lock()
2209 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_read_status()
2215 /* update cab_state->state from QAM_FSM_STATUS */ in stv0367cab_read_status()
2216 state->cab_state->state = stv0367cab_fsm_signaltype( in stv0367cab_read_status()
2224 if (state->cab_state->state > FE_CAB_NOSIGNAL) in stv0367cab_read_status()
2227 if (state->cab_state->state > FE_CAB_NOCARRIER) in stv0367cab_read_status()
2230 if (state->cab_state->state >= FE_CAB_DEMODOK) in stv0367cab_read_status()
2233 if (state->cab_state->state >= FE_CAB_DATAOK) in stv0367cab_read_status()
2242 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_standby()
2276 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_init()
2277 struct stv0367cab_state *cab_state = state->cab_state; in stv0367cab_init()
2282 stv0367_deftabs[state->deftabs][STV0367_TAB_CAB]); in stv0367cab_init()
2284 switch (state->config->ts_mode) { in stv0367cab_init()
2299 switch (state->config->clk_pol) { in stv0367cab_init()
2319 cab_state->mclk = stv0367cab_get_mclk(fe, state->config->xtal); in stv0367cab_init()
2320 cab_state->adc_clk = stv0367cab_get_adc_freq(fe, state->config->xtal); in stv0367cab_init()
2328 struct stv0367cab_state *cab_state = state->cab_state; in stv0367cab_algo()
2344 TRLTimeOut = 100000000 / p->symbol_rate; in stv0367cab_algo()
2346 within [-4%, +4%] of the symbol rate. in stv0367cab_algo()
2348 for a lock within [-search_range, +search_range]. in stv0367cab_algo()
2350 the micro-reflections we want to handle. in stv0367cab_algo()
2354 switch (p->modulation) { in stv0367cab_algo()
2381 if (pIntParams->search_range < 0) { in stv0367cab_algo()
2383 (-pIntParams->search_range / 1000)) / in stv0367cab_algo()
2384 (pIntParams->symbol_rate / 1000); in stv0367cab_algo()
2387 CRLTimeOut = (25 * CRLSymbols * (cab_state->search_range / 1000)) / in stv0367cab_algo()
2388 (p->symbol_rate / 1000); in stv0367cab_algo()
2390 CRLTimeOut = (1000 * CRLTimeOut) / p->symbol_rate; in stv0367cab_algo()
2417 stv0367cab_set_derot_freq(state, cab_state->adc_clk, in stv0367cab_algo()
2418 (1000 * (s32)ifkhz + cab_state->derot_offset)); in stv0367cab_algo()
2420 if ((p->symbol_rate > 10800000) | (p->symbol_rate < 1800000)) { in stv0367cab_algo()
2436 if ((LockTime >= (DemodTimeOut - EQLTimeOut)) && in stv0367cab_algo()
2459 u32_tmp = 262144 - u32_tmp; in stv0367cab_algo()
2460 u32_tmp = u32_tmp / (1 << (11 - stv0367_readbits(state, in stv0367cab_algo()
2466 F367CAB_AGC_PWRREF_HI) - 10) in stv0367cab_algo()
2487 tmp = stv0367cab_get_derot_freq(state, cab_state->adc_clk); in stv0367cab_algo()
2503 cab_state->spect_inv = stv0367_readbits(state, in stv0367cab_algo()
2508 if (ifkhz > cab_state->adc_clk / 1000) { in stv0367cab_algo()
2509 cab_state->freq_khz = in stv0367cab_algo()
2510 FE_Cab_TunerGetFrequency(pIntParams->hTuner) in stv0367cab_algo()
2511 - stv0367cab_get_derot_freq(state, cab_state->adc_clk) in stv0367cab_algo()
2512 - cab_state->adc_clk / 1000 + ifkhz; in stv0367cab_algo()
2514 cab_state->freq_khz = in stv0367cab_algo()
2515 FE_Cab_TunerGetFrequency(pIntParams->hTuner) in stv0367cab_algo()
2516 - stv0367cab_get_derot_freq(state, cab_state->adc_clk) in stv0367cab_algo()
2520 cab_state->freq_khz = in stv0367cab_algo()
2521 FE_Cab_TunerGetFrequency(pIntParams->hTuner) + in stv0367cab_algo()
2523 cab_state->adc_clk) - in stv0367cab_algo()
2524 cab_state->adc_clk / 4000; in stv0367cab_algo()
2527 cab_state->symbol_rate = stv0367cab_GetSymbolRate(state, in stv0367cab_algo()
2528 cab_state->mclk); in stv0367cab_algo()
2529 cab_state->locked = 1; in stv0367cab_algo()
2542 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367cab_set_frontend()
2543 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_set_frontend()
2544 struct stv0367cab_state *cab_state = state->cab_state; in stv0367cab_set_frontend()
2547 dprintk("%s: freq = %d, srate = %d\n", __func__, in stv0367cab_set_frontend()
2548 p->frequency, p->symbol_rate); in stv0367cab_set_frontend()
2550 cab_state->derot_offset = 0; in stv0367cab_set_frontend()
2552 switch (p->modulation) { in stv0367cab_set_frontend()
2572 if (state->reinit_on_setfrontend) in stv0367cab_set_frontend()
2576 if (fe->ops.tuner_ops.set_params) { in stv0367cab_set_frontend()
2577 if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) in stv0367cab_set_frontend()
2578 fe->ops.i2c_gate_ctrl(fe, 1); in stv0367cab_set_frontend()
2579 fe->ops.tuner_ops.set_params(fe); in stv0367cab_set_frontend()
2580 if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) in stv0367cab_set_frontend()
2581 fe->ops.i2c_gate_ctrl(fe, 0); in stv0367cab_set_frontend()
2586 p->symbol_rate, in stv0367cab_set_frontend()
2590 cab_state->adc_clk, in stv0367cab_set_frontend()
2591 cab_state->mclk, in stv0367cab_set_frontend()
2592 p->symbol_rate, in stv0367cab_set_frontend()
2594 /* Search algorithm launch, [-1.1*RangeOffset, +1.1*RangeOffset] scan */ in stv0367cab_set_frontend()
2595 cab_state->state = stv0367cab_algo(state, p); in stv0367cab_set_frontend()
2602 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_get_frontend()
2603 struct stv0367cab_state *cab_state = state->cab_state; in stv0367cab_get_frontend()
2611 p->symbol_rate = stv0367cab_GetSymbolRate(state, cab_state->mclk); in stv0367cab_get_frontend()
2616 p->modulation = QAM_16; in stv0367cab_get_frontend()
2619 p->modulation = QAM_32; in stv0367cab_get_frontend()
2622 p->modulation = QAM_64; in stv0367cab_get_frontend()
2625 p->modulation = QAM_128; in stv0367cab_get_frontend()
2628 p->modulation = QAM_256; in stv0367cab_get_frontend()
2634 p->frequency = stv0367_get_tuner_freq(fe); in stv0367cab_get_frontend()
2636 dprintk("%s: tuner frequency = %d\n", __func__, p->frequency); in stv0367cab_get_frontend()
2639 p->frequency += in stv0367cab_get_frontend()
2640 (stv0367cab_get_derot_freq(state, cab_state->adc_clk) - in stv0367cab_get_frontend()
2641 cab_state->adc_clk / 4000); in stv0367cab_get_frontend()
2645 if (ifkhz > cab_state->adc_clk / 1000) in stv0367cab_get_frontend()
2646 p->frequency += (ifkhz in stv0367cab_get_frontend()
2647 - stv0367cab_get_derot_freq(state, cab_state->adc_clk) in stv0367cab_get_frontend()
2648 - cab_state->adc_clk / 1000); in stv0367cab_get_frontend()
2650 p->frequency += (ifkhz in stv0367cab_get_frontend()
2651 - stv0367cab_get_derot_freq(state, cab_state->adc_clk)); in stv0367cab_get_frontend()
2668 struct stv0367_state *state = fe->demodulator_priv;
2690 IfAgcPwm -= 2048; in stv0367cab_get_rf_lvl()
2700 rfLevel = (-1) * stv0367cab_RF_LookUp1[1][i]; in stv0367cab_get_rf_lvl()
2705 rfLevel = -56; in stv0367cab_get_rf_lvl()
2709 rfLevel = (-1) * stv0367cab_RF_LookUp2[1][i]; in stv0367cab_get_rf_lvl()
2714 rfLevel = -72; in stv0367cab_get_rf_lvl()
2721 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_read_strength()
2727 if (signal <= -72) in stv0367cab_read_strength()
2730 *strength = (22 + signal) * (-1311); in stv0367cab_read_strength()
2739 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_snr_power()
2767 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_snr_readreg()
2784 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_read_snr()
2839 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_read_ucblcks()
2858 .name = "ST STV0367 DVB-C",
2898 state->i2c = i2c; in stv0367cab_attach()
2899 state->config = config; in stv0367cab_attach()
2900 cab_state->search_range = 280000; in stv0367cab_attach()
2901 cab_state->qamfec_status_reg = F367CAB_QAMFEC_LOCK; in stv0367cab_attach()
2902 state->cab_state = cab_state; in stv0367cab_attach()
2903 state->fe.ops = stv0367cab_ops; in stv0367cab_attach()
2904 state->fe.demodulator_priv = state; in stv0367cab_attach()
2905 state->chip_id = stv0367_readreg(state, 0xf000); in stv0367cab_attach()
2908 state->use_i2c_gatectrl = 1; in stv0367cab_attach()
2909 state->deftabs = STV0367_DEFTAB_GENERIC; in stv0367cab_attach()
2910 state->reinit_on_setfrontend = 1; in stv0367cab_attach()
2911 state->auto_if_khz = 0; in stv0367cab_attach()
2913 dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id); in stv0367cab_attach()
2916 if ((state->chip_id != 0x50) && (state->chip_id != 0x60)) in stv0367cab_attach()
2919 return &state->fe; in stv0367cab_attach()
2952 stv0367_pll_setup(state, STV0367_ICSPEED_53125, state->config->xtal); in stv0367ddb_setup_ter()
2958 state->activedemod = demod_ter; in stv0367ddb_setup_ter()
2983 stv0367_pll_setup(state, STV0367_ICSPEED_58000, state->config->xtal); in stv0367ddb_setup_cab()
2989 state->cab_state->mclk = stv0367cab_get_mclk(&state->fe, in stv0367ddb_setup_cab()
2990 state->config->xtal); in stv0367ddb_setup_cab()
2991 state->cab_state->adc_clk = stv0367cab_get_adc_freq(&state->fe, in stv0367ddb_setup_cab()
2992 state->config->xtal); in stv0367ddb_setup_cab()
2994 state->activedemod = demod_cab; in stv0367ddb_setup_cab()
2999 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_set_frontend()
3001 switch (fe->dtv_property_cache.delivery_system) { in stv0367ddb_set_frontend()
3003 if (state->activedemod != demod_ter) in stv0367ddb_set_frontend()
3008 if (state->activedemod != demod_cab) in stv0367ddb_set_frontend()
3012 if (fe->dtv_property_cache.symbol_rate == 0) { in stv0367ddb_set_frontend()
3014 return -EINVAL; in stv0367ddb_set_frontend()
3022 return -EINVAL; in stv0367ddb_set_frontend()
3027 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_read_signal_strength()
3028 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ddb_read_signal_strength()
3031 switch (state->activedemod) { in stv0367ddb_read_signal_strength()
3036 p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_signal_strength()
3040 p->strength.stat[0].scale = FE_SCALE_DECIBEL; in stv0367ddb_read_signal_strength()
3041 p->strength.stat[0].uvalue = signalstrength; in stv0367ddb_read_signal_strength()
3046 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_read_snr()
3047 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ddb_read_snr()
3051 switch (state->activedemod) { in stv0367ddb_read_snr()
3069 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_snr()
3073 p->cnr.stat[0].scale = FE_SCALE_DECIBEL; in stv0367ddb_read_snr()
3074 p->cnr.stat[0].uvalue = snrval; in stv0367ddb_read_snr()
3079 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_read_ucblocks()
3080 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ddb_read_ucblocks()
3083 switch (state->activedemod) { in stv0367ddb_read_ucblocks()
3091 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_ucblocks()
3095 p->block_error.stat[0].scale = FE_SCALE_COUNTER; in stv0367ddb_read_ucblocks()
3096 p->block_error.stat[0].uvalue = ucblocks; in stv0367ddb_read_ucblocks()
3102 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_read_status()
3103 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ddb_read_status()
3106 switch (state->activedemod) { in stv0367ddb_read_status()
3127 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_status()
3133 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_status()
3141 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_get_frontend()
3143 switch (state->activedemod) { in stv0367ddb_get_frontend()
3157 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_sleep()
3159 switch (state->activedemod) { in stv0367ddb_sleep()
3161 state->activedemod = demod_none; in stv0367ddb_sleep()
3164 state->activedemod = demod_none; in stv0367ddb_sleep()
3170 return -EINVAL; in stv0367ddb_sleep()
3175 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ddb_init()
3176 struct dtv_frontend_properties *p = &state->fe.dtv_property_cache; in stv0367ddb_init()
3180 if (stv0367_deftabs[state->deftabs][STV0367_TAB_BASE]) in stv0367ddb_init()
3182 stv0367_deftabs[state->deftabs][STV0367_TAB_BASE]); in stv0367ddb_init()
3185 stv0367_deftabs[state->deftabs][STV0367_TAB_CAB]); in stv0367ddb_init()
3189 stv0367_deftabs[state->deftabs][STV0367_TAB_TER]); in stv0367ddb_init()
3226 stv0367_pll_setup(state, STV0367_ICSPEED_58000, state->config->xtal); in stv0367ddb_init()
3247 ter_state->pBER = 0; in stv0367ddb_init()
3248 ter_state->first_lock = 0; in stv0367ddb_init()
3249 ter_state->unlock_counter = 2; in stv0367ddb_init()
3251 p->strength.len = 1; in stv0367ddb_init()
3252 p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_init()
3253 p->cnr.len = 1; in stv0367ddb_init()
3254 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_init()
3255 p->block_error.len = 1; in stv0367ddb_init()
3256 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_init()
3264 .name = "ST STV0367 DDB DVB-C/T",
3270 .caps = /* DVB-C */
3275 /* DVB-T */
3310 state->i2c = i2c; in stv0367ddb_attach()
3311 state->config = config; in stv0367ddb_attach()
3312 state->ter_state = ter_state; in stv0367ddb_attach()
3313 cab_state->search_range = 280000; in stv0367ddb_attach()
3314 cab_state->qamfec_status_reg = F367CAB_DESCR_SYNCSTATE; in stv0367ddb_attach()
3315 state->cab_state = cab_state; in stv0367ddb_attach()
3316 state->fe.ops = stv0367ddb_ops; in stv0367ddb_attach()
3317 state->fe.demodulator_priv = state; in stv0367ddb_attach()
3318 state->chip_id = stv0367_readreg(state, R367TER_ID); in stv0367ddb_attach()
3321 state->use_i2c_gatectrl = 0; in stv0367ddb_attach()
3322 state->deftabs = STV0367_DEFTAB_DDB; in stv0367ddb_attach()
3323 state->reinit_on_setfrontend = 0; in stv0367ddb_attach()
3324 state->auto_if_khz = 1; in stv0367ddb_attach()
3325 state->activedemod = demod_none; in stv0367ddb_attach()
3327 dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id); in stv0367ddb_attach()
3330 if ((state->chip_id != 0x50) && (state->chip_id != 0x60)) in stv0367ddb_attach()
3333 dev_info(&i2c->dev, "Found %s with ChipID %02X at adr %02X\n", in stv0367ddb_attach()
3334 state->fe.ops.info.name, state->chip_id, in stv0367ddb_attach()
3335 config->demod_address); in stv0367ddb_attach()
3339 return &state->fe; in stv0367ddb_attach()
3353 MODULE_DESCRIPTION("ST STV0367 DVB-C/T demodulator driver");