]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: phy: add firmware element of digital TX power compensation
authorPing-Ke Shih <pkshih@realtek.com>
Sat, 17 Jan 2026 04:41:53 +0000 (12:41 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 22 Jan 2026 02:14:30 +0000 (10:14 +0800)
Define and set compensation value to corresponding frequency bands.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260117044157.2392958-6-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/chan.c
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h

index 0b5509468582f0f789a408e9edd6e00bd3dc4b44..c0af6199222609dbce7a62db191e5c773f91088b 100644 (file)
@@ -60,6 +60,28 @@ static enum rtw89_subband rtw89_get_subband_type(enum rtw89_band band,
        }
 }
 
+static enum rtw89_tx_comp_band rtw89_get_tx_comp_band(enum rtw89_band band,
+                                                     u8 center_chan)
+{
+       switch (band) {
+       default:
+       case RTW89_BAND_2G:
+               return RTW89_TX_COMP_BAND_2GHZ;
+       case RTW89_BAND_5G:
+               if (center_chan < 149)
+                       return RTW89_TX_COMP_BAND_5GHZ_L;
+               else
+                       return RTW89_TX_COMP_BAND_5GHZ_H;
+       case RTW89_BAND_6G:
+               if (center_chan < 65)
+                       return RTW89_TX_COMP_BAND_5GHZ_H;
+               else if (center_chan < 193)
+                       return RTW89_TX_COMP_BAND_6GHZ_M;
+               else
+                       return RTW89_TX_COMP_BAND_6GHZ_UH;
+       }
+}
+
 static enum rtw89_sc_offset rtw89_get_primary_chan_idx(enum rtw89_bandwidth bw,
                                                       u32 center_freq,
                                                       u32 primary_freq)
@@ -123,6 +145,7 @@ void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,
 
        chan->freq = center_freq;
        chan->subband_type = rtw89_get_subband_type(band, center_chan);
+       chan->tx_comp_band = rtw89_get_tx_comp_band(band, center_chan);
        chan->pri_ch_idx = rtw89_get_primary_chan_idx(bandwidth, center_freq,
                                                      primary_freq);
        chan->pri_sb_idx = rtw89_get_primary_sb_idx(center_chan, primary_chan,
index 363d1bbe6869c3aac150157c82384f23e2a30f20..4778957d6b2dd926625522ef08dca1eb4c3bd1c2 100644 (file)
@@ -115,6 +115,16 @@ enum rtw89_subband {
        RTW89_SUBBAND_2GHZ_5GHZ_NR = RTW89_CH_5G_BAND_4 + 1,
 };
 
+enum rtw89_tx_comp_band {
+       RTW89_TX_COMP_BAND_2GHZ,
+       RTW89_TX_COMP_BAND_5GHZ_L,
+       RTW89_TX_COMP_BAND_5GHZ_H,
+       RTW89_TX_COMP_BAND_6GHZ_M,
+       RTW89_TX_COMP_BAND_6GHZ_UH,
+
+       RTW89_TX_COMP_BAND_NR,
+};
+
 enum rtw89_gain_offset {
        RTW89_GAIN_OFFSET_2G_CCK,
        RTW89_GAIN_OFFSET_2G_OFDM,
@@ -991,6 +1001,7 @@ struct rtw89_chan {
         */
        u32 freq;
        enum rtw89_subband subband_type;
+       enum rtw89_tx_comp_band tx_comp_band;
        enum rtw89_sc_offset pri_ch_idx;
        u8 pri_sb_idx;
 };
@@ -4831,6 +4842,7 @@ struct rtw89_fw_elm_info {
        const struct rtw89_regd_data *regd;
        const struct rtw89_fw_element_hdr *afe;
        const struct rtw89_fw_element_hdr *diag_mac;
+       const struct rtw89_fw_element_hdr *tx_comp;
 };
 
 enum rtw89_fw_mss_dev_type {
index b635579e90d3a525685e67aaa48ffc0d8897280c..5e405b57121f035846505230a1896cded3e11572 100644 (file)
@@ -1382,6 +1382,26 @@ int rtw89_recognize_diag_mac_from_elm(struct rtw89_dev *rtwdev,
        return 0;
 }
 
+static
+int rtw89_build_tx_comp_from_elm(struct rtw89_dev *rtwdev,
+                                const struct rtw89_fw_element_hdr *elm,
+                                const union rtw89_fw_element_arg arg)
+{
+       struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info;
+       struct rtw89_hal *hal = &rtwdev->hal;
+       u16 aid;
+
+       aid = le16_to_cpu(elm->aid);
+       if (aid && aid != hal->aid)
+               return 1; /* ignore if aid not matched */
+       else if (elm_info->tx_comp)
+               return 1; /* ignore if an element is existing */
+
+       elm_info->tx_comp = elm;
+
+       return 0;
+}
+
 static const struct rtw89_fw_element_handler __fw_element_handlers[] = {
        [RTW89_FW_ELEMENT_ID_BBMCU0] = {__rtw89_fw_recognize_from_elm,
                                        { .fw_type = RTW89_FW_BBMCU0 }, NULL},
@@ -1473,6 +1493,9 @@ static const struct rtw89_fw_element_handler __fw_element_handlers[] = {
        [RTW89_FW_ELEMENT_ID_DIAG_MAC] = {
                rtw89_recognize_diag_mac_from_elm, {}, NULL,
        },
+       [RTW89_FW_ELEMENT_ID_TX_COMP] = {
+               rtw89_build_tx_comp_from_elm, {}, NULL,
+       },
 };
 
 int rtw89_fw_recognize_elements(struct rtw89_dev *rtwdev)
index 146403d285b404fe61511a0207292ac738d77216..521702f97d5061500b23e6c96608312842b06035 100644 (file)
@@ -4262,6 +4262,7 @@ enum rtw89_fw_element_id {
        RTW89_FW_ELEMENT_ID_TXPWR_DA_LMT_RU_6GHZ = 26,
        RTW89_FW_ELEMENT_ID_AFE_PWR_SEQ = 27,
        RTW89_FW_ELEMENT_ID_DIAG_MAC = 28,
+       RTW89_FW_ELEMENT_ID_TX_COMP = 29,
 
        RTW89_FW_ELEMENT_ID_NUM,
 };