2024-01-30 15:44:29

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ v2 0/4] Update bcast ep register and config props

This patch removes unnecessary input prompts from broadcast ep register.
It also adds support to provide stream config options at broadcast
source endpoint config.

This is useful for a broadcast source supporting multiple streams,
since each stream could require a different config.

In client/player, the input prompts have been updated for broadcast
endpoint register and config: At broadcast ep register, the user will
enter the locally supported stream locations and context types.

At broacast source ep config, the user will provide the BIG that the
new stream will be part of, the stream Channel Allocation, and the
metadata of the subgroup to include the stream. These options will be
used to configure the BASE and the BIG.

Iulia Tanasescu (4):
bap: Parse BIG handle at endpoint config
shared/bap: Set bcast stream metadata
shared/lc3: Add macro for Channel Allocation LTV len
client/player: Update bcast endpoint input prompts

client/player.c | 238 ++++++++++++++++++++++++++++++++++---------
profiles/audio/bap.c | 7 +-
src/shared/bap.c | 20 ++--
src/shared/lc3.h | 4 +-
4 files changed, 213 insertions(+), 56 deletions(-)


base-commit: f59f4902bc4ea0bf5f1fed2b1e5e2f4ed52f0cb5
--
2.39.2



2024-01-30 15:44:33

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ v2 1/4] bap: Parse BIG handle at endpoint config

This adds support to parse the "BIG" key in bcast qos parser, at
endpoint configuration.
---
profiles/audio/bap.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 007e19f21..7faa6be7f 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -4,7 +4,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2022 Intel Corporation. All rights reserved.
- * Copyright 2023 NXP
+ * Copyright 2023-2024 NXP
*
*
*/
@@ -610,6 +610,11 @@ static int setup_parse_bcast_qos(struct bap_setup *setup, const char *key,
return -EINVAL;

dbus_message_iter_get_basic(iter, &qos->bcast.encryption);
+ } else if (!strcasecmp(key, "BIG")) {
+ if (var != DBUS_TYPE_BYTE)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(iter, &qos->bcast.big);
} else if (!strcasecmp(key, "Options")) {
if (var != DBUS_TYPE_BYTE)
return -EINVAL;
--
2.39.2


2024-01-30 15:44:36

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ v2 2/4] shared/bap: Set bcast stream metadata

This updates bt_bap_stream_metadata to handle broadcast streams,
by setting stream medatada.
---
src/shared/bap.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 06cac5bb3..851d6a5fa 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -4,7 +4,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2022 Intel Corporation. All rights reserved.
- * Copyright 2023 NXP
+ * Copyright 2023-2024 NXP
*
*/

