espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.81k stars 7.32k forks source link

C270 UVC Configuration description caught by esp32s3 wrong (IDFGH-13985) #14811

Open shenqili opened 3 weeks ago

shenqili commented 3 weeks ago

Answers checklist.

IDF version.

v5.3.1

Espressif SoC revision.

ESP32S3

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32-S3-DEV-KIT-N8R8

Power Supply used.

External 5V

What is the expected behavior?

I want to use Logitech C270 with esp32s3 to capture video and pictures

What is the actual behavior?

I have run the two project with the Logitech C270 which is supported by esp-idf and both failed. https://gitcode.com/gh_mirrors/es/esp-iot-solution/tree/master/examples/usb/host/usb_camera_mic_spk https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/uvc

In project of usb_camera_mic_spk I have got the wrong part of the UVC Configuration description without the video format descriptions part.

And in project of uvc. I have got the wrong part of the UVC Configuration description without the video format descriptions part. The supported video formats are not gotten by the esp32s3, which only shows the 160*120, 10frames,Uncompressed format.

ucvLog.txt usb_camera_mic_spk.txt

Steps to reproduce.

  1. Set the C270 and the esp32s3 (Use a USB hub with power supply to power the camera and ESP32 at the same time 微信图片_20241101095037 ) 微信图片_20241101095030

  2. Build the project and finish the menuconfig

  3. Run the project

Here is the main.c:

/*

include

include

include

include

include "freertos/FreeRTOS.h"

include "freertos/event_groups.h"

include "freertos/task.h"

include "esp_err.h"

include "esp_log.h"

include "usb_stream.h"

include "esp_camera.h"

ifdef CONFIG_ESP32_S3_USB_OTG

include "bsp/esp-bsp.h"

endif

static const char *TAG = "uvc_mic_spk_demo"; /** configure the example working mode ***/

define ENABLE_UVC_CAMERA_FUNCTION 1 / enable uvc function /

define ENABLE_UAC_MIC_SPK_FUNCTION 0 / enable uac mic+spk function /

if (ENABLE_UVC_CAMERA_FUNCTION)

define ENABLE_UVC_FRAME_RESOLUTION_ANY 1 / Using any resolution found from the camera /

define ENABLE_UVC_WIFI_XFER 0 / transfer uvc frame to wifi http /

endif

if (ENABLE_UAC_MIC_SPK_FUNCTION)

define ENABLE_UAC_MIC_SPK_LOOPBACK 0 / transfer mic data to speaker /

static uint32_t s_mic_samples_frequence = 0; static uint32_t s_mic_ch_num = 0; static uint32_t s_mic_bit_resolution = 0; static uint32_t s_spk_samples_frequence = 0; static uint32_t s_spk_ch_num = 0; static uint32_t s_spk_bit_resolution = 0;

endif

define BIT0_FRAME_START (0x01 << 0)

define BIT1_NEW_FRAME_START (0x01 << 1)

define BIT2_NEW_FRAME_END (0x01 << 2)

define BIT3_SPK_START (0x01 << 3)

define BIT4_SPK_RESET (0x01 << 4)

static EventGroupHandle_t s_evt_handle;

if (ENABLE_UVC_CAMERA_FUNCTION)

if (ENABLE_UVC_FRAME_RESOLUTION_ANY)

define DEMO_UVC_FRAME_WIDTH 320

define DEMO_UVC_FRAME_HEIGHT 240

else

define DEMO_UVC_FRAME_WIDTH 480

define DEMO_UVC_FRAME_HEIGHT 320

endif

ifdef CONFIG_IDF_TARGET_ESP32S2

define DEMO_UVC_XFER_BUFFER_SIZE (45 * 1024)

else

define DEMO_UVC_XFER_BUFFER_SIZE (55 * 1024)

endif

if (ENABLE_UVC_WIFI_XFER)

include "app_wifi.h"

include "app_httpd.h"

include "esp_camera.h"

static camera_fb_t s_fb = {0};

camera_fb_t *esp_camera_fb_get() { xEventGroupSetBits(s_evt_handle, BIT0_FRAME_START); xEventGroupWaitBits(s_evt_handle, BIT1_NEW_FRAME_START, true, true, portMAX_DELAY); return &s_fb; }

void esp_camera_fb_return(camera_fb_t *fb) { xEventGroupSetBits(s_evt_handle, BIT2_NEW_FRAME_END); return; }

static void camera_frame_cb(uvc_frame_t frame, void ptr) { ESP_LOGI(TAG, "uvc callback! frame_format = %d, seq = %"PRIu32", width = %"PRIu32", height = %"PRIu32", length = %u, ptr = %d", frame->frame_format, frame->sequence, frame->width, frame->height, frame->data_bytes, (int) ptr); if (!(xEventGroupGetBits(s_evt_handle) & BIT0_FRAME_START)) { return; }

switch (frame->frame_format) {
case UVC_FRAME_FORMAT_MJPEG:
    s_fb.buf = frame->data;
    s_fb.len = frame->data_bytes;
    s_fb.width = frame->width;
    s_fb.height = frame->height;
    s_fb.buf = frame->data;
    s_fb.format = PIXFORMAT_JPEG;
    s_fb.timestamp.tv_sec = frame->sequence;
    xEventGroupSetBits(s_evt_handle, BIT1_NEW_FRAME_START);
    ESP_LOGV(TAG, "send frame = %"PRIu32"", frame->sequence);
    xEventGroupWaitBits(s_evt_handle, BIT2_NEW_FRAME_END, true, true, portMAX_DELAY);
    ESP_LOGV(TAG, "send frame done = %"PRIu32"", frame->sequence);
    break;
default:
    ESP_LOGW(TAG, "Format not supported");
    assert(0);
    break;
}

}

else

static void camera_frame_cb(uvc_frame_t frame, void ptr) { ESP_LOGI(TAG, "uvc callback! frame_format = %d, seq = %"PRIu32", width = %"PRIu32", height = %"PRIu32", length = %u, ptr = %d", frame->frame_format, frame->sequence, frame->width, frame->height, frame->data_bytes, (int) ptr); }

endif //ENABLE_UVC_WIFI_XFER

endif //ENABLE_UVC_CAMERA_FUNCTION

if (ENABLE_UAC_MIC_SPK_FUNCTION)

static void mic_frame_cb(mic_frame_t frame, void ptr) { // We should using higher baudrate here, to reduce the blocking time here ESP_LOGD(TAG, "mic callback! bit_resolution = %u, samples_frequence = %"PRIu32", data_bytes = %"PRIu32, frame->bit_resolution, frame->samples_frequence, frame->data_bytes); // We should never block in mic callback!

if (ENABLE_UAC_MIC_SPK_LOOPBACK)

uac_spk_streaming_write(frame->data, frame->data_bytes, 0);

endif //ENABLE_UAC_MIC_SPK_LOOPBACK

}

endif //ENABLE_UAC_MIC_SPK_FUNCTION

