aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/net/wireless/ath/ath9k/calib.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-07-28 14:08:56 +0200
committerJohn W. Linville <linville@tuxdriver.com>2011-08-08 16:04:19 -0400
commitf23fba49b31070dc180d0d41d0125ab80f71c09f (patch)
tree697c307d350409028f6ffd370f11d71579dfd462 /drivers/net/wireless/ath/ath9k/calib.c
parentmac80211/mesh: make the preq queue lock consistent (diff)
downloadwireguard-linux-f23fba49b31070dc180d0d41d0125ab80f71c09f.tar.xz
wireguard-linux-f23fba49b31070dc180d0d41d0125ab80f71c09f.zip
ath9k_hw: calculate a much better approximation of channel noise
Currently ath9k presents the internal calibrated noise floor as channel noise measurement, however this results in highly chip specific values that are only useful as relative measurements but do not resemble any real channel noise values. In order to give a much better approximation of the real channel noise, add the difference between the measured noise floor and the nominal chip specific noise floor to the default minimum channel noise value, which is currently used to calculate the signal strength from the RSSI value. This may not be 100% accurate, but it's much better than what's there before. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/calib.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index a1250c586e40..ac2da3cce788 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -63,6 +63,19 @@ static s16 ath9k_hw_get_default_nf(struct ath_hw *ah,
return ath9k_hw_get_nf_limits(ah, chan)->nominal;
}
+s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan)
+{
+ s8 noise = ATH_DEFAULT_NOISE_FLOOR;
+
+ if (chan && chan->noisefloor) {
+ s8 delta = chan->noisefloor -
+ ath9k_hw_get_default_nf(ah, chan);
+ if (delta > 0)
+ noise += delta;
+ }
+ return noise;
+}
+EXPORT_SYMBOL(ath9k_hw_getchan_noise);
static void ath9k_hw_update_nfcal_hist_buffer(struct ath_hw *ah,
struct ath9k_hw_cal_data *cal,
@@ -378,6 +391,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan)
if (!caldata) {
chan->noisefloor = nf;
+ ah->noise = ath9k_hw_getchan_noise(ah, chan);
return false;
}
@@ -385,6 +399,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan)
caldata->nfcal_pending = false;
ath9k_hw_update_nfcal_hist_buffer(ah, caldata, nfarray);
chan->noisefloor = h[0].privNF;
+ ah->noise = ath9k_hw_getchan_noise(ah, chan);
return true;
}