Skip to content

Commit a56cbed

Browse files
Thalleycarlescufi
authored andcommitted
Bluetooth: ISO: Split ISO broadcast config
Splitt he ISO broadcast config into broadcaster and sync receiver. This will allow a device that only wants to one of the roles to have a much more optimized configuration. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 726656d commit a56cbed

File tree

11 files changed

+80
-34
lines changed

11 files changed

+80
-34
lines changed
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
CONFIG_BT=y
2-
CONFIG_BT_ISO_BROADCAST=y
2+
CONFIG_BT_ISO_BROADCASTER=y
33
CONFIG_BT_DEBUG_LOG=y
44
CONFIG_BT_DEVICE_NAME="Test ISO Broadcaster"
55

6-
# Temporary, enable the following to meet BT_ISO dependencies
7-
CONFIG_BT_OBSERVER=y
8-
CONFIG_BT_BROADCASTER=y
96
# Just needs to send a uint32_t value
107
CONFIG_BT_ISO_TX_MTU=23

samples/bluetooth/iso_broadcast_benchmark/prj.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ CONFIG_BT_DEVICE_NAME="ISO Broadcast Throughput"
55
CONFIG_BT=y
66
CONFIG_BT_PERIPHERAL=y
77
CONFIG_BT_OBSERVER=y
8-
CONFIG_BT_ISO_BROADCAST=y
8+
CONFIG_BT_ISO_BROADCASTER=y
9+
CONFIG_BT_ISO_SYNC_RECEIVER=y
910
CONFIG_BT_ISO_MAX_CHAN=1
1011
CONFIG_BT_ISO_TX_BUF_COUNT=2
1112

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
CONFIG_BT=y
22
CONFIG_BT_DEBUG_LOG=y
33
CONFIG_BT_DEVICE_NAME="Test ISO Receive"
4-
5-
# Temporary, enable the following to meet BT_ISO dependencies
6-
CONFIG_BT_ISO_BROADCAST=y
7-
CONFIG_BT_CENTRAL=y
4+
CONFIG_BT_ISO_SYNC_RECEIVER=y

subsys/bluetooth/Kconfig.iso

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
config BT_ISO
88
bool
99

10+
# TODO: Split between client (central) and server (peripheral)
1011
config BT_ISO_UNICAST
1112
bool "Bluetooth Isochronous Channel Unicast Support [EXPERIMENTAL]"
1213
depends on BT_CONN
@@ -15,16 +16,27 @@ config BT_ISO_UNICAST
1516
This option enables support for Bluetooth Broadcast
1617
Isochronous channels.
1718

18-
# TODO: Split between broadcaster and observer for optimization
1919
config BT_ISO_BROADCAST
20-
bool "Bluetooth Isochronous Channel Broadcast Support [EXPERIMENTAL]"
20+
bool
2121
select BT_ISO
2222
select BT_EXT_ADV
23+
24+
config BT_ISO_BROADCASTER
25+
bool "Bluetooth Isochronous Broadcaster Support [EXPERIMENTAL]"
26+
select BT_ISO_BROADCAST
27+
select BT_BROADCASTER
2328
select BT_PER_ADV
29+
help
30+
This option enables support for the Bluetooth Isochronous Broadcaster.
31+
32+
config BT_ISO_SYNC_RECEIVER
33+
bool "Bluetooth Isochronous Synchronized Receiver Support [EXPERIMENTAL]"
34+
select BT_ISO_BROADCAST
35+
select BT_OBSERVER
2436
select BT_PER_ADV_SYNC
2537
help
26-
This option enables support for Bluetooth Broadcast
27-
Isochronous channels.
38+
This option enables support for the Bluetooth Isochronous
39+
Synchronized Receiver.
2840

2941
if BT_ISO
3042

subsys/bluetooth/audio/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ config BT_AUDIO_UNICAST
3535
# TODO: Make BT_AUDIO_BROADCAST not depend on BT_CONN
3636
config BT_AUDIO_BROADCAST
3737
bool "Bluetooth Broadcast Audio Support"
38-
select BT_ISO_BROADCAST
38+
select BT_ISO_BROADCASTER
39+
select BT_ISO_SYNC_RECEIVER
3940
help
4041
This option enables support for Bluetooth Broadcast Audio using
4142
Isochronous channels.

subsys/bluetooth/host/buf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
6666
__ASSERT(type == BT_BUF_EVT || type == BT_BUF_ACL_IN ||
6767
type == BT_BUF_ISO_IN, "Invalid buffer type requested");
6868