static void stream_state_changed_cb(usb_stream_state_t event, void *arg) { switch (event) { case STREAM_CONNECTED: { size_t frame_size = 0; size_t frame_index = 0;

if (ENABLE_UVC_CAMERA_FUNCTION)

    ESP_LOGI(TAG, "========ENABLE READING DESCRIPTION===========");
    vTaskDelay(pdMS_TO_TICKS(100)); 
    uvc_frame_size_list_get(NULL, &frame_size, &frame_index);
    if (frame_size) {
        ESP_LOGI(TAG, "UVC: get frame list size = %u, current = %u", frame_size, frame_index);
        uvc_frame_size_t *uvc_frame_list = (uvc_frame_size_t *)malloc(frame_size * sizeof(uvc_frame_size_t));
        uvc_frame_size_list_get(uvc_frame_list, NULL, NULL);
        for (size_t i = 0; i < frame_size; i++) {
            ESP_LOGI(TAG, "\tframe[%u] = %ux%u", i, uvc_frame_list[i].width, uvc_frame_list[i].height);
        }
        free(uvc_frame_list);
    } else {
        ESP_LOGW(TAG, "UVC: get frame list size = %u", frame_size);
    }

endif

if (ENABLE_UAC_MIC_SPK_FUNCTION)

    uac_frame_size_list_get(STREAM_UAC_MIC, NULL, &frame_size, &frame_index);
    if (frame_size) {
        ESP_LOGI(TAG, "UAC MIC: get frame list size = %u, current = %u", frame_size, frame_index);
        uac_frame_size_t *mic_frame_list = (uac_frame_size_t *)malloc(frame_size * sizeof(uac_frame_size_t));
        uac_frame_size_list_get(STREAM_UAC_MIC, mic_frame_list, NULL, NULL);
        for (size_t i = 0; i < frame_size; i++) {
            ESP_LOGI(TAG, "\t [%u] ch_num = %u, bit_resolution = %u, samples_frequence = %"PRIu32 ", samples_frequence_min = %"PRIu32 ", samples_frequence_max = %"PRIu32,
                     i, mic_frame_list[i].ch_num, mic_frame_list[i].bit_resolution, mic_frame_list[i].samples_frequence,
                     mic_frame_list[i].samples_frequence_min, mic_frame_list[i].samples_frequence_max);
        }
        s_mic_samples_frequence = mic_frame_list[frame_index].samples_frequence;
        s_mic_ch_num = mic_frame_list[frame_index].ch_num;
        s_mic_bit_resolution = mic_frame_list[frame_index].bit_resolution;
        if (s_mic_ch_num != 1) {
            ESP_LOGW(TAG, "UAC MIC: only support 1 channel in this example");
        }
        ESP_LOGI(TAG, "UAC MIC: use frame[%u] ch_num = %"PRIu32", bit_resolution = %"PRIu32", samples_frequence = %"PRIu32,
                 frame_index, s_mic_ch_num, s_mic_bit_resolution, s_mic_samples_frequence);
        free(mic_frame_list);
    } else {
        ESP_LOGW(TAG, "UAC MIC: get frame list size = %u", frame_size);
    }

    uac_frame_size_list_get(STREAM_UAC_SPK, NULL, &frame_size, &frame_index);
    if (frame_size) {
        ESP_LOGI(TAG, "UAC SPK: get frame list size = %u, current = %u", frame_size, frame_index);
        uac_frame_size_t *spk_frame_list = (uac_frame_size_t *)malloc(frame_size * sizeof(uac_frame_size_t));
        uac_frame_size_list_get(STREAM_UAC_SPK, spk_frame_list, NULL, NULL);
        for (size_t i = 0; i < frame_size; i++) {
            ESP_LOGI(TAG, "\t [%u] ch_num = %u, bit_resolution = %u, samples_frequence = %"PRIu32 ", samples_frequence_min = %"PRIu32 ", samples_frequence_max = %"PRIu32,
                     i, spk_frame_list[i].ch_num, spk_frame_list[i].bit_resolution, spk_frame_list[i].samples_frequence,
                     spk_frame_list[i].samples_frequence_min, spk_frame_list[i].samples_frequence_max);
        }
        if (s_spk_samples_frequence != spk_frame_list[frame_index].samples_frequence
                || s_spk_ch_num != spk_frame_list[frame_index].ch_num
                || s_spk_bit_resolution != spk_frame_list[frame_index].bit_resolution) {
            if (s_spk_samples_frequence) {
                xEventGroupSetBits(s_evt_handle, BIT4_SPK_RESET);
            }
            s_spk_samples_frequence = spk_frame_list[frame_index].samples_frequence;
            s_spk_ch_num = spk_frame_list[frame_index].ch_num;
            s_spk_bit_resolution = spk_frame_list[frame_index].bit_resolution;
        }
        xEventGroupSetBits(s_evt_handle, BIT3_SPK_START);
        if (s_spk_ch_num != 1) {
            ESP_LOGW(TAG, "UAC SPK: only support 1 channel in this example");
        }
        ESP_LOGI(TAG, "UAC SPK: use frame[%u] ch_num = %"PRIu32", bit_resolution = %"PRIu32", samples_frequence = %"PRIu32,
                 frame_index, s_spk_ch_num, s_spk_bit_resolution, s_spk_samples_frequence);
        free(spk_frame_list);
    } else {
        ESP_LOGW(TAG, "UAC SPK: get frame list size = %u", frame_size);
    }

endif

    ESP_LOGI(TAG, "Device connected");
    break;
}
case STREAM_DISCONNECTED:
    ESP_LOGI(TAG, "Device disconnected");
    break;
default:
    ESP_LOGE(TAG, "Unknown event");
    break;
}

}

