Skip to content

Commit 19f9fe8

Browse files
committed
refactor(uvc): Clean-up
1 parent d0300d3 commit 19f9fe8

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

host/class/uvc/usb_host_uvc/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
menu "USB HOST UVC"
1+
menu "USB-Driver: UVC Host"
22

3-
config PRINTF_UVC_CONFIGURATION_DESCRIPTOR
3+
config UVC_HOST_PRINT_CONFIG_DESCRIPTOR
44
bool "Print UVC Configuration Descriptor"
55
default n
66
help
77
Print UVC Configuration Descriptor to console.
88

9-
config UVC_INTERVAL_ARRAY_SIZE
9+
config UVC_HOST_INTERVAL_ARRAY_SIZE
1010
int "Size of the interval array in uvc_host_frame_info_t"
1111
default 3
1212
help

host/class/uvc/usb_host_uvc/include/usb/uvc_host.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
#include "usb/usb_host.h"
1111
#include "usb/usb_types_uvc.h"
1212
#include "esp_err.h"
13+
#include "sdkconfig.h"
1314

1415
// Use this macros for opening a UVC stream with any VID or PID
1516
#define UVC_HOST_ANY_VID (0)
1617
#define UVC_HOST_ANY_PID (0)
1718
#define UVC_HOST_ANY_DEV_ADDR (0)
1819

20+
#define UVC_HOST_INTERVAL_ARRAY_SIZE (CONFIG_UVC_HOST_INTERVAL_ARRAY_SIZE)
21+
1922
#ifdef __cplusplus
2023
extern "C" {
2124
#endif
@@ -53,7 +56,7 @@ typedef struct {
5356
uint32_t interval_max; /**< Maximum frame interval */
5457
uint32_t interval_step; /**< Frame interval step */
5558
};
56-
uint32_t interval[CONFIG_UVC_INTERVAL_ARRAY_SIZE]; /**< We must put a fixed size here because of the union type. This is flexible size array though */
59+
uint32_t interval[UVC_HOST_INTERVAL_ARRAY_SIZE]; /**< We must put a fixed size here because of the union type. This is flexible size array though */
5760
};
5861
} uvc_host_frame_info_t;
5962

host/class/uvc/usb_host_uvc/uvc_descriptor_parsing.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ esp_err_t uvc_desc_get_frame_list(const usb_config_desc_t *config_desc, uint8_t
454454
frame_info->interval_max = this_frame->mjpeg_uncompressed.dwMaxFrameInterval;
455455
frame_info->interval_step = this_frame->mjpeg_uncompressed.dwFrameIntervalStep;
456456
} else {
457-
for (int i = 0; i < CONFIG_UVC_INTERVAL_ARRAY_SIZE; i ++) {
457+
for (int i = 0; i < UVC_HOST_INTERVAL_ARRAY_SIZE; i ++) {
458458
frame_info->interval[i] = this_frame->mjpeg_uncompressed.dwFrameInterval[i];
459459
}
460460
}
@@ -468,7 +468,7 @@ esp_err_t uvc_desc_get_frame_list(const usb_config_desc_t *config_desc, uint8_t
468468
frame_info->interval_max = this_frame->frame_based.dwMaxFrameInterval;
469469
frame_info->interval_step = this_frame->frame_based.dwFrameIntervalStep;
470470
} else {
471-
for (int i = 0; i < CONFIG_UVC_INTERVAL_ARRAY_SIZE; i ++) {
471+
for (int i = 0; i < UVC_HOST_INTERVAL_ARRAY_SIZE; i ++) {
472472
frame_info->interval[i] = this_frame->frame_based.dwFrameInterval[i];
473473
}
474474
}

host/class/uvc/usb_host_uvc/uvc_host.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@
3131
#include "freertos/queue.h"
3232
#include "freertos/event_groups.h"
3333

34+
#include "sdkconfig.h"
35+
3436
static const char *TAG = "uvc";
3537

38+
#define UVC_HOST_PRINT_CONFIG_DESCRIPTOR CONFIG_UVC_HOST_PRINT_CONFIG_DESCRIPTOR
39+
3640
// UVC spinlock
3741
portMUX_TYPE uvc_lock = portMUX_INITIALIZER_UNLOCKED;
3842

@@ -120,9 +124,9 @@ static esp_err_t uvc_host_device_connected(uint8_t addr)
120124

121125
// Create UAC interfaces list in RAM, connected to the particular USB dev
122126
if (is_uvc_device) {
123-
#ifdef CONFIG_PRINTF_UVC_CONFIGURATION_DESCRIPTOR
127+
#if (UVC_HOST_PRINT_CONFIG_DESCRIPTOR)
124128
usb_print_config_descriptor(config_desc, &uvc_print_desc);
125-
#endif
129+
#endif // UVC_HOST_PRINT_CONFIG_DESCRIPTOR
126130
// Create Interfaces list for a possibility to claim Interface
127131
ESP_RETURN_ON_ERROR(uvc_host_interface_check(addr, config_desc), TAG, "uvc stream interface not found");
128132
} else {
@@ -356,7 +360,6 @@ static esp_err_t uvc_find_and_open_usb_device(uint8_t dev_addr, uint16_t vid, ui
356360
if ((vid == device_desc->idVendor || vid == UVC_HOST_ANY_VID) &&
357361
(pid == device_desc->idProduct || pid == UVC_HOST_ANY_PID) &&
358362
(dev_addr == dev_info.dev_addr || dev_addr == UVC_HOST_ANY_DEV_ADDR)) {
359-
// Return path 1: t
360363
(*dev)->constant.dev_hdl = uvc_stream->constant.dev_hdl;
361364
return ESP_OK;
362365
}
@@ -394,7 +397,6 @@ static esp_err_t uvc_find_and_open_usb_device(uint8_t dev_addr, uint16_t vid, ui
394397
if ((vid == device_desc->idVendor || vid == UVC_HOST_ANY_VID) &&
395398
(pid == device_desc->idProduct || pid == UVC_HOST_ANY_PID) &&
396399
(dev_addr == dev_addr_list[i] || dev_addr == UVC_HOST_ANY_DEV_ADDR)) {
397-
// Return path 2:
398400
(*dev)->constant.dev_hdl = current_device;
399401
return ESP_OK;
400402
}

0 commit comments

Comments
 (0)