From: Thomas Huehn <thomas@net.t-labs.tu-berlin.de>
To: linville@tuxdriver.com
Cc: jirislaby@gmail.com, mickflemm@gmail.com,
mcgrof@qca.qualcomm.com, ath5k-devel@lists.ath5k.org,
linux-wireless@vger.kernel.org, johannes.berg@intel.com,
thomas@net.t-labs.tu-berlin.de, nbd@nbd.name
Subject: [PATCH 2/2] ath5k: fix phy_init() to respect user txpower changes
Date: Mon, 23 Jul 2012 18:01:15 +0200 [thread overview]
Message-ID: <1343059275-49590-3-git-send-email-thomas@net.t-labs.tu-berlin.de> (raw)
In-Reply-To: <1343059275-49590-1-git-send-email-thomas@net.t-labs.tu-berlin.de>
In such cases where phy_init() function got called, tx_power is always
set to ah->ah_txpower.txp_cur_pwr which is never updated with txpower
specified by the user instead it equale max chan power and got
potentially incremented by ah_txpower.txp_offset.
In any case the card was switching to a txpower level higher that
someone specified to use. This patch fix this by introducing
ah_txpower.txp_user_pwr which holds the tx_power specified at userland.
Function ath5k_hw_txpower is restructured and uses the value at
ah_txpower.txp_user_pwr directly.
Signed-off-by: Thomas Huehn <thomas@net.t-labs.tu-berlin.de>
---
restructure of ath5k_hw_txpower as suggested by Felix Fietkau.
---
drivers/net/wireless/ath/ath5k/ath5k.h | 1 +
drivers/net/wireless/ath/ath5k/base.c | 3 +++
drivers/net/wireless/ath/ath5k/phy.c | 27 ++++++++++++++-------------
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index 64a453a..89d9ac54 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -1418,6 +1418,7 @@ struct ath5k_hw {
s16 txp_min_pwr;
s16 txp_max_pwr;
s16 txp_cur_pwr;
+ s16 txp_user_pwr;
/* Values in 0.5dB units */
s16 txp_offset;
s16 txp_ofdm;
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 8c4c040..e831f69 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -2951,6 +2951,9 @@ ath5k_init(struct ieee80211_hw *hw)
hw->queues = 1;
}
+ /* init tx_power setting to maximum */
+ ah->ah_txpower.txp_user_pwr = AR5K_TUNE_MAX_TXPOWER;
+
tasklet_init(&ah->rxtq, ath5k_tasklet_rx, (unsigned long)ah);
tasklet_init(&ah->txtq, ath5k_tasklet_tx, (unsigned long)ah);
tasklet_init(&ah->beacontq, ath5k_tasklet_beacon, (unsigned long)ah);
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 8b71a2d..728ff07 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -3583,14 +3583,12 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr,
* ath5k_hw_txpower() - Set transmission power limit for a given channel
* @ah: The &struct ath5k_hw
* @channel: The &struct ieee80211_channel
- * @txpower: Requested tx power in 0.5dB steps
*
* Combines all of the above to set the requested tx power limit
- * on hw.
+ * on hw to ah->ah_txpower.txp_user_pwr.
*/
static int
-ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
- u8 txpower)
+ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel)
{
struct ath5k_rate_pcal_info rate_info;
struct ieee80211_channel *curr_channel = ah->ah_current_channel;
@@ -3598,11 +3596,6 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
u8 type;
int ret;
- if (txpower > AR5K_TUNE_MAX_TXPOWER) {
- ATH5K_ERR(ah, "invalid tx power: %u\n", txpower);
- return -EINVAL;
- }
-
ee_mode = ath5k_eeprom_mode_from_channel(channel);
if (ee_mode < 0) {
ATH5K_ERR(ah,
@@ -3667,7 +3660,7 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
ath5k_get_rate_pcal_data(ah, channel, &rate_info);
/* Setup rate power table */
- ath5k_setup_rate_powertable(ah, txpower, &rate_info, ee_mode);
+ ath5k_setup_rate_powertable(ah, ah->ah_txpower.txp_user_pwr, &rate_info, ee_mode);
/* Write rate power table on hw */
ath5k_hw_reg_write(ah, AR5K_TXPOWER_OFDM(3, 24) |
@@ -3717,8 +3710,16 @@ ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
{
ATH5K_DBG(ah, ATH5K_DEBUG_TXPOWER,
"changing txpower to %d\n", txpower);
+ if (txpower) {
+ ah->ah_txpower.txp_user_pwr = txpower;
+
+ if (ah->ah_txpower.txp_user_pwr > AR5K_TUNE_MAX_TXPOWER) {
+ ATH5K_ERR(ah, "invalid tx power: %u\n", ah->ah_txpower.txp_user_pwr);
+ return -EINVAL;
+ }
+ }
- return ath5k_hw_txpower(ah, ah->ah_current_channel, txpower);
+ return ath5k_hw_txpower(ah, ah->ah_current_channel);
}
@@ -3789,8 +3790,8 @@ ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
* RF buffer settings on 5211/5212+ so that we
* properly set curve indices.
*/
- ret = ath5k_hw_txpower(ah, channel, ah->ah_txpower.txp_cur_pwr ?
- ah->ah_txpower.txp_cur_pwr / 2 : AR5K_TUNE_MAX_TXPOWER);
+ ret = ath5k_hw_txpower(ah, channel);
+
if (ret)
return ret;
--
1.7.11.1
next prev parent reply other threads:[~2012-07-23 16:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-23 16:01 [PATCH 0/2] ath5k: fixing broken power gain calibration at 5GHz and txpower handling Thomas Huehn
2012-07-23 16:01 ` [PATCH 1/2] ath5k: fix wrong per rate target power eeprom reads for AR5K_EEPROM_MODE_11A Thomas Huehn
2012-07-25 18:42 ` Nick Kossifidis
2012-07-25 18:55 ` Felix Fietkau
2012-07-25 22:22 ` Nick Kossifidis
2012-07-25 22:01 ` [ath5k-devel] " Thomas Huehn
2012-07-25 22:31 ` Nick Kossifidis
2012-08-04 8:14 ` Thomas Huehn
2012-08-04 15:28 ` Nick Kossifidis
2012-08-05 11:06 ` Thomas Huehn
2012-08-05 11:56 ` Nick Kossifidis
2012-08-05 12:37 ` Thomas Huehn
2012-08-05 12:59 ` Nick Kossifidis
2012-08-05 18:26 ` Nick Kossifidis
2012-07-23 16:01 ` Thomas Huehn [this message]
2012-07-23 16:42 ` [ath5k-devel] [PATCH 2/2] ath5k: fix phy_init() to respect user txpower changes Bob Copeland
2012-07-23 18:25 ` Thomas Huehn
2012-07-23 18:29 ` Thomas Huehn
2012-07-23 19:20 ` Bob Copeland
2012-07-25 19:22 ` Nick Kossifidis
2012-07-25 23:07 ` Thomas Huehn
2012-07-25 23:23 ` Nick Kossifidis
2012-07-25 23:40 ` [ath5k-devel] " Thomas Huehn
2012-07-26 10:20 ` Nick Kossifidis
2012-07-26 10:28 ` Felix Fietkau
2012-07-26 10:31 ` Nick Kossifidis
2012-07-26 10:41 ` Felix Fietkau
2012-07-26 17:48 ` Nick Kossifidis
2012-07-26 20:56 ` Thomas Huehn
2012-07-28 11:45 ` Nick Kossifidis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1343059275-49590-3-git-send-email-thomas@net.t-labs.tu-berlin.de \
--to=thomas@net.t-labs.tu-berlin.de \
--cc=ath5k-devel@lists.ath5k.org \
--cc=jirislaby@gmail.com \
--cc=johannes.berg@intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mcgrof@qca.qualcomm.com \
--cc=mickflemm@gmail.com \
--cc=nbd@nbd.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).