@@ -5114,13 +5114,21 @@ unsigned int bt_bap_stream_metadata(struct bt_bap_stream *stream,
if (!stream)
return 0;

- if (!stream->client) {
- stream_metadata(stream, metadata, NULL);
+ switch (bt_bap_stream_get_type(stream)) {
+ case BT_BAP_STREAM_TYPE_UCAST:
+ if (!stream->client) {
+ stream_metadata(stream, metadata, NULL);
+ return 0;
+ }
+ return bap_stream_metadata(stream, BT_ASCS_METADATA,
+ metadata, func, user_data);
+ case BT_BAP_STREAM_TYPE_BCAST:
+ util_iov_free(stream->meta, 1);
+ stream->meta = util_iov_dup(metadata, 1);
+ return 1;
+ default:
return 0;
}
-
- return bap_stream_metadata(stream, BT_ASCS_METADATA, metadata, func,
- user_data);
}

unsigned int bt_bap_stream_release(struct bt_bap_stream *stream,
--
2.39.2


2024-01-30 15:44:40

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ v2 3/4] shared/lc3: Add macro for Channel Allocation LTV len

This adds a macro for the Audio_Channel_Allocation LTV len.
---
src/shared/lc3.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/shared/lc3.h b/src/shared/lc3.h
index e6b043699..4ca3c6898 100644
--- a/src/shared/lc3.h
+++ b/src/shared/lc3.h
@@ -4,6 +4,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2022 Intel Corporation. All rights reserved.
+ * Copyright 2024 NXP
*
*/

@@ -75,7 +76,8 @@
#define LC3_CONFIG_DURATION_7_5 0x00
#define LC3_CONFIG_DURATION_10 0x01

-#define LC3_CONFIG_CHAN_ALLOC (LC3_CONFIG_BASE + 2)
+#define LC3_CONFIG_CHAN_ALLOC (LC3_CONFIG_BASE + 2)
+#define LC3_CONFIG_CHAN_ALLOC_LEN 0x05

#define LC3_CONFIG_FRAME_LEN (LC3_CONFIG_BASE + 3)

--
2.39.2


2024-01-30 15:44:44

by Iulia Tanasescu

[permalink] [raw]
Subject: [PATCH BlueZ v2 4/4] client/player: Update bcast endpoint input prompts

This updates the input prompts for broadcast endpoint register and
config.

To register a broadcast endpoint, the user will be asked to enter
the supported stream locations and context types.

At broadcast source endpoint config, the user will provide stream
config options: The BIG that the new stream will be part of, the
stream Channel Allocation, and the metadata of the subgroup to
include the stream. These options will be used to configure the
BASE and the BIG.

The flow to create a Broadcast Source is the following:

[bluetooth]# endpoint.register 00001852-0000-1000-8000-
00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): a
[/local/endpoint/ep0] Locations: 3
[/local/endpoint/ep0] Supported Context (value): 15
[NEW] Endpoint /org/bluez/hci0/pac_bcast0
Endpoint /local/endpoint/ep0 registered

[bluetooth]# endpoint.config /org/bluez/hci0/pac_bcast0
/local/endpoint/ep0 16_2_1
[/local/endpoint/ep0] BIG (auto/value): 1
[/local/endpoint/ep0] Enter channel location (value/no): 3
[/local/endpoint/ep0] Enter Metadata (value/no): 0x03 0x02
0x04 0x00

To create a Broadcast Sink, enter the following:

[bluetooth]# endpoint.register 00001851-0000-1000-8000-
00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): a
[/local/endpoint/ep0] Locations: 3
[/local/endpoint/ep0] Supported Context (value): 15

[bluetooth]# scan on
[NEW] Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/
pac_bcast0

[bluetooth]# endpoint.config
/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0
/local/endpoint/ep0 16_2_1
---
client/player.c | 238 ++++++++++++++++++++++++++++++++++++++----------
1 file changed, 190 insertions(+), 48 deletions(-)

diff --git a/client/player.c b/client/player.c
index 623519209..620420cd6 100644
--- a/client/player.c
+++ b/client/player.c
@@ -4,7 +4,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2020 Intel Corporation. All rights reserved.
- * Copyright 2023 NXP
+ * Copyright 2023-2024 NXP
*
*
*/
@@ -3259,12 +3259,8 @@ static void endpoint_iso_group(const char *input, void *user_data)
ep->iso_group = value;
}

- if (!ep->broadcast)
- bt_shell_prompt_input(ep->path, "CIS (auto/value):",
- endpoint_iso_stream, ep);
- else
- bt_shell_prompt_input(ep->path, "BIS (auto/value):",
- endpoint_iso_stream, ep);
+ bt_shell_prompt_input(ep->path, "CIS (auto/value):",
+ endpoint_iso_stream, ep);
}

static void endpoint_context(const char *input, void *user_data)
@@ -3282,12 +3278,8 @@ static void endpoint_context(const char *input, void *user_data)

ep->context = value;

- if (ep->broadcast)
- bt_shell_prompt_input(ep->path, "BIG (auto/value):",
- endpoint_iso_group, ep);
- else
- bt_shell_prompt_input(ep->path, "CIG (auto/value):",
- endpoint_iso_group, ep);
+ bt_shell_prompt_input(ep->path, "CIG (auto/value):",
+ endpoint_iso_group, ep);
}

