summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-01-26 23:23:38 +0700
committerhathach <[email protected]>2024-01-26 23:23:38 +0700
commit0daf8ec51b9513fbab9601fedb2150dda3927b05 (patch)
tree3dc13921b3ac20f6232a007135a232cad686c13d /examples
parentb5cd673330fc87f2981ecf139b24940df5cb3cfe (diff)
update example to work bulk mjpeg
Diffstat (limited to 'examples')
-rw-r--r--examples/device/video_capture/src/usb_descriptors.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/examples/device/video_capture/src/usb_descriptors.c b/examples/device/video_capture/src/usb_descriptors.c
index 8e54d3afd..90a6b27a2 100644
--- a/examples/device/video_capture/src/usb_descriptors.c
+++ b/examples/device/video_capture/src/usb_descriptors.c
@@ -109,6 +109,10 @@ uint8_t const* tud_descriptor_device_cb(void) {
#define EPNUM_VIDEO_IN 0x81
#endif
+#if defined(CFG_EXAMPLE_VIDEO_READONLY) && !defined(CFG_EXAMPLE_VIDEO_DISABLE_MJPEG)
+ #define USE_MJPEG
+#endif
+
// For mcus that does not have enough SRAM for frame buffer, we use fixed frame data.
// To further reduce the size, we use MJPEG format instead of YUY2.
// Select interface descriptor and length accordingly.
@@ -197,8 +201,15 @@ typedef struct TU_ATTR_PACKED {
typedef struct TU_ATTR_PACKED {
tusb_desc_interface_t itf;
tusb_desc_video_streaming_input_header_1byte_t header;
+
+#ifdef USE_MJPEG
+ tusb_desc_video_format_mjpeg_t format;
+ tusb_desc_video_frame_mjpeg_continuous_t frame;
+#else
tusb_desc_video_format_uncompressed_t format;
tusb_desc_video_frame_uncompressed_continuous_t frame;
+#endif
+
tusb_desc_video_streaming_color_matching_t color;
tusb_desc_endpoint_t ep;
} uvc_streaming_desc_t;
@@ -316,14 +327,22 @@ const uvc_cfg_desc_t config_desc = {
.bmaControls = { 0 }
},
.format = {
+#ifdef USE_MJPEG
+ .bLength = sizeof(tusb_desc_video_format_mjpeg_t),
+ .bDescriptorType = TUSB_DESC_CS_INTERFACE,
+ .bDescriptorSubType = VIDEO_CS_ITF_VS_FORMAT_MJPEG,
+ .bFormatIndex = 1, // 1-based index
+ .bNumFrameDescriptors = 1,
+ .bmFlags = 0,
+#else
.bLength = sizeof(tusb_desc_video_format_uncompressed_t),
.bDescriptorType = TUSB_DESC_CS_INTERFACE,
.bDescriptorSubType = VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED,
-
.bFormatIndex = 1, // 1-based index
.bNumFrameDescriptors = 1,
.guidFormat = { TUD_VIDEO_GUID_YUY2 },
.bBitsPerPixel = 16,
+#endif
.bDefaultFrameIndex = 1,
.bAspectRatioX = 0,
.bAspectRatioY = 0,
@@ -331,9 +350,15 @@ const uvc_cfg_desc_t config_desc = {
.bCopyProtect = 0
},
.frame = {
+#ifdef USE_MJPEG
+ .bLength = sizeof(tusb_desc_video_frame_mjpeg_continuous_t),
+ .bDescriptorType = TUSB_DESC_CS_INTERFACE,
+ .bDescriptorSubType = VIDEO_CS_ITF_VS_FRAME_MJPEG,
+#else
.bLength = sizeof(tusb_desc_video_frame_uncompressed_continuous_t),
.bDescriptorType = TUSB_DESC_CS_INTERFACE,
.bDescriptorSubType = VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED,
+#endif
.bFrameIndex = 1, // 1-based index
.bmCapabilities = 0,