void app_main(void) {

ifdef CONFIG_ESP32_S3_USB_OTG

bsp_usb_mode_select_host();
bsp_usb_host_power_mode(BSP_USB_HOST_POWER_MODE_USB_DEV, true);

endif

esp_log_level_set("*", ESP_LOG_INFO);
esp_log_level_set("httpd_txrx", ESP_LOG_INFO);
esp_err_t ret = ESP_FAIL;
s_evt_handle = xEventGroupCreate();
if (s_evt_handle == NULL) {
    ESP_LOGE(TAG, "line-%u event group create failed", __LINE__);
    assert(0);
}

if (ENABLE_UVC_CAMERA_FUNCTION)

if (ENABLE_UVC_WIFI_XFER)

app_wifi_main();
app_httpd_main();

endif //ENABLE_UVC_WIFI_XFER

/* malloc double buffer for usb payload, xfer_buffer_size >= frame_buffer_size*/
uint8_t *xfer_buffer_a = (uint8_t *)malloc(DEMO_UVC_XFER_BUFFER_SIZE);
assert(xfer_buffer_a != NULL);
uint8_t *xfer_buffer_b = (uint8_t *)malloc(DEMO_UVC_XFER_BUFFER_SIZE);
assert(xfer_buffer_b != NULL);

/* malloc frame buffer for a jpeg frame*/
uint8_t *frame_buffer = (uint8_t *)malloc(DEMO_UVC_XFER_BUFFER_SIZE);
assert(frame_buffer != NULL);

uvc_config_t uvc_config = {
    /* match the any resolution of current camera (first frame size as default) */
    .frame_width = DEMO_UVC_FRAME_WIDTH,
    .frame_height = DEMO_UVC_FRAME_HEIGHT,
    .frame_interval = FPS2INTERVAL(15),
    .xfer_buffer_size = DEMO_UVC_XFER_BUFFER_SIZE,
    .xfer_buffer_a = xfer_buffer_a,
    .xfer_buffer_b = xfer_buffer_b,
    .frame_buffer_size = DEMO_UVC_XFER_BUFFER_SIZE,
    .frame_buffer = frame_buffer,
    .frame_cb = &camera_frame_cb,
    .frame_cb_arg = NULL,
};
/* config to enable uvc function */
ret = uvc_streaming_config(&uvc_config);
if (ret != ESP_OK) {
    ESP_LOGE(TAG, "uvc streaming config failed");
}

endif

if (ENABLE_UAC_MIC_SPK_FUNCTION)

/* match any frequency of audio device we can found
 * call uac_frame_size_list_get to get the frame list of current audio device
 */
uac_config_t uac_config = {
    .mic_bit_resolution = UAC_BITS_ANY,
    .mic_samples_frequence = UAC_FREQUENCY_ANY,
    .spk_bit_resolution = UAC_BITS_ANY,
    .spk_samples_frequence = UAC_FREQUENCY_ANY,
    .spk_buf_size = 16000,
    .mic_cb = &mic_frame_cb,
    .mic_cb_arg = NULL,
    /* Set flags to suspend speaker, user need call usb_streaming_control
    later to resume the speaker*/
    .flags = FLAG_UAC_SPK_SUSPEND_AFTER_START,
};
ret = uac_streaming_config(&uac_config);
if (ret != ESP_OK) {
    ESP_LOGE(TAG, "uac streaming config failed");
}

endif

/* register the state callback to get connect/disconnect event
* in the callback, we can get the frame list of current device
*/
ESP_ERROR_CHECK(usb_streaming_state_register(&stream_state_changed_cb, NULL));
/* start usb streaming, UVC and UAC MIC will start streaming because SUSPEND_AFTER_START flags not set */
ESP_ERROR_CHECK(usb_streaming_start());
ESP_ERROR_CHECK(usb_streaming_connect_wait(portMAX_DELAY));
// wait for speaker device ready
xEventGroupWaitBits(s_evt_handle, BIT3_SPK_START, false, false, portMAX_DELAY);

while (1) {
    xEventGroupWaitBits(s_evt_handle, BIT3_SPK_START, true, false, portMAX_DELAY);
    /* Manually resume the speaker because SUSPEND_AFTER_START flags is set */
    ESP_ERROR_CHECK(usb_streaming_control(STREAM_UAC_SPK, CTRL_RESUME, NULL));
    usb_streaming_control(STREAM_UAC_SPK, CTRL_UAC_VOLUME, (void *)80);
    usb_streaming_control(STREAM_UAC_MIC, CTRL_UAC_VOLUME, (void *)80);
    ESP_LOGI(TAG, "speaker resume");

if (ENABLE_UAC_MIC_SPK_FUNCTION && !ENABLE_UAC_MIC_SPK_LOOPBACK)

    ESP_LOGI(TAG, "start to play default sound");
    extern const uint8_t wave_array_32000_16_1[];
    extern const uint32_t s_buffer_size;
    int freq_offsite_step = 32000 / s_spk_samples_frequence;
    int downsampling_bits = 16 - s_spk_bit_resolution;
    const int buffer_ms = 400;
    const int buffer_size = buffer_ms * (s_spk_bit_resolution / 8) * (s_spk_samples_frequence / 1000);
    // if 8bit spk, declare uint8_t *d_buffer
    uint16_t *s_buffer = (uint16_t *)wave_array_32000_16_1;
    uint16_t *d_buffer = calloc(1, buffer_size);
    size_t offset_size = buffer_size / (s_spk_bit_resolution / 8);
    while (1) {
        if ((uint32_t)(s_buffer + offset_size) >= (uint32_t)(wave_array_32000_16_1 + s_buffer_size)) {
            s_buffer = (uint16_t *)wave_array_32000_16_1;
            // mute the speaker
            vTaskDelay(pdMS_TO_TICKS(1000));
            // un-mute the speaker
        } else {
            // fill to usb buffer
            for (size_t i = 0; i < offset_size; i++) {
                d_buffer[i] = *(s_buffer + i * freq_offsite_step) >> downsampling_bits;
            }
            // write to usb speaker
            uac_spk_streaming_write(d_buffer, buffer_size, pdMS_TO_TICKS(1000));
            s_buffer += offset_size * freq_offsite_step;
        }
        if (xEventGroupGetBits(s_evt_handle) & (BIT4_SPK_RESET | BIT3_SPK_START)) {
            // disconnect happens, we may need to reset the frequency of the speaker
            xEventGroupClearBits(s_evt_handle, BIT4_SPK_RESET);
            break;
        }
    }
    free(d_buffer);

endif

}

while (1) {
    vTaskDelay(100);
}

}

Debug Logs.

