Bluetooth: Audio: Add TBS client TX buffer count requirement

After removing the high default for MCS, it was discovered that
the TBS client requires a significant amount of buffers to work
properly as well. Added the requirement as a build assert that
depends on which optional TBS client features are enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
diff --git a/samples/bluetooth/hap_ha/prj.conf b/samples/bluetooth/hap_ha/prj.conf
index e6b91c1..93384c4 100644
--- a/samples/bluetooth/hap_ha/prj.conf
+++ b/samples/bluetooth/hap_ha/prj.conf
@@ -52,6 +52,7 @@
 CONFIG_BT_IAS=y
 
 CONFIG_BT_TBS_CLIENT=y
+CONFIG_BT_TBS_CLIENT_MINIMAL=y
 CONFIG_BT_TBS_CLIENT_GTBS=y
 CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES=0
 CONFIG_BT_TBS_CLIENT_CCID=y
diff --git a/subsys/bluetooth/audio/tbs_client.c b/subsys/bluetooth/audio/tbs_client.c
index ed744d0..1c1b3b6 100644
--- a/subsys/bluetooth/audio/tbs_client.c
+++ b/subsys/bluetooth/audio/tbs_client.c
@@ -24,6 +24,24 @@
 #include <zephyr/logging/log.h>
 
 LOG_MODULE_REGISTER(bt_tbs_client, CONFIG_BT_TBS_CLIENT_LOG_LEVEL);
+/* TODO TBS client attempts to subscribe to all characteristics at once if the MTU is large enough.
+ * This requires a significant amount of buffers, and should be optimized.
+ */
+
+/* Calculate the requiered buffers for TBS Client discovery */
+#define TBS_CLIENT_BUF_COUNT                                                                       \
+	(1 /* Discover buffer */ + 1 /* terminate reason */ +                                      \
+	 IS_ENABLED(CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME) +                                   \
+	 IS_ENABLED(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY) +                                      \
+	 IS_ENABLED(CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH) +                                 \
+	 IS_ENABLED(CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS) +                              \
+	 IS_ENABLED(CONFIG_BT_TBS_CLIENT_INCOMING_URI) +                                           \
+	 IS_ENABLED(CONFIG_BT_TBS_CLIENT_STATUS_FLAGS) +                                           \
+	 IS_ENABLED(CONFIG_BT_TBS_CLIENT_CP_PROCEDURES) +                                          \
+	 IS_ENABLED(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME) +                                     \
+	 IS_ENABLED(CONFIG_BT_TBS_CLIENT_INCOMING_CALL))
+
+BUILD_ASSERT(CONFIG_BT_L2CAP_TX_BUF_COUNT >= TBS_CLIENT_BUF_COUNT, "Too few L2CAP buffers");
 
 #include "common/bt_str.h"
 
diff --git a/tests/bluetooth/shell/audio.conf b/tests/bluetooth/shell/audio.conf
index 6a92a6e..2a76107 100644
--- a/tests/bluetooth/shell/audio.conf
+++ b/tests/bluetooth/shell/audio.conf
@@ -20,6 +20,8 @@
 CONFIG_BT_SHELL=y
 CONFIG_BT_DEVICE_NAME="audio test shell"
 CONFIG_BT_DEVICE_NAME_DYNAMIC=y
+# TBS Client may require up to 12 buffers
+CONFIG_BT_L2CAP_TX_BUF_COUNT=12
 CONFIG_BT_ID_MAX=2
 CONFIG_BT_HRS=y
 CONFIG_BT_FILTER_ACCEPT_LIST=y
diff --git a/tests/bsim/bluetooth/audio/prj.conf b/tests/bsim/bluetooth/audio/prj.conf
index a93d90c..664819d 100644
--- a/tests/bsim/bluetooth/audio/prj.conf
+++ b/tests/bsim/bluetooth/audio/prj.conf
@@ -6,6 +6,8 @@
 CONFIG_BT_CENTRAL=y
 CONFIG_BT_PERIPHERAL=y
 CONFIG_BT_DEVICE_NAME="bsim_test_audio"
+# TBS Client may require up to 12 buffers
+CONFIG_BT_L2CAP_TX_BUF_COUNT=12
 CONFIG_BT_MAX_CONN=5
 CONFIG_BT_MAX_PAIRED=5
 CONFIG_BT_GATT_DYNAMIC_DB=y