diff options
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 7110e1f1e49a..3e059b6c484d 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -2520,6 +2520,27 @@ static int rt2800_get_txpower_bw_comp(struct rt2x00_dev *rt2x00dev, | |||
2520 | return comp_value; | 2520 | return comp_value; |
2521 | } | 2521 | } |
2522 | 2522 | ||
2523 | static int rt2800_get_txpower_reg_delta(struct rt2x00_dev *rt2x00dev, | ||
2524 | int power_level, int max_power) | ||
2525 | { | ||
2526 | int delta; | ||
2527 | |||
2528 | if (test_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags)) | ||
2529 | return 0; | ||
2530 | |||
2531 | /* | ||
2532 | * XXX: We don't know the maximum transmit power of our hardware since | ||
2533 | * the EEPROM doesn't expose it. We only know that we are calibrated | ||
2534 | * to 100% tx power. | ||
2535 | * | ||
2536 | * Hence, we assume the regulatory limit that cfg80211 calulated for | ||
2537 | * the current channel is our maximum and if we are requested to lower | ||
2538 | * the value we just reduce our tx power accordingly. | ||
2539 | */ | ||
2540 | delta = power_level - max_power; | ||
2541 | return min(delta, 0); | ||
2542 | } | ||
2543 | |||
2523 | static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b, | 2544 | static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b, |
2524 | enum ieee80211_band band, int power_level, | 2545 | enum ieee80211_band band, int power_level, |
2525 | u8 txpower, int delta) | 2546 | u8 txpower, int delta) |
@@ -2586,6 +2607,12 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev, | |||
2586 | delta += rt2800_get_gain_calibration_delta(rt2x00dev); | 2607 | delta += rt2800_get_gain_calibration_delta(rt2x00dev); |
2587 | 2608 | ||
2588 | /* | 2609 | /* |
2610 | * Apply regulatory delta. | ||
2611 | */ | ||
2612 | delta += rt2800_get_txpower_reg_delta(rt2x00dev, power_level, | ||
2613 | chan->max_power); | ||
2614 | |||
2615 | /* | ||
2589 | * BBP_R1 controls TX power for all rates, it allow to set the following | 2616 | * BBP_R1 controls TX power for all rates, it allow to set the following |
2590 | * gains -12, -6, 0, +6 dBm by setting values 2, 1, 0, 3 respectively. | 2617 | * gains -12, -6, 0, +6 dBm by setting values 2, 1, 0, 3 respectively. |
2591 | * | 2618 | * |