V (1065) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (1066) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0x40E
D (1066) intr_alloc: Connected src 79 to int 3 (cpu 0)
D (1067) app_start: Starting scheduler on CPU0
V (1067) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (1067) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0x402
D (1067) intr_alloc: Connected src 57 to int 5 (cpu 0)
V (1067) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): checking args
V (1067) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): Args okay. Resulting flags 0x40E
I (1D (1068) intr_alloc: Connected src 80 to int 0 (cpu 1)
D (1068) app_start: Starting scheduler on CPU1
V (1068) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): checking args
V (1069) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): Args okay. Resulting flags 0x402
067) mainD (1069) intr_alloc: Connected src 58 to int 1 (cpu 1)
_task: Started on CPU0
D (1070) heap_init: New heap initialised at 0x3fce9710
I (1070) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
D (1071) esp_psram: Allocating block of size 32768 bytes
V (1071) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (1071) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (1072) intr_alloc: Connected src 52 to int 8 (cpu 0)
I (1072) main_task: Calling app_main()
I (1082) pp: pp rom version: e7ae62f
I (1083) net80211: net80211 rom version: e7ae62f
I (1085) wifi:wifi driver task: 3fcb74ac, prio:23, stack:6656, core=0
I (1090) wifi:wifi firmware version: ccaebfa
I (1090) wifi:wifi certification version: v7.0
I (1091) wifi:config NVS flash: enabled
I (1091) wifi:config nano formating: disabled
I (1091) wifi:Init data frame dynamic rx buffer num: 32
I (1091) wifi:Init static rx mgmt buffer num: 5
I (1091) wifi:Init management short buffer num: 32
I (1092) wifi:Init static tx buffer num: 16
I (1092) wifi:Init tx cache buffer num: 32
I (1093) wifi:Init static tx FG buffer num: 2
I (1093) wifi:Init static rx buffer size: 1600
I (1093) wifi:Init static rx buffer num: 10
I (1093) wifi:Init dynamic rx buffer num: 32
I (1094) wifi_init: rx ba win: 6
I (1094) wifi_init: accept mbox: 6
I (1094) wifi_init: tcpip mbox: 32
I (1095) wifi_init: udp mbox: 6
I (1095) wifi_init: tcp mbox: 6
I (1095) wifi_init: tcp tx win: 5760
I (1095) wifi_init: tcp rx win: 5760
I (1095) wifi_init: tcp mss: 1440
I (1096) wifi_init: WiFi IRAM OP enabled
I (1096) wifi_init: WiFi RX IRAM OP enabled
I (1099) camera wifi: wifi_init_softap finished.SSID:ESP32S3-UVC password:
I (1099) phy_init: phy_version 680,a6008b2,Jun  4 2024,16:41:10
I (1136) wifi:mode : softAP (7c:df:a1:fc:79:55)
I (1137) wifi:Total power save buffer number: 8
I (1138) wifi:Init max length of beacon: 752/752
I (1138) wifi:Init max length of beacon: 752/752
I (1139) camera_httpd: Starting web server on port: '80'
I (1140) esp_netif_lwip: DHCP server started on interface WIFI_AP_DEF with IP: 192.168.4.1
I (1143) camera_httpd: Starting stream server on port: '81'
I (1145) USB_STREAM: UVC Streaming Config Succeed, Version: 1.4.0
I (1146) USB_STREAM: SPK Streaming Suspend After Start
I (1146) USB_STREAM: UAC Streaming Config Succeed, Version: 1.4.0
I (1146) USB_STREAM: USB streaming callback register succeed
I (1147) USB_STREAM: Pre-alloc ctrl urb succeed, size = 2048
I (1148) USB_STREAM: USB stream task start
I (1178) USB_STREAM: USB Streaming Start Succeed
I (1178) USB_STREAM: Waiting USB Device Connection
I (1428) USB_STREAM: line 151 HCD_PORT_EVENT_CONNECTION
I (1428) USB_STREAM: Action: ACTION_DEVICE_CONNECT
I (1479) USB_STREAM: Resetting Port
I (1539) USB_STREAM: Setting Port FIFO, 1
I (1539) USB_STREAM: USB Speed: full-speed
I (1540) USB_STREAM: ENUM Stage START, Succeed
I (1541) USB_STREAM: ENUM Stage GET_SHORT_DEV_DESC, Succeed
I (1543) USB_STREAM: Default pipe endpoint MPS update to 64
I (1543) USB_STREAM: ENUM Stage CHECK_SHORT_DEV_DESC, Succeed
I (1544) USB_STREAM: ENUM Stage SET_ADDR, Succeed
I (1555) USB_STREAM: ENUM Stage CHECK_ADDR, Succeed
I (1556) USB_STREAM: ENUM Stage GET_FULL_DEV_DESC, Succeed
*** Device descriptor ***
bcdUSB 2.00
bDeviceClass 0xef
bDeviceSubClass 0x2
bDeviceProtocol 0x1
bMaxPacketSize0 64
idVendor 0x46d
idProduct 0x825
bNumConfigurations 1
I (1557) USB_STREAM: ENUM Stage CHECK_FULL_DEV_DESC, Succeed
I (1558) USB_STREAM: ENUM Stage GET_SHORT_CONFIG_DESC, Succeed
I (1570) USB_STREAM: ENUM Stage CHECK_SHORT_CONFIG_DESC, Succeed
I (1571) USB_STREAM: ENUM Stage GET_FULL_CONFIG_DESC, Succeed
*** Configuration descriptor ***
wTotalLength 660
bNumInterfaces 4
bConfigurationValue 1
*** Interface Association Descriptor: Video ***
        *** Interface descriptor ***
        bInterfaceNumber 0
        bAlternateSetting 0
        bNumEndpoints 1
        bInterfaceClass 0xe (Video)
        bInterfaceSubClass 0x1
                *** Endpoint descriptor ***
                bEndpointAddress 0x83   EP 3 IN
                bmAttributes 0x3        INT
                wMaxPacketSize 16
                bInterval 6
        *** Interface descriptor ***
        bInterfaceNumber 1
        bAlternateSetting 0
        bNumEndpoints 0
        bInterfaceClass 0xe (Video)
        bInterfaceSubClass 0x2
        *** Class-specific VS Interface Descriptor ***
        bNumFormats 1
        *** Interface descriptor ***
        bInterfaceNumber 1
        bAlternateSetting 1
        bNumEndpoints 1
        bInterfaceClass 0xe (Video)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x81   EP 1 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 128
                bInterval 1
        *** Interface descriptor ***
        bInterfaceNumber 1
        bAlternateSetting 2
        bNumEndpoints 1
        bInterfaceClass 0xe (Video)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x81   EP 1 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 256
                bInterval 1
        *** Interface descriptor ***
        bInterfaceNumber 1
        bAlternateSetting 3
        bNumEndpoints 1
        bInterfaceClass 0xe (Video)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x81   EP 1 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 384
                bInterval 1
        *** Interface descriptor ***
        bInterfaceNumber 1
        bAlternateSetting 4
        bNumEndpoints 1
        bInterfaceClass 0xe (Video)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x81   EP 1 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 512
                bInterval 1
        *** Interface descriptor ***
        bInterfaceNumber 1
        bAlternateSetting 5
        bNumEndpoints 1
        bInterfaceClass 0xe (Video)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x81   EP 1 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 768
                bInterval 1
        *** Interface descriptor ***
        bInterfaceNumber 1
        bAlternateSetting 6
        bNumEndpoints 1
        bInterfaceClass 0xe (Video)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x81   EP 1 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 780
                bInterval 1
        *** Interface descriptor ***
        bInterfaceNumber 1
        bAlternateSetting 7
        bNumEndpoints 1
        bInterfaceClass 0xe (Video)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x81   EP 1 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 800
                bInterval 1

