Skip to content

Commit

Permalink
mt76x2: add tx power adjustment for auto response frames
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Aug 25, 2016
1 parent aa77ead commit 2637e6b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions mt76x2.h
Expand Up @@ -213,5 +213,6 @@ void mt76x2_update_channel(struct mt76_dev *dev);
s8 mt76x3_tx_get_max_txpwr_adj(struct mt76x2_dev *dev,
const struct ieee80211_tx_rate *rate);
s8 mt76x2_tx_get_txpwr_adj(struct mt76x2_dev *dev, s8 txpwr, s8 max_txpwr_adj);
void mt76x2_tx_set_txpwr_auto(struct mt76x2_dev *dev, s8 txpwr);

#endif
4 changes: 3 additions & 1 deletion mt76x2_main.c
Expand Up @@ -150,8 +150,10 @@ mt76x2_config(struct ieee80211_hw *hw, u32 changed)
if (changed & IEEE80211_CONF_CHANGE_POWER) {
dev->txpower_conf = hw->conf.power_level * 2;

if (test_bit(MT76_STATE_RUNNING, &dev->mt76.state))
if (test_bit(MT76_STATE_RUNNING, &dev->mt76.state)) {
mt76x2_phy_set_txpower(dev);
mt76x2_tx_set_txpwr_auto(dev, dev->txpower_conf);
}
}

if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
Expand Down
2 changes: 2 additions & 0 deletions mt76x2_regs.h
Expand Up @@ -441,6 +441,8 @@
#define MT_TXOP_HLDR_ET 0x1608

#define MT_PROT_AUTO_TX_CFG 0x1648
#define MT_PROT_AUTO_TX_CFG_PROT_PADJ GENMASK(11, 8)
#define MT_PROT_AUTO_TX_CFG_AUTO_PADJ GENMASK(27, 24)

#define MT_TX_STAT_FIFO 0x1718
#define MT_TX_STAT_FIFO_VALID BIT(0)
Expand Down
12 changes: 12 additions & 0 deletions mt76x2_tx.c
Expand Up @@ -110,6 +110,18 @@ s8 mt76x2_tx_get_txpwr_adj(struct mt76x2_dev *dev, s8 txpwr, s8 max_txpwr_adj)
return (txpwr < -16) ? 8 : (txpwr + 32) / 2;
}

void mt76x2_tx_set_txpwr_auto(struct mt76x2_dev *dev, s8 txpwr)
{
s8 txpwr_adj;

txpwr_adj = mt76x2_tx_get_txpwr_adj(dev, txpwr,
dev->rate_power.ofdm[4]);
mt76_rmw_field(dev, MT_PROT_AUTO_TX_CFG,
MT_PROT_AUTO_TX_CFG_PROT_PADJ, txpwr_adj);
mt76_rmw_field(dev, MT_PROT_AUTO_TX_CFG,
MT_PROT_AUTO_TX_CFG_AUTO_PADJ, txpwr_adj);
}

int mt76x2_tx_prepare_skb(struct mt76_dev *mdev, void *txwi,
struct sk_buff *skb, struct mt76_queue *q,
struct mt76_wcid *wcid, struct ieee80211_sta *sta,
Expand Down

0 comments on commit 2637e6b

Please sign in to comment.