diff mbox series

[BlueZ,2/2] iso-tester: Add BAP Broadcast AC tests

Message ID 20230529062458.3632-3-iulia.tanasescu@nxp.com
State New
Headers show
Series iso-tester: Add BAP Broadcast AC tests | expand

Commit Message

Iulia Tanasescu May 29, 2023, 6:24 a.m. UTC
This adds the following tests based on BAP Broadcast Audio Configurations:

ISO Broadcaster AC 12 - Success
ISO Broadcaster AC 13 - Success
ISO Broadcaster AC 14 - Success

---
 tools/iso-tester.c | 193 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 157 insertions(+), 36 deletions(-)
diff mbox series

Patch

diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index 63c37bd52..ae6ddb2da 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -288,6 +288,90 @@ 
 #define QOS_IN_16_2_1 BCAST_QOS_IN(10000, 10, 40, 0x02, 2)
 #define QOS_IN_ENC_16_2_1 BCAST_QOS_IN_ENC(10000, 10, 40, 0x02, 2)
 
+static const uint8_t base_lc3_16_2_1[] = {
+	0x28, 0x00, 0x00, /* Presentation Delay */
+	0x01, /* Number of Subgroups */
+	0x01, /* Number of BIS */
+	0x06, 0x00, 0x00, 0x00, 0x00, /* Code ID = LC3 (0x06) */
+	0x11, /* Codec Specific Configuration */
+	0x02, 0x01, 0x03, /* 16 KHZ */
+	0x02, 0x02, 0x01, /* 10 ms */
+	0x05, 0x03, 0x01, 0x00, 0x00, 0x00,  /* Front Left */
+	0x03, 0x04, 0x28, 0x00, /* Frame Length 40 bytes */
+	0x04, /* Metadata */
+	0x03, 0x02, 0x02, 0x00, /* Audio Context: Convertional */
+	0x01, /* BIS */
+	0x00, /* Codec Specific Configuration */
+};
+
+/* Single Audio Channel. One BIS. */
+#define BCAST_AC_12 BCAST_QOS_OUT_1_1(10000, 10, 40, 0x02, 2)
+
+static const uint8_t base_lc3_ac_12[] = {
+	0x28, 0x00, 0x00, /* Presentation Delay */
+	0x01, /* Number of Subgroups */
+	0x01, /* Number of BIS */
+	0x06, 0x00, 0x00, 0x00, 0x00, /* Code ID = LC3 (0x06) */
+	0x11, /* Codec Specific Configuration */
+	0x02, 0x01, 0x03, /* 16 KHZ */
+	0x02, 0x02, 0x01, /* 10 ms */
+	0x05, 0x03, 0x01, 0x00, 0x00, 0x00,  /* Front Left */
+	0x03, 0x04, 0x28, 0x00, /* Frame Length 40 bytes */
+	0x04, /* Metadata */
+	0x03, 0x02, 0x02, 0x00, /* Audio Context: Convertional */
+	0x01, /* BIS */
+	0x00, /* Codec Specific Configuration */
+};
+
+/* Multiple Audio Channels. Two BISes. */
+#define BCAST_AC_13 BCAST_QOS_OUT_1_1(10000, 10, 40, 0x02, 2)
+
+static const uint8_t base_lc3_ac_13[] = {
+	0x28, 0x00, 0x00, /* Presentation Delay */
+	0x01, /* Number of Subgroups */
+	0x02, /* Number of BIS */
+	0x06, 0x00, 0x00, 0x00, 0x00, /* Code ID = LC3 (0x06) */
+	0x11, /* Codec Specific Configuration */
+	0x02, 0x01, 0x03, /* 16 KHZ */
+	0x02, 0x02, 0x01, /* 10 ms */
+	0x05, 0x03, 0x01, 0x00, 0x00, 0x00,  /* Front Left */
+	0x03, 0x04, 0x28, 0x00, /* Frame Length 40 bytes */
+	0x04, /* Metadata */
+	0x03, 0x02, 0x02, 0x00, /* Audio Context: Convertional */
+	0x01, /* BIS 1 */
+	0x06, /* Codec Specific Configuration */
+	0x05, 0x03, 0x01, 0x00, 0x00, 0x00, /* Audio_Channel_Allocation:
+					     * Front left
+					     */
+	0x01, /* BIS 2 */
+	0x06, /* Codec Specific Configuration */
+	0x05, 0x03, 0x02, 0x00, 0x00, 0x00, /* Audio_Channel_Allocation:
+					     * Front right
+					     */
+};
+
+/* Multiple Audio Channels. One BIS. */
+#define BCAST_AC_14 BCAST_QOS_OUT_1_1(10000, 10, 40, 0x02, 2)
+
+static const uint8_t base_lc3_ac_14[] = {
+	0x28, 0x00, 0x00, /* Presentation Delay */
+	0x01, /* Number of Subgroups */
+	0x01, /* Number of BIS */
+	0x06, 0x00, 0x00, 0x00, 0x00, /* Code ID = LC3 (0x06) */
+	0x11, /* Codec Specific Configuration */
+	0x02, 0x01, 0x03, /* 16 KHZ */
+	0x02, 0x02, 0x01, /* 10 ms */
+	0x05, 0x03, 0x01, 0x00, 0x00, 0x00,  /* Front Left */
+	0x03, 0x04, 0x28, 0x00, /* Frame Length 40 bytes */
+	0x04, /* Metadata */
+	0x03, 0x02, 0x02, 0x00, /* Audio Context: Convertional */
+	0x01, /* BIS */
+	0x06, /* Codec Specific Configuration */
+	0x05, 0x03, 0x03, 0x00, 0x00, 0x00, /* Audio_Channel_Allocation:
+					     * Front left, Front right
+					     */
+};
+
 struct test_data {
 	const void *test_data;
 	struct mgmt *mgmt;
@@ -315,7 +399,9 @@  struct iso_client_data {
 	bool defer;
 	bool disconnect;
 	bool ts;
-	bool mcis;
+	bool mconn;
+	const uint8_t *base;
+	size_t base_len;
 };
 
 static void mgmt_debug(const char *str, void *user_data)
@@ -835,7 +921,7 @@  static const struct iso_client_data connect_ac_6i = {
 	.qos = AC_6i_1,
 	.qos_2 = AC_6i_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -843,7 +929,7 @@  static const struct iso_client_data connect_ac_6ii = {
 	.qos = AC_6ii_1,
 	.qos_2 = AC_6ii_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -851,7 +937,7 @@  static const struct iso_client_data connect_ac_7i = {
 	.qos = AC_7i_1,
 	.qos_2 = AC_7i_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -859,7 +945,7 @@  static const struct iso_client_data connect_ac_7ii = {
 	.qos = AC_7ii_1,
 	.qos_2 = AC_7ii_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -867,7 +953,7 @@  static const struct iso_client_data connect_ac_8i = {
 	.qos = AC_8i_1,
 	.qos_2 = AC_8i_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -875,7 +961,7 @@  static const struct iso_client_data connect_ac_8ii = {
 	.qos = AC_8ii_1,
 	.qos_2 = AC_8ii_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -883,7 +969,7 @@  static const struct iso_client_data connect_ac_9i = {
 	.qos = AC_9i_1,
 	.qos_2 = AC_9i_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -891,7 +977,7 @@  static const struct iso_client_data connect_ac_9ii = {
 	.qos = AC_9ii_1,
 	.qos_2 = AC_9ii_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -899,7 +985,7 @@  static const struct iso_client_data connect_ac_11i = {
 	.qos = AC_11i_1,
 	.qos_2 = AC_11i_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -907,7 +993,7 @@  static const struct iso_client_data connect_ac_11ii = {
 	.qos = AC_11ii_1,
 	.qos_2 = AC_11ii_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 	.defer = true,
 };
 
@@ -915,14 +1001,14 @@  static const struct iso_client_data connect_ac_1_2 = {
 	.qos = AC_1_4,
 	.qos_2 = AC_2_10,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 };
 
 static const struct iso_client_data connect_ac_1_2_cig_1_2 = {
 	.qos = AC_1_4_1,
 	.qos_2 = AC_2_10_2,
 	.expect_err = 0,
-	.mcis = true,
+	.mconn = true,
 };
 
 static const struct iso_client_data bcast_16_2_1_send = {
@@ -930,6 +1016,8 @@  static const struct iso_client_data bcast_16_2_1_send = {
 	.expect_err = 0,
 	.send = &send_16_2_1,
 	.bcast = true,
+	.base = base_lc3_16_2_1,
+	.base_len = sizeof(base_lc3_16_2_1),
 };
 
 static const struct iso_client_data bcast_enc_16_2_1_send = {
@@ -937,6 +1025,8 @@  static const struct iso_client_data bcast_enc_16_2_1_send = {
 	.expect_err = 0,
 	.send = &send_16_2_1,
 	.bcast = true,
+	.base = base_lc3_16_2_1,
+	.base_len = sizeof(base_lc3_16_2_1),
 };
 
 static const struct iso_client_data bcast_1_16_2_1_send = {
@@ -944,6 +1034,8 @@  static const struct iso_client_data bcast_1_16_2_1_send = {
 	.expect_err = 0,
 	.send = &send_16_2_1,
 	.bcast = true,
+	.base = base_lc3_16_2_1,
+	.base_len = sizeof(base_lc3_16_2_1),
 };
 
 static const struct iso_client_data bcast_1_1_16_2_1_send = {
@@ -951,6 +1043,8 @@  static const struct iso_client_data bcast_1_1_16_2_1_send = {
 	.expect_err = 0,
 	.send = &send_16_2_1,
 	.bcast = true,
+	.base = base_lc3_16_2_1,
+	.base_len = sizeof(base_lc3_16_2_1),
 };
 
 static const struct iso_client_data bcast_16_2_1_recv = {
@@ -969,6 +1063,31 @@  static const struct iso_client_data bcast_enc_16_2_1_recv = {
 	.server = true,
 };
 
+static const struct iso_client_data bcast_ac_12 = {
+	.qos = BCAST_AC_12,
+	.expect_err = 0,
+	.bcast = true,
+	.base = base_lc3_ac_12,
+	.base_len = sizeof(base_lc3_ac_12),
+};
+
+static const struct iso_client_data bcast_ac_13 = {
+	.qos = BCAST_AC_13,
+	.expect_err = 0,
+	.bcast = true,
+	.mconn = true,
+	.base = base_lc3_ac_13,
+	.base_len = sizeof(base_lc3_ac_13),
+};
+
+static const struct iso_client_data bcast_ac_14 = {
+	.qos = BCAST_AC_14,
+	.expect_err = 0,
+	.bcast = true,
+	.base = base_lc3_ac_14,
+	.base_len = sizeof(base_lc3_ac_14),
+};
+
 static void client_connectable_complete(uint16_t opcode, uint8_t status,
 					const void *param, uint8_t len,
 					void *user_data)
@@ -1255,22 +1374,6 @@  static int create_iso_sock(struct test_data *data)
 	return sk;
 }
 
-static const uint8_t base_lc3_16_2_1[] = {
-	0x28, 0x00, 0x00, /* Presentation Delay */
-	0x01, /* Number of Subgroups */
-	0x01, /* Number of BIS */
-	0x06, 0x00, 0x00, 0x00, 0x00, /* Code ID = LC3 (0x06) */
-	0x11, /* Codec Specific Configuration */
-	0x02, 0x01, 0x03, /* 16 KHZ */
-	0x02, 0x02, 0x01, /* 10 ms */
-	0x05, 0x03, 0x01, 0x00, 0x00, 0x00,  /* Front Left */
-	0x03, 0x04, 0x28, 0x00, /* Frame Length 40 bytes */
-	0x04, /* Metadata */
-	0x03, 0x02, 0x02, 0x00, /* Audio Context: Convertional */
-	0x01, /* BIS */
-	0x00, /* Codec Specific Configuration */
-};
-
 static int connect_iso_sock(struct test_data *data, uint8_t num, int sk)
 {
 	const struct iso_client_data *isodata = data->test_data;
@@ -1283,7 +1386,7 @@  static int connect_iso_sock(struct test_data *data, uint8_t num, int sk)
 
 	client = hciemu_get_client(data->hciemu, num);
 	if (!client) {
-		if (!isodata->mcis) {
+		if (!isodata->mconn) {
 			tester_warn("No client");
 			return -ENODEV;
 		}
@@ -1295,7 +1398,7 @@  static int connect_iso_sock(struct test_data *data, uint8_t num, int sk)
 		}
 	}
 
-	if (num && isodata->mcis)
+	if (!isodata->bcast && num && isodata->mconn)
 		qos = &isodata->qos_2;
 
 	if (!isodata->bcast) {
@@ -1304,9 +1407,9 @@  static int connect_iso_sock(struct test_data *data, uint8_t num, int sk)
 			tester_warn("No client bdaddr");
 			return -ENODEV;
 		}
-	} else {
+	} else if (!isodata->server) {
 		err = setsockopt(sk, SOL_BLUETOOTH, BT_ISO_BASE,
-				base_lc3_16_2_1, sizeof(base_lc3_16_2_1));
+				isodata->base, isodata->base_len);
 		if (err < 0) {
 			tester_warn("Can't set socket BT_ISO_BASE option: "
 					"%s (%d)", strerror(errno), errno);
@@ -1323,7 +1426,7 @@  static int connect_iso_sock(struct test_data *data, uint8_t num, int sk)
 		return -EINVAL;
 	}
 
-	if (isodata->defer) {
+	if (isodata->defer || (isodata->bcast && isodata->mconn && !num)) {
 		int opt = 1;
 
 		if (setsockopt(sk, SOL_BLUETOOTH, BT_DEFER_SETUP, &opt,
@@ -1694,7 +1797,7 @@  static gboolean iso_connect(GIOChannel *io, GIOCondition cond,
 
 	if (!isodata->bcast) {
 		ret = check_ucast_qos(&qos, &isodata->qos,
-				      isodata->mcis ? &isodata->qos_2 : NULL);
+				      isodata->mconn ? &isodata->qos_2 : NULL);
 	} else if (!isodata->server)
 		ret = check_bcast_qos(&qos, &isodata->qos);
 
@@ -1879,7 +1982,7 @@  static void test_connect(const void *test_data)
 	func[n++] = iso_connect_cb;
 
 	/* Check if configuration requires multiple CIS setup */
-	if (!isodata->bcast && isodata->mcis)
+	if (!isodata->bcast && isodata->mconn)
 		func[n++] = iso_connect2_cb;
 
 	setup_connect_many(data, n, num, func);
@@ -2179,6 +2282,15 @@  static void test_bcast(const void *test_data)
 	setup_connect(data, 0, iso_connect_cb);
 }
 
+static void test_bcast2(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	uint8_t num[2] = {0, 1};
+	GIOFunc funcs[2] = {iso_connect_cb, iso_connect2_cb};
+
+	setup_connect_many(data, 2, num, funcs);
+}
+
 static void test_bcast_recv(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -2431,5 +2543,14 @@  int main(int argc, char *argv[])
 							setup_powered,
 							test_bcast_recv);
 
+	test_iso("ISO Broadcaster AC 12 - Success", &bcast_ac_12, setup_powered,
+							test_bcast);
+
+	test_iso("ISO Broadcaster AC 13 - Success", &bcast_ac_13, setup_powered,
+							test_bcast2);
+
+	test_iso("ISO Broadcaster AC 14 - Success", &bcast_ac_14, setup_powered,
+							test_bcast);
+
 	return tester_run();
 }