*** Interface Association Descriptor: Audio ***
        *** Interface descriptor ***
        bInterfaceNumber 2
        bAlternateSetting 0
        bNumEndpoints 0
        bInterfaceClass 0x1 (Audio)
        bInterfaceSubClass 0x1
        *** Audio control header descriptor ***
        bcdADC 0x100
        wTotalLength 39
        bInCollection 1
                Interface number[0] = 3
        *** Audio control input terminal descriptor ***
        bTerminalID 1
        wTerminalType 0x201
        bAssocTerminal 0
        bNrChannels 1
        wChannelConfig 0x0003
        *** Audio control output terminal descriptor ***
        bTerminalID 2
        wTerminalType 0x101
        bAssocTerminal 1
        *** Audio control feature unit descriptor ***
        bUnitID 5
        bSourceID 1
        bControlSize 2
        bmaControls[ch0] 0x3
        *** Interface descriptor ***
        bInterfaceNumber 3
        bAlternateSetting 0
        bNumEndpoints 0
        bInterfaceClass 0x1 (Audio)
        bInterfaceSubClass 0x2
        *** Interface descriptor ***
        bInterfaceNumber 3
        bAlternateSetting 1
        bNumEndpoints 1
        bInterfaceClass 0x1 (Audio)
        bInterfaceSubClass 0x2
        *** Audio stream general descriptor ***
        bTerminalLink 2
        bDelay 1
        wFormatTag 1
        *** Audio control header descriptor ***
        bFormatType 1
        bNrChannels 1
        bSubframeSize 2
        bBitResolution 16
        bSamFreqType 1
        tSamFreq[0] 32000
                *** Endpoint descriptor ***
                bEndpointAddress 0x82   EP 2 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 80
                bInterval 4

        *** Interface descriptor ***
        bInterfaceNumber 3
        bAlternateSetting 2
        bNumEndpoints 1
        bInterfaceClass 0x1 (Audio)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x82   EP 2 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 48
                bInterval 4
        *** Interface descriptor ***
        bInterfaceNumber 3
        bAlternateSetting 3
        bNumEndpoints 1
        bInterfaceClass 0x1 (Audio)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x82   EP 2 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 64
                *** Endpoint descriptor ***
                bEndpointAddress 0x82   EP 2 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 64
                bInterval 4
        *** Interface descriptor ***
        bInterfaceNumber 3
        bAlternateSetting 4
        bNumEndpoints 1
        bInterfaceClass 0x1 (Audio)
        bInterfaceSubClass 0x2
                *** Endpoint descriptor ***
                bEndpointAddress 0x82   EP 2 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 112
                bInterval 4
                bmAttributes 0x5        ISOC
                wMaxPacketSize 112
                bInterval 4
I (1617) USB_STREAM: Actual VS Interface(MPS <= 512) found, interface = 1, alt = 4
I (1617) USB_STREAM:    Endpoint(ISOC) Addr = 0x81, MPS = 512
E (1618) USB_STREAM: Setting format: 0 NOT found
W (1618) USB_STREAM: Frame: 0, width*height: 65535*65535, NOT found
I (1619) USB_STREAM: Audio control interface = 2
I (1619) USB_STREAM: Mic feature unit = 5
I (1619) USB_STREAM:    Support volume control, ch = 1
I (1619) USB_STREAM:    Support mute control, ch = 1
I (1619) USB_STREAM: Mic feature unit = 5
I (1619) USB_STREAM:    Support volume control, ch = 1
I (1619) USB_STREAM:    Support mute control, ch = 1
I (1620) USB_STREAM: Mic Interface found interface = 3
I (1620) USB_STREAM:    Endpoint(ISOC) Addr = 0x82, MPS = 80
I (1620) USB_STREAM:    Mic frequency control  Support
I (1621) USB_STREAM: ENUM Stage CHECK_FULL_CONFIG_DESC, Succeed
I (1621) USB_STREAM: ENUM Stage CHECK_FULL_CONFIG_DESC, Succeed
I (1622) USB_STREAM: ENUM Stage SET_CONFIG, Succeed
W (1634) uvc_mic_spk_demo: UVC: get frame list size = 0
I (1635) uvc_mic_spk_demo: UAC MIC: get frame list size = 1, current = 0
I (1635) uvc_mic_spk_demo:       [0] ch_num = 1, bit_resolution = 16, samples_frequence = 32000, samples_frequence_min = 0, samples_frequence_max = 0
I (1635) uvc_mic_spk_demo: UAC MIC: use frame[0] ch_num = 1, bit_resolution = 16, samples_frequence = 32000
I (1635) uvc_mic_spk_demo: UAC MIC: use frame[0] ch_num = 1, bit_resolution = 16, samples_frequence = 32000
W (1636) uvc_mic_spk_demo: UAC SPK: get frame list size = 0
I (1636) uvc_mic_spk_demo: Device connected
I (1637) USB_STREAM: Set Device Interface = 3, Alt = 1
I (1645) USB_STREAM: Set frequency endpoint 0x82: (32000) Hz
I (1676) USB_STREAM: USB Device Connected
I (80480) wifi:new:<1,1>, old:<1,1>, ap:<1,1>, sta:<255,255>, prof:1, snd_ch_cfg:0x0
I (80481) wifi:station: f0:d4:15:9f:d4:3b join, AID=1, bgn, 40U
I (80482) camera wifi: station f0:d4:15:9f:d4:3b join, AID=1
I (80676) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.4.2
I (81258) wifi:<ba-add>idx:2 (ifx:1, f0:d4:15:9f:d4:3b), tid:0, ssn:10, winSize:64
W (137377) httpd_uri: httpd_uri: URI '/favicon.ico' not found
W (137377) httpd_txrx: httpd_resp_send_err: 404 Not Found - Nothing matches the given URI

More Information.

I use the windows usb descriptior dumper to get the C270 descrption which is right。 And use amcap to connect the camera and set the format which is also successful. 微信图片_20241101100209

C270.txt

shenqili commented 3 weeks ago

https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/host/usb_camera_mic_spk is same as https://gitcode.com/gh_mirrors/es/esp-iot-solution/tree/master/examples/usb/host/usb_camera_mic_spk

shenqili commented 3 weeks ago

I have found the reason is that uvc device has Other Speed Configuration Descriptor (for full speed). And the ideal video format can only be gotten at the high speed. So the question changes to another. Why C270 is in the supported list and how can I use the C270 with esp32s3? I really want to know, thanks a lot. uvc

tore-espressif commented 3 weeks ago

I uncommented this line https://github.com/espressif/esp-idf/blob/9106c43accd9f5e75379f62f12597677213f5023/examples/peripherals/usb/host/uvc/main/main.c#L264 And this is my output with Logitech C270

