Open FFBoard
Open source force feedback firmware
video.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2021 Koji KITAYAMA
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
27#ifndef TUSB_VIDEO_H_
28#define TUSB_VIDEO_H_
29
30#include "common/tusb_common.h"
31
32enum {
34};
35
36// Table 3-19 Color Matching Descriptor
37typedef enum {
39 VIDEO_COLOR_PRIMARIES_BT709, // sRGB (default)
45
46// Table 3-19 Color Matching Descriptor
47typedef enum {
57
58// Table 3-19 Color Matching Descriptor
59typedef enum {
64 VIDEO_COLOR_COEF_SMPTE170M, // BT.601 default
67
68/* 4.2.1.2 Request Error Code Control */
69typedef enum {
70 VIDEO_ERROR_NONE = 0, /* The request succeeded. */
81
82/* A.2 Interface Subclass */
83typedef enum {
89
90/* A.3 Interface Protocol */
91typedef enum {
95
96/* A.5 Class-Specific VideoControl Interface Descriptor Subtypes */
97typedef enum {
108
109/* A.6 Class-Specific VideoStreaming Interface Descriptor Subtypes */
110typedef enum {
132
133/* A.7. Class-Specific Endpoint Descriptor Subtypes */
134typedef enum {
140
141/* A.8 Class-Specific Request Codes */
142typedef enum {
159
160/* A.9.1 VideoControl Interface Control Selectors */
161typedef enum {
166
167/* A.9.8 VideoStreaming Interface Control Selectors */
168typedef enum {
179
181
182/* B. Terminal Types */
183typedef enum {
184 // Terminal
187
188 // Input
192
193 // Output
197
198 // External
204
205//--------------------------------------------------------------------+
206// Video Control (VC) Descriptors
207//--------------------------------------------------------------------+
208
209/* 2.3.4.2 */
210#define tusb_desc_video_control_header_nitf_t(_nitf) \
211 struct TU_ATTR_PACKED { \
212 uint8_t bLength; \
213 uint8_t bDescriptorType; \
214 uint8_t bDescriptorSubType; \
215 uint16_t bcdUVC; \
216 uint16_t wTotalLength; \
217 uint32_t dwClockFrequency; /* deprecated */ \
218 uint8_t bInCollection; \
219 uint8_t baInterfaceNr[_nitf]; \
220 }
221
222typedef tusb_desc_video_control_header_nitf_t() tusb_desc_video_control_header_t;
223typedef tusb_desc_video_control_header_nitf_t(1) tusb_desc_video_control_header_1itf_t;
224typedef tusb_desc_video_control_header_nitf_t(2) tusb_desc_video_control_header_2itf_t;
225typedef tusb_desc_video_control_header_nitf_t(3) tusb_desc_video_control_header_3itf_t;
226typedef tusb_desc_video_control_header_nitf_t(4) tusb_desc_video_control_header_4itf_t;
227
228typedef struct TU_ATTR_PACKED {
229 uint8_t bLength;
230 uint8_t bDescriptorType;
231 uint8_t bDescriptorSubType;
232 uint8_t bTerminalID;
233 uint16_t wTerminalType;
234 uint8_t bAssocTerminal;
235 uint8_t iTerminal;
237
239
240typedef struct TU_ATTR_PACKED {
241 uint8_t bLength;
242 uint8_t bDescriptorType;
243 uint8_t bDescriptorSubType;
244 uint8_t bTerminalID;
246 uint8_t bAssocTerminal;
247 uint8_t bSourceID;
248 uint8_t iTerminal;
250
251TU_VERIFY_STATIC(sizeof(tusb_desc_video_control_output_terminal_t) == 9, "size is not correct");
252
253typedef struct TU_ATTR_PACKED {
254 uint8_t bLength;
255 uint8_t bDescriptorType;
256 uint8_t bDescriptorSubType;
257 uint8_t bTerminalID;
259 uint8_t bAssocTerminal;
260 uint8_t iTerminal;
261
266 uint8_t bmControls[3];
268
269TU_VERIFY_STATIC(sizeof(tusb_desc_video_control_camera_terminal_t) == 18, "size is not correct");
270
271//--------------------------------------------------------------------+
272// Video Streaming (VS) Descriptors
273//--------------------------------------------------------------------+
274
275/* 3.9.2.1 */
276#define tusb_desc_video_streaming_input_header_nbyte_t(_nb) \
277 struct TU_ATTR_PACKED { \
278 uint8_t bLength; \
279 uint8_t bDescriptorType; \
280 uint8_t bDescriptorSubType; \
281 uint8_t bNumFormats; /* Number of video payload Format descriptors for this interface */ \
282 uint16_t wTotalLength; \
283 uint8_t bEndpointAddress; \
284 uint8_t bmInfo; /* Bit 0: dynamic format change supported */ \
285 uint8_t bTerminalLink; \
286 uint8_t bStillCaptureMethod; \
287 uint8_t bTriggerSupport; /* Hardware trigger supported */ \
288 uint8_t bTriggerUsage; \
289 uint8_t bControlSize; /* sizeof of each control item */ \
290 uint8_t bmaControls[_nb]; \
291 }
292
293typedef tusb_desc_video_streaming_input_header_nbyte_t() tusb_desc_video_streaming_input_header_t;
294typedef tusb_desc_video_streaming_input_header_nbyte_t(1) tusb_desc_video_streaming_input_header_1byte_t;
295typedef tusb_desc_video_streaming_input_header_nbyte_t(2) tusb_desc_video_streaming_input_header_2byte_t;
296typedef tusb_desc_video_streaming_input_header_nbyte_t(3) tusb_desc_video_streaming_input_header_3byte_t;
297typedef tusb_desc_video_streaming_input_header_nbyte_t(4) tusb_desc_video_streaming_input_header_4byte_t;
298
299/* 3.9.2.2 */
300typedef struct TU_ATTR_PACKED {
301 uint8_t bLength;
302 uint8_t bDescriptorType;
303 uint8_t bDescriptorSubType;
304 uint8_t bNumFormats;
305 uint16_t wTotalLength;
307 uint8_t bTerminalLink;
308 uint8_t bControlSize;
309 uint8_t bmaControls[];
311
312typedef struct TU_ATTR_PACKED {
313 uint8_t bLength;
314 uint8_t bDescriptorType;
315 uint8_t bDescriptorSubType;
316 uint8_t bNumFormats;
318 uint8_t bEndpointAddress;
319 union {
320 struct {
321 uint8_t bmInfo;
322 uint8_t bTerminalLink;
326 uint8_t bControlSize;
327 uint8_t bmaControls[];
329 struct {
330 uint8_t bEndpointAddress;
331 uint8_t bTerminalLink;
332 uint8_t bControlSize;
333 uint8_t bmaControls[];
335 };
337
338// 3.9.2.6 Color Matching Descriptor
339typedef struct TU_ATTR_PACKED {
340 uint8_t bLength;
341 uint8_t bDescriptorType;
342 uint8_t bDescriptorSubType;
347
348TU_VERIFY_STATIC(sizeof(tusb_desc_video_streaming_color_matching_t) == 6, "size is not correct");
349
350//--------------------------------------------------------------------+
351// Format and Frame Descriptor
352// Note: bFormatIndex & bFrameIndex are 1-based index
353//--------------------------------------------------------------------+
354
355//------------- Uncompressed -------------//
356// Uncompressed payload specs: 3.1.1 format descriptor
357typedef struct TU_ATTR_PACKED {
358 uint8_t bLength;
359 uint8_t bDescriptorType;
360 uint8_t bDescriptorSubType;
362 uint8_t bNumFrameDescriptors; // Number of frame descriptors for this format
363 uint8_t guidFormat[16];
371
372TU_VERIFY_STATIC(sizeof(tusb_desc_video_format_uncompressed_t) == 27, "size is not correct");
373
374// Uncompressed payload specs: 3.1.2 frame descriptor
375#define tusb_desc_video_frame_uncompressed_nint_t(_nint) \
376 struct TU_ATTR_PACKED { \
377 uint8_t bLength; \
378 uint8_t bDescriptorType; \
379 uint8_t bDescriptorSubType; \
380 uint8_t bFrameIndex; \
381 uint8_t bmCapabilities; \
382 uint16_t wWidth; \
383 uint16_t wHeight; \
384 uint32_t dwMinBitRate; \
385 uint32_t dwMaxBitRate; \
386 uint32_t dwMaxVideoFrameBufferSize; /* deprecated in 1.5 */ \
387 uint32_t dwDefaultFrameInterval; /* 100ns unit */\
388 uint8_t bFrameIntervalType; \
389 uint32_t dwFrameInterval[_nint]; \
390 }
391
392typedef tusb_desc_video_frame_uncompressed_nint_t() tusb_desc_video_frame_uncompressed_t;
393typedef tusb_desc_video_frame_uncompressed_nint_t(1) tusb_desc_video_frame_uncompressed_1int_t;
394typedef tusb_desc_video_frame_uncompressed_nint_t(2) tusb_desc_video_frame_uncompressed_2int_t;
395typedef tusb_desc_video_frame_uncompressed_nint_t(3) tusb_desc_video_frame_uncompressed_3int_t;
396typedef tusb_desc_video_frame_uncompressed_nint_t(4) tusb_desc_video_frame_uncompressed_4int_t;
397
398// continuous = 3 intervals: min, max, step
399typedef tusb_desc_video_frame_uncompressed_3int_t tusb_desc_video_frame_uncompressed_continuous_t;
400
402
403//------------- MJPEG -------------//
404// MJPEG payload specs: 3.1.1 format descriptor
405typedef struct TU_ATTR_PACKED {
406 uint8_t bLength;
407 uint8_t bDescriptorType;
408 uint8_t bDescriptorSubType;
409 uint8_t bFormatIndex;
410 uint8_t bNumFrameDescriptors;
411 uint8_t bmFlags; // Bit 0: fixed size samples (1 = yes)
412 uint8_t bDefaultFrameIndex;
413 uint8_t bAspectRatioX;
414 uint8_t bAspectRatioY;
415 uint8_t bmInterlaceFlags;
416 uint8_t bCopyProtect;
418
419TU_VERIFY_STATIC(sizeof(tusb_desc_video_format_mjpeg_t) == 11, "size is not correct");
420
421// MJPEG payload specs: 3.1.2 frame descriptor (same as uncompressed)
422typedef tusb_desc_video_frame_uncompressed_t tusb_desc_video_frame_mjpeg_t;
423typedef tusb_desc_video_frame_uncompressed_1int_t tusb_desc_video_frame_mjpeg_1int_t;
424typedef tusb_desc_video_frame_uncompressed_2int_t tusb_desc_video_frame_mjpeg_2int_t;
425typedef tusb_desc_video_frame_uncompressed_3int_t tusb_desc_video_frame_mjpeg_3int_t;
426typedef tusb_desc_video_frame_uncompressed_4int_t tusb_desc_video_frame_mjpeg_4int_t;
427
428// continuous = 3 intervals: min, max, step
430
431//------------- DV -------------//
432// DV payload specs: 3.1.1
433typedef struct TU_ATTR_PACKED {
434 uint8_t bLength;
435 uint8_t bDescriptorType;
436 uint8_t bDescriptorSubType;
437 uint8_t bFormatIndex;
438 uint32_t dwMaxVideoFrameBufferSize; /* deprecated */
439 uint8_t bFormatType;
441
442// Frame Based payload specs: 3.1.1
443typedef struct TU_ATTR_PACKED {
444 uint8_t bLength;
445 uint8_t bDescriptorType;
446 uint8_t bDescriptorSubType;
447 uint8_t bFormatIndex;
448 uint8_t bNumFrameDescriptors;
449 uint8_t guidFormat[16];
450 uint8_t bBitsPerPixel;
451 uint8_t bDefaultFrameIndex;
452 uint8_t bAspectRatioX;
453 uint8_t bAspectRatioY;
454 uint8_t bmInterlaceFlags;
455 uint8_t bCopyProtect;
458
459typedef struct TU_ATTR_PACKED {
460 uint8_t bLength;
461 uint8_t bDescriptorType;
462 uint8_t bDescriptorSubType;
463 uint8_t bFrameIndex;
467 uint32_t dwMinBitRate;
468 uint32_t dwMaxBitRate;
472 uint32_t dwFrameInterval[];
474
475//--------------------------------------------------------------------+
476// Requests
477//--------------------------------------------------------------------+
478
479/* 2.4.3.3 */
480typedef struct TU_ATTR_PACKED {
482 union {
484 struct {
485 uint8_t FrameID: 1;
486 uint8_t EndOfFrame: 1;
489 uint8_t PayloadSpecific: 1;
490 uint8_t StillImage: 1;
491 uint8_t Error: 1;
492 uint8_t EndOfHeader: 1;
493 };
494 };
496
497/* 4.3.1.1 */
498typedef struct TU_ATTR_PACKED {
499 union {
500 uint8_t bmHint;
501 struct TU_ATTR_PACKED {
507 uint16_t : 0;
509 };
510 uint8_t bFormatIndex;
511 uint8_t bFrameIndex;
512 uint32_t dwFrameInterval;
521 union {
523 struct TU_ATTR_PACKED {
524 uint8_t FrameID : 1;
525 uint8_t EndOfFrame: 1;
526 uint8_t EndOfSlice: 1;
527 uint8_t : 0;
529 };
531 uint8_t bMinVersion;
532 uint8_t bMaxVersion;
533 uint8_t bUsage;
535 uint8_t bmSettings;
540
541TU_VERIFY_STATIC( sizeof(video_probe_and_commit_control_t) == 48, "size is not correct");
542
543#define TUD_VIDEO_DESC_IAD_LEN 8
544#define TUD_VIDEO_DESC_STD_VC_LEN 9
545#define TUD_VIDEO_DESC_CS_VC_LEN 12
546#define TUD_VIDEO_DESC_INPUT_TERM_LEN 8
547#define TUD_VIDEO_DESC_OUTPUT_TERM_LEN 9
548#define TUD_VIDEO_DESC_CAMERA_TERM_LEN 18
549#define TUD_VIDEO_DESC_STD_VS_LEN 9
550#define TUD_VIDEO_DESC_CS_VS_IN_LEN 13
551#define TUD_VIDEO_DESC_CS_VS_OUT_LEN 9
552#define TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR_LEN 27
553#define TUD_VIDEO_DESC_CS_VS_FMT_MJPEG_LEN 11
554#define TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_CONT_LEN 38
555#define TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_DISC_LEN 26
556#define TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_CONT_LEN 38
557#define TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_DISC_LEN 26
558#define TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING_LEN 6
559
560/* 2.2 compression formats */
561#define TUD_VIDEO_GUID_YUY2 0x59,0x55,0x59,0x32,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
562#define TUD_VIDEO_GUID_NV12 0x4E,0x56,0x31,0x32,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
563#define TUD_VIDEO_GUID_M420 0x4D,0x34,0x32,0x30,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
564#define TUD_VIDEO_GUID_I420 0x49,0x34,0x32,0x30,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
565
566#define TUD_VIDEO_DESC_IAD(_firstitf, _nitfs, _stridx) \
567 TUD_VIDEO_DESC_IAD_LEN, TUSB_DESC_INTERFACE_ASSOCIATION, \
568 _firstitf, _nitfs, TUSB_CLASS_VIDEO, VIDEO_SUBCLASS_INTERFACE_COLLECTION, \
569 VIDEO_ITF_PROTOCOL_UNDEFINED, _stridx
570
571#define TUD_VIDEO_DESC_STD_VC(_itfnum, _nEPs, _stridx) \
572 TUD_VIDEO_DESC_STD_VC_LEN, TUSB_DESC_INTERFACE, _itfnum, /* fixed to zero */ 0x00, \
573 _nEPs, TUSB_CLASS_VIDEO, VIDEO_SUBCLASS_CONTROL, VIDEO_ITF_PROTOCOL_15, _stridx
574
575/* 3.7.2 */
576#define TUD_VIDEO_DESC_CS_VC(_bcdUVC, _totallen, _clkfreq, ...) \
577 TUD_VIDEO_DESC_CS_VC_LEN + (TU_ARGS_NUM(__VA_ARGS__)), TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_HEADER, \
578 U16_TO_U8S_LE(_bcdUVC), U16_TO_U8S_LE((_totallen) + TUD_VIDEO_DESC_CS_VC_LEN + (TU_ARGS_NUM(__VA_ARGS__))), \
579 U32_TO_U8S_LE(_clkfreq), TU_ARGS_NUM(__VA_ARGS__), __VA_ARGS__
580
581/* 3.7.2.1 */
582#define TUD_VIDEO_DESC_INPUT_TERM(_tid, _tt, _at, _stridx) \
583 TUD_VIDEO_DESC_INPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_INPUT_TERMINAL, \
584 _tid, U16_TO_U8S_LE(_tt), _at, _stridx
585
586/* 3.7.2.2 */
587#define TUD_VIDEO_DESC_OUTPUT_TERM(_tid, _tt, _at, _srcid, _stridx) \
588 TUD_VIDEO_DESC_OUTPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_OUTPUT_TERMINAL, \
589 _tid, U16_TO_U8S_LE(_tt), _at, _srcid, _stridx
590
591/* 3.7.2.3 */
592#define TUD_VIDEO_DESC_CAMERA_TERM(_tid, _at, _stridx, _focal_min, _focal_max, _focal, _ctls) \
593 TUD_VIDEO_DESC_CAMERA_TERM_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_INPUT_TERMINAL, \
594 _tid, U16_TO_U8S_LE(VIDEO_ITT_CAMERA), _at, _stridx, \
595 U16_TO_U8S_LE(_focal_min), U16_TO_U8S_LE(_focal_max), U16_TO_U8S_LE(_focal), 3, \
596 TU_U32_BYTE0(_ctls), TU_U32_BYTE1(_ctls), TU_U32_BYTE2(_ctls)
597
598/* 3.9.1 */
599#define TUD_VIDEO_DESC_STD_VS(_itfnum, _alt, _epn, _stridx) \
600 TUD_VIDEO_DESC_STD_VS_LEN, TUSB_DESC_INTERFACE, _itfnum, _alt, \
601 _epn, TUSB_CLASS_VIDEO, VIDEO_SUBCLASS_STREAMING, VIDEO_ITF_PROTOCOL_15, _stridx
602
603/* 3.9.2.1 */
604#define TUD_VIDEO_DESC_CS_VS_INPUT(_numfmt, _totallen, _ep, _inf, _termlnk, _sticaptmeth, _trgspt, _trgusg, ...) \
605 TUD_VIDEO_DESC_CS_VS_IN_LEN + (_numfmt) * (TU_ARGS_NUM(__VA_ARGS__)), TUSB_DESC_CS_INTERFACE, \
606 VIDEO_CS_ITF_VS_INPUT_HEADER, _numfmt, \
607 U16_TO_U8S_LE((_totallen) + TUD_VIDEO_DESC_CS_VS_IN_LEN + (_numfmt) * (TU_ARGS_NUM(__VA_ARGS__))), \
608 _ep, _inf, _termlnk, _sticaptmeth, _trgspt, _trgusg, (TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__
609
610/* 3.9.2.2 */
611#define TUD_VIDEO_DESC_CS_VS_OUTPUT(_numfmt, _totallen, _ep, _inf, _termlnk, ...) \
612 TUD_VIDEO_DESC_CS_VS_OUT_LEN + (_numfmt) * (TU_ARGS_NUM(__VA_ARGS__)), TUSB_DESC_CS_INTERFACE, \
613 VIDEO_CS_ITF_VS_OUTPUT_HEADER, _numfmt, \
614 U16_TO_U8S_LE((_totallen) + TUD_VIDEO_DESC_CS_VS_OUT_LEN + (_numfmt) * (TU_ARGS_NUM(__VA_ARGS__))), \
615 _ep, _inf, _termlnk, (TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__
616
617/* Uncompressed 3.1.1 */
618#define TUD_VIDEO_GUID(_g0,_g1,_g2,_g3,_g4,_g5,_g6,_g7,_g8,_g9,_g10,_g11,_g12,_g13,_g14,_g15) _g0,_g1,_g2,_g3,_g4,_g5,_g6,_g7,_g8,_g9,_g10,_g11,_g12,_g13,_g14,_g15
619
620#define TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR(_fmtidx, _numfrmdesc, \
621 _guid, _bitsperpix, _frmidx, _asrx, _asry, _interlace, _cp) \
622 TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED, \
623 _fmtidx, _numfrmdesc, TUD_VIDEO_GUID(_guid), \
624 _bitsperpix, _frmidx, _asrx, _asry, _interlace, _cp
625
626/* Uncompressed 3.1.2 Table 3-3 */
627#define TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_CONT(_frmidx, _cap, _width, _height, _minbr, _maxbr, _maxfrmbufsz, _frminterval, _minfrminterval, _maxfrminterval, _frmintervalstep) \
628 TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_CONT_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED, \
629 _frmidx, _cap, U16_TO_U8S_LE(_width), U16_TO_U8S_LE(_height), U32_TO_U8S_LE(_minbr), U32_TO_U8S_LE(_maxbr), \
630 U32_TO_U8S_LE(_maxfrmbufsz), U32_TO_U8S_LE(_frminterval), 0, \
631 U32_TO_U8S_LE(_minfrminterval), U32_TO_U8S_LE(_maxfrminterval), U32_TO_U8S_LE(_frmintervalstep)
632
633/* Uncompressed 3.1.2 Table 3-4 */
634#define TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_DISC(_frmidx, _cap, _width, _height, _minbr, _maxbr, _maxfrmbufsz, _frminterval, ...) \
635 TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_DISC_LEN + (TU_ARGS_NUM(__VA_ARGS__)) * 4, \
636 TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED, \
637 _frmidx, _cap, U16_TO_U8S_LE(_width), U16_TO_U8S_LE(_height), U32_TO_U8S_LE(_minbr), U32_TO_U8S_LE(_maxbr), \
638 U32_TO_U8S_LE(_maxfrmbufsz), U32_TO_U8S_LE(_frminterval), (TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__
639
640/* Motion-JPEG 3.1.1 Table 3-1 */
641#define TUD_VIDEO_DESC_CS_VS_FMT_MJPEG(_fmtidx, _numfrmdesc, _fixed_sz, _frmidx, _asrx, _asry, _interlace, _cp) \
642 TUD_VIDEO_DESC_CS_VS_FMT_MJPEG_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FORMAT_MJPEG, \
643 _fmtidx, _numfrmdesc, _fixed_sz, _frmidx, _asrx, _asry, _interlace, _cp
644
645/* Motion-JPEG 3.1.1 Table 3-2 and 3-3 */
646#define TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_CONT(_frmidx, _cap, _width, _height, _minbr, _maxbr, _maxfrmbufsz, _frminterval, _minfrminterval, _maxfrminterval, _frmintervalstep) \
647 TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_CONT_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FRAME_MJPEG, \
648 _frmidx, _cap, U16_TO_U8S_LE(_width), U16_TO_U8S_LE(_height), U32_TO_U8S_LE(_minbr), U32_TO_U8S_LE(_maxbr), \
649 U32_TO_U8S_LE(_maxfrmbufsz), U32_TO_U8S_LE(_frminterval), 0, \
650 U32_TO_U8S_LE(_minfrminterval), U32_TO_U8S_LE(_maxfrminterval), U32_TO_U8S_LE(_frmintervalstep)
651
652/* Motion-JPEG 3.1.1 Table 3-2 and 3-4 */
653#define TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_DISC(_frmidx, _cap, _width, _height, _minbr, _maxbr, _maxfrmbufsz, _frminterval, ...) \
654 TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_DISC_LEN + (TU_ARGS_NUM(__VA_ARGS__)) * 4, \
655 TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FRAME_MJPEG, \
656 _frmidx, _cap, U16_TO_U8S_LE(_width), U16_TO_U8S_LE(_height), U32_TO_U8S_LE(_minbr), U32_TO_U8S_LE(_maxbr), \
657 U32_TO_U8S_LE(_maxfrmbufsz), U32_TO_U8S_LE(_frminterval), (TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__
658
659/* 3.9.2.6 */
660#define TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING(_color, _trns, _mat) \
661 TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING_LEN, \
662 TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_COLORFORMAT, \
663 _color, _trns, _mat
664
665/* 3.10.1.1 */
666#define TUD_VIDEO_DESC_EP_ISO(_ep, _epsize, _ep_interval) \
667 7, TUSB_DESC_ENDPOINT, _ep, (uint8_t) (TUSB_XFER_ISOCHRONOUS | TUSB_ISO_EP_ATT_ASYNCHRONOUS),\
668 U16_TO_U8S_LE(_epsize), _ep_interval
669
670/* 3.10.1.2 */
671#define TUD_VIDEO_DESC_EP_BULK(_ep, _epsize, _ep_interval) \
672 7, TUSB_DESC_ENDPOINT, _ep, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), _ep_interval
673
674#endif
AUDIO Channel Cluster Descriptor (4.1)
Definition: audio.h:647
struct TU_ATTR_PACKED::@56::@58 input
uint16_t wObjectiveFocalLengthMin
Definition: video.h:262
uint8_t EndOfHeader
Definition: video.h:492
uint8_t bControlSize
Definition: video.h:265
uint8_t EndOfFrame
Definition: video.h:486
uint8_t bStillCaptureMethod
Definition: video.h:323
uint8_t bNumFormats
Definition: video.h:304
uint8_t bAssocTerminal
Terminal ID of the Terminal that is associated with this Clock Source.
Definition: audio.h:674
uint32_t dwMaxBitRate
Definition: video.h:468
struct TU_ATTR_PACKED::@56::@59 output
uint16_t wCompQuality
Definition: video.h:505
uint32_t dwFrameInterval[]
Definition: video.h:472
uint8_t StillImage
Definition: video.h:490
uint32_t dwMaxVideoFrameSize
Definition: video.h:518
uint8_t bAspectRatioY
Definition: video.h:367
uint8_t bmControls
See: audio_cs_ac_interface_control_pos_t.
Definition: audio.h:662
uint32_t dwMaxPayloadTransferSize
Definition: video.h:519
uint8_t bDescriptorSubType
Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_HEADER.
Definition: audio.h:658
uint16_t wTotalLength
Total number of bytes returned for the class-specific AudioControl interface descriptor....
Definition: audio.h:661
uint8_t bTerminalID
Constant uniquely identifying the Terminal within the audio function. This value is used in all reque...
Definition: audio.h:724
uint8_t bBitDepthLuma
Definition: video.h:534
uint8_t bSourceID
ID of the Unit or Terminal to which this Terminal is connected.
Definition: audio.h:744
uint16_t wCompWindowSize
Definition: video.h:506
uint32_t dwMaxVideoFrameBufferSize
Definition: video.h:438
uint16_t wTerminalType
Constant characterizing the type of Terminal. See: audio_terminal_type_t for USB streaming and audio_...
Definition: audio.h:725
uint8_t bFrameIndex
Definition: video.h:463
uint8_t bColorPrimaries
Definition: video.h:343
struct TU_ATTR_PACKED::@64::TU_ATTR_PACKED Hint
uint8_t bTriggerUsage
Definition: video.h:325
uint8_t PayloadSpecific
Definition: video.h:489
uint8_t bFormatIndex
Definition: video.h:361
uint8_t bTriggerSupport
Definition: video.h:324
struct TU_ATTR_PACKED::@67::TU_ATTR_PACKED FramingInfo
uint8_t bUsage
Definition: video.h:533
uint8_t bMinVersion
Definition: video.h:531
uint8_t bmFramingInfo
Definition: video.h:522
uint8_t bDefaultFrameIndex
Definition: video.h:365
uint32_t dwClockFrequency
Definition: video.h:520
uint8_t bTerminalLink
The Terminal ID of the Terminal to which this interface is connected.
Definition: audio.h:784
uint8_t bmFlags
Definition: video.h:411
uint16_t wKeyFrameRatel
Definition: video.h:503
uint8_t bFrameIntervalType
Definition: video.h:470
uint8_t bCopyProtect
Definition: video.h:369
uint16_t dwFrameInterval
Definition: video.h:502
volatile uint16_t
Definition: hcd_rusb2.c:58
uint8_t iTerminal
Index of a string descriptor, describing the Input Terminal.
Definition: audio.h:732
uint8_t bAspectRatioX
Definition: video.h:366
uint16_t wWidth
Definition: video.h:465
uint8_t bNumFrameDescriptors
Definition: video.h:362
uint8_t bBitsPerPixel
Definition: video.h:364
uint16_t wDelay
Definition: video.h:517
uint8_t bmHint
Definition: video.h:500
uint8_t bMaxNumberOfRefFramesPlus1
Definition: video.h:536
uint8_t bVaribaleSize
Definition: video.h:456
uint8_t bDescriptorType
Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
Definition: audio.h:657
uint8_t bMatrixCoefficients
Definition: video.h:345
uint8_t bmaControls[]
Definition: video.h:309
uint8_t PresentationTime
Definition: video.h:487
uint32_t dwMinBitRate
Definition: video.h:467
uint32_t dwBytesPerLine
Definition: video.h:471
uint32_t dwDefaultFrameInterval
Definition: video.h:469
uint8_t bmSettings
Definition: video.h:535
uint16_t wPFrameRate
Definition: video.h:504
uint8_t bLength
Size of this descriptor in bytes: 9.
Definition: audio.h:656
uint16_t wOcularFocalLength
Definition: video.h:264
uint8_t bmHeaderInfo
Definition: video.h:483
uint8_t bHeaderLength
Definition: video.h:481
uint8_t bmInterlaceFlags
Definition: video.h:368
uint8_t bTransferCharacteristics
Definition: video.h:344
uint8_t bMaxVersion
Definition: video.h:532
uint8_t FrameID
Definition: video.h:485
uint8_t bEndpointAddress
Definition: video.h:306
uint8_t bPreferedVersion
Definition: video.h:530
uint8_t guidFormat[16]
Definition: video.h:363
uint8_t Error
Definition: video.h:491
uint8_t EndOfSlice
Definition: video.h:526
uint8_t SourceClockReference
Definition: video.h:488
uint8_t bmInfo
Definition: video.h:321
uint16_t bmRateControlModes
Definition: video.h:537
uint8_t bFormatType
Constant identifying the Format Type the AudioStreaming interface is using. See: audio_format_type_t.
Definition: audio.h:786
uint8_t bmCapabilities
Definition: video.h:464
uint16_t wKeyFrameRate
Definition: video.h:513
uint16_t wHeight
Definition: video.h:466
uint64_t bmLayoutPerStream
Definition: video.h:538
uint16_t wObjectiveFocalLengthMax
Definition: video.h:263
video_cs_vc_interface_subtype_t
Definition: video.h:97
@ VIDEO_CS_ITF_VC_INPUT_TERMINAL
Definition: video.h:100
@ VIDEO_CS_ITF_VC_OUTPUT_TERMINAL
Definition: video.h:101
@ VIDEO_CS_ITF_VC_ENCODING_UNIT
Definition: video.h:105
@ VIDEO_CS_ITF_VC_EXTENSION_UNIT
Definition: video.h:104
@ VIDEO_CS_ITF_VC_MAX
Definition: video.h:106
@ VIDEO_CS_ITF_VC_UNDEFINED
Definition: video.h:98
@ VIDEO_CS_ITF_VC_SELECTOR_UNIT
Definition: video.h:102
@ VIDEO_CS_ITF_VC_HEADER
Definition: video.h:99
@ VIDEO_CS_ITF_VC_PROCESSING_UNIT
Definition: video.h:103
@ VIDEO_BCD_1_50
Definition: video.h:33
video_interface_streaming_selector_t
Definition: video.h:168
@ VIDEO_VS_CTL_UPDATE_FRAME_SEGMENT
Definition: video.h:177
@ VIDEO_VS_CTL_PROBE
Definition: video.h:170
@ VIDEO_VS_CTL_COMMIT
Definition: video.h:171
@ VIDEO_VS_CTL_STILL_IMAGE_TRIGGER
Definition: video.h:174
@ VIDEO_VS_CTL_STREAM_ERROR_CODE
Definition: video.h:175
@ VIDEO_VS_CTL_STILL_PROBE
Definition: video.h:172
@ VIDEO_VS_CTL_STILL_COMMIT
Definition: video.h:173
@ VIDEO_VS_CTL_GENERATE_KEY_FRAME
Definition: video.h:176
@ VIDEO_VS_CTL_SYNCH_DELAY_CONTROL
Definition: video.h:178
@ VIDEO_VS_CTL_UNDEFINED
Definition: video.h:169
struct TU_ATTR_PACKED tusb_desc_video_format_mjpeg_t
struct TU_ATTR_PACKED tusb_desc_video_format_framebased_t
video_terminal_type_t
Definition: video.h:183
@ VIDEO_TT_STREAMING
Definition: video.h:186
@ VIDEO_ETT_COMPOSITE_CONNECTOR
Definition: video.h:200
@ VIDEO_ITT_CAMERA
Definition: video.h:190
@ VIDEO_ETT_SVIDEO_CONNECTOR
Definition: video.h:201
@ VIDEO_OTT_DISPLAY
Definition: video.h:195
@ VIDEO_ETT_COMPONENT_CONNECTOR
Definition: video.h:202
@ VIDEO_OTT_VENDOR_SPECIFIC
Definition: video.h:194
@ VIDEO_TT_VENDOR_SPECIFIC
Definition: video.h:185
@ VIDEO_ITT_MEDIA_TRANSPORT_INPUT
Definition: video.h:191
@ VIDEO_OTT_MEDIA_TRANSPORT_OUTPUT
Definition: video.h:196
@ VIDEO_ITT_VENDOR_SPECIFIC
Definition: video.h:189
@ VIDEO_ETT_VENDOR_SPEIFIC
Definition: video.h:199
video_color_primaries_t
Definition: video.h:37
@ VIDEO_COLOR_PRIMARIES_SMPTE170M
Definition: video.h:42
@ VIDEO_COLOR_PRIMARIES_SMPTE240M
Definition: video.h:43
@ VIDEO_COLOR_PRIMARIES_BT470_2M
Definition: video.h:40
@ VIDEO_COLOR_PRIMARIES_BT709
Definition: video.h:39
@ VIDEO_COLOR_PRIMARIES_BT470_2BG
Definition: video.h:41
@ VIDEO_COLOR_PRIMARIES_UNDEFINED
Definition: video.h:38
struct TU_ATTR_PACKED tusb_desc_video_control_camera_terminal_t
struct TU_ATTR_PACKED tusb_desc_video_streaming_output_header_t
tusb_desc_video_frame_uncompressed_t tusb_desc_video_frame_mjpeg_t
Definition: video.h:422
video_color_transfer_characteristics_t
Definition: video.h:47
@ VIDEO_COLOR_XFER_CH_BT470_2M
Definition: video.h:50
@ VIDEO_COLOR_XFER_CH_SRGB
Definition: video.h:55
@ VIDEO_COLOR_XFER_CH_BT470_2BG
Definition: video.h:51
@ VIDEO_COLOR_XFER_CH_SMPTE170M
Definition: video.h:52
@ VIDEO_COLOR_XFER_CH_UNDEFINED
Definition: video.h:48
@ VIDEO_COLOR_XFER_CH_SMPTE240M
Definition: video.h:53
@ VIDEO_COLOR_XFER_CH_LINEAR
Definition: video.h:54
@ VIDEO_COLOR_XFER_CH_BT709
Definition: video.h:49
tusb_desc_video_frame_uncompressed_1int_t tusb_desc_video_frame_mjpeg_1int_t
Definition: video.h:423
tusb_desc_video_frame_uncompressed_4int_t tusb_desc_video_frame_mjpeg_4int_t
Definition: video.h:426
tusb_desc_video_frame_uncompressed_3int_t tusb_desc_video_frame_uncompressed_continuous_t
Definition: video.h:399
struct TU_ATTR_PACKED tusb_desc_video_format_dv_t
video_cs_vs_interface_subtype_t
Definition: video.h:110
@ VIDEO_CS_ITF_VS_STILL_IMAGE_FRAME
Definition: video.h:114
@ VIDEO_CS_ITF_VS_UNDEFINED
Definition: video.h:111
@ VIDEO_CS_ITF_VS_FORMAT_H264
Definition: video.h:125
@ VIDEO_CS_ITF_VS_FORMAT_FRAME_BASED
Definition: video.h:122
@ VIDEO_CS_ITF_VS_FORMAT_VP8
Definition: video.h:128
@ VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED
Definition: video.h:115
@ VIDEO_CS_ITF_VS_FORMAT_MJPEG
Definition: video.h:117
@ VIDEO_CS_ITF_VS_FRAME_H264
Definition: video.h:126
@ VIDEO_CS_ITF_VS_FORMAT_VP8_SIMULCAST
Definition: video.h:130
@ VIDEO_CS_ITF_VS_FORMAT_DV
Definition: video.h:120
@ VIDEO_CS_ITF_VS_FORMAT_H264_SIMULCAST
Definition: video.h:127
@ VIDEO_CS_ITF_VS_FORMAT_MPEG2TS
Definition: video.h:119
@ VIDEO_CS_ITF_VS_FRAME_FRAME_BASED
Definition: video.h:123
@ VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED
Definition: video.h:116
@ VIDEO_CS_ITF_VS_FRAME_MJPEG
Definition: video.h:118
@ VIDEO_CS_ITF_VS_FORMAT_STREAM_BASED
Definition: video.h:124
@ VIDEO_CS_ITF_VS_INPUT_HEADER
Definition: video.h:112
@ VIDEO_CS_ITF_VS_COLORFORMAT
Definition: video.h:121
@ VIDEO_CS_ITF_VS_FRAME_VP8
Definition: video.h:129
@ VIDEO_CS_ITF_VS_OUTPUT_HEADER
Definition: video.h:113
struct TU_ATTR_PACKED tusb_desc_video_frame_framebased_t
tusb_desc_video_frame_uncompressed_2int_t tusb_desc_video_frame_mjpeg_2int_t
Definition: video.h:424
video_color_matrix_coefficients_t
Definition: video.h:59
@ VIDEO_COLOR_COEF_UNDEFINED
Definition: video.h:60
@ VIDEO_COLOR_COEF_SMPTE170M
Definition: video.h:64
@ VIDEO_COLOR_COEF_SMPTE240M
Definition: video.h:65
@ VIDEO_COLOR_COEF_BT470_2BG
Definition: video.h:63
@ VIDEO_COLOR_COEF_BT709
Definition: video.h:61
@ VIDEO_COLOR_COEF_FCC
Definition: video.h:62
video_cs_ep_subtype_t
Definition: video.h:134
@ VIDEO_CS_EP_INTERRUPT
Definition: video.h:138
@ VIDEO_CS_EP_UNDEFINED
Definition: video.h:135
@ VIDEO_CS_EP_GENERAL
Definition: video.h:136
@ VIDEO_CS_EP_ENDPOINT
Definition: video.h:137
struct TU_ATTR_PACKED video_probe_and_commit_control_t
video_control_request_t
Definition: video.h:142
@ VIDEO_REQUEST_SET_CUR_ALL
Definition: video.h:145
@ VIDEO_REQUEST_GET_INFO
Definition: video.h:151
@ VIDEO_REQUEST_GET_DEF_ALL
Definition: video.h:157
@ VIDEO_REQUEST_UNDEFINED
Definition: video.h:143
@ VIDEO_REQUEST_GET_LEN
Definition: video.h:150
@ VIDEO_REQUEST_GET_DEF
Definition: video.h:152
@ VIDEO_REQUEST_GET_CUR_ALL
Definition: video.h:153
@ VIDEO_REQUEST_GET_MIN
Definition: video.h:147
@ VIDEO_REQUEST_GET_RES
Definition: video.h:149
@ VIDEO_REQUEST_GET_MIN_ALL
Definition: video.h:154
@ VIDEO_REQUEST_SET_CUR
Definition: video.h:144
@ VIDEO_REQUEST_GET_CUR
Definition: video.h:146
@ VIDEO_REQUEST_GET_MAX
Definition: video.h:148
@ VIDEO_REQUEST_GET_RES_ALL
Definition: video.h:156
@ VIDEO_REQUEST_GET_MAX_ALL
Definition: video.h:155
struct TU_ATTR_PACKED tusb_desc_video_control_output_terminal_t
tusb_desc_video_frame_uncompressed_3int_t tusb_desc_video_frame_mjpeg_3int_t
Definition: video.h:425
struct TU_ATTR_PACKED tusb_video_payload_header_t
typedef tusb_desc_video_frame_uncompressed_nint_t() tusb_desc_video_frame_uncompressed_t
video_interface_protocol_code_t
Definition: video.h:91
@ VIDEO_ITF_PROTOCOL_15
Definition: video.h:93
@ VIDEO_ITF_PROTOCOL_UNDEFINED
Definition: video.h:92
typedef tusb_desc_video_control_header_nitf_t() tusb_desc_video_control_header_t
tusb_desc_video_frame_mjpeg_3int_t tusb_desc_video_frame_mjpeg_continuous_t
Definition: video.h:429
video_subclass_type_t
Definition: video.h:83
@ VIDEO_SUBCLASS_UNDEFINED
Definition: video.h:84
@ VIDEO_SUBCLASS_INTERFACE_COLLECTION
Definition: video.h:87
@ VIDEO_SUBCLASS_STREAMING
Definition: video.h:86
@ VIDEO_SUBCLASS_CONTROL
Definition: video.h:85
TU_VERIFY_STATIC(sizeof(tusb_desc_video_control_input_terminal_t)==8, "size is not correct")
typedef tusb_desc_video_streaming_input_header_nbyte_t() tusb_desc_video_streaming_input_header_t
video_error_code_t
Definition: video.h:69
@ VIDEO_ERROR_NOT_READY
Definition: video.h:71
@ VIDEO_ERROR_NONE
Definition: video.h:70
@ VIDEO_ERROR_POWER
Definition: video.h:73
@ VIDEO_ERROR_INVALID_UNIT
Definition: video.h:75
@ VIDEO_ERROR_UNKNOWN
Definition: video.h:79
@ VIDEO_ERROR_INVALID_REQUEST
Definition: video.h:77
@ VIDEO_ERROR_WRONG_STATE
Definition: video.h:72
@ VIDEO_ERROR_INVALID_VALUE_WITHIN_RANGE
Definition: video.h:78
@ VIDEO_ERROR_INVALID_CONTROL
Definition: video.h:76
@ VIDEO_ERROR_OUT_OF_RANGE
Definition: video.h:74
struct TU_ATTR_PACKED tusb_desc_video_streaming_inout_header_t
struct TU_ATTR_PACKED tusb_desc_video_control_input_terminal_t
video_interface_control_selector_t
Definition: video.h:161
@ VIDEO_VC_CTL_VIDEO_POWER_MODE
Definition: video.h:163
@ VIDEO_VC_CTL_REQUEST_ERROR_CODE
Definition: video.h:164
@ VIDEO_VC_CTL_UNDEFINED
Definition: video.h:162
struct TU_ATTR_PACKED tusb_desc_video_streaming_color_matching_t
struct TU_ATTR_PACKED tusb_desc_video_format_uncompressed_t