From ca8354932c5540f8ed075629d7705ceae118bd30 Mon Sep 17 00:00:00 2001 From: wangjialiang Date: Fri, 3 Apr 2026 17:10:40 +0800 Subject: [PATCH] fix(ble): support ble iso for esp32h4 eco1 --- components/bt/host/bluedroid/Kconfig.in | 2 +- .../host/bluedroid/bta/include/bta/bta_api.h | 1 + .../bt/host/bluedroid/hci/ble_hci_iso.c | 15 ++++++++++++--- components/bt/host/bluedroid/hci/hci_hal_h4.c | 17 ----------------- .../bluedroid/hci/include/hci/ble_hci_iso.h | 1 + components/bt/host/nimble/Kconfig.in | 12 ++++++------ components/bt/host/nimble/nimble | 2 +- .../transport/include/esp_hci_internal.h | 19 ++----------------- 8 files changed, 24 insertions(+), 45 deletions(-) diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index bb981404eb..3fb9211179 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -1437,7 +1437,7 @@ config BT_BLE_FEAT_CREATE_SYNC_RETRY_MAX menuconfig BT_BLE_FEAT_ISO_EN bool "Enable BLE 5.2 iso feature" - depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_AUDIO_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR + depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_ISO_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR default n help Enable BLE 5.2 iso diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_api.h index 7a6594c2dd..2237d73364 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -3074,6 +3074,7 @@ extern void BTA_DmBleGapIsoBigSyncTerminate(tBTA_DM_BLE_BIG_SYNC_TERMINATE_PARAM extern void BTA_DmBleGapIsoDataPathSet(tBTA_DM_BLE_ISO_SET_DATA_PATH_PARAMS *p_iso_data_path_param); extern void BTA_DmBleGapIsoDataPathRemove(tBTA_DM_BLE_ISO_REMOVE_DATA_PATH_PARAMS *p_iso_data_path_param); extern void BTA_DmBleGapIsoReadTxSync(uint16_t iso_handle); +extern void BTA_DmBleGapIsoReadLinkQuality(uint16_t iso_handle); #if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE) extern void BTA_DmBleIsoSetCigParams(uint8_t cig_id, uint32_t sdu_int_c_to_p, uint32_t sdu_int_p_to_c, uint8_t worse_case_SCA, uint8_t packing, uint8_t framing, uint16_t mtl_c_to_p, uint16_t mtl_p_to_c, uint8_t cis_cnt, uint8_t *cis_params); diff --git a/components/bt/host/bluedroid/hci/ble_hci_iso.c b/components/bt/host/bluedroid/hci/ble_hci_iso.c index 92db66d311..49632b67d3 100644 --- a/components/bt/host/bluedroid/hci/ble_hci_iso.c +++ b/components/bt/host/bluedroid/hci/ble_hci_iso.c @@ -22,6 +22,7 @@ #include "hci/ble_hci_iso.h" #include "common/bt_target.h" #include "osi/mutex.h" +#include "esp_hci_internal.h" #if (BLE_FEAT_ISO_EN == TRUE) @@ -79,6 +80,15 @@ ble_hci_set_iso_buf_sz(uint16_t pktlen, uint8_t max_pkts) return 0; } +void +ble_hci_get_iso_buf_size(uint16_t *pktlen, uint8_t *max_pkts) +{ + assert(pktlen && max_pkts); + + *pktlen = ble_hs_iso_buf_sz; + *max_pkts = ble_hs_iso_max_pkts; +} + #define BLE_ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) struct ble_hci_iso_conn * @@ -169,7 +179,6 @@ ble_hci_tx_iso_data(const uint8_t *data, uint16_t len, void *arg) int rc = 1; #if CONFIG_BT_LE_ISO_SUPPORT // return ble_transport_to_ll_iso(data, len, arg); - extern int ble_hci_trans_hs_iso_tx(const uint8_t *data, uint16_t length, void *arg); rc = ble_hci_trans_hs_iso_tx(data, len, arg); #endif // #if CONFIG_BT_LE_ISO_SUPPORT return rc; @@ -193,8 +202,8 @@ ble_hci_iso_tx_now(struct ble_hci_iso_conn *conn, const uint8_t *sdu, return 1; } #elif (BLE_ISO_NON_STD_FLOW_CTRL == TRUE) - extern uint16_t ble_ll_iso_free_buf_num_get(uint16_t conn_handle); - if (ble_ll_iso_free_buf_num_get(conn->conn_handle) == 0) { + extern uint16_t r_ble_ll_iso_free_buf_num_get(uint16_t conn_handle); + if (r_ble_ll_iso_free_buf_num_get(conn->conn_handle) == 0) { HCI_TRACE_ERROR("ISO flow control!\n"); return 1; } diff --git a/components/bt/host/bluedroid/hci/hci_hal_h4.c b/components/bt/host/bluedroid/hci/hci_hal_h4.c index a1f12bb9bf..cb53e8c479 100644 --- a/components/bt/host/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/host/bluedroid/hci/hci_hal_h4.c @@ -240,23 +240,6 @@ typedef void ble_host_rx_iso_data_fn(uint8_t *data, uint16_t len); static ble_host_rx_iso_data_fn *ble_host_iso_rx_cb = NULL; -void ble_host_register_rx_iso_data_cb(void *cb) -{ - /* If the iso rx cb is already registered, we will give - * a warning log here, and the cb will still be updated. - */ - if (ble_host_iso_rx_cb) { - HCI_TRACE_WARNING("iso rx cb %p already registered\n", ble_host_iso_rx_cb); - } - - ble_host_iso_rx_cb = cb; -} - -void ble_hci_register_rx_iso_data_cb(void *cb) -{ - ble_host_register_rx_iso_data_cb(cb); -} - #endif // #if (BLE_FEAT_ISO_EN == TRUE) // Internal functions diff --git a/components/bt/host/bluedroid/hci/include/hci/ble_hci_iso.h b/components/bt/host/bluedroid/hci/include/hci/ble_hci_iso.h index 4394363ead..f2b714a207 100644 --- a/components/bt/host/bluedroid/hci/include/hci/ble_hci_iso.h +++ b/components/bt/host/bluedroid/hci/include/hci/ble_hci_iso.h @@ -68,6 +68,7 @@ struct ble_hci_iso_conn { }; int ble_hci_set_iso_buf_sz(uint16_t pktlen, uint8_t max_pkts); +void ble_hci_get_iso_buf_size(uint16_t *pktlen, uint8_t *max_pkts); struct ble_hci_iso_conn *ble_hci_iso_conn_find(uint16_t conn_handle); diff --git a/components/bt/host/nimble/Kconfig.in b/components/bt/host/nimble/Kconfig.in index afe5f2f17d..692711f52d 100644 --- a/components/bt/host/nimble/Kconfig.in +++ b/components/bt/host/nimble/Kconfig.in @@ -768,15 +768,15 @@ menu "BLE 5.x Features" config BT_NIMBLE_ISO_BIS int "Maximum number of BIS" - range 1 3 + range 1 6 default 2 help Maximum number of BIS. config BT_NIMBLE_ISO_BIS_PER_BIG int "Maximum number of BIS per BIG" - range 1 3 - default 2 + range 1 BT_NIMBLE_ISO_BIS + default BT_NIMBLE_ISO_BIS help Maximum number of BIS per BIG. @@ -789,15 +789,15 @@ menu "BLE 5.x Features" config BT_NIMBLE_ISO_CIS int "Maximum number of CIS" - range 1 3 + range 1 6 default 2 help Maximum number of CIS. config BT_NIMBLE_ISO_CIS_PER_CIG int "Maximum number of CIS per CIG" - range 1 3 - default 2 + range 1 BT_NIMBLE_ISO_CIS + default BT_NIMBLE_ISO_CIS help Maximum number of CIS per CIG. diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index b683865655..e8d3aced0e 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit b683865655bc99dc35ac40b238dbd63f3086a632 +Subproject commit e8d3aced0e1d6cb7d49744502667cca45ab84d91 diff --git a/components/bt/porting_btdm/transport/include/esp_hci_internal.h b/components/bt/porting_btdm/transport/include/esp_hci_internal.h index ee75e7d0b5..18320ae413 100644 --- a/components/bt/porting_btdm/transport/include/esp_hci_internal.h +++ b/components/bt/porting_btdm/transport/include/esp_hci_internal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -40,18 +40,8 @@ typedef int esp_hci_internal_rx_iso_fn(const uint8_t *data, uint16_t len, void * void r_ble_iso_trans_cfg_hs(esp_hci_internal_rx_iso_fn *iso_cb, void *iso_arg); #define ble_iso_trans_cfg_hs r_ble_iso_trans_cfg_hs -/** - * @brief Transmit ISO (Isochronous) data over BLE HCItransport. - * - * @param data Pointer to the ISO data buffer to be transmitted. - * @param length Length of the ISO data in bytes. - * @param arg Optional user-defined argument, passed through - * the transport layer and may be used by the underlying driver or callback. - * - * @return 0 on success, or a non-zero error code on failure. - */ -int r_ble_hci_trans_hs_iso_tx(const uint8_t *data, uint16_t length, void *arg); +extern int r_ble_hci_trans_hs_iso_tx(const uint8_t *data, uint16_t length, void *arg); #define ble_hci_trans_hs_iso_tx r_ble_hci_trans_hs_iso_tx #endif // CONFIG_BT_LE_ISO_SUPPORT /** @@ -90,11 +80,6 @@ int r_ble_hci_trans_hs_acl_tx(struct ble_mbuf *om); */ int r_ble_hci_trans_hs_cmd_tx(uint8_t *cmd); - -#if CONFIG_BT_LE_ISO_SUPPORT -int ble_hci_trans_hs_iso_tx(const uint8_t *data, uint16_t length, void *arg); -#endif /* CONFIG_BT_LE_ISO_SUPPORT */ - /** * Allocates a flat buffer of the specified type. *