Logitech C270 FS CFG descriptor ``` *** Device descriptor *** bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0xef bDeviceSubClass 0x2 bDeviceProtocol 0x1 bMaxPacketSize0 64 idVendor 0x46d idProduct 0x825 bcdDevice 0.10 iManufacturer 0 iProduct 0 iSerialNumber 2 bNumConfigurations 1 *** Configuration descriptor *** bLength 9 bDescriptorType 2 wTotalLength 1117 bNumInterfaces 4 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 bMaxPower 500mA *** Interface Association Descriptor *** bLength 8 bDescriptorType 11 bFirstInterface 0 bInterfaceCount 2 bFunctionClass 0xe bFunctionSubClass 0x3 bFunctionProtocol 0x0 iFunction 0 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 0xe bInterfaceSubClass 0x1 bInterfaceProtocol 0x0 iInterface 0 *** Class-specific VC Interface Descriptor *** bLength 0xd bDescriptorType 0x24 bDescriptorSubType 1 bcdUVC 100 wTotalLength 160 dwClockFrequency 48000000 bFunctionProtocol 1 bInCollection 1 baInterfaceNr 18 *** Input Terminal Descriptor (Camera) *** bLength 0x12 bDescriptorType 0x24 bDescriptorSubType 2 bTerminalID 1 wTerminalType 201 bAssocTerminal 0 iTerminal 0 wObjectiveFocalLengthMin 0 wObjectiveFocalLengthMax 0 wOcularFocalLength 0 bControlSize 3 bmControls 0xe *** Processing Unit Descriptor *** bLength 0xb bDescriptorType 0x24 bDescriptorSubType 5 bUnitID 2 bSourceID 1 wMaxMultiplier 16384 bControlSize 2 bmControls 0x175b iProcessing 0 bmVideoStandards 0x1b *** Extension Unit Descriptor unsupported, skipping... *** *** Extension Unit Descriptor unsupported, skipping... *** *** Extension Unit Descriptor unsupported, skipping... *** *** Extension Unit Descriptor unsupported, skipping... *** *** Output Terminal Descriptor *** bLength 0x9 bDescriptorType 0x24 bDescriptorSubType 3 bTerminalID 5 wTerminalType 101 bAssocTerminal 0 bSourceID 4 iTerminal 0 *** Endpoint descriptor *** bLength 7 bDescriptorType 5 bEndpointAddress 0x87 EP 7 IN bmAttributes 0x3 INT wMaxPacketSize 16 bInterval 16 *** Class-specific Interrupt Endpoint Descriptor *** bLength 0x5 bDescriptorType 0x25 bDescriptorSubType 3 wMaxTransferSize 16 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 0 bInterfaceClass 0xe bInterfaceSubClass 0x2 bInterfaceProtocol 0x0 iInterface 0 *** Class-specific VC Interface Descriptor *** bLength 0x10 bDescriptorType 0x24 bDescriptorSubType 1 bcdUVC c203 wTotalLength 33026 dwClockFrequency 66816 bFunctionProtocol 0 bInCollection 1 baInterfaceNr 0 *** Selector Unit Descriptor *** bLength 0x1b bDescriptorType 0x24 bDescriptorSubType 4 bUnitID 1 bNrInPins 2 baSourceID1 89 baSourceID2 85 iSelector 89 *** Processing Unit Descriptor *** bLength 0x26 bDescriptorType 0x24 bDescriptorSubType 5 bUnitID 2 bSourceID 1 wMaxMultiplier 160 bControlSize 120 bmControls 0x0 iProcessing 112 bmVideoStandards 0x17 *** Processing Unit Descriptor *** bLength 0x26 bDescriptorType 0x24 bDescriptorSubType 5 bUnitID 3 bSourceID 1 wMaxMultiplier 176 bControlSize 144 bmControls 0x0 iProcessing 240 bmVideoStandards 0x1e *** VS Color Format Descriptor *** bLength 0x6 bDescriptorType 0x24 bDescriptorSubType 0xd bColorPrimaries 0x1 bTransferCharacteristics 1 bMatrixCoefficients 0x4 *** Extension Unit Descriptor unsupported, skipping... *** *** VS Frame Descriptor *** bLength 0x32 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0x1 bmCapabilities 0x1 wWidth 640 wHeigh 480 dwMinBitRate 24576000 dwMaxBitRate 147456000 dwMaxVideoFrameBufSize 614400 dwDefaultFrameInterval 333333 bFrameIntervalType 6 FrameInterval[0] 333333 FrameInterval[1] 400000 FrameInterval[2] 500000 FrameInterval[3] 666666 FrameInterval[4] 1000000 FrameInterval[5] 2000000 *** VS Frame Descriptor *** bLength 0x32 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0x2 bmCapabilities 0x1 wWidth 160 wHeigh 120 dwMinBitRate 1536000 dwMaxBitRate 9216000 dwMaxVideoFrameBufSize 38400 dwDefaultFrameInterval 333333 bFrameIntervalType 6 FrameInterval[0] 333333 FrameInterval[1] 400000 FrameInterval[2] 500000 FrameInterval[3] 666666 FrameInterval[4] 1000000 FrameInterval[5] 2000000 *** VS Frame Descriptor *** bLength 0x32 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0x3 bmCapabilities 0x1 wWidth 176 wHeigh 144 dwMinBitRate 2027520 dwMaxBitRate 12165120 dwMaxVideoFrameBufSize 50688 dwDefaultFrameInterval 333333 bFrameIntervalType 6 FrameInterval[0] 333333 FrameInterval[1] 400000 FrameInterval[2] 500000 FrameInterval[3] 666666 FrameInterval[4] 1000000 FrameInterval[5] 2000000 *** VS Frame Descriptor *** bLength 0x32 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0x4 bmCapabilities 0x1 wWidth 320 wHeigh 176 dwMinBitRate 4505600 dwMaxBitRate 27033600 dwMaxVideoFrameBufSize 112640 dwDefaultFrameInterval 333333 bFrameIntervalType 6 FrameInterval[0] 333333 FrameInterval[1] 400000 FrameInterval[2] 500000 FrameInterval[3] 666666 FrameInterval[4] 1000000 FrameInterval[5] 2000000 *** VS Frame Descriptor *** bLength 0x32 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0x5 bmCapabilities 0x1 wWidth 320 wHeigh 240 dwMinBitRate 6144000 dwMaxBitRate 36864000 dwMaxVideoFrameBufSize 153600 dwDefaultFrameInterval 333333 bFrameIntervalType 6 FrameInterval[0] 333333 FrameInterval[1] 400000 FrameInterval[2] 500000 FrameInterval[3] 666666 FrameInterval[4] 1000000 FrameInterval[5] 2000000 *** VS Frame Descriptor *** bLength 0x32 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0x6 bmCapabilities 0x1 wWidth 352 wHeigh 288 dwMinBitRate 8110080 dwMaxBitRate 48660480 dwMaxVideoFrameBufSize 202752 dwDefaultFrameInterval 333333 bFrameIntervalType 6 FrameInterval[0] 333333 FrameInterval[1] 400000 FrameInterval[2] 500000 FrameInterval[3] 666666 FrameInterval[4] 1000000 FrameInterval[5] 2000000 *** VS Frame Descriptor *** bLength 0x32 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0x7 bmCapabilities 0x1 wWidth 432 wHeigh 240 dwMinBitRate 8294400 dwMaxBitRate 49766400 dwMaxVideoFrameBufSize 207360 dwDefaultFrameInterval 333333 bFrameIntervalType 6 FrameInterval[0] 333333 FrameInterval[1] 400000 FrameInterval[2] 500000 FrameInterval[3] 666666 FrameInterval[4] 1000000 FrameInterval[5] 2000000 *** VS Frame Descriptor *** bLength 0x32 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0x8 bmCapabilities 0x1 wWidth 544 wHeigh 288 dwMinBitRate 12533760 dwMaxBitRate 75202560 dwMaxVideoFrameBufSize 313344 dwDefaultFrameInterval 333333 bFrameIntervalType 6 FrameInterval[0] 333333 FrameInterval[1] 400000 FrameInterval[2] 500000 FrameInterval[3] 666666 FrameInterval[4] 1000000 FrameInterval[5] 2000000 *** VS Frame Descriptor *** bLength 0x32 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0x9 bmCapabilities 0x1 wWidth 640 wHeigh 360 dwMinBitRate 18432000 dwMaxBitRate 110592000 dwMaxVideoFrameBufSize 460800 dwDefaultFrameInterval 333333 bFrameIntervalType 6 FrameInterval[0] 333333 FrameInterval[1] 400000 FrameInterval[2] 500000 FrameInterval[3] 666666 FrameInterval[4] 1000000 FrameInterval[5] 2000000 *** VS Frame Descriptor *** bLength 0x26 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0xa bmCapabilities 0x1 wWidth 752 wHeigh 416 dwMinBitRate 25026560 dwMaxBitRate 75079680 dwMaxVideoFrameBufSize 625664 dwDefaultFrameInterval 666666 bFrameIntervalType 3 FrameInterval[0] 666666 FrameInterval[1] 1000000 FrameInterval[2] 2000000 *** VS Frame Descriptor *** bLength 0x26 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0xb bmCapabilities 0x1 wWidth 800 wHeigh 448 dwMinBitRate 28672000 dwMaxBitRate 86016000 dwMaxVideoFrameBufSize 716800 dwDefaultFrameInterval 666666 bFrameIntervalType 3 FrameInterval[0] 666666 FrameInterval[1] 1000000 FrameInterval[2] 2000000 *** VS Frame Descriptor *** bLength 0x26 bDescriptorType 0x24 bDescriptorSubType 0x7 bFrameIndex 0xc bmCapabilities 0x1 wWidth 800 wHeigh 600 dwMinBitRate 38400000 dwMaxBitRate 115200000 dwMaxVideoFrameBufSize 960000 dwDefaultFrameInterval 666666 bFrameIntervalType 3 FrameInterval[0] 666666 FrameInterval[1] 1000000 FrameInterval[2] 2000000 *** VS Color Format Descriptor *** bLength 0x6 bDescriptorType 0x24 bDescriptorSubType 0xd bColorPrimaries 0x1 bTransferCharacteristics 1 bMatrixCoefficients 0x4 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 1 bNumEndpoints 1 bInterfaceClass 0xe bInterfaceSubClass 0x2 bInterfaceProtocol 0x0 iInterface 0 *** Endpoint descriptor *** bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 0x5 ISOC wMaxPacketSize 192 bInterval 1 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 2 bNumEndpoints 1 bInterfaceClass 0xe bInterfaceSubClass 0x2 bInterfaceProtocol 0x0 iInterface 0 *** Endpoint descriptor *** bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 0x5 ISOC wMaxPacketSize 384 bInterval 1 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 3 bNumEndpoints 1 bInterfaceClass 0xe bInterfaceSubClass 0x2 bInterfaceProtocol 0x0 iInterface 0 *** Endpoint descriptor *** bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 0x5 ISOC wMaxPacketSize 512 bInterval 1 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 4 bNumEndpoints 1 bInterfaceClass 0xe bInterfaceSubClass 0x2 bInterfaceProtocol 0x0 iInterface 0 *** Endpoint descriptor *** bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 0x5 ISOC wMaxPacketSize 640 bInterval 1 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 5 bNumEndpoints 1 bInterfaceClass 0xe bInterfaceSubClass 0x2 bInterfaceProtocol 0x0 iInterface 0 *** Endpoint descriptor *** bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 0x5 ISOC wMaxPacketSize 800 bInterval 1 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 6 bNumEndpoints 1 bInterfaceClass 0xe bInterfaceSubClass 0x2 bInterfaceProtocol 0x0 iInterface 0 *** Endpoint descriptor *** bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 0x5 ISOC wMaxPacketSize 944 bInterval 1 *** Interface Association Descriptor *** bLength 8 bDescriptorType 11 bFirstInterface 2 bInterfaceCount 2 bFunctionClass 0x1 bFunctionSubClass 0x2 bFunctionProtocol 0x0 iFunction 0 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 2 bAlternateSetting 0 bNumEndpoints 0 bInterfaceClass 0x1 bInterfaceSubClass 0x1 bInterfaceProtocol 0x0 iInterface 0 *** Class-specific VC Interface Descriptor *** bLength 0x9 bDescriptorType 0x24 bDescriptorSubType 1 bcdUVC 100 wTotalLength 38 dwClockFrequency 604766977 bFunctionProtocol 2 bInCollection 1 baInterfaceNr 1 *** Input Terminal Descriptor (Camera) *** bLength 0xc bDescriptorType 0x24 bDescriptorSubType 2 bTerminalID 1 wTerminalType 201 bAssocTerminal 0 iTerminal 1 wObjectiveFocalLengthMin 0 wObjectiveFocalLengthMax 0 wOcularFocalLength 9225 bControlSize 3 bmControls 0x103 *** Output Terminal Descriptor *** bLength 0x9 bDescriptorType 0x24 bDescriptorSubType 3 bTerminalID 3 wTerminalType 101 bAssocTerminal 1 bSourceID 5 iTerminal 0 *** Extension Unit Descriptor unsupported, skipping... *** *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 3 bAlternateSetting 0 bNumEndpoints 0 bInterfaceClass 0x1 bInterfaceSubClass 0x2 bInterfaceProtocol 0x0 iInterface 0 *** Interface descriptor *** bLength 9 bDescriptorType 4 bInterfaceNumber 3 bAlternateSetting 1 bNumEndpoints 1 bInterfaceClass 0x1 bInterfaceSubClass 0x2 bInterfaceProtocol 0x0 iInterface 0 *** Class-specific VC Interface Descriptor *** bLength 0x7 bDescriptorType 0x24 bDescriptorSubType 1 bcdUVC 103 wTotalLength 1 dwClockFrequency 16917515 bFunctionProtocol 1 bInCollection 2 baInterfaceNr 16 *** Input Terminal Descriptor (Camera) *** bLength 0xb bDescriptorType 0x24 bDescriptorSubType 2 bTerminalID 1 wTerminalType 201 bAssocTerminal 16 iTerminal 1 wObjectiveFocalLengthMin 16000 wObjectiveFocalLengthMax 2304 wOcularFocalLength 34309 bControlSize 5 bmControls 0x44 *** Endpoint descriptor *** bLength 9 bDescriptorType 5 bEndpointAddress 0x86 EP 6 IN bmAttributes 0x5 ISOC wMaxPacketSize 68 bInterval 1 *** Class-specific Interrupt Endpoint Descriptor *** bLength 0x7 bDescriptorType 0x25 bDescriptorSubType 1 wMaxTransferSize 1 *** String Descriptors *** iSerialNumber: E190CC90 DEVICE CONFIGURATION (046d:0825/E) --- Status: idle VideoControl: bcdUVC: 0x0100 VideoStreaming(1): bEndpointAddress: 129 Formats: UncompressedFormat(1) bits per pixel: 16 GUID: 5955593200001000800000aa00389b71 (YUY2) default frame: 2 aspect ratio: 0x0 interlace flags: 00 copy protect: 00 FrameDescriptor(2) capabilities: 01 size: 160x120 bit rate: 1536000-4608000 max frame size: 38400 default interval: 1/15 interval[0]: 1/15 interval[1]: 1/10 interval[2]: 1/5 FrameDescriptor(3) capabilities: 01 size: 176x144 bit rate: 2027520-6082560 max frame size: 50688 default interval: 1/15 interval[0]: 1/15 interval[1]: 1/10 interval[2]: 1/5 MJPEGFormat(2) bits per pixel: 0 GUID: 4d4a5047000000000000000000000000 (MJPG) default frame: 1 aspect ratio: 0x0 interlace flags: 00 copy protect: 00 FrameDescriptor(1) capabilities: 01 size: 640x480 bit rate: 24576000-147456000 max frame size: 614400 default interval: 1/30 interval[0]: 1/30 interval[1]: 1/25 interval[2]: 1/20 interval[3]: 1/15 interval[4]: 1/10 interval[5]: 1/5 FrameDescriptor(2) capabilities: 01 size: 160x120 bit rate: 1536000-9216000 max frame size: 38400 default interval: 1/30 interval[0]: 1/30 interval[1]: 1/25 interval[2]: 1/20 interval[3]: 1/15 interval[4]: 1/10 interval[5]: 1/5 FrameDescriptor(3) capabilities: 01 size: 176x144 bit rate: 2027520-12165120 max frame size: 50688 default interval: 1/30 interval[0]: 1/30 interval[1]: 1/25 interval[2]: 1/20 interval[3]: 1/15 interval[4]: 1/10 interval[5]: 1/5 FrameDescriptor(4) capabilities: 01 size: 320x176 bit rate: 4505600-27033600 max frame size: 112640 default interval: 1/30 interval[0]: 1/30 interval[1]: 1/25 interval[2]: 1/20 interval[3]: 1/15 interval[4]: 1/10 interval[5]: 1/5 FrameDescriptor(5) capabilities: 01 size: 320x240 bit rate: 6144000-36864000 max frame size: 153600 default interval: 1/30 interval[0]: 1/30 interval[1]: 1/25 interval[2]: 1/20 interval[3]: 1/15 interval[4]: 1/10 interval[5]: 1/5 FrameDescriptor(6) capabilities: 01 size: 352x288 bit rate: 8110080-48660480 max frame size: 202752 default interval: 1/30 interval[0]: 1/30 interval[1]: 1/25 interval[2]: 1/20 interval[3]: 1/15 interval[4]: 1/10 interval[5]: 1/5 FrameDescriptor(7) capabilities: 01 size: 432x240 bit rate: 8294400-49766400 max frame size: 207360 default interval: 1/30 interval[0]: 1/30 interval[1]: 1/25 interval[2]: 1/20 interval[3]: 1/15 interval[4]: 1/10 interval[5]: 1/5 FrameDescriptor(8) capabilities: 01 size: 544x288 bit rate: 12533760-75202560 max frame size: 313344 default interval: 1/30 interval[0]: 1/30 interval[1]: 1/25 interval[2]: 1/20 interval[3]: 1/15 interval[4]: 1/10 interval[5]: 1/5 FrameDescriptor(9) capabilities: 01 size: 640x360 bit rate: 18432000-110592000 max frame size: 460800 default interval: 1/30 interval[0]: 1/30 interval[1]: 1/25 interval[2]: 1/20 interval[3]: 1/15 interval[4]: 1/10 interval[5]: 1/5 FrameDescriptor(10) capabilities: 01 size: 752x416 bit rate: 25026560-75079680 max frame size: 625664 default interval: 1/15 interval[0]: 1/15 interval[1]: 1/10 interval[2]: 1/5 FrameDescriptor(11) capabilities: 01 size: 800x448 bit rate: 28672000-86016000 max frame size: 716800 default interval: 1/15 interval[0]: 1/15 interval[1]: 1/10 interval[2]: 1/5 FrameDescriptor(12) capabilities: 01 size: 800x600 bit rate: 38400000-115200000 max frame size: 960000 default interval: 1/15 interval[0]: 1/15 interval[1]: 1/10 interval[2]: 1/5 ```