69-
if (IS_ENABLED(CONFIG_BT_ISO) && type == BT_BUF_ISO_IN) {
69+
if ((IS_ENABLED(CONFIG_BT_ISO_UNICAST) ||
70+
IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER)) &&
71+
type == BT_BUF_ISO_IN) {
7072
return bt_iso_get_rx(timeout);
7173
}
7274

subsys/bluetooth/host/conn.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ void bt_conn_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags)
320320

321321
BT_DBG("handle %u len %u flags %02x", conn->handle, buf->len, flags);
322322

323-
if (IS_ENABLED(CONFIG_BT_ISO) &&
323+
if ((IS_ENABLED(CONFIG_BT_ISO_UNICAST) ||
324+
IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER)) &&
324325
conn->type == BT_CONN_TYPE_ISO) {
325326
bt_iso_recv(conn, buf, flags);
326327
return;

subsys/bluetooth/host/hci_core.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,13 +2203,15 @@ static const struct event_handler meta_events[] = {
22032203
EVENT_HANDLER(BT_HCI_EVT_LE_CIS_REQ, hci_le_cis_req,
22042204
sizeof(struct bt_hci_evt_le_cis_req)),
22052205
#endif /* (CONFIG_BT_ISO_UNICAST) */
2206-
#if defined(CONFIG_BT_ISO_BROADCAST)
2206+
#if defined(CONFIG_BT_ISO_BROADCASTER)
22072207
EVENT_HANDLER(BT_HCI_EVT_LE_BIG_COMPLETE,
22082208
hci_le_big_complete,
22092209
sizeof(struct bt_hci_evt_le_big_complete)),
22102210
EVENT_HANDLER(BT_HCI_EVT_LE_BIG_TERMINATE,
22112211
hci_le_big_terminate,
22122212
sizeof(struct bt_hci_evt_le_big_terminate)),
2213+
#endif /* CONFIG_BT_ISO_BROADCASTER */
2214+
#if defined(CONFIG_BT_ISO_SYNC_RECEIVER)
22132215
EVENT_HANDLER(BT_HCI_EVT_LE_BIG_SYNC_ESTABLISHED,
22142216
hci_le_big_sync_established,
22152217
sizeof(struct bt_hci_evt_le_big_sync_established)),
@@ -2219,7 +2221,7 @@ static const struct event_handler meta_events[] = {
22192221
EVENT_HANDLER(BT_HCI_EVT_LE_BIGINFO_ADV_REPORT,
22202222
bt_hci_le_biginfo_adv_report,
22212223
sizeof(struct bt_hci_evt_le_biginfo_adv_report)),
2222-
#endif /* (CONFIG_BT_ISO_BROADCAST) */
2224+
#endif /* CONFIG_BT_ISO_SYNC_RECEIVER */
22232225
#if defined(CONFIG_BT_DF_CONNECTIONLESS_CTE_RX)
22242226
EVENT_HANDLER(BT_HCI_EVT_LE_CONNECTIONLESS_IQ_REPORT, bt_hci_le_df_connectionless_iq_report,
22252227
sizeof(struct bt_hci_evt_le_connectionless_iq_report)),
@@ -2764,13 +2766,14 @@ static int le_set_event_mask(void)
27642766
}
27652767

27662768
/* Enable BIS events for broadcaster and/or receiver */
2767-
if (IS_ENABLED(CONFIG_BT_ISO_BROADCAST) &&
2768-
BT_FEAT_LE_BIS(bt_dev.le.features)) {
2769-
if (BT_FEAT_LE_ISO_BROADCASTER(bt_dev.le.features)) {
2769+
if (IS_ENABLED(CONFIG_BT_ISO) && BT_FEAT_LE_BIS(bt_dev.le.features)) {
2770+
if (IS_ENABLED(CONFIG_BT_ISO_BROADCASTER) &&
2771+
BT_FEAT_LE_ISO_BROADCASTER(bt_dev.le.features)) {
27702772
mask |= BT_EVT_MASK_LE_BIG_COMPLETE;
27712773
mask |= BT_EVT_MASK_LE_BIG_TERMINATED;
27722774
}
2773-
if (BT_FEAT_LE_SYNC_RECEIVER(bt_dev.le.features)) {
2775+
if (IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER) &&
2776+
BT_FEAT_LE_SYNC_RECEIVER(bt_dev.le.features)) {
27742777
mask |= BT_EVT_MASK_LE_BIG_SYNC_ESTABLISHED;
27752778
mask |= BT_EVT_MASK_LE_BIG_SYNC_LOST;
27762779
mask |= BT_EVT_MASK_LE_BIGINFO_ADV_REPORT;

subsys/bluetooth/host/iso.c

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,26 @@
2424
#define LOG_MODULE_NAME bt_iso
2525
#include "common/log.h"
2626

27+
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_BROADCAST)
2728
NET_BUF_POOL_FIXED_DEFINE(iso_tx_pool, CONFIG_BT_ISO_TX_BUF_COUNT,
2829
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU), NULL);
30+
#endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_BROADCAST */
31+
32+
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER)
2933
NET_BUF_POOL_FIXED_DEFINE(iso_rx_pool, CONFIG_BT_ISO_RX_BUF_COUNT,
3034
CONFIG_BT_ISO_RX_MTU, NULL);
3135

3236
static struct bt_iso_recv_info iso_info_data[CONFIG_BT_ISO_RX_BUF_COUNT];
3337
#define iso_info(buf) (&iso_info_data[net_buf_id(buf)])
38+
#endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_SYNC_RECEIVER */
3439
#define iso_chan(_iso) ((_iso)->iso.chan);
3540

41+
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_BROADCAST)
3642
#if CONFIG_BT_ISO_TX_FRAG_COUNT > 0
3743
NET_BUF_POOL_FIXED_DEFINE(iso_frag_pool, CONFIG_BT_ISO_TX_FRAG_COUNT,
3844
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU), NULL);
3945
#endif /* CONFIG_BT_ISO_TX_FRAG_COUNT > 0 */
46+
#endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_BROADCAST */
4047

4148
struct bt_conn iso_conns[CONFIG_BT_ISO_MAX_CHAN];
4249

@@ -49,11 +56,12 @@ static struct bt_iso_server *iso_server;
4956
struct bt_iso_big bigs[CONFIG_BT_ISO_MAX_BIG];
5057

5158
static struct bt_iso_big *lookup_big_by_handle(uint8_t big_handle);
52-
#endif /* defined(CONFIG_BT_ISO_BROADCAST) */
59+
#endif /* CONFIG_BT_ISO_BROADCAST */
5360

5461
/* Prototype */
5562
int hci_le_remove_cig(uint8_t cig_id);
5663

64+
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER)
5765
struct net_buf *bt_iso_get_rx(k_timeout_t timeout)
5866
{
5967
struct net_buf *buf = net_buf_alloc(&iso_rx_pool, timeout);
@@ -65,7 +73,9 @@ struct net_buf *bt_iso_get_rx(k_timeout_t timeout)
6573

6674
return buf;
6775
}
76+
#endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_SYNC_RECEIVER */
6877

78+
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_BROADCASTER)
6979
static void bt_iso_send_cb(struct bt_conn *iso, void *user_data)
7080
{
7181
struct bt_iso_chan *chan = iso->iso.chan;
@@ -79,6 +89,7 @@ static void bt_iso_send_cb(struct bt_conn *iso, void *user_data)
7989
ops->sent(chan);
8090
}
8191
}
92+
#endif /* CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_BROADCASTER */
8293

8394
void hci_iso(struct net_buf *buf)
8495
{
@@ -530,6 +541,7 @@ void bt_iso_chan_set_state(struct bt_iso_chan *chan, uint8_t state)
530541
}
531542
#endif /* CONFIG_BT_DEBUG_ISO */
532543

544+
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER)
533545
void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags)
534546
{
535547
struct bt_hci_iso_data_hdr *hdr;
@@ -671,7 +683,9 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags)
671683

672684
bt_conn_reset_rx_state(iso);
673685
}
686+
#endif /* CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER */
674687

688+
#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_BROADCASTER)
675689
int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf)
676690
{
677691
struct bt_hci_iso_data_hdr *hdr;
@@ -697,6 +711,7 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf)
697711

698712
return bt_conn_send_cb(chan->iso, buf, bt_iso_send_cb, NULL);
699713
}
714+
#endif /* CONFIG_BT_ISO_UNICAST) || CONFIG_BT_ISO_BROADCASTER */
700715

701716
static bool valid_chan_io_qos(const struct bt_iso_chan_io_qos *io_qos,
702717
bool is_tx)
@@ -1484,13 +1499,13 @@ static int big_init_bis(struct bt_iso_big *big, bool broadcaster)
14841499
return -EINVAL;
14851500
}
14861501

1487-
if (broadcaster) {
1502+
if (IS_ENABLED(CONFIG_BT_ISO_BROADCASTER) && broadcaster) {
14881503
CHECKIF(bis->qos->tx == NULL ||
14891504
!valid_chan_io_qos(bis->qos->tx, true)) {
14901505
BT_DBG("Invalid BIS QOS");
14911506
return -EINVAL;
14921507
}
1493-
} else {
1508+
} else if (IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER)) {
14941509
CHECKIF(bis->qos->rx == NULL) {
14951510
BT_DBG("Invalid BIS QOS");
14961511
return -EINVAL;
@@ -1514,6 +1529,7 @@ static int big_init_bis(struct bt_iso_big *big, bool broadcaster)
15141529
return 0;
15151530
}
15161531

1532+
#if defined(CONFIG_BT_ISO_BROADCASTER)
15171533
static int hci_le_create_big(struct bt_le_ext_adv *padv, struct bt_iso_big *big,
15181534
struct bt_iso_big_create_param *param)
15191535
{
@@ -1649,6 +1665,7 @@ int bt_iso_big_create(struct bt_le_ext_adv *padv, struct bt_iso_big_create_param
16491665

16501666
return err;
16511667
}
1668+
#endif /* CONFIG_BT_ISO_BROADCASTER */
16521669

16531670
static int hci_le_terminate_big(struct bt_iso_big *big)
16541671
{
@@ -1717,7 +1734,7 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
17171734
/* They all have the same QOS dir so we can just check the first */
17181735
broadcaster = big->bis[0]->qos->tx ? true : false;
17191736

1720-
if (broadcaster) {
1737+
if (IS_ENABLED(CONFIG_BT_ISO_BROADCASTER) && broadcaster) {
17211738
err = hci_le_terminate_big(big);
17221739

17231740
/* Wait for BT_HCI_EVT_LE_BIG_TERMINATE before cleaning up
@@ -1728,13 +1745,15 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
17281745
bt_iso_chan_set_state(big->bis[i], BT_ISO_DISCONNECT);
17291746
}
17301747
}
1731-
} else {
1748+
} else if (IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER)) {
17321749
err = hci_le_big_sync_term(big);
17331750

17341751
if (!err) {
17351752
big_disconnect(big, BT_HCI_ERR_LOCALHOST_TERM_CONN);
17361753
cleanup_big(big);
17371754
}
1755+
} else {
1756+
err = -EINVAL;
17381757
}
17391758

17401759
if (err) {
@@ -1744,6 +1763,7 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
17441763
return err;
17451764
}
17461765

1766+
#if defined(CONFIG_BT_ISO_BROADCASTER)
17471767
void hci_le_big_complete(struct net_buf *buf)
17481768
{
17491769
struct bt_hci_evt_le_big_complete *evt = (void *)buf->data;
@@ -1801,7 +1821,9 @@ void hci_le_big_terminate(struct net_buf *buf)
18011821
big_disconnect(big, evt->reason);
18021822
cleanup_big(big);
18031823
}
1824+
#endif /* CONFIG_BT_ISO_BROADCASTER */
18041825

1826+
#if defined(CONFIG_BT_ISO_SYNC_RECEIVER)
18051827
void hci_le_big_sync_established(struct net_buf *buf)
18061828
{
18071829
struct bt_hci_evt_le_big_sync_established *evt = (void *)buf->data;
@@ -1989,4 +2011,5 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para
19892011

19902012
return 0;
19912013
}
1992-
#endif /* defined(CONFIG_BT_ISO_BROADCAST) */
2014+
#endif /* CONFIG_BT_ISO_SYNC_RECEIVER */
2015+
#endif /* CONFIG_BT_ISO_BROADCAST */

subsys/bluetooth/host/scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ void bt_hci_le_biginfo_adv_report(struct net_buf *buf)
893893
}
894894
}
895895
}
896-
#endif /* defined(CONFIG_BT_ISO_BROADCAST) */
896+
#endif /* CONFIG_BT_ISO_BROADCAST */
897897
#if defined(CONFIG_BT_DF_CONNECTIONLESS_CTE_RX)
898898
void bt_hci_le_df_connectionless_iq_report(struct net_buf *buf)
899899
{

0 commit comments

Comments
 (0)