Browse Source

qcacmn: Add an API to translate the 6G channel enum

Add an API reg_translate_6g_chan_enum to translate an index between
MIN_6GHZ_CHANNEL and MAX_6GHZ_CHANNEL, to an index between 0 and
NUM_6GHZ_CHANNELS.

Change-Id: I5eaacf36403252a56293b8fadc797ac2aacd751d
CRs-Fixed: 3099080
Hariharan Basuthkar 3 years ago
parent
commit
722f740848

+ 17 - 0
umac/regulatory/core/src/reg_services_common.c

@@ -6087,6 +6087,23 @@ bool reg_is_upper_6g_edge_ch_disabled(struct wlan_objmgr_psoc *psoc)
 
 	return psoc_priv_obj->is_upper_6g_edge_ch_disabled;
 }
+
+static inline bool reg_is_within_range_inclusive(enum channel_enum left,
+						 enum channel_enum right,
+						 enum channel_enum idx)
+{
+	return (idx >= left) && (idx <= right);
+}
+
+uint16_t reg_convert_enum_to_6g_idx(enum channel_enum ch_idx)
+{
+	if (!reg_is_within_range_inclusive(MIN_6GHZ_CHANNEL,
+					   MAX_6GHZ_CHANNEL,
+					   ch_idx))
+		return INVALID_CHANNEL;
+
+	return (ch_idx - MIN_6GHZ_CHANNEL);
+}
 #endif
 
 #ifdef FEATURE_WLAN_CH_AVOID_EXT

+ 10 - 0
umac/regulatory/core/src/reg_services_common.h

@@ -1718,6 +1718,16 @@ bool reg_is_lower_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc);
  * Return: true if edge channels are supported, else false
  */
 bool reg_is_upper_6g_edge_ch_disabled(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * reg_convert_enum_to_6g_idx() - Convert a channel enum between
+ * MIN_6GHZ_CHANNEL and MAX_6GHZ_CHANNEL, to an index between 0 and
+ * NUM_6GHZ_CHANNELS
+ * @ch_idx: Channel index
+ *
+ * Return: enum channel_enum
+ */
+uint16_t reg_convert_enum_to_6g_idx(enum channel_enum ch_idx);
 #endif
 
 #ifdef FEATURE_WLAN_CH_AVOID_EXT