diff options
| author | sakumisu <[email protected]> | 2022-02-25 17:44:34 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2022-02-25 17:45:06 +0800 |
| commit | d7c2a0d571b71dcac0c0217102a604c4b48f5034 (patch) | |
| tree | 2bd4079a1806926b6e8f533cf83c206a9552a373 | |
| parent | 2d5a3878bfb13eaab74773019c296ed1eab6565f (diff) | |
modify video desc macro for universality
| -rw-r--r-- | class/video/usb_video.h | 90 | ||||
| -rw-r--r-- | demo/video_hs_mjpeg_template.c | 7 |
2 files changed, 23 insertions, 74 deletions
diff --git a/class/video/usb_video.h b/class/video/usb_video.h index 257a53d2..a7f4669a 100644 --- a/class/video/usb_video.h +++ b/class/video/usb_video.h @@ -1095,7 +1095,7 @@ struct video_autoexposure_mode { VIDEO_VC_PROCESSING_UNIT_DESCRIPTOR_SUBTYPE, \ 0x02, /* bUnitID */ \ 0x01, /* bSourceID */ \ - 0x00, 0x40, /* wMaxMultiplier */ \ + 0x00, 0x00, /* wMaxMultiplier */ \ 0x02, /* bControlSize */ \ 0x00, 0x00, /* bmControls */ \ 0x00, /* iProcessing */ \ @@ -1109,57 +1109,6 @@ struct video_autoexposure_mode { 0x02, /* bSourceID */ \ 0x00 /* iTerminal */ -#define VIDEO_VC_DESCRIPTOR_INIT_V2(bFirstInterface, bNumEndpoints, bcdUVC, wTotalLength, dwClockFrequency, stridx) \ - /* Interface Association Descriptor */ \ - 0x08, \ - USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION, \ - bFirstInterface, \ - 0x02, \ - USB_DEVICE_CLASS_VIDEO, \ - VIDEO_SC_VIDEO_INTERFACE_COLLECTION, \ - 0x00, \ - 0x00, \ - /* VideoControl Interface Descriptor */ \ - 0x09, /* bLength */ \ - USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \ - 0x00, /* bInterfaceNumber */ \ - 0x00, /* bAlternateSetting */ \ - 0x00, /* bNumEndpoints:1 endpoint (interrupt endpoint) */ \ - USB_DEVICE_CLASS_VIDEO, /* bInterfaceClass : CC_VIDEO */ \ - VIDEO_SC_VIDEOCONTROL, /* bInterfaceSubClass : SC_VIDEOCONTROL */ \ - VIDEO_PC_PROTOCOL_UNDEFINED, /* bInterfaceProtocol : PC_PROTOCOL_UNDEFINED */ \ - stridx, /* iInterface:Index to string descriptor that contains the string <Your Product Name> */ \ - /*Class-specific VideoControl Interface Descriptor */ \ - 0x0d, /* bLength */ \ - 0x24, /* bDescriptorType : CS_INTERFACE */ \ - VIDEO_VC_HEADER_DESCRIPTOR_SUBTYPE, /* bDescriptorSubType : VC_HEADER subtype */ \ - WBVAL(bcdUVC), /* bcdUVC : Revision of class specification that this device is based upon.*/ \ - WBVAL(wTotalLength), /* wTotalLength */ \ - DBVAL(dwClockFrequency), /* dwClockFrequency : 0x005b8d80 -> 6,000,000 == 6MHz*/ \ - 0x01, /* bInCollection : Number of streaming interfaces. */ \ - 0x01, /* baInterfaceNr(1) : VideoStreaming interface 1 belongs to this VideoControl interface.*/ \ - /* Input Terminal 1 -> Output Terminal 2 */ \ - 0x12, \ - 0x24, \ - VIDEO_VC_INPUT_TERMINAL_DESCRIPTOR_SUBTYPE, \ - 0x01, /* bTerminalID */ \ - WBVAL(VIDEO_ITT_CAMERA), /* wTerminalType : 0x0201 Camera Sensor*/ \ - 0x00, /* bAssocTerminal */ \ - 0x00, /* iTerminal */ \ - WBVAL(0x0000), /* wObjectiveFocalLengthMin */ \ - WBVAL(0x0000), /* wObjectiveFocalLengthMax */ \ - WBVAL(0x0000), /* wOcularFocalLength */ \ - 0x03, /* bControlSize */ \ - 0x00, 0x00, 0x00, /* bmControls */ \ - 0x09, \ - 0x24, \ - VIDEO_VC_OUTPUT_TERMINAL_DESCRIPTOR_SUBTYPE, \ - 0x02, /* bTerminalID */ \ - WBVAL(VIDEO_TT_STREAMING), \ - 0x00, /* bAssocTerminal */ \ - 0x01, /* bSourceID */ \ - 0x00 /* iTerminal */ - #define VIDEO_VS_DESCRIPTOR_INIT(bInterfaceNumber, bAlternateSetting, bNumEndpoints) \ /* Video Streaming (VS) Interface Descriptor */ \ 0x09, /* bLength */ \ @@ -1174,22 +1123,6 @@ struct video_autoexposure_mode { #define VIDEO_VS_HEADER_DESCRIPTOR_INIT(bNumFormats, wTotalLength, bEndpointAddress) \ /*Class-specific VideoStream Header Descriptor (Input) */ \ - 0x10, \ - 0x24, \ - VIDEO_VS_INPUT_HEADER_DESCRIPTOR_SUBTYPE, \ - bNumFormats, /* bNumFormats : One format descriptor follows. */ \ - WBVAL(wTotalLength), \ - bEndpointAddress, \ - 0x00, /* bmInfo : No dynamic format change supported. */ \ - 0x03, /* bTerminalLink : This VideoStreaming interface supplies terminal ID 3 (Output Terminal). */ \ - 0x00, /* bStillCaptureMethod : Device supports still image capture method 0. */ \ - 0x00, /* bTriggerSupport : Hardware trigger supported for still image capture */ \ - 0x00, /* bTriggerUsage : Hardware trigger should initiate a still image capture. */ \ - 0x01, /* bControlSize : Size of the bmaControls field */ \ - 0x00, 0x00, 0x00 /* bmaControls : No VideoStreaming specific controls are supported.*/ \ - -#define VIDEO_VS_HEADER_DESCRIPTOR_INIT_V2(bNumFormats, wTotalLength, bEndpointAddress) \ - /*Class-specific VideoStream Header Descriptor (Input) */ \ 0x0e, \ 0x24, \ VIDEO_VS_INPUT_HEADER_DESCRIPTOR_SUBTYPE, \ @@ -1197,12 +1130,12 @@ struct video_autoexposure_mode { WBVAL(wTotalLength), \ bEndpointAddress, \ 0x00, /* bmInfo : No dynamic format change supported. */ \ - 0x02, /* bTerminalLink : This VideoStreaming interface supplies terminal ID 2 (Output Terminal). */ \ + 0x03, /* bTerminalLink : This VideoStreaming interface supplies terminal ID 2 (Output Terminal). */ \ 0x00, /* bStillCaptureMethod : Device supports still image capture method 0. */ \ 0x00, /* bTriggerSupport : Hardware trigger supported for still image capture */ \ 0x00, /* bTriggerUsage : Hardware trigger should initiate a still image capture. */ \ 0x01, /* bControlSize : Size of the bmaControls field */ \ - 0x00 /* bmaControls : No VideoStreaming specific controls are supported.*/ + 0x00, /* bmaControls : No VideoStreaming specific controls are supported.*/ #define VIDEO_VS_FORMAT_UNCOMPRESSED_DESCRIPTOR_INIT(bFormatIndex, bNumFrameDescriptors, GUIDFormat) \ /*Payload Format(UNCOMPRESSED) Descriptor */ \ @@ -1266,5 +1199,22 @@ struct video_autoexposure_mode { DBVAL(dwMinFrameInterval1), /* dwMinFrameInterval : 1,000,000 ns *100ns -> 10 FPS,Shortest frame interval supported (at highest frame rate), in 100 ns units */ \ DBVAL(dwMinFrameInterval2) /* dwMaxFrameInterval : 1,000,000 ns *100ns -> 10 FPS,Longest frame interval supported (at lowest frame rate), in 100 ns units */ +#define VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_INIT_V2(bFrameIndex, wWidth, wHeight, dwMinBitRate, dwMaxBitRate, \ + dwMaxVideoFrameBufferSize, dwDefaultFrameInterval, dwMinFrameInterval1, dwMinFrameInterval2) \ + 0x26, /* bLength */ \ + 0x24, /* bDescriptorType : CS_INTERFACE */ \ + VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_SUBTYPE, /* bDescriptorSubType : VS_FRAME_MJPEG */ \ + bFrameIndex, /* bFrameIndex : First (and only) frame descriptor */ \ + 0x00, /* bmCapabilities : Still images using capture method 0 are supported at this frame setting.D1: Fixed frame-rate. */ \ + WBVAL(wWidth), /* wWidth (2bytes): Width of frame is 128 pixels. */ \ + WBVAL(wHeight), /* wHeight (2bytes): Height of frame is 64 pixels. */ \ + DBVAL(dwMinBitRate), /* dwMinBitRate (4bytes): Min bit rate in bits/s */ \ + DBVAL(dwMaxBitRate), /* dwMaxBitRate (4bytes): Max bit rate in bits/s */ \ + DBVAL(dwMaxVideoFrameBufferSize), /* dwMaxVideoFrameBufSize (4bytes): Maximum video or still frame size, in bytes. */ \ + DBVAL(dwDefaultFrameInterval), /* dwDefaultFrameInterval : 1,000,000 * 100ns -> 10 FPS */ \ + 0x00, /* bFrameIntervalType : Indicates how the frame interval can be programmed. 0: Continuous frame interval 1..255: The number of discrete frame */ \ + DBVAL(dwMinFrameInterval1), /* dwMinFrameInterval : 1,000,000 ns *100ns -> 10 FPS,Shortest frame interval supported (at highest frame rate), in 100 ns units */ \ + DBVAL(dwMinFrameInterval2), /* dwMaxFrameInterval : 1,000,000 ns *100ns -> 10 FPS,Longest frame interval supported (at lowest frame rate), in 100 ns units */ \ + 0x00, 0x00, 0x00, 0x00 /* dwFrameIntervalStep : No frame interval step supported. */ // clang-format on #endif /* USB_VIDEO_H_ */ diff --git a/demo/video_hs_mjpeg_template.c b/demo/video_hs_mjpeg_template.c index 8ede99e9..6f17d8cd 100644 --- a/demo/video_hs_mjpeg_template.c +++ b/demo/video_hs_mjpeg_template.c @@ -170,12 +170,11 @@ USB_DESC_SECTION const uint8_t video_descriptor[] = { USB_DESC_SECTION const uint8_t video_descriptor[] = { USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0001, 0x01), USB_CONFIG_DESCRIPTOR_INIT(USB_VIDEO_DESC_SIZ, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER), - VIDEO_VC_DESCRIPTOR_INIT_V2(0x00, 0, 0x0100, VC_TERMINAL_SIZ, 48000000, 0x02), + VIDEO_VC_DESCRIPTOR_INIT(0x00, 0, 0x0100, VC_TERMINAL_SIZ, 48000000, 0x02), VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x00, 0x00), - VIDEO_VS_HEADER_DESCRIPTOR_INIT_V2(0x01, VC_HEADER_SIZ, 0x81), - VIDEO_VS_FORMAT_MJPEG_DESCRIPTOR_INIT(0x01, 0x01), + VIDEO_VS_HEADER_DESCRIPTOR_INIT(0x01, VC_HEADER_SIZ, 0x81), VIDEO_VS_FORMAT_MJPEG_DESCRIPTOR_INIT(0x01, 0x01), - VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_INIT(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, INTERVAL, INTERVAL, 0x00061A80), + VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_INIT_V2(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, INTERVAL, INTERVAL, INTERVAL), VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x01, 0x01), /* 1.2.2.2 Standard VideoStream Isochronous Video Data Endpoint Descriptor */ 0x07, /* bLength */ |
