From 28c8cf401fb1f5d71fe29ca0ead238825d0abc8d Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Wed, 6 Mar 2024 10:01:50 +0100 Subject: [PATCH 1/4] fix(host/uvc): Bump libuvc version to relax video format negotiation --- host/class/uvc/usb_host_uvc/libuvc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/class/uvc/usb_host_uvc/libuvc b/host/class/uvc/usb_host_uvc/libuvc index 68d07a00..047920bc 160000 --- a/host/class/uvc/usb_host_uvc/libuvc +++ b/host/class/uvc/usb_host_uvc/libuvc @@ -1 +1 @@ -Subproject commit 68d07a00e11d1944e27b7295ee69673239c00b4b +Subproject commit 047920bcdfb1dac42424c90de5cc77dfc9fba04d From 45f85acafe80b68984533f234135839d455dbc61 Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Wed, 6 Mar 2024 11:06:46 +0100 Subject: [PATCH 2/4] fix(host/uvc): Fix crash on opening non-UVC devices --- host/class/uvc/usb_host_uvc/src/descriptor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/host/class/uvc/usb_host_uvc/src/descriptor.c b/host/class/uvc/usb_host_uvc/src/descriptor.c index 531fbd3c..3eef600f 100644 --- a/host/class/uvc/usb_host_uvc/src/descriptor.c +++ b/host/class/uvc/usb_host_uvc/src/descriptor.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -190,8 +190,8 @@ int parse_configuration(libusb_config_descriptor_t *config, const uint8_t *buffe LIBUSB_GOTO_ON_FALSE(interface->altsetting); for (int ep = 0; ep < endpoints; ep++) { - ep_desc = usb_parse_endpoint_descriptor_by_index(ifc_desc, ep, config->wTotalLength, &offset); - ifc_desc = (const usb_intf_desc_t *)ep_desc; + int intf_offset = offset; // Current offset is interface offset in the configuration descriptor + ep_desc = usb_parse_endpoint_descriptor_by_index(ifc_desc, ep, config->wTotalLength, &intf_offset); libusb_endpoint_descriptor_t *endpoint = &altsetting->endpoint[ep]; copy_endpoint_desc(endpoint, ep_desc); LIBUSB_GOTO_ON_ERROR( add_extra_data(&extra, ep_desc) ); From ea0b3bf98fe07c09e9bbc4009038bff64c730adb Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Wed, 6 Mar 2024 12:18:16 +0100 Subject: [PATCH 3/4] release(usb/uvc): Release UVC driver v1.0.3 --- host/class/uvc/usb_host_uvc/CHANGELOG.md | 18 ++++++++++++++++++ host/class/uvc/usb_host_uvc/README.md | 1 + host/class/uvc/usb_host_uvc/idf_component.yml | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 host/class/uvc/usb_host_uvc/CHANGELOG.md diff --git a/host/class/uvc/usb_host_uvc/CHANGELOG.md b/host/class/uvc/usb_host_uvc/CHANGELOG.md new file mode 100644 index 00000000..6b7a9806 --- /dev/null +++ b/host/class/uvc/usb_host_uvc/CHANGELOG.md @@ -0,0 +1,18 @@ +## 1.0.3 + +- Added support for ESP32-P4 +- Bumped libuvc version to relax frame format negotiation +- Fixed crash on opening non-UVC devices + +## 1.0.2 + +- Updated libuvc library to 0.0.7 https://github.com/libuvc/libuvc/tree/v0.0.7 +- Added Software BoM information + +## 1.0.1 + +- Fixed compatibility with IDF v4.4 + +## 1.0.0 + +- Initial version diff --git a/host/class/uvc/usb_host_uvc/README.md b/host/class/uvc/usb_host_uvc/README.md index 885f7103..b8398839 100644 --- a/host/class/uvc/usb_host_uvc/README.md +++ b/host/class/uvc/usb_host_uvc/README.md @@ -21,3 +21,4 @@ Following two supported formats are the most common (both encoded in MJPEG): ## Tested cameras * Logitech C980 * CANYON CNE-CWC2 + * Logitech C270 diff --git a/host/class/uvc/usb_host_uvc/idf_component.yml b/host/class/uvc/usb_host_uvc/idf_component.yml index 5573da47..0096d1f7 100644 --- a/host/class/uvc/usb_host_uvc/idf_component.yml +++ b/host/class/uvc/usb_host_uvc/idf_component.yml @@ -1,5 +1,5 @@ ## IDF Component Manager Manifest File -version: "1.0.2~1" +version: "1.0.3" description: USB Host UVC driver url: https://github.com/espressif/esp-usb/tree/master/host/class/uvc/usb_host_uvc dependencies: From 83cf7019fcb0d49197aedc89460a6c4114e944e5 Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Fri, 8 Mar 2024 12:56:56 +0100 Subject: [PATCH 4/4] fear(host/uvc): Add libuvc_get_usb_device_info() function This allows users to get detailed information about underlying USB device. Closes https://github.com/espressif/esp-usb/issues/19 --- host/class/uvc/usb_host_uvc/CHANGELOG.md | 1 + .../uvc/usb_host_uvc/include/libuvc_adapter.h | 12 ++++++++++- .../uvc/usb_host_uvc/src/libusb_adapter.c | 20 ++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/host/class/uvc/usb_host_uvc/CHANGELOG.md b/host/class/uvc/usb_host_uvc/CHANGELOG.md index 6b7a9806..42b00c3e 100644 --- a/host/class/uvc/usb_host_uvc/CHANGELOG.md +++ b/host/class/uvc/usb_host_uvc/CHANGELOG.md @@ -3,6 +3,7 @@ - Added support for ESP32-P4 - Bumped libuvc version to relax frame format negotiation - Fixed crash on opening non-UVC devices +- Added `libuvc_get_usb_device_info` function ## 1.0.2 diff --git a/host/class/uvc/usb_host_uvc/include/libuvc_adapter.h b/host/class/uvc/usb_host_uvc/include/libuvc_adapter.h index afb3390c..64ffebaf 100644 --- a/host/class/uvc/usb_host_uvc/include/libuvc_adapter.h +++ b/host/class/uvc/usb_host_uvc/include/libuvc_adapter.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,6 +8,8 @@ #include #include #include "esp_err.h" +#include "usb/usb_types_stack.h" +#include "libuvc/libuvc.h" #ifdef __cplusplus extern "C" { @@ -60,6 +62,14 @@ esp_err_t libuvc_adapter_print_descriptors(uvc_device_handle_t *device); */ esp_err_t libuvc_adapter_handle_events(uint32_t timeout_ms); +/** + * @brief Get information about underlying USB device + * + * @param[in] dev UVC device handle obtained from uvc_find_device() + * @param[out] dev_info Pointer to structure where the information will be saved + */ +esp_err_t libuvc_get_usb_device_info(uvc_device_t *dev, usb_device_info_t *dev_info); + #ifdef __cplusplus } #endif diff --git a/host/class/uvc/usb_host_uvc/src/libusb_adapter.c b/host/class/uvc/usb_host_uvc/src/libusb_adapter.c index 48569212..25de0f3e 100644 --- a/host/class/uvc/usb_host_uvc/src/libusb_adapter.c +++ b/host/class/uvc/usb_host_uvc/src/libusb_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -192,6 +192,24 @@ esp_err_t libuvc_adapter_print_descriptors(uvc_device_handle_t *device) return ESP_OK; } +esp_err_t libuvc_get_usb_device_info(uvc_device_t *dev, usb_device_info_t *dev_info) +{ + uvc_error_t ret; + struct libusb_device_handle *usb_devh; + + ret = libusb_open(dev->usb_dev, &usb_devh); + UVC_DEBUG("libusb_open() = %d", ret); + if (ret != UVC_SUCCESS) { + return ESP_FAIL; + } + + uvc_camera_t *camera = (uvc_camera_t *)(usb_devh); + RETURN_ON_ERROR( usb_host_device_info(camera->handle, dev_info) ); + + libusb_close(usb_devh); + return ESP_OK; +} + esp_err_t libuvc_adapter_handle_events(uint32_t timeout_ms) { if (s_uvc_driver == NULL) {