Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions subsys/bluetooth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,65 @@ config BT_DATA_LEN_UPDATE
Enable support for Bluetooth v4.2 LE Data Length Update procedure.
endif # BT_CONN


config BT_ISO
bool "Bluetooth Isochronous Channel Support [EXPERIMENTAL]"
depends on BT_CONN
help
Select this to enable Isochronous Channel support.

if BT_ISO

config BT_ISO_MAX_CHAN
int "Maximum number of simultaneous ISO channels"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will need to revisit this once there is more "meat" on the controller. For the controller it is more natural to model CISes/CIGs/BISes/BIGs than individual channels. But it looks reasonable enough for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. For the host, it doesn't matter if the ISO channel is for a BIS or a CIS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw., in a discussion with @asmk-ot it came up that this is actually useful as it is for the ISOAL in the controller

depends on BT_ISO
default BT_MAX_CONN
range 1 64
help
Maximum number of simultaneous Bluetooth isochronous channels
supported.

config BT_ISO_TX_BUF_COUNT
int "Number of Isochronous TX buffers"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should refer to "HCI ISO Data TX buffers". The controller also has to deal with SDUs and PDUs, so the description should be explicit about this to avoid confusion what the setting refers to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in another comment: This isn't just for HCI, but is also used in the host if ISO isn't done over HCI.

As I understand it, it's used for full SDUs. If fragmentation is used/supported, the buffer count is controller by CONFIG_BT_ISO_TX_FRAG_COUNT.

I updated the help message to clarify SDUs.

default 1
range 1 255
help
Number of buffers available for outgoing Isochronous channel SDUs.

config BT_ISO_TX_FRAG_COUNT
int "Number of ISO TX fragment buffers"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is referring to fragmenting SDUs in the host and not to fragmentation in ISOAL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

default 2
range 0 255
help
Number of buffers available for fragments of TX buffers. Warning:
setting this to 0 means that the application must ensure that
queued TX buffers never need to be fragmented, i.e. that the
controller's buffer size is large enough. If this is not ensured,
and there are no dedicated fragment buffers, a deadlock may occur.
In most cases the default value of 2 is a safe bet.

config BT_ISO_TX_MTU
int "Maximum supported MTU for Isochronous TX buffers"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this refer to the MTU of HCI Isochronous Data packets over HCI? How does it relate to ISO_Data_Packet_Length return parameter of the HCI_LE_Read_Buffer_Size command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is somewhat related to the length returned by the HCI_LE_Read_Buffer_Size command:

	max_num = MIN(rp->iso_max_pkt, CONFIG_BT_ISO_TX_BUF_COUNT);
	k_sem_init(&bt_dev.le.iso_pkts, max_num, max_num);

The bt_dev.le.iso_pkts is initialized the smallest of the two. How that affects the host is outside of my understanding of how this is implemented. Perhaps @Vudentz can further explain this.

default 251
range 23 4095
help
Maximum MTU for Isochronous channels TX buffers.

config BT_ISO_RX_BUF_COUNT
int "Number of Isochronous RX buffers"
default 1
range 1 255
help
Number of buffers available for incoming Isochronous channel SDUs.

config BT_ISO_RX_MTU
int "Maximum supported MTU for Isochronous RX buffers"
default 251
range 23 4095
help
Maximum MTU for Isochronous channels RX buffers.
endif # BT_ISO

# Workaround for not being able to have commas in macro arguments
DT_CHOSEN_Z_BT_C2H_UART := zephyr,bt-c2h-uart

Expand Down
7 changes: 5 additions & 2 deletions subsys/bluetooth/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ if(CONFIG_BT_HCI_HOST)
endif()
endif()

zephyr_library_sources_ifdef(
CONFIG_BT_ISO
iso.c
)

if(CONFIG_BT_DF)
zephyr_library_sources(
direction.c
Expand Down Expand Up @@ -101,5 +106,3 @@ if(CONFIG_BT_CONN_DISABLE_SECURITY)
Do not use in production."
)
endif()

add_subdirectory_ifdef(CONFIG_BT_AUDIO audio)
6 changes: 6 additions & 0 deletions subsys/bluetooth/host/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,12 @@ config BT_DEBUG_CONN
This option enables debug support for Bluetooth
connection handling.

config BT_DEBUG_ISO
bool "ISO channel debug"
help
Use this option to enable ISO channels debug logs for the
Bluetooth Audio functionality.

config BT_DEBUG_KEYS
bool "Bluetooth security keys debug"
depends on BT_HCI_HOST
Expand Down
6 changes: 0 additions & 6 deletions subsys/bluetooth/host/audio/CMakeLists.txt

This file was deleted.

64 changes: 0 additions & 64 deletions subsys/bluetooth/host/audio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ menuconfig BT_AUDIO

if BT_AUDIO

config BT_ISO
bool

if BT_CONN

config BT_AUDIO_UNICAST
Expand All @@ -35,58 +32,6 @@ config BT_AUDIO_UNICAST
This option enables support for Bluetooth Unicast Audio using
Isochronous channels.

if BT_AUDIO_UNICAST

