diff mbox series

[BlueZ,v2,2/5] test-bap: Move BASE defines to lc3.h

Message ID 20240625072711.7011-3-iulia.tanasescu@nxp.com (mailing list archive)
State Accepted
Commit 98013b74e5b12b30dd5fa86c1f78c8234d7eeac5
Headers show
Series test-bap: Add Broadcast Source STR MBIS tests | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Iulia Tanasescu June 25, 2024, 7:27 a.m. UTC
This moves the BASE related defines introduced in
test-bap to lc3.h.
---
 src/shared/lc3.h | 150 ++++++++++++++++++++++++++++++++++++++++++++++
 unit/test-bap.c  | 151 +----------------------------------------------
 2 files changed, 152 insertions(+), 149 deletions(-)
diff mbox series

Patch

diff --git a/src/shared/lc3.h b/src/shared/lc3.h
index abd9b29a3..944f574b0 100644
--- a/src/shared/lc3.h
+++ b/src/shared/lc3.h
@@ -275,6 +275,156 @@ 
 	LC3_CONFIG_48_AC(LC3_CONFIG_DURATION_10, LC3_CONFIG_FRAME_LEN_48_6, \
 			_ac)
 
+#define BASE(_pd, _sgrp, _nbis, _cfg...) \
+	_pd & 0xff, _pd >> 8, _pd >> 16, \
+	_sgrp, \
+	_nbis, \
+	_cfg
+
+#define BASE_LC3(_pd, _sgrp, _nbis, _cc...) \
+	BASE(_pd, _sgrp, _nbis, \
+		0x06, 0x00, 0x00, 0x00, 0x00, \
+		_cc)
+
+#define LC3_CFG(_freq, _dur, _len) \
+	0x0a, \
+	0x02, LC3_CONFIG_FREQ, _freq, \
+	0x02, LC3_CONFIG_DURATION, _dur, \
+	0x03, LC3_CONFIG_FRAME_LEN, _len, _len >> 8
+
+#define LC3_CFG_8_1 \
+	LC3_CFG(LC3_CONFIG_FREQ_8KHZ, \
+		LC3_CONFIG_DURATION_7_5, \
+		LC3_CONFIG_FRAME_LEN_8_1)
+
+#define BASE_LC3_8_1 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_8_1, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_8_2 \
+	LC3_CFG(LC3_CONFIG_FREQ_8KHZ, \
+		LC3_CONFIG_DURATION_10, \
+		LC3_CONFIG_FRAME_LEN_8_2)
+
+#define BASE_LC3_8_2 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_8_2, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_16_1 \
+	LC3_CFG(LC3_CONFIG_FREQ_16KHZ, \
+		LC3_CONFIG_DURATION_7_5, \
+		LC3_CONFIG_FRAME_LEN_16_1)
+
+#define BASE_LC3_16_1 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_16_1, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_16_2 \
+	LC3_CFG(LC3_CONFIG_FREQ_16KHZ, \
+		LC3_CONFIG_DURATION_10, \
+		LC3_CONFIG_FRAME_LEN_16_2)
+
+#define BASE_LC3_16_2 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_16_2, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_24_1 \
+	LC3_CFG(LC3_CONFIG_FREQ_24KHZ, \
+		LC3_CONFIG_DURATION_7_5, \
+		LC3_CONFIG_FRAME_LEN_24_1)
+
+#define BASE_LC3_24_1 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_24_1, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_24_2 \
+	LC3_CFG(LC3_CONFIG_FREQ_24KHZ, \
+		LC3_CONFIG_DURATION_10, \
+		LC3_CONFIG_FRAME_LEN_24_2)
+
+#define BASE_LC3_24_2 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_24_2, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_32_1 \
+	LC3_CFG(LC3_CONFIG_FREQ_32KHZ, \
+		LC3_CONFIG_DURATION_7_5, \
+		LC3_CONFIG_FRAME_LEN_32_1)
+
+#define BASE_LC3_32_1 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_32_1, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_32_2 \
+	LC3_CFG(LC3_CONFIG_FREQ_32KHZ, \
+		LC3_CONFIG_DURATION_10, \
+		LC3_CONFIG_FRAME_LEN_32_2)
+
+#define BASE_LC3_32_2 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_32_2, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_44_1 \
+	LC3_CFG(LC3_CONFIG_FREQ_44KHZ, \
+		LC3_CONFIG_DURATION_7_5, \
+		LC3_CONFIG_FRAME_LEN_44_1)
+
+#define BASE_LC3_44_1 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_44_1, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_44_2 \
+	LC3_CFG(LC3_CONFIG_FREQ_44KHZ, \
+		LC3_CONFIG_DURATION_10, \
+		LC3_CONFIG_FRAME_LEN_44_2)
+
+#define BASE_LC3_44_2 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_44_2, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_48_1 \
+	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
+		LC3_CONFIG_DURATION_7_5, \
+		LC3_CONFIG_FRAME_LEN_48_1)
+
+#define BASE_LC3_48_1 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_48_1, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_48_2 \
+	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
+		LC3_CONFIG_DURATION_10, \
+		LC3_CONFIG_FRAME_LEN_48_2)
+
+#define BASE_LC3_48_2 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_48_2, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_48_3 \
+	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
+		LC3_CONFIG_DURATION_7_5, \
+		LC3_CONFIG_FRAME_LEN_48_3)
+
+#define BASE_LC3_48_3 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_48_3, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_48_4 \
+	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
+		LC3_CONFIG_DURATION_10, \
+		LC3_CONFIG_FRAME_LEN_48_4)
+
+#define BASE_LC3_48_4 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_48_4, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_48_5 \
+	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
+		LC3_CONFIG_DURATION_7_5, \
+		LC3_CONFIG_FRAME_LEN_48_5)
+
+#define BASE_LC3_48_5 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_48_5, 0x00, 0x01, 0x00)
+
+#define LC3_CFG_48_6 \
+	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
+		LC3_CONFIG_DURATION_10, \
+		LC3_CONFIG_FRAME_LEN_48_6)
+
+#define BASE_LC3_48_6 \
+	BASE_LC3(40000, 1, 1, LC3_CFG_48_6, 0x00, 0x01, 0x00)
+
+#define BASE_VS(_cc) \
+	BASE(40000, 1, 1, \
+		0xFF, 0x00, 0x00, 0x00, 0x00, \
+		_cc, 0x00, 0x01, 0x00)
+
 #define LC3_QOS_UNFRAMED	0x00
 #define LC3_QOS_FRAMED		0x01
 
