Lines Matching +full:an +full:- +full:1585

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 */
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_writereg()
135 state->config->demod_address, reg, data); in stv0367_writereg()
137 ret = i2c_transfer(state->i2c, &msg, 1); in stv0367_writereg()
140 __func__, state->config->demod_address, reg, data); in stv0367_writereg()
142 return (ret != 1) ? -EREMOTEIO : 0; in stv0367_writereg()
152 .addr = state->config->demod_address, in stv0367_readreg()
157 .addr = state->config->demod_address, in stv0367_readreg()
168 ret = i2c_transfer(state->i2c, msg, 2); in stv0367_readreg()
171 __func__, state->config->demod_address, reg, b1[0]); in stv0367_readreg()
175 state->config->demod_address, reg, b1[0]); in stv0367_readreg()
191 (*pos) = (i - 1); in extract_mask_pos()
305 if (state->auto_if_khz && state->fe.ops.tuner_ops.get_if_frequency) { in stv0367_get_if_khz()
306 state->fe.ops.tuner_ops.get_if_frequency(&state->fe, ifkhz); in stv0367_get_if_khz()
307 *ifkhz = *ifkhz / 1000; /* hz -> khz */ in stv0367_get_if_khz()
309 *ifkhz = state->config->if_khz; in stv0367_get_if_khz()
316 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_gate_ctrl()
336 struct dvb_frontend_ops *frontend_ops = &fe->ops; in stv0367_get_tuner_freq()
337 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; in stv0367_get_tuner_freq()
343 if (tuner_ops->get_frequency) { in stv0367_get_tuner_freq()
344 err = tuner_ops->get_frequency(fe, &freq); in stv0367_get_tuner_freq()
353 return -1; in stv0367_get_tuner_freq()
485 stv0367_writebits(state, F367TER_IIR_CELL_NB, i - 1); in stv0367ter_filt_coeff_init()
489 (R367TER_IIRCX_COEFF1_MSB + 2 * (j - 1)), in stv0367ter_filt_coeff_init()
490 MSB(CellsCoeffs[k][i-1][j-1])); in stv0367ter_filt_coeff_init()
492 (R367TER_IIRCX_COEFF1_LSB + 2 * (j - 1)), in stv0367ter_filt_coeff_init()
493 LSB(CellsCoeffs[k][i-1][j-1])); in stv0367ter_filt_coeff_init()
620 wd -= 2; in stv0367ter_check_syr()
668 wd -= 1; in stv0367ter_check_cpamp()
703 if (state->config->if_iq_mode != 0) in stv0367ter_lock_algo()
770 /*reset fec an reedsolo FOR 367 only*/ in stv0367ter_lock_algo()
788 wd -= tempo; in stv0367ter_lock_algo()
840 wd -= tempo; in stv0367ter_lock_algo()
848 /*if(ter_state->if_iq_mode!=FE_TER_NORMAL_IF_TUNER) { in stv0367ter_lock_algo()
927 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_standby()
951 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_init()
952 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_init()
956 ter_state->pBER = 0; in stv0367ter_init()
959 stv0367_deftabs[state->deftabs][STV0367_TAB_TER]); in stv0367ter_init()
961 stv0367_pll_setup(state, STV0367_ICSPEED_53125, state->config->xtal); in stv0367ter_init()
967 stv0367ter_set_ts_mode(state, state->config->ts_mode); in stv0367ter_init()
968 stv0367ter_set_clk_pol(state, state->config->clk_pol); in stv0367ter_init()
970 state->chip_id = stv0367_readreg(state, R367TER_ID); in stv0367ter_init()
971 ter_state->first_lock = 0; in stv0367ter_init()
972 ter_state->unlock_counter = 2; in stv0367ter_init()
979 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ter_algo()
980 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_algo()
981 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_algo()
993 ter_state->frequency = p->frequency; in stv0367ter_algo()
994 ter_state->force = FE_TER_FORCENONE in stv0367ter_algo()
996 ter_state->if_iq_mode = state->config->if_iq_mode; in stv0367ter_algo()
997 switch (state->config->if_iq_mode) { in stv0367ter_algo()
1017 return -EINVAL; in stv0367ter_algo()
1022 switch (p->inversion) { in stv0367ter_algo()
1026 if (ter_state->if_iq_mode == FE_TER_IQ_TUNER) in stv0367ter_algo()
1028 ter_state->sense); in stv0367ter_algo()
1031 ter_state->sense); in stv0367ter_algo()
1036 if (ter_state->if_iq_mode == FE_TER_IQ_TUNER) in stv0367ter_algo()
1038 p->inversion); in stv0367ter_algo()
1041 p->inversion); in stv0367ter_algo()
1046 if ((ter_state->if_iq_mode != FE_TER_NORMAL_IF_TUNER) && in stv0367ter_algo()
1047 (ter_state->pBW != ter_state->bw)) { in stv0367ter_algo()
1061 if (!stv0367_iir_filt_init(state, ter_state->bw, in stv0367ter_algo()
1062 state->config->xtal)) in stv0367ter_algo()
1063 return -EINVAL; in stv0367ter_algo()
1065 ter_state->pBW = ter_state->bw; in stv0367ter_algo()
1070 if (ter_state->hierarchy == FE_TER_HIER_LOW_PRIO) in stv0367ter_algo()
1075 InternalFreq = stv0367ter_get_mclk(state, state->config->xtal) / 1000; in stv0367ter_algo()
1077 ((((ter_state->bw * 64 * (1 << 15) * 100) in stv0367ter_algo()
1088 temp = (int)(((1 << 17) * ter_state->bw * 1000) / (7 * (InternalFreq))); in stv0367ter_algo()
1095 ((InternalFreq - ifkhz) * (1 << 16) / (InternalFreq)); in stv0367ter_algo()
1101 ter_state->echo_pos = 0; in stv0367ter_algo()
1102 ter_state->ucblocks = 0; /* liplianin */ in stv0367ter_algo()
1103 ter_state->pBER = 0; /* liplianin */ in stv0367ter_algo()
1104 stv0367_writebits(state, F367TER_LONG_ECHO, ter_state->echo_pos); in stv0367ter_algo()
1109 ter_state->state = FE_TER_LOCKOK; in stv0367ter_algo()
1111 ter_state->mode = stv0367_readbits(state, F367TER_SYR_MODE); in stv0367ter_algo()
1112 ter_state->guard = stv0367_readbits(state, F367TER_SYR_GUARD); in stv0367ter_algo()
1114 ter_state->first_lock = 1; /* we know sense now :) */ in stv0367ter_algo()
1116 ter_state->agc_val = in stv0367ter_algo()
1129 offset -= 16777216; in stv0367ter_algo()
1133 if (ter_state->mode == FE_TER_MODE_2K) in stv0367ter_algo()
1135 else if (ter_state->mode == FE_TER_MODE_4K) in stv0367ter_algo()
1137 else if (ter_state->mode == FE_TER_MODE_8K) in stv0367ter_algo()
1144 offset = offset * -1; in stv0367ter_algo()
1147 if (ter_state->bw == 6) in stv0367ter_algo()
1149 else if (ter_state->bw == 7) in stv0367ter_algo()
1152 ter_state->frequency += offset; in stv0367ter_algo()
1162 timing_offset -= 65536; in stv0367ter_algo()
1170 tempo--; in stv0367ter_algo()
1174 timing_offset = (timing_offset - 11) / 22; in stv0367ter_algo()
1175 step = -1; in stv0367ter_algo()
1206 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ter_set_frontend()
1207 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_set_frontend()
1208 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_set_frontend()
1214 if (state->reinit_on_setfrontend) in stv0367ter_set_frontend()
1217 if (fe->ops.tuner_ops.set_params) { in stv0367ter_set_frontend()
1218 if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) in stv0367ter_set_frontend()
1219 fe->ops.i2c_gate_ctrl(fe, 1); in stv0367ter_set_frontend()
1220 fe->ops.tuner_ops.set_params(fe); in stv0367ter_set_frontend()
1221 if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) in stv0367ter_set_frontend()
1222 fe->ops.i2c_gate_ctrl(fe, 0); in stv0367ter_set_frontend()
1225 switch (p->transmission_mode) { in stv0367ter_set_frontend()
1229 ter_state->mode = FE_TER_MODE_2K; in stv0367ter_set_frontend()
1235 ter_state->mode = FE_TER_MODE_8K; in stv0367ter_set_frontend()
1239 switch (p->guard_interval) { in stv0367ter_set_frontend()
1245 ter_state->guard = p->guard_interval; in stv0367ter_set_frontend()
1248 ter_state->guard = GUARD_INTERVAL_1_32; in stv0367ter_set_frontend()
1252 switch (p->bandwidth_hz) { in stv0367ter_set_frontend()
1254 ter_state->bw = FE_TER_CHAN_BW_6M; in stv0367ter_set_frontend()
1257 ter_state->bw = FE_TER_CHAN_BW_7M; in stv0367ter_set_frontend()
1261 ter_state->bw = FE_TER_CHAN_BW_8M; in stv0367ter_set_frontend()
1264 ter_state->hierarchy = FE_TER_HIER_NONE; in stv0367ter_set_frontend()
1266 switch (p->inversion) { in stv0367ter_set_frontend()
1273 if (ter_state->first_lock) in stv0367ter_set_frontend()
1278 ter_state->state = FE_TER_NOLOCK; in stv0367ter_set_frontend()
1281 while (((index) < num_trials) && (ter_state->state != FE_TER_LOCKOK)) { in stv0367ter_set_frontend()
1282 if (!ter_state->first_lock) { in stv0367ter_set_frontend()
1283 if (p->inversion == INVERSION_AUTO) in stv0367ter_set_frontend()
1284 ter_state->sense = SenseTrials[index]; in stv0367ter_set_frontend()
1289 if ((ter_state->state == FE_TER_LOCKOK) && in stv0367ter_set_frontend()
1290 (p->inversion == INVERSION_AUTO) && in stv0367ter_set_frontend()
1305 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_read_ucblocks()
1306 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_read_ucblocks()
1317 ter_state->ucblocks = errs; in stv0367ter_read_ucblocks()
1320 (*ucblocks) = ter_state->ucblocks; in stv0367ter_read_ucblocks()
1328 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_get_frontend()
1329 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_get_frontend()
1333 p->frequency = stv0367_get_tuner_freq(fe); in stv0367ter_get_frontend()
1334 if ((int)p->frequency < 0) in stv0367ter_get_frontend()
1335 p->frequency = -p->frequency; in stv0367ter_get_frontend()
1339 p->modulation = QPSK; in stv0367ter_get_frontend()
1341 p->modulation = QAM_16; in stv0367ter_get_frontend()
1343 p->modulation = QAM_64; in stv0367ter_get_frontend()
1345 p->inversion = stv0367_readbits(state, F367TER_INV_SPECTR); in stv0367ter_get_frontend()
1352 p->hierarchy = HIERARCHY_NONE; in stv0367ter_get_frontend()
1355 p->hierarchy = HIERARCHY_1; in stv0367ter_get_frontend()
1358 p->hierarchy = HIERARCHY_2; in stv0367ter_get_frontend()
1361 p->hierarchy = HIERARCHY_4; in stv0367ter_get_frontend()
1364 p->hierarchy = HIERARCHY_AUTO; in stv0367ter_get_frontend()
1369 if (ter_state->hierarchy == FE_TER_HIER_LOW_PRIO) in stv0367ter_get_frontend()
1376 p->code_rate_HP = FEC_1_2; in stv0367ter_get_frontend()
1379 p->code_rate_HP = FEC_2_3; in stv0367ter_get_frontend()
1382 p->code_rate_HP = FEC_3_4; in stv0367ter_get_frontend()
1385 p->code_rate_HP = FEC_5_6; in stv0367ter_get_frontend()
1388 p->code_rate_HP = FEC_7_8; in stv0367ter_get_frontend()
1391 p->code_rate_HP = FEC_AUTO; in stv0367ter_get_frontend()
1399 p->transmission_mode = TRANSMISSION_MODE_2K; in stv0367ter_get_frontend()
1402 p->transmission_mode = TRANSMISSION_MODE_4K; in stv0367ter_get_frontend()
1405 p->transmission_mode = TRANSMISSION_MODE_8K; in stv0367ter_get_frontend()
1408 p->transmission_mode = TRANSMISSION_MODE_AUTO; in stv0367ter_get_frontend()
1411 p->guard_interval = stv0367_readbits(state, F367TER_SYR_GUARD); in stv0367ter_get_frontend()
1418 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_snr_readreg()
1450 struct stv0367_state *state = fe->demodulator_priv;
1451 struct stv0367ter_state *ter_state = state->ter_state;
1456 ter_state->unlock_counter += 1;
1458 ter_state->unlock_counter = 0;
1460 if (ter_state->unlock_counter > 2) {
1479 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_read_status()
1496 struct stv0367_state *state = fe->demodulator_priv; in stv0367ter_read_ber()
1497 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ter_read_ber()
1512 tber = ter_state->pBER; in stv0367ter_read_ber()
1570 ter_state->pBER = tber; in stv0367ter_read_ber()
1579 struct stv0367ter_state *ter_state = state->ter_state;
1639 ter_state->pPER = Per;
1648 fe_tune_settings->min_delay_ms = 1000; in stv0367_get_tune_settings()
1649 fe_tune_settings->step_size = 0; in stv0367_get_tune_settings()
1650 fe_tune_settings->max_drift = 0; in stv0367_get_tune_settings()
1657 struct stv0367_state *state = fe->demodulator_priv; in stv0367_release()
1659 kfree(state->ter_state); in stv0367_release()
1660 kfree(state->cab_state); in stv0367_release()
1667 .name = "ST STV0367 DVB-T",
1709 state->i2c = i2c; in stv0367ter_attach()
1710 state->config = config; in stv0367ter_attach()
1711 state->ter_state = ter_state; in stv0367ter_attach()
1712 state->fe.ops = stv0367ter_ops; in stv0367ter_attach()
1713 state->fe.demodulator_priv = state; in stv0367ter_attach()
1714 state->chip_id = stv0367_readreg(state, 0xf000); in stv0367ter_attach()
1717 state->use_i2c_gatectrl = 1; in stv0367ter_attach()
1718 state->deftabs = STV0367_DEFTAB_GENERIC; in stv0367ter_attach()
1719 state->reinit_on_setfrontend = 1; in stv0367ter_attach()
1720 state->auto_if_khz = 0; in stv0367ter_attach()
1722 dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id); in stv0367ter_attach()
1725 if ((state->chip_id != 0x50) && (state->chip_id != 0x60)) in stv0367ter_attach()
1728 return &state->fe; in stv0367ter_attach()
1739 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_gate_ctrl()
1750 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_get_mclk()
1896 derot_hz = derot_hz - adc_hz; in stv0367cab_set_derot_freq()
2127 (state->cab_state->qamfec_status_reg ? in stv0367cab_qamfec_lock()
2128 state->cab_state->qamfec_status_reg : in stv0367cab_qamfec_lock()
2187 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_read_status()
2193 /* update cab_state->state from QAM_FSM_STATUS */ in stv0367cab_read_status()
2194 state->cab_state->state = stv0367cab_fsm_signaltype( in stv0367cab_read_status()
2202 if (state->cab_state->state > FE_CAB_NOSIGNAL) in stv0367cab_read_status()
2205 if (state->cab_state->state > FE_CAB_NOCARRIER) in stv0367cab_read_status()
2208 if (state->cab_state->state >= FE_CAB_DEMODOK) in stv0367cab_read_status()
2211 if (state->cab_state->state >= FE_CAB_DATAOK) in stv0367cab_read_status()
2220 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_standby()
2254 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_init()
2255 struct stv0367cab_state *cab_state = state->cab_state; in stv0367cab_init()
2260 stv0367_deftabs[state->deftabs][STV0367_TAB_CAB]); in stv0367cab_init()
2262 switch (state->config->ts_mode) { in stv0367cab_init()
2277 switch (state->config->clk_pol) { in stv0367cab_init()
2297 cab_state->mclk = stv0367cab_get_mclk(fe, state->config->xtal); in stv0367cab_init()
2298 cab_state->adc_clk = stv0367cab_get_adc_freq(fe, state->config->xtal); in stv0367cab_init()
2306 struct stv0367cab_state *cab_state = state->cab_state; in stv0367cab_algo()
2322 TRLTimeOut = 100000000 / p->symbol_rate; in stv0367cab_algo()
2324 within [-4%, +4%] of the symbol rate. in stv0367cab_algo()
2326 for a lock within [-search_range, +search_range]. in stv0367cab_algo()
2328 the micro-reflections we want to handle. in stv0367cab_algo()
2332 switch (p->modulation) { in stv0367cab_algo()
2359 if (pIntParams->search_range < 0) { in stv0367cab_algo()
2361 (-pIntParams->search_range / 1000)) / in stv0367cab_algo()
2362 (pIntParams->symbol_rate / 1000); in stv0367cab_algo()
2365 CRLTimeOut = (25 * CRLSymbols * (cab_state->search_range / 1000)) / in stv0367cab_algo()
2366 (p->symbol_rate / 1000); in stv0367cab_algo()
2368 CRLTimeOut = (1000 * CRLTimeOut) / p->symbol_rate; in stv0367cab_algo()
2395 stv0367cab_set_derot_freq(state, cab_state->adc_clk, in stv0367cab_algo()
2396 (1000 * (s32)ifkhz + cab_state->derot_offset)); in stv0367cab_algo()
2398 if ((p->symbol_rate > 10800000) | (p->symbol_rate < 1800000)) { in stv0367cab_algo()
2414 if ((LockTime >= (DemodTimeOut - EQLTimeOut)) && in stv0367cab_algo()
2425 * it is not the right symbol rate or it is an analog in stv0367cab_algo()
2437 u32_tmp = 262144 - u32_tmp; in stv0367cab_algo()
2438 u32_tmp = u32_tmp / (1 << (11 - stv0367_readbits(state, in stv0367cab_algo()
2444 F367CAB_AGC_PWRREF_HI) - 10) in stv0367cab_algo()
2465 tmp = stv0367cab_get_derot_freq(state, cab_state->adc_clk); in stv0367cab_algo()
2481 cab_state->spect_inv = stv0367_readbits(state, in stv0367cab_algo()
2486 if (ifkhz > cab_state->adc_clk / 1000) { in stv0367cab_algo()
2487 cab_state->freq_khz = in stv0367cab_algo()
2488 FE_Cab_TunerGetFrequency(pIntParams->hTuner) in stv0367cab_algo()
2489 - stv0367cab_get_derot_freq(state, cab_state->adc_clk) in stv0367cab_algo()
2490 - cab_state->adc_clk / 1000 + ifkhz; in stv0367cab_algo()
2492 cab_state->freq_khz = in stv0367cab_algo()
2493 FE_Cab_TunerGetFrequency(pIntParams->hTuner) in stv0367cab_algo()
2494 - stv0367cab_get_derot_freq(state, cab_state->adc_clk) in stv0367cab_algo()
2498 cab_state->freq_khz = in stv0367cab_algo()
2499 FE_Cab_TunerGetFrequency(pIntParams->hTuner) + in stv0367cab_algo()
2501 cab_state->adc_clk) - in stv0367cab_algo()
2502 cab_state->adc_clk / 4000; in stv0367cab_algo()
2505 cab_state->symbol_rate = stv0367cab_GetSymbolRate(state, in stv0367cab_algo()
2506 cab_state->mclk); in stv0367cab_algo()
2507 cab_state->locked = 1; in stv0367cab_algo()
2520 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367cab_set_frontend()
2521 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_set_frontend()
2522 struct stv0367cab_state *cab_state = state->cab_state; in stv0367cab_set_frontend()
2526 p->frequency, p->symbol_rate); in stv0367cab_set_frontend()
2528 cab_state->derot_offset = 0; in stv0367cab_set_frontend()
2530 switch (p->modulation) { in stv0367cab_set_frontend()
2550 if (state->reinit_on_setfrontend) in stv0367cab_set_frontend()
2554 if (fe->ops.tuner_ops.set_params) { in stv0367cab_set_frontend()
2555 if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) in stv0367cab_set_frontend()
2556 fe->ops.i2c_gate_ctrl(fe, 1); in stv0367cab_set_frontend()
2557 fe->ops.tuner_ops.set_params(fe); in stv0367cab_set_frontend()
2558 if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) in stv0367cab_set_frontend()
2559 fe->ops.i2c_gate_ctrl(fe, 0); in stv0367cab_set_frontend()
2564 p->symbol_rate, in stv0367cab_set_frontend()
2568 cab_state->adc_clk, in stv0367cab_set_frontend()
2569 cab_state->mclk, in stv0367cab_set_frontend()
2570 p->symbol_rate, in stv0367cab_set_frontend()
2572 /* Search algorithm launch, [-1.1*RangeOffset, +1.1*RangeOffset] scan */ in stv0367cab_set_frontend()
2573 cab_state->state = stv0367cab_algo(state, p); in stv0367cab_set_frontend()
2580 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_get_frontend()
2581 struct stv0367cab_state *cab_state = state->cab_state; in stv0367cab_get_frontend()
2589 p->symbol_rate = stv0367cab_GetSymbolRate(state, cab_state->mclk); in stv0367cab_get_frontend()
2594 p->modulation = QAM_16; in stv0367cab_get_frontend()
2597 p->modulation = QAM_32; in stv0367cab_get_frontend()
2600 p->modulation = QAM_64; in stv0367cab_get_frontend()
2603 p->modulation = QAM_128; in stv0367cab_get_frontend()
2606 p->modulation = QAM_256; in stv0367cab_get_frontend()
2612 p->frequency = stv0367_get_tuner_freq(fe); in stv0367cab_get_frontend()
2614 dprintk("%s: tuner frequency = %d\n", __func__, p->frequency); in stv0367cab_get_frontend()
2617 p->frequency += in stv0367cab_get_frontend()
2618 (stv0367cab_get_derot_freq(state, cab_state->adc_clk) - in stv0367cab_get_frontend()
2619 cab_state->adc_clk / 4000); in stv0367cab_get_frontend()
2623 if (ifkhz > cab_state->adc_clk / 1000) in stv0367cab_get_frontend()
2624 p->frequency += (ifkhz in stv0367cab_get_frontend()
2625 - stv0367cab_get_derot_freq(state, cab_state->adc_clk) in stv0367cab_get_frontend()
2626 - cab_state->adc_clk / 1000); in stv0367cab_get_frontend()
2628 p->frequency += (ifkhz in stv0367cab_get_frontend()
2629 - stv0367cab_get_derot_freq(state, cab_state->adc_clk)); in stv0367cab_get_frontend()
2646 struct stv0367_state *state = fe->demodulator_priv;
2668 IfAgcPwm -= 2048; in stv0367cab_get_rf_lvl()
2678 rfLevel = (-1) * stv0367cab_RF_LookUp1[1][i]; in stv0367cab_get_rf_lvl()
2683 rfLevel = -56; in stv0367cab_get_rf_lvl()
2687 rfLevel = (-1) * stv0367cab_RF_LookUp2[1][i]; in stv0367cab_get_rf_lvl()
2692 rfLevel = -72; in stv0367cab_get_rf_lvl()
2699 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_read_strength()
2705 if (signal <= -72) in stv0367cab_read_strength()
2708 *strength = (22 + signal) * (-1311); in stv0367cab_read_strength()
2717 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_snr_power()
2745 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_snr_readreg()
2762 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_read_snr()
2787 else if (temp >= 1585) in stv0367cab_read_snr()
2817 struct stv0367_state *state = fe->demodulator_priv; in stv0367cab_read_ucblcks()
2836 .name = "ST STV0367 DVB-C",
2876 state->i2c = i2c; in stv0367cab_attach()
2877 state->config = config; in stv0367cab_attach()
2878 cab_state->search_range = 280000; in stv0367cab_attach()
2879 cab_state->qamfec_status_reg = F367CAB_QAMFEC_LOCK; in stv0367cab_attach()
2880 state->cab_state = cab_state; in stv0367cab_attach()
2881 state->fe.ops = stv0367cab_ops; in stv0367cab_attach()
2882 state->fe.demodulator_priv = state; in stv0367cab_attach()
2883 state->chip_id = stv0367_readreg(state, 0xf000); in stv0367cab_attach()
2886 state->use_i2c_gatectrl = 1; in stv0367cab_attach()
2887 state->deftabs = STV0367_DEFTAB_GENERIC; in stv0367cab_attach()
2888 state->reinit_on_setfrontend = 1; in stv0367cab_attach()
2889 state->auto_if_khz = 0; in stv0367cab_attach()
2891 dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id); in stv0367cab_attach()
2894 if ((state->chip_id != 0x50) && (state->chip_id != 0x60)) in stv0367cab_attach()
2897 return &state->fe; in stv0367cab_attach()
2930 stv0367_pll_setup(state, STV0367_ICSPEED_53125, state->config->xtal); in stv0367ddb_setup_ter()
2936 state->activedemod = demod_ter; in stv0367ddb_setup_ter()
2961 stv0367_pll_setup(state, STV0367_ICSPEED_58000, state->config->xtal); in stv0367ddb_setup_cab()
2967 state->cab_state->mclk = stv0367cab_get_mclk(&state->fe, in stv0367ddb_setup_cab()
2968 state->config->xtal); in stv0367ddb_setup_cab()
2969 state->cab_state->adc_clk = stv0367cab_get_adc_freq(&state->fe, in stv0367ddb_setup_cab()
2970 state->config->xtal); in stv0367ddb_setup_cab()
2972 state->activedemod = demod_cab; in stv0367ddb_setup_cab()
2977 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_set_frontend()
2979 switch (fe->dtv_property_cache.delivery_system) { in stv0367ddb_set_frontend()
2981 if (state->activedemod != demod_ter) in stv0367ddb_set_frontend()
2986 if (state->activedemod != demod_cab) in stv0367ddb_set_frontend()
2990 if (fe->dtv_property_cache.symbol_rate == 0) { in stv0367ddb_set_frontend()
2992 return -EINVAL; in stv0367ddb_set_frontend()
3000 return -EINVAL; in stv0367ddb_set_frontend()
3005 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_read_signal_strength()
3006 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ddb_read_signal_strength()
3009 switch (state->activedemod) { in stv0367ddb_read_signal_strength()
3014 p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_signal_strength()
3018 p->strength.stat[0].scale = FE_SCALE_DECIBEL; in stv0367ddb_read_signal_strength()
3019 p->strength.stat[0].uvalue = signalstrength; in stv0367ddb_read_signal_strength()
3024 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_read_snr()
3025 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ddb_read_snr()
3029 switch (state->activedemod) { in stv0367ddb_read_snr()
3047 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_snr()
3051 p->cnr.stat[0].scale = FE_SCALE_DECIBEL; in stv0367ddb_read_snr()
3052 p->cnr.stat[0].uvalue = snrval; in stv0367ddb_read_snr()
3057 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_read_ucblocks()
3058 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ddb_read_ucblocks()
3061 switch (state->activedemod) { in stv0367ddb_read_ucblocks()
3069 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_ucblocks()
3073 p->block_error.stat[0].scale = FE_SCALE_COUNTER; in stv0367ddb_read_ucblocks()
3074 p->block_error.stat[0].uvalue = ucblocks; in stv0367ddb_read_ucblocks()
3080 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_read_status()
3081 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in stv0367ddb_read_status()
3084 switch (state->activedemod) { in stv0367ddb_read_status()
3105 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_status()
3111 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_read_status()
3119 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_get_frontend()
3121 switch (state->activedemod) { in stv0367ddb_get_frontend()
3135 struct stv0367_state *state = fe->demodulator_priv; in stv0367ddb_sleep()
3137 switch (state->activedemod) { in stv0367ddb_sleep()
3139 state->activedemod = demod_none; in stv0367ddb_sleep()
3142 state->activedemod = demod_none; in stv0367ddb_sleep()
3148 return -EINVAL; in stv0367ddb_sleep()
3153 struct stv0367ter_state *ter_state = state->ter_state; in stv0367ddb_init()
3154 struct dtv_frontend_properties *p = &state->fe.dtv_property_cache; in stv0367ddb_init()
3158 if (stv0367_deftabs[state->deftabs][STV0367_TAB_BASE]) in stv0367ddb_init()
3160 stv0367_deftabs[state->deftabs][STV0367_TAB_BASE]); in stv0367ddb_init()
3163 stv0367_deftabs[state->deftabs][STV0367_TAB_CAB]); in stv0367ddb_init()
3167 stv0367_deftabs[state->deftabs][STV0367_TAB_TER]); in stv0367ddb_init()
3204 stv0367_pll_setup(state, STV0367_ICSPEED_58000, state->config->xtal); in stv0367ddb_init()
3225 ter_state->pBER = 0; in stv0367ddb_init()
3226 ter_state->first_lock = 0; in stv0367ddb_init()
3227 ter_state->unlock_counter = 2; in stv0367ddb_init()
3229 p->strength.len = 1; in stv0367ddb_init()
3230 p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_init()
3231 p->cnr.len = 1; in stv0367ddb_init()
3232 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_init()
3233 p->block_error.len = 1; in stv0367ddb_init()
3234 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in stv0367ddb_init()
3242 .name = "ST STV0367 DDB DVB-C/T",
3248 .caps = /* DVB-C */
3253 /* DVB-T */
3288 state->i2c = i2c; in stv0367ddb_attach()
3289 state->config = config; in stv0367ddb_attach()
3290 state->ter_state = ter_state; in stv0367ddb_attach()
3291 cab_state->search_range = 280000; in stv0367ddb_attach()
3292 cab_state->qamfec_status_reg = F367CAB_DESCR_SYNCSTATE; in stv0367ddb_attach()
3293 state->cab_state = cab_state; in stv0367ddb_attach()
3294 state->fe.ops = stv0367ddb_ops; in stv0367ddb_attach()
3295 state->fe.demodulator_priv = state; in stv0367ddb_attach()
3296 state->chip_id = stv0367_readreg(state, R367TER_ID); in stv0367ddb_attach()
3299 state->use_i2c_gatectrl = 0; in stv0367ddb_attach()
3300 state->deftabs = STV0367_DEFTAB_DDB; in stv0367ddb_attach()
3301 state->reinit_on_setfrontend = 0; in stv0367ddb_attach()
3302 state->auto_if_khz = 1; in stv0367ddb_attach()
3303 state->activedemod = demod_none; in stv0367ddb_attach()
3305 dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id); in stv0367ddb_attach()
3308 if ((state->chip_id != 0x50) && (state->chip_id != 0x60)) in stv0367ddb_attach()
3311 dev_info(&i2c->dev, "Found %s with ChipID %02X at adr %02X\n", in stv0367ddb_attach()
3312 state->fe.ops.info.name, state->chip_id, in stv0367ddb_attach()
3313 config->demod_address); in stv0367ddb_attach()
3317 return &state->fe; in stv0367ddb_attach()
3331 MODULE_DESCRIPTION("ST STV0367 DVB-C/T demodulator driver");