From patchwork Tue Nov 28 15:28:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13471358 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hwzB/1kk" Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DA1CD1 for ; Tue, 28 Nov 2023 07:28:37 -0800 (PST) Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6d80245b6easo2991605a34.0 for ; Tue, 28 Nov 2023 07:28:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701185315; x=1701790115; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=YuZucRIo3c+d//e7GkzsXFLJR0Rgxs24p9QsrDyqCbg=; b=hwzB/1kkMOFzueFyYumllz6bStnftGT4MVSX8EJx7HeWWgElogmzzQOLQRvAz2Pbr7 OvDYPAx2rhD5kiJi+z6KhYAXebflRBmZuHohXTG9TfAA5Mdz5xaGVYsSCMIhOt7WJMEn jha7aTURuARFmDZd/tK5wL+EMAQc5v+rWNYDNwsi6F8T6m3yruAI3QSfRVIS+BIkw1OY 6mQE2kTz5tQ7Fb5vImZ4KmDucvUxzuWv8mUDVrGCxHSrCgdLGkIRdDOCzOQmqug+OeVQ JnNstb+bk+xydcGTBFQ77gsfli9xI+JZZzH238TlIOSY+30OV+9c8NInb2Sh6czfWKBU nw+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701185315; x=1701790115; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YuZucRIo3c+d//e7GkzsXFLJR0Rgxs24p9QsrDyqCbg=; b=Vv4YY/tkmVk0qqkUKs62lDt+mWW8SupeS2Cg0VY21ufsr66MdGYNZD48QzRBfb+g60 sIla+6LY76MbYq1PZVkOz3l6n/OK8akVd8gTfZLlwlxHcHL1QFAr6z0EkUdK4ur4DZQm FQJTVir/LmKXE+9c7G8MN7GXVZbmCRgHWsBRjdh4vGc1yuIpX5CHN9LR1FpBZ64yVw+a ZN1e3z6CJ20FL+SU9x3im09i9tkbTVqz3vTgaScqmsC/5pEXhe06+6r+MH4LfyOBHg0Y uY0JGcvkP7znUt1kKr2CZbTb+lK0qMRHcjbedUgByVF8euTSOVInja/16epg3HVeTdnG rJeg== X-Gm-Message-State: AOJu0YyWODgkuunXRGGD7SxpyOaH1Pa8ywwhlnGeS5BL/2HBqzA9W4T3 p7qM1MJiS1a3+YhejtFmeh3oaRcVZLDMjA== X-Google-Smtp-Source: AGHT+IG+6+uDrkpW3yiMGZkIhj/nP+RUUhUvxWsKk7WPIbjGw3KvvEZZTN0nNUA6r7687fkhRVBgSA== X-Received: by 2002:a05:6358:3107:b0:16b:c53b:4eec with SMTP id c7-20020a056358310700b0016bc53b4eecmr16507714rwe.25.1701185315320; Tue, 28 Nov 2023 07:28:35 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id bf9-20020a056130054900b0079a1018d185sm1660644uab.31.2023.11.28.07.28.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 07:28:33 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 1/3] iso-tester: Add tests for GMAP broadcast QoS presets Date: Tue, 28 Nov 2023 10:28:30 -0500 Message-ID: <20231128152832.1730901-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This adds the following tests: ISO QoS 48_1_g - Success ISO QoS 48_2_g - Success ISO QoS 48_3_g - Success ISO QoS 48_4_g - Success --- tools/iso-tester.c | 133 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 118 insertions(+), 15 deletions(-) diff --git a/tools/iso-tester.c b/tools/iso-tester.c index 4d47373e3290..d1f0be180c33 100644 --- a/tools/iso-tester.c +++ b/tools/iso-tester.c @@ -307,22 +307,81 @@ #define QOS_OUT_1_1_16_2_1 BCAST_QOS_OUT_1_1(10000, 10, 40, 0x02, 2) #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) +#define QOS_OUT_48_1_g BCAST_QOS_OUT(7500, 8, 75, 0x02, 1) +#define QOS_OUT_48_2_g BCAST_QOS_OUT(10000, 10, 100, 0x02, 1) +#define QOS_OUT_48_3_g BCAST_QOS_OUT(7500, 8, 90, 0x02, 1) +#define QOS_OUT_48_4_g BCAST_QOS_OUT(10000, 10, 120, 0x02, 1) -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 */ -}; +#define BASE(_pd, _sgrp, _nbis, _cfg...) \ +{ \ + _pd & 0xff, _pd >> 8, _pd >> 16, \ + _sgrp, \ + _nbis, \ + _cfg \ +} + +#define LC3_BASE(_pd, _sgrp, _nbis, _cc...) \ + BASE(_pd, _sgrp, _nbis, 0x06, 0x00, 0x00, 0x00, 0x00, _cc) + +/* 16 KHZ - 10 ms - Front Left - Frame Length 40 bytes */ +#define LC3_CONFIG_16_2_1 \ + 0x10, \ + 0x02, 0x01, 0x03, \ + 0x02, 0x02, 0x01, \ + 0x05, 0x03, 0x01, 0x00, 0x00, 0x00, \ + 0x03, 0x04, 0x28, 0x00 + +/* Audio Context: Convertional */ +#define CTXT_CONVERSIONAL \ + 0x04, \ + 0x03, 0x02, 0x02, 0x00 + +static const uint8_t base_lc3_16_2_1[] = + LC3_BASE(40000, 1, 1, LC3_CONFIG_16_2_1, CTXT_CONVERSIONAL, + 0x01, /* BIS */ + 0x00 /* Codec Specific Configuration */); + +#define LC3_CONFIG_G(_freq, _dur, _len) \ + 0x0a, \ + 0x02, 0x01, _freq, \ + 0x02, 0x02, _dur, \ + 0x03, 0x04, _len, _len >> 8 + +#define LC3_CONFIG_FRONT_LEFT \ + 0x06, \ + 0x05, 0x03, 0x01, 0x00, 0x00, 0x00 + +/* 48 KHZ - 7.5 ms - Frame Length 75 bytes */ +#define LC3_CONFIG_48_1_G \ + LC3_CONFIG_G(0x08, 0x00, 75) + +static const uint8_t base_lc3_48_1_g[] = + LC3_BASE(10000, 1, 1, LC3_CONFIG_48_1_G, CTXT_CONVERSIONAL, + 0x01, LC3_CONFIG_FRONT_LEFT); + +/* 48 KHZ - 10 ms Frame Length 100 bytes */ +#define LC3_CONFIG_48_2_G \ + LC3_CONFIG_G(0x08, 0x01, 100) + +static const uint8_t base_lc3_48_2_g[] = + LC3_BASE(10000, 1, 1, LC3_CONFIG_48_2_G, CTXT_CONVERSIONAL, + 0x01, LC3_CONFIG_FRONT_LEFT); + +/* 48 KHZ - 7.5 ms Frame Length 90 bytes */ +#define LC3_CONFIG_48_3_G \ + LC3_CONFIG_G(0x08, 0x00, 90) + +static const uint8_t base_lc3_48_3_g[] = + LC3_BASE(10000, 1, 1, LC3_CONFIG_48_3_G, CTXT_CONVERSIONAL, + 0x01, LC3_CONFIG_FRONT_LEFT); + +/* 48 KHZ - 7.5 ms Frame Length 90 bytes */ +#define LC3_CONFIG_48_4_G \ + LC3_CONFIG_G(0x08, 0x00, 120) + +static const uint8_t base_lc3_48_4_g[] = + LC3_BASE(10000, 1, 1, LC3_CONFIG_48_3_G, CTXT_CONVERSIONAL, + 0x01, LC3_CONFIG_FRONT_LEFT); /* Single Audio Channel. One BIS. */ #define BCAST_AC_12 BCAST_QOS_OUT_1_1(10000, 10, 40, 0x02, 2) @@ -1166,6 +1225,38 @@ static const struct iso_client_data connect_ac_1_2_cig_1_2 = { .mconn = true, }; +static const struct iso_client_data bcast_48_1_g = { + .qos = QOS_OUT_48_1_g, + .expect_err = 0, + .bcast = true, + .base = base_lc3_48_1_g, + .base_len = sizeof(base_lc3_48_1_g), +}; + +static const struct iso_client_data bcast_48_2_g = { + .qos = QOS_OUT_48_2_g, + .expect_err = 0, + .bcast = true, + .base = base_lc3_48_2_g, + .base_len = sizeof(base_lc3_48_2_g), +}; + +static const struct iso_client_data bcast_48_3_g = { + .qos = QOS_OUT_48_3_g, + .expect_err = 0, + .bcast = true, + .base = base_lc3_48_3_g, + .base_len = sizeof(base_lc3_48_3_g), +}; + +static const struct iso_client_data bcast_48_4_g = { + .qos = QOS_OUT_48_4_g, + .expect_err = 0, + .bcast = true, + .base = base_lc3_48_4_g, + .base_len = sizeof(base_lc3_48_4_g), +}; + static const struct iso_client_data bcast_16_2_1_send = { .qos = QOS_OUT_16_2_1, .expect_err = 0, @@ -3054,6 +3145,18 @@ int main(int argc, char *argv[]) test_iso("ISO QoS 48_4_gr - Success", &connect_48_4_gr, setup_powered, test_connect); + test_iso("ISO QoS 48_1_g - Success", &bcast_48_1_g, + setup_powered, test_bcast); + + test_iso("ISO QoS 48_2_g - Success", &bcast_48_2_g, + setup_powered, test_bcast); + + test_iso("ISO QoS 48_3_g - Success", &bcast_48_3_g, + setup_powered, test_bcast); + + test_iso("ISO QoS 48_4_g - Success", &bcast_48_4_g, + setup_powered, test_bcast); + test_iso("ISO QoS - Invalid", &connect_invalid, setup_powered, test_connect); From patchwork Tue Nov 28 15:28:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13471359 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DJ4T90Tr" Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 480E410CA for ; Tue, 28 Nov 2023 07:28:39 -0800 (PST) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b2ec9a79bdso3730851b6e.3 for ; Tue, 28 Nov 2023 07:28:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701185317; x=1701790117; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9Zv7hq1AH16bnPc19IonLtbuxJzvavyDhkPsM0yiosw=; b=DJ4T90TrVtQvZiHAN3A1VMCeGhhnxTE8k844T0JRskywFbuROf+Oz3xVutWCIhXdzt TzDOaVRdCNLAeeBddySRXfoxpeEZoost8NbsRFxB8vaEvWpXbQ5fqI5MVJjEbN/wHc5u 6y6DhtxsbuAbW33bVA4mbQjMqUYPAOL460QxJjLyGVMWb1w4pNdsP8aYQ29Mpv8HjzOA /FAhSaly3pSPiI5w9YmJGGHGviu7a3lHSKa4mhGKOKWCqpqXb5sQzA8yNtTl8xGdBh4G 6QDI0XO8LnQHi2Yw/Sh0htBy+rDvO1wPUiBRhYZCm7MWAsVN64bdEjJTUVRzSHrHz+cg IbcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701185317; x=1701790117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Zv7hq1AH16bnPc19IonLtbuxJzvavyDhkPsM0yiosw=; b=sVB82TLOKLJ+zxT6Aa7/pVjuzq59R54p22uS/Ln64eB+1fchuHAUckLlL7pGC4x58/ XolkYOf3XWEqYhgLQzEJ6UUWiYNY2O/n6RpoyEd3aoKJoid+OVYjtxVmrnbwL1h8aDjK wwB3DQcnXbjYZLVFb8+EygAqBRiqFgyTV/mxBxrRCFoRpGNSNAmb9e2AG3+GJ93LgHov Ar7DDzHH40E7ZjuK6Tg1ewJPe/XrEcIRvaJZW+WF79EO5Nou9R2e1jyLFb75OE7WotXo g5itl1a9I3rg4N/T7+flq2tQ4FWi8W36Qs05b0OZV+StUCKUXgPw3gABhERfZwy5EDxR 8akg== X-Gm-Message-State: AOJu0Yx5myIyrXHKxjeUinxEWTBwixkjxdeUUDLuAr8bG0qvZHIGrW1m 2VEnsNp4YXZZtRQJ1QxL9e5NcdlvDV6vfg== X-Google-Smtp-Source: AGHT+IE2nldLYBZyuU4ph72iJ7oxktkjIq+H7i9Tx0MbHZMlB646GbTGMEqUsDUofotvBc6XeyQQvQ== X-Received: by 2002:a05:6358:291e:b0:16d:bc0b:836 with SMTP id y30-20020a056358291e00b0016dbc0b0836mr15681130rwb.19.1701185317153; Tue, 28 Nov 2023 07:28:37 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id bf9-20020a056130054900b0079a1018d185sm1660644uab.31.2023.11.28.07.28.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 07:28:35 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 2/3] util: Make debugger arg of util_debug_ltv const Date: Tue, 28 Nov 2023 10:28:31 -0500 Message-ID: <20231128152832.1730901-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231128152832.1730901-1-luiz.dentz@gmail.com> References: <20231128152832.1730901-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This makes the debugger argument of util_debug_ltv const as they are not suppose to change during its call. --- src/shared/bap-debug.c | 6 +++--- src/shared/util.c | 10 +++++----- src/shared/util.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/shared/bap-debug.c b/src/shared/bap-debug.c index 62bcde969377..495a22c44126 100644 --- a/src/shared/bap-debug.c +++ b/src/shared/bap-debug.c @@ -184,7 +184,7 @@ done: user_data); } -struct util_ltv_debugger pac_cap_table[] = { +static const struct util_ltv_debugger pac_cap_table[] = { UTIL_LTV_DEBUG(0x01, pac_debug_freq), UTIL_LTV_DEBUG(0x02, pac_debug_duration), UTIL_LTV_DEBUG(0x03, pac_debug_channels), @@ -413,7 +413,7 @@ done: user_data); } -struct util_ltv_debugger ase_cc_table[] = { +static const struct util_ltv_debugger ase_cc_table[] = { UTIL_LTV_DEBUG(0x01, ase_debug_freq), UTIL_LTV_DEBUG(0x02, ase_debug_duration), UTIL_LTV_DEBUG(0x03, ase_debug_location), @@ -527,7 +527,7 @@ done: user_data); } -struct util_ltv_debugger ase_metadata_table[] = { +static const struct util_ltv_debugger ase_metadata_table[] = { UTIL_LTV_DEBUG(0x01, ase_debug_preferred_context), UTIL_LTV_DEBUG(0x02, ase_debug_context), UTIL_LTV_DEBUG(0x03, ase_debug_program_info), diff --git a/src/shared/util.c b/src/shared/util.c index cebb02cc3ee4..34491f4e5a56 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -157,8 +157,8 @@ uint64_t util_debug_bit(const char *label, uint64_t val, return mask; } -static struct util_ltv_debugger* -ltv_debugger(struct util_ltv_debugger *debugger, size_t num, uint8_t type) +static const struct util_ltv_debugger* +ltv_debugger(const struct util_ltv_debugger *debugger, size_t num, uint8_t type) { size_t i; @@ -166,7 +166,7 @@ ltv_debugger(struct util_ltv_debugger *debugger, size_t num, uint8_t type) return NULL; for (i = 0; i < num; i++) { - struct util_ltv_debugger *debug = &debugger[i]; + const struct util_ltv_debugger *debug = &debugger[i]; if (debug->type == type) return debug; @@ -177,7 +177,7 @@ ltv_debugger(struct util_ltv_debugger *debugger, size_t num, uint8_t type) /* Helper to print debug information of LTV entries */ bool util_debug_ltv(const uint8_t *data, uint8_t len, - struct util_ltv_debugger *debugger, size_t num, + const struct util_ltv_debugger *debugger, size_t num, util_debug_func_t function, void *user_data) { struct iovec iov; @@ -188,7 +188,7 @@ bool util_debug_ltv(const uint8_t *data, uint8_t len, for (i = 0; iov.iov_len; i++) { uint8_t l, t, *v; - struct util_ltv_debugger *debug; + const struct util_ltv_debugger *debug; if (!util_iov_pull_u8(&iov, &l)) { util_debug(function, user_data, diff --git a/src/shared/util.h b/src/shared/util.h index 44205d7d35d5..6698d00415de 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -135,7 +135,7 @@ struct util_ltv_debugger { }; bool util_debug_ltv(const uint8_t *data, uint8_t len, - struct util_ltv_debugger *debugger, size_t num, + const struct util_ltv_debugger *debugger, size_t num, util_debug_func_t function, void *user_data); unsigned char util_get_dt(const char *parent, const char *name); From patchwork Tue Nov 28 15:28:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13471360 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UluTaLa/" Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2EB710D1 for ; Tue, 28 Nov 2023 07:28:40 -0800 (PST) Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6d7eca548ccso3213745a34.3 for ; Tue, 28 Nov 2023 07:28:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701185319; x=1701790119; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PMRcStEa6a1gBpdv3t70birwXww/qU1B666I/WHu554=; b=UluTaLa/xfRQE/mX0ttJ1aMiT1z1i+t+zl0rtkz409lDkHoKJv4co0Ngw/vv3rBZzt F/ouFOcjCiUeFyMkmVOW7jWmRiKPxupi2ES2AWWROvjCnc/xCOb6rFi3eT2sxTlQuUwi 1f4r2yPPlVhrGVAVvuV+R1HcIoV5XZZXZBLu8wputb3V3lEm+kescFvxbP+RcKacnoAZ tAXyXMniEe5PzqM8gpUwHiMPZcvSpYsMGJJ0TCc+y6O9ZpAfL7R+N6i+gHr8pM7jWMB2 E2Qq+IJXnvG1HDjQBqdcz8Ws+QE4PAnLwYom1RxgHHB49CavElMXP/VlXLe8Klus5PiT h+sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701185319; x=1701790119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PMRcStEa6a1gBpdv3t70birwXww/qU1B666I/WHu554=; b=OZViGswUW7F0nJe1XEa1CnhEwRkwldDvnWpHAHS/zw8CucpCq5pJskUJGqcOHFvxXk KTS+amtWRyg8a+TQ08ZRX3DGgJUZl2suVzu++Se5IpYJ1iMH4KFLp2pxbUh48+bJZPGC JhK7MbIUDSJbRI66VQneTfdmI/aeDRLrFSp9wdXVeDf6xdz2kZnL5r0o2TRWKgmlt70D EsCIg4Cz7T/fssud92QCSzjKkwXwzuYaKS2WgVat3FtO8UTh7wdlpZzv4DbZ6v4RNlhO 9jrPQekFmGm18yqvgRwV7BpeWH/8TLx8DzkAV/j6IjAS7vKS3RIoA273K7hqaRp4HT9H oEPQ== X-Gm-Message-State: AOJu0Yzbt1Cqcn26SBGhN8tIg3mlR8Avp2fExqteIynf3zkdKgo7S0VE j534XdpBhECkOUeLbMODzqYkw9XIwKWQug== X-Google-Smtp-Source: AGHT+IGSrH2TaxydTGLw+KPw88/TqwrYyUYxlJL41FgSfLzdJOJZyvWfn0KcVi5vmHwucDpLGgjUPA== X-Received: by 2002:a05:6358:3423:b0:16b:f6ba:a03a with SMTP id h35-20020a056358342300b0016bf6baa03amr17743244rwd.8.1701185319294; Tue, 28 Nov 2023 07:28:39 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id bf9-20020a056130054900b0079a1018d185sm1660644uab.31.2023.11.28.07.28.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 07:28:37 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 3/3] monitor: Add proper decoding of TLV for BASE Date: Tue, 28 Nov 2023 10:28:32 -0500 Message-ID: <20231128152832.1730901-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231128152832.1730901-1-luiz.dentz@gmail.com> References: <20231128152832.1730901-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This uses bt_bap_debug_{config, metadata} to decode the TLV entries found in Basic Audio Announcement: < HCI Command: LE Set Peri.. (0x08|0x003f) plen 41 Handle: 1 Operation: Complete ext advertising data (0x03) Data length: 0x26 Service Data: Basic Audio Announcement (0x1851) Presetation Delay: 10000 Number of Subgroups: 1 Subgroup #0: Number of BIS(s): 1 Codec: LC3 (0x06) Codec Specific Configuration: #0: len 0x02 type 0x01 Codec Specific Configuration: Sampling Frequency: 48 Khz (0x08) Codec Specific Configuration: #1: len 0x02 type 0x02 Codec Specific Configuration: Frame Duration: 7.5 ms (0x00) Codec Specific Configuration: #2: len 0x03 type 0x04 Codec Specific Configuration: Frame Length: 75 (0x004b) Metadata: #0: len 0x03 type 0x02 Metadata: Context: 0x0002 Metadata: Context Conversational (0x0002) BIS #0: Index: 1 Codec Specific Configuration: #0: len 0x05 type 0x03 Codec Specific Configuration: Location: 0x00000001 Codec Specific Configuration: Location: Front Left (0x00000001) --- monitor/packet.c | 49 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/monitor/packet.c b/monitor/packet.c index 87805be0122a..b06f8a5d3802 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -35,6 +35,7 @@ #include "src/shared/util.h" #include "src/shared/btsnoop.h" #include "src/shared/queue.h" +#include "src/shared/bap-debug.h" #include "display.h" #include "bt.h" #include "ll.h" @@ -3405,20 +3406,6 @@ static void print_uuid128_list(const char *label, const void *data, } } -static void *iov_pull(struct iovec *iov, size_t len) -{ - void *data; - - if (iov->iov_len < len) - return NULL; - - data = iov->iov_base; - iov->iov_base += len; - iov->iov_len -= len; - - return data; -} - static void print_ltv(const char *str, void *user_data) { const char *label = user_data; @@ -3435,7 +3422,7 @@ static void print_base_annoucement(const uint8_t *data, uint8_t data_len) iov.iov_base = (void *) data; iov.iov_len = data_len; - base_data = iov_pull(&iov, sizeof(*base_data)); + base_data = util_iov_pull_mem(&iov, sizeof(*base_data)); if (!base_data) goto done; @@ -3453,7 +3440,7 @@ static void print_base_annoucement(const uint8_t *data, uint8_t data_len) print_field(" Subgroup #%u:", i); - subgroup = iov_pull(&iov, sizeof(*subgroup)); + subgroup = util_iov_pull_mem(&iov, sizeof(*subgroup)); if (!subgroup) goto done; @@ -3470,29 +3457,31 @@ static void print_base_annoucement(const uint8_t *data, uint8_t data_len) subgroup->codec.vid); } - codec_cfg = iov_pull(&iov, sizeof(*codec_cfg)); + codec_cfg = util_iov_pull_mem(&iov, sizeof(*codec_cfg)); if (!codec_cfg) goto done; - if (!iov_pull(&iov, codec_cfg->len)) + if (!util_iov_pull_mem(&iov, codec_cfg->len)) goto done; label = " Codec Specific Configuration"; - util_debug_ltv(codec_cfg->data, codec_cfg->len, NULL, 0, - print_ltv, (void *)label); + bt_bap_debug_config(codec_cfg->data, codec_cfg->len, + print_ltv, (void *)label); - metadata = iov_pull(&iov, sizeof(*metadata)); + metadata = util_iov_pull_mem(&iov, sizeof(*metadata)); if (!metadata) goto done; - if (!iov_pull(&iov, metadata->len)) + if (!util_iov_pull(&iov, metadata->len)) goto done; label = " Metadata"; - util_debug_ltv(metadata->data, metadata->len, NULL, 0, - print_ltv, (void *)label); + bt_bap_debug_metadata(metadata->data, metadata->len, + print_ltv, (void *)label); + + label = " Codec Specific Configuration"; /* Level 3 - BIS(s)*/ for (j = 0; j < subgroup->num_bis; j++) { @@ -3500,21 +3489,21 @@ static void print_base_annoucement(const uint8_t *data, uint8_t data_len) print_field(" BIS #%u:", j); - bis = iov_pull(&iov, sizeof(*bis)); + bis = util_iov_pull_mem(&iov, sizeof(*bis)); if (!bis) goto done; print_field(" Index: %u", bis->index); - codec_cfg = iov_pull(&iov, sizeof(*codec_cfg)); + codec_cfg = util_iov_pull_mem(&iov, sizeof(*codec_cfg)); if (!codec_cfg) goto done; - if (!iov_pull(&iov, codec_cfg->len)) + if (!util_iov_pull(&iov, codec_cfg->len)) goto done; - print_hex_field(" Codec Specific Configuration", - codec_cfg->data, codec_cfg->len); + bt_bap_debug_config(codec_cfg->data, codec_cfg->len, + print_ltv, (void *)label); } } @@ -10443,7 +10432,7 @@ static void num_completed_packets_evt(struct timeval *tv, uint16_t index, const struct bt_hci_evt_num_completed_packets *evt = data; int i; - iov_pull(&iov, 1); + util_iov_pull(&iov, 1); print_field("Num handles: %d", evt->num_handles);