Lines Matching +full:reference +full:- +full:div2 +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-or-later
50 struct stb0899_internal *internal = &state->internal;
55 return stb0899_calc_srate(internal->master_clk, sfr);
71 dprintk(state->verbose, FE_DEBUG, 1, "-->"); in stb0899_set_srate()
122 struct stb0899_internal *internal = &state->internal; in stb0899_carr_width()
124 return (internal->srate + (internal->srate * internal->rolloff) / 100); in stb0899_carr_width()
133 struct stb0899_internal *internal = &state->internal; in stb0899_first_subrange()
134 struct stb0899_params *params = &state->params; in stb0899_first_subrange()
135 struct stb0899_config *config = state->config; in stb0899_first_subrange()
140 if (config->tuner_get_bandwidth) { in stb0899_first_subrange()
141 stb0899_i2c_gate_ctrl(&state->frontend, 1); in stb0899_first_subrange()
142 config->tuner_get_bandwidth(&state->frontend, &bandwidth); in stb0899_first_subrange()
143 stb0899_i2c_gate_ctrl(&state->frontend, 0); in stb0899_first_subrange()
144 range = bandwidth - stb0899_carr_width(state) / 2; in stb0899_first_subrange()
148 internal->sub_range = min(internal->srch_range, range); in stb0899_first_subrange()
150 internal->sub_range = 0; in stb0899_first_subrange()
152 internal->freq = params->freq; in stb0899_first_subrange()
153 internal->tuner_offst = 0L; in stb0899_first_subrange()
154 internal->sub_dir = 1; in stb0899_first_subrange()
164 struct stb0899_internal *internal = &state->internal; in stb0899_check_tmg()
169 msleep(internal->t_derot); in stb0899_check_tmg()
178 internal->status = ANALOGCARRIER; in stb0899_check_tmg()
179 dprintk(state->verbose, FE_DEBUG, 1, "-->ANALOG Carrier !"); in stb0899_check_tmg()
181 internal->status = TIMINGOK; in stb0899_check_tmg()
182 dprintk(state->verbose, FE_DEBUG, 1, "------->TIMING OK !"); in stb0899_check_tmg()
185 internal->status = NOTIMING; in stb0899_check_tmg()
186 dprintk(state->verbose, FE_DEBUG, 1, "-->NO TIMING !"); in stb0899_check_tmg()
188 return internal->status; in stb0899_check_tmg()
193 * perform a fs/2 zig-zag to find timing
197 struct stb0899_internal *internal = &state->internal; in stb0899_search_tmg()
198 struct stb0899_params *params = &state->params; in stb0899_search_tmg()
204 internal->status = NOTIMING; in stb0899_search_tmg()
207 derot_limit = (internal->sub_range / 2L) / internal->mclk; in stb0899_search_tmg()
208 derot_step = (params->srate / 2L) / internal->mclk; in stb0899_search_tmg()
212 derot_freq += index * internal->direction * derot_step; /* next derot zig zag position */ in stb0899_search_tmg()
215 next_loop--; in stb0899_search_tmg()
218 STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq)); in stb0899_search_tmg()
219 STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq)); in stb0899_search_tmg()
222 internal->direction = -internal->direction; /* Change zigzag direction */ in stb0899_search_tmg()
225 if (internal->status == TIMINGOK) { in stb0899_search_tmg()
227 internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]); in stb0899_search_tmg()
228 dprintk(state->verbose, FE_DEBUG, 1, "------->TIMING OK ! Derot Freq = %d", internal->derot_freq); in stb0899_search_tmg()
231 return internal->status; in stb0899_search_tmg()
240 struct stb0899_internal *internal = &state->internal; in stb0899_check_carrier()
243 msleep(internal->t_derot); /* wait for derotator ok */ in stb0899_check_carrier()
250 dprintk(state->verbose, FE_DEBUG, 1, "--------------------> STB0899_DSTATUS=[0x%02x]", reg); in stb0899_check_carrier()
252 internal->status = CARRIEROK; in stb0899_check_carrier()
253 dprintk(state->verbose, FE_DEBUG, 1, "-------------> CARRIEROK !"); in stb0899_check_carrier()
255 internal->status = NOCARRIER; in stb0899_check_carrier()
256 dprintk(state->verbose, FE_DEBUG, 1, "-------------> NOCARRIER !"); in stb0899_check_carrier()
259 return internal->status; in stb0899_check_carrier()
268 struct stb0899_internal *internal = &state->internal; in stb0899_search_carrier()
275 internal->status = NOCARRIER; in stb0899_search_carrier()
276 derot_limit = (internal->sub_range / 2L) / internal->mclk; in stb0899_search_carrier()
277 derot_freq = internal->derot_freq; in stb0899_search_carrier()
284 dprintk(state->verbose, FE_DEBUG, 1, "Derot Freq=%d, mclk=%d", derot_freq, internal->mclk); in stb0899_search_carrier()
288 …derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator positi… in stb0899_search_carrier()
291 next_loop--; in stb0899_search_carrier()
298 STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq)); in stb0899_search_carrier()
299 STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq)); in stb0899_search_carrier()
304 internal->direction = -internal->direction; /* Change zigzag direction */ in stb0899_search_carrier()
305 } while ((internal->status != CARRIEROK) && next_loop); in stb0899_search_carrier()
307 if (internal->status == CARRIEROK) { in stb0899_search_carrier()
309 internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]); in stb0899_search_carrier()
310 dprintk(state->verbose, FE_DEBUG, 1, "----> CARRIER OK !, Derot Freq=%d", internal->derot_freq); in stb0899_search_carrier()
312 internal->derot_freq = last_derot_freq; in stb0899_search_carrier()
315 return internal->status; in stb0899_search_carrier()
324 struct stb0899_internal *internal = &state->internal; in stb0899_check_data()
325 struct stb0899_params *params = &state->params; in stb0899_check_data()
330 internal->status = NODATA; in stb0899_check_data()
341 if (params->srate <= 2000000) in stb0899_check_data()
343 else if (params->srate <= 5000000) in stb0899_check_data()
345 else if (params->srate <= 15000000) in stb0899_check_data()
366 internal->status = DATAOK; in stb0899_check_data()
367 dprintk(state->verbose, FE_DEBUG, 1, "-----------------> DATA OK !"); in stb0899_check_data()
370 return internal->status; in stb0899_check_data()
384 struct stb0899_internal *internal = &state->internal; in stb0899_search_data()
385 struct stb0899_params *params = &state->params; in stb0899_search_data()
387 derot_step = (params->srate / 4L) / internal->mclk; in stb0899_search_data()
388 derot_limit = (internal->sub_range / 2L) / internal->mclk; in stb0899_search_data()
389 derot_freq = internal->derot_freq; in stb0899_search_data()
392 if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) { in stb0899_search_data()
394 derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */ in stb0899_search_data()
396 next_loop--; in stb0899_search_data()
399 dprintk(state->verbose, FE_DEBUG, 1, "Derot freq=%d, mclk=%d", derot_freq, internal->mclk); in stb0899_search_data()
404 STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq)); in stb0899_search_data()
405 STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq)); in stb0899_search_data()
412 internal->direction = -internal->direction; /* change zig zag direction */ in stb0899_search_data()
413 } while ((internal->status != DATAOK) && next_loop); in stb0899_search_data()
415 if (internal->status == DATAOK) { in stb0899_search_data()
418 /* store autodetected IQ swapping as default for DVB-S2 tuning */ in stb0899_search_data()
421 internal->inversion = IQ_SWAP_ON; in stb0899_search_data()
423 internal->inversion = IQ_SWAP_OFF; in stb0899_search_data()
425 internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]); in stb0899_search_data()
426 dprintk(state->verbose, FE_DEBUG, 1, "------> DATAOK ! Derot Freq=%d", internal->derot_freq); in stb0899_search_data()
429 return internal->status; in stb0899_search_data()
438 struct stb0899_internal *internal = &state->internal; in stb0899_check_range()
439 struct stb0899_params *params = &state->params; in stb0899_check_range()
443 range_offst = internal->srch_range / 2000; in stb0899_check_range()
444 tp_freq = internal->freq - (internal->derot_freq * internal->mclk) / 1000; in stb0899_check_range()
446 if ((tp_freq >= params->freq - range_offst) && (tp_freq <= params->freq + range_offst)) { in stb0899_check_range()
447 internal->status = RANGEOK; in stb0899_check_range()
448 dprintk(state->verbose, FE_DEBUG, 1, "----> RANGEOK !"); in stb0899_check_range()
450 internal->status = OUTOFRANGE; in stb0899_check_range()
451 dprintk(state->verbose, FE_DEBUG, 1, "----> OUT OF RANGE !"); in stb0899_check_range()
454 return internal->status; in stb0899_check_range()
463 struct stb0899_internal *internal = &state->internal; in next_sub_range()
464 struct stb0899_params *params = &state->params; in next_sub_range()
468 if (internal->sub_dir > 0) { in next_sub_range()
469 old_sub_range = internal->sub_range; in next_sub_range()
470 internal->sub_range = min((internal->srch_range / 2) - in next_sub_range()
471 (internal->tuner_offst + internal->sub_range / 2), in next_sub_range()
472 internal->sub_range); in next_sub_range()
474 if (internal->sub_range < 0) in next_sub_range()
475 internal->sub_range = 0; in next_sub_range()
477 internal->tuner_offst += (old_sub_range + internal->sub_range) / 2; in next_sub_range()
480 internal->freq = params->freq + (internal->sub_dir * internal->tuner_offst) / 1000; in next_sub_range()
481 internal->sub_dir = -internal->sub_dir; in next_sub_range()
491 struct stb0899_params *params = &state->params; in stb0899_dvbs_algo()
492 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs_algo()
493 struct stb0899_config *config = state->config; in stb0899_dvbs_algo()
511 internal->direction = 1; in stb0899_dvbs_algo()
513 stb0899_set_srate(state, internal->master_clk, params->srate); in stb0899_dvbs_algo()
515 if (params->srate <= 5000000) { in stb0899_dvbs_algo()
521 } else if (params->srate <= 15000000) { in stb0899_dvbs_algo()
527 } else if(params->srate <= 25000000) { in stb0899_dvbs_algo()
541 dprintk(state->verbose, FE_DEBUG, 1, "Set the timing loop to acquisition"); in stb0899_dvbs_algo()
552 dprintk(state->verbose, FE_DEBUG, 1, "Derot Percent=%d Srate=%d mclk=%d", in stb0899_dvbs_algo()
553 internal->derot_percent, params->srate, internal->mclk); in stb0899_dvbs_algo()
556 …internal->derot_step = internal->derot_percent * (params->srate / 1000L) / internal->mclk; /* Dero… in stb0899_dvbs_algo()
557 internal->t_derot = stb0899_calc_derot_time(params->srate); in stb0899_dvbs_algo()
558 internal->t_data = 500; in stb0899_dvbs_algo()
560 dprintk(state->verbose, FE_DEBUG, 1, "RESET stream merger"); in stb0899_dvbs_algo()
588 internal->derot_freq = 0; in stb0899_dvbs_algo()
589 internal->status = NOAGC1; in stb0899_dvbs_algo()
591 /* enable tuner I/O */ in stb0899_dvbs_algo()
592 stb0899_i2c_gate_ctrl(&state->frontend, 1); in stb0899_dvbs_algo()
595 dprintk(state->verbose, FE_DEBUG, 1, "Tuner set frequency"); in stb0899_dvbs_algo()
596 if (state->config->tuner_set_frequency) in stb0899_dvbs_algo()
597 state->config->tuner_set_frequency(&state->frontend, internal->freq); in stb0899_dvbs_algo()
599 if (state->config->tuner_get_frequency) in stb0899_dvbs_algo()
600 state->config->tuner_get_frequency(&state->frontend, &internal->freq); in stb0899_dvbs_algo()
602 msleep(internal->t_agc1 + internal->t_agc2 + internal->t_derot); /* AGC1, AGC2 and timing loop */ in stb0899_dvbs_algo()
603 dprintk(state->verbose, FE_DEBUG, 1, "current derot freq=%d", internal->derot_freq); in stb0899_dvbs_algo()
604 internal->status = AGC1OK; in stb0899_dvbs_algo()
607 if (config->tuner_get_bandwidth) in stb0899_dvbs_algo()
608 config->tuner_get_bandwidth(&state->frontend, &bandwidth); in stb0899_dvbs_algo()
611 stb0899_i2c_gate_ctrl(&state->frontend, 0); in stb0899_dvbs_algo()
613 if (params->srate <= bandwidth / 2) in stb0899_dvbs_algo()
618 if (internal->status == TIMINGOK) { in stb0899_dvbs_algo()
619 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
621 internal->derot_freq, internal->mclk); in stb0899_dvbs_algo()
624 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
626 internal->derot_freq, internal->mclk); in stb0899_dvbs_algo()
629 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
631 internal->derot_freq, internal->mclk); in stb0899_dvbs_algo()
634 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
636 internal->derot_freq, internal->mclk); in stb0899_dvbs_algo()
638 internal->freq = params->freq - ((internal->derot_freq * internal->mclk) / 1000); in stb0899_dvbs_algo()
640 internal->fecrate = STB0899_GETFIELD(VITCURPUN, reg); in stb0899_dvbs_algo()
641 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
643 params->freq, internal->freq); in stb0899_dvbs_algo()
645 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
647 internal->fecrate); in stb0899_dvbs_algo()
652 if (internal->status != RANGEOK) in stb0899_dvbs_algo()
655 } while (internal->sub_range && internal->status != RANGEOK); in stb0899_dvbs_algo()
661 if (internal->status == RANGEOK) { in stb0899_dvbs_algo()
662 dprintk(state->verbose, FE_DEBUG, 1, "Locked & Range OK !"); in stb0899_dvbs_algo()
671 switch (internal->fecrate) { in stb0899_dvbs_algo()
703 dprintk(state->verbose, FE_DEBUG, 1, "Unsupported Puncture Rate"); in stb0899_dvbs_algo()
719 return internal->status; in stb0899_dvbs_algo()
728 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_config_uwp()
729 struct stb0899_config *config = state->config; in stb0899_dvbs2_config_uwp()
736 STB0899_SETFIELD_VAL(UWP_ESN0_AVE, uwp1, config->esno_ave); in stb0899_dvbs2_config_uwp()
737 STB0899_SETFIELD_VAL(UWP_ESN0_QUANT, uwp1, config->esno_quant); in stb0899_dvbs2_config_uwp()
738 STB0899_SETFIELD_VAL(UWP_TH_SOF, uwp1, config->uwp_threshold_sof); in stb0899_dvbs2_config_uwp()
740 STB0899_SETFIELD_VAL(FE_COARSE_TRK, uwp2, internal->av_frame_coarse); in stb0899_dvbs2_config_uwp()
741 STB0899_SETFIELD_VAL(FE_FINE_TRK, uwp2, internal->av_frame_fine); in stb0899_dvbs2_config_uwp()
742 STB0899_SETFIELD_VAL(UWP_MISS_TH, uwp2, config->miss_threshold); in stb0899_dvbs2_config_uwp()
744 STB0899_SETFIELD_VAL(UWP_TH_ACQ, uwp3, config->uwp_threshold_acq); in stb0899_dvbs2_config_uwp()
745 STB0899_SETFIELD_VAL(UWP_TH_TRACK, uwp3, config->uwp_threshold_track); in stb0899_dvbs2_config_uwp()
752 STB0899_SETFIELD_VAL(SOF_SEARCH_TIMEOUT, reg, config->sof_search_timeout); in stb0899_dvbs2_config_uwp()
780 return i - 1; in Log2Int()
789 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_calc_srate()
790 struct stb0899_config *config = state->config; in stb0899_dvbs2_calc_srate()
795 dec_ratio = (internal->master_clk * 2) / (5 * internal->srate); in stb0899_dvbs2_calc_srate()
799 master_clk = internal->master_clk / 1000; in stb0899_dvbs2_calc_srate()
800 srate = internal->srate / 1000; in stb0899_dvbs2_calc_srate()
803 intval = (decim * (1 << (config->btr_nco_bits - 1))) / master_clk; in stb0899_dvbs2_calc_srate()
804 remain = (decim * (1 << (config->btr_nco_bits - 1))) % master_clk; in stb0899_dvbs2_calc_srate()
806 intval = (1 << (config->btr_nco_bits - 1)) / (master_clk / 100) * decim / 100; in stb0899_dvbs2_calc_srate()
807 remain = (decim * (1 << (config->btr_nco_bits - 1))) % master_clk; in stb0899_dvbs2_calc_srate()
820 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_calc_dev()
823 dec_ratio = (internal->master_clk * 2) / (5 * internal->srate); in stb0899_dvbs2_calc_dev()
826 master_clk = internal->master_clk / 1000; /* for integer Calculation*/ in stb0899_dvbs2_calc_dev()
827 srate = internal->srate / 1000; /* for integer Calculation*/ in stb0899_dvbs2_calc_dev()
839 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_set_srate()
846 dec_ratio = (internal->master_clk * 2) / (5 * internal->srate); in stb0899_dvbs2_set_srate()
852 win_sel = dec_rate - 4; in stb0899_dvbs2_set_srate()
856 f_sym = internal->master_clk / ((decim * internal->srate) / 1000); in stb0899_dvbs2_set_srate()
883 freq_adj = internal->srate / (internal->master_clk / 4096); in stb0899_dvbs2_set_srate()
893 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_set_btr_loopbw()
894 struct stb0899_config *config = state->config; in stb0899_dvbs2_set_btr_loopbw()
902 dec_ratio = (internal->master_clk * 2) / (5 * internal->srate); in stb0899_dvbs2_set_btr_loopbw()
908 K = (1 << config->btr_nco_bits) / (internal->master_clk / 1000); in stb0899_dvbs2_set_btr_loopbw()
909 K *= (internal->srate / 1000000) * decim; /*k=k 10^-8*/ in stb0899_dvbs2_set_btr_loopbw()
914 wn = (2 * (loopbw_percent * 1000) * 40 * zeta) /wn; /*wn =wn 10^-8*/ in stb0899_dvbs2_set_btr_loopbw()
916 k_indirect = (wn * wn) / K; /*kindirect = kindirect 10^-6*/ in stb0899_dvbs2_set_btr_loopbw()
917 k_direct = (2 * wn * zeta) / K; /*kDirect = kDirect 10^-2*/ in stb0899_dvbs2_set_btr_loopbw()
920 k_direct_shift = Log2Int(k_direct) - Log2Int(10000) - 2; in stb0899_dvbs2_set_btr_loopbw()
921 k_btr1_rshft = (-1 * k_direct_shift) + config->btr_gain_shift_offset; in stb0899_dvbs2_set_btr_loopbw()
925 k_indirect_shift = Log2Int(k_indirect + 15) - 20 /*- 2*/; in stb0899_dvbs2_set_btr_loopbw()
926 k_btr0_rshft = (-1 * k_indirect_shift) + config->btr_gain_shift_offset; in stb0899_dvbs2_set_btr_loopbw()
927 k_btr0 = k_indirect * (1 << (-k_indirect_shift)); in stb0899_dvbs2_set_btr_loopbw()
932 k_btr2_rshft = k_btr0_rshft - 15; in stb0899_dvbs2_set_btr_loopbw()
952 struct stb0899_config *config = state->config; in stb0899_dvbs2_set_carr_freq()
956 crl_nom_freq = (1 << config->crl_nco_bits) / master_clk; in stb0899_dvbs2_set_carr_freq()
969 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_init_calc()
981 if (internal->srate / 1000000 >= 15) in stb0899_dvbs2_init_calc()
983 else if (internal->srate / 1000000 >= 10) in stb0899_dvbs2_init_calc()
985 else if (internal->srate / 1000000 >= 5) in stb0899_dvbs2_init_calc()
990 range = internal->srch_range / 1000000; in stb0899_dvbs2_init_calc()
991 steps = (10 * range * (1 << 17)) / (step_size * (internal->srate / 1000000)); in stb0899_dvbs2_init_calc()
995 stb0899_dvbs2_set_carr_freq(state, internal->center_freq - in stb0899_dvbs2_init_calc()
996 (internal->step_size * (internal->srate / 20000000)), in stb0899_dvbs2_init_calc()
997 (internal->master_clk) / 1000000); in stb0899_dvbs2_init_calc()
999 stb0899_dvbs2_set_carr_freq(state, internal->center_freq, (internal->master_clk) / 1000000); in stb0899_dvbs2_init_calc()
1017 /* set enable BTR loopback */ in stb0899_dvbs2_btr_init()
1034 * trigger a DVB-S2 acquisition
1082 * get DVB-S2 Demod LOCK status
1086 int time = -10, lock = 0, uwp, csm; in stb0899_dvbs2_get_dmd_status()
1091 dprintk(state->verbose, FE_DEBUG, 1, "DMD_STATUS=[0x%02x]", reg); in stb0899_dvbs2_get_dmd_status()
1093 dprintk(state->verbose, FE_DEBUG, 1, "------------->IF AGC LOCKED !"); in stb0899_dvbs2_get_dmd_status()
1095 dprintk(state->verbose, FE_DEBUG, 1, "----------->DMD STAT2=[0x%02x]", reg); in stb0899_dvbs2_get_dmd_status()
1107 dprintk(state->verbose, FE_DEBUG, 1, "----------------> DVB-S2 LOCK !"); in stb0899_dvbs2_get_dmd_status()
1125 dprintk(state->verbose, FE_DEBUG, 1, "---------> CFGPDELSTATUS=[0x%02x]", reg); in stb0899_dvbs2_get_data_lock()
1135 * get DVB-S2 FEC LOCK status
1149 dprintk(state->verbose, FE_DEBUG, 1, "---------->DVB-S2 FEC LOCK !"); in stb0899_dvbs2_get_fec_status()
1163 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_init_csm()
1169 if (((internal->master_clk / internal->srate) <= 4) && (modcod <= 11) && (pilots == 1)) { in stb0899_dvbs2_init_csm()
1266 * get DVB-S2 Symbol Rate
1270 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_get_srate()
1271 struct stb0899_config *config = state->config; in stb0899_dvbs2_get_srate()
1274 int div1, div2, rem1, rem2; in stb0899_dvbs2_get_srate() local
1276 div1 = config->btr_nco_bits / 2; in stb0899_dvbs2_get_srate()
1277 div2 = config->btr_nco_bits - div1 - 1; in stb0899_dvbs2_get_srate()
1285 intval1 = internal->master_clk / (1 << div1); in stb0899_dvbs2_get_srate()
1286 intval2 = bTrNomFreq / (1 << div2); in stb0899_dvbs2_get_srate()
1288 rem1 = internal->master_clk % (1 << div1); in stb0899_dvbs2_get_srate()
1289 rem2 = bTrNomFreq % (1 << div2); in stb0899_dvbs2_get_srate()
1291 srate = (intval1 * intval2) + ((intval1 * rem2) / (1 << div2)) + ((intval2 * rem1) / (1 << div1)); in stb0899_dvbs2_get_srate()
1304 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_algo()
1311 if (internal->srate <= 2000000) { in stb0899_dvbs2_algo()
1314 } else if (internal->srate <= 5000000) { in stb0899_dvbs2_algo()
1317 } else if (internal->srate <= 10000000) { in stb0899_dvbs2_algo()
1320 } else if (internal->srate <= 15000000) { in stb0899_dvbs2_algo()
1323 } else if (internal->srate <= 20000000) { in stb0899_dvbs2_algo()
1326 } else if (internal->srate <= 25000000) { in stb0899_dvbs2_algo()
1339 /* enable tuner I/O */ in stb0899_dvbs2_algo()
1340 stb0899_i2c_gate_ctrl(&state->frontend, 1); in stb0899_dvbs2_algo()
1343 if (state->config->tuner_set_frequency) in stb0899_dvbs2_algo()
1344 state->config->tuner_set_frequency(&state->frontend, internal->freq); in stb0899_dvbs2_algo()
1345 if (state->config->tuner_get_frequency) in stb0899_dvbs2_algo()
1346 state->config->tuner_get_frequency(&state->frontend, &internal->freq); in stb0899_dvbs2_algo()
1349 stb0899_i2c_gate_ctrl(&state->frontend, 0); in stb0899_dvbs2_algo()
1365 switch (internal->inversion) { in stb0899_dvbs2_algo()
1377 internal->status = stb0899_dvbs2_get_dmd_status(state, searchTime); in stb0899_dvbs2_algo()
1379 if (internal->status == DVBS2_DEMOD_LOCK) { in stb0899_dvbs2_algo()
1380 dprintk(state->verbose, FE_DEBUG, 1, "------------> DVB-S2 DEMOD LOCK !"); in stb0899_dvbs2_algo()
1383 internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); in stb0899_dvbs2_algo()
1386 while ((internal->status != DVBS2_FEC_LOCK) && (i < 3)) { in stb0899_dvbs2_algo()
1395 internal->status = stb0899_dvbs2_get_fec_status(state, searchTime); in stb0899_dvbs2_algo()
1400 if (internal->status != DVBS2_FEC_LOCK) { in stb0899_dvbs2_algo()
1410 internal->status = stb0899_dvbs2_get_dmd_status(state, searchTime); in stb0899_dvbs2_algo()
1411 if (internal->status == DVBS2_DEMOD_LOCK) { in stb0899_dvbs2_algo()
1414 internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); in stb0899_dvbs2_algo()
1416 while ((internal->status != DVBS2_FEC_LOCK) && (i < 3)) { in stb0899_dvbs2_algo()
1426 internal->status = stb0899_dvbs2_get_fec_status(state, searchTime); in stb0899_dvbs2_algo()
1431 if (pParams->DVBS2State == FE_DVBS2_FEC_LOCKED) in stb0899_dvbs2_algo()
1432 pParams->IQLocked = !iqSpectrum; in stb0899_dvbs2_algo()
1435 if (internal->status == DVBS2_FEC_LOCK) { in stb0899_dvbs2_algo()
1436 dprintk(state->verbose, FE_DEBUG, 1, "----------------> DVB-S2 FEC Lock !"); in stb0899_dvbs2_algo()
1441 if ((((10 * internal->master_clk) / (internal->srate / 10)) <= 410) && in stb0899_dvbs2_algo()
1447 internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); in stb0899_dvbs2_algo()
1450 while ((internal->status != DVBS2_FEC_LOCK) && (i < 3)) { in stb0899_dvbs2_algo()
1458 internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); in stb0899_dvbs2_algo()
1463 if ((((10 * internal->master_clk) / (internal->srate / 10)) <= 410) && in stb0899_dvbs2_algo()
1484 offsetfreq *= (internal->master_clk / 1000000); in stb0899_dvbs2_algo()
1489 internal->inversion = IQ_SWAP_ON; in stb0899_dvbs2_algo()
1491 internal->inversion = IQ_SWAP_OFF; in stb0899_dvbs2_algo()
1493 internal->freq = internal->freq + offsetfreq; in stb0899_dvbs2_algo()
1494 internal->srate = stb0899_dvbs2_get_srate(state); in stb0899_dvbs2_algo()
1497 internal->modcod = STB0899_GETFIELD(UWP_DECODE_MOD, reg) >> 2; in stb0899_dvbs2_algo()
1498 internal->pilots = STB0899_GETFIELD(UWP_DECODE_MOD, reg) & 0x01; in stb0899_dvbs2_algo()
1499 internal->frame_length = (STB0899_GETFIELD(UWP_DECODE_MOD, reg) >> 1) & 0x01; in stb0899_dvbs2_algo()
1505 /* if QPSK 1/2,QPSK 3/5 or QPSK 2/3 set IF AGC reference to 16 otherwise 32*/ in stb0899_dvbs2_algo()
1506 if (INRANGE(STB0899_QPSK_12, internal->modcod, STB0899_QPSK_23)) in stb0899_dvbs2_algo()
1521 return internal->status; in stb0899_dvbs2_algo()