diff --git a/subsys/bluetooth/controller/CMakeLists.txt b/subsys/bluetooth/controller/CMakeLists.txt index 6606ec9cb07..529f762ff06 100644 --- a/subsys/bluetooth/controller/CMakeLists.txt +++ b/subsys/bluetooth/controller/CMakeLists.txt @@ -90,6 +90,12 @@ if(CONFIG_BT_LL_SW_SPLIT) ) endif() + if(CONFIG_BT_CTLR_PERIPHERAL_ISO OR + CONFIG_BT_CTLR_CENTRAL_ISO) + zephyr_library_sources( + ll_sw/ull_conn_iso.c + ) + endif() if(CONFIG_BT_CTLR_ADV_ISO OR CONFIG_BT_CTLR_SYNC_ISO OR CONFIG_BT_CTLR_PERIPHERAL_ISO OR diff --git a/subsys/bluetooth/controller/ll_sw/ull.c b/subsys/bluetooth/controller/ll_sw/ull.c index d58790ff322..ca0c809489f 100644 --- a/subsys/bluetooth/controller/ll_sw/ull.c +++ b/subsys/bluetooth/controller/ll_sw/ull.c @@ -52,6 +52,9 @@ #include "ull_sync_internal.h" #include "ull_sync_iso_internal.h" #include "ull_conn_internal.h" +#include "ull_conn_iso_internal.h" +#include "ull_central_iso_internal.h" +#include "ull_peripheral_iso_internal.h" #include "ull_df.h" #if defined(CONFIG_BT_CTLR_USER_EXT) @@ -459,12 +462,34 @@ int ll_init(struct k_sem *sem_rx) * CONFIG_BT_CTLR_PERIPHERAL_ISO || CONFIG_BT_CTLR_CENTRAL_ISO */ +#if defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) || \ + defined(CONFIG_BT_CTLR_CENTRAL_ISO) + err = ull_conn_iso_init(); + if (err) { + return err; + } +#endif /* CONFIG_BT_CTLR_PERIPHERAL_ISO || CONFIG_BT_CTLR_CENTRAL_ISO */ + +#if defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) + err = ull_peripheral_iso_init(); + if (err) { + return err; + } +#endif /* CONFIG_BT_CTLR_PERIPHERAL_ISO */ + +#if defined(CONFIG_BT_CTLR_CENTRAL_ISO) + err = ull_central_iso_init(); + if (err) { + return err; + } +#endif /* CONFIG_BT_CTLR_CENTRAL_ISO */ + #if defined(CONFIG_BT_CTLR_ADV_ISO) err = ull_adv_iso_init(); if (err) { return err; } -#endif /* CONFIG_BT_CONN */ +#endif /* CONFIG_BT_CTLR_ADV_ISO */ #if IS_ENABLED(CONFIG_BT_CTLR_DF) err = lll_df_init(); @@ -535,11 +560,27 @@ void ll_reset(void) * CONFIG_BT_CTLR_PERIPHERAL_ISO || CONFIG_BT_CTLR_CENTRAL_ISO */ +#if defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) || \ + defined(CONFIG_BT_CTLR_CENTRAL_ISO) + err = ull_conn_iso_reset(); + LL_ASSERT(!err); +#endif /* CONFIG_BT_CTLR_PERIPHERAL_ISO || CONFIG_BT_CTLR_CENTRAL_ISO */ + +#if defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) + err = ull_peripheral_iso_reset(); + LL_ASSERT(!err); +#endif /* CONFIG_BT_CTLR_PERIPHERAL_ISO */ + +#if defined(CONFIG_BT_CTLR_CENTRAL_ISO) + err = ull_central_iso_reset(); + LL_ASSERT(!err); +#endif /* CONFIG_BT_CTLR_CENTRAL_ISO */ + #if defined(CONFIG_BT_CTLR_ADV_ISO) /* Reset periodic sync sets */ err = ull_adv_iso_reset(); LL_ASSERT(!err); -#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */ +#endif /* CONFIG_BT_CTLR_ADV_ISO */ #if IS_ENABLED(CONFIG_BT_CTLR_DF) err = ull_df_reset(); diff --git a/subsys/bluetooth/controller/ll_sw/ull_central_iso.c b/subsys/bluetooth/controller/ll_sw/ull_central_iso.c index de16efc0ef3..d46d3beb183 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_central_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_central_iso.c @@ -122,3 +122,13 @@ void ll_cis_create(uint16_t cis_handle, uint16_t acl_handle) ARG_UNUSED(cis_handle); ARG_UNUSED(acl_handle); } + +int ull_central_iso_init(void) +{ + return 0; +} + +int ull_central_iso_reset(void) +{ + return 0; +} diff --git a/subsys/bluetooth/controller/ll_sw/ull_central_iso_internal.h b/subsys/bluetooth/controller/ll_sw/ull_central_iso_internal.h new file mode 100644 index 00000000000..ea8a2e2f8ee --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/ull_central_iso_internal.h @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2021 Demant + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Helper functions to initialize and reset ull_central_iso module */ +int ull_central_iso_init(void); +int ull_central_iso_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c b/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c new file mode 100644 index 00000000000..89c23c05672 --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021 Demant + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include "util/mem.h" +#include "util/memq.h" + +#include "lll.h" +#include "lll_conn_iso.h" +#include "ull_conn_iso_types.h" + +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) +#define LOG_MODULE_NAME bt_ctlr_ull_conn_iso +#include "common/log.h" +#include "hal/debug.h" + +static struct ll_conn_iso_stream cis_pool[CONFIG_BT_CTLR_CONN_ISO_STREAMS]; +static void *cis_free; + +static struct ll_conn_iso_group cig_pool[CONFIG_BT_CTLR_CONN_ISO_GROUPS]; +static void *cig_free; + +static int init_reset(void); + +int ull_conn_iso_init(void) +{ + return init_reset(); +} + +int ull_conn_iso_reset(void) +{ + return init_reset(); +} + +static int init_reset(void) +{ + /* Initialize CIS pool */ + mem_init(cis_pool, sizeof(struct ll_conn_iso_stream), + sizeof(cis_pool) / sizeof(struct ll_conn_iso_stream), + &cis_free); + + /* Initialize CIG pool */ + mem_init(cig_pool, sizeof(struct ll_conn_iso_group), + sizeof(cig_pool) / sizeof(struct ll_conn_iso_group), + &cig_free); + + return 0; +} diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn_iso_internal.h b/subsys/bluetooth/controller/ll_sw/ull_conn_iso_internal.h new file mode 100644 index 00000000000..8c1d88c12e6 --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/ull_conn_iso_internal.h @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2021 Demant + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Helper functions to initialize and reset ull_conn_iso module */ +int ull_conn_iso_init(void); +int ull_conn_iso_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c b/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c index 563792f2c0e..8507ad6bea2 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c @@ -25,3 +25,13 @@ uint8_t ll_cis_reject(uint16_t handle, uint8_t reason) return BT_HCI_ERR_CMD_DISALLOWED; } + +int ull_peripheral_iso_init(void) +{ + return 0; +} + +int ull_peripheral_iso_reset(void) +{ + return 0; +} diff --git a/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso_internal.h b/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso_internal.h new file mode 100644 index 00000000000..8df591e9620 --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso_internal.h @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2021 Demant + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Helper functions to initialize and reset ull_peripheral_iso module */ +int ull_peripheral_iso_init(void); +int ull_peripheral_iso_reset(void);