1616 * - USB Device Class Definition for Video Devices: Motion-JPEG Payload (Revision 1.5)
1717 */
1818
19- #ifndef ZEPHYR_INCLUDE_USBD_CLASS_UVC_H_
20- #define ZEPHYR_INCLUDE_USBD_CLASS_UVC_H_
19+ #ifndef ZEPHYR_INCLUDE_USB_CLASS_UVC_H_
20+ #define ZEPHYR_INCLUDE_USB_CLASS_UVC_H_
2121
2222#include <zephyr/usb/usb_ch9.h>
2323
2424/* Video Class-Specific Request Codes */
2525#define UVC_SET_CUR 0x01
2626#define UVC_GET_CUR 0x81
27+ #define UVC_SET_CUR_ALL 0x11
2728#define UVC_GET_MIN 0x82
2829#define UVC_GET_MAX 0x83
2930#define UVC_GET_RES 0x84
3031#define UVC_GET_LEN 0x85
31- #define UVC_GET_INFO 0x86
32+ #define UVC_GET_INFO 0x86
3233#define UVC_GET_DEF 0x87
34+ #define UVC_GET_CUR_ALL 0x91
35+ #define UVC_GET_MIN_ALL 0x92
36+ #define UVC_GET_MAX_ALL 0x93
37+ #define UVC_GET_RES_ALL 0x94
38+ #define UVC_GET_DEF_ALL 0x97
3339
3440/* Flags announcing which controls are supported */
3541#define UVC_INFO_SUPPORTS_GET BIT(0)
5561#define UVC_BMHEADERINFO_ERROR BIT(6)
5662#define UVC_BMHEADERINFO_END_OF_HEADER BIT(7)
5763
64+ /* Video Interface Class Codes */
65+ #define UVC_SC_VIDEOCLASS 0x0E
5866/* Video Interface Subclass Codes */
5967#define UVC_SC_VIDEOCONTROL 0x01
6068#define UVC_SC_VIDEOSTREAMING 0x02
119127#define UVC_EXT_COMPONENT_CONNECTOR 0x0403
120128
121129/* VideoStreaming Interface Controls */
130+ #define UVC_VS_CONTROL_UNDEFINED 0x00
122131#define UVC_VS_PROBE_CONTROL 0x01
123132#define UVC_VS_COMMIT_CONTROL 0x02
124133#define UVC_VS_STILL_PROBE_CONTROL 0x03
138147#define UVC_SU_INPUT_SELECT_CONTROL 0x01
139148
140149/* Camera Terminal Controls */
150+ #define UVC_CT_CONTROL_UNDEFINED 0x00
141151#define UVC_CT_SCANNING_MODE_CONTROL 0x01
142152#define UVC_CT_AE_MODE_CONTROL 0x02
143153#define UVC_CT_AE_PRIORITY_CONTROL 0x03
202212#define UVC_EU_START_OR_STOP_LAYER_CONTROL 0x13
203213#define UVC_EU_ERROR_RESILIENCY_CONTROL 0x14
204214
215+ /* Processing Unit Control Bit Positions (for bmControls bitmap) */
216+ #define UVC_PU_BMCONTROL_BRIGHTNESS BIT(0)
217+ #define UVC_PU_BMCONTROL_CONTRAST BIT(1)
218+ #define UVC_PU_BMCONTROL_HUE BIT(2)
219+ #define UVC_PU_BMCONTROL_SATURATION BIT(3)
220+ #define UVC_PU_BMCONTROL_SHARPNESS BIT(4)
221+ #define UVC_PU_BMCONTROL_GAMMA BIT(5)
222+ #define UVC_PU_BMCONTROL_WHITE_BALANCE_TEMPERATURE BIT(6)
223+ #define UVC_PU_BMCONTROL_WHITE_BALANCE_COMPONENT BIT(7)
224+ #define UVC_PU_BMCONTROL_BACKLIGHT_COMPENSATION BIT(8)
225+ #define UVC_PU_BMCONTROL_GAIN BIT(9)
226+ #define UVC_PU_BMCONTROL_POWER_LINE_FREQUENCY BIT(10)
227+ #define UVC_PU_BMCONTROL_HUE_AUTO BIT(11)
228+ #define UVC_PU_BMCONTROL_WHITE_BALANCE_TEMPERATURE_AUTO BIT(12)
229+ #define UVC_PU_BMCONTROL_WHITE_BALANCE_COMPONENT_AUTO BIT(13)
230+ #define UVC_PU_BMCONTROL_DIGITAL_MULTIPLIER BIT(14)
231+ #define UVC_PU_BMCONTROL_DIGITAL_MULTIPLIER_LIMIT BIT(15)
232+ #define UVC_PU_BMCONTROL_ANALOG_VIDEO_STANDARD BIT(16)
233+ #define UVC_PU_BMCONTROL_ANALOG_LOCK_STATUS BIT(17)
234+ #define UVC_PU_BMCONTROL_CONTRAST_AUTO BIT(18)
235+ /* Bits 19-23 are reserved for future use */
236+
237+ /* Camera Terminal Control Bit Positions (for bmControls bitmap) */
238+ #define UVC_CT_BMCONTROL_SCANNING_MODE BIT(0)
239+ #define UVC_CT_BMCONTROL_AE_MODE BIT(1)
240+ #define UVC_CT_BMCONTROL_AE_PRIORITY BIT(2)
241+ #define UVC_CT_BMCONTROL_EXPOSURE_TIME_ABSOLUTE BIT(3)
242+ #define UVC_CT_BMCONTROL_EXPOSURE_TIME_RELATIVE BIT(4)
243+ #define UVC_CT_BMCONTROL_FOCUS_ABSOLUTE BIT(5)
244+ #define UVC_CT_BMCONTROL_FOCUS_RELATIVE BIT(6)
245+ #define UVC_CT_BMCONTROL_IRIS_ABSOLUTE BIT(7)
246+ #define UVC_CT_BMCONTROL_IRIS_RELATIVE BIT(8)
247+ #define UVC_CT_BMCONTROL_ZOOM_ABSOLUTE BIT(9)
248+ #define UVC_CT_BMCONTROL_ZOOM_RELATIVE BIT(10)
249+ #define UVC_CT_BMCONTROL_PAN_TILT_ABSOLUTE BIT(11)
250+ #define UVC_CT_BMCONTROL_PAN_TILT_RELATIVE BIT(12)
251+ #define UVC_CT_BMCONTROL_ROLL_ABSOLUTE BIT(13)
252+ #define UVC_CT_BMCONTROL_ROLL_RELATIVE BIT(14)
253+ /* Bits 15-16 are reserved */
254+ #define UVC_CT_BMCONTROL_FOCUS_AUTO BIT(17)
255+ #define UVC_CT_BMCONTROL_PRIVACY BIT(18)
256+ #define UVC_CT_BMCONTROL_FOCUS_SIMPLE BIT(19)
257+ #define UVC_CT_BMCONTROL_WINDOW BIT(20)
258+ #define UVC_CT_BMCONTROL_REGION_OF_INTEREST BIT(21)
259+ /* Bits 22-23 are reserved for future use */
260+
205261/* Extension Unit Controls */
206262#define UVC_XU_BASE_CONTROL 0x00
207263
@@ -222,7 +278,7 @@ struct uvc_control_header_descriptor {
222278 uint16_t wTotalLength ;
223279 uint32_t dwClockFrequency ;
224280 uint8_t bInCollection ;
225- uint8_t baInterfaceNr [1 ];
281+ uint8_t baInterfaceNr [];
226282} __packed ;
227283
228284struct uvc_unit_descriptor {
@@ -232,6 +288,16 @@ struct uvc_unit_descriptor {
232288 uint8_t bUnitID ;
233289};
234290
291+ struct uvc_input_terminal_descriptor {
292+ uint8_t bLength ;
293+ uint8_t bDescriptorType ;
294+ uint8_t bDescriptorSubType ;
295+ uint8_t bTerminalID ;
296+ uint16_t wTerminalType ;
297+ uint8_t bAssocTerminal ;
298+ uint8_t iTerminal ;
299+ } __packed ;
300+
235301struct uvc_output_terminal_descriptor {
236302 uint8_t bLength ;
237303 uint8_t bDescriptorType ;
@@ -307,10 +373,10 @@ struct uvc_extension_unit_descriptor {
307373 uint8_t iExtension ;
308374} __packed ;
309375
310- struct uvc_stream_header_descriptor {
376+ struct uvc_stream_input_header_descriptor {
311377 uint8_t bLength ;
312378 uint8_t bDescriptorType ;
313- uint8_t bDescriptorSubtype ;
379+ uint8_t bDescriptorSubType ;
314380 uint8_t bNumFormats ;
315381 uint16_t wTotalLength ;
316382 uint8_t bEndpointAddress ;
@@ -320,6 +386,19 @@ struct uvc_stream_header_descriptor {
320386 uint8_t bTriggerSupport ;
321387 uint8_t bTriggerUsage ;
322388 uint8_t bControlSize ;
389+ uint8_t bmControls [];
390+ } __packed ;
391+
392+ struct uvc_stream_output_header_descriptor {
393+ uint8_t bLength ;
394+ uint8_t bDescriptorType ;
395+ uint8_t bDescriptorSubType ;
396+ uint8_t bNumFormats ;
397+ uint16_t wTotalLength ;
398+ uint8_t bEndpointAddress ;
399+ uint8_t bTerminalLink ;
400+ uint8_t bControlSize ;
401+ uint8_t bmControls [];
323402} __packed ;
324403
325404struct uvc_frame_still_image_descriptor {
@@ -348,7 +427,7 @@ struct uvc_format_descriptor {
348427struct uvc_format_uncomp_descriptor {
349428 uint8_t bLength ;
350429 uint8_t bDescriptorType ;
351- uint8_t bDescriptorSubtype ;
430+ uint8_t bDescriptorSubType ;
352431 uint8_t bFormatIndex ;
353432 uint8_t bNumFrameDescriptors ;
354433 uint8_t guidFormat [16 ];
@@ -363,7 +442,7 @@ struct uvc_format_uncomp_descriptor {
363442struct uvc_format_mjpeg_descriptor {
364443 uint8_t bLength ;
365444 uint8_t bDescriptorType ;
366- uint8_t bDescriptorSubtype ;
445+ uint8_t bDescriptorSubType ;
367446 uint8_t bFormatIndex ;
368447 uint8_t bNumFrameDescriptors ;
369448 uint8_t bmFlags ;
@@ -375,10 +454,18 @@ struct uvc_format_mjpeg_descriptor {
375454 uint8_t bCopyProtect ;
376455} __packed ;
377456
457+ struct uvc_format_descriptor_header {
458+ uint8_t bLength ;
459+ uint8_t bDescriptorType ;
460+ uint8_t bDescriptorSubType ;
461+ uint8_t bFormatIndex ;
462+ uint8_t bNumFrameDescriptors ;
463+ } __packed ;
464+
378465struct uvc_frame_descriptor {
379466 uint8_t bLength ;
380467 uint8_t bDescriptorType ;
381- uint8_t bDescriptorSubtype ;
468+ uint8_t bDescriptorSubType ;
382469 uint8_t bFrameIndex ;
383470 uint8_t bmCapabilities ;
384471 uint16_t wWidth ;
@@ -394,7 +481,7 @@ struct uvc_frame_descriptor {
394481struct uvc_frame_continuous_descriptor {
395482 uint8_t bLength ;
396483 uint8_t bDescriptorType ;
397- uint8_t bDescriptorSubtype ;
484+ uint8_t bDescriptorSubType ;
398485 uint8_t bFrameIndex ;
399486 uint8_t bmCapabilities ;
400487 uint16_t wWidth ;
@@ -422,13 +509,20 @@ struct uvc_frame_discrete_descriptor {
422509 uint32_t dwMaxVideoFrameBufferSize ;
423510 uint32_t dwDefaultFrameInterval ;
424511 uint8_t bFrameIntervalType ;
512+ /* TODO: commonly configurable frame interval ( suggestion: uint32_t dwFrameInterval[]; )*/
425513#ifdef CONFIG_USBD_VIDEO_MAX_FRMIVAL
426514 uint32_t dwFrameInterval [CONFIG_USBD_VIDEO_MAX_FRMIVAL ];
427515#else
428516 uint32_t dwFrameInterval [1 ];
429517#endif
430518} __packed ;
431519
520+ struct uvc_cs_descriptor_header {
521+ uint8_t bLength ;
522+ uint8_t bDescriptorType ;
523+ uint8_t bDescriptorSubType ;
524+ } __packed ;
525+
432526struct uvc_color_descriptor {
433527 uint8_t bLength ;
434528 uint8_t bDescriptorType ;
@@ -485,4 +579,4 @@ struct uvc_payload_header {
485579 uint16_t scrSourceClockSOF ; /* optional */
486580} __packed ;
487581
488- #endif /* ZEPHYR_INCLUDE_USBD_CLASS_UVC_H_ */
582+ #endif /* ZEPHYR_INCLUDE_USB_CLASS_UVC_H_ */
0 commit comments