Lines Matching refs:antcomb
71 static inline bool ath_is_alt_ant_ratio_better(struct ath_ant_comb *antcomb, in ath_is_alt_ant_ratio_better() argument
82 if (alt_ratio >= antcomb->ant_ratio2 && in ath_is_alt_ant_ratio_better()
83 alt_rssi_avg >= antcomb->low_rssi_thresh && in ath_is_alt_ant_ratio_better()
91 struct ath_ant_comb *antcomb, in ath_ant_div_comb_alt_check() argument
114 if (alt_rssi_avg < 4 || alt_rssi_avg < antcomb->low_rssi_thresh) in ath_ant_div_comb_alt_check()
119 (alt_ratio > antcomb->ant_ratio)) in ath_ant_div_comb_alt_check()
124 if (alt_rssi_avg < 4 || alt_rssi_avg < antcomb->low_rssi_thresh) in ath_ant_div_comb_alt_check()
129 (alt_ratio > antcomb->ant_ratio)) in ath_ant_div_comb_alt_check()
138 static void ath_lnaconf_alt_good_scan(struct ath_ant_comb *antcomb, in ath_lnaconf_alt_good_scan() argument
142 antcomb->quick_scan_cnt = 0; in ath_lnaconf_alt_good_scan()
145 antcomb->rssi_lna2 = main_rssi_avg; in ath_lnaconf_alt_good_scan()
147 antcomb->rssi_lna1 = main_rssi_avg; in ath_lnaconf_alt_good_scan()
151 antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; in ath_lnaconf_alt_good_scan()
152 antcomb->first_quick_scan_conf = in ath_lnaconf_alt_good_scan()
154 antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1; in ath_lnaconf_alt_good_scan()
157 antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; in ath_lnaconf_alt_good_scan()
158 antcomb->first_quick_scan_conf = in ath_lnaconf_alt_good_scan()
160 antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA2; in ath_lnaconf_alt_good_scan()
163 antcomb->main_conf = ATH_ANT_DIV_COMB_LNA2; in ath_lnaconf_alt_good_scan()
164 antcomb->first_quick_scan_conf = in ath_lnaconf_alt_good_scan()
166 antcomb->second_quick_scan_conf = in ath_lnaconf_alt_good_scan()
170 antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1; in ath_lnaconf_alt_good_scan()
171 antcomb->first_quick_scan_conf = in ath_lnaconf_alt_good_scan()
173 antcomb->second_quick_scan_conf = in ath_lnaconf_alt_good_scan()
177 antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; in ath_lnaconf_alt_good_scan()
178 antcomb->first_quick_scan_conf = in ath_lnaconf_alt_good_scan()
180 antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1; in ath_lnaconf_alt_good_scan()
183 antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; in ath_lnaconf_alt_good_scan()
184 antcomb->first_quick_scan_conf = in ath_lnaconf_alt_good_scan()
186 antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA2; in ath_lnaconf_alt_good_scan()
193 static void ath_ant_set_alt_ratio(struct ath_ant_comb *antcomb, in ath_ant_set_alt_ratio() argument
197 if (antcomb->first_ratio && antcomb->second_ratio) { in ath_ant_set_alt_ratio()
198 if (antcomb->rssi_second > antcomb->rssi_third) { in ath_ant_set_alt_ratio()
200 if ((antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) || in ath_ant_set_alt_ratio()
201 (antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) in ath_ant_set_alt_ratio()
210 antcomb->first_quick_scan_conf; in ath_ant_set_alt_ratio()
211 } else if ((antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) || in ath_ant_set_alt_ratio()
212 (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) { in ath_ant_set_alt_ratio()
220 conf->alt_lna_conf = antcomb->second_quick_scan_conf; in ath_ant_set_alt_ratio()
222 } else if (antcomb->first_ratio) { in ath_ant_set_alt_ratio()
224 if ((antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) || in ath_ant_set_alt_ratio()
225 (antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) in ath_ant_set_alt_ratio()
233 conf->alt_lna_conf = antcomb->first_quick_scan_conf; in ath_ant_set_alt_ratio()
234 } else if (antcomb->second_ratio) { in ath_ant_set_alt_ratio()
236 if ((antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) || in ath_ant_set_alt_ratio()
237 (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) in ath_ant_set_alt_ratio()
245 conf->alt_lna_conf = antcomb->second_quick_scan_conf; in ath_ant_set_alt_ratio()
248 if ((antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) || in ath_ant_set_alt_ratio()
249 (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2)) in ath_ant_set_alt_ratio()
257 conf->alt_lna_conf = antcomb->main_conf; in ath_ant_set_alt_ratio()
261 static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb, in ath_select_ant_div_from_quick_scan() argument
267 switch (antcomb->quick_scan_cnt) { in ath_select_ant_div_from_quick_scan()
270 div_ant_conf->main_lna_conf = antcomb->main_conf; in ath_select_ant_div_from_quick_scan()
271 div_ant_conf->alt_lna_conf = antcomb->first_quick_scan_conf; in ath_select_ant_div_from_quick_scan()
275 div_ant_conf->main_lna_conf = antcomb->main_conf; in ath_select_ant_div_from_quick_scan()
276 div_ant_conf->alt_lna_conf = antcomb->second_quick_scan_conf; in ath_select_ant_div_from_quick_scan()
277 antcomb->rssi_first = main_rssi_avg; in ath_select_ant_div_from_quick_scan()
278 antcomb->rssi_second = alt_rssi_avg; in ath_select_ant_div_from_quick_scan()
280 if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) { in ath_select_ant_div_from_quick_scan()
282 if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, in ath_select_ant_div_from_quick_scan()
286 antcomb->total_pkt_count)) in ath_select_ant_div_from_quick_scan()
287 antcomb->first_ratio = true; in ath_select_ant_div_from_quick_scan()
289 antcomb->first_ratio = false; in ath_select_ant_div_from_quick_scan()
290 } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) { in ath_select_ant_div_from_quick_scan()
291 if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, in ath_select_ant_div_from_quick_scan()
295 antcomb->total_pkt_count)) in ath_select_ant_div_from_quick_scan()
296 antcomb->first_ratio = true; in ath_select_ant_div_from_quick_scan()
298 antcomb->first_ratio = false; in ath_select_ant_div_from_quick_scan()
300 if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, in ath_select_ant_div_from_quick_scan()
304 antcomb->total_pkt_count)) in ath_select_ant_div_from_quick_scan()
305 antcomb->first_ratio = true; in ath_select_ant_div_from_quick_scan()
307 antcomb->first_ratio = false; in ath_select_ant_div_from_quick_scan()
311 antcomb->alt_good = false; in ath_select_ant_div_from_quick_scan()
312 antcomb->scan_not_start = false; in ath_select_ant_div_from_quick_scan()
313 antcomb->scan = false; in ath_select_ant_div_from_quick_scan()
314 antcomb->rssi_first = main_rssi_avg; in ath_select_ant_div_from_quick_scan()
315 antcomb->rssi_third = alt_rssi_avg; in ath_select_ant_div_from_quick_scan()
317 switch(antcomb->second_quick_scan_conf) { in ath_select_ant_div_from_quick_scan()
319 antcomb->rssi_lna1 = alt_rssi_avg; in ath_select_ant_div_from_quick_scan()
322 antcomb->rssi_lna2 = alt_rssi_avg; in ath_select_ant_div_from_quick_scan()
325 if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) in ath_select_ant_div_from_quick_scan()
326 antcomb->rssi_lna2 = main_rssi_avg; in ath_select_ant_div_from_quick_scan()
327 else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) in ath_select_ant_div_from_quick_scan()
328 antcomb->rssi_lna1 = main_rssi_avg; in ath_select_ant_div_from_quick_scan()
334 if (antcomb->rssi_lna2 > antcomb->rssi_lna1 + in ath_select_ant_div_from_quick_scan()
340 if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) { in ath_select_ant_div_from_quick_scan()
341 if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, in ath_select_ant_div_from_quick_scan()
345 antcomb->total_pkt_count)) in ath_select_ant_div_from_quick_scan()
346 antcomb->second_ratio = true; in ath_select_ant_div_from_quick_scan()
348 antcomb->second_ratio = false; in ath_select_ant_div_from_quick_scan()
349 } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) { in ath_select_ant_div_from_quick_scan()
350 if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, in ath_select_ant_div_from_quick_scan()
354 antcomb->total_pkt_count)) in ath_select_ant_div_from_quick_scan()
355 antcomb->second_ratio = true; in ath_select_ant_div_from_quick_scan()
357 antcomb->second_ratio = false; in ath_select_ant_div_from_quick_scan()
359 if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio, in ath_select_ant_div_from_quick_scan()
363 antcomb->total_pkt_count)) in ath_select_ant_div_from_quick_scan()
364 antcomb->second_ratio = true; in ath_select_ant_div_from_quick_scan()
366 antcomb->second_ratio = false; in ath_select_ant_div_from_quick_scan()
369 ath_ant_set_alt_ratio(antcomb, div_ant_conf); in ath_select_ant_div_from_quick_scan()
378 struct ath_ant_comb *antcomb, in ath_ant_div_conf_fast_divbias() argument
441 if (!(antcomb->scan) && in ath_ant_div_conf_fast_divbias()
451 if (!(antcomb->scan) && in ath_ant_div_conf_fast_divbias()
458 if (!(antcomb->scan) && in ath_ant_div_conf_fast_divbias()
468 if (!(antcomb->scan) && in ath_ant_div_conf_fast_divbias()
500 if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio)) in ath_ant_div_conf_fast_divbias()
509 if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio)) in ath_ant_div_conf_fast_divbias()
515 if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio)) in ath_ant_div_conf_fast_divbias()
524 if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio)) in ath_ant_div_conf_fast_divbias()
542 if (antcomb->fast_div_bias) in ath_ant_div_conf_fast_divbias()
543 ant_conf->fast_div_bias = antcomb->fast_div_bias; in ath_ant_div_conf_fast_divbias()
589 static void ath_ant_try_scan(struct ath_ant_comb *antcomb, in ath_ant_try_scan() argument
596 antcomb->rssi_lna2 = alt_rssi_avg; in ath_ant_try_scan()
597 antcomb->rssi_lna1 = main_rssi_avg; in ath_ant_try_scan()
598 antcomb->scan = true; in ath_ant_try_scan()
604 antcomb->rssi_lna1 = alt_rssi_avg; in ath_ant_try_scan()
605 antcomb->rssi_lna2 = main_rssi_avg; in ath_ant_try_scan()
606 antcomb->scan = true; in ath_ant_try_scan()
612 antcomb->rssi_add = alt_rssi_avg; in ath_ant_try_scan()
613 antcomb->scan = true; in ath_ant_try_scan()
618 antcomb->rssi_sub = alt_rssi_avg; in ath_ant_try_scan()
619 antcomb->scan = false; in ath_ant_try_scan()
620 if (antcomb->rssi_lna2 > in ath_ant_try_scan()
621 (antcomb->rssi_lna1 + conf->lna1_lna2_switch_delta)) { in ath_ant_try_scan()
623 if ((antcomb->rssi_add > antcomb->rssi_lna1) && in ath_ant_try_scan()
624 (antcomb->rssi_add > antcomb->rssi_sub)) { in ath_ant_try_scan()
628 } else if (antcomb->rssi_sub > in ath_ant_try_scan()
629 antcomb->rssi_lna1) { in ath_ant_try_scan()
640 if ((antcomb->rssi_add > antcomb->rssi_lna2) && in ath_ant_try_scan()
641 (antcomb->rssi_add > antcomb->rssi_sub)) { in ath_ant_try_scan()
645 } else if (antcomb->rssi_sub > in ath_ant_try_scan()
646 antcomb->rssi_lna2) { in ath_ant_try_scan()
663 struct ath_ant_comb *antcomb, in ath_ant_try_switch() argument
670 if (ath_ant_div_comb_alt_check(div_ant_conf, antcomb, alt_ratio, in ath_ant_try_switch()
700 static bool ath_ant_short_scan_check(struct ath_ant_comb *antcomb) in ath_ant_short_scan_check() argument
704 if (!antcomb->scan || !antcomb->alt_good) in ath_ant_short_scan_check()
707 if (time_after(jiffies, antcomb->scan_start_time + in ath_ant_short_scan_check()
711 if (antcomb->total_pkt_count == ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT) { in ath_ant_short_scan_check()
712 alt_ratio = ((antcomb->alt_recv_cnt * 100) / in ath_ant_short_scan_check()
713 antcomb->total_pkt_count); in ath_ant_short_scan_check()
714 if (alt_ratio < antcomb->ant_ratio) in ath_ant_short_scan_check()
724 struct ath_ant_comb *antcomb = &sc->ant_comb; in ath_ant_comb_scan() local
737 if (alt_rssi >= antcomb->low_rssi_thresh) { in ath_ant_comb_scan()
738 antcomb->ant_ratio = ATH_ANT_DIV_COMB_ALT_ANT_RATIO; in ath_ant_comb_scan()
739 antcomb->ant_ratio2 = ATH_ANT_DIV_COMB_ALT_ANT_RATIO2; in ath_ant_comb_scan()
741 antcomb->ant_ratio = ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI; in ath_ant_comb_scan()
742 antcomb->ant_ratio2 = ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI; in ath_ant_comb_scan()
747 antcomb->total_pkt_count++; in ath_ant_comb_scan()
748 antcomb->main_total_rssi += main_rssi; in ath_ant_comb_scan()
749 antcomb->alt_total_rssi += alt_rssi; in ath_ant_comb_scan()
752 antcomb->main_recv_cnt++; in ath_ant_comb_scan()
754 antcomb->alt_recv_cnt++; in ath_ant_comb_scan()
766 short_scan = ath_ant_short_scan_check(antcomb); in ath_ant_comb_scan()
768 if (((antcomb->total_pkt_count < ATH_ANT_DIV_COMB_MAX_PKTCOUNT) || in ath_ant_comb_scan()
772 if (antcomb->total_pkt_count) { in ath_ant_comb_scan()
773 alt_ratio = ((antcomb->alt_recv_cnt * 100) / in ath_ant_comb_scan()
774 antcomb->total_pkt_count); in ath_ant_comb_scan()
775 main_rssi_avg = (antcomb->main_total_rssi / in ath_ant_comb_scan()
776 antcomb->total_pkt_count); in ath_ant_comb_scan()
777 alt_rssi_avg = (antcomb->alt_total_rssi / in ath_ant_comb_scan()
778 antcomb->total_pkt_count); in ath_ant_comb_scan()
784 antcomb->count++; in ath_ant_comb_scan()
786 if (antcomb->count == ATH_ANT_DIV_COMB_MAX_COUNT) { in ath_ant_comb_scan()
787 if (alt_ratio > antcomb->ant_ratio) { in ath_ant_comb_scan()
788 ath_lnaconf_alt_good_scan(antcomb, div_ant_conf, in ath_ant_comb_scan()
790 antcomb->alt_good = true; in ath_ant_comb_scan()
792 antcomb->alt_good = false; in ath_ant_comb_scan()
795 antcomb->count = 0; in ath_ant_comb_scan()
796 antcomb->scan = true; in ath_ant_comb_scan()
797 antcomb->scan_not_start = true; in ath_ant_comb_scan()
800 if (!antcomb->scan) { in ath_ant_comb_scan()
801 ret = ath_ant_try_switch(&div_ant_conf, antcomb, alt_ratio, in ath_ant_comb_scan()
808 if (!antcomb->scan && in ath_ant_comb_scan()
812 if (!antcomb->scan_not_start) { in ath_ant_comb_scan()
813 ath_ant_try_scan(antcomb, &div_ant_conf, curr_alt_set, in ath_ant_comb_scan()
816 if (!antcomb->alt_good) { in ath_ant_comb_scan()
817 antcomb->scan_not_start = false; in ath_ant_comb_scan()
832 ath_select_ant_div_from_quick_scan(antcomb, &div_ant_conf, in ath_ant_comb_scan()
835 antcomb->quick_scan_cnt++; in ath_ant_comb_scan()
839 ath_ant_div_conf_fast_divbias(&div_ant_conf, antcomb, alt_ratio); in ath_ant_comb_scan()
843 antcomb->scan_start_time = jiffies; in ath_ant_comb_scan()
844 antcomb->total_pkt_count = 0; in ath_ant_comb_scan()
845 antcomb->main_total_rssi = 0; in ath_ant_comb_scan()
846 antcomb->alt_total_rssi = 0; in ath_ant_comb_scan()
847 antcomb->main_recv_cnt = 0; in ath_ant_comb_scan()
848 antcomb->alt_recv_cnt = 0; in ath_ant_comb_scan()