r668: Configure.in and autogen.sh cleanup based on ideas by giskard.
[cinelerra_cv.git] / cinelerra / videodev2.h
blobafa10b8adfb35d09ef1bb1674170949a1763c985
1 /*
2 * Video for Linux Two
4 * Header file for V4L2 drivers and applications.
6 * Author: Bill Dirks <bdirks@pacbell.net>
7 */
9 #ifndef __LINUX_VIDEODEV_H
10 #define __LINUX_VIDEODEV_H
13 #define V4L2_MAJOR_VERSION 0
14 #define V4L2_MINOR_VERSION 20
15 #include "videodevfix.h"
18 * M I S C E L L A N E O U S
21 /* Four-character-code (int32_tCC) */
22 #define fourcc(a,b,c,d)\
23 (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))
25 /* Open flag for non-capturing opens on capture devices */
26 #define O_NONCAP O_TRUNC
27 #define O_NOIO O_TRUNC
29 /* Timestamp data type, 64-bit signed integer */
30 /* Should be removed from here when UST is added to kernel */
31 #ifndef STAMP_T
32 #define STAMP_T
33 typedef __s64 stamp_t;
34 #endif
37 * D R I V E R C A P A B I L I T I E S
39 struct v4l2_capability
41 char name[32]; /* Descriptive, and unique */
42 int type; /* Device type, see below */
43 int inputs; /* Num video inputs */
44 int outputs; /* Num video outputs */
45 int audios; /* Num audio devices */
46 int maxwidth;
47 int maxheight;
48 int minwidth;
49 int minheight;
50 int maxframerate;
51 __u32 flags; /* Feature flags, see below */
52 __u32 reserved[4];
54 /* Values for 'type' field */
55 #define V4L2_TYPE_CAPTURE 0 /* Is a video capture device */
56 #define V4L2_TYPE_CODEC 1 /* Is a CODEC device */
57 #define V4L2_TYPE_OUTPUT 2 /* Is a video output device */
58 #define V4L2_TYPE_FX 3 /* Is a video effects device */
59 #define V4L2_TYPE_VBI 4 /* Is a VBI capture device */
60 #define V4L2_TYPE_VTR 5 /* Is a tape recorder controller */
61 #define V4L2_TYPE_VTX 6 /* Is a teletext device */
62 #define V4L2_TYPE_RADIO 7 /* Is a radio device */
63 #define V4L2_TYPE_PRIVATE 1000 /* Start of driver private types */
64 /* Flags for 'flags' field */
65 #define V4L2_FLAG_READ 0x00001 /* Can capture via read() call */
66 #define V4L2_FLAG_WRITE 0x00002 /* Can accept data via write() */
67 #define V4L2_FLAG_STREAMING 0x00004 /* Can capture streaming video */
68 #define V4L2_FLAG_PREVIEW 0x00008 /* Can do automatic preview */
69 #define V4L2_FLAG_SELECT 0x00010 /* Supports the select() call */
70 #define V4L2_FLAG_TUNER 0x00020 /* Can tune */
71 #define V4L2_FLAG_MONOCHROME 0x00040 /* Monochrome only */
72 #define V4L2_FLAG_DATA_SERVICE 0x00080 /* Has a related data service dev. */
76 * V I D E O I M A G E F O R M A T
78 struct v4l2_pix_format
80 __u32 width;
81 __u32 height;
82 __u32 depth;
83 __u32 pixelformat;
84 __u32 flags;
85 __u32 bytesperline; /* only used when there are pad bytes */
86 __u32 sizeimage;
87 __u32 priv; /* private data, depends on pixelformat */
89 /* Pixel format int32_tCC depth Description */
90 #define V4L2_PIX_FMT_RGB332 fourcc('R','G','B','1') /* 8 RGB-3-3-2 */
91 #define V4L2_PIX_FMT_RGB555 fourcc('R','G','B','O') /* 16 RGB-5-5-5 */
92 #define V4L2_PIX_FMT_RGB565 fourcc('R','G','B','P') /* 16 RGB-5-6-5 */
93 #define V4L2_PIX_FMT_BGR24 fourcc('B','G','R','3') /* 24 BGR-8-8-8 */
94 #define V4L2_PIX_FMT_RGB24 fourcc('R','G','B','3') /* 24 RGB-8-8-8 */
95 #define V4L2_PIX_FMT_BGR32 fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */
96 #define V4L2_PIX_FMT_RGB32 fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */
97 #define V4L2_PIX_FMT_GREY fourcc('G','R','E','Y') /* 8 Greyscale */
98 #define V4L2_PIX_FMT_YVU410 fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */
99 #define V4L2_PIX_FMT_YVU420 fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */
100 #define V4L2_PIX_FMT_YUYV fourcc('Y','U','Y','V') /* 16 YUV 4:2:2 */
101 #define V4L2_PIX_FMT_UYVY fourcc('U','Y','V','Y') /* 16 YUV 4:2:2 */
102 #define V4L2_PIX_FMT_YVU422P fourcc('4','2','2','P') /* 16 YVU422 planar */
103 #define V4L2_PIX_FMT_YVU411P fourcc('4','1','1','P') /* 16 YVU411 planar */
105 /* The following formats are not defined in the V4L2 specification */
106 #define V4L2_PIX_FMT_YUV410 fourcc('Y','U','V','9') /* 9 YUV 4:1:0 */
107 #define V4L2_PIX_FMT_YUV420 fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */
108 #define V4L2_PIX_FMT_YYUV fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */
109 #define V4L2_PIX_FMT_HI240 fourcc('H','I','2','4') /* 8 8-bit color */
112 /* Flags */
113 #define V4L2_FMT_FLAG_COMPRESSED 0x0001 /* Compressed format */
114 #define V4L2_FMT_FLAG_BYTESPERLINE 0x0002 /* bytesperline field valid */
115 #define V4L2_FMT_FLAG_INTERLACED 0x0004 /* Image is interlaced */
116 #define V4L2_FMT_FLAG_TOPFIELD 0x0008 /* is a top field only */
117 #define V4L2_FMT_FLAG_BOTFIELD 0x0010 /* is a bottom field only */
118 #define V4L2_FMT_FLAG_ODDFIELD V4L2_FMT_FLAG_TOPFIELD
119 #define V4L2_FMT_FLAG_EVENFIELD V4L2_FMT_FLAG_BOTFIELD
120 #define V4L2_FMT_FLAG_COMBINED V4L2_FMT_FLAG_INTERLACED
121 #define V4L2_FMT_CS_field 0xF000 /* Color space field mask */
122 #define V4L2_FMT_CS_601YUV 0x1000 /* ITU YCrCb color space */
123 #define V4L2_FMT_FLAG_SWCONVERSION 0x0800 /* used only in format enum. */
124 /* SWCONVERSION indicates the format is not natively supported by the */
125 /* driver and the driver uses software conversion to support it */
129 * F O R M A T E N U M E R A T I O N
131 struct v4l2_fmtdesc
133 int index; /* Format number */
134 char description[32]; /* Description string */
135 __u32 pixelformat; /* Format fourcc */
136 __u32 flags; /* Format flags */
137 __u32 depth; /* Bits per pixel */
138 __u32 reserved[2];
141 struct v4l2_cvtdesc
143 int index;
144 struct
146 __u32 pixelformat;
147 __u32 flags;
148 __u32 depth;
149 __u32 reserved[2];
150 } in, out;
153 struct v4l2_fxdesc
155 int index;
156 char name[32];
157 __u32 flags;
158 __u32 inputs;
159 __u32 controls;
160 __u32 reserved[2];
165 * T I M E C O D E
167 struct v4l2_timecode
169 __u8 frames;
170 __u8 seconds;
171 __u8 minutes;
172 __u8 hours;
173 __u8 userbits[4];
174 __u32 flags;
175 __u32 type;
177 /* Type */
178 #define V4L2_TC_TYPE_24FPS 1
179 #define V4L2_TC_TYPE_25FPS 2
180 #define V4L2_TC_TYPE_30FPS 3
181 #define V4L2_TC_TYPE_50FPS 4
182 #define V4L2_TC_TYPE_60FPS 5
185 /* Flags */
186 #define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */
187 #define V4L2_TC_FLAG_COLORFRAME 0x0002
188 #define V4L2_TC_USERBITS_field 0x000C
189 #define V4L2_TC_USERBITS_USERDEFINED 0x0000
190 #define V4L2_TC_USERBITS_8BITCHARS 0x0008
191 /* The above is based on SMPTE timecodes */
195 * C O M P R E S S I O N P A R A M E T E R S
197 struct v4l2_compression
199 int quality;
200 int keyframerate;
201 int pframerate;
202 __u32 reserved[5];
207 * M E M O R Y - M A P P I N G B U F F E R S
209 struct v4l2_requestbuffers
211 int count;
212 __u32 type;
213 __u32 reserved[2];
215 struct v4l2_buffer
217 int index;
218 __u32 type;
219 __u32 offset;
220 __u32 length;
221 __u32 bytesused;
222 __u32 flags;
223 stamp_t timestamp;
224 struct v4l2_timecode timecode;
225 __u32 sequence;
226 __u32 reserved[3];
228 /* Buffer type codes and flags for 'type' field */
229 #define V4L2_BUF_TYPE_field 0x00001FFF /* Type field mask */
230 #define V4L2_BUF_TYPE_CAPTURE 0x00000001
231 #define V4L2_BUF_TYPE_CODECIN 0x00000002
232 #define V4L2_BUF_TYPE_CODECOUT 0x00000003
233 #define V4L2_BUF_TYPE_EFFECTSIN 0x00000004
234 #define V4L2_BUF_TYPE_EFFECTSIN2 0x00000005
235 #define V4L2_BUF_TYPE_EFFECTSOUT 0x00000006
236 #define V4L2_BUF_TYPE_VIDEOOUT 0x00000007
237 #define V4L2_BUF_TYPE_FXCONTROL 0x00000008
239 /* Starting value of driver private buffer types */
240 #define V4L2_BUF_TYPE_PRIVATE 0x00001000
242 #define V4L2_BUF_ATTR_DEVICEMEM 0x00010000 /* Buffer is on device (flag) */
244 /* Flags used only in VIDIOC_REQBUFS */
245 #define V4L2_BUF_REQ_field 0xF0000000
246 #define V4L2_BUF_REQ_CONTIG 0x10000000 /* Map all buffers in one
247 contiguous mmap(). This flag
248 only used in VIDIOC_REQBUFS */
250 /* Flags for 'flags' field */
251 #define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */
252 #define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */
253 #define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */
254 #define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */
255 #define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */
256 #define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */
257 #define V4L2_BUF_FLAG_TOPFIELD 0x0040 /* Image is a top field only */
258 #define V4L2_BUF_FLAG_BOTFIELD 0x0080 /* Image is a bottom field only */
259 #define V4L2_BUF_FLAG_ODDFIELD V4L2_BUF_FLAG_TOPFIELD
260 #define V4L2_BUF_FLAG_EVENFIELD V4L2_BUF_FLAG_BOTFIELD
261 #define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */
264 * O V E R L A Y P R E V I E W
266 struct v4l2_framebuffer
268 __u32 capability;
269 __u32 flags;
270 void *base[3];
271 struct v4l2_pix_format fmt;
273 /* Flags for the 'capability' field. Read only */
274 #define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001
275 #define V4L2_FBUF_CAP_CHROMAKEY 0x0002
276 #define V4L2_FBUF_CAP_CLIPPING 0x0004
277 #define V4L2_FBUF_CAP_SCALEUP 0x0008
278 #define V4L2_FBUF_CAP_SCALEDOWN 0x0010
279 #define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0020
280 /* Flags for the 'flags' field. */
281 #define V4L2_FBUF_FLAG_PRIMARY 0x0001
282 #define V4L2_FBUF_FLAG_OVERLAY 0x0002
283 #define V4L2_FBUF_FLAG_CHROMAKEY 0x0004
285 struct v4l2_clip
287 int x;
288 int y;
289 int width;
290 int height;
291 struct v4l2_clip *next;
293 struct v4l2_window
295 int x;
296 int y;
297 int width;
298 int height;
299 __u32 chromakey;
300 struct v4l2_clip *clips;
301 int clipcount;
302 void *bitmap;
307 * D E V I C E P E R F O R M A N C E
309 struct v4l2_performance
311 int frames;
312 int framesdropped;
313 __u64 bytesin;
314 __u64 bytesout;
315 __u32 reserved[4];
319 * C A P T U R E P A R A M E T E R S
321 struct v4l2_captureparm
323 __u32 capability; /* Supported modes */
324 __u32 capturemode; /* Current mode */
325 unsigned long timeperframe; /* Time per frame in .1us units */
326 __u32 extendedmode; /* Driver-specific extensions */
327 __u32 reserved[4];
329 /* Flags for 'capability' and 'capturemode' fields */
330 #define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */
331 //#define V4L2_MODE_VFLIP 0x0002 /* Flip image vertically */
332 //#define V4L2_MODE_HFLIP 0x0004 /* Flip image horizontally */
333 #define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */
335 struct v4l2_outputparm
337 __u32 capability; /* Supported modes */
338 __u32 outputmode; /* Current mode */
339 unsigned long timeperframe; /* Time per frame in .1us units */
340 __u32 extendedmode; /* Driver-specific extensions */
341 __u32 reserved[4];
345 * I N P U T I M A G E C R O P P I N G
347 struct v4l2_cropcap
349 __u32 capability;
350 int min_x;
351 int min_y;
352 int max_x;
353 int max_y;
354 int default_left;
355 int default_top;
356 int default_right;
357 int default_bottom;
358 __u32 reserved[2];
360 struct v4l2_crop
362 int left;
363 int top;
364 int right;
365 int bottom;
366 __u32 reserved;
370 * D I G I T A L Z O O M
372 struct v4l2_zoomcap
374 __u32 capability;
375 __u32 maxwidth;
376 __u32 maxheight;
377 __u32 minwidth;
378 __u32 minheight;
379 __u32 reserved[2];
381 /* Flags for the capability field */
382 #define V4L2_ZOOM_NONCAP 0x0001
383 #define V4L2_ZOOM_WHILESTREAMING 0x0002
385 struct v4l2_zoom
387 __u32 x;
388 __u32 y;
389 __u32 width;
390 __u32 height;
391 __u32 reserved;
396 * A N A L O G V I D E O S T A N D A R D
398 struct v4l2_standard
400 __u8 name[24];
401 struct {
402 __u32 numerator;
403 __u32 denominator; /* >= 1 */
404 } framerate; /* Frames, not fields */
405 __u32 framelines;
406 __u32 reserved1;
407 __u32 colorstandard;
408 union {
409 struct {
410 __u32 colorsubcarrier; /* Hz */
411 } pal;
412 struct {
413 __u32 colorsubcarrier; /* Hz */
414 } ntsc;
415 struct {
416 __u32 f0b; /* Hz (blue) */
417 __u32 f0r; /* Hz (red) */
418 } secam;
419 __u8 reserved[12];
420 } colorstandard_data;
421 __u32 transmission; /* Bit field. Must be zero for
422 non-modulators/demodulators. */
423 __u32 reserved2; /* Must be set to zero */
426 /* Values for the 'colorstandard' field */
427 #define V4L2_COLOR_STD_PAL 1
428 #define V4L2_COLOR_STD_NTSC 2
429 #define V4L2_COLOR_STD_SECAM 3
431 /* Values for the color subcarrier fields */
432 #define V4L2_COLOR_SUBC_PAL 4433619 /* PAL BGHI, NTSC-44 */
433 #define V4L2_COLOR_SUBC_PAL_M 3575611 /* PAL M (Brazil) */
434 #define V4L2_COLOR_SUBC_PAL_N 3582056 /* PAL N */
435 #define V4L2_COLOR_SUBC_NTSC 3579545 /* NTSC M, NTSC-Japan */
436 #define V4L2_COLOR_SUBC_SECAMB 4250000 /* SECAM B - Y carrier */
437 #define V4L2_COLOR_SUBC_SECAMR 4406250 /* SECAM R - Y carrier */
439 /* Flags for the 'transmission' field */
440 #define V4L2_TRANSM_STD_B (1<<1)
441 #define V4L2_TRANSM_STD_D (1<<3)
442 #define V4L2_TRANSM_STD_G (1<<6)
443 #define V4L2_TRANSM_STD_H (1<<7)
444 #define V4L2_TRANSM_STD_I (1<<8)
445 #define V4L2_TRANSM_STD_K (1<<10)
446 #define V4L2_TRANSM_STD_K1 (1<<11)
447 #define V4L2_TRANSM_STD_L (1<<12)
448 #define V4L2_TRANSM_STD_M (1<<13)
449 #define V4L2_TRANSM_STD_N (1<<14)
452 /* Used in the VIDIOC_ENUMSTD ioctl for querying supported standards */
453 struct v4l2_enumstd
455 int index;
456 struct v4l2_standard std;
457 __u32 inputs; /* set of inputs that */
458 /* support this standard */
459 __u32 outputs; /* set of outputs that */
460 /* support this standard */
461 __u32 reserved[2];
466 * V I D E O I N P U T S
468 struct v4l2_input
470 int index; /* Which input */
471 char name[32]; /* Label */
472 int type; /* Type of input */
473 __u32 capability; /* Capability flags */
474 int assoc_audio; /* Associated audio input */
475 __u32 reserved[4];
477 /* Values for the 'type' field */
478 #define V4L2_INPUT_TYPE_TUNER 1
479 #define V4L2_INPUT_TYPE_CAMERA 2
481 /* Flags for the 'capability' field */
482 #define V4L2_INPUT_CAP_AUDIO 0x0001 /* assoc_audio */
486 * V I D E O O U T P U T S
488 struct v4l2_output
490 int index; /* Which output */
491 char name[32]; /* Label */
492 int type; /* Type of output */
493 __u32 capability; /* Capability flags */
494 int assoc_audio; /* Associated audio */
495 __u32 reserved[4];
497 /* Values for the 'type' field */
498 #define V4L2_OUTPUT_TYPE_MODULATOR 1
499 #define V4L2_OUTPUT_TYPE_ANALOG 2
500 #define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
502 /* Flags for the 'capability' field */
503 #define V4L2_OUTPUT_CAP_AUDIO 0x0001 /* assoc_audio */
507 * C O N T R O L S
509 struct v4l2_control
511 __u32 id;
512 int value;
515 /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
516 struct v4l2_queryctrl
518 __u32 id;
519 __u8 name[32]; /* Whatever */
520 int minimum; /* Note signedness */
521 int maximum;
522 unsigned int step;
523 int default_value;
524 __u32 type;
525 __u32 flags;
526 __u32 category; /* Automatically filled in by V4L2 */
527 __u8 group[32]; /* for pre-defined controls */
528 __u32 reserved[2];
531 /* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
532 struct v4l2_querymenu
534 __u32 id;
535 int index;
536 __u8 name[32]; /* Whatever */
537 int reserved;
540 /* Used in V4L2_BUF_TYPE_FXCONTROL buffers */
541 struct v4l2_fxcontrol
543 __u32 id;
544 __u32 value;
547 /* Control types */
548 #define V4L2_CTRL_TYPE_INTEGER 0
549 #define V4L2_CTRL_TYPE_BOOLEAN 1
550 #define V4L2_CTRL_TYPE_MENU 2
551 #define V4L2_CTRL_TYPE_BUTTON 3
553 /* Control flags */
554 #define V4L2_CTRL_FLAG_DISABLED 0x0001
555 #define V4L2_CTRL_FLAG_GRABBED 0x0002
557 /* Control categories */
558 #define V4L2_CTRL_CAT_VIDEO 1 /* "Video" */
559 #define V4L2_CTRL_CAT_AUDIO 2 /* "Audio" */
560 #define V4L2_CTRL_CAT_EFFECT 3 /* "Effect" */
562 /* Control IDs defined by V4L2 */
563 #define V4L2_CID_BASE 0x00980900
564 /* IDs reserved for driver specific controls */
565 #define V4L2_CID_PRIVATE_BASE 0x08000000
566 /* IDs reserved for effect-specific controls on effects devices */
567 #define V4L2_CID_EFFECT_BASE 0x0A00B000
569 #define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0)
570 #define V4L2_CID_CONTRAST (V4L2_CID_BASE+1)
571 #define V4L2_CID_SATURATION (V4L2_CID_BASE+2)
572 #define V4L2_CID_HUE (V4L2_CID_BASE+3)
573 #define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5)
574 #define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6)
575 #define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7)
576 #define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8)
577 #define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9)
578 #define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10)
579 #define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11)
580 #define V4l2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12)
581 #define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13)
582 #define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14)
583 #define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15)
584 #define V4L2_CID_GAMMA (V4L2_CID_BASE+16)
585 #define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */
586 #define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17)
587 #define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18)
588 #define V4L2_CID_GAIN (V4L2_CID_BASE+19)
589 #define V4L2_CID_HFLIP (V4L2_CID_BASE+20)
590 #define V4L2_CID_VFLIP (V4L2_CID_BASE+21)
591 #define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
592 #define V4L2_CID_VCENTER (V4l2_CID_BASE+23)
593 #define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */
594 /* Remember to change fill_ctrl_category() in videodev.c */
597 * T U N I N G
599 struct v4l2_tuner
601 int input;
602 char name[32];
603 struct v4l2_standard std;
604 __u32 capability;
605 __u32 rangelow;
606 __u32 rangehigh;
607 __u32 rxsubchans;
608 __u32 audmode;
609 int signal;
610 int afc;
611 __u32 reserved[4];
613 struct v4l2_modulator
615 int output;
616 char name[32];
617 struct v4l2_standard std;
618 __u32 capability;
619 __u32 rangelow;
620 __u32 rangehigh;
621 __u32 txsubchans;
622 __u32 reserved[4];
624 /* Flags for the 'capability' field */
625 #define V4L2_TUNER_CAP_LOW 0x0001
626 #define V4L2_TUNER_CAP_NORM 0x0002
627 #define V4L2_TUNER_CAP_STEREO 0x0010
628 #define V4L2_TUNER_CAP_LANG2 0x0020
629 #define V4L2_TUNER_CAP_SAP 0x0020
630 #define V4L2_TUNER_CAP_LANG1 0x0040
632 /* Flags for the 'rxsubchans' field */
633 #define V4L2_TUNER_SUB_MONO 0x0001
634 #define V4L2_TUNER_SUB_STEREO 0x0002
635 #define V4L2_TUNER_SUB_LANG2 0x0004
636 #define V4L2_TUNER_SUB_SAP 0x0004
637 #define V4L2_TUNER_SUB_LANG1 0x0008
639 /* Values for the 'audmode' field */
640 #define V4L2_TUNER_MODE_MONO 0x0000
641 #define V4L2_TUNER_MODE_STEREO 0x0001
642 #define V4L2_TUNER_MODE_LANG2 0x0002
643 #define V4L2_TUNER_MODE_SAP 0x0002
644 #define V4L2_TUNER_MODE_LANG1 0x0003
646 struct v4l2_frequency
648 int port;
649 __u32 frequency;
650 __u32 reserved[2];
654 * A U D I O
656 struct v4l2_audio
658 int audio;
659 char name[32];
660 __u32 capability;
661 __u32 mode;
662 __u32 reserved[2];
664 /* Flags for the 'capability' field */
665 #define V4L2_AUDCAP_EFFECTS 0x0020
666 #define V4L2_AUDCAP_LOUDNESS 0x0040
667 #define V4L2_AUDCAP_AVL 0x0080
669 /* Flags for the 'mode' field */
670 #define V4L2_AUDMODE_LOUDNESS 0x00002
671 #define V4L2_AUDMODE_AVL 0x00004
672 #define V4L2_AUDMODE_STEREO_field 0x0FF00
673 #define V4L2_AUDMODE_STEREO_LINEAR 0x00100
674 #define V4L2_AUDMODE_STEREO_PSEUDO 0x00200
675 #define V4L2_AUDMODE_STEREO_SPATIAL30 0x00300
676 #define V4L2_AUDMODE_STEREO_SPATIAL50 0x00400
678 struct v4l2_audioout
680 int audio;
681 char name[32];
682 __u32 capability;
683 __u32 mode;
684 __u32 reserved[2];
688 * D A T A S E R V I C E S ( V B I )
691 struct v4l2_vbi_format
693 __u32 sampling_rate; /* in 1 Hz */
694 __u32 reserved1; /* must be zero */
695 __u32 samples_per_line;
696 __u32 sample_format; /* V4L2_VBI_SF_* */
697 __s32 start[2];
698 __u32 count[2];
699 __u32 flags; /* V4L2_VBI_* */
700 __u32 reserved2; /* must be zero */
703 /* VBI sampling formats */
704 #define V4L2_VBI_SF_UBYTE 1
706 /* VBI flags */
707 #define V4L2_VBI_UNSYNC (1<< 0)
708 #define V4L2_VBI_INTERLACED (1<< 1)
712 * A G G R E G A T E S T R U C T U R E S
715 /* Stream data format
717 struct v4l2_format
719 __u32 type;
720 union
722 struct v4l2_pix_format pix; /* image format */
723 struct v4l2_vbi_format vbi; /* VBI data */
724 /* add more */
725 __u8 raw_data[200]; /* user-defined */
726 } fmt;
730 /* Stream type-dependent parameters
732 struct v4l2_streamparm
734 __u32 type;
735 union
737 struct v4l2_captureparm capture;
738 struct v4l2_outputparm output;
739 /* add more */
740 __u8 raw_data[200]; /* user-defined */
741 } parm;
747 * I O C T L C O D E S F O R V I D E O D E V I C E S
750 #define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability)
751 #define VIDIOC_RESERVED _IO ('V', 1)
752 #define VIDIOC_ENUM_PIXFMT _IOWR ('V', 2, struct v4l2_fmtdesc)
753 #define VIDIOC_ENUM_FBUFFMT _IOWR ('V', 3, struct v4l2_fmtdesc)
754 #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format)
755 #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format)
756 #define VIDIOC_G_COMP _IOR ('V', 6, struct v4l2_compression)
757 #define VIDIOC_S_COMP _IOW ('V', 7, struct v4l2_compression)
758 #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers)
759 #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer)
760 #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer)
761 #define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer)
762 #define VIDIOC_G_WIN _IOR ('V', 12, struct v4l2_window)
763 #define VIDIOC_S_WIN _IOW ('V', 13, struct v4l2_window)
764 #define VIDIOC_PREVIEW _IOWR ('V', 14, int)
765 #define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer)
766 #define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer)
767 #define VIDIOC_STREAMON _IOW ('V', 18, int)
768 #define VIDIOC_STREAMOFF _IOW ('V', 19, int)
769 #define VIDIOC_G_PERF _IOR ('V', 20, struct v4l2_performance)
770 #define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm)
771 #define VIDIOC_S_PARM _IOW ('V', 22, struct v4l2_streamparm)
772 #define VIDIOC_G_STD _IOR ('V', 23, struct v4l2_standard)
773 #define VIDIOC_S_STD _IOW ('V', 24, struct v4l2_standard)
774 #define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_enumstd)
775 #define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input)
776 #define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control)
777 #define VIDIOC_S_CTRL _IOW ('V', 28, struct v4l2_control)
778 #define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner)
779 #define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner)
780 #define VIDIOC_G_FREQ _IOR ('V', 31, int)
781 #define VIDIOC_S_FREQ _IOWR ('V', 32, int)
782 #define VIDIOC_G_AUDIO _IOWR ('V', 33, struct v4l2_audio)
783 #define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio)
784 #define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl)
785 #define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu)
786 #define VIDIOC_G_INPUT _IOR ('V', 38, int)
787 #define VIDIOC_S_INPUT _IOWR ('V', 39, int)
788 #define VIDIOC_ENUMCVT _IOWR ('V', 40, struct v4l2_cvtdesc)
789 #define VIDIOC_G_OUTPUT _IOR ('V', 46, int)
790 #define VIDIOC_S_OUTPUT _IOWR ('V', 47, int)
791 #define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output)
792 #define VIDIOC_G_AUDOUT _IOWR ('V', 49, struct v4l2_audioout)
793 #define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout)
794 #define VIDIOC_ENUMFX _IOWR ('V', 51, struct v4l2_fxdesc)
795 #define VIDIOC_G_EFFECT _IOR ('V', 52, int)
796 #define VIDIOC_S_EFFECT _IOWR ('V', 53, int)
797 #define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator)
798 #define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator)
800 #define VIDIOC_ENUM_CAPFMT VIDIOC_ENUM_PIXFMT
801 #define VIDIOC_ENUM_OUTFMT VIDIOC_ENUM_PIXFMT
802 #define VIDIOC_ENUM_SRCFMT VIDIOC_ENUM_PIXFMT
803 #define VIDIOC_ENUMFMT VIDIOC_ENUM_PIXFMT
805 #define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
808 #ifdef __KERNEL__
810 * These things are used only by drivers.
813 extern int videodev_init(void);
817 * V 4 L 2 D R I V E R H E L P E R A P I
819 * Some commonly needed functions for drivers.
822 extern void v4l2_version(int *major, int *minor);
823 extern int v4l2_major_number(void);
825 /* Memory management */
826 extern unsigned long v4l2_vmalloc_to_bus(void *virt);
827 extern unsigned long v4l2_vmalloc_to_page(void *virt);
829 /* Simple queue management */
830 struct v4l2_q_node
832 struct v4l2_q_node *forw, *back;
834 struct v4l2_queue
836 struct v4l2_q_node *forw, *back;
837 rwlock_t qlock;
839 extern void v4l2_q_init(struct v4l2_queue *q);
840 extern void v4l2_q_add_head(struct v4l2_queue *q, struct v4l2_q_node *node);
841 extern void v4l2_q_add_tail(struct v4l2_queue *q, struct v4l2_q_node *node);
842 extern void *v4l2_q_del_head(struct v4l2_queue *q);
843 extern void *v4l2_q_del_tail(struct v4l2_queue *q);
844 extern void *v4l2_q_peek_head(struct v4l2_queue *q);
845 extern void *v4l2_q_peek_tail(struct v4l2_queue *q);
846 extern void *v4l2_q_yank_node(struct v4l2_queue *q, struct v4l2_q_node *node);
848 /* Math functions */
849 extern u32 v4l2_math_div6432(u64 a, u32 d, u32 *r);
851 /* Time functions */
852 extern unsigned long v4l2_timestamp_divide(stamp_t t,
853 unsigned long p_100ns);
854 extern unsigned long v4l2_timestamp_correct(stamp_t *t,
855 unsigned long p_100ns);
857 /* Master Clock functions */
858 struct v4l2_clock
860 void (*gettime)(stamp_t *);
862 extern int v4l2_masterclock_register(struct v4l2_clock *clock);
863 extern void v4l2_masterclock_unregister(struct v4l2_clock *clock);
864 extern void v4l2_masterclock_gettime(stamp_t *curr);
866 /* Video standard functions */
867 extern unsigned int v4l2_video_std_fps(struct v4l2_standard *vs);
868 extern unsigned long v4l2_video_std_tpf(struct v4l2_standard *vs);
869 extern int v4l2_video_std_confirm(struct v4l2_standard *vs);
870 extern int v4l2_video_std_construct(struct v4l2_standard *vs,
871 int id, __u32 transmission);
873 #define V4L2_STD_PAL 1 /* PAL B, G, H, I (...) */
874 #define V4L2_STD_PAL_M 5 /* (Brazil) */
875 #define V4L2_STD_PAL_N 6 /* (Argentina, Paraguay, Uruguay) */
876 #define V4L2_STD_PAL_60 10 /* PAL/NTSC hybrid */
877 #define V4L2_STD_NTSC 11 /* NTSC M (USA, ...) */
878 #define V4L2_STD_NTSC_N 12 /* (Barbados, Bolivia, Colombia,
879 S. Korea) */
880 #define V4L2_STD_NTSC_44 15 /* PAL/NTSC hybrid */
881 #define V4L2_STD_SECAM 21 /* SECAM B, D, G, K, K1 (...) */
882 //#define V4L2_STD_SECAM_H 27 /* (Greece, Iran, Morocco) */
883 //#define V4L2_STD_SECAM_L 28 /* (France, Luxembourg, Monaco) */
884 //#define V4L2_STD_SECAM_M 29 /* (Jamaica) */
887 * D E V I C E D R I V E R R E G I S T R A T I O N
890 struct v4l2_device
892 char name[32];
893 int type;
894 int minor;
896 int (*open)(struct v4l2_device *v,
897 int flags, void **idptr);
898 void (*close)(void *id);
899 long (*read)(void *id,
900 char *buf, unsigned long count, int noblock);
901 long (*write)(void *id,
902 const char *buf, unsigned long count, int noblock);
903 int (*ioctl)(void *id,
904 unsigned int cmd, void *arg);
905 int (*mmap)(void *id,
906 struct vm_area_struct *vma);
907 int (*poll)(void *id,
908 struct file *file, poll_table *table);
910 int (*initialize)(struct v4l2_device *v);
911 void *priv; /* may be used by the driver */
913 int busy; /* open count maintained by videodev.c */
914 void *v4l2_priv; /* for V4L2 use */
915 int v4l2_reserved[4]; /* for V4L2 use */
918 /* Size of kernel ioctl arg buffer used in ioctl handler */
919 #define V4L2_MAX_IOCTL_SIZE 256
921 extern int v4l2_register_device(struct v4l2_device *);
922 extern void v4l2_unregister_device(struct v4l2_device *);
924 /* V4L2 structures */
925 extern struct v4l2_device *v4l2_device_from_file(struct file *file);
926 extern void *v4l2_openid_from_file(struct file *file);
928 #endif/*ifdef __KERNEL__ */
931 /*----------------------------------------------------------------------
932 Old Video for Linux backward compatibility below this line.
933 ----------------------------------------------------------------------
935 All new applications should use the new API calls.
937 (These definitions taken from 2.2.1.)
942 #define VID_TYPE_CAPTURE 1 /* Can capture */
943 #define VID_TYPE_TUNER 2 /* Can tune */
944 #define VID_TYPE_TELETEXT 4 /* Does teletext */
945 #define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
946 #define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
947 #define VID_TYPE_CLIPPING 32 /* Can clip */
948 #define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
949 #define VID_TYPE_SCALES 128 /* Scalable */
950 #define VID_TYPE_MONOCHROME 256 /* Monochrome only */
951 #define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
953 struct video_capability
955 char name[32];
956 int type;
957 int channels; /* Num channels */
958 int audios; /* Num audio devices */
959 int maxwidth; /* Supported width */
960 int maxheight; /* And height */
961 int minwidth; /* Supported width */
962 int minheight; /* And height */
966 struct video_channel
968 int channel;
969 char name[32];
970 int tuners;
971 __u32 flags;
972 #define VIDEO_VC_TUNER 1 /* Channel has a tuner */
973 #define VIDEO_VC_AUDIO 2 /* Channel has audio */
974 __u16 type;
975 #define VIDEO_TYPE_TV 1
976 #define VIDEO_TYPE_CAMERA 2
977 __u16 norm; /* Norm set by channel */
980 struct video_tuner
982 int tuner;
983 char name[32];
984 ulong rangelow, rangehigh; /* Tuner range */
985 __u32 flags;
986 #define VIDEO_TUNER_PAL 1
987 #define VIDEO_TUNER_NTSC 2
988 #define VIDEO_TUNER_SECAM 4
989 #define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */
990 #define VIDEO_TUNER_NORM 16 /* Tuner can set norm */
991 #define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */
992 #define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */
993 #define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */
994 __u16 mode; /* PAL/NTSC/SECAM/OTHER */
995 #define VIDEO_MODE_PAL 0
996 #define VIDEO_MODE_NTSC 1
997 #define VIDEO_MODE_SECAM 2
998 #define VIDEO_MODE_AUTO 3
999 __u16 signal; /* Signal strength 16bit scale */
1002 struct video_picture
1004 __u16 brightness;
1005 __u16 hue;
1006 __u16 colour;
1007 __u16 contrast;
1008 __u16 whiteness; /* Black and white only */
1009 __u16 depth; /* Capture depth */
1010 __u16 palette; /* Palette in use */
1011 #define VIDEO_PALETTE_GREY 1 /* Linear greyscale */
1012 #define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */
1013 #define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */
1014 #define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */
1015 #define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */
1016 #define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */
1017 #define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */
1018 #define VIDEO_PALETTE_YUYV 8
1019 #define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */
1020 #define VIDEO_PALETTE_YUV420 10
1021 #define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */
1022 #define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */
1023 #define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */
1024 #define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */
1025 #define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */
1026 #define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */
1027 #define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */
1028 #define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */
1031 struct video_audio
1033 int audio; /* Audio channel */
1034 __u16 volume; /* If settable */
1035 __u16 bass, treble;
1036 __u32 flags;
1037 #define VIDEO_AUDIO_MUTE 1
1038 #define VIDEO_AUDIO_MUTABLE 2
1039 #define VIDEO_AUDIO_VOLUME 4
1040 #define VIDEO_AUDIO_BASS 8
1041 #define VIDEO_AUDIO_TREBLE 16
1042 #define VIDEO_AUDIO_BALANCE 32
1043 char name[16];
1044 #define VIDEO_SOUND_MONO 1
1045 #define VIDEO_SOUND_STEREO 2
1046 #define VIDEO_SOUND_LANG1 4
1047 #define VIDEO_SOUND_LANG2 8
1048 __u16 mode;
1049 __u16 balance; /* Stereo balance */
1050 __u16 step; /* Step actual volume uses */
1053 struct video_clip
1055 __s32 x,y;
1056 __s32 width, height;
1057 struct video_clip *next; /* For user use/driver use only */
1060 struct video_window
1062 __u32 x,y; /* Position of window */
1063 __u32 width,height; /* Its size */
1064 __u32 chromakey;
1065 __u32 flags;
1066 struct video_clip *clips; /* Set only */
1067 int clipcount;
1068 #define VIDEO_WINDOW_INTERLACE 1
1069 #define VIDEO_CLIP_BITMAP -1
1070 /* bitmap is 1024x625, a '1' bit represents a clipped pixel */
1071 #define VIDEO_CLIPMAP_SIZE (128 * 625)
1074 struct video_capture
1076 __u32 x,y; /* Offsets into image */
1077 __u32 width, height; /* Area to capture */
1078 __u16 decimation; /* Decimation divder */
1079 __u16 flags; /* Flags for capture */
1080 #define VIDEO_CAPTURE_ODD 0 /* Temporal */
1081 #define VIDEO_CAPTURE_EVEN 1
1084 struct video_buffer
1086 void *base;
1087 int height,width;
1088 int depth;
1089 int bytesperline;
1092 struct video_mmap
1094 unsigned int frame; /* Frame (0 - n) for double buffer */
1095 int height,width;
1096 unsigned int format; /* should be VIDEO_PALETTE_* */
1099 struct video_key
1101 __u8 key[8];
1102 __u32 flags;
1106 #define VIDEO_MAX_FRAME 32
1108 struct video_mbuf
1110 int size; /* Total memory to map */
1111 int frames; /* Frames */
1112 int offsets[VIDEO_MAX_FRAME];
1116 #define VIDEO_NO_UNIT (-1)
1119 struct video_unit
1121 int video; /* Video minor */
1122 int vbi; /* VBI minor */
1123 int radio; /* Radio minor */
1124 int audio; /* Audio minor */
1125 int teletext; /* Teletext minor */
1128 #define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */
1129 #define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */
1130 #define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */
1131 #define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */
1132 #define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */
1133 #define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */
1134 #define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */
1135 #define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */
1136 #define VIDIOCGWIN _IOR('v',9, struct video_window) /* Set the video overlay window */
1137 #define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
1138 #define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */
1139 #define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */
1140 #define VIDIOCKEY _IOR('v',13, struct video_key) /* Video key event - to dev 255 is to all - cuts capture on all DMA windows with this key (0xFFFFFFFF == all) */
1141 #define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */
1142 #define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */
1143 #define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */
1144 #define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */
1145 #define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */
1146 #define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */
1147 #define VIDIOCGMBUF _IOR('v', 20, struct video_mbuf) /* Memory map buffer info */
1148 #define VIDIOCGUNIT _IOR('v', 21, struct video_unit) /* Get attached units */
1149 #define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get frame buffer */
1150 #define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set frame buffer - root only */
1151 #define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */
1155 #endif/*ifndef __LINUX_VIDEODEV_H*/