You can see many JPEG and Uncompressed formats available

And the ideal video format can only be gotten at the high speed.

What do you mean by 'ideal video format'?

ESP32-S2 and S3 are Full-Speed only, so it is not possible to stream higher quality (eg. 1280x720) video.

(ESP32-P4 is High-Speed and this is possible)

shenqili commented 2 weeks ago

I uncommented this line

https://github.com/espressif/esp-idf/blob/9106c43accd9f5e75379f62f12597677213f5023/examples/peripherals/usb/host/uvc/main/main.c#L264

And this is my output with Logitech C270 Logitech C270 FS CFG descriptor You can see many JPEG and Uncompressed formats available

And the ideal video format can only be gotten at the high speed.

What do you mean by 'ideal video format'?

ESP32-S2 and S3 are Full-Speed only, so it is not possible to stream higher quality (eg. 1280x720) video.

(ESP32-P4 is High-Speed and this is possible)

Thanks for responding. The Ideal video format should include MJPEG video format, like 640*480. For the C270 is supported by the esp32s3 which is demonstrated in usb_host_uvc 1.0.4(https://components.espressif.com/components/espressif/usb_host_uvc). And a youtuber have successfully used it for video tranfering. The link is below: https://www.youtube.com/watch?v=Hi-6Y12Jhgs. He used esp32s3 generic and also the C270 and run the project. So I have the doubt what is the wrong with me. I am willing for your feedback. Thx again.

shenqili commented 2 weeks ago

C270-windows vs esp32-log.docx I have upload the whole C270 configuration (captured by the windows usb description dumper) and compared to the print log of the ESP32 line by line. And as you seen, the configuration descrption gotten by esp32 is the 'Other Speed Configuration Descriptor'. It should work if get the configuration in the upper part. So I really want to how the examples of usb_host uvc 1.0.4 ror the youtube video can successfully use the C270.

tore-espressif commented 2 weeks ago

It appears that your camera does not support any additional video formats in Full-Speed mode. This is unusual, as my Logitech C270 camera, which has a bcdDevice version of 0x12, does support a wider range of formats. In contrast, your camera's bcdDevice version is 0x21, indicating a newer version of the USB device. However, despite being newer, it seems to lack support for certain video formats in Full-Speed.

The discrepancy between the configuration descriptors seen by Windows and ESP-IDF is also notable. While Windows detects the High-Speed descriptor with the full range of video formats, ESP-IDF only accesses the Full-Speed configuration descriptor, which has a reduced subset of formats.

I’m not sure why Logitech chose to limit the available formats in Full-Speed mode for the newer version of the camera. If the data you provided is accurate, this would seem to be the most plausible explanation.

shenqili commented 2 weeks ago

It doubts me a lot. And the difference between your C270 and my C270 in the version may be the most plausible reason for the failure. So for me, I have nothing could do more with the esp32s3 does not support the High-Speed for C270 video transferring in version 0x21. If it is possible to change from esp32s3 to another chip which supports both High-Speed and Wifi, like Raspberry Pi or use a external HS-PHY on the esp32s3?

shenqili commented 2 weeks ago

Or is it possible to do some configuration or adjustment in ESP-IDF to access the High Speed Configuration descriptor of C270 I used.

tore-espressif commented 1 week ago

There is no easy way how you can add USB HighSpeed support to ESP32-S3. Transferring your design to Raspberry Pi, or any other linux capable architecture will also give you a lot more computing power for video postprocessing. But it will greatly depend on what do you need to actually do