diff options
author | Felix Fietkau <nbd@openwrt.org> | 2010-08-02 09:53:13 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-08-16 15:26:38 -0400 |
commit | 2292ca6d783d3c79b58591bb3ee795bf0144e5ff (patch) | |
tree | fff1c4e6f26d86e135ade5217589b4015d14c5d2 /drivers/net | |
parent | 6252fcb9f802a992c697edf105e30271a4ae3246 (diff) |
ath9k_hw: apply the noise floor validation to the median instead of single
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/calib.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c index 45208690c0ec..ccb1b2eae85e 100644 --- a/drivers/net/wireless/ath/ath9k/calib.c +++ b/drivers/net/wireless/ath/ath9k/calib.c | |||
@@ -19,8 +19,7 @@ | |||
19 | 19 | ||
20 | /* Common calibration code */ | 20 | /* Common calibration code */ |
21 | 21 | ||
22 | /* We can tune this as we go by monitoring really low values */ | 22 | #define ATH9K_NF_TOO_HIGH -60 |
23 | #define ATH9K_NF_TOO_LOW -60 | ||
24 | 23 | ||
25 | static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer) | 24 | static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer) |
26 | { | 25 | { |
@@ -45,11 +44,35 @@ static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer) | |||
45 | return nfval; | 44 | return nfval; |
46 | } | 45 | } |
47 | 46 | ||
48 | static void ath9k_hw_update_nfcal_hist_buffer(struct ath9k_nfcal_hist *h, | 47 | static struct ath_nf_limits *ath9k_hw_get_nf_limits(struct ath_hw *ah, |
48 | struct ath9k_channel *chan) | ||
49 | { | ||
50 | struct ath_nf_limits *limit; | ||
51 | |||
52 | if (!chan || IS_CHAN_2GHZ(chan)) | ||
53 | limit = &ah->nf_2g; | ||
54 | else | ||
55 | limit = &ah->nf_5g; | ||
56 | |||
57 | return limit; | ||
58 | } | ||
59 | |||
60 | static s16 ath9k_hw_get_default_nf(struct ath_hw *ah, | ||
61 | struct ath9k_channel *chan) | ||
62 | { | ||
63 | return ath9k_hw_get_nf_limits(ah, chan)->nominal; | ||
64 | } | ||
65 | |||
66 | |||
67 | static void ath9k_hw_update_nfcal_hist_buffer(struct ath_hw *ah, | ||
68 | struct ath9k_nfcal_hist *h, | ||
49 | int16_t *nfarray) | 69 | int16_t *nfarray) |
50 | { | 70 | { |
71 | struct ath_nf_limits *limit; | ||
51 | int i; | 72 | int i; |
52 | 73 | ||
74 | limit = ath9k_hw_get_nf_limits(ah, ah->curchan); | ||
75 | |||
53 | for (i = 0; i < NUM_NF_READINGS; i++) { | 76 | for (i = 0; i < NUM_NF_READINGS; i++) { |
54 | h[i].nfCalBuffer[h[i].currIndex] = nfarray[i]; | 77 | h[i].nfCalBuffer[h[i].currIndex] = nfarray[i]; |
55 | 78 | ||
@@ -63,6 +86,9 @@ static void ath9k_hw_update_nfcal_hist_buffer(struct ath9k_nfcal_hist *h, | |||
63 | h[i].privNF = | 86 | h[i].privNF = |
64 | ath9k_hw_get_nf_hist_mid(h[i].nfCalBuffer); | 87 | ath9k_hw_get_nf_hist_mid(h[i].nfCalBuffer); |
65 | } | 88 | } |
89 | |||
90 | if (h[i].privNF > limit->max) | ||
91 | h[i].privNF = limit->max; | ||
66 | } | 92 | } |
67 | } | 93 | } |
68 | 94 | ||
@@ -104,19 +130,6 @@ void ath9k_hw_reset_calibration(struct ath_hw *ah, | |||
104 | ah->cal_samples = 0; | 130 | ah->cal_samples = 0; |
105 | } | 131 | } |
106 | 132 | ||
107 | static s16 ath9k_hw_get_default_nf(struct ath_hw *ah, | ||
108 | struct ath9k_channel *chan) | ||
109 | { | ||
110 | struct ath_nf_limits *limit; | ||
111 | |||
112 | if (!chan || IS_CHAN_2GHZ(chan)) | ||
113 | limit = &ah->nf_2g; | ||
114 | else | ||
115 | limit = &ah->nf_5g; | ||
116 | |||
117 | return limit->nominal; | ||
118 | } | ||
119 | |||
120 | /* This is done for the currently configured channel */ | 133 | /* This is done for the currently configured channel */ |
121 | bool ath9k_hw_reset_calvalid(struct ath_hw *ah) | 134 | bool ath9k_hw_reset_calvalid(struct ath_hw *ah) |
122 | { | 135 | { |
@@ -277,10 +290,10 @@ static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf) | |||
277 | "NF calibrated [%s] [chain %d] is %d\n", | 290 | "NF calibrated [%s] [chain %d] is %d\n", |
278 | (i >= 3 ? "ext" : "ctl"), i % 3, nf[i]); | 291 | (i >= 3 ? "ext" : "ctl"), i % 3, nf[i]); |
279 | 292 | ||
280 | if (nf[i] > limit->max) { | 293 | if (nf[i] > ATH9K_NF_TOO_HIGH) { |
281 | ath_print(common, ATH_DBG_CALIBRATE, | 294 | ath_print(common, ATH_DBG_CALIBRATE, |
282 | "NF[%d] (%d) > MAX (%d), correcting to MAX", | 295 | "NF[%d] (%d) > MAX (%d), correcting to MAX", |
283 | i, nf[i], limit->max); | 296 | i, nf[i], ATH9K_NF_TOO_HIGH); |
284 | nf[i] = limit->max; | 297 | nf[i] = limit->max; |
285 | } else if (nf[i] < limit->min) { | 298 | } else if (nf[i] < limit->min) { |
286 | ath_print(common, ATH_DBG_CALIBRATE, | 299 | ath_print(common, ATH_DBG_CALIBRATE, |
@@ -326,7 +339,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan) | |||
326 | 339 | ||
327 | h = caldata->nfCalHist; | 340 | h = caldata->nfCalHist; |
328 | caldata->nfcal_pending = false; | 341 | caldata->nfcal_pending = false; |
329 | ath9k_hw_update_nfcal_hist_buffer(h, nfarray); | 342 | ath9k_hw_update_nfcal_hist_buffer(ah, h, nfarray); |
330 | caldata->rawNoiseFloor = h[0].privNF; | 343 | caldata->rawNoiseFloor = h[0].privNF; |
331 | return true; | 344 | return true; |
332 | } | 345 | } |