From: Ping-Ke Shih <pkshih@realtek.com>
To: <linux-wireless@vger.kernel.org>
Cc: <kevin_yang@realtek.com>
Subject: [PATCH rtw-next 2/7] wifi: rtw89: 8922d: refactor digital power compensation to support new format
Date: Wed, 20 May 2026 20:38:18 +0800 [thread overview]
Message-ID: <20260520123823.1792954-3-pkshih@realtek.com> (raw)
In-Reply-To: <20260520123823.1792954-1-pkshih@realtek.com>
Because base settings of digital power compensation can be shared across
all bands, the settings are divided into two parts -- base and individual
values per bands. Refactor the code to be reuse with new format.
No change logic at all.
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
drivers/net/wireless/realtek/rtw89/rtw8922d.c | 31 +++++++++++++------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8922d.c b/drivers/net/wireless/realtek/rtw89/rtw8922d.c
index c6c37e25e4c8..af2df4adfa85 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8922d.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8922d.c
@@ -2118,29 +2118,42 @@ static void rtw8922d_set_digital_pwr_comp(struct rtw89_dev *rtwdev,
enum rtw89_rf_path path,
enum rtw89_phy_idx phy_idx)
{
-#define DIGITAL_PWR_COMP_REG_NUM 22
+#define DIGITAL_PWR_COMP_BASE_NUM 7
+#define DIGITAL_PWR_COMP_VALS_NUM 15
static const u32 pw_comp_cr[2] = {R_RX_PATH0_TBL0_BE4, R_RX_PATH1_TBL0_BE4};
- const __le32 (*pwr_comp_val)[2][RTW89_TX_COMP_BAND_NR]
- [BB_PATH_NUM_8922D][DIGITAL_PWR_COMP_REG_NUM];
+ const struct {
+ struct {
+ __le32 base[DIGITAL_PWR_COMP_BASE_NUM];
+ __le32 vals[DIGITAL_PWR_COMP_VALS_NUM];
+ } sets[2][RTW89_TX_COMP_BAND_NR][BB_PATH_NUM_8922D];
+ } *pwr_comp_v0;
struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info;
const struct rtw89_fw_element_hdr *txcomp_elm = elm_info->tx_comp;
- const __le32 *digital_pwr_comp;
+ const __le32 (*comp_base)[DIGITAL_PWR_COMP_BASE_NUM];
+ const __le32 (*comp_vals)[DIGITAL_PWR_COMP_VALS_NUM];
u32 addr, val;
u32 i;
- if (sizeof(*pwr_comp_val) != le32_to_cpu(txcomp_elm->size)) {
+ if (sizeof(*pwr_comp_v0) == le32_to_cpu(txcomp_elm->size)) {
+ pwr_comp_v0 = (const void *)txcomp_elm->u.common.contents;
+ comp_base = &pwr_comp_v0->sets[nss][chan->tx_comp_band][path].base;
+ comp_vals = &pwr_comp_v0->sets[nss][chan->tx_comp_band][path].vals;
+ } else {
rtw89_debug(rtwdev, RTW89_DBG_UNEXP,
"incorrect power comp size %d\n",
le32_to_cpu(txcomp_elm->size));
return;
}
- pwr_comp_val = (const void *)txcomp_elm->u.common.contents;
- digital_pwr_comp = (*pwr_comp_val)[nss][chan->tx_comp_band][path];
addr = pw_comp_cr[path];
- for (i = 0; i < DIGITAL_PWR_COMP_REG_NUM; i++, addr += 4) {
- val = le32_to_cpu(digital_pwr_comp[i]);
+ for (i = 0; i < ARRAY_SIZE(*comp_base); i++, addr += 4) {
+ val = le32_to_cpu((*comp_base)[i]);
+ rtw89_phy_write32_idx(rtwdev, addr, MASKDWORD, val, phy_idx);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(*comp_vals); i++, addr += 4) {
+ val = le32_to_cpu((*comp_vals)[i]);
rtw89_phy_write32_idx(rtwdev, addr, MASKDWORD, val, phy_idx);
}
}
--
2.25.1
next prev parent reply other threads:[~2026-05-20 12:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 12:38 [PATCH rtw-next 0/7] wifi: rtw89: update firmware elements formats of power track, compensation and MRU Ping-Ke Shih
2026-05-20 12:38 ` [PATCH rtw-next 1/7] wifi: rtw89: fw: load TX power track element according to AID Ping-Ke Shih
2026-05-27 8:42 ` Ping-Ke Shih
2026-05-20 12:38 ` Ping-Ke Shih [this message]
2026-05-20 12:38 ` [PATCH rtw-next 3/7] wifi: rtw89: 8922d: support new digital power compensation format Ping-Ke Shih
2026-05-20 12:38 ` [PATCH rtw-next 4/7] wifi: rtw89: fw: load TX compensation element by RFE type Ping-Ke Shih
2026-05-20 12:38 ` [PATCH rtw-next 5/7] wifi: rtw89: Wi-Fi 7 configure TX power limit for large MRU Ping-Ke Shih
2026-05-20 12:38 ` [PATCH rtw-next 6/7] wifi: rtw89: debug: show large MRU in txpwr_table dbgfs Ping-Ke Shih
2026-05-20 12:38 ` [PATCH rtw-next 7/7] wifi: rtw89: 8922d: configure TX shape settings Ping-Ke Shih
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260520123823.1792954-3-pkshih@realtek.com \
--to=pkshih@realtek.com \
--cc=kevin_yang@realtek.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox