aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHelmut Schaa <helmut.schaa@googlemail.com>2011-03-28 07:32:01 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-04-04 16:20:02 -0400
commit2af242e19f06cfaade7ac8608c9df8af1e0fbb34 (patch)
treea7492fb3651ad39cc053e64f0af19469f1958f2d /drivers
parent75faae8b80171b447bfc4bac448308676fb8a663 (diff)
rt2x00: Don't recalculate HT40 compensation for each rate
Previously the HT40 tx power compensation value was calculated for each rate. However, the calculation is independent of the tx rate and as such can be precalculated and just passed in for each rate. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 2f8af7a806ec..26ac8927a7c5 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -1861,7 +1861,8 @@ static u8 rt2800_compesate_txpower(struct rt2x00_dev *rt2x00dev,
1861 int is_rate_b, 1861 int is_rate_b,
1862 enum ieee80211_band band, 1862 enum ieee80211_band band,
1863 int power_level, 1863 int power_level,
1864 u8 txpower) 1864 u8 txpower,
1865 int delta)
1865{ 1866{
1866 u32 reg; 1867 u32 reg;
1867 u16 eeprom; 1868 u16 eeprom;
@@ -1869,13 +1870,10 @@ static u8 rt2800_compesate_txpower(struct rt2x00_dev *rt2x00dev,
1869 u8 eirp_txpower; 1870 u8 eirp_txpower;
1870 u8 eirp_txpower_criterion; 1871 u8 eirp_txpower_criterion;
1871 u8 reg_limit; 1872 u8 reg_limit;
1872 int bw_comp;
1873 1873
1874 if (!((band == IEEE80211_BAND_5GHZ) && is_rate_b)) 1874 if (!((band == IEEE80211_BAND_5GHZ) && is_rate_b))
1875 return txpower; 1875 return txpower;
1876 1876
1877 bw_comp = rt2800_get_txpower_bw_comp(rt2x00dev, band);
1878
1879 if (test_bit(CONFIG_SUPPORT_POWER_LIMIT, &rt2x00dev->flags)) { 1877 if (test_bit(CONFIG_SUPPORT_POWER_LIMIT, &rt2x00dev->flags)) {
1880 /* 1878 /*
1881 * Check if eirp txpower exceed txpower_limit. 1879 * Check if eirp txpower exceed txpower_limit.
@@ -1898,14 +1896,14 @@ static u8 rt2800_compesate_txpower(struct rt2x00_dev *rt2x00dev,
1898 EEPROM_EIRP_MAX_TX_POWER_5GHZ); 1896 EEPROM_EIRP_MAX_TX_POWER_5GHZ);
1899 1897
1900 eirp_txpower = eirp_txpower_criterion + (txpower - criterion) + 1898 eirp_txpower = eirp_txpower_criterion + (txpower - criterion) +
1901 (is_rate_b ? 4 : 0) + bw_comp; 1899 (is_rate_b ? 4 : 0) + delta;
1902 1900
1903 reg_limit = (eirp_txpower > power_level) ? 1901 reg_limit = (eirp_txpower > power_level) ?
1904 (eirp_txpower - power_level) : 0; 1902 (eirp_txpower - power_level) : 0;
1905 } else 1903 } else
1906 reg_limit = 0; 1904 reg_limit = 0;
1907 1905
1908 return txpower + bw_comp - reg_limit; 1906 return txpower + delta - reg_limit;
1909} 1907}
1910 1908
1911static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev, 1909static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
@@ -1919,6 +1917,12 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
1919 u32 offset; 1917 u32 offset;
1920 enum ieee80211_band band = conf->channel->band; 1918 enum ieee80211_band band = conf->channel->band;
1921 int power_level = conf->power_level; 1919 int power_level = conf->power_level;
1920 int delta;
1921
1922 /*
1923 * Calculate HT40 compensation delta
1924 */
1925 delta = rt2800_get_txpower_bw_comp(rt2x00dev, band);
1922 1926
1923 /* 1927 /*
1924 * set to normal bbp tx power control mode: +/- 0dBm 1928 * set to normal bbp tx power control mode: +/- 0dBm
@@ -1948,7 +1952,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
1948 txpower = rt2x00_get_field16(eeprom, 1952 txpower = rt2x00_get_field16(eeprom,
1949 EEPROM_TXPOWER_BYRATE_RATE0); 1953 EEPROM_TXPOWER_BYRATE_RATE0);
1950 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band, 1954 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band,
1951 power_level, txpower); 1955 power_level, txpower, delta);
1952 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE0, txpower); 1956 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE0, txpower);
1953 1957
1954 /* 1958 /*
@@ -1959,7 +1963,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
1959 txpower = rt2x00_get_field16(eeprom, 1963 txpower = rt2x00_get_field16(eeprom,
1960 EEPROM_TXPOWER_BYRATE_RATE1); 1964 EEPROM_TXPOWER_BYRATE_RATE1);
1961 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band, 1965 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band,
1962 power_level, txpower); 1966 power_level, txpower, delta);
1963 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE1, txpower); 1967 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE1, txpower);
1964 1968
1965 /* 1969 /*
@@ -1970,7 +1974,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
1970 txpower = rt2x00_get_field16(eeprom, 1974 txpower = rt2x00_get_field16(eeprom,
1971 EEPROM_TXPOWER_BYRATE_RATE2); 1975 EEPROM_TXPOWER_BYRATE_RATE2);
1972 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band, 1976 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band,
1973 power_level, txpower); 1977 power_level, txpower, delta);
1974 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE2, txpower); 1978 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE2, txpower);
1975 1979
1976 /* 1980 /*
@@ -1981,7 +1985,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
1981 txpower = rt2x00_get_field16(eeprom, 1985 txpower = rt2x00_get_field16(eeprom,
1982 EEPROM_TXPOWER_BYRATE_RATE3); 1986 EEPROM_TXPOWER_BYRATE_RATE3);
1983 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band, 1987 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band,
1984 power_level, txpower); 1988 power_level, txpower, delta);
1985 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE3, txpower); 1989 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE3, txpower);
1986 1990
1987 /* read the next four txpower values */ 1991 /* read the next four txpower values */
@@ -1997,7 +2001,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
1997 txpower = rt2x00_get_field16(eeprom, 2001 txpower = rt2x00_get_field16(eeprom,
1998 EEPROM_TXPOWER_BYRATE_RATE0); 2002 EEPROM_TXPOWER_BYRATE_RATE0);
1999 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band, 2003 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band,
2000 power_level, txpower); 2004 power_level, txpower, delta);
2001 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE4, txpower); 2005 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE4, txpower);
2002 2006
2003 /* 2007 /*
@@ -2008,7 +2012,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
2008 txpower = rt2x00_get_field16(eeprom, 2012 txpower = rt2x00_get_field16(eeprom,
2009 EEPROM_TXPOWER_BYRATE_RATE1); 2013 EEPROM_TXPOWER_BYRATE_RATE1);
2010 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band, 2014 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band,
2011 power_level, txpower); 2015 power_level, txpower, delta);
2012 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE5, txpower); 2016 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE5, txpower);
2013 2017
2014 /* 2018 /*
@@ -2019,7 +2023,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
2019 txpower = rt2x00_get_field16(eeprom, 2023 txpower = rt2x00_get_field16(eeprom,
2020 EEPROM_TXPOWER_BYRATE_RATE2); 2024 EEPROM_TXPOWER_BYRATE_RATE2);
2021 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band, 2025 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band,
2022 power_level, txpower); 2026 power_level, txpower, delta);
2023 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE6, txpower); 2027 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE6, txpower);
2024 2028
2025 /* 2029 /*
@@ -2030,7 +2034,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
2030 txpower = rt2x00_get_field16(eeprom, 2034 txpower = rt2x00_get_field16(eeprom,
2031 EEPROM_TXPOWER_BYRATE_RATE3); 2035 EEPROM_TXPOWER_BYRATE_RATE3);
2032 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band, 2036 txpower = rt2800_compesate_txpower(rt2x00dev, is_rate_b, band,
2033 power_level, txpower); 2037 power_level, txpower, delta);
2034 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE7, txpower); 2038 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE7, txpower);
2035 2039
2036 rt2800_register_write(rt2x00dev, offset, reg); 2040 rt2800_register_write(rt2x00dev, offset, reg);