config BT_MAX_ISO_CONN
int "Maximum number of simultaneous ISO connections"
depends on BT_ISO
default BT_MAX_CONN
range 1 64
help
Maximum number of simultaneous Bluetooth isochronous connections
supported.

config BT_ISO_TX_BUF_COUNT
int "Numer of Isochronous TX buffers"
default 1
range 1 255
help
Number of buffers available for outgoing Isochronous channel packets.

config BT_ISO_TX_FRAG_COUNT
int "Number of ISO TX fragment buffers"
default 2
range 0 255
help
Number of buffers available for fragments of TX buffers. Warning:
setting this to 0 means that the application must ensure that
queued TX buffers never need to be fragmented, i.e. that the
controller's buffer size is large enough. If this is not ensured,
and there are no dedicated fragment buffers, a deadlock may occur.
In most cases the default value of 2 is a safe bet.

config BT_ISO_TX_MTU
int "Maximum supported MTU for Isochronous TX buffers"
default 251
range 23 2000
help
Maximum MTU for Isochronous channels TX buffers.

config BT_ISO_RX_BUF_COUNT
int "Numer of Isochronous RX buffers"
default 1
range 1 255
help
Number of buffers available for incoming Isochronous channel packets.

config BT_ISO_RX_MTU
int "Maximum supported MTU for Isochronous RX buffers"
default 251
range 23 2000
help
Maximum MTU for Isochronous channels RX buffers.

endif # BT_AUDIO_UNICAST
endif # BT_CONN

config BT_AUDIO_DEBUG
Expand All @@ -96,13 +41,4 @@ config BT_AUDIO_DEBUG
Use this option to enable debug logs for the Bluetooth
Audio functionality.

if BT_AUDIO_DEBUG

config BT_AUDIO_DEBUG_ISO
bool "ISO channel debug"
help
Use this option to enable ISO channels debug logs for the
Bluetooth Audio functionality.

endif # BT_AUDIO_DEBUG
endif # BT_AUDIO
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "hci_core.h"
#include "conn_internal.h"
#include "audio/iso_internal.h"
#include "iso_internal.h"

#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE)
#define LOG_MODULE_NAME bt_buf
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "ssp.h"
#include "att_internal.h"
#include "gatt_internal.h"
#include "audio/iso_internal.h"
#include "iso_internal.h"

/* Peripheral timeout to initialize Connection Parameter Update procedure */
#define CONN_UPDATE_TIMEOUT K_MSEC(CONFIG_BT_CONN_PARAM_UPDATE_TIMEOUT)
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/conn_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ struct bt_conn {
struct bt_conn_br br;
struct bt_conn_sco sco;
#endif
#if defined(CONFIG_BT_AUDIO)
#if defined(CONFIG_BT_ISO)
struct bt_conn_iso iso;
#endif
};
Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/host/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "ecc.h"

#include "conn_internal.h"
#include "audio/iso_internal.h"
#include "iso_internal.h"
#include "l2cap_internal.h"
#include "gatt_internal.h"
#include "smp.h"
Expand Down Expand Up @@ -5206,7 +5206,7 @@ static void process_events(struct k_poll_event *ev, int count)
#if defined(CONFIG_BT_CONN)
#if defined(CONFIG_BT_ISO)
/* command FIFO + conn_change signal + MAX_CONN + MAX_ISO_CONN */
#define EV_COUNT (2 + CONFIG_BT_MAX_CONN + CONFIG_BT_MAX_ISO_CONN)
#define EV_COUNT (2 + CONFIG_BT_MAX_CONN + CONFIG_BT_ISO_MAX_CHAN)
#else
/* command FIFO + conn_change signal + MAX_CONN */
#define EV_COUNT (2 + CONFIG_BT_MAX_CONN)
Expand Down
15 changes: 8 additions & 7 deletions subsys/bluetooth/host/hci_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ NET_BUF_POOL_FIXED_DEFINE(hci_cmd_pool, CONFIG_BT_HCI_CMD_COUNT,
NET_BUF_POOL_FIXED_DEFINE(hci_acl_pool, BT_HCI_ACL_COUNT,
BT_BUF_ACL_SIZE, NULL);
#if defined(CONFIG_BT_ISO)
NET_BUF_POOL_FIXED_DEFINE(hci_iso_pool, BT_ISO_TX_BUF_COUNT,
BT_ISO_TX_MTU, NULL);
#endif
NET_BUF_POOL_FIXED_DEFINE(hci_iso_pool, CONFIG_BT_ISO_TX_BUF_COUNT,
CONFIG_BT_ISO_TX_MTU, NULL);
#endif /* CONFIG_BT_ISO */

struct bt_dev_raw bt_dev;
struct bt_hci_raw_cmd_ext *cmd_ext;
Expand Down Expand Up @@ -78,9 +78,10 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
switch (type) {
case BT_BUF_EVT:
case BT_BUF_ACL_IN:
case BT_BUF_ISO_IN:
break;
default:
BT_ERR("Invalid type: %u", type);
BT_ERR("Invalid rx type: %u", type);
return NULL;
}

Expand Down Expand Up @@ -112,7 +113,7 @@ struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
case BT_BUF_ISO_OUT:
pool = &hci_iso_pool;
break;
#endif
#endif /* CONFIG_BT_ISO */
case BT_BUF_H4:
if (IS_ENABLED(CONFIG_BT_HCI_RAW_H4) &&
raw_mode == BT_HCI_RAW_MODE_H4) {
Expand All @@ -130,7 +131,7 @@ struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
type = BT_BUF_ISO_OUT;
pool = &hci_iso_pool;
break;
#endif
#endif /* CONFIG_BT_ISO */
default:
LOG_ERR("Unknown H4 type %u", type);
return NULL;
Expand All @@ -143,7 +144,7 @@ struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
}
__fallthrough;
default:
BT_ERR("Invalid type: %u", type);
BT_ERR("Invalid tx type: %u", type);
return NULL;
}