diff --git a/unit/test-bap.c b/unit/test-bap.c
index 638717afc..c92c4f671 100644
--- a/unit/test-bap.c
+++ b/unit/test-bap.c
@@ -5574,29 +5574,6 @@  static void test_scc(void)
 	test_str_1_1_1_lc3();
 }
 
-#define LC3_CFG(_freq, _dur, _len) \
-	0x0a, \
-	0x02, 0x01, _freq, \
-	0x02, 0x02, _dur, \
-	0x03, 0x04, _len, _len >> 8
-
-#define BASE(_pd, _sgrp, _nbis, _cfg...) \
-	_pd & 0xff, _pd >> 8, _pd >> 16, \
-	_sgrp, \
-	_nbis, \
-	_cfg
-
-#define BASE_LC3(_pd, _sgrp, _nbis, _cc...) \
-	BASE(_pd, _sgrp, _nbis, 0x06, 0x00, 0x00, 0x00, 0x00, _cc)
-
-#define LC3_CFG_8_1 \
-	LC3_CFG(LC3_CONFIG_FREQ_8KHZ, \
-		LC3_CONFIG_DURATION_7_5, \
-		LC3_CONFIG_FRAME_LEN_8_1)
-
-#define BASE_LC3_8_1 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_8_1, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_8_1_1 = {
 	.cc = LC3_CONFIG_8_1,
 	.qos = LC3_QOS_8_1_1_B,
@@ -5613,14 +5590,6 @@  static struct test_config cfg_bsrc_8_1_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_8_2 \
-	LC3_CFG(LC3_CONFIG_FREQ_8KHZ, \
-		LC3_CONFIG_DURATION_10, \
-		LC3_CONFIG_FRAME_LEN_8_2)
-
-#define BASE_LC3_8_2 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_8_2, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_8_2_1 = {
 	.cc = LC3_CONFIG_8_2,
 	.qos = LC3_QOS_8_2_1_B,
