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 <[email protected]>
This commit is contained in:
Felix Fietkau
2020-02-11 21:01:03 +01:00
parent 764e1d208a
commit 1881241c7e
4 changed files with 15 additions and 36 deletions
+2 -18
View File
@@ -1050,25 +1050,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;
}