Skip to content

Commit

Permalink
Merge branch 'fix/usb_stream_idf53_build' into 'master'
Browse files Browse the repository at this point in the history
fix(usb_stream): add miss macros of idf53

Closes AEG-1308

See merge request ae_group/esp-iot-solution!950
  • Loading branch information
leeebo committed Feb 4, 2024
2 parents f37a267 + fdb79ac commit 65c3166
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
4 changes: 4 additions & 0 deletions components/usb/usb_stream/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions components/usb/usb_stream/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.3.1"
version: "1.3.2"
targets:
- esp32s2
- esp32s3
Expand All @@ -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
Expand Down
40 changes: 33 additions & 7 deletions components/usb/usb_stream/usb_stream.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -463,20 +462,47 @@ 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,
};
#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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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_);

Expand Down

0 comments on commit 65c3166

Please sign in to comment.