From afe469eac70a1b6247370eef8c6517d8986b43fb Mon Sep 17 00:00:00 2001 From: Casper Bonde Date: Mon, 29 Mar 2021 10:19:12 +0200 Subject: [PATCH] Bluetooth: ISO: Speed up BT ISO data processing For the native posix build the sleep calls used in tasks will stall the zephyr instance which sets an upper limit on the data processing interval to once every 20-30 millisecond. This change reduces the duration of the sleep calls and increases the TICKS_PER_SECOND to allow for shorter sleeps. This is needed to support the data rates needed for LE Audio streaming. The rate is tuned to support up to bidirectional 5ms ISO-intervals. This change also increases the ISO buffer count from 1 to 5 to allow for some buffering in the controller, which is needed for gapless playback and/or use of burst number larger than 1. Signed-off-by: Casper Bonde --- drivers/bluetooth/hci/userchan.c | 2 +- tests/bluetooth/shell/boards/native_posix.conf | 9 +++++++++ tests/bluetooth/shell/prj.conf | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 tests/bluetooth/shell/boards/native_posix.conf diff --git a/drivers/bluetooth/hci/userchan.c b/drivers/bluetooth/hci/userchan.c index 26fb4668b0e..275ab5d29e2 100644 --- a/drivers/bluetooth/hci/userchan.c +++ b/drivers/bluetooth/hci/userchan.c @@ -106,7 +106,7 @@ static void rx_thread(void *p1, void *p2, void *p3) ssize_t len; if (!uc_ready()) { - k_sleep(K_MSEC(20)); + k_sleep(K_MSEC(1)); continue; } diff --git a/tests/bluetooth/shell/boards/native_posix.conf b/tests/bluetooth/shell/boards/native_posix.conf new file mode 100644 index 00000000000..e52a0a2849b --- /dev/null +++ b/tests/bluetooth/shell/boards/native_posix.conf @@ -0,0 +1,9 @@ +CONFIG_NO_OPTIMIZATIONS=y +# Allows for copying larger amount of data into the shell +CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=4096 + +# For native posix k_sleep is used in the data path as well as for shell input +# detection, hence data processing is at least two ticks per packet. To support +# 5ms ISO interval bidirectional data the system shall never stall for more +# than 1.5 ms in average. +CONFIG_SYS_CLOCK_TICKS_PER_SEC=500 diff --git a/tests/bluetooth/shell/prj.conf b/tests/bluetooth/shell/prj.conf index 4fe7ea05d53..1767e51a188 100644 --- a/tests/bluetooth/shell/prj.conf +++ b/tests/bluetooth/shell/prj.conf @@ -50,7 +50,7 @@ CONFIG_BT_AUTO_PHY_UPDATE=y CONFIG_BT_AUDIO=y CONFIG_BT_AUDIO_UNICAST=y CONFIG_BT_AUDIO_BROADCAST=y - +CONFIG_BT_ISO_TX_BUF_COUNT=5 CONFIG_BT_VOCS_MAX_INSTANCE_COUNT=1 CONFIG_BT_VOCS_CLIENT_MAX_INSTANCE_COUNT=1