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