From fdb79ac94a771ac4ec37d2ab0cee242c11624c52 Mon Sep 17 00:00:00 2001 From: Li Bo Date: Sun, 4 Feb 2024 17:40:50 +0800 Subject: [PATCH] fix(usb_stream): add miss macros of idf53 --- components/usb/usb_stream/CHANGELOG.md | 4 +++ components/usb/usb_stream/idf_component.yml | 4 +-- components/usb/usb_stream/usb_stream.c | 40 +++++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/components/usb/usb_stream/CHANGELOG.md b/components/usb/usb_stream/CHANGELOG.md index 50a487d05..9fd22de62 100644 --- a/components/usb/usb_stream/CHANGELOG.md +++ b/components/usb/usb_stream/CHANGELOG.md @@ -1,5 +1,9 @@ # ChangeLog +## v1.3.2 - 2024-02-04 + +* Fix build error under latest ESP-IDF master (5.3), due to the changes in ``usb_dwc_ll.h`` + ## v1.3.1 - 2023-12-29 ### Bug Fixes: diff --git a/components/usb/usb_stream/idf_component.yml b/components/usb/usb_stream/idf_component.yml index c96cdccb9..6b26d55a2 100644 --- a/components/usb/usb_stream/idf_component.yml +++ b/components/usb/usb_stream/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.3.1" +version: "1.3.2" targets: - esp32s2 - esp32s3 @@ -9,7 +9,7 @@ documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/us issues: https://github.com/espressif/esp-iot-solution/issues dependencies: idf: ">=4.4.1" - cmake_utilities: "0.*" + cmake_utilities: "0.5.*" examples: - path: ../../../examples/usb/host/usb_camera_mic_spk - path: ../../../examples/usb/host/usb_camera_lcd_display diff --git a/components/usb/usb_stream/usb_stream.c b/components/usb/usb_stream/usb_stream.c index ca91cc3c6..6426ab709 100644 --- a/components/usb/usb_stream/usb_stream.c +++ b/components/usb/usb_stream/usb_stream.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -28,7 +28,6 @@ #include "usb/usb_types_stack.h" #include "usb/usb_types_ch9.h" #include "usb/usb_helpers.h" -#include "esp_private/usb_phy.h" #include "usb_private.h" #include "usb_stream_descriptor.h" #include "usb_host_helpers.h" @@ -463,13 +462,38 @@ typedef struct { int periodic_out_mps; } fifo_mps_limits_t; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0) -const fifo_mps_limits_t mps_limits_default = { +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) + +#ifndef USB_DWC_FIFO_RX_LINES_DEFAULT +#define USB_DWC_FIFO_RX_LINES_DEFAULT 104 +#endif + +#ifndef USB_DWC_FIFO_NPTX_LINES_DEFAULT +#define USB_DWC_FIFO_NPTX_LINES_DEFAULT 48 +#endif + +#ifndef USB_DWC_FIFO_PTX_LINES_DEFAULT +#define USB_DWC_FIFO_PTX_LINES_DEFAULT 48 +#endif + +#ifndef USB_DWC_FIFO_RX_LINES_BIASRX +#define USB_DWC_FIFO_RX_LINES_BIASRX 152 +#endif + +#ifndef USB_DWC_FIFO_NPTX_LINES_BIASRX +#define USB_DWC_FIFO_NPTX_LINES_BIASRX 16 +#endif + +#ifndef USB_DWC_FIFO_PTX_LINES_BIASRX +#define USB_DWC_FIFO_PTX_LINES_BIASRX 32 +#endif + +const fifo_mps_limits_t s_mps_limits_default = { .in_mps = (USB_DWC_FIFO_RX_LINES_DEFAULT - 2) * 4, .non_periodic_out_mps = USB_DWC_FIFO_NPTX_LINES_DEFAULT * 4, .periodic_out_mps = USB_DWC_FIFO_PTX_LINES_DEFAULT * 4, }; -const fifo_mps_limits_t mps_limits_bias_rx = { +const fifo_mps_limits_t s_mps_limits_bias_rx = { .in_mps = (USB_DWC_FIFO_RX_LINES_BIASRX - 2) * 4, .non_periodic_out_mps = USB_DWC_FIFO_NPTX_LINES_BIASRX * 4, .periodic_out_mps = USB_DWC_FIFO_PTX_LINES_BIASRX * 4, @@ -477,6 +501,8 @@ const fifo_mps_limits_t mps_limits_bias_rx = { #else extern const fifo_mps_limits_t mps_limits_default; extern const fifo_mps_limits_t mps_limits_bias_rx; +#define s_mps_limits_default mps_limits_default +#define s_mps_limits_bias_rx mps_limits_bias_rx #endif typedef struct { @@ -3669,7 +3695,7 @@ esp_err_t usb_streaming_start() s_usb_dev.dev_addr = USB_DEVICE_ADDR; s_usb_dev.configuration = USB_CONFIG_NUM; s_usb_dev.fifo_bias = HCD_PORT_FIFO_BIAS_BALANCED; - s_usb_dev.mps_limits = &mps_limits_default; + s_usb_dev.mps_limits = &s_mps_limits_default; if (s_usb_dev.uac_cfg.spk_samples_frequence && s_usb_dev.uac_cfg.spk_bit_resolution) { //using samples_frequence and bit_resolution as enable condition @@ -3723,7 +3749,7 @@ esp_err_t usb_streaming_start() s_usb_dev.enabled[STREAM_UVC] = true; //if enable uvc, we should set fifo bias to RX s_usb_dev.fifo_bias = HCD_PORT_FIFO_BIAS_RX; - s_usb_dev.mps_limits = &mps_limits_bias_rx; + s_usb_dev.mps_limits = &s_mps_limits_bias_rx; } 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_);