update example to work bulk mjpeg
This commit is contained in:
@@ -109,6 +109,10 @@ uint8_t const* tud_descriptor_device_cb(void) {
|
|||||||
#define EPNUM_VIDEO_IN 0x81
|
#define EPNUM_VIDEO_IN 0x81
|
||||||
#endif
|
#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.
|
// 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.
|
// To further reduce the size, we use MJPEG format instead of YUY2.
|
||||||
// Select interface descriptor and length accordingly.
|
// Select interface descriptor and length accordingly.
|
||||||
@@ -197,8 +201,15 @@ typedef struct TU_ATTR_PACKED {
|
|||||||
typedef struct TU_ATTR_PACKED {
|
typedef struct TU_ATTR_PACKED {
|
||||||
tusb_desc_interface_t itf;
|
tusb_desc_interface_t itf;
|
||||||
tusb_desc_video_streaming_input_header_1byte_t header;
|
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_format_uncompressed_t format;
|
||||||
tusb_desc_video_frame_uncompressed_continuous_t frame;
|
tusb_desc_video_frame_uncompressed_continuous_t frame;
|
||||||
|
#endif
|
||||||
|
|
||||||
tusb_desc_video_streaming_color_matching_t color;
|
tusb_desc_video_streaming_color_matching_t color;
|
||||||
tusb_desc_endpoint_t ep;
|
tusb_desc_endpoint_t ep;
|
||||||
} uvc_streaming_desc_t;
|
} uvc_streaming_desc_t;
|
||||||
@@ -316,14 +327,22 @@ const uvc_cfg_desc_t config_desc = {
|
|||||||
.bmaControls = { 0 }
|
.bmaControls = { 0 }
|
||||||
},
|
},
|
||||||
.format = {
|
.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),
|
.bLength = sizeof(tusb_desc_video_format_uncompressed_t),
|
||||||
.bDescriptorType = TUSB_DESC_CS_INTERFACE,
|
.bDescriptorType = TUSB_DESC_CS_INTERFACE,
|
||||||
.bDescriptorSubType = VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED,
|
.bDescriptorSubType = VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED,
|
||||||
|
|
||||||
.bFormatIndex = 1, // 1-based index
|
.bFormatIndex = 1, // 1-based index
|
||||||
.bNumFrameDescriptors = 1,
|
.bNumFrameDescriptors = 1,
|
||||||
.guidFormat = { TUD_VIDEO_GUID_YUY2 },
|
.guidFormat = { TUD_VIDEO_GUID_YUY2 },
|
||||||
.bBitsPerPixel = 16,
|
.bBitsPerPixel = 16,
|
||||||
|
#endif
|
||||||
.bDefaultFrameIndex = 1,
|
.bDefaultFrameIndex = 1,
|
||||||
.bAspectRatioX = 0,
|
.bAspectRatioX = 0,
|
||||||
.bAspectRatioY = 0,
|
.bAspectRatioY = 0,
|
||||||
@@ -331,9 +350,15 @@ const uvc_cfg_desc_t config_desc = {
|
|||||||
.bCopyProtect = 0
|
.bCopyProtect = 0
|
||||||
},
|
},
|
||||||
.frame = {
|
.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),
|
.bLength = sizeof(tusb_desc_video_frame_uncompressed_continuous_t),
|
||||||
.bDescriptorType = TUSB_DESC_CS_INTERFACE,
|
.bDescriptorType = TUSB_DESC_CS_INTERFACE,
|
||||||
.bDescriptorSubType = VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED,
|
.bDescriptorSubType = VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED,
|
||||||
|
#endif
|
||||||
|
|
||||||
.bFrameIndex = 1, // 1-based index
|
.bFrameIndex = 1, // 1-based index
|
||||||
.bmCapabilities = 0,
|
.bmCapabilities = 0,
|
||||||
|
@@ -405,7 +405,7 @@ typedef struct TU_ATTR_PACKED {
|
|||||||
uint8_t bDescriptorSubType;
|
uint8_t bDescriptorSubType;
|
||||||
uint8_t bFormatIndex;
|
uint8_t bFormatIndex;
|
||||||
uint8_t bNumFrameDescriptors;
|
uint8_t bNumFrameDescriptors;
|
||||||
uint8_t bmFlags;
|
uint8_t bmFlags; // Bit 0: fixed size samples (1 = yes)
|
||||||
uint8_t bDefaultFrameIndex;
|
uint8_t bDefaultFrameIndex;
|
||||||
uint8_t bAspectRatioX;
|
uint8_t bAspectRatioX;
|
||||||
uint8_t bAspectRatioY;
|
uint8_t bAspectRatioY;
|
||||||
@@ -415,7 +415,15 @@ typedef struct TU_ATTR_PACKED {
|
|||||||
|
|
||||||
// MJPEG payload specs: 3.1.2 frame descriptor (same as uncompressed)
|
// MJPEG payload specs: 3.1.2 frame descriptor (same as uncompressed)
|
||||||
typedef tusb_desc_video_frame_uncompressed_t tusb_desc_video_frame_mjpeg_t;
|
typedef tusb_desc_video_frame_uncompressed_t tusb_desc_video_frame_mjpeg_t;
|
||||||
|
typedef tusb_desc_video_frame_uncompressed_1int_t tusb_desc_video_frame_mjpeg_1int_t;
|
||||||
|
typedef tusb_desc_video_frame_uncompressed_2int_t tusb_desc_video_frame_mjpeg_2int_t;
|
||||||
|
typedef tusb_desc_video_frame_uncompressed_3int_t tusb_desc_video_frame_mjpeg_3int_t;
|
||||||
|
typedef tusb_desc_video_frame_uncompressed_4int_t tusb_desc_video_frame_mjpeg_4int_t;
|
||||||
|
|
||||||
|
// continuous = 3 intervals: min, max, step
|
||||||
|
typedef tusb_desc_video_frame_mjpeg_3int_t tusb_desc_video_frame_mjpeg_continuous_t;
|
||||||
|
|
||||||
|
//------------- DV -------------//
|
||||||
// DV payload specs: 3.1.1
|
// DV payload specs: 3.1.1
|
||||||
typedef struct TU_ATTR_PACKED {
|
typedef struct TU_ATTR_PACKED {
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
|
Reference in New Issue
Block a user