aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasanthakumar Thiagarajan <vasanth@atheros.com>2010-11-10 08:03:14 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-11-16 16:37:06 -0500
commitbc2068020bfa976efd425f3be590f58a012fd747 (patch)
tree83eafebd48788d4af4fe2b4a5e449d479e7be5aa
parent15cbbc44cc4abaaebc37caf0ec9410a3f83d1deb (diff)
ath9k_hw: Add helper function for interpolation
Also round off interpolated values this would improve power accuracy by 0.5dB in some cases. Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 5ffeda25bf14..1b4e99167b6c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -2982,6 +2982,16 @@ static int ath9k_hw_ar9300_check_eeprom(struct ath_hw *ah)
2982 return 0; 2982 return 0;
2983} 2983}
2984 2984
2985static int interpolate(int x, int xa, int xb, int ya, int yb)
2986{
2987 int bf, factor, plus;
2988
2989 bf = 2 * (yb - ya) * (x - xa) / (xb - xa);
2990 factor = bf / 2;
2991 plus = bf % 2;
2992 return ya + factor + plus;
2993}
2994
2985static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah, 2995static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
2986 enum eeprom_param param) 2996 enum eeprom_param param)
2987{ 2997{
@@ -3614,7 +3624,7 @@ static int ar9003_hw_power_interpolate(int32_t x,
3614 if (hx == lx) 3624 if (hx == lx)
3615 y = ly; 3625 y = ly;
3616 else /* interpolate */ 3626 else /* interpolate */
3617 y = ly + (((x - lx) * (hy - ly)) / (hx - lx)); 3627 y = interpolate(x, lx, hx, ly, hy);
3618 } else /* only low is good, use it */ 3628 } else /* only low is good, use it */
3619 y = ly; 3629 y = ly;
3620 } else if (hhave) /* only high is good, use it */ 3630 } else if (hhave) /* only high is good, use it */
@@ -4204,25 +4214,23 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
4204 /* so is the high frequency, interpolate */ 4214 /* so is the high frequency, interpolate */
4205 if (hfrequency[ichain] - frequency < 1000) { 4215 if (hfrequency[ichain] - frequency < 1000) {
4206 4216
4207 correction[ichain] = lcorrection[ichain] + 4217 correction[ichain] = interpolate(frequency,
4208 (((frequency - lfrequency[ichain]) * 4218 lfrequency[ichain],
4209 (hcorrection[ichain] - 4219 hfrequency[ichain],
4210 lcorrection[ichain])) / 4220 lcorrection[ichain],
4211 (hfrequency[ichain] - lfrequency[ichain])); 4221 hcorrection[ichain]);
4212 4222
4213 temperature[ichain] = ltemperature[ichain] + 4223 temperature[ichain] = interpolate(frequency,
4214 (((frequency - lfrequency[ichain]) * 4224 lfrequency[ichain],
4215 (htemperature[ichain] - 4225 hfrequency[ichain],
4216 ltemperature[ichain])) / 4226 ltemperature[ichain],
4217 (hfrequency[ichain] - lfrequency[ichain])); 4227 htemperature[ichain]);
4218 4228
4219 voltage[ichain] = 4229 voltage[ichain] = interpolate(frequency,
4220 lvoltage[ichain] + 4230 lfrequency[ichain],
4221 (((frequency - 4231 hfrequency[ichain],
4222 lfrequency[ichain]) * (hvoltage[ichain] - 4232 lvoltage[ichain],
4223 lvoltage[ichain])) 4233 hvoltage[ichain]);
4224 / (hfrequency[ichain] -
4225 lfrequency[ichain]));
4226 } 4234 }
4227 /* only low is good, use it */ 4235 /* only low is good, use it */
4228 else { 4236 else {