static void endpoint_supported_context(const char *input, void *user_data)
@@ -3305,6 +3297,11 @@ static void endpoint_supported_context(const char *input, void *user_data)

ep->supported_context = value;

+ if (ep->broadcast) {
+ endpoint_register(ep);
+ return;
+ }
+
bt_shell_prompt_input(ep->path, "Context (value):", endpoint_context,
ep);
}
@@ -3354,13 +3351,6 @@ static void endpoint_auto_accept(const char *input, void *user_data)
{
struct endpoint *ep = user_data;

- if (!strcmp(ep->uuid, BCAA_SERVICE_UUID) ||
- !strcmp(ep->uuid, BAA_SERVICE_UUID)) {
- ep->broadcast = true;
- } else {
- ep->broadcast = false;
- }
-
if (!strcasecmp(input, "y") || !strcasecmp(input, "yes")) {
ep->auto_accept = true;
bt_shell_prompt_input(ep->path, "Max Transports (auto/value):",
@@ -3478,6 +3468,13 @@ static void cmd_register_endpoint(int argc, char *argv[])
g_list_length(local_endpoints));
local_endpoints = g_list_append(local_endpoints, ep);

+ if (!strcmp(ep->uuid, BCAA_SERVICE_UUID) ||
+ !strcmp(ep->uuid, BAA_SERVICE_UUID)) {
+ ep->broadcast = true;
+ } else {
+ ep->broadcast = false;
+ }
+
if (strrchr(argv[2], ':')) {
ep->codec = 0xff;
parse_vendor_codec(argv[2], &ep->cid, &ep->vid);
@@ -3626,6 +3623,147 @@ static void endpoint_config(const char *input, void *user_data)

static struct endpoint *endpoint_new(const struct capabilities *cap);

+static void endpoint_set_metadata_cfg(const char *input, void *user_data)
+{
+ struct endpoint_config *cfg = user_data;
+
+ if (!strcasecmp(input, "n") || !strcasecmp(input, "no"))
+ goto done;
+
+ if (!cfg->meta)
+ cfg->meta = g_new0(struct iovec, 1);
+
+ cfg->meta->iov_base = str2bytearray((char *) input,
+ &cfg->meta->iov_len);
+ if (!cfg->meta->iov_base) {
+ free(cfg->meta);
+ cfg->meta = NULL;
+ }
+
+done:
+ endpoint_set_config(cfg);
+}
+
+static struct iovec *iov_append_ltv(struct iovec **iov, uint8_t l,
+ uint8_t t, void *v)
+{
+ if (!*iov)
+ *iov = new0(struct iovec, 1);
+
+ if (!((*iov)->iov_base))
+ (*iov)->iov_base = new0(uint8_t, l + 1);
+
+ util_iov_push_u8(*iov, l);
+ util_iov_push_u8(*iov, t);
+ util_iov_push_mem(*iov, l - 1, v);
+
+ return *iov;
+}
+
+static void config_endpoint_channel_location(const char *input, void *user_data)
+{
+ struct endpoint_config *cfg = user_data;
+ char *endptr = NULL;
+ uint32_t location;
+
+ if (!strcasecmp(input, "n") || !strcasecmp(input, "no"))
+ goto add_meta;
+
+ location = strtol(input, &endptr, 0);
+
+ if (!endptr || *endptr != '\0') {
+ bt_shell_printf("Invalid argument: %s\n", input);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ /* Add Channel Allocation LTV in capabilities */
+ location = cpu_to_le32(location);
+ iov_append_ltv(&cfg->caps, LC3_CONFIG_CHAN_ALLOC_LEN,
+ LC3_CONFIG_CHAN_ALLOC, &location);
+
+add_meta:
+ /* Add metadata */
+ bt_shell_prompt_input(cfg->ep->path, "Enter Metadata (value/no):",
+ endpoint_set_metadata_cfg, cfg);
+}
+
+static void ltv_find(size_t i, uint8_t l, uint8_t t, uint8_t *v,
+ void *user_data)
+{
+ bool *found = user_data;
+
+ *found = true;
+}
+
+static void config_endpoint_iso_group(const char *input, void *user_data)
+{
+ struct endpoint_config *cfg = user_data;
+ char *endptr = NULL;
+ int value;
+ uint8_t type = LC3_CONFIG_CHAN_ALLOC;
+ bool found = false;
+
+ if (!strcasecmp(input, "a") || !strcasecmp(input, "auto")) {
+ cfg->ep->iso_group = BT_ISO_QOS_GROUP_UNSET;
+ } else {
+ value = strtol(input, &endptr, 0);
+
+ if (!endptr || *endptr != '\0' || value > UINT8_MAX) {
+ bt_shell_printf("Invalid argument: %s\n", input);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ cfg->ep->iso_group = value;
+ }
+
+ /* Check if Channel Allocation is present in caps */
+ util_ltv_foreach(cfg->caps->iov_base,
+ cfg->caps->iov_len, &type,
+ ltv_find, &found);
+
+ /* Add Channel Allocation if it is not present in caps */
+ if (!found) {
+ bt_shell_prompt_input(cfg->ep->path,
+ "Enter channel location (value/no):",
+ config_endpoint_channel_location, cfg);
+ } else {
+ /* Add metadata */
+ bt_shell_prompt_input(cfg->ep->path,
+ "Enter Metadata (value/no):",
+ endpoint_set_metadata_cfg, cfg);
+ }
+}
+
+static void endpoint_set_config_bcast(struct endpoint_config *cfg)
+{
+ cfg->ep->bcode = g_new0(struct iovec, 1);
+ iov_append(&cfg->ep->bcode, bcast_code,
+ sizeof(bcast_code));
+
+ /* Add periodic advertisement parameters */
+ cfg->sync_factor = BCAST_SYNC_FACTOR;
+ cfg->options = BCAST_OPTIONS;
+ cfg->skip = BCAST_SKIP;
+ cfg->sync_timeout = BCAST_SYNC_TIMEOUT;
+ cfg->sync_cte_type = BCAST_SYNC_CTE_TYPE;
+
+ /* Add BIG create sync parameters */
+ cfg->mse = BCAST_MSE;
+ cfg->timeout = BCAST_TIMEOUT;
+
+ if ((strcmp(cfg->ep->uuid, BAA_SERVICE_UUID) == 0)) {
+ /* A broadcast sink endpoint config does not need
+ * user input.
+ */
+ endpoint_set_config(cfg);
+ return;
+ }
+
+ bt_shell_prompt_input(cfg->ep->path,
+ "BIG (auto/value):",
+ config_endpoint_iso_group, cfg);
+}
+
static void cmd_config_endpoint(int argc, char *argv[])
{
struct endpoint_config *cfg;
@@ -3662,24 +3800,11 @@ static void cmd_config_endpoint(int argc, char *argv[])
/* Set QoS parameters */
cfg->qos = preset->qos;

- if (cfg->ep->broadcast) {
- cfg->ep->bcode = g_new0(struct iovec, 1);
- iov_append(&cfg->ep->bcode, bcast_code,
- sizeof(bcast_code));
-
- /* Add periodic advertisement parameters */
- cfg->sync_factor = BCAST_SYNC_FACTOR;
- cfg->options = BCAST_OPTIONS;
- cfg->skip = BCAST_SKIP;
- cfg->sync_timeout = BCAST_SYNC_TIMEOUT;
- cfg->sync_cte_type = BCAST_SYNC_CTE_TYPE;
- /* Add BIG create sync parameters */
- cfg->mse = BCAST_MSE;
- cfg->timeout = BCAST_TIMEOUT;
-
- endpoint_set_config(cfg);
- } else
+ if (cfg->ep->broadcast)
+ endpoint_set_config_bcast(cfg);
+ else
endpoint_set_config(cfg);
+
return;
}

@@ -4090,6 +4215,30 @@ static const struct bt_shell_menu endpoint_menu = {
{} },
};

+static void endpoint_init_bcast(struct endpoint *ep)
+{
+ if (!strcmp(ep->uuid, BAA_SERVICE_UUID)) {
+ ep->locations = EP_SNK_LOCATIONS;
+ ep->supported_context = EP_SUPPORTED_SNK_CTXT;
+ } else {
+ ep->locations = EP_SRC_LOCATIONS;
+ ep->supported_context = EP_SUPPORTED_SRC_CTXT;
+ }
+}
+
+static void endpoint_init_ucast(struct endpoint *ep)
+{
+ if (!strcmp(ep->uuid, PAC_SINK_UUID)) {
+ ep->locations = EP_SNK_LOCATIONS;
+ ep->supported_context = EP_SUPPORTED_SNK_CTXT;
+ ep->context = EP_SNK_CTXT;
+ } else if (!strcmp(ep->uuid, PAC_SOURCE_UUID)) {
+ ep->locations = EP_SRC_LOCATIONS;
+ ep->supported_context = EP_SUPPORTED_SRC_CTXT;
+ ep->context = EP_SRC_CTXT;
+ }
+}
+
static void endpoint_init_defaults(struct endpoint *ep)
{
ep->preset = find_presets(ep->uuid, ep->codec, ep->vid, ep->cid);
@@ -4105,18 +4254,11 @@ static void endpoint_init_defaults(struct endpoint *ep)

ep->broadcast = (strcmp(ep->uuid, BCAA_SERVICE_UUID) &&
strcmp(ep->uuid, BAA_SERVICE_UUID)) ? false : true;
- if (ep->broadcast)
- return;

- if (!strcmp(ep->uuid, PAC_SINK_UUID)) {
- ep->locations = EP_SNK_LOCATIONS;
- ep->supported_context = EP_SUPPORTED_SNK_CTXT;
- ep->context = EP_SNK_CTXT;
- } else if (!strcmp(ep->uuid, PAC_SOURCE_UUID)) {
- ep->locations = EP_SRC_LOCATIONS;
- ep->supported_context = EP_SUPPORTED_SRC_CTXT;
- ep->context = EP_SRC_CTXT;
- }
+ if (ep->broadcast)
+ endpoint_init_bcast(ep);
+ else
+ endpoint_init_ucast(ep);
}

static struct endpoint *endpoint_new(const struct capabilities *cap)
--
2.39.2


2024-01-30 17:48:39

by bluez.test.bot

[permalink] [raw]
Subject: RE: Update bcast ep register and config props

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=821345

---Test result---

Test Summary:
CheckPatch PASS 2.26 seconds
GitLint PASS 1.11 seconds
BuildEll PASS 24.40 seconds
BluezMake PASS 770.42 seconds
MakeCheck PASS 12.05 seconds
MakeDistcheck PASS 168.67 seconds
CheckValgrind PASS 232.61 seconds
CheckSmatch PASS 336.84 seconds
bluezmakeextell PASS 109.69 seconds
IncrementalBuild PASS 2852.15 seconds
ScanBuild PASS 981.67 seconds



---
Regards,
Linux Bluetooth

2024-01-30 18:40:36

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 0/4] Update bcast ep register and config props

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Tue, 30 Jan 2024 17:44:08 +0200 you wrote:
> This patch removes unnecessary input prompts from broadcast ep register.
> It also adds support to provide stream config options at broadcast
> source endpoint config.
>
> This is useful for a broadcast source supporting multiple streams,
> since each stream could require a different config.
>
> [...]

Here is the summary with links:
- [BlueZ,v2,1/4] bap: Parse BIG handle at endpoint config
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2aecc09ada8b
- [BlueZ,v2,2/4] shared/bap: Set bcast stream metadata
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5c90ef8d8247
- [BlueZ,v2,3/4] shared/lc3: Add macro for Channel Allocation LTV len
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=711814570bad
- [BlueZ,v2,4/4] client/player: Update bcast endpoint input prompts
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a692cc44dc87

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html