mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-01 17:12:20 -05:00
wifi: mt76: support power delta calculation for 5 TX paths
One variant of MT7992 has 5 TX paths, so extend the power delta function to support it. Also, rename nss_delta to path_delta since the value is based on the number of TX paths rather tha the number of spatial streams. (path delta [0.5 dBm] = 10 * log(path number) [dBm] * 2) Co-developed-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Link: https://patch.msgid.link/20250515032952.1653494-9-shayne.chen@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
committed by
Felix Fietkau
parent
249173e94d
commit
56e38675c5
@@ -1705,7 +1705,7 @@ s8 mt76_get_power_bound(struct mt76_phy *phy, s8 txpower)
|
||||
int n_chains = hweight16(phy->chainmask);
|
||||
|
||||
txpower = mt76_get_sar_power(phy, phy->chandef.chan, txpower * 2);
|
||||
txpower -= mt76_tx_power_nss_delta(n_chains);
|
||||
txpower -= mt76_tx_power_path_delta(n_chains);
|
||||
|
||||
return txpower;
|
||||
}
|
||||
@@ -1721,7 +1721,7 @@ int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||
return -EINVAL;
|
||||
|
||||
n_chains = hweight16(phy->chainmask);
|
||||
delta = mt76_tx_power_nss_delta(n_chains);
|
||||
delta = mt76_tx_power_path_delta(n_chains);
|
||||
*dbm = DIV_ROUND_UP(phy->txpower_cur + delta, 2);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1398,12 +1398,12 @@ 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 inline u8 mt76_tx_power_path_delta(u8 path)
|
||||
{
|
||||
static const u8 nss_delta[4] = { 0, 6, 9, 12 };
|
||||
u8 idx = nss - 1;
|
||||
static const u8 path_delta[5] = { 0, 6, 9, 12, 14 };
|
||||
u8 idx = path - 1;
|
||||
|
||||
return (idx < ARRAY_SIZE(nss_delta)) ? nss_delta[idx] : 0;
|
||||
return (idx < ARRAY_SIZE(path_delta)) ? path_delta[idx] : 0;
|
||||
}
|
||||
|
||||
static inline bool mt76_testmode_enabled(struct mt76_phy *phy)
|
||||
|
||||
@@ -273,7 +273,7 @@ void mt7615_init_txpower(struct mt7615_dev *dev,
|
||||
struct ieee80211_supported_band *sband)
|
||||
{
|
||||
int i, n_chains = hweight8(dev->mphy.antenna_mask), target_chains;
|
||||
int delta_idx, delta = mt76_tx_power_nss_delta(n_chains);
|
||||
int delta_idx, delta = mt76_tx_power_path_delta(n_chains);
|
||||
u8 *eep = (u8 *)dev->mt76.eeprom.data;
|
||||
enum nl80211_band band = sband->band;
|
||||
struct mt76_power_limits limits;
|
||||
|
||||
@@ -2067,7 +2067,7 @@ static void mt7615_mcu_set_txpower_sku(struct mt7615_phy *phy, u8 *sku)
|
||||
};
|
||||
|
||||
tx_power = mt76_get_sar_power(mphy, mphy->chandef.chan, tx_power);
|
||||
tx_power -= mt76_tx_power_nss_delta(n_chains);
|
||||
tx_power -= mt76_tx_power_path_delta(n_chains);
|
||||
tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan,
|
||||
&limits, tx_power);
|
||||
mphy->txpower_cur = tx_power;
|
||||
@@ -2084,8 +2084,8 @@ static void mt7615_mcu_set_txpower_sku(struct mt7615_phy *phy, u8 *sku)
|
||||
int delta = 0;
|
||||
|
||||
if (i < n_chains - 1)
|
||||
delta = mt76_tx_power_nss_delta(n_chains) -
|
||||
mt76_tx_power_nss_delta(i + 1);
|
||||
delta = mt76_tx_power_path_delta(n_chains) -
|
||||
mt76_tx_power_path_delta(i + 1);
|
||||
sku[MT_SKU_1SS_DELTA + i] = delta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ static void __mt7915_init_txpower(struct mt7915_phy *phy,
|
||||
{
|
||||
struct mt7915_dev *dev = phy->dev;
|
||||
int i, n_chains = hweight16(phy->mt76->chainmask);
|
||||
int nss_delta = mt76_tx_power_nss_delta(n_chains);
|
||||
int path_delta = mt76_tx_power_path_delta(n_chains);
|
||||
int pwr_delta = mt7915_eeprom_get_power_delta(dev, sband->band);
|
||||
struct mt76_power_limits limits;
|
||||
|
||||
@@ -305,7 +305,7 @@ static void __mt7915_init_txpower(struct mt7915_phy *phy,
|
||||
target_power = mt76_get_rate_power_limits(phy->mt76, chan,
|
||||
&limits,
|
||||
target_power);
|
||||
target_power += nss_delta;
|
||||
target_power += path_delta;
|
||||
target_power = DIV_ROUND_UP(target_power, 2);
|
||||
chan->max_power = min_t(int, chan->max_reg_power,
|
||||
target_power);
|
||||
|
||||
@@ -317,8 +317,8 @@ static void __mt7996_init_txpower(struct mt7996_phy *phy,
|
||||
struct ieee80211_supported_band *sband)
|
||||
{
|
||||
struct mt7996_dev *dev = phy->dev;
|
||||
int i, nss = hweight16(phy->mt76->chainmask);
|
||||
int nss_delta = mt76_tx_power_nss_delta(nss);
|
||||
int i, n_chains = hweight16(phy->mt76->chainmask);
|
||||
int path_delta = mt76_tx_power_path_delta(n_chains);
|
||||
int pwr_delta = mt7996_eeprom_get_power_delta(dev, sband->band);
|
||||
struct mt76_power_limits limits;
|
||||
|
||||
@@ -330,7 +330,7 @@ static void __mt7996_init_txpower(struct mt7996_phy *phy,
|
||||
target_power = mt76_get_rate_power_limits(phy->mt76, chan,
|
||||
&limits,
|
||||
target_power);
|
||||
target_power += nss_delta;
|
||||
target_power += path_delta;
|
||||
target_power = DIV_ROUND_UP(target_power, 2);
|
||||
chan->max_power = min_t(int, chan->max_reg_power,
|
||||
target_power);
|
||||
|
||||
@@ -688,7 +688,7 @@ mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||
}
|
||||
|
||||
n_chains = hweight16(phy->mt76->chainmask);
|
||||
delta = mt76_tx_power_nss_delta(n_chains);
|
||||
delta = mt76_tx_power_path_delta(n_chains);
|
||||
*dbm = DIV_ROUND_UP(phy->mt76->txpower_cur + delta, 2);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user