@@ -5637,14 +5606,6 @@  static struct test_config cfg_bsrc_8_2_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_16_1 \
-	LC3_CFG(LC3_CONFIG_FREQ_16KHZ, \
-		LC3_CONFIG_DURATION_7_5, \
-		LC3_CONFIG_FRAME_LEN_16_1)
-
-#define BASE_LC3_16_1 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_16_1, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_16_1_1 = {
 	.cc = LC3_CONFIG_16_1,
 	.qos = LC3_QOS_16_1_1_B,
@@ -5661,14 +5622,6 @@  static struct test_config cfg_bsrc_16_1_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_16_2 \
-	LC3_CFG(LC3_CONFIG_FREQ_16KHZ, \
-		LC3_CONFIG_DURATION_10, \
-		LC3_CONFIG_FRAME_LEN_16_2)
-
-#define BASE_LC3_16_2 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_16_2, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_16_2_1 = {
 	.cc = LC3_CONFIG_16_2,
 	.qos = LC3_QOS_16_2_1_B,
@@ -5685,14 +5638,6 @@  static struct test_config cfg_bsrc_16_2_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_24_1 \
-	LC3_CFG(LC3_CONFIG_FREQ_24KHZ, \
-		LC3_CONFIG_DURATION_7_5, \
-		LC3_CONFIG_FRAME_LEN_24_1)
-
-#define BASE_LC3_24_1 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_24_1, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_24_1_1 = {
 	.cc = LC3_CONFIG_24_1,
 	.qos = LC3_QOS_24_1_1_B,
@@ -5709,14 +5654,6 @@  static struct test_config cfg_bsrc_24_1_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_24_2 \
-	LC3_CFG(LC3_CONFIG_FREQ_24KHZ, \
-		LC3_CONFIG_DURATION_10, \
-		LC3_CONFIG_FRAME_LEN_24_2)
-
-#define BASE_LC3_24_2 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_24_2, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_24_2_1 = {
 	.cc = LC3_CONFIG_24_2,
 	.qos = LC3_QOS_24_2_1_B,
@@ -5733,14 +5670,6 @@  static struct test_config cfg_bsrc_24_2_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_32_1 \
-	LC3_CFG(LC3_CONFIG_FREQ_32KHZ, \
-		LC3_CONFIG_DURATION_7_5, \
-		LC3_CONFIG_FRAME_LEN_32_1)
-
-#define BASE_LC3_32_1 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_32_1, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_32_1_1 = {
 	.cc = LC3_CONFIG_32_1,
 	.qos = LC3_QOS_32_1_1_B,
@@ -5757,14 +5686,6 @@  static struct test_config cfg_bsrc_32_1_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_32_2 \
-	LC3_CFG(LC3_CONFIG_FREQ_32KHZ, \
-		LC3_CONFIG_DURATION_10, \
-		LC3_CONFIG_FRAME_LEN_32_2)
-
-#define BASE_LC3_32_2 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_32_2, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_32_2_1 = {
 	.cc = LC3_CONFIG_32_2,
 	.qos = LC3_QOS_32_2_1_B,
@@ -5781,14 +5702,6 @@  static struct test_config cfg_bsrc_32_2_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_44_1 \
-	LC3_CFG(LC3_CONFIG_FREQ_44KHZ, \
-		LC3_CONFIG_DURATION_7_5, \
-		LC3_CONFIG_FRAME_LEN_44_1)
-
-#define BASE_LC3_44_1 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_44_1, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_44_1_1 = {
 	.cc = LC3_CONFIG_44_1,
 	.qos = LC3_QOS_44_1_1_B,
@@ -5805,14 +5718,6 @@  static struct test_config cfg_bsrc_44_1_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_44_2 \
-	LC3_CFG(LC3_CONFIG_FREQ_44KHZ, \
-		LC3_CONFIG_DURATION_10, \
-		LC3_CONFIG_FRAME_LEN_44_2)
-
-#define BASE_LC3_44_2 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_44_2, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_44_2_1 = {
 	.cc = LC3_CONFIG_44_2,
 	.qos = LC3_QOS_44_2_1_B,
