From: Ping-Ke Shih <pkshih@realtek.com>
To: <kvalo@kernel.org>
Cc: <kevin_yang@realtek.com>, <linux-wireless@vger.kernel.org>
Subject: [PATCH 1/7] wifi: rtw89: add subband index of primary channel to struct rtw89_chan
Date: Wed, 20 Sep 2023 15:43:16 +0800 [thread overview]
Message-ID: <20230920074322.42898-2-pkshih@realtek.com> (raw)
In-Reply-To: <20230920074322.42898-1-pkshih@realtek.com>
The subband index is a hardware value of relationship between primary
channel and bandwidth, and it is used by setting channel/bandwidth to
specify the primary channel.
Because this index is only needed when bandwidth >= 20 MHz, adjust
order of enumerator bandwidth to access offsets array easier. To prevent
misuse RTW89_CHANNEL_WIDTH_NUM as size, change it to
RTW89_CHANNEL_WIDTH_ORDINARY_NUM that will be the size of array. The
enumerator values of bandwidth (before ordinary number) will be also
used by upcoming TX power table built in firmware file, so add a comment
to remind keeping the order.
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
drivers/net/wireless/realtek/rtw89/chan.c | 15 +++++++++++++++
drivers/net/wireless/realtek/rtw89/core.h | 12 +++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c
index fb68d7f8ec3a..85c25213bf02 100644
--- a/drivers/net/wireless/realtek/rtw89/chan.c
+++ b/drivers/net/wireless/realtek/rtw89/chan.c
@@ -87,6 +87,19 @@ static enum rtw89_sc_offset rtw89_get_primary_chan_idx(enum rtw89_bandwidth bw,
return primary_chan_idx;
}
+static u8 rtw89_get_primary_sb_idx(u8 central_ch, u8 pri_ch,
+ enum rtw89_bandwidth bw)
+{
+ static const u8 prisb_cal_ofst[RTW89_CHANNEL_WIDTH_ORDINARY_NUM] = {
+ 0, 2, 6, 14, 30
+ };
+
+ if (bw >= RTW89_CHANNEL_WIDTH_ORDINARY_NUM)
+ return 0;
+
+ return (prisb_cal_ofst[bw] + pri_ch - central_ch) / 4;
+}
+
void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,
enum rtw89_band band, enum rtw89_bandwidth bandwidth)
{
@@ -106,6 +119,8 @@ void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,
chan->subband_type = rtw89_get_subband_type(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,
+ bandwidth);
}
bool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev,
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 08fa83995e17..cafc1e09f4d6 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -841,9 +841,14 @@ enum rtw89_bandwidth {
RTW89_CHANNEL_WIDTH_40 = 1,
RTW89_CHANNEL_WIDTH_80 = 2,
RTW89_CHANNEL_WIDTH_160 = 3,
- RTW89_CHANNEL_WIDTH_80_80 = 4,
- RTW89_CHANNEL_WIDTH_5 = 5,
- RTW89_CHANNEL_WIDTH_10 = 6,
+ RTW89_CHANNEL_WIDTH_320 = 4,
+
+ /* keep index order above */
+ RTW89_CHANNEL_WIDTH_ORDINARY_NUM = 5,
+
+ RTW89_CHANNEL_WIDTH_80_80 = 5,
+ RTW89_CHANNEL_WIDTH_5 = 6,
+ RTW89_CHANNEL_WIDTH_10 = 7,
};
enum rtw89_ps_mode {
@@ -898,6 +903,7 @@ struct rtw89_chan {
u32 freq;
enum rtw89_subband subband_type;
enum rtw89_sc_offset pri_ch_idx;
+ u8 pri_sb_idx;
};
struct rtw89_chan_rcd {
--
2.25.1
next prev parent reply other threads:[~2023-09-20 7:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 7:43 [PATCH 0/7] wifi: rtw89: support to load TX power tables from firmware file Ping-Ke Shih
2023-09-20 7:43 ` Ping-Ke Shih [this message]
2023-09-22 7:44 ` [PATCH 1/7] wifi: rtw89: add subband index of primary channel to struct rtw89_chan Kalle Valo
2023-09-20 7:43 ` [PATCH 2/7] wifi: rtw89: indicate TX shape table inside RFE parameter Ping-Ke Shih
2023-09-20 7:43 ` [PATCH 3/7] wifi: rtw89: indicate TX power by rate " Ping-Ke Shih
2023-09-20 7:43 ` [PATCH 4/7] wifi: rtw89: phy: refine helpers used for raw TX power Ping-Ke Shih
2023-09-20 7:43 ` [PATCH 5/7] wifi: rtw89: load TX power by rate when RFE parms setup Ping-Ke Shih
2023-09-20 7:43 ` [PATCH 6/7] wifi: rtw89: phy: extend TX power common stuffs for Wi-Fi 7 chips Ping-Ke Shih
2023-09-20 7:43 ` [PATCH 7/7] wifi: rtw89: load TX power related tables from FW elements 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=20230920074322.42898-2-pkshih@realtek.com \
--to=pkshih@realtek.com \
--cc=kevin_yang@realtek.com \
--cc=kvalo@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).