From: Ping-Ke Shih <pkshih@realtek.com>
To: <linux-wireless@vger.kernel.org>
Cc: <kevin_yang@realtek.com>, <dian_syuan0116@realtek.com>,
<damon.chen@realtek.com>
Subject: [PATCH rtw-next 3/5] wifi: rtw89: enable dynamic antenna gain based on country
Date: Thu, 6 Mar 2025 10:11:42 +0800 [thread overview]
Message-ID: <20250306021144.12854-4-pkshih@realtek.com> (raw)
In-Reply-To: <20250306021144.12854-1-pkshih@realtek.com>
From: Kuan-Chung Chen <damon.chen@realtek.com>
The dynamic antenna gain (DAG) considers the country, meaning DAG can
be activated only when countries and regulatory domains allow it.
Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
drivers/net/wireless/realtek/rtw89/core.h | 1 +
drivers/net/wireless/realtek/rtw89/phy.c | 11 ++++++++---
drivers/net/wireless/realtek/rtw89/regd.c | 14 ++++++++++++++
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 074c865e6d03..b8f46207141e 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -4666,6 +4666,7 @@ enum rtw89_ant_gain_domain_type {
struct rtw89_ant_gain_info {
s8 offset[RTW89_ANT_GAIN_CHAIN_NUM][RTW89_ANT_GAIN_SUBBAND_NR];
u32 regd_enabled;
+ bool block_country;
};
struct rtw89_6ghz_span {
diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index abc2a7e989eb..bd736417f467 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -2044,7 +2044,7 @@ static s8 rtw89_phy_ant_gain_offset(struct rtw89_dev *rtwdev, u8 band, u32 cente
if (!chip->support_ant_gain)
return 0;
- if (!(ant_gain->regd_enabled & BIT(regd)))
+ if (ant_gain->block_country || !(ant_gain->regd_enabled & BIT(regd)))
return 0;
offset_patha = rtw89_phy_ant_gain_query(rtwdev, RF_PATH_A, center_freq);
@@ -2057,10 +2057,14 @@ s16 rtw89_phy_ant_gain_pwr_offset(struct rtw89_dev *rtwdev,
const struct rtw89_chan *chan)
{
struct rtw89_ant_gain_info *ant_gain = &rtwdev->ant_gain;
+ const struct rtw89_chip_info *chip = rtwdev->chip;
u8 regd = rtw89_regd_get(rtwdev, chan->band_type);
s8 offset_patha, offset_pathb;
- if (!(ant_gain->regd_enabled & BIT(regd)))
+ if (!chip->support_ant_gain)
+ return 0;
+
+ if (ant_gain->block_country || !(ant_gain->regd_enabled & BIT(regd)))
return 0;
offset_patha = rtw89_phy_ant_gain_query(rtwdev, RF_PATH_A, chan->freq);
@@ -2079,7 +2083,8 @@ int rtw89_print_ant_gain(struct rtw89_dev *rtwdev, char *buf, size_t bufsz,
char *p = buf, *end = buf + bufsz;
s8 offset_patha, offset_pathb;
- if (!chip->support_ant_gain || !(ant_gain->regd_enabled & BIT(regd))) {
+ if (!(chip->support_ant_gain && (ant_gain->regd_enabled & BIT(regd))) ||
+ ant_gain->block_country) {
p += scnprintf(p, end - p, "no DAG is applied\n");
goto out;
}
diff --git a/drivers/net/wireless/realtek/rtw89/regd.c b/drivers/net/wireless/realtek/rtw89/regd.c
index d31403f9009e..655323a79608 100644
--- a/drivers/net/wireless/realtek/rtw89/regd.c
+++ b/drivers/net/wireless/realtek/rtw89/regd.c
@@ -733,6 +733,19 @@ static void rtw89_regd_apply_policy_tas(struct rtw89_dev *rtwdev)
tas->block_regd = !test_bit(RTW89_REGD_FUNC_TAS, regd->func_bitmap);
}
+static void rtw89_regd_apply_policy_ant_gain(struct rtw89_dev *rtwdev)
+{
+ struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
+ struct rtw89_ant_gain_info *ant_gain = &rtwdev->ant_gain;
+ const struct rtw89_chip_info *chip = rtwdev->chip;
+ const struct rtw89_regd *regd = regulatory->regd;
+
+ if (!chip->support_ant_gain)
+ return;
+
+ ant_gain->block_country = !test_bit(RTW89_REGD_FUNC_DAG, regd->func_bitmap);
+}
+
static void rtw89_regd_notifier_apply(struct rtw89_dev *rtwdev,
struct wiphy *wiphy,
struct regulatory_request *request)
@@ -751,6 +764,7 @@ static void rtw89_regd_notifier_apply(struct rtw89_dev *rtwdev,
rtw89_regd_apply_policy_unii4(rtwdev, wiphy);
rtw89_regd_apply_policy_6ghz(rtwdev, wiphy);
rtw89_regd_apply_policy_tas(rtwdev);
+ rtw89_regd_apply_policy_ant_gain(rtwdev);
}
static
--
2.25.1
next prev parent reply other threads:[~2025-03-06 2:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 2:11 [PATCH rtw-next 0/5] wifi: rtw89: refine TAS and DAG Ping-Ke Shih
2025-03-06 2:11 ` [PATCH rtw-next 1/5] wifi: rtw89: add support for negative values of dBm to linear conversion Ping-Ke Shih
2025-03-13 1:00 ` Ping-Ke Shih
2025-03-06 2:11 ` [PATCH rtw-next 2/5] wifi: rtw89: refine mechanism of TAS Ping-Ke Shih
2025-03-06 2:11 ` Ping-Ke Shih [this message]
2025-03-06 2:11 ` [PATCH rtw-next 4/5] wifi: rtw89: 8922a: enable dynamic antenna gain Ping-Ke Shih
2025-03-06 2:11 ` [PATCH rtw-next 5/5] wifi: rtw89: set force HE TB mode when connecting to 11ax AP 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=20250306021144.12854-4-pkshih@realtek.com \
--to=pkshih@realtek.com \
--cc=damon.chen@realtek.com \
--cc=dian_syuan0116@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