@@ -5829,14 +5734,6 @@  static struct test_config cfg_bsrc_44_2_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_48_1 \
-	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
-		LC3_CONFIG_DURATION_7_5, \
-		LC3_CONFIG_FRAME_LEN_48_1)
-
-#define BASE_LC3_48_1 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_48_1, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_48_1_1 = {
 	.cc = LC3_CONFIG_48_1,
 	.qos = LC3_QOS_48_1_1_B,
@@ -5853,14 +5750,6 @@  static struct test_config cfg_bsrc_48_1_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_48_2 \
-	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
-		LC3_CONFIG_DURATION_10, \
-		LC3_CONFIG_FRAME_LEN_48_2)
-
-#define BASE_LC3_48_2 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_48_2, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_48_2_1 = {
 	.cc = LC3_CONFIG_48_2,
 	.qos = LC3_QOS_48_2_1_B,
@@ -5877,14 +5766,6 @@  static struct test_config cfg_bsrc_48_2_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_48_3 \
-	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
-		LC3_CONFIG_DURATION_7_5, \
-		LC3_CONFIG_FRAME_LEN_48_3)
-
-#define BASE_LC3_48_3 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_48_3, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_48_3_1 = {
 	.cc = LC3_CONFIG_48_3,
 	.qos = LC3_QOS_48_3_1_B,
@@ -5901,14 +5782,6 @@  static struct test_config cfg_bsrc_48_3_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_48_4 \
-	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
-		LC3_CONFIG_DURATION_10, \
-		LC3_CONFIG_FRAME_LEN_48_4)
-
-#define BASE_LC3_48_4 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_48_4, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_48_4_1 = {
 	.cc = LC3_CONFIG_48_4,
 	.qos = LC3_QOS_48_4_1_B,
@@ -5925,14 +5798,6 @@  static struct test_config cfg_bsrc_48_4_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_48_5 \
-	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
-		LC3_CONFIG_DURATION_7_5, \
-		LC3_CONFIG_FRAME_LEN_48_5)
-
-#define BASE_LC3_48_5 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_48_5, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_48_5_1 = {
 	.cc = LC3_CONFIG_48_5,
 	.qos = LC3_QOS_48_5_1_B,
@@ -5949,14 +5814,6 @@  static struct test_config cfg_bsrc_48_5_2 = {
 	.state_func = bsrc_state_cfg,
 };
 
-#define LC3_CFG_48_6 \
-	LC3_CFG(LC3_CONFIG_FREQ_48KHZ, \
-		LC3_CONFIG_DURATION_10, \
-		LC3_CONFIG_FRAME_LEN_48_6)
-
-#define BASE_LC3_48_6 \
-	BASE_LC3(40000, 1, 1, LC3_CFG_48_6, 0x00, 0x01, 0x00)
-
 static struct test_config cfg_bsrc_48_6_1 = {
 	.cc = LC3_CONFIG_48_6,
 	.qos = LC3_QOS_48_6_1_B,
@@ -5983,10 +5840,6 @@  static struct test_config cfg_bsrc_48_6_2 = {
 	0x10, \
 	VS_CC
 
-#define BASE_VS \
-	BASE(40000, 1, 1, 0xFF, 0x00, 0x00, 0x00, 0x00, \
-	VS_CFG, 0x00, 0x01, 0x00)
-
 #define QOS_BCAST \
 { \
 	.bcast.big = 0x00, \
@@ -6003,7 +5856,7 @@  static struct test_config cfg_bsrc_48_6_2 = {
 static struct test_config cfg_bsrc_vs = {
 	.cc = UTIL_IOV_INIT(VS_CC),
 	.qos = QOS_BCAST,
-	.base = UTIL_IOV_INIT(BASE_VS),
+	.base = UTIL_IOV_INIT(BASE_VS(VS_CFG)),
 	.vs = true,
 	.src = true,
 	.state_func = bsrc_state_cfg,
@@ -7106,7 +6959,7 @@  static struct test_config cfg_bsrc_str_48_6 = {
 static struct test_config cfg_bsrc_str_vs = {
 	.cc = UTIL_IOV_INIT(VS_CC),
 	.qos = QOS_BCAST,
-	.base = UTIL_IOV_INIT(BASE_VS),
+	.base = UTIL_IOV_INIT(BASE_VS(VS_CFG)),
 	.src = true,
 	.state_func = bsrc_state_str,
 	.streams = 1,