mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 15:29:16 +00:00
mt76: fix rounding issues on converting per-chain and combined txpower
Unify code converting between the different txpower values. Always add/remove the combined txpower delta before dividing half-dB values. Also fix the combined txpower delta values. The correct half-dB delta for 3 chains is 9, not 8. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
049019c2a0
commit
07cda40630
@ -1051,25 +1051,9 @@ int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||
{
|
||||
struct mt76_phy *phy = hw->priv;
|
||||
int n_chains = hweight8(phy->antenna_mask);
|
||||
int delta = mt76_tx_power_nss_delta(n_chains);
|
||||
|
||||
*dbm = DIV_ROUND_UP(phy->txpower_cur, 2);
|
||||
|
||||
/* convert from per-chain power to combined
|
||||
* output power
|
||||
*/
|
||||
switch (n_chains) {
|
||||
case 4:
|
||||
*dbm += 6;
|
||||
break;
|
||||
case 3:
|
||||
*dbm += 4;
|
||||
break;
|
||||
case 2:
|
||||
*dbm += 3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*dbm = DIV_ROUND_UP(phy->txpower_cur + delta, 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -755,6 +755,13 @@ static inline bool mt76_is_skb_pktid(u8 pktid)
|
||||
return pktid >= MT_PACKET_ID_FIRST;
|
||||
}
|
||||
|
||||
static inline u8 mt76_tx_power_nss_delta(u8 nss)
|
||||
{
|
||||
static const u8 nss_delta[4] = { 0, 6, 9, 12 };
|
||||
|
||||
return nss_delta[nss - 1];
|
||||
}
|
||||
|
||||
void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb);
|
||||
void mt76_tx(struct mt76_phy *dev, struct ieee80211_sta *sta,
|
||||
struct mt76_wcid *wcid, struct sk_buff *skb);
|
||||
|
@ -269,6 +269,7 @@ mt7615_init_txpower(struct mt7615_dev *dev,
|
||||
int i, n_chains = hweight8(dev->mphy.antenna_mask), target_chains;
|
||||
u8 *eep = (u8 *)dev->mt76.eeprom.data;
|
||||
enum nl80211_band band = sband->band;
|
||||
int delta = mt76_tx_power_nss_delta(n_chains);
|
||||
|
||||
target_chains = mt7615_ext_pa_enabled(dev, band) ? 1 : n_chains;
|
||||
for (i = 0; i < sband->n_channels; i++) {
|
||||
@ -283,21 +284,7 @@ mt7615_init_txpower(struct mt7615_dev *dev,
|
||||
target_power = max(target_power, eep[index]);
|
||||
}
|
||||
|
||||
target_power = DIV_ROUND_UP(target_power, 2);
|
||||
switch (n_chains) {
|
||||
case 4:
|
||||
target_power += 6;
|
||||
break;
|
||||
case 3:
|
||||
target_power += 4;
|
||||
break;
|
||||
case 2:
|
||||
target_power += 3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
target_power = DIV_ROUND_UP(target_power + delta, 2);
|
||||
chan->max_power = min_t(int, chan->max_reg_power,
|
||||
target_power);
|
||||
chan->orig_mpwr = target_power;
|
||||
|
@ -1595,14 +1595,14 @@ int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev)
|
||||
|
||||
static void mt7615_mcu_set_txpower_sku(struct mt7615_phy *phy, u8 *sku)
|
||||
{
|
||||
static const u8 nss_delta[4] = { 0, 6, 8, 12 };
|
||||
struct mt76_phy *mphy = phy->mt76;
|
||||
struct ieee80211_hw *hw = mphy->hw;
|
||||
int n_chains = hweight8(mphy->antenna_mask);
|
||||
int tx_power;
|
||||
int i;
|
||||
|
||||
tx_power = hw->conf.power_level * 2 - nss_delta[n_chains - 1];
|
||||
tx_power = hw->conf.power_level * 2 -
|
||||
mt76_tx_power_nss_delta(n_chains);
|
||||
mphy->txpower_cur = tx_power;
|
||||
|
||||
for (i = 0; i < MT_SKU_1SS_DELTA; i++)
|
||||
@ -1612,7 +1612,8 @@ static void mt7615_mcu_set_txpower_sku(struct mt7615_phy *phy, u8 *sku)
|
||||
int delta = 0;
|
||||
|
||||
if (i < n_chains - 1)
|
||||
delta = nss_delta[n_chains - 1] - nss_delta[i];
|
||||
delta = mt76_tx_power_nss_delta(n_chains) -
|
||||
mt76_tx_power_nss_delta(i + 1);
|
||||
sku[MT_SKU_1SS_DELTA + i] = delta;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user