linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sujith Manoharan <sujith@msujith.org>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 3/8] ath9k: Add ALT check for cards with GROUP-3 config
Date: Thu,  1 Aug 2013 11:53:19 +0530	[thread overview]
Message-ID: <1375338204-2021-3-git-send-email-sujith@msujith.org> (raw)
In-Reply-To: <1375338204-2021-1-git-send-email-sujith@msujith.org>

From: Sujith Manoharan <c_manoha@qca.qualcomm.com>

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath9k/antenna.c | 50 +++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/antenna.c b/drivers/net/wireless/ath/ath9k/antenna.c
index 130e983..ee25165 100644
--- a/drivers/net/wireless/ath/ath9k/antenna.c
+++ b/drivers/net/wireless/ath/ath9k/antenna.c
@@ -64,28 +64,45 @@ static inline bool ath_is_alt_ant_ratio_better(int alt_ratio, int maxdelta,
 		(alt_rssi_avg > main_rssi_avg + mindelta)) && (pkt_count > 50);
 }
 
-static inline bool ath_ant_div_comb_alt_check(u8 div_group, int alt_ratio,
-					      int curr_main_set, int curr_alt_set,
-					      int alt_rssi_avg, int main_rssi_avg)
+static inline bool ath_ant_div_comb_alt_check(struct ath_hw_antcomb_conf conf,
+					      int alt_ratio, int alt_rssi_avg,
+					      int main_rssi_avg)
 {
-	bool result = false;
-	switch (div_group) {
+	bool result, set1, set2;
+
+	result = set1 = set2 = false;
+
+	if (conf.main_lna_conf == ATH_ANT_DIV_COMB_LNA2 &&
+	    conf.alt_lna_conf == ATH_ANT_DIV_COMB_LNA1)
+		set1 = true;
+
+	if (conf.main_lna_conf == ATH_ANT_DIV_COMB_LNA1 &&
+	    conf.alt_lna_conf == ATH_ANT_DIV_COMB_LNA2)
+		set2 = true;
+
+	switch (conf.div_group) {
 	case 0:
 		if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)
 			result = true;
 		break;
 	case 1:
 	case 2:
-		if ((((curr_main_set == ATH_ANT_DIV_COMB_LNA2) &&
-		      (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) &&
-		      (alt_rssi_avg >= (main_rssi_avg - 5))) ||
-		     ((curr_main_set == ATH_ANT_DIV_COMB_LNA1) &&
-		      (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) &&
-		      (alt_rssi_avg >= (main_rssi_avg - 2)))) &&
-		    (alt_rssi_avg >= 4))
+		if (alt_rssi_avg < 4)
+			break;
+
+		if ((set1 && (alt_rssi_avg >= (main_rssi_avg - 5))) ||
+		    (set2 && (alt_rssi_avg >= (main_rssi_avg - 2))))
 			result = true;
-		else
-			result = false;
+
+		break;
+	case 3:
+		if (alt_rssi_avg < 4)
+			break;
+
+		if ((set1 && (alt_rssi_avg >= (main_rssi_avg - 3))) ||
+		    (set2 && (alt_rssi_avg >= (main_rssi_avg + 3))))
+			result = true;
+
 		break;
 	}
 
@@ -671,9 +688,8 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs)
 	}
 
 	if (!antcomb->scan) {
-		if (ath_ant_div_comb_alt_check(div_ant_conf.div_group,
-					alt_ratio, curr_main_set, curr_alt_set,
-					alt_rssi_avg, main_rssi_avg)) {
+		if (ath_ant_div_comb_alt_check(div_ant_conf, alt_ratio,
+					       alt_rssi_avg, main_rssi_avg)) {
 			if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) {
 				/* Switch main and alt LNA */
 				div_ant_conf.main_lna_conf =
-- 
1.8.3.4


  parent reply	other threads:[~2013-08-01  6:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01  6:23 [PATCH 1/8] ath9k: Do a quick scan only when scan_not_start is true Sujith Manoharan
2013-08-01  6:23 ` [PATCH 2/8] ath9k: Use a subroutine to check for short scan Sujith Manoharan
2013-08-01  6:23 ` Sujith Manoharan [this message]
2013-08-01  6:23 ` [PATCH 4/8] ath9k: Use a subroutine to try LNA switch Sujith Manoharan
2013-08-01  6:23 ` [PATCH 5/8] ath9k: Use a helper function for checking LNA options Sujith Manoharan
2013-08-01  6:23 ` [PATCH 6/8] ath9k: Simplify checks in quick_scan Sujith Manoharan
2013-08-01  6:23 ` [PATCH 7/8] ath9k: Use a subroutine to calculate ALT ratio Sujith Manoharan
2013-08-01  6:23 ` [PATCH 8/8] ath9k: Add statistics for antenna diversity Sujith Manoharan
2013-08-01 15:27   ` [PATCH v2 " Sujith Manoharan
2013-08-01 16:37     ` cross compile backports? Jonathan Bagg
2013-08-01 17:47       ` Solomon Peachy
2013-08-01 19:03         ` Luis R. Rodriguez
2013-08-01 19:12         ` cross compile backports with LTIB Jonathan Bagg
2013-08-01 19:17           ` Jonathan Bagg
2013-08-01 19:44     ` [PATCH v2 8/8] ath9k: Add statistics for antenna diversity John W. Linville
2013-08-01 19:53       ` John W. Linville

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1375338204-2021-3-git-send-email-sujith@msujith.org \
    --to=sujith@msujith.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).