All of lore.kernel.org
 help / color / mirror / Atom feed
From: Iulia Tanasescu <iulia.tanasescu@nxp.com>
To: linux-bluetooth@vger.kernel.org
Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com,
	andrei.istodorescu@nxp.com, luiz.dentz@gmail.com,
	Iulia Tanasescu <iulia.tanasescu@nxp.com>
Subject: [PATCH BlueZ 2/3] client/player: Make QoS sync_factor configurable
Date: Fri, 13 Dec 2024 13:31:12 +0200	[thread overview]
Message-ID: <20241213113113.64818-3-iulia.tanasescu@nxp.com> (raw)
In-Reply-To: <20241213113113.64818-1-iulia.tanasescu@nxp.com>

This adds a new user input prompt when configuring a Broadcast Source
endpoint, to configure a QoS sync_factor value. This is useful for the
user to adjust how frequent PA announcements should be sent by the
Source, depending on scenario, instead of always using a hardcoded
value.

[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 sync factor (value/auto): 2
[/local/endpoint/ep0] Enter channel location (value/no): 1
[/local/endpoint/ep0] Enter Metadata (value/no): no

The PA interval is chosen as the BIG SDU interval multiplied by
sync_factor:

< HCI Command: LE Set Periodic Advertising Parameters (0x08|0x003e)
        Handle: 1
        Min interval: 20.00 msec (0x0010)
        Max interval: 20.00 msec (0x0010)
        Properties: 0x0000
> HCI Event: Command Complete (0x0e)
      LE Set Periodic Advertising Parameters (0x08|0x003e)
        Status: Success (0x00)

< HCI Command: LE Create Broadcast Isochronous Group (0x08|0x0068)
        Handle: 0x01
        Advertising Handle: 0x01
        Number of BIS: 1
        SDU Interval: 10000 us (0x002710)
        Maximum SDU size: 40
        Maximum Latency: 10 ms (0x000a)
        RTN: 0x02
        PHY: LE 2M (0x02)
        Packing: Sequential (0x00)
        Framing: Unframed (0x00)
        Encryption: 0x00
        Broadcast Code[16]: 0102680553f1415aa265bbafc6ea03b8
> HCI Event: Command Status (0x0f)
      LE Create Broadcast Isochronous Group (0x08|0x0068)
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e)
      LE Broadcast Isochronous Group Complete (0x1b)
        Status: Success (0x00)
        Handle: 0x01
        BIG Synchronization Delay: 912 us (0x000390)
        Transport Latency: 912 us (0x000390)
        PHY: LE 2M (0x02)
        NSE: 3
        BN: 1
        PTO: 0
        IRC: 3
        Maximum PDU: 40
        ISO Interval: 10.00 msec (0x0008)
        Connection Handle #0: 6

This also updates the broadcast-source.bt script, to include a new
input value for sync_factor.
---
 client/player.c                    | 30 +++++++++++++++++++++++++++---
 client/scripts/broadcast-source.bt |  1 +
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/client/player.c b/client/player.c
index eed8d2306..f93c9d908 100644
--- a/client/player.c
+++ b/client/player.c
@@ -3724,7 +3724,7 @@ add_meta:
 			endpoint_set_metadata_cfg, cfg);
 }
 
-static void config_endpoint_iso_group(const char *input, void *user_data)
+static void config_endpoint_sync_factor(const char *input, void *user_data)
 {
 	struct endpoint_config *cfg = user_data;
 	char *endptr = NULL;
@@ -3733,7 +3733,7 @@ static void config_endpoint_iso_group(const char *input, void *user_data)
 	bool found = false;
 
 	if (!strcasecmp(input, "a") || !strcasecmp(input, "auto")) {
-		cfg->ep->iso_group = BT_ISO_QOS_GROUP_UNSET;
+		cfg->qos.bcast.sync_factor = BT_ISO_SYNC_FACTOR;
 	} else {
 		value = strtol(input, &endptr, 0);
 
@@ -3742,7 +3742,7 @@ static void config_endpoint_iso_group(const char *input, void *user_data)
 			return bt_shell_noninteractive_quit(EXIT_FAILURE);
 		}
 
-		cfg->ep->iso_group = value;
+		cfg->qos.bcast.sync_factor = value;
 	}
 
 	/* Check if Channel Allocation is present in caps */
@@ -3763,6 +3763,30 @@ static void config_endpoint_iso_group(const char *input, void *user_data)
 	}
 }
 
+static void config_endpoint_iso_group(const char *input, void *user_data)
+{
+	struct endpoint_config *cfg = user_data;
+	char *endptr = NULL;
+	int value;
+
+	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;
+	}
+
+	bt_shell_prompt_input(cfg->ep->path,
+			"Enter sync factor (value/auto):",
+			config_endpoint_sync_factor, cfg);
+}
+
 static void endpoint_set_config_bcast(struct endpoint_config *cfg)
 {
 	cfg->ep->bcode = g_new0(struct iovec, 1);
diff --git a/client/scripts/broadcast-source.bt b/client/scripts/broadcast-source.bt
index 6da9e23e2..1b918efb0 100644
--- a/client/scripts/broadcast-source.bt
+++ b/client/scripts/broadcast-source.bt
@@ -6,6 +6,7 @@ a
 4
 endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 16_2_1
 1
+a
 3
 0x03 0x02 0x04 0x00
 transport.acquire /org/bluez/hci0/pac_bcast0/fd0
\ No newline at end of file
-- 
2.43.0


  parent reply	other threads:[~2024-12-13 11:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13 11:31 [PATCH BlueZ 0/3] client/player: Make QoS sync_factor configurable Iulia Tanasescu
2024-12-13 11:31 ` [PATCH BlueZ 1/3] lib: Add BT_ISO_SYNC_FACTOR Iulia Tanasescu
2024-12-13 12:35   ` client/player: Make QoS sync_factor configurable bluez.test.bot
2024-12-13 11:31 ` Iulia Tanasescu [this message]
2024-12-13 11:31 ` [PATCH BlueZ 3/3] bap: Do not allow BIS QoS mismatch Iulia Tanasescu
2024-12-16 21:50 ` [PATCH BlueZ 0/3] client/player: Make QoS sync_factor configurable patchwork-bot+bluetooth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241213113113.64818-3-iulia.tanasescu@nxp.com \
    --to=iulia.tanasescu@nxp.com \
    --cc=andrei.istodorescu@nxp.com \
    --cc=claudia.rosu@nxp.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=mihai-octavian.urzica@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.