Skip to content

Commit d6b2c33

Browse files
committed
Merge branch 'fix/fix_usb_stream_fifo_bias' into 'master'
fix(usb_stream): fix compilation issue caused by fifo_bias See merge request ae_group/esp-iot-solution!1317
2 parents 8eb7bba + b2c78e2 commit d6b2c33

File tree

8 files changed

+39
-7
lines changed

8 files changed

+39
-7
lines changed

.gitlab/ci/build.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,10 +1670,7 @@ build_components_usb_usb_stream_test_apps:
16701670
extends:
16711671
- .build_examples_template
16721672
- .rules:build:components_usb_usb_stream_test
1673-
parallel:
1674-
matrix:
1675-
- IMAGE: espressif/idf:release-v5.0
1676-
- IMAGE: espressif/idf:release-v5.4
1673+
- .build_idf_active_release_version
16771674
variables:
16781675
EXAMPLE_DIR: components/usb/usb_stream/test_apps
16791676

components/usb/usb_stream/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog
22

3+
## v1.5.1 - 2025-7-15
4+
5+
### Bug Fixes:
6+
7+
* Fix compilation errors on esp-idf release v5.3 and above.
8+
39
## v1.5.0 - 2024-12-10
410

511
### Improvements:

components/usb/usb_stream/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Features:
1111
3. Support volume, mute and other features control through the UAC Control interface
1212
4. Support stream separately suspend and resume
1313

14+
> Note: For ESP-IDF V5.3.3 and above, if you enable UVC, please also enable `Bias IN` in `Component config → USB-OTG → Hardware FIFO size biasing`.
15+
1416
### USB Stream User Guide
1517

1618
Please refer: https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_host/usb_stream.html

components/usb/usb_stream/README_CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
3. 支持通过 UAC Control 接口控制麦克风音量、静音等特性
1212
4. 支持对数据流暂停和恢复
1313

14+
> Note: 对于 ESP-IDF V5.3.3 及以上的版本,若使能 UVC,请在 `Component config → USB-OTG → Hardware FIFO size biasing` 中使能 `Bias IN`
15+
1416
### USB Stream 用户指南
1517

1618
请参考:https://docs.espressif.com/projects/esp-iot-solution/zh_CN/latest/usb/usb_host/usb_stream.html

components/usb/usb_stream/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.5.0"
1+
version: "1.5.1"
22
targets:
33
- esp32s2
44
- esp32s3

components/usb/usb_stream/test_apps/sdkconfig.ci.quick

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y
77

88
# Enable Quick start mode
99
CONFIG_USB_STREAM_QUICK_START=y
10+
CONFIG_USB_HOST_HW_BUFFER_BIAS_IN=y

components/usb/usb_stream/usb_host_helpers.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -14,6 +14,7 @@
1414
#include "esp_private/usb_phy.h"
1515
#include "usb_host_helpers.h"
1616
#include "esp_intr_alloc.h"
17+
#include "esp_bit_defs.h"
1718

1819
#define USB_PORT_NUM 1 //Default port number
1920
static const char *TAG = "USB_STREAM";
@@ -195,16 +196,31 @@ hcd_port_handle_t _usb_port_init(hcd_port_callback_t callback, void *callback_ar
195196
UVC_CHECK(ESP_OK == ret, "USB PHY init failed", NULL);
196197
hcd_config_t hcd_config = {
197198
.intr_flags = ESP_INTR_FLAG_LEVEL2,
199+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 1)
200+
.peripheral_map = BIT0,
201+
.fifo_config = NULL,
202+
#endif
198203
};
199204
ret = hcd_install(&hcd_config);
200205
UVC_CHECK_GOTO(ESP_OK == ret, "HCD Install failed", hcd_init_err);
201206
hcd_port_config_t port_cfg = {
207+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 3)
202208
.fifo_bias = HCD_PORT_FIFO_BIAS_BALANCED,
209+
#endif
203210
.callback = callback,
204211
.callback_arg = callback_arg,
205212
.context = phy_handle,
206213
};
214+
215+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 1)
216+
int root_port_index = 0;
217+
if (hcd_config.peripheral_map & BIT1) {
218+
root_port_index = 1;
219+
}
220+
ret = hcd_port_init(root_port_index, &port_cfg, &port_hdl);
221+
#else
207222
ret = hcd_port_init(USB_PORT_NUM, &port_cfg, &port_hdl);
223+
#endif
208224
UVC_CHECK_GOTO(ESP_OK == ret, "HCD Port init failed", port_init_err);
209225
ret = hcd_port_command(port_hdl, HCD_PORT_CMD_POWER_ON);
210226
UVC_CHECK_GOTO(ESP_OK == ret, "HCD Port Power on failed", port_power_err);

components/usb/usb_stream/usb_stream.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -512,7 +512,9 @@ typedef struct {
512512
// const values after usb stream start
513513
bool enabled[STREAM_MAX];
514514
hcd_port_handle_t port_hdl;
515+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 3)
515516
hcd_port_fifo_bias_t fifo_bias;
517+
#endif
516518
const fifo_mps_limits_t *mps_limits;
517519
uint16_t configuration;
518520
uint8_t dev_addr;
@@ -3353,8 +3355,10 @@ static void _usb_processing_task(void *arg)
33533355
continue;
33543356
}
33553357
reset_retry = 3;
3358+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 3)
33563359
ESP_LOGI(TAG, "Setting Port FIFO, %d", usb_dev->fifo_bias);
33573360
ESP_ERROR_CHECK(hcd_port_set_fifo_bias(usb_dev->port_hdl, usb_dev->fifo_bias));
3361+
#endif
33583362
action_bits &= ~ACTION_DEVICE_CONNECT;
33593363
action_bits |= ACTION_DEVICE_ENUM;
33603364
usb_dev->enum_stage = ENUM_STAGE_NONE;
@@ -3706,7 +3710,9 @@ esp_err_t usb_streaming_start()
37063710
s_usb_dev.dev_speed = USB_SPEED_FULL;
37073711
s_usb_dev.dev_addr = USB_DEVICE_ADDR;
37083712
s_usb_dev.configuration = USB_CONFIG_NUM;
3713+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 3)
37093714
s_usb_dev.fifo_bias = HCD_PORT_FIFO_BIAS_BALANCED;
3715+
#endif
37103716
s_usb_dev.mps_limits = &s_mps_limits_default;
37113717

37123718
if (s_usb_dev.uac_cfg.spk_samples_frequence && s_usb_dev.uac_cfg.spk_bit_resolution) {
@@ -3760,7 +3766,9 @@ esp_err_t usb_streaming_start()
37603766
ESP_LOGD(TAG, "Camera instance created");
37613767
s_usb_dev.enabled[STREAM_UVC] = true;
37623768
//if enable uvc, we should set fifo bias to RX
3769+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 3)
37633770
s_usb_dev.fifo_bias = HCD_PORT_FIFO_BIAS_RX;
3771+
#endif
37643772
s_usb_dev.mps_limits = &s_mps_limits_bias_rx;
37653773
}
37663774
UVC_CHECK_GOTO(s_usb_dev.enabled[STREAM_UAC_MIC] == true || s_usb_dev.enabled[STREAM_UAC_SPK] == true || s_usb_dev.enabled[STREAM_UVC] == true, "uac/uvc streaming not configured", free_resource_);

0 commit comments

Comments
 (0)