Expand Down
22 changes: 11 additions & 11 deletions subsys/bluetooth/host/audio/iso.c → subsys/bluetooth/host/iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "host/conn_internal.h"
#include "iso_internal.h"

#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_ISO)
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ISO)
#define LOG_MODULE_NAME bt_iso
#include "common/log.h"

Expand All @@ -34,7 +34,7 @@ NET_BUF_POOL_FIXED_DEFINE(iso_frag_pool, CONFIG_BT_ISO_TX_FRAG_COUNT,

/* TODO: Allow more than one server? */
static struct bt_iso_server *iso_server;
struct bt_conn iso_conns[CONFIG_BT_MAX_ISO_CONN];
struct bt_conn iso_conns[CONFIG_BT_ISO_MAX_CHAN];


struct bt_iso_data_path {
Expand Down Expand Up @@ -257,7 +257,7 @@ void bt_iso_cleanup(struct bt_conn *conn)
conn->iso.acl = NULL;

/* Check if conn is last of CIG */
for (i = 0; i < CONFIG_BT_MAX_ISO_CONN; i++) {
for (i = 0; i < CONFIG_BT_ISO_MAX_CHAN; i++) {
if (conn == &iso_conns[i]) {
continue;
}
Expand All @@ -268,7 +268,7 @@ void bt_iso_cleanup(struct bt_conn *conn)
}
}

if (i == CONFIG_BT_MAX_ISO_CONN) {
if (i == CONFIG_BT_ISO_MAX_CHAN) {
hci_le_remove_cig(conn->iso.cig_id);
}

Expand Down Expand Up @@ -330,9 +330,9 @@ struct net_buf *bt_iso_create_frag_timeout(size_t reserve, k_timeout_t timeout)
{
struct net_buf_pool *pool = NULL;

#if CONFIG_BT_L2CAP_TX_FRAG_COUNT > 0
#if CONFIG_BT_ISO_TX_FRAG_COUNT > 0
pool = &iso_frag_pool;
#endif
#endif /* CONFIG_BT_ISO_TX_FRAG_COUNT > 0 */

#if defined(CONFIG_NET_BUF_LOG)
return bt_conn_create_pdu_timeout_debug(pool, reserve, timeout, func,
Expand Down Expand Up @@ -417,7 +417,7 @@ int bt_conn_bind_iso(struct bt_iso_create_param *param)
return -ENOTSUP;
}

if (!param->num_conns || param->num_conns > CONFIG_BT_MAX_ISO_CONN) {
if (!param->num_conns || param->num_conns > CONFIG_BT_ISO_MAX_CHAN) {
return -EINVAL;
}

Expand Down Expand Up @@ -520,7 +520,7 @@ int bt_conn_connect_iso(struct bt_conn **conns, uint8_t num_conns)
return -ENOTSUP;
}

if (num_conns > CONFIG_BT_MAX_ISO_CONN) {
if (num_conns > CONFIG_BT_ISO_MAX_CHAN) {
return -EINVAL;
}

Expand Down Expand Up @@ -783,7 +783,7 @@ int bt_iso_server_register(struct bt_iso_server *server)
return 0;
}

#if defined(CONFIG_BT_AUDIO_DEBUG_ISO)
#if defined(CONFIG_BT_DEBUG_ISO)
const char *bt_iso_chan_state_str(uint8_t state)
{
switch (state) {
Expand Down Expand Up @@ -847,7 +847,7 @@ void bt_iso_chan_set_state(struct bt_iso_chan *chan, uint8_t state)
{
chan->state = state;
}
#endif /* CONFIG_BT_AUDIO_DEBUG_ISO */
#endif /* CONFIG_BT_DEBUG_ISO */

void bt_iso_chan_remove(struct bt_conn *conn, struct bt_iso_chan *chan)
{
Expand Down Expand Up @@ -898,7 +898,7 @@ int bt_iso_chan_bind(struct bt_conn **conns, uint8_t num_conns,

int bt_iso_chan_connect(struct bt_iso_chan **chans, uint8_t num_chans)
{
struct bt_conn *conns[CONFIG_BT_MAX_ISO_CONN];
struct bt_conn *conns[CONFIG_BT_ISO_MAX_CHAN];
int i, err;

__ASSERT_NO_MSG(chans);
Expand Down
Loading