Skip to content

Commit

Permalink
bluetooth: controller: Add dependencies to Kconfig symbols
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rugeGerritsen committed Jan 17, 2025
1 parent 4389cc3 commit fcbe2bb
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 72 deletions.
7 changes: 7 additions & 0 deletions subsys/bluetooth/controller/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -554,20 +558,23 @@ 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
The time reserved for other roles in each ISO interval, used when selecting BIG parameters.

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
The time reserved for other roles in each ISO interval, used when selecting CIG parameters.

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.
Expand Down
142 changes: 70 additions & 72 deletions subsys/bluetooth/controller/hci_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(&params);
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(&params);
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(&params);
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(&params);
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(&params);
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(&params);
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) {
Expand Down

0 comments on commit fcbe2bb

Please sign in to comment.