Linux bluetooth development
 help / color / mirror / Atom feed
From: Yang Li via B4 Relay <devnull+yang.li.amlogic.com@kernel.org>
To: Linux Bluetooth <linux-bluetooth@vger.kernel.org>
Cc: Yang Li <yang.li@amlogic.com>
Subject: [PATCH BlueZ bluez v3] bap: Start BIG sync after receiving BIGInfo
Date: Tue, 28 Jul 2026 14:24:45 +0800	[thread overview]
Message-ID: <20260728-big_sync-v3-1-6751ba0802ce@amlogic.com> (raw)

From: Yang Li <yang.li@amlogic.com>

The current implementation starts BIG sync before receiving a BIGInfo
report. According to the Bluetooth Core Specification, BIG sync should
only be initiated after BIGInfo has been received.

Starting BIG sync too early may cause unexpected controller behavior.

Trigger BIG sync from the BIGInfo callback, following the same approach
used by the short PA flow.

Fixes: https://github.com/bluez/bluez/issues/2345

Signed-off-by: Yang Li <yang.li@amlogic.com>
---
Changes in v3:
- Fixed coding style warning.
- Link to v2: https://patch.msgid.link/20260727-big_sync-v2-1-053fd3bcc3be@amlogic.com

Changes in v2:
- Fixed build error.
- Link to v1: https://patch.msgid.link/20260724-big_sync-v1-1-0a35013e30ba@amlogic.com
---
 profiles/audio/bap.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index dd4b3c8ff..473e4cfc2 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -3650,7 +3650,8 @@ static void setup_refresh_qos(void *data, void *user_data)
 	setup->qos = *bt_bap_stream_get_qos(stream);
 }
 
-static void iso_do_big_sync(GIOChannel *io, void *user_data)
+static gboolean iso_do_big_sync(GIOChannel *io, GIOCondition cond,
+						void *user_data)
 {
 	GError *err = NULL;
 	struct bap_setup *setup = user_data;
@@ -3659,7 +3660,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)
 	struct bt_iso_qos qos;
 	struct queue *links = bt_bap_stream_io_get_links(setup->stream);
 
-	DBG("PA Sync done");
+	DBG("BIG info received, do BIG sync");
 
 	g_io_channel_unref(data->listen_io);
 	g_io_channel_shutdown(data->listen_io, TRUE, NULL);
@@ -3682,6 +3683,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)
 			BT_IO_OPT_INVALID)) {
 		error("bt_io_set: %s", err->message);
 		g_error_free(err);
+		return FALSE;
 	}
 
 	if (!bt_io_bcast_accept(io,
@@ -3692,16 +3694,31 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)
 			iso_bc_addr.bc_bis, BT_IO_OPT_INVALID)) {
 		error("bt_io_bcast_accept: %s", err->message);
 		g_error_free(err);
+		return FALSE;
 	}
+
+	return TRUE;
+}
+
+static void long_pa_sync_confirm_cb(GIOChannel *io, void *user_data)
+{
+	struct bap_setup *setup = user_data;
+	struct bap_data *data = setup->data;
+
+	DBG("Long PA Sync done");
+
+	/* store io and add watch that will call iso_do_big_sync */
+	data->io_id = g_io_add_watch(io, G_IO_OUT, iso_do_big_sync,
+							setup);
 }
 
 static void pa_and_big_sync(struct bap_setup *setup)
 {
 	GError *err = NULL;
 	struct bap_data *bap_data = setup->data;
-
 	DBG("Create PA sync with this source");
-	bap_data->listen_io = bt_io_listen(NULL, iso_do_big_sync, setup,
+
+	bap_data->listen_io = bt_io_listen(NULL, long_pa_sync_confirm_cb, setup,
 			NULL, &err,
 			BT_IO_OPT_SOURCE_BDADDR,
 			btd_adapter_get_address(bap_data->adapter),

---
base-commit: 89d477bb5494eef0b24e5667be62f854da250a97
change-id: 20260724-big_sync-45c24ec09121

Best regards,
-- 
Yang Li <yang.li@amlogic.com>



             reply	other threads:[~2026-07-28  6:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  6:24 Yang Li via B4 Relay [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-07-28  6:26 [PATCH BlueZ bluez v3] bap: Start BIG sync after receiving BIGInfo Yang Li via B4 Relay
2026-07-28 14:50 ` patchwork-bot+bluetooth
2026-07-28 16:01 ` Bastien Nocera

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=20260728-big_sync-v3-1-6751ba0802ce@amlogic.com \
    --to=devnull+yang.li.amlogic.com@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=yang.li@amlogic.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox