Skip to content

Commit e0c8081

Browse files
committed
Bluetooth: hci_raw: Move BT_ISO to common Kconfig and fix ISO buffers
This commit moves the BT_ISO to a common (host and controller) Kconfig and fixes the ISO buffers in hci_raw.c Signed-off-by: Emil Gydesen <[email protected]>
1 parent 2e2915a commit e0c8081

File tree

7 files changed

+86
-85
lines changed

7 files changed

+86
-85
lines changed

subsys/bluetooth/Kconfig

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,64 @@ config BT_DATA_LEN_UPDATE
222222
Enable support for Bluetooth v4.2 LE Data Length Update procedure.
223223
endif # BT_CONN
224224

225+
226+
config BT_ISO
227+
bool "Bluetooth Isochronous Channel Support [EXPERIMENTAL]"
228+
help
229+
Select this to enable Isochronous Channel support.
230+
231+
if BT_ISO
232+
233+
config BT_ISO_MAX_CHAN
234+
int "Maximum number of simultaneous ISO channels"
235+
depends on BT_ISO
236+
default BT_MAX_CONN
237+
range 1 64
238+
help
239+
Maximum number of simultaneous Bluetooth isochronous channels
240+
supported.
241+
242+
config BT_ISO_TX_BUF_COUNT
243+
int "Number of Isochronous TX buffers"
244+
default 1
245+
range 1 255
246+
help
247+
Number of buffers available for outgoing Isochronous channel SDUs.
248+
249+
config BT_ISO_TX_FRAG_COUNT
250+
int "Number of ISO TX fragment buffers"
251+
default 2
252+
range 0 255
253+
help
254+
Number of buffers available for fragments of TX buffers. Warning:
255+
setting this to 0 means that the application must ensure that
256+
queued TX buffers never need to be fragmented, i.e. that the
257+
controller's buffer size is large enough. If this is not ensured,
258+
and there are no dedicated fragment buffers, a deadlock may occur.
259+
In most cases the default value of 2 is a safe bet.
260+
261+
config BT_ISO_TX_MTU
262+
int "Maximum supported MTU for Isochronous TX buffers"
263+
default 251
264+
range 23 4095
265+
help
266+
Maximum MTU for Isochronous channels TX buffers.
267+
268+
config BT_ISO_RX_BUF_COUNT
269+
int "Number of Isochronous RX buffers"
270+
default 1
271+
range 1 255
272+
help
273+
Number of buffers available for incoming Isochronous channel SDUs.
274+
275+
config BT_ISO_RX_MTU
276+
int "Maximum supported MTU for Isochronous RX buffers"
277+
default 251
278+
range 23 4095
279+
help
280+
Maximum MTU for Isochronous channels RX buffers.
281+
endif # BT_ISO
282+
225283
# Workaround for not being able to have commas in macro arguments
226284
DT_CHOSEN_Z_BT_C2H_UART := zephyr,bt-c2h-uart
227285

subsys/bluetooth/host/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,12 @@ config BT_DEBUG_CONN
668668
This option enables debug support for Bluetooth
669669
connection handling.
670670

671+
config BT_DEBUG_ISO
672+
bool "ISO channel debug"
673+
help
674+
Use this option to enable ISO channels debug logs for the
675+
Bluetooth Audio functionality.
676+
671677
config BT_DEBUG_KEYS
672678
bool "Bluetooth security keys debug"
673679
depends on BT_HCI_HOST

subsys/bluetooth/host/audio/Kconfig

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ menuconfig BT_AUDIO
1717

1818
if BT_AUDIO
1919

20-
config BT_ISO
21-
bool
22-
2320
if BT_CONN
2421

2522
config BT_AUDIO_UNICAST
@@ -35,58 +32,6 @@ config BT_AUDIO_UNICAST
3532
This option enables support for Bluetooth Unicast Audio using
3633
Isochronous channels.
3734

38-
if BT_AUDIO_UNICAST
39-
40-
config BT_MAX_ISO_CONN
41-
int "Maximum number of simultaneous ISO connections"
42-
depends on BT_ISO
43-
default BT_MAX_CONN
44-
range 1 64
45-
help
46-
Maximum number of simultaneous Bluetooth isochronous connections
47-
supported.
48-
49-
config BT_ISO_TX_BUF_COUNT
50-
int "Numer of Isochronous TX buffers"
51-
default 1
52-
range 1 255
53-
help
54-
Number of buffers available for outgoing Isochronous channel packets.
55-
56-
config BT_ISO_TX_FRAG_COUNT
57-
int "Number of ISO TX fragment buffers"
58-
default 2
59-
range 0 255
60-
help
61-
Number of buffers available for fragments of TX buffers. Warning:
62-
setting this to 0 means that the application must ensure that
63-
queued TX buffers never need to be fragmented, i.e. that the
64-
controller's buffer size is large enough. If this is not ensured,
65-
and there are no dedicated fragment buffers, a deadlock may occur.
66-
In most cases the default value of 2 is a safe bet.
67-
68-
config BT_ISO_TX_MTU
69-
int "Maximum supported MTU for Isochronous TX buffers"
70-
default 251
71-
range 23 2000
72-
help
73-
Maximum MTU for Isochronous channels TX buffers.
74-
75-
config BT_ISO_RX_BUF_COUNT
76-
int "Numer of Isochronous RX buffers"
77-
default 1
78-
range 1 255
79-
help
80-
Number of buffers available for incoming Isochronous channel packets.
81-
82-
config BT_ISO_RX_MTU
83-
int "Maximum supported MTU for Isochronous RX buffers"
84-
default 251
85-
range 23 2000
86-
help
87-
Maximum MTU for Isochronous channels RX buffers.
88-
89-
endif # BT_AUDIO_UNICAST
9035
endif # BT_CONN
9136

