1*ba30c7beSmglocker /* $OpenBSD: uvideo.h,v 1.31 2008/08/27 17:31:48 mglocker Exp $ */ 2c200fde7Smglocker 3cf110a4aSrobert /* 4cf110a4aSrobert * Copyright (c) 2007 Robert Nagy <robert@openbsd.org> 5cf110a4aSrobert * Copyright (c) 2008 Marcus Glocker <mglocker@openbsd.org> 6cf110a4aSrobert * 7cf110a4aSrobert * Permission to use, copy, modify, and distribute this software for any 8cf110a4aSrobert * purpose with or without fee is hereby granted, provided that the above 9cf110a4aSrobert * copyright notice and this permission notice appear in all copies. 10cf110a4aSrobert * 11cf110a4aSrobert * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12cf110a4aSrobert * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13cf110a4aSrobert * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14cf110a4aSrobert * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15cf110a4aSrobert * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16cf110a4aSrobert * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17cf110a4aSrobert * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18cf110a4aSrobert */ 19cf110a4aSrobert 201dc1fa5aSmglocker #include <sys/queue.h> 21cf110a4aSrobert #include <sys/videoio.h> 22cf110a4aSrobert 23cf110a4aSrobert /* 24cf110a4aSrobert * USB Video Class 25cf110a4aSrobert */ 26cf110a4aSrobert /* Table A-7: Video Class-Specific Endpoint Descriptor Subtypes */ 27cf110a4aSrobert #define EP_UNDEFINED 0x00 28cf110a4aSrobert #define EP_GENERAL 0x01 29cf110a4aSrobert #define EP_ENDPOINT 0x02 30cf110a4aSrobert #define EP_INTERRUPT 0x03 31cf110a4aSrobert 32cf110a4aSrobert /* Table A-5: Video Class-Specific VC Interface Descriptor Subtypes */ 33cf110a4aSrobert #define UDESCSUB_VC_DESCRIPTOR_UNDEFINED 0x00 34cf110a4aSrobert #define UDESCSUB_VC_HEADER 0x01 35cf110a4aSrobert #define UDESCSUB_VC_INPUT_TERMINAL 0x02 36cf110a4aSrobert #define UDESCSUB_VC_OUTPUT_TERMINAL 0x03 37cf110a4aSrobert #define UDESCSUB_VC_SELECTOR_UNIT 0x04 38cf110a4aSrobert #define UDESCSUB_VC_PROCESSING_UNIT 0x05 39cf110a4aSrobert #define UDESCSUB_VC_EXTENSION_UNIT 0x06 40cf110a4aSrobert 41cf110a4aSrobert /* Table A-6: Video Class-Specific VS Interface Descriptor Subtypes */ 42cf110a4aSrobert #define UDESCSUB_VS_UNDEFINED 0x00 43cf110a4aSrobert #define UDESCSUB_VS_INPUT_HEADER 0x01 44cf110a4aSrobert #define UDESCSUB_VS_OUTPUT_HEADER 0x02 45cf110a4aSrobert #define UDESCSUB_VS_STILL_IMAGE_FRAME 0x03 46cf110a4aSrobert #define UDESCSUB_VS_FORMAT_UNCOMPRESSED 0x04 47cf110a4aSrobert #define UDESCSUB_VS_FRAME_UNCOMPRESSED 0x05 48cf110a4aSrobert #define UDESCSUB_VS_FORMAT_MJPEG 0x06 49cf110a4aSrobert #define UDESCSUB_VS_FRAME_MJPEG 0x07 50cf110a4aSrobert #define UDESCSUB_VS_FORMAT_MPEG2TS 0x0a 51cf110a4aSrobert #define UDESCSUB_VS_FORMAT_DV 0x0c 52cf110a4aSrobert #define UDESCSUB_VS_COLORFORMAT 0x0d 53cf110a4aSrobert #define UDESCSUB_VS_FORMAT_FRAME_BASED 0x10 54cf110a4aSrobert #define UDESCSUB_VS_FRAME_FRAME_BASED 0x11 55cf110a4aSrobert #define UDESCSUB_VS_FORMAT_STREAM_BASED 0x12 56cf110a4aSrobert 57cf110a4aSrobert /* Table A-8: Video Class-Specific Request Codes */ 58cf110a4aSrobert #define RC_UNDEFINED 0x00 59cf110a4aSrobert #define SET_CUR 0x01 60cf110a4aSrobert #define GET_CUR 0x81 61cf110a4aSrobert #define GET_MIN 0x82 62cf110a4aSrobert #define GET_MAX 0x83 63cf110a4aSrobert #define GET_RES 0x84 64cf110a4aSrobert #define GET_LEN 0x85 65cf110a4aSrobert #define GET_INFO 0x86 66cf110a4aSrobert #define GET_DEF 0x87 67cf110a4aSrobert 68cf110a4aSrobert /* Table A-9: Video Control Interface Control Selectors */ 69cf110a4aSrobert #define VC_CONTROL_UNDEFINED 0x00 70cf110a4aSrobert #define VC_VIDEO_POWER_MODE_CONTROL 0x01 71cf110a4aSrobert #define VC_REQUEST_ERROR_CODE_CONTROL 0x02 72cf110a4aSrobert 73cf110a4aSrobert /* Table A-11: Selector Unit Control Selectors */ 74cf110a4aSrobert #define SU_CONTROL_UNDEFINED 0x00 75cf110a4aSrobert #define SU_INPUT_SELECT_CONTROL 0x01 76cf110a4aSrobert 77cf110a4aSrobert /* Table A-12: Camera Terminal Control Selectors */ 78cf110a4aSrobert #define CT_CONTROL_UNDEFINED 0x00 79cf110a4aSrobert #define CT_SCANNING_MODE_CONTROL 0x01 80cf110a4aSrobert #define CT_AE_MODE_CONTROL 0x02 81cf110a4aSrobert #define CT_AE_PRIORITY_CONTROL 0x03 82cf110a4aSrobert #define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04 83cf110a4aSrobert #define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05 84cf110a4aSrobert #define CT_FOCUS_ABSOLUTE_CONTROL 0x06 85cf110a4aSrobert #define CT_FOCUS_RELATIVE_CONTROL 0x07 86cf110a4aSrobert #define CT_FOCUS_AUTO_CONTROL 0x08 87cf110a4aSrobert #define CT_IRIS_ABSOLUTE_CONTROL 0x09 88cf110a4aSrobert #define CT_IRIS_RELATIVE_CONTROL 0x0a 89cf110a4aSrobert #define CT_ZOOM_ABSOLUTE_CONTROL 0x0b 90cf110a4aSrobert #define CT_ZOOM_RELATIVE_CONTROL 0x0c 91cf110a4aSrobert #define CT_PANTILT_ABSOLUTE_CONTROL 0x0d 92cf110a4aSrobert #define CT_PANTILT_RELATIVE_CONTROL 0x0e 93cf110a4aSrobert #define CT_ROLL_ABSOLUTE_CONTROL 0x0f 94cf110a4aSrobert #define CT_ROLL_RELATIVE_CONTROL 0x10 95cf110a4aSrobert #define CT_PRIVACY_CONTROL 0x11 96cf110a4aSrobert 97cf110a4aSrobert /* Table A-13: Processing Unit Control Selectors */ 98cf110a4aSrobert #define PU_CONTROL_UNDEFINED 0x00 99cf110a4aSrobert #define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01 100cf110a4aSrobert #define PU_BRIGHTNESS_CONTROL 0x02 101cf110a4aSrobert #define PU_CONTRAST_CONTROL 0x03 102cf110a4aSrobert #define PU_GAIN_CONTROL 0x04 103cf110a4aSrobert #define PU_POWER_LINE_FREQUENCY_CONTROL 0x05 104cf110a4aSrobert #define PU_HUE_CONTROL 0x06 105cf110a4aSrobert #define PU_SATURATION_CONTROL 0x07 106cf110a4aSrobert #define PU_SHARPNESS_CONTROL 0x08 107cf110a4aSrobert #define PU_GAMMA_CONTROL 0x09 108cf110a4aSrobert #define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a 109cf110a4aSrobert #define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b 110cf110a4aSrobert #define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c 111cf110a4aSrobert #define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d 112cf110a4aSrobert #define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e 113cf110a4aSrobert #define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f 114cf110a4aSrobert #define PU_HUE_AUTO_CONTROL 0x10 115cf110a4aSrobert #define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 116cf110a4aSrobert #define PU_ANALOG_LOCK_STATUS_CONTROL 0x12 117cf110a4aSrobert 118cf110a4aSrobert /* Table A-15: VideoStreaming Interface Control Selectors */ 119cf110a4aSrobert #define VS_CONTROL_UNDEFINED 0x00 120cf110a4aSrobert #define VS_PROBE_CONTROL 0x01 121cf110a4aSrobert #define VS_COMMIT_CONTROL 0x02 122cf110a4aSrobert #define VS_STILL_PROBE_CONTROL 0x03 123cf110a4aSrobert #define VS_STILL_COMMIT_CONTROL 0x04 124cf110a4aSrobert #define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05 125cf110a4aSrobert #define VS_STREAM_ERROR_CODE_CONTROL 0x06 126cf110a4aSrobert #define VS_GENERATE_KEY_FRAME_CONTROL 0x07 127cf110a4aSrobert #define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08 128cf110a4aSrobert #define VS_SYNC_DELAY_CONTROL 0x09 129cf110a4aSrobert 130cf110a4aSrobert /* probe commit bmRequests */ 131cf110a4aSrobert #define UVIDEO_SET_IF 0x21 132cf110a4aSrobert #define UVIDEO_GET_IF 0xa1 133cf110a4aSrobert #define UVIDEO_SET_EP 0x22 134cf110a4aSrobert #define UVIDEO_GET_EP 0xa2 135cf110a4aSrobert 136cf110a4aSrobert /* Table B-1: USB Terminal Types */ 137cf110a4aSrobert #define TT_VENDOR_SPECIFIC 0x0100 138cf110a4aSrobert #define TT_STREAMING 0x0101 139cf110a4aSrobert 140cf110a4aSrobert /* Table B-2: Input Terminal Types */ 141cf110a4aSrobert #define ITT_VENDOR_SPECIFIC 0x0200 142cf110a4aSrobert #define ITT_CAMERA 0x0201 143cf110a4aSrobert #define ITT_MEDIA_TRANSPORT_INPUT 0x0202 144cf110a4aSrobert 145cf110a4aSrobert /* Table B-3: Output Terminal Types */ 146cf110a4aSrobert #define OTT_VENDOR_SPECIFIC 0x0300 147cf110a4aSrobert #define OTT_DISPLAY 0x0301 148cf110a4aSrobert #define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302 149cf110a4aSrobert 150cf110a4aSrobert /* Table B-4: External Terminal Types */ 151cf110a4aSrobert #define EXTERNAL_VENDOR_SPECIFIC 0x0400 152cf110a4aSrobert #define COMPOSITE_CONNECTOR 0x0401 153cf110a4aSrobert #define SVIDEO_CONNECTOR 0x0402 154cf110a4aSrobert #define COMPONENT_CONNECTOR 0x0403 155cf110a4aSrobert 156cf110a4aSrobert /* Table 3-3: VC Interface Header Descriptor */ 157cf110a4aSrobert struct usb_video_header_desc { 158cf110a4aSrobert uByte bLength; 159cf110a4aSrobert uByte bDescriptorType; 160cf110a4aSrobert uByte bDescriptorSubtype; 161cf110a4aSrobert uWord bcdUVC; 162cf110a4aSrobert uWord wTotalLength; 163f72577ceSmglocker uDWord dwClockFrequency; 164cf110a4aSrobert uByte bInCollection; 165*ba30c7beSmglocker } __packed; 166259e150dSmglocker 167259e150dSmglocker struct usb_video_header_desc_all { 168259e150dSmglocker struct usb_video_header_desc *fix; 169259e150dSmglocker uByte *baInterfaceNr; 170cf110a4aSrobert }; 171cf110a4aSrobert 172cf110a4aSrobert /* Table 3-4: Input Terminal Descriptor */ 173cf110a4aSrobert struct usb_video_input_terminal_desc { 174cf110a4aSrobert uByte bLength; 175cf110a4aSrobert uByte bDescriptorType; 176cf110a4aSrobert uByte bDescriptorSubtype; 177cf110a4aSrobert uByte bTerminalID; 178cf110a4aSrobert uWord wTerminalType; 179cf110a4aSrobert uByte bAssocTerminal; 180cf110a4aSrobert uByte iTerminal; 181*ba30c7beSmglocker } __packed; 182cf110a4aSrobert 183cf110a4aSrobert /* Table 3-5: Output Terminal Descriptor */ 184cf110a4aSrobert struct usb_video_output_terminal_desc { 185cf110a4aSrobert uByte bLength; 186cf110a4aSrobert uByte bDescriptorType; 187cf110a4aSrobert uByte bDescriptorSubtype; 188cf110a4aSrobert uByte bTerminalID; 189cf110a4aSrobert uWord wTerminalType; 190cf110a4aSrobert uByte bAssocTerminal; 191cf110a4aSrobert uByte bSourceID; 192cf110a4aSrobert uByte iTerminal; 193*ba30c7beSmglocker } __packed; 194cf110a4aSrobert 195cf110a4aSrobert /* Table 3-6: Camera Terminal Descriptor */ 196cf110a4aSrobert struct usb_video_camera_terminal_desc { 197cf110a4aSrobert uByte bLength; 198cf110a4aSrobert uByte bDescriptorType; 199cf110a4aSrobert uByte bDescriptorSubtype; 200cf110a4aSrobert uByte bTerminalID; 201cf110a4aSrobert uWord wTerminalType; 202cf110a4aSrobert uByte bAssocTerminal; 203cf110a4aSrobert uByte iTerminal; 204cf110a4aSrobert uWord wObjectiveFocalLengthMin; 205cf110a4aSrobert uWord wObjectiveFocalLengthMax; 206cf110a4aSrobert uWord wOcularFocalLength; 207cf110a4aSrobert uByte bControlSize; 208f72577ceSmglocker uByte *bmControls; 209*ba30c7beSmglocker } __packed; 210cf110a4aSrobert 2112ee56f53Smglocker /* Table 3-8: VC Processing Unit Descriptor */ 2122ee56f53Smglocker struct usb_video_vc_processing_desc { 2132ee56f53Smglocker uByte bLength; 2142ee56f53Smglocker uByte bDescriptorType; 2152ee56f53Smglocker uByte bDescriptorSubtype; 2162ee56f53Smglocker uByte bUnitID; 2172ee56f53Smglocker uByte bSourceID; 2182ee56f53Smglocker uWord wMaxMultiplier; 2192ee56f53Smglocker uByte bControlSize; 2202ee56f53Smglocker uWord bmControls; /* XXX must be variable size of bControlSize */ 2212ee56f53Smglocker uByte iProcessing; 2222ee56f53Smglocker uByte bmVideoStandards; 2232ee56f53Smglocker } __packed; 2242ee56f53Smglocker 22501c33b94Smglocker /* Table 3-9: VC Extension Unit Descriptor */ 22601c33b94Smglocker struct usb_video_vc_extension_desc { 22701c33b94Smglocker uByte bLength; 22801c33b94Smglocker uByte bDescriptorType; 22901c33b94Smglocker uByte bDescriptorSubtype; 23001c33b94Smglocker uByte bUnitID; 23101c33b94Smglocker uByte guidExtensionCode[16]; 23201c33b94Smglocker uByte bNumControls; 23301c33b94Smglocker uByte bNrInPins; 23401c33b94Smglocker } __packed; 23501c33b94Smglocker 236cf110a4aSrobert /* Table 3-11: VC Endpoint Descriptor */ 237cf110a4aSrobert struct usb_video_vc_endpoint_desc { 238cf110a4aSrobert uByte bLength; 239cf110a4aSrobert uByte bDescriptorType; 240cf110a4aSrobert uByte bDescriptorSubtype; 241cf110a4aSrobert uWord wMaxTransferSize; 242*ba30c7beSmglocker } __packed; 243cf110a4aSrobert 24469db36cdSmglocker /* Table 3-13: Interface Input Header Descriptor */ 24569db36cdSmglocker struct usb_video_input_header_desc { 24669db36cdSmglocker uByte bLength; 24769db36cdSmglocker uByte bDescriptorType; 24869db36cdSmglocker uByte bDescriptorSubtype; 24969db36cdSmglocker uByte bNumFormats; 25069db36cdSmglocker uWord wTotalLength; 25169db36cdSmglocker uByte bEndpointAddress; 25269db36cdSmglocker uByte bmInfo; 25369db36cdSmglocker uByte bTerminalLink; 25469db36cdSmglocker uByte bStillCaptureMethod; 25569db36cdSmglocker uByte bTriggerSupport; 25669db36cdSmglocker uByte bTriggerUsage; 25769db36cdSmglocker uByte bControlSize; 258*ba30c7beSmglocker } __packed; 25969db36cdSmglocker 260c668bad0Smglocker struct usb_video_input_header_desc_all { 261c668bad0Smglocker struct usb_video_input_header_desc *fix; 262c668bad0Smglocker uByte *bmaControls; 263c668bad0Smglocker }; 264c668bad0Smglocker 265cf110a4aSrobert /* Table 3-18: Color Matching Descriptor */ 266cf110a4aSrobert struct usb_video_color_matching_descr { 267cf110a4aSrobert uByte bLength; 268cf110a4aSrobert uByte bDescriptorType; 269cf110a4aSrobert uByte bDescriptorSubtype; 270cf110a4aSrobert uByte bColorPrimaries; 271cf110a4aSrobert uByte bTransferCharacteristics; 272cf110a4aSrobert uByte bMatrixCoefficients; 273cf110a4aSrobert } __packed; 274cf110a4aSrobert 275cf110a4aSrobert /* Table 4-47: Video Probe and Commit Controls */ 276cf110a4aSrobert struct usb_video_probe_commit { 277259e150dSmglocker uWord bmHint; 278cf110a4aSrobert uByte bFormatIndex; 279cf110a4aSrobert uByte bFrameIndex; 280259e150dSmglocker uDWord dwFrameInterval; 281259e150dSmglocker uWord wKeyFrameRate; 282259e150dSmglocker uWord wPFrameRate; 283259e150dSmglocker uWord wCompQuality; 284259e150dSmglocker uWord wCompWindowSize; 285259e150dSmglocker uWord wDelay; 286259e150dSmglocker uDWord dwMaxVideoFrameSize; 287259e150dSmglocker uDWord dwMaxPayloadTransferSize; 288259e150dSmglocker uDWord wClockFrequency; 289cf110a4aSrobert uByte bmFramingInfo; 290cf110a4aSrobert uByte bPreferedVersion; 291cf110a4aSrobert uByte bMinVersion; 292cf110a4aSrobert uByte bMaxVersion; 293cf110a4aSrobert } __packed; 294cf110a4aSrobert 295cf110a4aSrobert /* 296cf110a4aSrobert * USB Video Payload Uncompressed 297cf110a4aSrobert */ 298cf110a4aSrobert /* Table 2-1: Compression Formats */ 299cf110a4aSrobert #define UVIDEO_FORMAT_GUID_YUY2 { \ 300cf110a4aSrobert 0x59, 0x55, 0x59, 0x32, 0x00, 0x00, 0x10, 0x00, \ 301cf110a4aSrobert 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } 302cf110a4aSrobert 303cf110a4aSrobert #define UVIDEO_FORMAT_GUID_NV12 { \ 304cf110a4aSrobert 0x4e, 0x56, 0x31, 0x32, 0x00, 0x00, 0x10, 0x00, \ 305cf110a4aSrobert 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } 306cf110a4aSrobert 307cf110a4aSrobert /* 308cf110a4aSrobert * USB Video Payload MJPEG 309cf110a4aSrobert */ 310cf110a4aSrobert /* Table 2-1: Stream Header Format for the Motion-JPEG */ 311cf110a4aSrobert #define UVIDEO_STREAM_FID (1 << 0) 312cf110a4aSrobert #define UVIDEO_STREAM_EOF (1 << 1) 313cf110a4aSrobert #define UVIDEO_STREAM_PTS (1 << 2) 314cf110a4aSrobert #define UVIDEO_STREAM_SCR (1 << 3) 315cf110a4aSrobert #define UVIDEO_STREAM_RES (1 << 4) 316cf110a4aSrobert #define UVIDEO_STREAM_STI (1 << 5) 317cf110a4aSrobert #define UVIDEO_STREAM_ERR (1 << 6) 318cf110a4aSrobert #define UVIDEO_STREAM_EOH (1 << 7) 319cf110a4aSrobert 320cf110a4aSrobert /* Table 3-1: Motion-JPEG Video Format Descriptor */ 321259e150dSmglocker struct usb_video_format_mjpeg_desc { 322cf110a4aSrobert uByte bLength; 323cf110a4aSrobert uByte bDescriptorType; 324cf110a4aSrobert uByte bDescriptorSubtype; 325cf110a4aSrobert uByte bFormatIndex; 326cf110a4aSrobert uByte bNumFrameDescriptors; 327cf110a4aSrobert uByte bmFlags; 328cf110a4aSrobert uByte bDefaultFrameIndex; 329cf110a4aSrobert uByte bAspectRatioX; 330cf110a4aSrobert uByte bAspectRatioY; 331cf110a4aSrobert uByte bmInterlaceFlags; 332cf110a4aSrobert uByte bCopyProtect; 333cf110a4aSrobert } __packed; 334cf110a4aSrobert 335cf110a4aSrobert /* Table 3-2: Motion-JPEG Video Frame Descriptor */ 336259e150dSmglocker struct usb_video_frame_mjpeg_desc { 337cf110a4aSrobert uByte bLength; 338cf110a4aSrobert uByte bDescriptorType; 339cf110a4aSrobert uByte bDescriptorSubtype; 340cf110a4aSrobert uByte bFrameIndex; 341cf110a4aSrobert uByte bmCapabilities; 342cf110a4aSrobert uWord wWidth; 343cf110a4aSrobert uWord wHeight; 344cf110a4aSrobert uDWord dwMinBitRate; 345cf110a4aSrobert uDWord dwMaxBitRate; 346cf110a4aSrobert uDWord dwMaxVideoFrameBufferSize; 347eaa1845bSmglocker uDWord dwDefaultFrameInterval; 348cf110a4aSrobert uByte bFrameIntervalType; 349eaa1845bSmglocker /* TODO add continous/discrete frame intervals (Table 3-3/3-4) */ 350cf110a4aSrobert } __packed; 351cf110a4aSrobert 352cf110a4aSrobert /* 353786c2e79Smglocker * USB Video Payload Uncompressed 354786c2e79Smglocker */ 355786c2e79Smglocker /* Table 3-1: Uncompressed Video Format Descriptor */ 356786c2e79Smglocker struct usb_video_format_uncompressed_desc { 357786c2e79Smglocker uByte bLength; 358786c2e79Smglocker uByte bDescriptorType; 359786c2e79Smglocker uByte bDescriptorSubtype; 360786c2e79Smglocker uByte bFormatIndex; 361786c2e79Smglocker uByte bNumFrameDescriptors; 362786c2e79Smglocker uByte guidFormat[16]; 363786c2e79Smglocker uByte bBitsPerPixel; 364786c2e79Smglocker uByte bDefaultFrameIndex; 365786c2e79Smglocker uByte bAspectRatioX; 366786c2e79Smglocker uByte bAspectRatioY; 367786c2e79Smglocker uByte bmInterlaceFlags; 368786c2e79Smglocker uByte bCopyProtect; 369786c2e79Smglocker } __packed; 370786c2e79Smglocker 371786c2e79Smglocker /* Table 3-2: Uncompressed Video Frame Descriptor */ 372786c2e79Smglocker struct usb_video_frame_uncompressed_desc { 373786c2e79Smglocker uByte bLength; 374786c2e79Smglocker uByte bDescriptorType; 375786c2e79Smglocker uByte bDescriptorSubtype; 376786c2e79Smglocker uByte bFrameIndex; 377786c2e79Smglocker uByte bmCapabilities; 378786c2e79Smglocker uWord wWidth; 379786c2e79Smglocker uWord wHeight; 380786c2e79Smglocker uDWord dwMinBitRate; 381786c2e79Smglocker uDWord dwMaxBitRate; 382786c2e79Smglocker uDWord dwMaxVideoFrameBufferSize; 383786c2e79Smglocker uDWord dwDefaultFrameInterval; 384786c2e79Smglocker uByte bFrameIntervalType; 385786c2e79Smglocker /* TODO add continous/discrete frame intervals (Table 3-3/3-4) */ 386786c2e79Smglocker } __packed; 387786c2e79Smglocker 388786c2e79Smglocker /* 389cf110a4aSrobert * Driver specific private definitions. 390cf110a4aSrobert */ 391ff018eb9Smglocker struct uvideo_format_desc { 392ff018eb9Smglocker uByte bLength; 393ff018eb9Smglocker uByte bDescriptorType; 394ff018eb9Smglocker uByte bDescriptorSubtype; 395ff018eb9Smglocker uByte bFormatIndex; 396ff018eb9Smglocker uByte bNumFrameDescriptors; 397ff018eb9Smglocker union { 398ff018eb9Smglocker /* mjpeg */ 399ff018eb9Smglocker struct { 400ff018eb9Smglocker uByte bmFlags; 401ff018eb9Smglocker uByte bDefaultFrameIndex; 402ff018eb9Smglocker uByte bAspectRatioX; 403ff018eb9Smglocker uByte bAspectRatioY; 404ff018eb9Smglocker uByte bmInterlaceFlags; 405ff018eb9Smglocker uByte bCopyProtect; 406ff018eb9Smglocker } mjpeg; 407ff018eb9Smglocker 408ff018eb9Smglocker /* uncompressed */ 409ff018eb9Smglocker struct { 410ff018eb9Smglocker uByte guidFormat[16]; 411ff018eb9Smglocker uByte bBitsPerPixel; 412ff018eb9Smglocker uByte bDefaultFrameIndex; 413ff018eb9Smglocker uByte bAspectRatioX; 414ff018eb9Smglocker uByte bAspectRatioY; 415ff018eb9Smglocker uByte bmInterlaceFlags; 416ff018eb9Smglocker uByte bCopyProtect; 417ff018eb9Smglocker } uc; 418ff018eb9Smglocker } u; 419ff018eb9Smglocker } __packed; 420ff018eb9Smglocker 421*ba30c7beSmglocker #define UVIDEO_NFRAMES_MAX 40 422*ba30c7beSmglocker struct uvideo_vs_iface { 423*ba30c7beSmglocker struct uvideo_softc *sc; 424*ba30c7beSmglocker usbd_xfer_handle xfer; 425*ba30c7beSmglocker void *buf; 426*ba30c7beSmglocker usbd_interface_handle ifaceh; 427*ba30c7beSmglocker int endpoint; 428*ba30c7beSmglocker usbd_pipe_handle pipeh; 429*ba30c7beSmglocker uint16_t size[UVIDEO_NFRAMES_MAX]; 430*ba30c7beSmglocker int numalts; 431*ba30c7beSmglocker int curalt; 432*ba30c7beSmglocker uint32_t max_packet_size; 433*ba30c7beSmglocker int iface; 434*ba30c7beSmglocker }; 435*ba30c7beSmglocker 436*ba30c7beSmglocker struct uvideo_frame_buffer { 437*ba30c7beSmglocker int sample; 438*ba30c7beSmglocker uint8_t fid; 439*ba30c7beSmglocker int offset; 440*ba30c7beSmglocker int buf_size; 441*ba30c7beSmglocker uint8_t *buf; 442*ba30c7beSmglocker }; 443*ba30c7beSmglocker 444*ba30c7beSmglocker #define UVIDEO_MAX_BUFFERS 32 445*ba30c7beSmglocker struct uvideo_mmap { 446*ba30c7beSmglocker SIMPLEQ_ENTRY(uvideo_mmap) q_frames; 447*ba30c7beSmglocker uint8_t *buf; 448*ba30c7beSmglocker struct v4l2_buffer v4l2_buf; 449*ba30c7beSmglocker }; 450*ba30c7beSmglocker typedef SIMPLEQ_HEAD(, uvideo_mmap) q_mmap; 451*ba30c7beSmglocker 45296d56267Smglocker struct uvideo_format_group { 45394047bb7Smglocker uint32_t pixelformat; 454ff018eb9Smglocker uint8_t format_dfidx; 45548ae767dSmglocker struct uvideo_format_desc *format; 456ff018eb9Smglocker /* frame descriptors for mjpeg and uncompressed are identical */ 45796d56267Smglocker #define UVIDEO_MAX_FRAME 16 458ff018eb9Smglocker struct usb_video_frame_mjpeg_desc *frame_cur; 45996d56267Smglocker struct usb_video_frame_mjpeg_desc *frame[UVIDEO_MAX_FRAME]; 46048ae767dSmglocker int frame_num; 46148ae767dSmglocker }; 46296d56267Smglocker 46388daba3dSmglocker struct uvideo_res { 46488daba3dSmglocker int width; 46588daba3dSmglocker int height; 46688daba3dSmglocker int fidx; 467*ba30c7beSmglocker }; 46888daba3dSmglocker 4692ee56f53Smglocker struct uvideo_controls { 4702ee56f53Smglocker int cid; 4712ee56f53Smglocker int type; 4722ee56f53Smglocker char name[32]; 4732ee56f53Smglocker uint16_t ctrl_bitmap; 4742ee56f53Smglocker uint16_t ctrl_selector; 4752ee56f53Smglocker uint16_t ctrl_len; 4762ee56f53Smglocker } uvideo_ctrls[] = { 4772ee56f53Smglocker /* TODO complete control list */ 4782ee56f53Smglocker { 4792ee56f53Smglocker V4L2_CID_BRIGHTNESS, 4802ee56f53Smglocker V4L2_CTRL_TYPE_INTEGER, 4812ee56f53Smglocker "Brightness", 4822ee56f53Smglocker (1 << 0), 4832ee56f53Smglocker PU_BRIGHTNESS_CONTROL, 4842ee56f53Smglocker 2 4852ee56f53Smglocker }, 4862ee56f53Smglocker { 4872ee56f53Smglocker V4L2_CID_CONTRAST, 4882ee56f53Smglocker V4L2_CTRL_TYPE_INTEGER, 4892ee56f53Smglocker "Contrast", 4902ee56f53Smglocker (1 << 1), 4912ee56f53Smglocker PU_CONTRAST_CONTROL, 4922ee56f53Smglocker 2 4932ee56f53Smglocker }, 4942ee56f53Smglocker { 4952ee56f53Smglocker V4L2_CID_HUE, 4962ee56f53Smglocker V4L2_CTRL_TYPE_INTEGER, 4972ee56f53Smglocker "Hue", 4982ee56f53Smglocker (1 << 2), 4992ee56f53Smglocker PU_HUE_CONTROL, 5002ee56f53Smglocker 2 5012ee56f53Smglocker }, 5022ee56f53Smglocker { 5032ee56f53Smglocker V4L2_CID_SATURATION, 5042ee56f53Smglocker V4L2_CTRL_TYPE_INTEGER, 5052ee56f53Smglocker "Saturation", 5062ee56f53Smglocker (1 << 3), 5072ee56f53Smglocker PU_SATURATION_CONTROL, 5082ee56f53Smglocker 2 5092ee56f53Smglocker }, 5102ee56f53Smglocker { 5112ee56f53Smglocker V4L2_CID_GAMMA, 5122ee56f53Smglocker V4L2_CTRL_TYPE_INTEGER, 5132ee56f53Smglocker "Gamma", 5142ee56f53Smglocker (1 << 5), 5152ee56f53Smglocker PU_GAMMA_CONTROL, 5162ee56f53Smglocker 2 5172ee56f53Smglocker }, 5182ee56f53Smglocker { 5192ee56f53Smglocker V4L2_CID_GAIN, 5202ee56f53Smglocker V4L2_CTRL_TYPE_INTEGER, 5212ee56f53Smglocker "Gain", 5222ee56f53Smglocker (1 << 9), 5232ee56f53Smglocker PU_GAIN_CONTROL, 5242ee56f53Smglocker 2, 5252ee56f53Smglocker }, 5262ee56f53Smglocker { 0, 0, "", 0, 0, 0 } 5272ee56f53Smglocker }; 5282ee56f53Smglocker 529cf110a4aSrobert struct uvideo_softc { 530cf110a4aSrobert struct device sc_dev; 531cf110a4aSrobert usbd_device_handle sc_udev; 532cf110a4aSrobert usbd_interface_handle sc_iface; 533cf110a4aSrobert int sc_iface_number; 534cf110a4aSrobert int sc_product; 535cf110a4aSrobert int sc_vendor; 536cf110a4aSrobert 537cf110a4aSrobert int sc_intr_number; 538cf110a4aSrobert usbd_pipe_handle sc_intr_pipe; 539cf110a4aSrobert u_char *sc_ibuf; 540cf110a4aSrobert int sc_isize; 541cf110a4aSrobert int sc_vc_iface; 542cf110a4aSrobert 543cf110a4aSrobert struct device *sc_videodev; 544cf110a4aSrobert 545cf110a4aSrobert struct vs_info *sc_alts; 546cf110a4aSrobert int sc_nalts; 547cf110a4aSrobert int sc_nullalt; 548cf110a4aSrobert int sc_video_rev; 549cf110a4aSrobert int sc_enabled; 550cf110a4aSrobert int sc_dying; 551cf110a4aSrobert int sc_mode; 55270fff4d6Smglocker int sc_max_fbuf_size; 55394047bb7Smglocker int sc_negotiated_flag; 554cf110a4aSrobert 555cf110a4aSrobert u_int16_t uvc_version; 556cf110a4aSrobert u_int32_t clock_frequency; 557cf110a4aSrobert u_int32_t quirks; 558cf110a4aSrobert 559f42b917bSmglocker struct uvideo_frame_buffer sc_frame_buffer; 5601dc1fa5aSmglocker 561ac9faad8Smglocker struct uvideo_mmap sc_mmap[UVIDEO_MAX_BUFFERS]; 562ac9faad8Smglocker uint8_t *sc_mmap_buffer; 5631dc1fa5aSmglocker q_mmap sc_mmap_q; 5641dc1fa5aSmglocker int sc_mmap_count; 5651dc1fa5aSmglocker int sc_mmap_cur; 566321912b9Smglocker int sc_mmap_flag; 567cf110a4aSrobert 568cf110a4aSrobert struct vnode *sc_vp; 569cf110a4aSrobert struct usb_task sc_task_write; 570cf110a4aSrobert 571259e150dSmglocker int sc_nframes; 572259e150dSmglocker struct usb_video_probe_commit sc_desc_probe; 573259e150dSmglocker struct usb_video_header_desc_all sc_desc_vc_header; 574c668bad0Smglocker struct usb_video_input_header_desc_all sc_desc_vs_input_header; 57596d56267Smglocker 5762ee56f53Smglocker #define UVIDEO_MAX_PU 8 5772ee56f53Smglocker int sc_desc_vc_pu_num; 5782ee56f53Smglocker struct usb_video_vc_processing_desc *sc_desc_vc_pu_cur; 5792ee56f53Smglocker struct usb_video_vc_processing_desc *sc_desc_vc_pu[UVIDEO_MAX_PU]; 5802ee56f53Smglocker 58196d56267Smglocker #define UVIDEO_MAX_FORMAT 8 5826e7dc0a3Smglocker int sc_fmtgrp_idx; 58394047bb7Smglocker int sc_fmtgrp_num; 58496d56267Smglocker struct uvideo_format_group *sc_fmtgrp_cur; 58596d56267Smglocker struct uvideo_format_group sc_fmtgrp[UVIDEO_MAX_FORMAT]; 586259e150dSmglocker 587259e150dSmglocker #define UVIDEO_MAX_VS_NUM 8 588f00f92e5Smglocker struct uvideo_vs_iface *sc_vs_cur; 589259e150dSmglocker struct uvideo_vs_iface sc_vs_coll[UVIDEO_MAX_VS_NUM]; 590dabf5a5aSmglocker 591dabf5a5aSmglocker void *sc_uplayer_arg; 592dabf5a5aSmglocker int *sc_uplayer_fsize; 593dabf5a5aSmglocker uint8_t *sc_uplayer_fbuffer; 594dabf5a5aSmglocker void (*sc_uplayer_intr)(void *); 595cf110a4aSrobert }; 596