PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
v2u_defs.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * $Id: v2u_defs.h 14622 2011-10-28 21:34:50Z rekjanov $
4  *
5  * Copyright (C) 2003-2011 Epiphan Systems Inc. All rights reserved.
6  *
7  * VGA2USB common defines and types
8  *
9  ****************************************************************************/
10 
11 #ifndef _VGA2USB_DEFS_H_
12 #define _VGA2USB_DEFS_H_ 1
13 
14 /* Required system headers */
15 #if !defined(__KERNEL__) && !defined(__C51__)
16 # ifdef _WIN32
17 # include <windows.h>
18 # include <winioctl.h>
19 # else /* Unix */
20 # include <stdint.h>
21 # include <sys/ioctl.h>
22 # endif /* Unix */
23 #endif /* __KERNEL__ */
24 
25 /* Structure packing */
26 #ifdef _WIN32
27 # include <pshpack1.h>
28 #endif
29 
30 #ifndef V2U_PACKED
31 # if defined(_WIN32) || defined(__C51__)
32 # define V2U_PACKED
33 # else
34 # define V2U_PACKED __attribute__((packed))
35 # endif
36 #endif
37 
38 /* Basic data types */
39 #ifdef _WIN32
40 typedef __int8 V2U_INT8;
41 typedef unsigned __int8 V2U_UINT8;
42 typedef __int16 V2U_INT16;
43 typedef unsigned __int16 V2U_UINT16;
44 typedef __int32 V2U_INT32;
45 typedef unsigned __int32 V2U_UINT32;
46 typedef __int64 V2U_INT64;
47 typedef unsigned __int64 V2U_UINT64;
48 #elif defined(__C51__)
49 typedef char V2U_INT8;
50 typedef unsigned char V2U_UINT8;
51 typedef short V2U_INT16;
52 typedef unsigned short V2U_UINT16;
53 typedef long V2U_INT32;
54 typedef unsigned long V2U_UINT32;
55 /* V2U_INT64 and V2U_UINT64 should not be used on FX2 microcontroller */
56 typedef BYTE V2U_INT64[8];
57 typedef BYTE V2U_UINT64[8];
58 #else
59 typedef int8_t V2U_INT8;
60 typedef uint8_t V2U_UINT8;
61 typedef int16_t V2U_INT16;
62 typedef uint16_t V2U_UINT16;
63 typedef int32_t V2U_INT32;
64 typedef uint32_t V2U_UINT32;
65 typedef int64_t V2U_INT64;
66 typedef uint64_t V2U_UINT64;
67 #endif
68 
72 #if !defined(__C51__)
74 #endif
75 
76 #define V2U_TRUE 1
77 #define V2U_FALSE 0
78 
79 typedef struct v2u_size
80 {
84 
85 typedef struct v2u_rect
86 {
92 
93 typedef struct v2u_str_ucs2
94 {
95  V2U_UCS2* buffer; /* not necessarily NULL-terminated */
96  V2U_UINT32 len; /* string length, in characters */
97  V2U_UINT32 maxlen; /* buffer size, in characters */
99 
100 /*
101  * V2U_VideoMode
102  *
103  * Video mode descriptor.
104  *
105  * Note that the vertical refresh rate is measured in milliHertz.
106  * That is, the number 59900 represents 59.9 Hz.
107  */
108 typedef struct ioctl_videomode
109 {
110  V2U_INT32 width; /* screen width, pixels */
111  V2U_INT32 height; /* screen height, pixels */
112  V2U_INT32 vfreq; /* vertical refresh rate, mHz */
114 
115 /*
116  * V2U_GrabParameters
117  *
118  * VGA capture parameters.
119  *
120  * Gain = Contrast
121  * Offset = Brightness
122  */
123 typedef struct ioctl_setparams
124 {
125  V2U_UINT32 flags; /* Validity flags for fields below */
126  /* When any of the fields below is used, */
127  /* corresponding V2U_FLAG_VALID_* flag is set */
128  /* otherwise the field is ignored */
129  V2U_INT32 hshift; /* Shifts image left (<0) or right(>0). */
130  /* Valid range depends on the video mode. */
131  /* Invalid values are rounded to the nearest */
132  /* valid value */
133  V2U_UINT8 phase; /* Pixel sampling phase, [0,31] */
134  V2U_UINT8 gain_r; /* Gain for the red channel, [0,255] */
135  V2U_UINT8 gain_g; /* Gain for the green channel, [0,255] */
136  V2U_UINT8 gain_b; /* Gain for the blue channel, [0,255] */
137  V2U_UINT8 offset_r; /* Offset for the red channel, [0,63] */
138  V2U_UINT8 offset_g; /* Offset for the green channel, [0,63] */
139  V2U_UINT8 offset_b; /* Offset for the blue channel, [0,63] */
140  V2U_UINT8 reserved; /* added for alignment, don't use */
141  V2U_INT32 vshift; /* Shifts image up or down */
142  /* Valid range depends on the video mode. */
143  /* Invalid values are rounded to the nearest */
144  /* valid value */
145  V2U_INT32 pllshift; /* Adjusts the PLL value */
146  V2U_UINT32 grab_flags; /* Sets grab_flags V2U_GRAB_* */
147  V2U_UINT32 grab_flags_mask; /* Marks which bits from grab_flags are used */
149 
150 /* Indicates that hshift field is used */
151 #define V2U_FLAG_VALID_HSHIFT 0x0001
152 /* Indicates that phase field is used */
153 #define V2U_FLAG_VALID_PHASE 0x0002
154 /* Indicates that all gain_{rgb} and offset_{rgb} fields are used */
155 #define V2U_FLAG_VALID_OFFSETGAIN 0x0004
156 /* Indicates that vshift field is used */
157 #define V2U_FLAG_VALID_VSHIFT 0x0008
158 /* Indicates that pllshift field is used */
159 #define V2U_FLAG_VALID_PLLSHIFT 0x0010
160 /* Indicates that grab_flags and grab_flags_mask are used */
161 #define V2U_FLAG_VALID_GRABFLAGS 0x0020
162 
163 /* Flags allowed in grab_flags and grab_flags_mask fields */
164 /* Grab image upside-down */
165 #define V2U_GRAB_BMP_BOTTOM_UP 0x10000
166 /* Sometimes 4:3 and wide modes with the same height are indistinguishable,
167  * so this flag can force choosing wide mode */
168 #define V2U_GRAB_PREFER_WIDE_MODE 0x20000
169 
170 /*
171  * The ranges below are obsolete. They depend on the frame grabber model
172  * as well as the video mode. Use V2UKey_AdjustmentsRange property to get
173  * the ranges that are valid for the parcular frame grabber and current
174  * video mode.
175  */
176 #define V2U_MIN_PHASE 0
177 #define V2U_MAX_PHASE 31
178 #define V2U_MIN_GAIN 0
179 #define V2U_MAX_GAIN 255
180 #define V2U_MIN_OFFSET 0
181 #define V2U_MAX_OFFSET 63
182 
183 /*
184  * V2U_SendPS2
185  *
186  * PS/2 packet descriptor.
187  */
188 typedef struct ioctl_sendps2
189 {
190  short addr;
191  short len;
192  unsigned char buf[64];
194 
195 #define V2U_PS2ADDR_KEYBOARD 0x01
196 #define V2U_PS2ADDR_MOUSE 0x02
197 
198 /*
199  * V2U_GetSN
200  *
201  * Serial number.
202  */
203 
204 #define V2U_SN_BUFSIZ 32
205 
206 typedef struct ioctl_getsn
207 {
208  char sn[V2U_SN_BUFSIZ]; /* OUT serial number string */
210 
211 typedef enum v2u_product_type
212 {
236  V2UProductCount /* Number of known product types */
238 
239 /*
240  * Note that V2UScaleModeWeightedAverage scale mode is EXPERIMENTAL and
241  * currently only works for RGB24 capture. For all other pixel formats
242  * it defaults to V2UScaleModeNearestNeighbor.
243  */
244 typedef enum v2u_scale_mode
245 {
246  V2UScaleNone, /* No scaling */
247  V2UScaleModeNearestNeighbor, /* Nearest neighbor algorithm */
248  V2UScaleModeWeightedAverage, /* Weighted average algorithm */
249  V2UScaleModeFastBilinear, /* Fast bilinear */
250  V2UScaleModeBilinear, /* Bilinear */
251  V2UScaleModeBicubic, /* Bicubic */
252  V2UScaleModeExperimental, /* Experimental */
253  V2UScaleModePoint, /* Nearest neighbour# 2 */
254  V2UScaleModeArea, /* Weighted average */
255  V2UScaleModeBicubLin, /* Luma bicubic, chroma bilinear */
256  V2UScaleModeSinc, /* Sinc */
257  V2UScaleModeLanczos, /* Lanczos */
258  V2UScaleModeSpline, /* Natural bicubic spline */
259  V2UScaleModeHardware, /* Scale in hardware, if supported */
260  V2UScaleModeCount /* Number of valid modes */
261 } V2UScaleMode;
262 
263 /* Macros to translate V2UScaleMode to capture flags and back */
264 #define V2U_SCALE_MODE_TO_FLAGS(_m) \
265  (((_m) << 16) & V2U_GRABFRAME_SCALE_MASK)
266 #define V2U_SCALE_FLAGS_TO_MODE(_f) \
267  ((V2UScaleMode)(((_f) & V2U_GRABFRAME_SCALE_MASK) >> 16))
268 
269 typedef enum v2u_rotation_mode
270 {
271  V2URotationNone, /* V2U_GRABFRAME_ROTATION_NONE */
272  V2URotationLeft90, /* V2U_GRABFRAME_ROTATION_LEFT90 */
273  V2URotationRight90, /* V2U_GRABFRAME_ROTATION_RIGHT90 */
274  V2URotation180, /* V2U_GRABFRAME_ROTATION_180 */
275  V2URotationCount /* Number of valid rotation types */
277 
278 /* Macros to translate V2URotationMode to capture flags and back */
279 #define V2U_ROTATION_MODE_TO_FLAGS(_m) \
280  (((_m) << 20) & V2U_GRABFRAME_ROTATION_MASK)
281 #define V2U_ROTATION_FLAGS_TO_MODE(_f) \
282  ((V2URotationMode)(((_f) & V2U_GRABFRAME_ROTATION_MASK) >> 20))
283 
284 typedef struct v2u_adjustment_range
285 {
301 
302 /* Video mode descriptor */
303 typedef struct vesa_videomode
304 {
306  V2U_UINT16 HorAddrTime; /* pixels */
307  V2U_UINT16 HorFrontPorch; /* pixels */
308  V2U_UINT16 HorSyncTime; /* pixels */
309  V2U_UINT16 HorBackPorch; /* pixels */
310  V2U_UINT16 VerAddrTime; /* lines */
312  V2U_UINT16 VerSyncTime; /* lines */
314  V2U_UINT32 Type; /* flags, see below */
315 
316 #define VIDEOMODE_TYPE_VALID 0x01
317 #define VIDEOMODE_TYPE_ENABLED 0x02
318 #define VIDEOMODE_TYPE_SUPPORTED 0x04
319 #define VIDEOMODE_TYPE_DUALLINK 0x08
320 #define VIDEOMODE_TYPE_DIGITAL 0x10
321 #define VIDEOMODE_TYPE_INTERLACED 0x20
322 #define VIDEOMODE_TYPE_HSYNCPOSITIVE 0x40
323 #define VIDEOMODE_TYPE_VSYNCPOSITIVE 0x80
324 #define VIDEOMODE_TYPE_TOPFIELDFIRST 0x100
325 
328 
329 /* Maximum number of custom videomodes */
330 #define V2U_CUSTOM_VIDEOMODE_COUNT 8
331 
332 /*
333  * The first 8 (V2U_CUSTOM_VIDEOMODE_COUNT) entries in the video mode table
334  * are reserved for custom video modes. The remaining entries are standard
335  * video modes.
336  */
337 typedef struct custom_videomode
338 {
342 
343 typedef struct v2u_version
344 {
350 
351 /*
352  * Property keys and types
353  */
354 
355 /* V2UKey_DirectShowFlags */
356 #define V2U_DSHOW_LIMIT_FPS 0x200
357 #define V2U_DSHOW_FLIP_VERTICALLY 0x400
358 #define V2U_DSHOW_FIX_FPS 0x800
359 
360 /* Type of video input (V2UKey_InputSignalType) */
361 #define V2U_INPUT_NONE 0x00
362 #define V2U_INPUT_ANALOG 0x01
363 #define V2U_INPUT_DIGITAL 0x02
364 #define V2U_INPUT_SOG 0x04
365 #define V2U_INPUT_COMPOSITE 0x08
366 
367 /* V2UKey_DigitalModeDetect */
369 {
370  V2UDigitalMode_AutoDetect, /* Automatic detection (default) */
371  V2UDigitalMode_SingleLink, /* Force single link */
372  V2UDigitalMode_DualLink, /* Force dual link */
373  V2UDigitalMode_Count /* Not a valid value */
375 
376 /* V2UKey_NoiseFilter */
377 typedef enum v2u_noise_filter
378 {
379  V2UNoiseFilter_Auto, /* Automatic configuration (default) */
380  V2UNoiseFilter_None, /* Disable noise filter */
381  V2UNoiseFilter_Low, /* Good for Apple */
384  V2UNoiseFilter_Extreme, /* Good for black and white */
385  V2UNoiseFilter_Count /* Not a valid value */
387 
388 /* V2UKey_BusType */
389 typedef enum v2u_bus_type
390 {
391  V2UBusType_Other, /* Doesn't fall into any known category */
392  V2UBusType_USB, /* USB bus */
393  V2UBusType_PCI, /* PCI (Express) bus */
394  V2UBusType_Count /* Not a valid value */
395 } V2UBusType;
396 
397 /* H/VSync threshold values */
398 #define V2U_MIN_SYNC_THRESHOLD 0
399 #define V2U_MAX_SYNC_THRESHOLD 255
400 #define V2U_DEFAULT_SYNC_THRESHOLD 128
401 
402 /* ResetADC options */
403 #define ResetADC_Reset 0x01
404 #define ResetADC_PowerDown 0x02
405 #define ResetADC_PowerUp 0x03
406 
407 /* Divide the value of V2UKey_DirectShowMaxFps by 100 to get the fps value */
408 #define V2U_FPS_DENOMINATOR 100
409 
410 /* Device capabilities for V2UKey_DeviceCaps */
411 #define V2U_CAPS_VGA_CAPTURE 0x0001 /* Captures VGA signal*/
412 #define V2U_CAPS_DVI_CAPTURE 0x0002 /* Captures DVI single-link */
413 #define V2U_CAPS_DVI_DUAL_LINK 0x0004 /* Captures DVI dual-link */
414 #define V2U_CAPS_KVM 0x0008 /* KVM functionality */
415 #define V2U_CAPS_EDID 0x0010 /* Programmable EDID */
416 #define V2U_CAPS_HW_COMPRESSION 0x0020 /* On-board compression */
417 #define V2U_CAPS_SYNC_THRESHOLD 0x0040 /* Adjustable sync thresholds */
418 #define V2U_CAPS_HW_SCALE 0x0080 /* Hardware scale */
419 #define V2U_CAPS_SIGNATURE 0x0100 /* Signed hardware */
420 
422 {
423  V2UPropAccess_NO, /* unaccesible */
424  V2UPropAccess_RO, /* Read only */
425  V2UPropAccess_RW, /* Read/Write */
426  V2UPropAccess_WO, /* Write only */
428 
429 typedef enum v2u_property_type
430 {
431  V2UPropType_Invalid = -1, /* Not a valid type */
432  V2UPropType_Int8, /* int8 - First valid type (zero) */
433  V2UPropType_Int16, /* int16 */
434  V2UPropType_Int32, /* int32 - Also used for enums */
435  V2UPropType_Boolean, /* boolean */
436  V2UPropType_Size, /* size */
437  V2UPropType_Rect, /* rect */
438  V2UPropType_Version, /* version */
439  V2UPropType_Binary, /* blob */
440  V2UPropType_EDID, /* edid */
441  V2UPropType_AdjustRange, /* adj_range */
442  V2UPropType_VGAMode, /* vgamode */
445  V2UPropType_Uint8, /* uint8 */
446  V2UPropType_Uint16, /* uint16 */
447  V2UPropType_Uint32, /* uint32 */
448  V2UPropType_Reserved, /* not being used */
449  V2UPropType_UserData, /* userdata */
450  V2UPropType_Int64, /* int64 */
451  V2UPropType_Uint64, /* uint64 */
452  V2UPropType_VESAMode, /* vesa_mode */
454  V2UPropType_Count /* Number of valid types */
456 
457 #define V2UPropType_Enum V2UPropType_Int32
458 
459 #define V2U_PROPERTY_LIST(property) \
460  property( V2UKey_UsbProductID, \
461  "USB Product id", \
462  V2UPropType_Int16, \
463  V2UPropAccess_RO) \
464  property( V2UKey_ProductType, \
465  "Product type", \
466  V2UPropType_Enum, \
467  V2UPropAccess_RO) \
468  property( V2UKey_DirectShowFixRes, /* Windows only */\
469  "DS Fix Resolution", \
470  V2UPropType_Size, \
471  V2UPropAccess_RW) \
472  property( V2UKey_DirectShowFlags, /* Windows only */\
473  "DS Flags", \
474  V2UPropType_Int32, \
475  V2UPropAccess_RW) \
476  property( V2UKey_DirectShowDefaultBmp, /* Windows only */\
477  "DS Default BMP", \
478  V2UPropType_StrUcs2, \
479  V2UPropAccess_RW) \
480  property( V2UKey_ModeMeasurmentsDump, \
481  "Mode Measurments dump", \
482  V2UPropType_Binary, \
483  V2UPropAccess_RO) \
484  property( V2UKey_ResetADC, /* Not really a property */\
485  "Reset ADC", \
486  V2UPropType_Int32, \
487  V2UPropAccess_WO) \
488  property( V2UKey_DirectShowScaleMode, /* Windows only */\
489  "DirectShow Scale Mode", \
490  V2UPropType_Enum, \
491  V2UPropAccess_RW) \
492  property( V2UKey_HardwareCompression, \
493  "Hardware Compression", \
494  V2UPropType_Boolean, \
495  V2UPropAccess_RO) \
496  property( V2UKey_AdjustmentsRange, \
497  "Adjustments Range", \
498  V2UPropType_AdjustRange, \
499  V2UPropAccess_RO) \
500  property( V2UKey_Version, \
501  "Version", \
502  V2UPropType_Version, \
503  V2UPropAccess_RO) \
504  property( V2UKey_EDID, \
505  "EDID", \
506  V2UPropType_EDID, \
507  V2UPropAccess_RW) \
508  property( V2UKey_DirectShowMaxFps, /* Windows only */\
509  "DS Max fps", \
510  V2UPropType_Int32, \
511  V2UPropAccess_RW) \
512  property( V2UKey_KVMCapable, \
513  "KVM capable", \
514  V2UPropType_Boolean, \
515  V2UPropAccess_RO) \
516  property( V2UKey_VGAMode, \
517  "VGA mode", \
518  V2UPropType_VGAMode, \
519  V2UPropAccess_RW) \
520  property( V2UKey_CurrentVGAMode, /* Since 3.24.6 */\
521  "Current VGA mode", \
522  V2UPropType_VESAMode, \
523  V2UPropAccess_RO) \
524  property( V2UKey_ModeMeasureInterval, \
525  "Mode Measure interval", \
526  V2UPropType_Int32, \
527  V2UPropAccess_RW) \
528  property( V2UKey_EDIDSupport, \
529  "EDID support", \
530  V2UPropType_Boolean, \
531  V2UPropAccess_RO) \
532  property( V2UKey_ProductName, \
533  "Product name", \
534  V2UPropType_String, \
535  V2UPropAccess_RO) \
536  property( V2UKey_TuneInterval, /* ms */\
537  "Tune interval", \
538  V2UPropType_Uint32, \
539  V2UPropAccess_RW) \
540  property( V2UKey_UserData, \
541  "User data", \
542  V2UPropType_UserData, \
543  V2UPropAccess_RW) \
544  property( V2UKey_SerialNumber, \
545  "Serial number", \
546  V2UPropType_String, \
547  V2UPropAccess_RO) \
548  property( V2UKey_InputSignalType, /* Since 3.23.7.3 */\
549  "Input signal type", \
550  V2UPropType_Uint32, \
551  V2UPropAccess_RO) \
552  property( V2UKey_DigitalModeDetect, /* Since 3.24.5, DVI2USB Duo */\
553  "Digital mode detection", \
554  V2UPropType_Enum, \
555  V2UPropAccess_RW) \
556  property( V2UKey_NoiseFilter, /* Since 3.24.6 */\
557  "Noise filter", \
558  V2UPropType_Enum, \
559  V2UPropAccess_RW) \
560  property( V2UKey_HSyncThreshold, /* Since 3.24.6 */\
561  "Hsync threshold", \
562  V2UPropType_Uint8, \
563  V2UPropAccess_RW) \
564  property( V2UKey_VSyncThreshold, /* Since 3.24.6 */\
565  "Vsync threshold", \
566  V2UPropType_Uint8, \
567  V2UPropAccess_RW) \
568  property( V2UKey_DeviceCaps, /* Since 3.24.6 */\
569  "Device capabilities", \
570  V2UPropType_Uint32, \
571  V2UPropAccess_RO) \
572  property( V2UKey_DirectShowDefaultBmp2, /* Since 3.24.9.4, Windows */\
573  "DS Default BMP", \
574  V2UPropType_String2, \
575  V2UPropAccess_RW) \
576  property( V2UKey_BusType, /* Since 3.24.9.5 */\
577  "Grabber bus type", \
578  V2UPropType_Enum, \
579  V2UPropAccess_RO) \
580 
581 /* Define V2UPropertyKey enum */
582 typedef enum v2u_property_key
583 {
584 #define V2U_PROPERTY_KEY_ENUM(key,name,type,access) key,
586 #undef V2U_PROPERTY_KEY_ENUM
587  V2UKey_Count /* Number of known properties */
589 
590 #define V2U_USERDATA_LEN 8
591 
592 typedef union v2u_property_value
593 {
611  char str[256];
617 
618 typedef struct v2u_ioctl_property
619 {
620  V2UPropertyKey key; /* IN property key */
621  V2UPropertyValue value; /* IN/OUT property value */
623 
624 /*
625  * V2U_GrabFrame
626  *
627  * Frame buffer.
628  */
629 typedef struct ioctl_grabframe
630 {
631 #define V2U_GrabFrame_Fields(pointer) \
632  pointer pixbuf; /* IN should be filled by user process */\
633  V2U_UINT32 pixbuflen; /* IN should be filled by user process */\
634  V2U_INT32 width; /* OUT width in pixels */\
635  V2U_INT32 height; /* OUT height in pixels */\
636  V2U_UINT32 bpp; /* IN pixel format */
637  V2U_GrabFrame_Fields(void*)
639 
640 typedef struct ioctl_grabframe2
641 {
642 #define V2U_GrabFrame2_Fields(pointer) \
643  pointer pixbuf; /* IN should be filled by user process */\
644  V2U_UINT32 pixbuflen; /* IN should be filled by user process */\
645  V2U_UINT32 palette; /* IN pixel format */\
646  V2URect crop; /* IN/OUT cropping area; all zeros = full frame */\
647  V2U_VideoMode mode; /* OUT VGA mode */\
648  V2U_UINT32 imagelen; /* OUT size of the image stored in pixbuf */\
649  V2U_INT32 retcode; /* OUT return/error code */
650  V2U_GrabFrame2_Fields(void*)
652 
653 /*
654  * Error codes
655  */
656 #define V2UERROR_OK 0 /* Success */
657 #define V2UERROR_FAULT 1 /* Unspecified error */
658 #define V2UERROR_INVALARG 2 /* Invalid argument */
659 #define V2UERROR_SMALLBUF 3 /* Insufficient buffer size */
660 #define V2UERROR_OUTOFMEMORY 4 /* Out of memory */
661 #define V2UERROR_NOSIGNAL 5 /* No signal detected */
662 #define V2UERROR_UNSUPPORTED 6 /* Unsupported video mode */
663 #define V2UERROR_TIMEOUT 7 /* grab timeout */
664 
665 /*
666  * The following flags can be OR'ed with V2U_GrabFrame::bpp or
667  * V2U_GrabFrame2::palette field. The flags are preserved on return.
668  *
669  * V2U_GRABFRAME_BOTTOM_UP_FLAG
670  * This flag requests the bitmap data to be sent in bottom-up format.
671  * By default, the bitmap data are stored in the top-down order.
672  *
673  * V2U_GRABFRAME_KEYFRAME_FLAG
674  * This flag only makes sense when the data are requested in compressed
675  * format (V2U_GRABFRAME_FORMAT_CRGB24 and such). If this flag is set, the
676  * driver updates and returns a full frame (i.e. keyframe).
677  */
678 #define V2U_GRABFRAME_RESERVED 0x0f000000 /* These are ignored */
679 #define V2U_GRABFRAME_FLAGS_MASK 0xf0000000 /* Bits reserved for flags */
680 #define V2U_GRABFRAME_BOTTOM_UP_FLAG 0x80000000 /* Invert order of lines */
681 #define V2U_GRABFRAME_KEYFRAME_FLAG 0x40000000 /* Full frame is requested */
682 #define V2U_GRABFRAME_ADDR_IS_PHYS 0x20000000 /* Buffer addr is physical */
683 #define V2U_GRABFRAME_DEINTERLACE 0x10000000 /* De-interlace image, if it is interlaced */
684 
685 /*
686  * Image rotation mode
687  *
688  * V2U_GRABFRAME_ROTATION_NONE
689  * No rotation, image is grabbed in its original orientation.
690  *
691  * V2U_GRABFRAME_ROTATION_LEFT90
692  * Grab the image rotated 90 degrees to the left with respect
693  * to its original orientation.
694  *
695  * V2U_GRABFRAME_ROTATION_RIGHT90
696  * Grab the image rotated 90 degrees to the right with respect
697  * to its original orientation.
698  *
699  * V2U_GRABFRAME_ROTATION_180
700  * Grab the image rotated 180 degrees with respect to its
701  * original orientation.
702  */
703 #define V2U_GRABFRAME_ROTATION_MASK 0x00300000 /* Bits reserved for mode */
704 #define V2U_GRABFRAME_ROTATION_NONE 0x00000000 /* No rotation */
705 #define V2U_GRABFRAME_ROTATION_LEFT90 0x00100000 /* 90 degrees to the left */
706 #define V2U_GRABFRAME_ROTATION_RIGHT90 0x00200000 /* 90 degrees to the right */
707 #define V2U_GRABFRAME_ROTATION_180 0x00300000 /* Rotation 180 degrees */
708 
709 /* If a valid algorithm code is set, the image will be scaled to
710  * width/height in V2U_GrabFrame or crop.width/crop.height in V2U_GrabFrame2.
711  * If no bits in V2U_GRABFRAME_SCALE_MASK are set, no scaling is performed.
712  * If an unknown algorithm code is specified, a default one will be used.
713  * Scaling works for the following capture formats:
714  *
715  * V2U_GRABFRAME_FORMAT_Y8
716  * V2U_GRABFRAME_FORMAT_RGB4
717  * V2U_GRABFRAME_FORMAT_RGB8
718  * V2U_GRABFRAME_FORMAT_RGB16
719  * V2U_GRABFRAME_FORMAT_BGR16
720  * V2U_GRABFRAME_FORMAT_RGB24
721  * V2U_GRABFRAME_FORMAT_ARGB32
722  * V2U_GRABFRAME_FORMAT_BGR24
723  * V2U_GRABFRAME_FORMAT_YUY2
724  * V2U_GRABFRAME_FORMAT_2VUY
725  * V2U_GRABFRAME_FORMAT_YV12
726  * V2U_GRABFRAME_FORMAT_I420
727  * V2U_GRABFRAME_FORMAT_NV12
728  *
729  * Scaling is available since version 3.10.9
730  *
731  * Note that V2U_GRABFRAME_SCALE_AVERAGE scale mode is EXPERIMENTAL and
732  * currently only works for RGB24 and BGR24 images.
733  */
734 #define V2U_GRABFRAME_SCALE_MASK 0x000F0000 /* Scale algorithm mask */
735 #define V2U_GRABFRAME_SCALE_NEAREST 0x00010000 /* Nearest neighbour */
736 #define V2U_GRABFRAME_SCALE_AVERAGE 0x00020000 /* Weighted average */
737 #define V2U_GRABFRAME_SCALE_FAST_BILINEAR 0x00030000 /* Fast bilinear */
738 #define V2U_GRABFRAME_SCALE_BILINEAR 0x00040000 /* Bilinear */
739 #define V2U_GRABFRAME_SCALE_BICUBIC 0x00050000 /* Bicubic */
740 #define V2U_GRABFRAME_SCALE_EXPERIMENTAL 0x00060000 /* Experimental */
741 #define V2U_GRABFRAME_SCALE_POINT 0x00070000 /* Nearest neighbour */
742 #define V2U_GRABFRAME_SCALE_AREA 0x00080000 /* Weighted average */
743 #define V2U_GRABFRAME_SCALE_BICUBLIN 0x00090000 /* Lum bicub,Chr bilinear*/
744 #define V2U_GRABFRAME_SCALE_SINC 0x000A0000 /* Sinc */
745 #define V2U_GRABFRAME_SCALE_LANCZOS 0x000B0000 /* Lanczos */
746 #define V2U_GRABFRAME_SCALE_SPLINE 0x000C0000 /* Natural bicubic spline*/
747 #define V2U_GRABFRAME_SCALE_HW 0x000D0000 /* Hardware provided */
748 #define V2U_GRABFRAME_SCALE_MAX_MODE 0x000D0000 /* Maximum valid mode */
749 
750 /* Bits that define image format */
751 #define V2U_GRABFRAME_FORMAT_MASK 0x0000ffff /* Image format mask */
752 #define V2U_GRABFRAME_FORMAT_RGB_MASK 0x0000001f /* Mask for RGB formats */
753 #define V2U_GRABFRAME_FORMAT_RGB4 0x00000004
754 #define V2U_GRABFRAME_FORMAT_RGB8 0x00000008 /* R2:G3:B3 */
755 #define V2U_GRABFRAME_FORMAT_RGB16 0x00000010
756 #define V2U_GRABFRAME_FORMAT_RGB24 0x00000018
757 #define V2U_GRABFRAME_FORMAT_YUY2 0x00000100 /* Same as YUV422 */
758 #define V2U_GRABFRAME_FORMAT_YV12 0x00000200
759 #define V2U_GRABFRAME_FORMAT_2VUY 0x00000300
760 #define V2U_GRABFRAME_FORMAT_BGR16 0x00000400
761 #define V2U_GRABFRAME_FORMAT_Y8 0x00000500
762 #define V2U_GRABFRAME_FORMAT_CRGB24 0x00000600 /* Compressed RGB24 */
763 #define V2U_GRABFRAME_FORMAT_CYUY2 0x00000700 /* Compressed YUY2 */
764 #define V2U_GRABFRAME_FORMAT_BGR24 0x00000800
765 #define V2U_GRABFRAME_FORMAT_CBGR24 0x00000900 /* Compressed BGR24 */
766 #define V2U_GRABFRAME_FORMAT_I420 0x00000A00 /* Same as YUV420P */
767 #define V2U_GRABFRAME_FORMAT_ARGB32 0x00000B00
768 #define V2U_GRABFRAME_FORMAT_NV12 0x00000C00
769 #define V2U_GRABFRAME_FORMAT_C2VUY 0x00000D00 /* Compressed 2VUY */
770 
771 /* Old flag names, defined here for backward compatibility */
772 #define V2U_GRABFRAME_PALETTE_MASK V2U_GRABFRAME_FORMAT_MASK
773 #define V2U_GRABFRAME_PALETTE_RGB_MASK V2U_GRABFRAME_FORMAT_RGB_MASK
774 #define V2U_GRABFRAME_PALETTE_RGB4 V2U_GRABFRAME_FORMAT_RGB4
775 #define V2U_GRABFRAME_PALETTE_RGB8 V2U_GRABFRAME_FORMAT_RGB8
776 #define V2U_GRABFRAME_PALETTE_RGB16 V2U_GRABFRAME_FORMAT_RGB16
777 #define V2U_GRABFRAME_PALETTE_RGB24 V2U_GRABFRAME_FORMAT_RGB24
778 #define V2U_GRABFRAME_PALETTE_ARGB32 V2U_GRABFRAME_FORMAT_ARGB32
779 #define V2U_GRABFRAME_PALETTE_YUY2 V2U_GRABFRAME_FORMAT_YUY2
780 #define V2U_GRABFRAME_PALETTE_YV12 V2U_GRABFRAME_FORMAT_YV12
781 #define V2U_GRABFRAME_PALETTE_I420 V2U_GRABFRAME_FORMAT_I420
782 #define V2U_GRABFRAME_PALETTE_2VUY V2U_GRABFRAME_FORMAT_2VUY
783 #define V2U_GRABFRAME_PALETTE_BGR16 V2U_GRABFRAME_FORMAT_BGR16
784 #define V2U_GRABFRAME_PALETTE_Y8 V2U_GRABFRAME_FORMAT_Y8
785 #define V2U_GRABFRAME_PALETTE_BGR24 V2U_GRABFRAME_FORMAT_BGR24
786 #define V2U_GRABFRAME_PALETTE_NV12 V2U_GRABFRAME_FORMAT_NV12
787 
788 #define V2U_GRABFRAME_FORMAT(p) ((p) & V2U_GRABFRAME_FORMAT_MASK)
789 
790 /* Macro to determine bpp (bits per pixel) for particular grab format */
791 #define V2UPALETTE_2_BPP(p) \
792  (((p) & V2U_GRABFRAME_FORMAT_RGB_MASK) ? \
793  ((V2U_UINT8)((p) & V2U_GRABFRAME_FORMAT_RGB_MASK)) : \
794  (((V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_BGR16) || \
795  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_YUY2) || \
796  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_2VUY) || \
797  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_CYUY2) || \
798  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_C2VUY)) ? 16 :\
799  (((V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_YV12) || \
800  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_NV12) || \
801  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_I420)) ? 12 : \
802  (((V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_Y8) || \
803  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_RGB8)) ? 8 : \
804  (((V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_CRGB24) || \
805  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_CBGR24) || \
806  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_BGR24)) ? 24 : \
807  ((V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_ARGB32) ? 32 : 0))))))
808 
809 /* Macro to determine whether frame data is compressed */
810 #define V2UPALETTE_COMPRESSED(p) \
811  ((V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_CRGB24) || \
812  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_CBGR24) || \
813  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_CYUY2) || \
814  (V2U_GRABFRAME_FORMAT(p) == V2U_GRABFRAME_FORMAT_C2VUY))
815 
816 /*
817  * Restore previous packing
818  */
819 #ifdef _WIN32
820 # include <poppack.h>
821 #endif
822 
823 #endif /* _VGA2USB_DEFS_H_ */
uint64_t V2U_UINT64
Definition: v2u_defs.h:66
V2U_INT64 int64
Definition: v2u_defs.h:600
#define V2U_GrabFrame_Fields(pointer)
Definition: v2u_defs.h:631
struct ioctl_setparams V2U_GrabParameters
#define V2U_PROPERTY_KEY_ENUM(key, name, type, access)
Definition: v2u_defs.h:584
V2U_UINT8 blob[256]
Definition: v2u_defs.h:614
struct v2u_rect V2URect
struct v2u_ioctl_property V2U_Property
v2u_digital_mode_detect
Definition: v2u_defs.h:368
union v2u_property_value V2UPropertyValue
struct ioctl_sendps2 V2U_SendPS2
V2U_INT32 vshift
Definition: v2u_defs.h:141
V2UAdjRange adj_range
Definition: v2u_defs.h:607
V2U_INT16 gain_max
Definition: v2u_defs.h:295
struct custom_videomode V2UVGAMode
V2U_UINT8 gain_g
Definition: v2u_defs.h:135
enum v2u_property_access V2UPropertyAccess
V2U_INT32 x
Definition: v2u_defs.h:87
v2u_bus_type
Definition: v2u_defs.h:389
V2U_INT16 offset_min
Definition: v2u_defs.h:292
V2U_INT16 gain_min
Definition: v2u_defs.h:294
struct vesa_videomode V2UVideoModeDescr
V2U_UINT16 V2U_UCS2
Definition: v2u_defs.h:70
V2U_INT16 vshift_max
Definition: v2u_defs.h:297
V2U_INT32 V2U_BOOL
Definition: v2u_defs.h:71
V2U_INT16 phase_max
Definition: v2u_defs.h:291
V2U_INT32 int32
Definition: v2u_defs.h:598
V2U_INT16 hshift_min
Definition: v2u_defs.h:288
V2U_UCS2 * buffer
Definition: v2u_defs.h:95
int32_t V2U_INT32
Definition: v2u_defs.h:63
#define V2U_PACKED
Definition: v2u_defs.h:34
struct ioctl_grabframe2 V2U_GrabFrame2
uint16_t V2U_UINT16
Definition: v2u_defs.h:62
struct v2u_size V2USize
V2U_INT32 vfreq
Definition: v2u_defs.h:112
V2U_UINT32 len
Definition: v2u_defs.h:96
v2u_noise_filter
Definition: v2u_defs.h:377
V2UPropertyValue value
Definition: v2u_defs.h:621
V2U_UINT8 offset_r
Definition: v2u_defs.h:137
V2U_INT16 hshift_max
Definition: v2u_defs.h:289
struct ioctl_videomode V2U_VideoMode
#define V2U_GrabFrame2_Fields(pointer)
Definition: v2u_defs.h:642
V2U_UINT32 grab_flags_mask
Definition: v2u_defs.h:147
V2U_INT32 width
Definition: v2u_defs.h:81
V2U_INT32 idx
Definition: v2u_defs.h:339
V2U_UINT16 HorFrontPorch
Definition: v2u_defs.h:307
V2U_INT32 hshift
Definition: v2u_defs.h:129
v2u_property_access
Definition: v2u_defs.h:421
#define V2U_USERDATA_LEN
Definition: v2u_defs.h:590
uint32_t V2U_UINT32
Definition: v2u_defs.h:64
V2U_UINT16 uint16
Definition: v2u_defs.h:597
V2U_UINT16 VerBackPorch
Definition: v2u_defs.h:313
V2UStrUcs2 wstr
Definition: v2u_defs.h:606
struct ioctl_getsn V2U_GetSN
V2U_UINT8 phase
Definition: v2u_defs.h:133
V2U_UINT8 offset_b
Definition: v2u_defs.h:139
V2U_UINT32 Type
Definition: v2u_defs.h:314
V2U_UINT8 userdata[V2U_USERDATA_LEN]
Definition: v2u_defs.h:615
V2U_INT32 height
Definition: v2u_defs.h:111
V2U_UINT8 V2U_BYTE
Definition: v2u_defs.h:69
V2U_INT32 micro
Definition: v2u_defs.h:347
V2U_INT16 pll_min
Definition: v2u_defs.h:298
V2U_UINT32 valid_flags
Definition: v2u_defs.h:287
V2U_INT32 width
Definition: v2u_defs.h:89
V2U_UINT8 offset_g
Definition: v2u_defs.h:138
enum v2u_scale_mode V2UScaleMode
#define V2U_SN_BUFSIZ
Definition: v2u_defs.h:204
V2U_UINT16 VerSyncTime
Definition: v2u_defs.h:312
v2u_scale_mode
Definition: v2u_defs.h:244
#define V2U_PROPERTY_LIST(property)
Definition: v2u_defs.h:459
const V2UVideoModeDescr * V2UVideoModeDescrCPtr
Definition: v2u_defs.h:327
enum v2u_product_type V2UProductType
enum v2u_property_type V2UPropertyType
char sn[V2U_SN_BUFSIZ]
Definition: v2u_defs.h:208
V2UVersion version
Definition: v2u_defs.h:608
struct ioctl_grabframe V2U_GrabFrame
V2U_UINT16 HorAddrTime
Definition: v2u_defs.h:306
V2U_UINT16 HorSyncTime
Definition: v2u_defs.h:308
V2UVideoModeDescr vesa_mode
Definition: v2u_defs.h:340
V2U_INT16 phase_min
Definition: v2u_defs.h:290
V2U_INT32 major
Definition: v2u_defs.h:345
enum v2u_property_key V2UPropertyKey
V2U_INT32 nano
Definition: v2u_defs.h:348
struct v2u_str_ucs2 V2UStrUcs2
V2U_INT16 vshift_min
Definition: v2u_defs.h:296
V2U_UINT32 maxlen
Definition: v2u_defs.h:97
V2UVGAMode vgamode
Definition: v2u_defs.h:609
V2U_BOOL boolean
Definition: v2u_defs.h:602
V2U_INT32 width
Definition: v2u_defs.h:110
V2U_UINT16 HorBackPorch
Definition: v2u_defs.h:309
V2U_UINT16 VerFrontPorch
Definition: v2u_defs.h:311
short addr
Definition: v2u_defs.h:190
V2U_INT16 offset_max
Definition: v2u_defs.h:293
V2U_INT64 V2U_TIME
Definition: v2u_defs.h:73
V2UVideoModeDescr vesa_mode
Definition: v2u_defs.h:610
V2U_UCS2 str2[128]
Definition: v2u_defs.h:612
int16_t V2U_INT16
Definition: v2u_defs.h:61
enum v2u_noise_filter V2UNoiseFilter
V2U_UINT8 edid[128]
Definition: v2u_defs.h:613
V2U_UINT8 uint8
Definition: v2u_defs.h:595
char str[256]
Definition: v2u_defs.h:611
int8_t V2U_INT8
Definition: v2u_defs.h:59
V2U_UINT8 gain_r
Definition: v2u_defs.h:134
unsigned char buf[64]
Definition: v2u_defs.h:192
V2U_UINT32 uint32
Definition: v2u_defs.h:599
V2U_UINT16 VerAddrTime
Definition: v2u_defs.h:310
V2U_INT32 minor
Definition: v2u_defs.h:346
V2U_INT16 pll_max
Definition: v2u_defs.h:299
V2UProductType product_type
Definition: v2u_defs.h:603
V2U_INT32 y
Definition: v2u_defs.h:88
unsigned char BYTE
Definition: ATC3DGm.h:449
V2U_UINT32 VerFrequency
Definition: v2u_defs.h:305
int64_t V2U_INT64
Definition: v2u_defs.h:65
V2U_INT32 height
Definition: v2u_defs.h:82
V2U_UINT32 flags
Definition: v2u_defs.h:286
enum v2u_digital_mode_detect V2UDigitalModeDetect
V2U_UINT8 reserved
Definition: v2u_defs.h:140
V2U_INT32 height
Definition: v2u_defs.h:90
V2U_UINT32 flags
Definition: v2u_defs.h:125
v2u_product_type
Definition: v2u_defs.h:211
V2U_UINT64 uint64
Definition: v2u_defs.h:601
enum v2u_bus_type V2UBusType
enum v2u_rotation_mode V2URotationMode
v2u_property_key
Definition: v2u_defs.h:582
V2UPropertyKey key
Definition: v2u_defs.h:620
V2U_UINT32 grab_flags
Definition: v2u_defs.h:146
v2u_rotation_mode
Definition: v2u_defs.h:269
v2u_property_type
Definition: v2u_defs.h:429
V2U_UINT8 gain_b
Definition: v2u_defs.h:136
struct v2u_adjustment_range V2UAdjRange
uint8_t V2U_UINT8
Definition: v2u_defs.h:60
V2U_INT32 pllshift
Definition: v2u_defs.h:145
V2U_INT16 int16
Definition: v2u_defs.h:596
struct v2u_version V2UVersion