diff options
author | Felix Fietkau <nbd@openwrt.org> | 2010-10-19 20:09:46 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-11-15 13:23:15 -0500 |
commit | babcbc295fee766ca710235e431686fef744d9a6 (patch) | |
tree | 3ac71fc21561e3dd97a9d370dc8504faa767f01d | |
parent | de40f316c01b1ba9535e6dc99f6a67e7655b07da (diff) |
ath9k: initialize per-channel tx power limits instead of hardcoding them
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/ath/ath9k/common.c | 15 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/common.h | 5 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/htc_drv_main.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/init.c | 33 |
4 files changed, 45 insertions, 12 deletions
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c index f43a2d98421c..48b07c319a7f 100644 --- a/drivers/net/wireless/ath/ath9k/common.c +++ b/drivers/net/wireless/ath/ath9k/common.c | |||
@@ -107,12 +107,10 @@ static u32 ath9k_get_extchanmode(struct ieee80211_channel *chan, | |||
107 | /* | 107 | /* |
108 | * Update internal channel flags. | 108 | * Update internal channel flags. |
109 | */ | 109 | */ |
110 | void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw, | 110 | void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, |
111 | struct ath9k_channel *ichan) | 111 | struct ieee80211_channel *chan, |
112 | enum nl80211_channel_type channel_type) | ||
112 | { | 113 | { |
113 | struct ieee80211_channel *chan = hw->conf.channel; | ||
114 | struct ieee80211_conf *conf = &hw->conf; | ||
115 | |||
116 | ichan->channel = chan->center_freq; | 114 | ichan->channel = chan->center_freq; |
117 | ichan->chan = chan; | 115 | ichan->chan = chan; |
118 | 116 | ||
@@ -124,9 +122,8 @@ void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw, | |||
124 | ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM; | 122 | ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM; |
125 | } | 123 | } |
126 | 124 | ||
127 | if (conf_is_ht(conf)) | 125 | if (channel_type != NL80211_CHAN_NO_HT) |
128 | ichan->chanmode = ath9k_get_extchanmode(chan, | 126 | ichan->chanmode = ath9k_get_extchanmode(chan, channel_type); |
129 | conf->channel_type); | ||
130 | } | 127 | } |
131 | EXPORT_SYMBOL(ath9k_cmn_update_ichannel); | 128 | EXPORT_SYMBOL(ath9k_cmn_update_ichannel); |
132 | 129 | ||
@@ -142,7 +139,7 @@ struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, | |||
142 | 139 | ||
143 | chan_idx = curchan->hw_value; | 140 | chan_idx = curchan->hw_value; |
144 | channel = &ah->channels[chan_idx]; | 141 | channel = &ah->channels[chan_idx]; |
145 | ath9k_cmn_update_ichannel(hw, channel); | 142 | ath9k_cmn_update_ichannel(channel, curchan, hw->conf.channel_type); |
146 | 143 | ||
147 | return channel; | 144 | return channel; |
148 | } | 145 | } |
diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h index fea3b3315391..c76c75a77c62 100644 --- a/drivers/net/wireless/ath/ath9k/common.h +++ b/drivers/net/wireless/ath/ath9k/common.h | |||
@@ -62,8 +62,9 @@ enum ath_stomp_type { | |||
62 | 62 | ||
63 | int ath9k_cmn_padpos(__le16 frame_control); | 63 | int ath9k_cmn_padpos(__le16 frame_control); |
64 | int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb); | 64 | int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb); |
65 | void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw, | 65 | void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, |
66 | struct ath9k_channel *ichan); | 66 | struct ieee80211_channel *chan, |
67 | enum nl80211_channel_type channel_type); | ||
67 | struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, | 68 | struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, |
68 | struct ath_hw *ah); | 69 | struct ath_hw *ah); |
69 | int ath9k_cmn_count_streams(unsigned int chainmask, int max); | 70 | int ath9k_cmn_count_streams(unsigned int chainmask, int max); |
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c index 26b9a16ce33f..8266ce1f02e3 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c | |||
@@ -1400,7 +1400,9 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed) | |||
1400 | ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n", | 1400 | ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n", |
1401 | curchan->center_freq); | 1401 | curchan->center_freq); |
1402 | 1402 | ||
1403 | ath9k_cmn_update_ichannel(hw, &priv->ah->channels[pos]); | 1403 | ath9k_cmn_update_ichannel(&priv->ah->channels[pos], |
1404 | hw->conf.channel, | ||
1405 | hw->conf.channel_type); | ||
1404 | 1406 | ||
1405 | if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) { | 1407 | if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) { |
1406 | ath_print(common, ATH_DBG_FATAL, | 1408 | ath_print(common, ATH_DBG_FATAL, |
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 12f4fd79c907..1b72720b36e2 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c | |||
@@ -642,6 +642,37 @@ err_hw: | |||
642 | return ret; | 642 | return ret; |
643 | } | 643 | } |
644 | 644 | ||
645 | static void ath9k_init_band_txpower(struct ath_softc *sc, int band) | ||
646 | { | ||
647 | struct ieee80211_supported_band *sband; | ||
648 | struct ieee80211_channel *chan; | ||
649 | struct ath_hw *ah = sc->sc_ah; | ||
650 | struct ath_regulatory *reg = ath9k_hw_regulatory(ah); | ||
651 | int i; | ||
652 | |||
653 | sband = &sc->sbands[band]; | ||
654 | for (i = 0; i < sband->n_channels; i++) { | ||
655 | chan = &sband->channels[i]; | ||
656 | ah->curchan = &ah->channels[chan->hw_value]; | ||
657 | ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20); | ||
658 | ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true); | ||
659 | chan->max_power = reg->max_power_level / 2; | ||
660 | } | ||
661 | } | ||
662 | |||
663 | static void ath9k_init_txpower_limits(struct ath_softc *sc) | ||
664 | { | ||
665 | struct ath_hw *ah = sc->sc_ah; | ||
666 | struct ath9k_channel *curchan = ah->curchan; | ||
667 | |||
668 | if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) | ||
669 | ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ); | ||
670 | if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) | ||
671 | ath9k_init_band_txpower(sc, IEEE80211_BAND_5GHZ); | ||
672 | |||
673 | ah->curchan = curchan; | ||
674 | } | ||
675 | |||
645 | void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | 676 | void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) |
646 | { | 677 | { |
647 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 678 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
@@ -736,6 +767,8 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc, u16 subsysid, | |||
736 | if (error != 0) | 767 | if (error != 0) |
737 | goto error_rx; | 768 | goto error_rx; |
738 | 769 | ||
770 | ath9k_init_txpower_limits(sc); | ||
771 | |||
739 | /* Register with mac80211 */ | 772 | /* Register with mac80211 */ |
740 | error = ieee80211_register_hw(hw); | 773 | error = ieee80211_register_hw(hw); |
741 | if (error) | 774 | if (error) |