9237
config BT_AUDIO_DEBUG
@@ -96,13 +41,4 @@ config BT_AUDIO_DEBUG
9641
Use this option to enable debug logs for the Bluetooth
9742
Audio functionality.
9843

99-
if BT_AUDIO_DEBUG
100-
101-
config BT_AUDIO_DEBUG_ISO
102-
bool "ISO channel debug"
103-
help
104-
Use this option to enable ISO channels debug logs for the
105-
Bluetooth Audio functionality.
106-
107-
endif # BT_AUDIO_DEBUG
10844
endif # BT_AUDIO

subsys/bluetooth/host/audio/iso.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "host/conn_internal.h"
1919
#include "iso_internal.h"
2020

21-
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_ISO)
21+
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ISO)
2222
#define LOG_MODULE_NAME bt_iso
2323
#include "common/log.h"
2424

@@ -34,7 +34,7 @@ NET_BUF_POOL_FIXED_DEFINE(iso_frag_pool, CONFIG_BT_ISO_TX_FRAG_COUNT,
3434

3535
/* TODO: Allow more than one server? */
3636
static struct bt_iso_server *iso_server;
37-
struct bt_conn iso_conns[CONFIG_BT_MAX_ISO_CONN];
37+
struct bt_conn iso_conns[CONFIG_BT_ISO_MAX_CHAN];
3838

3939

4040
struct bt_iso_data_path {
@@ -257,7 +257,7 @@ void bt_iso_cleanup(struct bt_conn *conn)
257257
conn->iso.acl = NULL;
258258

259259
/* Check if conn is last of CIG */
260-
for (i = 0; i < CONFIG_BT_MAX_ISO_CONN; i++) {
260+
for (i = 0; i < CONFIG_BT_ISO_MAX_CHAN; i++) {
261261
if (conn == &iso_conns[i]) {
262262
continue;
263263
}
@@ -268,7 +268,7 @@ void bt_iso_cleanup(struct bt_conn *conn)
268268
}
269269
}
270270

271-
if (i == CONFIG_BT_MAX_ISO_CONN) {
271+
if (i == CONFIG_BT_ISO_MAX_CHAN) {
272272
hci_le_remove_cig(conn->iso.cig_id);
273273
}
274274

@@ -417,7 +417,7 @@ int bt_conn_bind_iso(struct bt_iso_create_param *param)
417417
return -ENOTSUP;
418418
}
419419

420-
if (!param->num_conns || param->num_conns > CONFIG_BT_MAX_ISO_CONN) {
420+
if (!param->num_conns || param->num_conns > CONFIG_BT_ISO_MAX_CHAN) {
421421
return -EINVAL;
422422
}
423423

@@ -520,7 +520,7 @@ int bt_conn_connect_iso(struct bt_conn **conns, uint8_t num_conns)
520520
return -ENOTSUP;
521521
}
522522

523-
if (num_conns > CONFIG_BT_MAX_ISO_CONN) {
523+
if (num_conns > CONFIG_BT_ISO_MAX_CHAN) {
524524
return -EINVAL;
525525
}
526526

@@ -783,7 +783,7 @@ int bt_iso_server_register(struct bt_iso_server *server)
783783
return 0;
784784
}
785785

786-
#if defined(CONFIG_BT_AUDIO_DEBUG_ISO)
786+
#if defined(CONFIG_BT_DEBUG_ISO)
787787
const char *bt_iso_chan_state_str(uint8_t state)
788788
{
789789
switch (state) {
@@ -847,7 +847,7 @@ void bt_iso_chan_set_state(struct bt_iso_chan *chan, uint8_t state)
847847
{
848848
chan->state = state;
849849
}
850-
#endif /* CONFIG_BT_AUDIO_DEBUG_ISO */
850+
#endif /* CONFIG_BT_DEBUG_ISO */
851851

852852
void bt_iso_chan_remove(struct bt_conn *conn, struct bt_iso_chan *chan)
853853
{
@@ -898,7 +898,7 @@ int bt_iso_chan_bind(struct bt_conn **conns, uint8_t num_conns,
898898

899899
int bt_iso_chan_connect(struct bt_iso_chan **chans, uint8_t num_chans)
900900
{
901-
struct bt_conn *conns[CONFIG_BT_MAX_ISO_CONN];
901+
struct bt_conn *conns[CONFIG_BT_ISO_MAX_CHAN];
902902
int i, err;
903903

904904
__ASSERT_NO_MSG(chans);

subsys/bluetooth/host/audio/iso_internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ struct iso_data {
2828

2929
#define iso(buf) ((struct iso_data *)net_buf_user_data(buf))
3030

31-
#if defined(CONFIG_BT_MAX_ISO_CONN)
32-
extern struct bt_conn iso_conns[CONFIG_BT_MAX_ISO_CONN];
31+
#if defined(CONFIG_BT_ISO_MAX_CHAN)
32+
extern struct bt_conn iso_conns[CONFIG_BT_ISO_MAX_CHAN];
3333
#endif
3434

3535
/* Process ISO buffer */
@@ -97,14 +97,14 @@ struct net_buf *bt_iso_create_frag_timeout(size_t reserve, k_timeout_t timeout);
9797
bt_iso_create_frag_timeout(_reserve, K_FOREVER)
9898
#endif
9999

100-
#if defined(CONFIG_BT_AUDIO_DEBUG_ISO)
100+
#if defined(CONFIG_BT_DEBUG_ISO)
101101
void bt_iso_chan_set_state_debug(struct bt_iso_chan *chan, uint8_t state,
102102
const char *func, int line);
103103
#define bt_iso_chan_set_state(_chan, _state) \
104104
bt_iso_chan_set_state_debug(_chan, _state, __func__, __LINE__)
105105
#else
106106
void bt_iso_chan_set_state(struct bt_iso_chan *chan, uint8_t state);
107-
#endif /* CONFIG_BT_AUDIO_DEBUG_ISO */
107+
#endif /* CONFIG_BT_DEBUG_ISO */
108108

109109
/* Process incoming data for a connection */
110110
void bt_iso_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags);

subsys/bluetooth/host/hci_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5206,7 +5206,7 @@ static void process_events(struct k_poll_event *ev, int count)
52065206
#if defined(CONFIG_BT_CONN)
52075207
#if defined(CONFIG_BT_ISO)
52085208
/* command FIFO + conn_change signal + MAX_CONN + MAX_ISO_CONN */
5209-
#define EV_COUNT (2 + CONFIG_BT_MAX_CONN + CONFIG_BT_MAX_ISO_CONN)
5209+
#define EV_COUNT (2 + CONFIG_BT_MAX_CONN + CONFIG_BT_ISO_MAX_CHAN)
52105210
#else
52115211
/* command FIFO + conn_change signal + MAX_CONN */
52125212
#define EV_COUNT (2 + CONFIG_BT_MAX_CONN)

subsys/bluetooth/host/hci_raw.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ NET_BUF_POOL_FIXED_DEFINE(hci_cmd_pool, CONFIG_BT_HCI_CMD_COUNT,
4343
NET_BUF_POOL_FIXED_DEFINE(hci_acl_pool, BT_HCI_ACL_COUNT,
4444
BT_BUF_ACL_SIZE, NULL);
4545
#if defined(CONFIG_BT_ISO)
46-
NET_BUF_POOL_FIXED_DEFINE(hci_iso_pool, BT_ISO_TX_BUF_COUNT,
47-
BT_ISO_TX_MTU, NULL);
48-
#endif
46+
NET_BUF_POOL_FIXED_DEFINE(hci_iso_pool, CONFIG_BT_ISO_TX_BUF_COUNT,
47+
CONFIG_BT_ISO_TX_MTU, NULL);
48+
#endif /* CONFIG_BT_ISO */
4949

5050
struct bt_dev_raw bt_dev;
5151
struct bt_hci_raw_cmd_ext *cmd_ext;
@@ -78,9 +78,10 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
7878
switch (type) {
7979
case BT_BUF_EVT:
8080
case BT_BUF_ACL_IN:
81+
case BT_BUF_ISO_IN:
8182
break;
8283
default:
83-
BT_ERR("Invalid type: %u", type);
84+
BT_ERR("Invalid rx type: %u", type);
8485
return NULL;
8586
}
8687

@@ -112,7 +113,7 @@ struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
112113
case BT_BUF_ISO_OUT:
113114
pool = &hci_iso_pool;
114115
break;
115-
#endif
116+
#endif /* CONFIG_BT_ISO */
116117
case BT_BUF_H4:
117118
if (IS_ENABLED(CONFIG_BT_HCI_RAW_H4) &&
118119
raw_mode == BT_HCI_RAW_MODE_H4) {
@@ -130,7 +131,7 @@ struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
130131
type = BT_BUF_ISO_OUT;
131132
pool = &hci_iso_pool;
132133
break;
133-
#endif
134+
#endif /* CONFIG_BT_ISO */
134135
default:
135136
LOG_ERR("Unknown H4 type %u", type);
136137
return NULL;
@@ -143,7 +144,7 @@ struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
143144
}
144145
__fallthrough;
145146
default:
146-
BT_ERR("Invalid type: %u", type);
147+
BT_ERR("Invalid tx type: %u", type);
147148
return NULL;
148149
}
149150

0 commit comments

Comments
 (0)