@@ -120,6 +120,6 @@ mt7915_tssi_enabled(struct mt7915_dev *dev, enum nl80211_band band)
return eep[MT_EE_WIFI_CONF + 7] & MT_EE_WIFI_CONF_TSSI0_2G;
}
-extern const struct sku_group mt7915_sku_groups[];
+extern const struct sku_group mt7915_sku_groups[MAX_SKU_RATE_GROUP_NUM];
#endif
@@ -3171,15 +3171,45 @@ int mt7915_mcu_set_sku(struct mt7915_phy *phy)
.format_id = 4,
.dbdc_idx = phy != &dev->phy,
};
- int i;
- s8 *delta;
+ struct mt76_power_limits limits_array;
+ s8 *delta, *la = (s8 *)&limits_array;
+ int i, idx;
delta = dev->rate_power[mphy->chandef.chan->band];
mphy->txpower_cur = hw->conf.power_level * 2 +
delta[MT7915_SKU_MAX_DELTA_IDX];
- for (i = 0; i < MT7915_SKU_RATE_NUM; i++)
- req.val[i] = hw->conf.power_level * 2 + delta[i];
+ mt76_get_rate_power_limits(mphy, mphy->chandef.chan,
+ &limits_array, mphy->txpower_cur);
+
+ for (i = 0, idx = 0; i < ARRAY_SIZE(mt7915_sku_groups); i++) {
+ const struct sku_group *sku = &mt7915_sku_groups[i];
+ u32 offset = sku->offset[mphy->chandef.chan->band];
+ u8 mcs_num = sku->len;
+ int j;
+
+ if (i >= SKU_HT_BW20 && i <= SKU_VHT_BW160) {
+ mcs_num = 10;
+
+ if (i == SKU_HT_BW20 || i == SKU_VHT_BW20)
+ la = (s8 *)&limits_array + 12;
+ }
+
+ if (!offset) {
+ idx += sku->len;
+ la += mcs_num;
+ continue;
+ }
+
+ for (j = 0; j < min_t(u8, mcs_num, sku->len); j++) {
+ s8 rate_power;
+
+ rate_power = hw->conf.power_level * 2 + delta[idx + j];
+ req.val[idx + j] = min_t(s8, la[j], rate_power);
+ }
+ la += mcs_num;
+ idx += sku->len;
+ }
return __mt76_mcu_send_msg(&dev->mt76,
MCU_EXT_CMD_TX_POWER_FEATURE_CTRL,