1*70fff4d6Smglocker /* $OpenBSD: uvideo.h,v 1.25 2008/07/26 11:42:43 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; 165259e150dSmglocker }; 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; 181cf110a4aSrobert }; 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; 193cf110a4aSrobert }; 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; 209cf110a4aSrobert }; 210cf110a4aSrobert 21101c33b94Smglocker /* Table 3-9: VC Extension Unit Descriptor */ 21201c33b94Smglocker struct usb_video_vc_extension_desc { 21301c33b94Smglocker uByte bLength; 21401c33b94Smglocker uByte bDescriptorType; 21501c33b94Smglocker uByte bDescriptorSubtype; 21601c33b94Smglocker uByte bUnitID; 21701c33b94Smglocker uByte guidExtensionCode[16]; 21801c33b94Smglocker uByte bNumControls; 21901c33b94Smglocker uByte bNrInPins; 22001c33b94Smglocker } __packed; 22101c33b94Smglocker 222cf110a4aSrobert /* Table 3-11: VC Endpoint Descriptor */ 223cf110a4aSrobert struct usb_video_vc_endpoint_desc { 224cf110a4aSrobert uByte bLength; 225cf110a4aSrobert uByte bDescriptorType; 226cf110a4aSrobert uByte bDescriptorSubtype; 227cf110a4aSrobert uWord wMaxTransferSize; 228cf110a4aSrobert }; 229cf110a4aSrobert 23069db36cdSmglocker /* Table 3-13: Interface Input Header Descriptor */ 23169db36cdSmglocker struct usb_video_input_header_desc { 23269db36cdSmglocker uByte bLength; 23369db36cdSmglocker uByte bDescriptorType; 23469db36cdSmglocker uByte bDescriptorSubtype; 23569db36cdSmglocker uByte bNumFormats; 23669db36cdSmglocker uWord wTotalLength; 23769db36cdSmglocker uByte bEndpointAddress; 23869db36cdSmglocker uByte bmInfo; 23969db36cdSmglocker uByte bTerminalLink; 24069db36cdSmglocker uByte bStillCaptureMethod; 24169db36cdSmglocker uByte bTriggerSupport; 24269db36cdSmglocker uByte bTriggerUsage; 24369db36cdSmglocker uByte bControlSize; 24469db36cdSmglocker }; 24569db36cdSmglocker 246c668bad0Smglocker struct usb_video_input_header_desc_all { 247c668bad0Smglocker struct usb_video_input_header_desc *fix; 248c668bad0Smglocker uByte *bmaControls; 249c668bad0Smglocker }; 250c668bad0Smglocker 251cf110a4aSrobert /* Table 3-18: Color Matching Descriptor */ 252cf110a4aSrobert struct usb_video_color_matching_descr { 253cf110a4aSrobert uByte bLength; 254cf110a4aSrobert uByte bDescriptorType; 255cf110a4aSrobert uByte bDescriptorSubtype; 256cf110a4aSrobert uByte bColorPrimaries; 257cf110a4aSrobert uByte bTransferCharacteristics; 258cf110a4aSrobert uByte bMatrixCoefficients; 259cf110a4aSrobert } __packed; 260cf110a4aSrobert 261cf110a4aSrobert /* Table 4-47: Video Probe and Commit Controls */ 262cf110a4aSrobert struct usb_video_probe_commit { 263259e150dSmglocker uWord bmHint; 264cf110a4aSrobert uByte bFormatIndex; 265cf110a4aSrobert uByte bFrameIndex; 266259e150dSmglocker uDWord dwFrameInterval; 267259e150dSmglocker uWord wKeyFrameRate; 268259e150dSmglocker uWord wPFrameRate; 269259e150dSmglocker uWord wCompQuality; 270259e150dSmglocker uWord wCompWindowSize; 271259e150dSmglocker uWord wDelay; 272259e150dSmglocker uDWord dwMaxVideoFrameSize; 273259e150dSmglocker uDWord dwMaxPayloadTransferSize; 274259e150dSmglocker uDWord wClockFrequency; 275cf110a4aSrobert uByte bmFramingInfo; 276cf110a4aSrobert uByte bPreferedVersion; 277cf110a4aSrobert uByte bMinVersion; 278cf110a4aSrobert uByte bMaxVersion; 279cf110a4aSrobert } __packed; 280cf110a4aSrobert 281cf110a4aSrobert /* 282cf110a4aSrobert * USB Video Payload Uncompressed 283cf110a4aSrobert */ 284cf110a4aSrobert /* Table 2-1: Compression Formats */ 285cf110a4aSrobert #define UVIDEO_FORMAT_GUID_YUY2 { \ 286cf110a4aSrobert 0x59, 0x55, 0x59, 0x32, 0x00, 0x00, 0x10, 0x00, \ 287cf110a4aSrobert 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } 288cf110a4aSrobert 289cf110a4aSrobert #define UVIDEO_FORMAT_GUID_NV12 { \ 290cf110a4aSrobert 0x4e, 0x56, 0x31, 0x32, 0x00, 0x00, 0x10, 0x00, \ 291cf110a4aSrobert 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } 292cf110a4aSrobert 293cf110a4aSrobert /* 294cf110a4aSrobert * USB Video Payload MJPEG 295cf110a4aSrobert */ 296cf110a4aSrobert /* Table 2-1: Stream Header Format for the Motion-JPEG */ 297cf110a4aSrobert #define UVIDEO_STREAM_FID (1 << 0) 298cf110a4aSrobert #define UVIDEO_STREAM_EOF (1 << 1) 299cf110a4aSrobert #define UVIDEO_STREAM_PTS (1 << 2) 300cf110a4aSrobert #define UVIDEO_STREAM_SCR (1 << 3) 301cf110a4aSrobert #define UVIDEO_STREAM_RES (1 << 4) 302cf110a4aSrobert #define UVIDEO_STREAM_STI (1 << 5) 303cf110a4aSrobert #define UVIDEO_STREAM_ERR (1 << 6) 304cf110a4aSrobert #define UVIDEO_STREAM_EOH (1 << 7) 305cf110a4aSrobert 306cf110a4aSrobert /* Table 3-1: Motion-JPEG Video Format Descriptor */ 307259e150dSmglocker struct usb_video_format_mjpeg_desc { 308cf110a4aSrobert uByte bLength; 309cf110a4aSrobert uByte bDescriptorType; 310cf110a4aSrobert uByte bDescriptorSubtype; 311cf110a4aSrobert uByte bFormatIndex; 312cf110a4aSrobert uByte bNumFrameDescriptors; 313cf110a4aSrobert uByte bmFlags; 314cf110a4aSrobert uByte bDefaultFrameIndex; 315cf110a4aSrobert uByte bAspectRatioX; 316cf110a4aSrobert uByte bAspectRatioY; 317cf110a4aSrobert uByte bmInterlaceFlags; 318cf110a4aSrobert uByte bCopyProtect; 319cf110a4aSrobert } __packed; 320cf110a4aSrobert 321cf110a4aSrobert /* Table 3-2: Motion-JPEG Video Frame Descriptor */ 322259e150dSmglocker struct usb_video_frame_mjpeg_desc { 323cf110a4aSrobert uByte bLength; 324cf110a4aSrobert uByte bDescriptorType; 325cf110a4aSrobert uByte bDescriptorSubtype; 326cf110a4aSrobert uByte bFrameIndex; 327cf110a4aSrobert uByte bmCapabilities; 328cf110a4aSrobert uWord wWidth; 329cf110a4aSrobert uWord wHeight; 330cf110a4aSrobert uDWord dwMinBitRate; 331cf110a4aSrobert uDWord dwMaxBitRate; 332cf110a4aSrobert uDWord dwMaxVideoFrameBufferSize; 333eaa1845bSmglocker uDWord dwDefaultFrameInterval; 334cf110a4aSrobert uByte bFrameIntervalType; 335eaa1845bSmglocker /* TODO add continous/discrete frame intervals (Table 3-3/3-4) */ 336cf110a4aSrobert } __packed; 337cf110a4aSrobert 338cf110a4aSrobert /* 339786c2e79Smglocker * USB Video Payload Uncompressed 340786c2e79Smglocker */ 341786c2e79Smglocker /* Table 3-1: Uncompressed Video Format Descriptor */ 342786c2e79Smglocker struct usb_video_format_uncompressed_desc { 343786c2e79Smglocker uByte bLength; 344786c2e79Smglocker uByte bDescriptorType; 345786c2e79Smglocker uByte bDescriptorSubtype; 346786c2e79Smglocker uByte bFormatIndex; 347786c2e79Smglocker uByte bNumFrameDescriptors; 348786c2e79Smglocker uByte guidFormat[16]; 349786c2e79Smglocker uByte bBitsPerPixel; 350786c2e79Smglocker uByte bDefaultFrameIndex; 351786c2e79Smglocker uByte bAspectRatioX; 352786c2e79Smglocker uByte bAspectRatioY; 353786c2e79Smglocker uByte bmInterlaceFlags; 354786c2e79Smglocker uByte bCopyProtect; 355786c2e79Smglocker } __packed; 356786c2e79Smglocker 357786c2e79Smglocker /* Table 3-2: Uncompressed Video Frame Descriptor */ 358786c2e79Smglocker struct usb_video_frame_uncompressed_desc { 359786c2e79Smglocker uByte bLength; 360786c2e79Smglocker uByte bDescriptorType; 361786c2e79Smglocker uByte bDescriptorSubtype; 362786c2e79Smglocker uByte bFrameIndex; 363786c2e79Smglocker uByte bmCapabilities; 364786c2e79Smglocker uWord wWidth; 365786c2e79Smglocker uWord wHeight; 366786c2e79Smglocker uDWord dwMinBitRate; 367786c2e79Smglocker uDWord dwMaxBitRate; 368786c2e79Smglocker uDWord dwMaxVideoFrameBufferSize; 369786c2e79Smglocker uDWord dwDefaultFrameInterval; 370786c2e79Smglocker uByte bFrameIntervalType; 371786c2e79Smglocker /* TODO add continous/discrete frame intervals (Table 3-3/3-4) */ 372786c2e79Smglocker } __packed; 373786c2e79Smglocker 374786c2e79Smglocker /* 375cf110a4aSrobert * Driver specific private definitions. 376cf110a4aSrobert */ 3774ad08878Smglocker #define UVIDEO_NFRAMES_MAX 40 378cf110a4aSrobert 379259e150dSmglocker struct uvideo_vs_iface { 380cf110a4aSrobert struct uvideo_softc *sc; 381cf110a4aSrobert usbd_xfer_handle xfer; 382cf110a4aSrobert void *buf; 383cf110a4aSrobert usbd_interface_handle ifaceh; 384259e150dSmglocker int endpoint; 385259e150dSmglocker usbd_pipe_handle pipeh; 386259e150dSmglocker uint16_t size[UVIDEO_NFRAMES_MAX]; 387259e150dSmglocker int numalts; 388259e150dSmglocker int curalt; 389259e150dSmglocker uint32_t max_packet_size; 390259e150dSmglocker int iface; 391cf110a4aSrobert }; 392cf110a4aSrobert 393cf110a4aSrobert struct uvideo_sample_buffer { 394cf110a4aSrobert int fragment; 395cf110a4aSrobert uint8_t fid; 396cf110a4aSrobert int offset; 397aac52593Smglocker int buf_size; 398cf110a4aSrobert uint8_t *buf; 399cf110a4aSrobert }; 400cf110a4aSrobert 40110b73889Smglocker #define UVIDEO_MAX_BUFFERS 32 402ac9faad8Smglocker struct uvideo_mmap { 4031dc1fa5aSmglocker SIMPLEQ_ENTRY(uvideo_mmap) q_frames; 404f7821c14Smglocker uint8_t *buf; 405ac9faad8Smglocker struct v4l2_buffer v4l2_buf; 406f7821c14Smglocker }; 4071dc1fa5aSmglocker typedef SIMPLEQ_HEAD(, uvideo_mmap) q_mmap; 408f7821c14Smglocker 409ff018eb9Smglocker struct uvideo_format_desc { 410ff018eb9Smglocker uByte bLength; 411ff018eb9Smglocker uByte bDescriptorType; 412ff018eb9Smglocker uByte bDescriptorSubtype; 413ff018eb9Smglocker uByte bFormatIndex; 414ff018eb9Smglocker uByte bNumFrameDescriptors; 415ff018eb9Smglocker union { 416ff018eb9Smglocker /* mjpeg */ 417ff018eb9Smglocker struct { 418ff018eb9Smglocker uByte bmFlags; 419ff018eb9Smglocker uByte bDefaultFrameIndex; 420ff018eb9Smglocker uByte bAspectRatioX; 421ff018eb9Smglocker uByte bAspectRatioY; 422ff018eb9Smglocker uByte bmInterlaceFlags; 423ff018eb9Smglocker uByte bCopyProtect; 424ff018eb9Smglocker } mjpeg; 425ff018eb9Smglocker 426ff018eb9Smglocker /* uncompressed */ 427ff018eb9Smglocker struct { 428ff018eb9Smglocker uByte guidFormat[16]; 429ff018eb9Smglocker uByte bBitsPerPixel; 430ff018eb9Smglocker uByte bDefaultFrameIndex; 431ff018eb9Smglocker uByte bAspectRatioX; 432ff018eb9Smglocker uByte bAspectRatioY; 433ff018eb9Smglocker uByte bmInterlaceFlags; 434ff018eb9Smglocker uByte bCopyProtect; 435ff018eb9Smglocker } uc; 436ff018eb9Smglocker } u; 437ff018eb9Smglocker } __packed; 438ff018eb9Smglocker 43996d56267Smglocker struct uvideo_format_group { 44094047bb7Smglocker uint32_t pixelformat; 441ff018eb9Smglocker struct uvideo_format_desc *format; 442ff018eb9Smglocker uint8_t format_dfidx; 443ff018eb9Smglocker /* frame descriptors for mjpeg and uncompressed are identical */ 44496d56267Smglocker #define UVIDEO_MAX_FRAME 16 44594047bb7Smglocker int frame_num; 446ff018eb9Smglocker struct usb_video_frame_mjpeg_desc *frame_cur; 44796d56267Smglocker struct usb_video_frame_mjpeg_desc *frame[UVIDEO_MAX_FRAME]; 44896d56267Smglocker } __packed; 44996d56267Smglocker 45088daba3dSmglocker struct uvideo_res { 45188daba3dSmglocker int width; 45288daba3dSmglocker int height; 45388daba3dSmglocker int fidx; 45488daba3dSmglocker } __packed; 45588daba3dSmglocker 456cf110a4aSrobert struct uvideo_softc { 457cf110a4aSrobert struct device sc_dev; 458cf110a4aSrobert usbd_device_handle sc_udev; 459cf110a4aSrobert usbd_interface_handle sc_iface; 460cf110a4aSrobert int sc_iface_number; 461cf110a4aSrobert int sc_product; 462cf110a4aSrobert int sc_vendor; 463cf110a4aSrobert 464cf110a4aSrobert int sc_intr_number; 465cf110a4aSrobert usbd_pipe_handle sc_intr_pipe; 466cf110a4aSrobert u_char *sc_ibuf; 467cf110a4aSrobert int sc_isize; 468cf110a4aSrobert int sc_vc_iface; 469cf110a4aSrobert 470cf110a4aSrobert struct device *sc_videodev; 471cf110a4aSrobert 472cf110a4aSrobert struct vs_info *sc_alts; 473cf110a4aSrobert int sc_nalts; 474cf110a4aSrobert int sc_nullalt; 475cf110a4aSrobert int sc_video_rev; 476cf110a4aSrobert int sc_enabled; 477cf110a4aSrobert int sc_dying; 478cf110a4aSrobert int sc_mode; 479*70fff4d6Smglocker int sc_max_fbuf_size; 48094047bb7Smglocker int sc_negotiated_flag; 481cf110a4aSrobert 482cf110a4aSrobert u_int16_t uvc_version; 483cf110a4aSrobert u_int32_t clock_frequency; 484cf110a4aSrobert u_int32_t quirks; 485cf110a4aSrobert 486cf110a4aSrobert struct uvideo_sample_buffer sc_sample_buffer; 4871dc1fa5aSmglocker 488ac9faad8Smglocker struct uvideo_mmap sc_mmap[UVIDEO_MAX_BUFFERS]; 489ac9faad8Smglocker uint8_t *sc_mmap_buffer; 4901dc1fa5aSmglocker q_mmap sc_mmap_q; 4911dc1fa5aSmglocker int sc_mmap_count; 4921dc1fa5aSmglocker int sc_mmap_cur; 493321912b9Smglocker int sc_mmap_flag; 494cf110a4aSrobert 495cf110a4aSrobert struct vnode *sc_vp; 496cf110a4aSrobert struct usb_task sc_task_write; 497cf110a4aSrobert 498259e150dSmglocker int sc_nframes; 499259e150dSmglocker struct usb_video_probe_commit sc_desc_probe; 500259e150dSmglocker struct usb_video_header_desc_all sc_desc_vc_header; 501c668bad0Smglocker struct usb_video_input_header_desc_all sc_desc_vs_input_header; 50296d56267Smglocker 50396d56267Smglocker #define UVIDEO_MAX_FORMAT 8 50494047bb7Smglocker int sc_fmtgrp_num; 50596d56267Smglocker struct uvideo_format_group *sc_fmtgrp_cur; 50696d56267Smglocker struct uvideo_format_group sc_fmtgrp[UVIDEO_MAX_FORMAT]; 507259e150dSmglocker 508259e150dSmglocker #define UVIDEO_MAX_VS_NUM 8 509259e150dSmglocker struct uvideo_vs_iface *sc_vs_curr; 510259e150dSmglocker struct uvideo_vs_iface sc_vs_coll[UVIDEO_MAX_VS_NUM]; 511dabf5a5aSmglocker 512dabf5a5aSmglocker void *sc_uplayer_arg; 513dabf5a5aSmglocker int *sc_uplayer_fsize; 514dabf5a5aSmglocker uint8_t *sc_uplayer_fbuffer; 515dabf5a5aSmglocker void (*sc_uplayer_intr)(void *); 516cf110a4aSrobert }; 517