From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 09/13] shared/bap: Add callback broadcast instances
Date: Thu, 9 Oct 2025 17:29:27 -0400 [thread overview]
Message-ID: <20251009212931.445719-9-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20251009212931.445719-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes bt_bap_register have a dedicated callback for broadcast
instances and also fixes bt_bap_stream_io_get_qos to handle broadcast
streams.
---
profiles/audio/bap.c | 2 +-
profiles/audio/bass.c | 2 +-
src/shared/bap.c | 59 ++++++++++++++++++++++++++++++++++++++++---
src/shared/bap.h | 4 +--
unit/test-bap.c | 2 +-
5 files changed, 60 insertions(+), 9 deletions(-)
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 2994881ccc1d..b2711359952b 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -3897,7 +3897,7 @@ static int bap_init(void)
if (err)
return err;
- bap_id = bt_bap_register(bap_attached, bap_detached, NULL);
+ bap_id = bt_bap_register(bap_attached, NULL, bap_detached, NULL);
return 0;
}
diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c
index 537c9206a71c..ee1257702638 100644
--- a/profiles/audio/bass.c
+++ b/profiles/audio/bass.c
@@ -1815,7 +1815,7 @@ static int bass_init(void)
return err;
bass_id = bt_bass_register(bass_attached, bass_detached, NULL);
- bap_id = bt_bap_register(bap_attached, bap_detached, NULL);
+ bap_id = bt_bap_register(bap_attached, NULL, bap_detached, NULL);
return 0;
}
diff --git a/src/shared/bap.c b/src/shared/bap.c
index 9b7395223c67..2b99b23488fa 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -98,6 +98,7 @@ struct bt_bap_bcode_cb {
struct bt_bap_cb {
unsigned int id;
bt_bap_func_t attached;
+ bt_bap_func_t bc_attached;
bt_bap_func_t detached;
void *user_data;
};
@@ -4524,13 +4525,13 @@ static void bap_free(void *data)
free(bap);
}
-unsigned int bt_bap_register(bt_bap_func_t attached, bt_bap_func_t detached,
- void *user_data)
+unsigned int bt_bap_register(bt_bap_func_t attached, bt_bap_func_t bc_attached,
+ bt_bap_func_t detached, void *user_data)
{
struct bt_bap_cb *cb;
static unsigned int id;
- if (!attached && !detached)
+ if (!attached && !bc_attached && !detached)
return 0;
if (!bap_cbs)
@@ -4539,6 +4540,7 @@ unsigned int bt_bap_register(bt_bap_func_t attached, bt_bap_func_t detached,
cb = new0(struct bt_bap_cb, 1);
cb->id = ++id ? id : ++id;
cb->attached = attached;
+ cb->bc_attached = bc_attached;
cb->detached = detached;
cb->user_data = user_data;
@@ -5643,6 +5645,17 @@ clone:
return true;
}
+static void bap_bc_attached(void *data, void *user_data)
+{
+ struct bt_bap_cb *cb = data;
+ struct bt_bap *bap = user_data;
+
+ if (!cb->bc_attached)
+ return;
+
+ cb->bc_attached(bap, cb->user_data);
+}
+
bool bt_bap_attach_broadcast(struct bt_bap *bap)
{
struct bt_bap_endpoint *ep;
@@ -5655,6 +5668,8 @@ bool bt_bap_attach_broadcast(struct bt_bap *bap)
queue_push_tail(sessions, bap);
+ queue_foreach(bap_cbs, bap_bc_attached, bap);
+
ep = bap_get_endpoint_bcast(bap->remote_eps, bap->ldb,
BT_BAP_BCAST_SOURCE);
if (ep)
@@ -6769,6 +6784,36 @@ static void bap_stream_get_out_qos(void *data, void *user_data)
*qos = &stream->qos;
}
+static void bap_stream_bcast_get_out_qos(void *data, void *user_data)
+{
+ struct bt_bap_stream *stream = data;
+ struct bt_bap_qos **qos = user_data;
+
+ if (!stream)
+ return;
+
+ if (!qos || *qos || stream->ep->dir != BT_BAP_BCAST_SINK ||
+ !stream->qos.bcast.io_qos.sdu)
+ return;
+
+ *qos = &stream->qos;
+}
+
+static void bap_stream_bcast_get_in_qos(void *data, void *user_data)
+{
+ struct bt_bap_stream *stream = data;
+ struct bt_bap_qos **qos = user_data;
+
+ if (!stream)
+ return;
+
+ if (!qos || *qos || stream->ep->dir != BT_BAP_BCAST_SOURCE ||
+ !stream->qos.bcast.io_qos.sdu)
+ return;
+
+ *qos = &stream->qos;
+}
+
bool bt_bap_stream_io_get_qos(struct bt_bap_stream *stream,
struct bt_bap_qos **in,
struct bt_bap_qos **out)
@@ -6785,13 +6830,19 @@ bool bt_bap_stream_io_get_qos(struct bt_bap_stream *stream,
bap_stream_get_out_qos(stream, out);
queue_foreach(stream->links, bap_stream_get_in_qos, in);
break;
+ case BT_BAP_BCAST_SOURCE:
+ bap_stream_bcast_get_in_qos(stream, in);
+ break;
+ case BT_BAP_BCAST_SINK:
+ bap_stream_bcast_get_out_qos(stream, out);
+ break;
default:
return false;
}
DBG(stream->bap, "in %p out %p", in ? *in : NULL, out ? *out : NULL);
- return in && out;
+ return (in && *in) || (out && *out);
}
static void bap_stream_get_dir(void *data, void *user_data)
diff --git a/src/shared/bap.h b/src/shared/bap.h
index fba8b6b17884..bf166d439935 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -116,8 +116,8 @@ uint8_t bt_bap_stream_get_type(struct bt_bap_stream *stream);
struct bt_bap_stream *bt_bap_pac_get_stream(struct bt_bap_pac *pac);
/* Session related function */
-unsigned int bt_bap_register(bt_bap_func_t added, bt_bap_func_t removed,
- void *user_data);
+unsigned int bt_bap_register(bt_bap_func_t attached, bt_bap_func_t bc_attached,
+ bt_bap_func_t detached, void *user_data);
bool bt_bap_unregister(unsigned int id);
struct bt_bap *bt_bap_new(struct gatt_db *ldb, struct gatt_db *rdb);
diff --git a/unit/test-bap.c b/unit/test-bap.c
index c15afe52dbbc..d07652f6ca44 100644
--- a/unit/test-bap.c
+++ b/unit/test-bap.c
@@ -1184,7 +1184,7 @@ static void test_server(const void *user_data)
tester_io_set_complete_func(test_complete_cb);
- data->id = bt_bap_register(bap_attached, NULL, data);
+ data->id = bt_bap_register(bap_attached, NULL, NULL, data);
g_assert(data->id);
tester_io_send();
--
2.51.0
next prev parent reply other threads:[~2025-10-09 21:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 21:29 [PATCH BlueZ v2 01/13] monitor: Use PAST to refer to Periodic Advertising Sync Transfer Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 02/13] emulator: Add initial support for PAST Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 03/13] iso-tester: Add tests for PAST procedures Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 04/13] monitor: Add support for PAST MGMT settings and flags Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 05/13] MGMT: Add PAST Settings and Flags Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 06/13] device: Add initial support for setting DEVICE_FLAG_PAST Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 07/13] bass: Add " Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 08/13] iso.rst: Add documentation for PAST/rebind Luiz Augusto von Dentz
2025-10-09 21:29 ` Luiz Augusto von Dentz [this message]
2025-10-09 21:29 ` [PATCH BlueZ v2 10/13] MediaAssistant: Add Device option to Push Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 11/13] bass: Implement Device option for Push Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 12/13] client/assistant: Handle assistant.push to own broadcasts Luiz Augusto von Dentz
2025-10-09 21:29 ` [PATCH BlueZ v2 13/13] client/assistant: Detect if object already contains a valid BCode Luiz Augusto von Dentz
2025-10-09 22:51 ` [BlueZ,v2,01/13] monitor: Use PAST to refer to Periodic Advertising Sync Transfer bluez.test.bot
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=20251009212931.445719-9-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/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