Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions host/class/uvc/usb_host_uvc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Added support for user-provided frame buffers via `user_frame_buffers` field in `uvc_host_stream_config_t.advanced`
- Added global suspend/resume support

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ static void stream_callback(const uvc_host_stream_event_data_t *event, void *use
case UVC_HOST_FRAME_BUFFER_UNDERFLOW:
ESP_LOGW(TAG, "Frame buffer underflow");
break;
#ifdef UVC_HOST_SUSPEND_RESUME_API_SUPPORTED
case UVC_HOST_DEVICE_SUSPENDED:
ESP_LOGI(TAG, "Device suspended");
break;
case UVC_HOST_DEVICE_RESUMED:
ESP_LOGI(TAG, "Device resumed");
break;
#endif // UVC_HOST_SUSPEND_RESUME_API_SUPPORTED
default:
abort();
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -62,6 +62,14 @@ void stream_callback(const uvc_host_stream_event_data_t *event, void *user_ctx)
case UVC_HOST_FRAME_BUFFER_UNDERFLOW:
ESP_LOGW(TAG, "Frame buffer underflow");
break;
#ifdef UVC_HOST_SUSPEND_RESUME_API_SUPPORTED
case UVC_HOST_DEVICE_SUSPENDED:
ESP_LOGI(TAG, "Device suspended");
break;
case UVC_HOST_DEVICE_RESUMED:
ESP_LOGI(TAG, "Device resumed");
break;
#endif // UVC_HOST_SUSPEND_RESUME_API_SUPPORTED
default:
abort();
break;
Expand Down
14 changes: 14 additions & 0 deletions host/class/uvc/usb_host_uvc/include/usb/uvc_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
extern "C" {
#endif

// For backward compatibility with IDF versions which do not have suspend/resume api
#ifdef USB_HOST_LIB_EVENT_FLAGS_AUTO_SUSPEND
#define UVC_HOST_SUSPEND_RESUME_API_SUPPORTED
#endif

typedef struct uvc_host_stream_s *uvc_host_stream_hdl_t;

enum uvc_host_driver_event {
Expand Down Expand Up @@ -100,6 +105,10 @@ enum uvc_host_dev_event {
UVC_HOST_FRAME_BUFFER_UNDERFLOW, /**< The received frame was discarded because no available buffer was free for storage.
To address this, either optimize your processing speed or increase the `number_of_frame_buffers` parameter in
`uvc_host_stream_config_t.advanced` to allocate additional buffers. */
#ifdef UVC_HOST_SUSPEND_RESUME_API_SUPPORTED
UVC_HOST_DEVICE_SUSPENDED, /**< Device was suspended. The stream is stopped. */
UVC_HOST_DEVICE_RESUMED, /**< Device was resumed. */
#endif // UVC_HOST_SUSPEND_RESUME_API_SUPPORTED
};

/**
Expand All @@ -118,6 +127,11 @@ typedef struct {
} frame_overflow; // UVC_HOST_FRAME_BUFFER_OVERFLOW
struct {
} frame_underflow; // UVC_HOST_FRAME_BUFFER_UNDERFLOW
#ifdef UVC_HOST_SUSPEND_RESUME_API_SUPPORTED
struct {
uvc_host_stream_hdl_t stream_hdl;
} device_suspended_resumed;
#endif // UVC_HOST_SUSPEND_RESUME_API_SUPPORTED
};
} uvc_host_stream_event_data_t;

Expand Down
Loading
Loading