@@ -109,6 +109,10 @@ uint8_t const* tud_descriptor_device_cb(void) {
109109 #define EPNUM_VIDEO_IN 0x81
110110#endif
111111
112+ #if defined(CFG_EXAMPLE_VIDEO_READONLY ) && !defined(CFG_EXAMPLE_VIDEO_DISABLE_MJPEG )
113+ #define USE_MJPEG
114+ #endif
115+
112116// For mcus that does not have enough SRAM for frame buffer, we use fixed frame data.
113117// To further reduce the size, we use MJPEG format instead of YUY2.
114118// Select interface descriptor and length accordingly.
@@ -197,8 +201,15 @@ typedef struct TU_ATTR_PACKED {
197201typedef struct TU_ATTR_PACKED {
198202 tusb_desc_interface_t itf ;
199203 tusb_desc_video_streaming_input_header_1byte_t header ;
204+
205+ #ifdef USE_MJPEG
206+ tusb_desc_video_format_mjpeg_t format ;
207+ tusb_desc_video_frame_mjpeg_continuous_t frame ;
208+ #else
200209 tusb_desc_video_format_uncompressed_t format ;
201210 tusb_desc_video_frame_uncompressed_continuous_t frame ;
211+ #endif
212+
202213 tusb_desc_video_streaming_color_matching_t color ;
203214 tusb_desc_endpoint_t ep ;
204215} uvc_streaming_desc_t ;
@@ -316,24 +327,38 @@ const uvc_cfg_desc_t config_desc = {
316327 .bmaControls = { 0 }
317328 },
318329 .format = {
330+ #ifdef USE_MJPEG
331+ .bLength = sizeof (tusb_desc_video_format_mjpeg_t ),
332+ .bDescriptorType = TUSB_DESC_CS_INTERFACE ,
333+ .bDescriptorSubType = VIDEO_CS_ITF_VS_FORMAT_MJPEG ,
334+ .bFormatIndex = 1 , // 1-based index
335+ .bNumFrameDescriptors = 1 ,
336+ .bmFlags = 0 ,
337+ #else
319338 .bLength = sizeof (tusb_desc_video_format_uncompressed_t ),
320339 .bDescriptorType = TUSB_DESC_CS_INTERFACE ,
321340 .bDescriptorSubType = VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED ,
322-
323341 .bFormatIndex = 1 , // 1-based index
324342 .bNumFrameDescriptors = 1 ,
325343 .guidFormat = { TUD_VIDEO_GUID_YUY2 },
326344 .bBitsPerPixel = 16 ,
345+ #endif
327346 .bDefaultFrameIndex = 1 ,
328347 .bAspectRatioX = 0 ,
329348 .bAspectRatioY = 0 ,
330349 .bmInterlaceFlags = 0 ,
331350 .bCopyProtect = 0
332351 },
333352 .frame = {
353+ #ifdef USE_MJPEG
354+ .bLength = sizeof (tusb_desc_video_frame_mjpeg_continuous_t ),
355+ .bDescriptorType = TUSB_DESC_CS_INTERFACE ,
356+ .bDescriptorSubType = VIDEO_CS_ITF_VS_FRAME_MJPEG ,
357+ #else
334358 .bLength = sizeof (tusb_desc_video_frame_uncompressed_continuous_t ),
335359 .bDescriptorType = TUSB_DESC_CS_INTERFACE ,
336360 .bDescriptorSubType = VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED ,
361+ #endif
337362
338363 .bFrameIndex = 1 , // 1-based index
339364 .bmCapabilities = 0 ,
0 commit comments