From ba1949759d27c0b72c5963b6cb216e1d99859c63 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Tue, 20 Dec 2022 15:39:07 +0100 Subject: [PATCH] Bluetooth: Audio: Add packing field to broadcast source Add support for setting the ISO packing field when creating a broadcast source. Signed-off-by: Emil Gydesen --- include/zephyr/bluetooth/audio/audio.h | 9 +++++++++ subsys/bluetooth/audio/broadcast_source.c | 9 ++++++++- subsys/bluetooth/audio/endpoint.h | 1 + .../bsim_bt/bsim_test_audio/src/broadcast_source_test.c | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/zephyr/bluetooth/audio/audio.h b/include/zephyr/bluetooth/audio/audio.h index 321d218fb32..575530f3a68 100644 --- a/include/zephyr/bluetooth/audio/audio.h +++ b/include/zephyr/bluetooth/audio/audio.h @@ -2052,6 +2052,15 @@ struct bt_audio_broadcast_source_create_param { /** Quality of Service configuration. */ struct bt_codec_qos *qos; + + /** @brief Broadcast Source packing mode. + * + * @ref BT_ISO_PACKING_SEQUENTIAL or @ref BT_ISO_PACKING_INTERLEAVED. + * + * @note This is a recommendation to the controller, which the + * controller may ignore. + */ + uint8_t packing; }; /** @brief Create audio broadcast source. diff --git a/subsys/bluetooth/audio/broadcast_source.c b/subsys/bluetooth/audio/broadcast_source.c index f484870a810..1004674fa24 100644 --- a/subsys/bluetooth/audio/broadcast_source.c +++ b/subsys/bluetooth/audio/broadcast_source.c @@ -532,6 +532,12 @@ static bool valid_create_param(const struct bt_audio_broadcast_source_create_par return false; } + CHECKIF(param->packing != BT_ISO_PACKING_SEQUENTIAL && + param->packing != BT_ISO_PACKING_INTERLEAVED) { + LOG_DBG("param->packing %u is invalid", param->packing); + return false; + } + qos = param->qos; CHECKIF(qos == NULL) { LOG_DBG("param->qos is NULL"); @@ -727,6 +733,7 @@ int bt_audio_broadcast_source_create(struct bt_audio_broadcast_source_create_par } } source->qos = qos; + source->packing = param->packing; LOG_DBG("Broadcasting with ID 0x%6X", source->broadcast_id); @@ -873,7 +880,7 @@ int bt_audio_broadcast_source_start(struct bt_audio_broadcast_source *source, param.num_bis = bis_count; param.bis_channels = bis; param.framing = source->qos->framing; - param.packing = 0; /* TODO: Add to QoS struct */ + param.packing = source->packing; param.interval = source->qos->interval; param.latency = source->qos->latency; diff --git a/subsys/bluetooth/audio/endpoint.h b/subsys/bluetooth/audio/endpoint.h index ceaef5028bd..fb099d0d458 100644 --- a/subsys/bluetooth/audio/endpoint.h +++ b/subsys/bluetooth/audio/endpoint.h @@ -77,6 +77,7 @@ struct bt_audio_broadcast_stream_data { struct bt_audio_broadcast_source { uint8_t stream_count; + uint8_t packing; uint32_t broadcast_id; /* 24 bit */ struct bt_iso_big *big; diff --git a/tests/bluetooth/bsim_bt/bsim_test_audio/src/broadcast_source_test.c b/tests/bluetooth/bsim_bt/bsim_test_audio/src/broadcast_source_test.c index 5bc5b9e7a2b..e97cbfe521b 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_audio/src/broadcast_source_test.c +++ b/tests/bluetooth/bsim_bt/bsim_test_audio/src/broadcast_source_test.c @@ -127,6 +127,7 @@ static int setup_broadcast_source(struct bt_audio_broadcast_source **source) create_param.params_count = ARRAY_SIZE(subgroup_params); create_param.params = subgroup_params; create_param.qos = &preset_16_2_2.qos; + create_param.packing = BT_ISO_PACKING_SEQUENTIAL; printk("Creating broadcast source with %zu subgroups and %zu streams\n", ARRAY_SIZE(subgroup_params), ARRAY_SIZE(stream_params));