Lines Matching +full:acquisition +full:- +full:time
62 struct stb0899_internal *internal = &state->internal;
67 return stb0899_calc_srate(internal->master_clk, sfr);
83 dprintk(state->verbose, FE_DEBUG, 1, "-->"); in stb0899_set_srate()
115 * Compute the amount of time needed by the derotator to lock
117 * return: derotator time constant (ms)
134 struct stb0899_internal *internal = &state->internal; in stb0899_carr_width()
136 return (internal->srate + (internal->srate * internal->rolloff) / 100); in stb0899_carr_width()
145 struct stb0899_internal *internal = &state->internal; in stb0899_first_subrange()
146 struct stb0899_params *params = &state->params; in stb0899_first_subrange()
147 struct stb0899_config *config = state->config; in stb0899_first_subrange()
152 if (config->tuner_get_bandwidth) { in stb0899_first_subrange()
153 stb0899_i2c_gate_ctrl(&state->frontend, 1); in stb0899_first_subrange()
154 config->tuner_get_bandwidth(&state->frontend, &bandwidth); in stb0899_first_subrange()
155 stb0899_i2c_gate_ctrl(&state->frontend, 0); in stb0899_first_subrange()
156 range = bandwidth - stb0899_carr_width(state) / 2; in stb0899_first_subrange()
160 internal->sub_range = min(internal->srch_range, range); in stb0899_first_subrange()
162 internal->sub_range = 0; in stb0899_first_subrange()
164 internal->freq = params->freq; in stb0899_first_subrange()
165 internal->tuner_offst = 0L; in stb0899_first_subrange()
166 internal->sub_dir = 1; in stb0899_first_subrange()
172 * internal.Ttiming: time to wait for loop lock
176 struct stb0899_internal *internal = &state->internal; in stb0899_check_tmg()
181 msleep(internal->t_derot); in stb0899_check_tmg()
190 internal->status = ANALOGCARRIER; in stb0899_check_tmg()
191 dprintk(state->verbose, FE_DEBUG, 1, "-->ANALOG Carrier !"); in stb0899_check_tmg()
193 internal->status = TIMINGOK; in stb0899_check_tmg()
194 dprintk(state->verbose, FE_DEBUG, 1, "------->TIMING OK !"); in stb0899_check_tmg()
197 internal->status = NOTIMING; in stb0899_check_tmg()
198 dprintk(state->verbose, FE_DEBUG, 1, "-->NO TIMING !"); in stb0899_check_tmg()
200 return internal->status; in stb0899_check_tmg()
205 * perform a fs/2 zig-zag to find timing
209 struct stb0899_internal *internal = &state->internal; in stb0899_search_tmg()
210 struct stb0899_params *params = &state->params; in stb0899_search_tmg()
216 internal->status = NOTIMING; in stb0899_search_tmg()
219 derot_limit = (internal->sub_range / 2L) / internal->mclk; in stb0899_search_tmg()
220 derot_step = (params->srate / 2L) / internal->mclk; in stb0899_search_tmg()
224 derot_freq += index * internal->direction * derot_step; /* next derot zig zag position */ in stb0899_search_tmg()
227 next_loop--; in stb0899_search_tmg()
230 STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq)); in stb0899_search_tmg()
231 STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq)); in stb0899_search_tmg()
234 internal->direction = -internal->direction; /* Change zigzag direction */ in stb0899_search_tmg()
237 if (internal->status == TIMINGOK) { in stb0899_search_tmg()
239 internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]); in stb0899_search_tmg()
240 dprintk(state->verbose, FE_DEBUG, 1, "------->TIMING OK ! Derot Freq = %d", internal->derot_freq); in stb0899_search_tmg()
243 return internal->status; in stb0899_search_tmg()
252 struct stb0899_internal *internal = &state->internal; in stb0899_check_carrier()
255 msleep(internal->t_derot); /* wait for derotator ok */ in stb0899_check_carrier()
262 dprintk(state->verbose, FE_DEBUG, 1, "--------------------> STB0899_DSTATUS=[0x%02x]", reg); in stb0899_check_carrier()
264 internal->status = CARRIEROK; in stb0899_check_carrier()
265 dprintk(state->verbose, FE_DEBUG, 1, "-------------> CARRIEROK !"); in stb0899_check_carrier()
267 internal->status = NOCARRIER; in stb0899_check_carrier()
268 dprintk(state->verbose, FE_DEBUG, 1, "-------------> NOCARRIER !"); in stb0899_check_carrier()
271 return internal->status; in stb0899_check_carrier()
280 struct stb0899_internal *internal = &state->internal; in stb0899_search_carrier()
287 internal->status = NOCARRIER; in stb0899_search_carrier()
288 derot_limit = (internal->sub_range / 2L) / internal->mclk; in stb0899_search_carrier()
289 derot_freq = internal->derot_freq; in stb0899_search_carrier()
296 dprintk(state->verbose, FE_DEBUG, 1, "Derot Freq=%d, mclk=%d", derot_freq, internal->mclk); in stb0899_search_carrier()
300 …derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator positi… in stb0899_search_carrier()
303 next_loop--; in stb0899_search_carrier()
310 STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq)); in stb0899_search_carrier()
311 STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq)); in stb0899_search_carrier()
316 internal->direction = -internal->direction; /* Change zigzag direction */ in stb0899_search_carrier()
317 } while ((internal->status != CARRIEROK) && next_loop); in stb0899_search_carrier()
319 if (internal->status == CARRIEROK) { in stb0899_search_carrier()
321 internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]); in stb0899_search_carrier()
322 dprintk(state->verbose, FE_DEBUG, 1, "----> CARRIER OK !, Derot Freq=%d", internal->derot_freq); in stb0899_search_carrier()
324 internal->derot_freq = last_derot_freq; in stb0899_search_carrier()
327 return internal->status; in stb0899_search_carrier()
336 struct stb0899_internal *internal = &state->internal; in stb0899_check_data()
337 struct stb0899_params *params = &state->params; in stb0899_check_data()
342 internal->status = NODATA; in stb0899_check_data()
353 if (params->srate <= 2000000) in stb0899_check_data()
355 else if (params->srate <= 5000000) in stb0899_check_data()
357 else if (params->srate <= 15000000) in stb0899_check_data()
378 internal->status = DATAOK; in stb0899_check_data()
379 dprintk(state->verbose, FE_DEBUG, 1, "-----------------> DATA OK !"); in stb0899_check_data()
382 return internal->status; in stb0899_check_data()
396 struct stb0899_internal *internal = &state->internal; in stb0899_search_data()
397 struct stb0899_params *params = &state->params; in stb0899_search_data()
399 derot_step = (params->srate / 4L) / internal->mclk; in stb0899_search_data()
400 derot_limit = (internal->sub_range / 2L) / internal->mclk; in stb0899_search_data()
401 derot_freq = internal->derot_freq; in stb0899_search_data()
404 if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) { in stb0899_search_data()
406 derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */ in stb0899_search_data()
408 next_loop--; in stb0899_search_data()
411 dprintk(state->verbose, FE_DEBUG, 1, "Derot freq=%d, mclk=%d", derot_freq, internal->mclk); in stb0899_search_data()
416 STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq)); in stb0899_search_data()
417 STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq)); in stb0899_search_data()
424 internal->direction = -internal->direction; /* change zig zag direction */ in stb0899_search_data()
425 } while ((internal->status != DATAOK) && next_loop); in stb0899_search_data()
427 if (internal->status == DATAOK) { in stb0899_search_data()
430 /* store autodetected IQ swapping as default for DVB-S2 tuning */ in stb0899_search_data()
433 internal->inversion = IQ_SWAP_ON; in stb0899_search_data()
435 internal->inversion = IQ_SWAP_OFF; in stb0899_search_data()
437 internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]); in stb0899_search_data()
438 dprintk(state->verbose, FE_DEBUG, 1, "------> DATAOK ! Derot Freq=%d", internal->derot_freq); in stb0899_search_data()
441 return internal->status; in stb0899_search_data()
450 struct stb0899_internal *internal = &state->internal; in stb0899_check_range()
451 struct stb0899_params *params = &state->params; in stb0899_check_range()
455 range_offst = internal->srch_range / 2000; in stb0899_check_range()
456 tp_freq = internal->freq - (internal->derot_freq * internal->mclk) / 1000; in stb0899_check_range()
458 if ((tp_freq >= params->freq - range_offst) && (tp_freq <= params->freq + range_offst)) { in stb0899_check_range()
459 internal->status = RANGEOK; in stb0899_check_range()
460 dprintk(state->verbose, FE_DEBUG, 1, "----> RANGEOK !"); in stb0899_check_range()
462 internal->status = OUTOFRANGE; in stb0899_check_range()
463 dprintk(state->verbose, FE_DEBUG, 1, "----> OUT OF RANGE !"); in stb0899_check_range()
466 return internal->status; in stb0899_check_range()
475 struct stb0899_internal *internal = &state->internal; in next_sub_range()
476 struct stb0899_params *params = &state->params; in next_sub_range()
480 if (internal->sub_dir > 0) { in next_sub_range()
481 old_sub_range = internal->sub_range; in next_sub_range()
482 internal->sub_range = min((internal->srch_range / 2) - in next_sub_range()
483 (internal->tuner_offst + internal->sub_range / 2), in next_sub_range()
484 internal->sub_range); in next_sub_range()
486 if (internal->sub_range < 0) in next_sub_range()
487 internal->sub_range = 0; in next_sub_range()
489 internal->tuner_offst += (old_sub_range + internal->sub_range) / 2; in next_sub_range()
492 internal->freq = params->freq + (internal->sub_dir * internal->tuner_offst) / 1000; in next_sub_range()
493 internal->sub_dir = -internal->sub_dir; in next_sub_range()
503 struct stb0899_params *params = &state->params; in stb0899_dvbs_algo()
504 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs_algo()
505 struct stb0899_config *config = state->config; in stb0899_dvbs_algo()
523 internal->direction = 1; in stb0899_dvbs_algo()
525 stb0899_set_srate(state, internal->master_clk, params->srate); in stb0899_dvbs_algo()
526 /* Carrier loop optimization versus symbol rate for acquisition*/ in stb0899_dvbs_algo()
527 if (params->srate <= 5000000) { in stb0899_dvbs_algo()
533 } else if (params->srate <= 15000000) { in stb0899_dvbs_algo()
539 } else if(params->srate <= 25000000) { in stb0899_dvbs_algo()
553 dprintk(state->verbose, FE_DEBUG, 1, "Set the timing loop to acquisition"); in stb0899_dvbs_algo()
554 /* Set the timing loop to acquisition */ in stb0899_dvbs_algo()
559 * Do not read any status variables while acquisition, in stb0899_dvbs_algo()
560 * If any needed, read before the acquisition starts in stb0899_dvbs_algo()
562 * acquisition to go bad and hence no locks. in stb0899_dvbs_algo()
564 dprintk(state->verbose, FE_DEBUG, 1, "Derot Percent=%d Srate=%d mclk=%d", in stb0899_dvbs_algo()
565 internal->derot_percent, params->srate, internal->mclk); in stb0899_dvbs_algo()
568 …internal->derot_step = internal->derot_percent * (params->srate / 1000L) / internal->mclk; /* Dero… in stb0899_dvbs_algo()
569 internal->t_derot = stb0899_calc_derot_time(params->srate); in stb0899_dvbs_algo()
570 internal->t_data = 500; in stb0899_dvbs_algo()
572 dprintk(state->verbose, FE_DEBUG, 1, "RESET stream merger"); in stb0899_dvbs_algo()
580 * 1/2 and 7/8 for acquisition in stb0899_dvbs_algo()
600 internal->derot_freq = 0; in stb0899_dvbs_algo()
601 internal->status = NOAGC1; in stb0899_dvbs_algo()
604 stb0899_i2c_gate_ctrl(&state->frontend, 1); in stb0899_dvbs_algo()
607 dprintk(state->verbose, FE_DEBUG, 1, "Tuner set frequency"); in stb0899_dvbs_algo()
608 if (state->config->tuner_set_frequency) in stb0899_dvbs_algo()
609 state->config->tuner_set_frequency(&state->frontend, internal->freq); in stb0899_dvbs_algo()
611 if (state->config->tuner_get_frequency) in stb0899_dvbs_algo()
612 state->config->tuner_get_frequency(&state->frontend, &internal->freq); in stb0899_dvbs_algo()
614 msleep(internal->t_agc1 + internal->t_agc2 + internal->t_derot); /* AGC1, AGC2 and timing loop */ in stb0899_dvbs_algo()
615 dprintk(state->verbose, FE_DEBUG, 1, "current derot freq=%d", internal->derot_freq); in stb0899_dvbs_algo()
616 internal->status = AGC1OK; in stb0899_dvbs_algo()
619 if (config->tuner_get_bandwidth) in stb0899_dvbs_algo()
620 config->tuner_get_bandwidth(&state->frontend, &bandwidth); in stb0899_dvbs_algo()
623 stb0899_i2c_gate_ctrl(&state->frontend, 0); in stb0899_dvbs_algo()
625 if (params->srate <= bandwidth / 2) in stb0899_dvbs_algo()
630 if (internal->status == TIMINGOK) { in stb0899_dvbs_algo()
631 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
633 internal->derot_freq, internal->mclk); in stb0899_dvbs_algo()
636 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
638 internal->derot_freq, internal->mclk); in stb0899_dvbs_algo()
641 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
643 internal->derot_freq, internal->mclk); in stb0899_dvbs_algo()
646 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
648 internal->derot_freq, internal->mclk); in stb0899_dvbs_algo()
650 internal->freq = params->freq - ((internal->derot_freq * internal->mclk) / 1000); in stb0899_dvbs_algo()
652 internal->fecrate = STB0899_GETFIELD(VITCURPUN, reg); in stb0899_dvbs_algo()
653 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
655 params->freq, internal->freq); in stb0899_dvbs_algo()
657 dprintk(state->verbose, FE_DEBUG, 1, in stb0899_dvbs_algo()
659 internal->fecrate); in stb0899_dvbs_algo()
664 if (internal->status != RANGEOK) in stb0899_dvbs_algo()
667 } while (internal->sub_range && internal->status != RANGEOK); in stb0899_dvbs_algo()
673 if (internal->status == RANGEOK) { in stb0899_dvbs_algo()
674 dprintk(state->verbose, FE_DEBUG, 1, "Locked & Range OK !"); in stb0899_dvbs_algo()
676 stb0899_write_reg(state, STB0899_VITSYNC, 0x39); /* SN to b'11 for acquisition */ in stb0899_dvbs_algo()
683 switch (internal->fecrate) { in stb0899_dvbs_algo()
715 dprintk(state->verbose, FE_DEBUG, 1, "Unsupported Puncture Rate"); in stb0899_dvbs_algo()
731 return internal->status; in stb0899_dvbs_algo()
740 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_config_uwp()
741 struct stb0899_config *config = state->config; in stb0899_dvbs2_config_uwp()
748 STB0899_SETFIELD_VAL(UWP_ESN0_AVE, uwp1, config->esno_ave); in stb0899_dvbs2_config_uwp()
749 STB0899_SETFIELD_VAL(UWP_ESN0_QUANT, uwp1, config->esno_quant); in stb0899_dvbs2_config_uwp()
750 STB0899_SETFIELD_VAL(UWP_TH_SOF, uwp1, config->uwp_threshold_sof); in stb0899_dvbs2_config_uwp()
752 STB0899_SETFIELD_VAL(FE_COARSE_TRK, uwp2, internal->av_frame_coarse); in stb0899_dvbs2_config_uwp()
753 STB0899_SETFIELD_VAL(FE_FINE_TRK, uwp2, internal->av_frame_fine); in stb0899_dvbs2_config_uwp()
754 STB0899_SETFIELD_VAL(UWP_MISS_TH, uwp2, config->miss_threshold); in stb0899_dvbs2_config_uwp()
756 STB0899_SETFIELD_VAL(UWP_TH_ACQ, uwp3, config->uwp_threshold_acq); in stb0899_dvbs2_config_uwp()
757 STB0899_SETFIELD_VAL(UWP_TH_TRACK, uwp3, config->uwp_threshold_track); in stb0899_dvbs2_config_uwp()
764 STB0899_SETFIELD_VAL(SOF_SEARCH_TIMEOUT, reg, config->sof_search_timeout); in stb0899_dvbs2_config_uwp()
792 return i - 1; in Log2Int()
801 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_calc_srate()
802 struct stb0899_config *config = state->config; in stb0899_dvbs2_calc_srate()
807 dec_ratio = (internal->master_clk * 2) / (5 * internal->srate); in stb0899_dvbs2_calc_srate()
811 master_clk = internal->master_clk / 1000; in stb0899_dvbs2_calc_srate()
812 srate = internal->srate / 1000; in stb0899_dvbs2_calc_srate()
815 intval = (decim * (1 << (config->btr_nco_bits - 1))) / master_clk; in stb0899_dvbs2_calc_srate()
816 remain = (decim * (1 << (config->btr_nco_bits - 1))) % master_clk; in stb0899_dvbs2_calc_srate()
818 intval = (1 << (config->btr_nco_bits - 1)) / (master_clk / 100) * decim / 100; in stb0899_dvbs2_calc_srate()
819 remain = (decim * (1 << (config->btr_nco_bits - 1))) % master_clk; in stb0899_dvbs2_calc_srate()
832 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_calc_dev()
835 dec_ratio = (internal->master_clk * 2) / (5 * internal->srate); in stb0899_dvbs2_calc_dev()
838 master_clk = internal->master_clk / 1000; /* for integer Caculation*/ in stb0899_dvbs2_calc_dev()
839 srate = internal->srate / 1000; /* for integer Caculation*/ in stb0899_dvbs2_calc_dev()
851 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_set_srate()
858 dec_ratio = (internal->master_clk * 2) / (5 * internal->srate); in stb0899_dvbs2_set_srate()
864 win_sel = dec_rate - 4; in stb0899_dvbs2_set_srate()
868 f_sym = internal->master_clk / ((decim * internal->srate) / 1000); in stb0899_dvbs2_set_srate()
895 freq_adj = internal->srate / (internal->master_clk / 4096); in stb0899_dvbs2_set_srate()
905 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_set_btr_loopbw()
906 struct stb0899_config *config = state->config; in stb0899_dvbs2_set_btr_loopbw()
914 dec_ratio = (internal->master_clk * 2) / (5 * internal->srate); in stb0899_dvbs2_set_btr_loopbw()
920 K = (1 << config->btr_nco_bits) / (internal->master_clk / 1000); in stb0899_dvbs2_set_btr_loopbw()
921 K *= (internal->srate / 1000000) * decim; /*k=k 10^-8*/ in stb0899_dvbs2_set_btr_loopbw()
926 wn = (2 * (loopbw_percent * 1000) * 40 * zeta) /wn; /*wn =wn 10^-8*/ in stb0899_dvbs2_set_btr_loopbw()
928 k_indirect = (wn * wn) / K; /*kindirect = kindirect 10^-6*/ in stb0899_dvbs2_set_btr_loopbw()
929 k_direct = (2 * wn * zeta) / K; /*kDirect = kDirect 10^-2*/ in stb0899_dvbs2_set_btr_loopbw()
932 k_direct_shift = Log2Int(k_direct) - Log2Int(10000) - 2; in stb0899_dvbs2_set_btr_loopbw()
933 k_btr1_rshft = (-1 * k_direct_shift) + config->btr_gain_shift_offset; in stb0899_dvbs2_set_btr_loopbw()
937 k_indirect_shift = Log2Int(k_indirect + 15) - 20 /*- 2*/; in stb0899_dvbs2_set_btr_loopbw()
938 k_btr0_rshft = (-1 * k_indirect_shift) + config->btr_gain_shift_offset; in stb0899_dvbs2_set_btr_loopbw()
939 k_btr0 = k_indirect * (1 << (-k_indirect_shift)); in stb0899_dvbs2_set_btr_loopbw()
944 k_btr2_rshft = k_btr0_rshft - 15; in stb0899_dvbs2_set_btr_loopbw()
964 struct stb0899_config *config = state->config; in stb0899_dvbs2_set_carr_freq()
968 crl_nom_freq = (1 << config->crl_nco_bits) / master_clk; in stb0899_dvbs2_set_carr_freq()
981 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_init_calc()
993 if (internal->srate / 1000000 >= 15) in stb0899_dvbs2_init_calc()
995 else if (internal->srate / 1000000 >= 10) in stb0899_dvbs2_init_calc()
997 else if (internal->srate / 1000000 >= 5) in stb0899_dvbs2_init_calc()
1002 range = internal->srch_range / 1000000; in stb0899_dvbs2_init_calc()
1003 steps = (10 * range * (1 << 17)) / (step_size * (internal->srate / 1000000)); in stb0899_dvbs2_init_calc()
1007 stb0899_dvbs2_set_carr_freq(state, internal->center_freq - in stb0899_dvbs2_init_calc()
1008 (internal->step_size * (internal->srate / 20000000)), in stb0899_dvbs2_init_calc()
1009 (internal->master_clk) / 1000000); in stb0899_dvbs2_init_calc()
1011 stb0899_dvbs2_set_carr_freq(state, internal->center_freq, (internal->master_clk) / 1000000); in stb0899_dvbs2_init_calc()
1046 * trigger a DVB-S2 acquisition
1071 /* start acquisition process */ in stb0899_dvbs2_reacquire()
1094 * get DVB-S2 Demod LOCK status
1098 int time = -10, lock = 0, uwp, csm; in stb0899_dvbs2_get_dmd_status() local
1103 dprintk(state->verbose, FE_DEBUG, 1, "DMD_STATUS=[0x%02x]", reg); in stb0899_dvbs2_get_dmd_status()
1105 dprintk(state->verbose, FE_DEBUG, 1, "------------->IF AGC LOCKED !"); in stb0899_dvbs2_get_dmd_status()
1107 dprintk(state->verbose, FE_DEBUG, 1, "----------->DMD STAT2=[0x%02x]", reg); in stb0899_dvbs2_get_dmd_status()
1113 time += 10; in stb0899_dvbs2_get_dmd_status()
1116 } while ((!lock) && (time <= timeout)); in stb0899_dvbs2_get_dmd_status()
1119 dprintk(state->verbose, FE_DEBUG, 1, "----------------> DVB-S2 LOCK !"); in stb0899_dvbs2_get_dmd_status()
1132 int time = 0, lock = 0; in stb0899_dvbs2_get_data_lock() local
1135 while ((!lock) && (time < timeout)) { in stb0899_dvbs2_get_data_lock()
1137 dprintk(state->verbose, FE_DEBUG, 1, "---------> CFGPDELSTATUS=[0x%02x]", reg); in stb0899_dvbs2_get_data_lock()
1139 time++; in stb0899_dvbs2_get_data_lock()
1147 * get DVB-S2 FEC LOCK status
1151 int time = 0, Locked; in stb0899_dvbs2_get_fec_status() local
1155 time++; in stb0899_dvbs2_get_fec_status()
1158 } while ((!Locked) && (time < timeout)); in stb0899_dvbs2_get_fec_status()
1161 dprintk(state->verbose, FE_DEBUG, 1, "---------->DVB-S2 FEC LOCK !"); in stb0899_dvbs2_get_fec_status()
1175 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_init_csm()
1181 if (((internal->master_clk / internal->srate) <= 4) && (modcod <= 11) && (pilots == 1)) { in stb0899_dvbs2_init_csm()
1278 * get DVB-S2 Symbol Rate
1282 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_get_srate()
1283 struct stb0899_config *config = state->config; in stb0899_dvbs2_get_srate()
1288 div1 = config->btr_nco_bits / 2; in stb0899_dvbs2_get_srate()
1289 div2 = config->btr_nco_bits - div1 - 1; in stb0899_dvbs2_get_srate()
1297 intval1 = internal->master_clk / (1 << div1); in stb0899_dvbs2_get_srate()
1300 rem1 = internal->master_clk % (1 << div1); in stb0899_dvbs2_get_srate()
1316 struct stb0899_internal *internal = &state->internal; in stb0899_dvbs2_algo()
1323 if (internal->srate <= 2000000) { in stb0899_dvbs2_algo()
1324 searchTime = 5000; /* 5000 ms max time to lock UWP and CSM, SYMB <= 2Mbs */ in stb0899_dvbs2_algo()
1325 FecLockTime = 350; /* 350 ms max time to lock FEC, SYMB <= 2Mbs */ in stb0899_dvbs2_algo()
1326 } else if (internal->srate <= 5000000) { in stb0899_dvbs2_algo()
1327 searchTime = 2500; /* 2500 ms max time to lock UWP and CSM, 2Mbs < SYMB <= 5Mbs */ in stb0899_dvbs2_algo()
1328 FecLockTime = 170; /* 170 ms max time to lock FEC, 2Mbs< SYMB <= 5Mbs */ in stb0899_dvbs2_algo()
1329 } else if (internal->srate <= 10000000) { in stb0899_dvbs2_algo()
1330 searchTime = 1500; /* 1500 ms max time to lock UWP and CSM, 5Mbs <SYMB <= 10Mbs */ in stb0899_dvbs2_algo()
1331 FecLockTime = 80; /* 80 ms max time to lock FEC, 5Mbs< SYMB <= 10Mbs */ in stb0899_dvbs2_algo()
1332 } else if (internal->srate <= 15000000) { in stb0899_dvbs2_algo()
1333 searchTime = 500; /* 500 ms max time to lock UWP and CSM, 10Mbs <SYMB <= 15Mbs */ in stb0899_dvbs2_algo()
1334 FecLockTime = 50; /* 50 ms max time to lock FEC, 10Mbs< SYMB <= 15Mbs */ in stb0899_dvbs2_algo()
1335 } else if (internal->srate <= 20000000) { in stb0899_dvbs2_algo()
1336 searchTime = 300; /* 300 ms max time to lock UWP and CSM, 15Mbs < SYMB <= 20Mbs */ in stb0899_dvbs2_algo()
1337 FecLockTime = 30; /* 50 ms max time to lock FEC, 15Mbs< SYMB <= 20Mbs */ in stb0899_dvbs2_algo()
1338 } else if (internal->srate <= 25000000) { in stb0899_dvbs2_algo()
1339 searchTime = 250; /* 250 ms max time to lock UWP and CSM, 20 Mbs < SYMB <= 25Mbs */ in stb0899_dvbs2_algo()
1340 FecLockTime = 25; /* 25 ms max time to lock FEC, 20Mbs< SYMB <= 25Mbs */ in stb0899_dvbs2_algo()
1342 searchTime = 150; /* 150 ms max time to lock UWP and CSM, SYMB > 25Mbs */ in stb0899_dvbs2_algo()
1343 FecLockTime = 20; /* 20 ms max time to lock FEC, 20Mbs< SYMB <= 25Mbs */ in stb0899_dvbs2_algo()
1346 /* Maintain Stream Merger in reset during acquisition */ in stb0899_dvbs2_algo()
1352 stb0899_i2c_gate_ctrl(&state->frontend, 1); in stb0899_dvbs2_algo()
1355 if (state->config->tuner_set_frequency) in stb0899_dvbs2_algo()
1356 state->config->tuner_set_frequency(&state->frontend, internal->freq); in stb0899_dvbs2_algo()
1357 if (state->config->tuner_get_frequency) in stb0899_dvbs2_algo()
1358 state->config->tuner_get_frequency(&state->frontend, &internal->freq); in stb0899_dvbs2_algo()
1361 stb0899_i2c_gate_ctrl(&state->frontend, 0); in stb0899_dvbs2_algo()
1363 /* Set IF AGC to acquisition */ in stb0899_dvbs2_algo()
1377 switch (internal->inversion) { in stb0899_dvbs2_algo()
1389 internal->status = stb0899_dvbs2_get_dmd_status(state, searchTime); in stb0899_dvbs2_algo()
1391 if (internal->status == DVBS2_DEMOD_LOCK) { in stb0899_dvbs2_algo()
1392 dprintk(state->verbose, FE_DEBUG, 1, "------------> DVB-S2 DEMOD LOCK !"); in stb0899_dvbs2_algo()
1395 internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); in stb0899_dvbs2_algo()
1397 /*If false lock (UWP and CSM Locked but no FEC) try 3 time max*/ in stb0899_dvbs2_algo()
1398 while ((internal->status != DVBS2_FEC_LOCK) && (i < 3)) { in stb0899_dvbs2_algo()
1407 internal->status = stb0899_dvbs2_get_fec_status(state, searchTime); in stb0899_dvbs2_algo()
1412 if (internal->status != DVBS2_FEC_LOCK) { in stb0899_dvbs2_algo()
1422 internal->status = stb0899_dvbs2_get_dmd_status(state, searchTime); in stb0899_dvbs2_algo()
1423 if (internal->status == DVBS2_DEMOD_LOCK) { in stb0899_dvbs2_algo()
1426 internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); in stb0899_dvbs2_algo()
1428 while ((internal->status != DVBS2_FEC_LOCK) && (i < 3)) { in stb0899_dvbs2_algo()
1438 internal->status = stb0899_dvbs2_get_fec_status(state, searchTime); in stb0899_dvbs2_algo()
1443 if (pParams->DVBS2State == FE_DVBS2_FEC_LOCKED) in stb0899_dvbs2_algo()
1444 pParams->IQLocked = !iqSpectrum; in stb0899_dvbs2_algo()
1447 if (internal->status == DVBS2_FEC_LOCK) { in stb0899_dvbs2_algo()
1448 dprintk(state->verbose, FE_DEBUG, 1, "----------------> DVB-S2 FEC Lock !"); in stb0899_dvbs2_algo()
1453 if ((((10 * internal->master_clk) / (internal->srate / 10)) <= 410) && in stb0899_dvbs2_algo()
1459 internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); in stb0899_dvbs2_algo()
1462 while ((internal->status != DVBS2_FEC_LOCK) && (i < 3)) { in stb0899_dvbs2_algo()
1470 internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); in stb0899_dvbs2_algo()
1475 if ((((10 * internal->master_clk) / (internal->srate / 10)) <= 410) && in stb0899_dvbs2_algo()
1496 offsetfreq *= (internal->master_clk / 1000000); in stb0899_dvbs2_algo()
1501 internal->inversion = IQ_SWAP_ON; in stb0899_dvbs2_algo()
1503 internal->inversion = IQ_SWAP_OFF; in stb0899_dvbs2_algo()
1505 internal->freq = internal->freq + offsetfreq; in stb0899_dvbs2_algo()
1506 internal->srate = stb0899_dvbs2_get_srate(state); in stb0899_dvbs2_algo()
1509 internal->modcod = STB0899_GETFIELD(UWP_DECODE_MOD, reg) >> 2; in stb0899_dvbs2_algo()
1510 internal->pilots = STB0899_GETFIELD(UWP_DECODE_MOD, reg) & 0x01; in stb0899_dvbs2_algo()
1511 internal->frame_length = (STB0899_GETFIELD(UWP_DECODE_MOD, reg) >> 1) & 0x01; in stb0899_dvbs2_algo()
1518 if (INRANGE(STB0899_QPSK_12, internal->modcod, STB0899_QPSK_23)) in stb0899_dvbs2_algo()
1533 return internal->status; in stb0899_dvbs2_algo()