From 4dfe35ef10876d34f9d10eeeb087ec6714f791ef Mon Sep 17 00:00:00 2001 From: Rubin Gerritsen Date: Thu, 16 Jan 2025 13:57:38 +0100 Subject: [PATCH] bluetooth: controller: Add dependencies to Kconfig symbols Add dependencies to SoftDevice Controller specific config entries so that symbols that are not relevant for a given application cannot be configured. This also removes these from the generated configuration file. This requires some change to source code as well because some Kconfig entries are now undefined for some application configurations. Signed-off-by: Rubin Gerritsen --- subsys/bluetooth/controller/Kconfig | 7 ++ subsys/bluetooth/controller/hci_driver.c | 142 +++++++++++------------ 2 files changed, 77 insertions(+), 72 deletions(-) diff --git a/subsys/bluetooth/controller/Kconfig b/subsys/bluetooth/controller/Kconfig index b8533c613648..a5397c7458a8 100644 --- a/subsys/bluetooth/controller/Kconfig +++ b/subsys/bluetooth/controller/Kconfig @@ -155,6 +155,7 @@ config BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT_OVERRIDE config BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT int "Default max connection event length [us]" + depends on BT_CONN default 0 if BT_ISO && !BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT_OVERRIDE default 7500 if !BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT_OVERRIDE range 0 4000000 @@ -182,6 +183,7 @@ config BT_CTLR_SDC_CONN_EVENT_EXTEND_DEFAULT config BT_CTLR_SDC_CENTRAL_ACL_EVENT_SPACING_DEFAULT int "Default central ACL event spacing [us]" + depends on BT_CENTRAL default 30000 if BT_ISO default BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT help @@ -217,6 +219,7 @@ config BT_CTLR_SDC_PERIODIC_ADV_EVENT_LEN_DEFAULT_OVERRIDE config BT_CTLR_SDC_PERIODIC_ADV_EVENT_LEN_DEFAULT int "Default periodic advertising event length [us]" + depends on BT_PER_ADV default 2500 if BT_ISO && !BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT_OVERRIDE default 7500 if !BT_CTLR_SDC_PERIODIC_ADV_EVENT_LEN_DEFAULT_OVERRIDE range 0 4000000 @@ -252,6 +255,7 @@ config BT_CTLR_SDC_RX_PACKET_COUNT config BT_CTLR_SDC_SCAN_BUFFER_COUNT int "Number of buffers available in the scanner" + depends on BT_OBSERVER default 3 range 2 20 help @@ -554,6 +558,7 @@ config BT_CTLR_SDC_IGNORE_HCI_ISO_DATA_TS_FROM_HOST config BT_CTLR_SDC_BIG_RESERVED_TIME_US int "BIG reserved time [us]" + depends on BT_CTLR_ADV_ISO range 0 4000000 default 1600 help @@ -561,6 +566,7 @@ config BT_CTLR_SDC_BIG_RESERVED_TIME_US config BT_CTLR_SDC_CIG_RESERVED_TIME_US int "CIG reserved time [us]" + depends on BT_CTLR_CENTRAL_ISO range 0 4000000 default 1300 help @@ -568,6 +574,7 @@ config BT_CTLR_SDC_CIG_RESERVED_TIME_US config BT_CTLR_SDC_CIS_SUBEVENT_LENGTH_US int "CIS subevent length [us]" + depends on BT_CTLR_CENTRAL_ISO default 0 help Sets the subevent length to be used for CISes in microseconds. diff --git a/subsys/bluetooth/controller/hci_driver.c b/subsys/bluetooth/controller/hci_driver.c index 2086261966de..db88f5970cc3 100644 --- a/subsys/bluetooth/controller/hci_driver.c +++ b/subsys/bluetooth/controller/hci_driver.c @@ -1089,17 +1089,17 @@ static int configure_memory_usage(void) } } - if (IS_ENABLED(CONFIG_BT_OBSERVER)) { - cfg.scan_buffer_cfg.count = CONFIG_BT_CTLR_SDC_SCAN_BUFFER_COUNT; +#if defined(CONFIG_BT_OBSERVER) + cfg.scan_buffer_cfg.count = CONFIG_BT_CTLR_SDC_SCAN_BUFFER_COUNT; - required_memory = - sdc_cfg_set(SDC_DEFAULT_RESOURCE_CFG_TAG, - SDC_CFG_TYPE_SCAN_BUFFER_CFG, - &cfg); - if (required_memory < 0) { - return required_memory; - } + required_memory = + sdc_cfg_set(SDC_DEFAULT_RESOURCE_CFG_TAG, + SDC_CFG_TYPE_SCAN_BUFFER_CFG, + &cfg); + if (required_memory < 0) { + return required_memory; } +#endif /* CONFIG_BT_OBSERVER */ if (IS_ENABLED(CONFIG_BT_PER_ADV_SYNC)) { cfg.periodic_sync_count.count = SDC_PERIODIC_ADV_SYNC_COUNT; @@ -1355,81 +1355,79 @@ static int hci_driver_open(const struct device *dev, bt_hci_recv_t recv_func) return err; } - if (IS_ENABLED(CONFIG_BT_PER_ADV)) { - sdc_hci_cmd_vs_periodic_adv_event_length_set_t params = { - .event_length_us = CONFIG_BT_CTLR_SDC_PERIODIC_ADV_EVENT_LEN_DEFAULT - }; - err = sdc_hci_cmd_vs_periodic_adv_event_length_set(¶ms); - if (err) { - MULTITHREADING_LOCK_RELEASE(); - return -ENOTSUP; - } +#if defined(CONFIG_BT_PER_ADV) + sdc_hci_cmd_vs_periodic_adv_event_length_set_t per_adv_length_params = { + .event_length_us = CONFIG_BT_CTLR_SDC_PERIODIC_ADV_EVENT_LEN_DEFAULT + }; + err = sdc_hci_cmd_vs_periodic_adv_event_length_set(&per_adv_length_params); + if (err) { + MULTITHREADING_LOCK_RELEASE(); + return -ENOTSUP; } +#endif /* CONFIG_BT_PER_ADV */ - if (IS_ENABLED(CONFIG_BT_ISO_BROADCASTER)) { - sdc_hci_cmd_vs_big_reserved_time_set_t params = { - .reserved_time_us = CONFIG_BT_CTLR_SDC_BIG_RESERVED_TIME_US - }; - err = sdc_hci_cmd_vs_big_reserved_time_set(¶ms); - if (err) { - MULTITHREADING_LOCK_RELEASE(); - return -ENOTSUP; - } +#if defined(CONFIG_BT_CTLR_SDC_BIG_RESERVED_TIME_US) + sdc_hci_cmd_vs_big_reserved_time_set_t big_reserved_time_params = { + .reserved_time_us = CONFIG_BT_CTLR_SDC_BIG_RESERVED_TIME_US + }; + err = sdc_hci_cmd_vs_big_reserved_time_set(&big_reserved_time_params); + if (err) { + MULTITHREADING_LOCK_RELEASE(); + return -ENOTSUP; } +#endif /* BT_CTLR_SDC_BIG_RESERVED_TIME_US*/ - if (IS_ENABLED(CONFIG_BT_CTLR_CONN_ISO)) { - sdc_hci_cmd_vs_cig_reserved_time_set_t params = { - .reserved_time_us = CONFIG_BT_CTLR_SDC_CIG_RESERVED_TIME_US - }; - err = sdc_hci_cmd_vs_cig_reserved_time_set(¶ms); - if (err) { - MULTITHREADING_LOCK_RELEASE(); - return -ENOTSUP; - } +#if defined(CONFIG_BT_CTLR_CENTRAL_ISO) + sdc_hci_cmd_vs_cig_reserved_time_set_t cig_reserved_time_params = { + .reserved_time_us = CONFIG_BT_CTLR_SDC_CIG_RESERVED_TIME_US + }; + err = sdc_hci_cmd_vs_cig_reserved_time_set(&cig_reserved_time_params); + if (err) { + MULTITHREADING_LOCK_RELEASE(); + return -ENOTSUP; } - if (IS_ENABLED(CONFIG_BT_CTLR_CONN_ISO)) { - sdc_hci_cmd_vs_cis_subevent_length_set_t params = { - .cis_subevent_length_us = CONFIG_BT_CTLR_SDC_CIS_SUBEVENT_LENGTH_US - }; - err = sdc_hci_cmd_vs_cis_subevent_length_set(¶ms); - if (err) { - MULTITHREADING_LOCK_RELEASE(); - return -ENOTSUP; - } + sdc_hci_cmd_vs_cis_subevent_length_set_t cis_subevent_length_params = { + .cis_subevent_length_us = CONFIG_BT_CTLR_SDC_CIS_SUBEVENT_LENGTH_US + }; + err = sdc_hci_cmd_vs_cis_subevent_length_set(&cis_subevent_length_params); + if (err) { + MULTITHREADING_LOCK_RELEASE(); + return -ENOTSUP; } +#endif /* CONFIG_BT_CTLR_CENTRAL_ISO */ - if (IS_ENABLED(CONFIG_BT_CONN)) { - sdc_hci_cmd_vs_event_length_set_t params = { - .event_length_us = CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT - }; - err = sdc_hci_cmd_vs_event_length_set(¶ms); - if (err) { - MULTITHREADING_LOCK_RELEASE(); - return -ENOTSUP; - } +#if defined(CONFIG_BT_CONN) + sdc_hci_cmd_vs_event_length_set_t conn_event_length_params = { + .event_length_us = CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT + }; + err = sdc_hci_cmd_vs_event_length_set(&conn_event_length_params); + if (err) { + MULTITHREADING_LOCK_RELEASE(); + return -ENOTSUP; + } - sdc_hci_cmd_vs_conn_event_extend_t event_extend_params = { - .enable = IS_ENABLED(CONFIG_BT_CTLR_SDC_CONN_EVENT_EXTEND_DEFAULT) - }; - err = sdc_hci_cmd_vs_conn_event_extend(&event_extend_params); - if (err) { - MULTITHREADING_LOCK_RELEASE(); - return -ENOTSUP; - } + sdc_hci_cmd_vs_conn_event_extend_t event_extend_params = { + .enable = IS_ENABLED(CONFIG_BT_CTLR_SDC_CONN_EVENT_EXTEND_DEFAULT) + }; + err = sdc_hci_cmd_vs_conn_event_extend(&event_extend_params); + if (err) { + MULTITHREADING_LOCK_RELEASE(); + return -ENOTSUP; } +#endif /* CONFIG_BT_CONN */ - if (IS_ENABLED(CONFIG_BT_CENTRAL)) { - sdc_hci_cmd_vs_central_acl_event_spacing_set_t params = { - .central_acl_event_spacing_us = - CONFIG_BT_CTLR_SDC_CENTRAL_ACL_EVENT_SPACING_DEFAULT - }; - err = sdc_hci_cmd_vs_central_acl_event_spacing_set(¶ms); - if (err) { - MULTITHREADING_LOCK_RELEASE(); - return -ENOTSUP; - } +#if defined(CONFIG_BT_CENTRAL) + sdc_hci_cmd_vs_central_acl_event_spacing_set_t acl_event_spacing_params = { + .central_acl_event_spacing_us = + CONFIG_BT_CTLR_SDC_CENTRAL_ACL_EVENT_SPACING_DEFAULT + }; + err = sdc_hci_cmd_vs_central_acl_event_spacing_set(&acl_event_spacing_params); + if (err) { + MULTITHREADING_LOCK_RELEASE(); + return -ENOTSUP; } +#endif /* CONFIG_BT_CENTRAL */ #if defined(CONFIG_BT_CTLR_MIN_VAL_OF_MAX_ACL_TX_PAYLOAD_DEFAULT) if (CONFIG_BT_CTLR_MIN_VAL_OF_MAX_ACL_TX_PAYLOAD_DEFAULT != 27) {