de25219f3cc24e7e687bc486a2715ebe54ab371d
[openwrt.git] / package / mac80211 / patches / 522-ath9k_tx_power_init.patch
1 --- a/drivers/net/wireless/ath/ath9k/init.c
2 +++ b/drivers/net/wireless/ath/ath9k/init.c
3 @@ -654,6 +654,37 @@ err_hw:
4 return ret;
5 }
6
7 +static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
8 +{
9 + struct ieee80211_supported_band *sband;
10 + struct ieee80211_channel *chan;
11 + struct ath_hw *ah = sc->sc_ah;
12 + struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
13 + int i;
14 +
15 + sband = &sc->sbands[band];
16 + for (i = 0; i < sband->n_channels; i++) {
17 + chan = &sband->channels[i];
18 + ah->curchan = &ah->channels[chan->hw_value];
19 + ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20);
20 + ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true);
21 + chan->max_power = reg->max_power_level / 2;
22 + }
23 +}
24 +
25 +static void ath9k_init_txpower_limits(struct ath_softc *sc)
26 +{
27 + struct ath_hw *ah = sc->sc_ah;
28 + struct ath9k_channel *curchan = ah->curchan;
29 +
30 + if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
31 + ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ);
32 + if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
33 + ath9k_init_band_txpower(sc, IEEE80211_BAND_5GHZ);
34 +
35 + ah->curchan = curchan;
36 +}
37 +
38 void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
39 {
40 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
41 @@ -748,6 +779,8 @@ int ath9k_init_device(u16 devid, struct
42 if (error != 0)
43 goto error_rx;
44
45 + ath9k_init_txpower_limits(sc);
46 +
47 /* Register with mac80211 */
48 error = ieee80211_register_hw(hw);
49 if (error)
50 --- a/drivers/net/wireless/ath/ath9k/common.c
51 +++ b/drivers/net/wireless/ath/ath9k/common.c
52 @@ -107,12 +107,10 @@ static u32 ath9k_get_extchanmode(struct
53 /*
54 * Update internal channel flags.
55 */
56 -void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
57 - struct ath9k_channel *ichan)
58 +void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
59 + struct ieee80211_channel *chan,
60 + enum nl80211_channel_type channel_type)
61 {
62 - struct ieee80211_channel *chan = hw->conf.channel;
63 - struct ieee80211_conf *conf = &hw->conf;
64 -
65 ichan->channel = chan->center_freq;
66 ichan->chan = chan;
67
68 @@ -124,9 +122,8 @@ void ath9k_cmn_update_ichannel(struct ie
69 ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
70 }
71
72 - if (conf_is_ht(conf))
73 - ichan->chanmode = ath9k_get_extchanmode(chan,
74 - conf->channel_type);
75 + if (channel_type != NL80211_CHAN_NO_HT)
76 + ichan->chanmode = ath9k_get_extchanmode(chan, channel_type);
77 }
78 EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
79
80 @@ -142,7 +139,7 @@ struct ath9k_channel *ath9k_cmn_get_curc
81
82 chan_idx = curchan->hw_value;
83 channel = &ah->channels[chan_idx];
84 - ath9k_cmn_update_ichannel(hw, channel);
85 + ath9k_cmn_update_ichannel(channel, curchan, hw->conf.channel_type);
86
87 return channel;
88 }
89 --- a/drivers/net/wireless/ath/ath9k/common.h
90 +++ b/drivers/net/wireless/ath/ath9k/common.h
91 @@ -62,8 +62,9 @@ enum ath_stomp_type {
92
93 int ath9k_cmn_padpos(__le16 frame_control);
94 int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
95 -void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
96 - struct ath9k_channel *ichan);
97 +void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
98 + struct ieee80211_channel *chan,
99 + enum nl80211_channel_type channel_type);
100 struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
101 struct ath_hw *ah);
102 int ath9k_cmn_count_streams(unsigned int chainmask, int max);
103 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
104 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
105 @@ -1405,7 +1405,9 @@ static int ath9k_htc_config(struct ieee8
106 ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
107 curchan->center_freq);
108
109 - ath9k_cmn_update_ichannel(hw, &priv->ah->channels[pos]);
110 + ath9k_cmn_update_ichannel(&priv->ah->channels[pos],
111 + hw->conf.channel,
112 + hw->conf.channel_type);
113
114 if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
115 ath_print(common, ATH_DBG_FATAL,
This page took 0.052806 seconds and 3 git commands to generate.