commented early_printk patch because of rejects.
[linux-flexiantxendom0-3.2.10.git] / include / linux / videodev2.h
1 #ifndef __LINUX_VIDEODEV2_H
2 #define __LINUX_VIDEODEV2_H
3 /*
4  *      Video for Linux Two
5  *
6  *      Header file for v4l or V4L2 drivers and applications, for
7  *      Linux kernels 2.2.x or 2.4.x.
8  *
9  *      See http://bytesex.org/v4l/ for API specs and other
10  *      v4l2 documentation.
11  *
12  *      Author: Bill Dirks <bdirks@pacbell.net>
13  *              Justin Schoeman
14  *              et al.
15  */
16 #include <linux/time.h> /* need struct timeval */
17
18 /*
19  *      M I S C E L L A N E O U S
20  */
21
22 /*  Four-character-code (FOURCC) */
23 #define v4l2_fourcc(a,b,c,d)\
24         (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))
25
26 /*
27  *      E N U M S
28  */
29 enum v4l2_field {
30         V4L2_FIELD_ANY        = 0, /* driver can choose from none,
31                                       top, bottom, interlaced
32                                       depending on whatever it thinks
33                                       is approximate ... */
34         V4L2_FIELD_NONE       = 1, /* this device has no fields ... */
35         V4L2_FIELD_TOP        = 2, /* top field only */
36         V4L2_FIELD_BOTTOM     = 3, /* bottom field only */
37         V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */
38         V4L2_FIELD_SEQ_TB     = 5, /* both fields sequential into one
39                                       buffer, top-bottom order */
40         V4L2_FIELD_SEQ_BT     = 6, /* same as above + bottom-top order */
41         V4L2_FIELD_ALTERNATE  = 7, /* both fields alternating into
42                                       separate buffers */
43 };
44 #define V4L2_FIELD_HAS_TOP(field)       \
45         ((field) == V4L2_FIELD_TOP      ||\
46          (field) == V4L2_FIELD_INTERLACED ||\
47          (field) == V4L2_FIELD_SEQ_TB   ||\
48          (field) == V4L2_FIELD_SEQ_BT)
49 #define V4L2_FIELD_HAS_BOTTOM(field)    \
50         ((field) == V4L2_FIELD_BOTTOM   ||\
51          (field) == V4L2_FIELD_INTERLACED ||\
52          (field) == V4L2_FIELD_SEQ_TB   ||\
53          (field) == V4L2_FIELD_SEQ_BT)
54 #define V4L2_FIELD_HAS_BOTH(field)      \
55         ((field) == V4L2_FIELD_INTERLACED ||\
56          (field) == V4L2_FIELD_SEQ_TB   ||\
57          (field) == V4L2_FIELD_SEQ_BT)
58
59 enum v4l2_buf_type {
60         V4L2_BUF_TYPE_VIDEO_CAPTURE  = 1,
61         V4L2_BUF_TYPE_VIDEO_OUTPUT   = 2,
62         V4L2_BUF_TYPE_VIDEO_OVERLAY  = 3,
63         V4L2_BUF_TYPE_VBI_CAPTURE    = 4,
64         V4L2_BUF_TYPE_VBI_OUTPUT     = 5,
65         V4L2_BUF_TYPE_PRIVATE        = 0x80,
66 };
67
68 enum v4l2_ctrl_type {
69         V4L2_CTRL_TYPE_INTEGER       = 1,
70         V4L2_CTRL_TYPE_BOOLEAN       = 2,
71         V4L2_CTRL_TYPE_MENU          = 3,
72         V4L2_CTRL_TYPE_BUTTON        = 4,
73 };
74
75 enum v4l2_tuner_type {
76         V4L2_TUNER_RADIO             = 1,
77         V4L2_TUNER_ANALOG_TV         = 2,
78 };
79
80 enum v4l2_memory {
81         V4L2_MEMORY_MMAP             = 1,
82         V4L2_MEMORY_USERPTR          = 2,
83         V4L2_MEMORY_OVERLAY          = 3,
84 };
85
86 /* see also http://vektor.theorem.ca/graphics/ycbcr/ */
87 enum v4l2_colorspace {
88         /* ITU-R 601 -- broadcast NTSC/PAL */
89         V4L2_COLORSPACE_SMPTE170M     = 1,
90
91         /* 1125-Line (US) HDTV */
92         V4L2_COLORSPACE_SMPTE240M     = 2,
93
94         /* HD and modern captures. */
95         V4L2_COLORSPACE_REC709        = 3,
96         
97         /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */
98         V4L2_COLORSPACE_BT878         = 4,
99         
100         /* These should be useful.  Assume 601 extents. */
101         V4L2_COLORSPACE_470_SYSTEM_M  = 5,
102         V4L2_COLORSPACE_470_SYSTEM_BG = 6,
103         
104         /* I know there will be cameras that send this.  So, this is
105          * unspecified chromaticities and full 0-255 on each of the
106          * Y'CbCr components
107          */
108         V4L2_COLORSPACE_JPEG          = 7,
109         
110         /* For RGB colourspaces, this is probably a good start. */
111         V4L2_COLORSPACE_SRGB          = 8,
112 };
113
114 struct v4l2_rect {
115         __s32   left;
116         __s32   top;
117         __s32   width;
118         __s32   height;
119 };
120
121 struct v4l2_fract {
122         __u32   numerator;
123         __u32   denominator;
124 };
125
126 /*
127  *      D R I V E R   C A P A B I L I T I E S
128  */
129 struct v4l2_capability
130 {
131         __u8    driver[16];     /* i.e. "bttv" */
132         __u8    card[32];       /* i.e. "Hauppauge WinTV" */
133         __u8    bus_info[32];   /* "PCI:" + pci_name(pci_dev) */
134         __u32   version;        /* should use KERNEL_VERSION() */
135         __u32   capabilities;   /* Device capabilities */
136         __u32   reserved[4];
137 };
138
139 /* Values for 'capabilities' field */
140 #define V4L2_CAP_VIDEO_CAPTURE  0x00000001  /* Is a video capture device */
141 #define V4L2_CAP_VIDEO_OUTPUT   0x00000002  /* Is a video output device */
142 #define V4L2_CAP_VIDEO_OVERLAY  0x00000004  /* Can do video overlay */
143 #define V4L2_CAP_VBI_CAPTURE    0x00000010  /* Is a VBI capture device */
144 #define V4L2_CAP_VBI_OUTPUT     0x00000020  /* Is a VBI output device */
145 #define V4L2_CAP_RDS_CAPTURE    0x00000100  /* RDS data capture */
146
147 #define V4L2_CAP_TUNER          0x00010000  /* Has a tuner */
148 #define V4L2_CAP_AUDIO          0x00020000  /* has audio support */
149
150 #define V4L2_CAP_READWRITE      0x01000000  /* read/write systemcalls */
151 #define V4L2_CAP_ASYNCIO        0x02000000  /* async I/O */
152 #define V4L2_CAP_STREAMING      0x04000000  /* streaming I/O ioctls */
153
154 /*
155  *      V I D E O   I M A G E   F O R M A T
156  */
157
158 struct v4l2_pix_format
159 {
160         __u32                   width;
161         __u32                   height;
162         __u32                   pixelformat;
163         enum v4l2_field         field;
164         __u32                   bytesperline;   /* for padding, zero if unused */
165         __u32                   sizeimage;
166         enum v4l2_colorspace    colorspace;
167         __u32                   priv;           /* private data, depends on pixelformat */
168 };
169
170 /*           Pixel format    FOURCC                  depth  Description   */
171 #define V4L2_PIX_FMT_RGB332  v4l2_fourcc('R','G','B','1') /*  8  RGB-3-3-2     */
172 #define V4L2_PIX_FMT_RGB555  v4l2_fourcc('R','G','B','O') /* 16  RGB-5-5-5     */
173 #define V4L2_PIX_FMT_RGB565  v4l2_fourcc('R','G','B','P') /* 16  RGB-5-6-5     */
174 #define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R','G','B','Q') /* 16  RGB-5-5-5 BE  */
175 #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R','G','B','R') /* 16  RGB-5-6-5 BE  */
176 #define V4L2_PIX_FMT_BGR24   v4l2_fourcc('B','G','R','3') /* 24  BGR-8-8-8     */
177 #define V4L2_PIX_FMT_RGB24   v4l2_fourcc('R','G','B','3') /* 24  RGB-8-8-8     */
178 #define V4L2_PIX_FMT_BGR32   v4l2_fourcc('B','G','R','4') /* 32  BGR-8-8-8-8   */
179 #define V4L2_PIX_FMT_RGB32   v4l2_fourcc('R','G','B','4') /* 32  RGB-8-8-8-8   */
180 #define V4L2_PIX_FMT_GREY    v4l2_fourcc('G','R','E','Y') /*  8  Greyscale     */
181 #define V4L2_PIX_FMT_YVU410  v4l2_fourcc('Y','V','U','9') /*  9  YVU 4:1:0     */
182 #define V4L2_PIX_FMT_YVU420  v4l2_fourcc('Y','V','1','2') /* 12  YVU 4:2:0     */
183 #define V4L2_PIX_FMT_YUYV    v4l2_fourcc('Y','U','Y','V') /* 16  YUV 4:2:2     */
184 #define V4L2_PIX_FMT_UYVY    v4l2_fourcc('U','Y','V','Y') /* 16  YUV 4:2:2     */
185 #define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4','2','2','P') /* 16  YVU422 planar */
186 #define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4','1','1','P') /* 16  YVU411 planar */
187 #define V4L2_PIX_FMT_Y41P    v4l2_fourcc('Y','4','1','P') /* 12  YUV 4:1:1     */
188
189 /* two planes -- one Y, one Cr + Cb interleaved  */
190 #define V4L2_PIX_FMT_NV12    v4l2_fourcc('N','V','1','2') /* 12  Y/CbCr 4:2:0  */
191 #define V4L2_PIX_FMT_NV21    v4l2_fourcc('N','V','2','1') /* 12  Y/CrCb 4:2:0  */
192
193 /*  The following formats are not defined in the V4L2 specification */
194 #define V4L2_PIX_FMT_YUV410  v4l2_fourcc('Y','U','V','9') /*  9  YUV 4:1:0     */
195 #define V4L2_PIX_FMT_YUV420  v4l2_fourcc('Y','U','1','2') /* 12  YUV 4:2:0     */
196 #define V4L2_PIX_FMT_YYUV    v4l2_fourcc('Y','Y','U','V') /* 16  YUV 4:2:2     */
197 #define V4L2_PIX_FMT_HI240   v4l2_fourcc('H','I','2','4') /*  8  8-bit color   */
198
199 /* compressed formats */
200 #define V4L2_PIX_FMT_MJPEG    v4l2_fourcc('M','J','P','G') /* Motion-JPEG   */
201 #define V4L2_PIX_FMT_JPEG     v4l2_fourcc('J','P','E','G') /* JFIF JPEG     */
202 #define V4L2_PIX_FMT_DV       v4l2_fourcc('d','v','s','d') /* 1394          */
203 #define V4L2_PIX_FMT_MPEG     v4l2_fourcc('M','P','E','G') /* MPEG          */
204
205 /*  Vendor-specific formats   */
206 #define V4L2_PIX_FMT_WNVA    v4l2_fourcc('W','N','V','A') /* Winnov hw compres */
207
208 /*
209  *      F O R M A T   E N U M E R A T I O N
210  */
211 struct v4l2_fmtdesc
212 {
213         __u32               index;             /* Format number      */
214         enum v4l2_buf_type  type;              /* buffer type        */
215         __u32               flags;
216         __u8                description[32];   /* Description string */
217         __u32               pixelformat;       /* Format fourcc      */
218         __u32               reserved[4];
219 };
220
221 #define V4L2_FMT_FLAG_COMPRESSED 0x0001
222
223
224 /*
225  *      T I M E C O D E
226  */
227 struct v4l2_timecode
228 {
229         __u32   type;
230         __u32   flags;
231         __u8    frames;
232         __u8    seconds;
233         __u8    minutes;
234         __u8    hours;
235         __u8    userbits[4];
236 };
237
238 /*  Type  */
239 #define V4L2_TC_TYPE_24FPS              1
240 #define V4L2_TC_TYPE_25FPS              2
241 #define V4L2_TC_TYPE_30FPS              3
242 #define V4L2_TC_TYPE_50FPS              4
243 #define V4L2_TC_TYPE_60FPS              5
244
245 /*  Flags  */
246 #define V4L2_TC_FLAG_DROPFRAME          0x0001 /* "drop-frame" mode */
247 #define V4L2_TC_FLAG_COLORFRAME         0x0002
248 #define V4L2_TC_USERBITS_field          0x000C
249 #define V4L2_TC_USERBITS_USERDEFINED    0x0000
250 #define V4L2_TC_USERBITS_8BITCHARS      0x0008
251 /* The above is based on SMPTE timecodes */
252
253
254 /*
255  *      C O M P R E S S I O N   P A R A M E T E R S
256  */
257 #if 0
258 /* ### generic compression settings don't work, there is too much
259  * ### codec-specific stuff.  Maybe reuse that for MPEG codec settings
260  * ### later ... */
261 struct v4l2_compression
262 {
263         __u32   quality;
264         __u32   keyframerate;
265         __u32   pframerate;
266         __u32   reserved[5];
267 };
268 #endif
269
270 struct v4l2_jpegcompression
271 {
272         int quality;
273
274         int  APPn;              /* Number of APP segment to be written,
275                                  * must be 0..15 */
276         int  APP_len;           /* Length of data in JPEG APPn segment */
277         char APP_data[60];      /* Data in the JPEG APPn segment. */
278         
279         int  COM_len;           /* Length of data in JPEG COM segment */
280         char COM_data[60];      /* Data in JPEG COM segment */
281         
282         __u32 jpeg_markers;     /* Which markers should go into the JPEG
283                                  * output. Unless you exactly know what
284                                  * you do, leave them untouched.
285                                  * Inluding less markers will make the
286                                  * resulting code smaller, but there will
287                                  * be fewer aplications which can read it.
288                                  * The presence of the APP and COM marker
289                                  * is influenced by APP_len and COM_len
290                                  * ONLY, not by this property! */
291         
292 #define V4L2_JPEG_MARKER_DHT (1<<3)    /* Define Huffman Tables */
293 #define V4L2_JPEG_MARKER_DQT (1<<4)    /* Define Quantization Tables */
294 #define V4L2_JPEG_MARKER_DRI (1<<5)    /* Define Restart Interval */
295 #define V4L2_JPEG_MARKER_COM (1<<6)    /* Comment segment */
296 #define V4L2_JPEG_MARKER_APP (1<<7)    /* App segment, driver will
297                                         * allways use APP0 */
298 };
299
300
301 /*
302  *      M E M O R Y - M A P P I N G   B U F F E R S
303  */
304 struct v4l2_requestbuffers
305 {
306         __u32                   count;
307         enum v4l2_buf_type      type;
308         enum v4l2_memory        memory;
309         __u32                   reserved[2];
310 };
311
312 struct v4l2_buffer
313 {
314         __u32                   index;
315         enum v4l2_buf_type      type;
316         __u32                   bytesused;
317         __u32                   flags;
318         enum v4l2_field         field;
319         struct timeval          timestamp;
320         struct v4l2_timecode    timecode;
321         __u32                   sequence;
322
323         /* memory location */
324         enum v4l2_memory        memory;
325         union {
326                 __u32           offset;
327                 unsigned long   userptr;
328         } m;
329         __u32                   length;
330
331         __u32                   reserved[2];
332 };
333
334 /*  Flags for 'flags' field */
335 #define V4L2_BUF_FLAG_MAPPED    0x0001  /* Buffer is mapped (flag) */
336 #define V4L2_BUF_FLAG_QUEUED    0x0002  /* Buffer is queued for processing */
337 #define V4L2_BUF_FLAG_DONE      0x0004  /* Buffer is ready */
338 #define V4L2_BUF_FLAG_KEYFRAME  0x0008  /* Image is a keyframe (I-frame) */
339 #define V4L2_BUF_FLAG_PFRAME    0x0010  /* Image is a P-frame */
340 #define V4L2_BUF_FLAG_BFRAME    0x0020  /* Image is a B-frame */
341 #define V4L2_BUF_FLAG_TIMECODE  0x0100  /* timecode field is valid */
342
343 /*
344  *      O V E R L A Y   P R E V I E W
345  */
346 struct v4l2_framebuffer
347 {
348         __u32                   capability;
349         __u32                   flags;
350 /* FIXME: in theory we should pass something like PCI device + memory
351  * region + offset instead of some physical address */
352         void*                   base;
353         struct v4l2_pix_format  fmt;
354 };
355 /*  Flags for the 'capability' field. Read only */
356 #define V4L2_FBUF_CAP_EXTERNOVERLAY     0x0001
357 #define V4L2_FBUF_CAP_CHROMAKEY         0x0002
358 #define V4L2_FBUF_CAP_LIST_CLIPPING     0x0004
359 #define V4L2_FBUF_CAP_BITMAP_CLIPPING   0x0008
360 /*  Flags for the 'flags' field. */
361 #define V4L2_FBUF_FLAG_PRIMARY          0x0001
362 #define V4L2_FBUF_FLAG_OVERLAY          0x0002
363 #define V4L2_FBUF_FLAG_CHROMAKEY        0x0004
364
365 struct v4l2_clip
366 {
367         struct v4l2_rect        c;
368         struct v4l2_clip        *next;
369 };
370
371 struct v4l2_window
372 {
373         struct v4l2_rect        w;
374         enum v4l2_field         field;
375         __u32                   chromakey;
376         struct v4l2_clip        *clips;
377         __u32                   clipcount;
378         void                    *bitmap;
379 };
380
381
382 /*
383  *      C A P T U R E   P A R A M E T E R S
384  */
385 struct v4l2_captureparm
386 {
387         __u32              capability;    /*  Supported modes */
388         __u32              capturemode;   /*  Current mode */
389         struct v4l2_fract  timeperframe;  /*  Time per frame in .1us units */
390         __u32              extendedmode;  /*  Driver-specific extensions */
391         __u32              readbuffers;   /*  # of buffers for read */
392         __u32              reserved[4];
393 };
394 /*  Flags for 'capability' and 'capturemode' fields */
395 #define V4L2_MODE_HIGHQUALITY   0x0001  /*  High quality imaging mode */
396 #define V4L2_CAP_TIMEPERFRAME   0x1000  /*  timeperframe field is supported */
397
398 struct v4l2_outputparm
399 {
400         __u32              capability;   /*  Supported modes */
401         __u32              outputmode;   /*  Current mode */
402         struct v4l2_fract  timeperframe; /*  Time per frame in seconds */
403         __u32              extendedmode; /*  Driver-specific extensions */
404         __u32              writebuffers; /*  # of buffers for write */
405         __u32              reserved[4];
406 };
407
408 /*
409  *      I N P U T   I M A G E   C R O P P I N G
410  */
411
412 struct v4l2_cropcap {
413         enum v4l2_buf_type      type;   
414         struct v4l2_rect        bounds;
415         struct v4l2_rect        defrect;
416         struct v4l2_fract       pixelaspect;
417 };
418
419 struct v4l2_crop {
420         enum v4l2_buf_type      type;
421         struct v4l2_rect        c;
422 };
423
424 /*
425  *      A N A L O G   V I D E O   S T A N D A R D
426  */
427
428 typedef __u64 v4l2_std_id;
429
430 /* one bit for each */
431 #define V4L2_STD_PAL_B          ((v4l2_std_id)0x00000001)
432 #define V4L2_STD_PAL_B1         ((v4l2_std_id)0x00000002)
433 #define V4L2_STD_PAL_G          ((v4l2_std_id)0x00000004)
434 #define V4L2_STD_PAL_H          ((v4l2_std_id)0x00000008)
435 #define V4L2_STD_PAL_I          ((v4l2_std_id)0x00000010)
436 #define V4L2_STD_PAL_D          ((v4l2_std_id)0x00000020)
437 #define V4L2_STD_PAL_D1         ((v4l2_std_id)0x00000040)
438 #define V4L2_STD_PAL_K          ((v4l2_std_id)0x00000080)
439
440 #define V4L2_STD_PAL_M          ((v4l2_std_id)0x00000100)
441 #define V4L2_STD_PAL_N          ((v4l2_std_id)0x00000200)
442 #define V4L2_STD_PAL_Nc         ((v4l2_std_id)0x00000400)
443 #define V4L2_STD_PAL_60         ((v4l2_std_id)0x00000800)
444
445 #define V4L2_STD_NTSC_M         ((v4l2_std_id)0x00001000)
446 #define V4L2_STD_NTSC_M_JP      ((v4l2_std_id)0x00002000)
447
448 #define V4L2_STD_SECAM_B        ((v4l2_std_id)0x00010000)
449 #define V4L2_STD_SECAM_D        ((v4l2_std_id)0x00020000)
450 #define V4L2_STD_SECAM_G        ((v4l2_std_id)0x00040000)
451 #define V4L2_STD_SECAM_H        ((v4l2_std_id)0x00080000)
452 #define V4L2_STD_SECAM_K        ((v4l2_std_id)0x00100000)
453 #define V4L2_STD_SECAM_K1       ((v4l2_std_id)0x00200000)
454 #define V4L2_STD_SECAM_L        ((v4l2_std_id)0x00400000)
455
456 /* ATSC/HDTV */
457 #define V4L2_STD_ATSC_8_VSB     ((v4l2_std_id)0x01000000)
458 #define V4L2_STD_ATSC_16_VSB    ((v4l2_std_id)0x02000000)
459
460 /* some common needed stuff */
461 #define V4L2_STD_PAL_BG         (V4L2_STD_PAL_B         |\
462                                  V4L2_STD_PAL_B1        |\
463                                  V4L2_STD_PAL_G)
464 #define V4L2_STD_PAL_DK         (V4L2_STD_PAL_D         |\
465                                  V4L2_STD_PAL_D1        |\
466                                  V4L2_STD_PAL_K)
467 #define V4L2_STD_PAL            (V4L2_STD_PAL_BG        |\
468                                  V4L2_STD_PAL_DK        |\
469                                  V4L2_STD_PAL_H         |\
470                                  V4L2_STD_PAL_I)
471 #define V4L2_STD_NTSC           (V4L2_STD_NTSC_M        |\
472                                  V4L2_STD_NTSC_M_JP)
473 #define V4L2_STD_SECAM          (V4L2_STD_SECAM_B       |\
474                                  V4L2_STD_SECAM_D       |\
475                                  V4L2_STD_SECAM_G       |\
476                                  V4L2_STD_SECAM_H       |\
477                                  V4L2_STD_SECAM_K       |\
478                                  V4L2_STD_SECAM_K1      |\
479                                  V4L2_STD_SECAM_L)
480
481 #define V4L2_STD_525_60         (V4L2_STD_PAL_M         |\
482                                  V4L2_STD_PAL_60        |\
483                                  V4L2_STD_NTSC)
484 #define V4L2_STD_625_50         (V4L2_STD_PAL           |\
485                                  V4L2_STD_PAL_N         |\
486                                  V4L2_STD_PAL_Nc        |\
487                                  V4L2_STD_SECAM)
488
489 #define V4L2_STD_UNKNOWN        0
490 #define V4L2_STD_ALL            (V4L2_STD_525_60        |\
491                                  V4L2_STD_625_50)
492
493 struct v4l2_standard
494 {
495         __u32                index;
496         v4l2_std_id          id;
497         __u8                 name[24];
498         struct v4l2_fract    frameperiod; /* Frames, not fields */
499         __u32                framelines;
500         __u32                reserved[4];
501 };
502
503
504 /*
505  *      V I D E O   I N P U T S
506  */
507 struct v4l2_input
508 {
509         __u32        index;             /*  Which input */
510         __u8         name[32];          /*  Label */
511         __u32        type;              /*  Type of input */
512         __u32        audioset;          /*  Associated audios (bitfield) */
513         __u32        tuner;             /*  Associated tuner */
514         v4l2_std_id  std;
515         __u32        status;
516         __u32        reserved[4];
517 };
518 /*  Values for the 'type' field */
519 #define V4L2_INPUT_TYPE_TUNER           1
520 #define V4L2_INPUT_TYPE_CAMERA          2
521
522 /* field 'status' - general */
523 #define V4L2_IN_ST_NO_POWER    0x00000001  /* Attached device is off */
524 #define V4L2_IN_ST_NO_SIGNAL   0x00000002
525 #define V4L2_IN_ST_NO_COLOR    0x00000004
526
527 /* field 'status' - analog */
528 #define V4L2_IN_ST_NO_H_LOCK   0x00000100  /* No horizontal sync lock */
529 #define V4L2_IN_ST_COLOR_KILL  0x00000200  /* Color killer is active */
530
531 /* field 'status' - digital */
532 #define V4L2_IN_ST_NO_SYNC     0x00010000  /* No synchronization lock */
533 #define V4L2_IN_ST_NO_EQU      0x00020000  /* No equalizer lock */
534 #define V4L2_IN_ST_NO_CARRIER  0x00040000  /* Carrier recovery failed */
535
536 /* field 'status' - VCR and set-top box */
537 #define V4L2_IN_ST_MACROVISION 0x01000000  /* Macrovision detected */
538 #define V4L2_IN_ST_NO_ACCESS   0x02000000  /* Conditional access denied */
539 #define V4L2_IN_ST_VTR         0x04000000  /* VTR time constant */
540
541 /*
542  *      V I D E O   O U T P U T S
543  */
544 struct v4l2_output
545 {
546         __u32        index;             /*  Which output */
547         __u8         name[32];          /*  Label */
548         __u32        type;              /*  Type of output */
549         __u32        audioset;          /*  Associated audios (bitfield) */
550         __u32        modulator;         /*  Associated modulator */
551         v4l2_std_id  std;
552         __u32        reserved[4];
553 };
554 /*  Values for the 'type' field */
555 #define V4L2_OUTPUT_TYPE_MODULATOR              1
556 #define V4L2_OUTPUT_TYPE_ANALOG                 2
557 #define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY       3
558
559 /*
560  *      C O N T R O L S
561  */
562 struct v4l2_control
563 {
564         __u32                id;
565         __s32                value;
566 };
567
568 /*  Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
569 struct v4l2_queryctrl
570 {
571         __u32                id;
572         enum v4l2_ctrl_type  type;
573         __u8                 name[32];  /* Whatever */
574         __s32                minimum;   /* Note signedness */
575         __s32                maximum;
576         __s32                step;
577         __s32                default_value;
578         __u32                flags;
579         __u32                reserved[2];
580 };
581
582 /*  Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
583 struct v4l2_querymenu
584 {
585         __u32           id;
586         __u32           index;
587         __u8            name[32];       /* Whatever */
588         __u32           reserved;
589 };
590
591 /*  Control flags  */
592 #define V4L2_CTRL_FLAG_DISABLED         0x0001
593 #define V4L2_CTRL_FLAG_GRABBED          0x0002
594
595 /*  Control IDs defined by V4L2 */
596 #define V4L2_CID_BASE                   0x00980900
597 /*  IDs reserved for driver specific controls */
598 #define V4L2_CID_PRIVATE_BASE           0x08000000
599
600 #define V4L2_CID_BRIGHTNESS             (V4L2_CID_BASE+0)
601 #define V4L2_CID_CONTRAST               (V4L2_CID_BASE+1)
602 #define V4L2_CID_SATURATION             (V4L2_CID_BASE+2)
603 #define V4L2_CID_HUE                    (V4L2_CID_BASE+3)
604 #define V4L2_CID_AUDIO_VOLUME           (V4L2_CID_BASE+5)
605 #define V4L2_CID_AUDIO_BALANCE          (V4L2_CID_BASE+6)
606 #define V4L2_CID_AUDIO_BASS             (V4L2_CID_BASE+7)
607 #define V4L2_CID_AUDIO_TREBLE           (V4L2_CID_BASE+8)
608 #define V4L2_CID_AUDIO_MUTE             (V4L2_CID_BASE+9)
609 #define V4L2_CID_AUDIO_LOUDNESS         (V4L2_CID_BASE+10)
610 #define V4L2_CID_BLACK_LEVEL            (V4L2_CID_BASE+11)
611 #define V4L2_CID_AUTO_WHITE_BALANCE     (V4L2_CID_BASE+12)
612 #define V4L2_CID_DO_WHITE_BALANCE       (V4L2_CID_BASE+13)
613 #define V4L2_CID_RED_BALANCE            (V4L2_CID_BASE+14)
614 #define V4L2_CID_BLUE_BALANCE           (V4L2_CID_BASE+15)
615 #define V4L2_CID_GAMMA                  (V4L2_CID_BASE+16)
616 #define V4L2_CID_WHITENESS              (V4L2_CID_GAMMA) /* ? Not sure */
617 #define V4L2_CID_EXPOSURE               (V4L2_CID_BASE+17)
618 #define V4L2_CID_AUTOGAIN               (V4L2_CID_BASE+18)
619 #define V4L2_CID_GAIN                   (V4L2_CID_BASE+19)
620 #define V4L2_CID_HFLIP                  (V4L2_CID_BASE+20)
621 #define V4L2_CID_VFLIP                  (V4L2_CID_BASE+21)
622 #define V4L2_CID_HCENTER                (V4L2_CID_BASE+22)
623 #define V4L2_CID_VCENTER                (V4L2_CID_BASE+23)
624 #define V4L2_CID_LASTP1                 (V4L2_CID_BASE+24) /* last CID + 1 */
625
626 /*
627  *      T U N I N G
628  */
629 struct v4l2_tuner
630 {
631         __u32                   index;
632         __u8                    name[32];
633         enum v4l2_tuner_type    type;
634         __u32                   capability;
635         __u32                   rangelow;
636         __u32                   rangehigh;
637         __u32                   rxsubchans;
638         __u32                   audmode;
639         __s32                   signal;
640         __s32                   afc;
641         __u32                   reserved[4];
642 };
643
644 struct v4l2_modulator
645 {
646         __u32                   index;
647         __u8                    name[32];
648         __u32                   capability;
649         __u32                   rangelow;
650         __u32                   rangehigh;
651         __u32                   txsubchans;
652         __u32                   reserved[4];
653 };
654
655 /*  Flags for the 'capability' field */
656 #define V4L2_TUNER_CAP_LOW              0x0001
657 #define V4L2_TUNER_CAP_NORM             0x0002
658 #define V4L2_TUNER_CAP_STEREO           0x0010
659 #define V4L2_TUNER_CAP_LANG2            0x0020
660 #define V4L2_TUNER_CAP_SAP              0x0020
661 #define V4L2_TUNER_CAP_LANG1            0x0040
662
663 /*  Flags for the 'rxsubchans' field */
664 #define V4L2_TUNER_SUB_MONO             0x0001
665 #define V4L2_TUNER_SUB_STEREO           0x0002
666 #define V4L2_TUNER_SUB_LANG2            0x0004
667 #define V4L2_TUNER_SUB_SAP              0x0004
668 #define V4L2_TUNER_SUB_LANG1            0x0008
669
670 /*  Values for the 'audmode' field */
671 #define V4L2_TUNER_MODE_MONO            0x0000
672 #define V4L2_TUNER_MODE_STEREO          0x0001
673 #define V4L2_TUNER_MODE_LANG2           0x0002
674 #define V4L2_TUNER_MODE_SAP             0x0002
675 #define V4L2_TUNER_MODE_LANG1           0x0003
676
677 struct v4l2_frequency
678 {
679         __u32                 tuner;
680         enum v4l2_tuner_type  type;
681         __u32                 frequency;
682         __u32                 reserved[8];
683 };
684
685 /*
686  *      A U D I O
687  */
688 struct v4l2_audio
689 {
690         __u32   index;
691         __u8    name[32];
692         __u32   capability;
693         __u32   mode;
694         __u32   reserved[2];
695 };
696 /*  Flags for the 'capability' field */
697 #define V4L2_AUDCAP_STEREO              0x00001
698 #define V4L2_AUDCAP_AVL                 0x00002
699
700 /*  Flags for the 'mode' field */
701 #define V4L2_AUDMODE_AVL                0x00001
702
703 struct v4l2_audioout
704 {
705         __u32   index;
706         __u8    name[32];
707         __u32   capability;
708         __u32   mode;
709         __u32   reserved[2];
710 };
711
712 /*
713  *      D A T A   S E R V I C E S   ( V B I )
714  *
715  *      Data services API by Michael Schimek
716  */
717
718 struct v4l2_vbi_format
719 {
720         __u32   sampling_rate;          /* in 1 Hz */
721         __u32   offset;
722         __u32   samples_per_line;
723         __u32   sample_format;          /* V4L2_PIX_FMT_* */
724         __s32   start[2];
725         __u32   count[2];
726         __u32   flags;                  /* V4L2_VBI_* */
727         __u32   reserved[2];            /* must be zero */
728 };
729
730 /*  VBI flags  */
731 #define V4L2_VBI_UNSYNC         (1<< 0)
732 #define V4L2_VBI_INTERLACED     (1<< 1)
733
734
735 /*
736  *      A G G R E G A T E   S T R U C T U R E S
737  */
738
739 /*      Stream data format
740  */
741 struct v4l2_format
742 {
743         enum v4l2_buf_type type;
744         union
745         {
746                 struct v4l2_pix_format  pix;  // V4L2_BUF_TYPE_VIDEO_CAPTURE
747                 struct v4l2_window      win;  // V4L2_BUF_TYPE_VIDEO_OVERLAY
748                 struct v4l2_vbi_format  vbi;  // V4L2_BUF_TYPE_VBI_CAPTURE
749                 __u8    raw_data[200];        // user-defined
750         } fmt;
751 };
752
753
754 /*      Stream type-dependent parameters
755  */
756 struct v4l2_streamparm
757 {
758         enum v4l2_buf_type type;
759         union
760         {
761                 struct v4l2_captureparm capture;
762                 struct v4l2_outputparm  output;
763                 __u8    raw_data[200];  /* user-defined */
764         } parm;
765 };
766
767
768
769 /*
770  *      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
771  *
772  */
773 #define VIDIOC_QUERYCAP         _IOR  ('V',  0, struct v4l2_capability)
774 #define VIDIOC_RESERVED         _IO   ('V',  1)
775 #define VIDIOC_ENUM_FMT         _IOWR ('V',  2, struct v4l2_fmtdesc)
776 #define VIDIOC_G_FMT            _IOWR ('V',  4, struct v4l2_format)
777 #define VIDIOC_S_FMT            _IOWR ('V',  5, struct v4l2_format)
778 #if 0
779 #define VIDIOC_G_COMP           _IOR  ('V',  6, struct v4l2_compression)
780 #define VIDIOC_S_COMP           _IOW  ('V',  7, struct v4l2_compression)
781 #endif
782 #define VIDIOC_REQBUFS          _IOWR ('V',  8, struct v4l2_requestbuffers)
783 #define VIDIOC_QUERYBUF         _IOWR ('V',  9, struct v4l2_buffer)
784 #define VIDIOC_G_FBUF           _IOR  ('V', 10, struct v4l2_framebuffer)
785 #define VIDIOC_S_FBUF           _IOW  ('V', 11, struct v4l2_framebuffer)
786 #define VIDIOC_OVERLAY          _IOWR ('V', 14, int)
787 #define VIDIOC_QBUF             _IOWR ('V', 15, struct v4l2_buffer)
788 #define VIDIOC_DQBUF            _IOWR ('V', 17, struct v4l2_buffer)
789 #define VIDIOC_STREAMON         _IOW  ('V', 18, int)
790 #define VIDIOC_STREAMOFF        _IOW  ('V', 19, int)
791 #define VIDIOC_G_PARM           _IOWR ('V', 21, struct v4l2_streamparm)
792 #define VIDIOC_S_PARM           _IOW  ('V', 22, struct v4l2_streamparm)
793 #define VIDIOC_G_STD            _IOR  ('V', 23, v4l2_std_id)
794 #define VIDIOC_S_STD            _IOW  ('V', 24, v4l2_std_id)
795 #define VIDIOC_ENUMSTD          _IOWR ('V', 25, struct v4l2_standard)
796 #define VIDIOC_ENUMINPUT        _IOWR ('V', 26, struct v4l2_input)
797 #define VIDIOC_G_CTRL           _IOWR ('V', 27, struct v4l2_control)
798 #define VIDIOC_S_CTRL           _IOW  ('V', 28, struct v4l2_control)
799 #define VIDIOC_G_TUNER          _IOWR ('V', 29, struct v4l2_tuner)
800 #define VIDIOC_S_TUNER          _IOW  ('V', 30, struct v4l2_tuner)
801 #define VIDIOC_G_AUDIO          _IOWR ('V', 33, struct v4l2_audio)
802 #define VIDIOC_S_AUDIO          _IOW  ('V', 34, struct v4l2_audio)
803 #define VIDIOC_QUERYCTRL        _IOWR ('V', 36, struct v4l2_queryctrl)
804 #define VIDIOC_QUERYMENU        _IOWR ('V', 37, struct v4l2_querymenu)
805 #define VIDIOC_G_INPUT          _IOR  ('V', 38, int)
806 #define VIDIOC_S_INPUT          _IOWR ('V', 39, int)
807 #define VIDIOC_G_OUTPUT         _IOR  ('V', 46, int)
808 #define VIDIOC_S_OUTPUT         _IOWR ('V', 47, int)
809 #define VIDIOC_ENUMOUTPUT       _IOWR ('V', 48, struct v4l2_output)
810 #define VIDIOC_G_AUDOUT         _IOWR ('V', 49, struct v4l2_audioout)
811 #define VIDIOC_S_AUDOUT         _IOW  ('V', 50, struct v4l2_audioout)
812 #define VIDIOC_G_MODULATOR      _IOWR ('V', 54, struct v4l2_modulator)
813 #define VIDIOC_S_MODULATOR      _IOW  ('V', 55, struct v4l2_modulator)
814 #define VIDIOC_G_FREQUENCY      _IOWR ('V', 56, struct v4l2_frequency)
815 #define VIDIOC_S_FREQUENCY      _IOW  ('V', 57, struct v4l2_frequency)
816 #define VIDIOC_CROPCAP          _IOR  ('V', 58, struct v4l2_cropcap)
817 #define VIDIOC_G_CROP           _IOWR ('V', 59, struct v4l2_crop)
818 #define VIDIOC_S_CROP           _IOW  ('V', 60, struct v4l2_crop)
819 #define VIDIOC_G_JPEGCOMP       _IOR  ('V', 61, struct v4l2_jpegcompression)
820 #define VIDIOC_S_JPEGCOMP       _IOW  ('V', 62, struct v4l2_jpegcompression)
821 #define VIDIOC_QUERYSTD         _IOR  ('V', 63, v4l2_std_id)
822 #define VIDIOC_TRY_FMT          _IOWR ('V', 64, struct v4l2_format)
823
824 #define BASE_VIDIOC_PRIVATE     192             /* 192-255 are private */
825
826
827 #ifdef __KERNEL__
828 /*
829  *
830  *      V 4 L 2   D R I V E R   H E L P E R   A P I
831  *
832  *      Some commonly needed functions for drivers (v4l2-common.o module)
833  */
834 #include <linux/fs.h>
835
836 /*  Video standard functions  */
837 extern unsigned int v4l2_video_std_fps(struct v4l2_standard *vs);
838 extern int v4l2_video_std_construct(struct v4l2_standard *vs,
839                                     int id, char *name);
840
841 /*  Compatibility layer interface  */
842 typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
843                            unsigned int cmd, void *arg);
844 int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
845                                int cmd, void *arg, v4l2_kioctl driver_ioctl);
846
847 /* names for fancy debug output */
848 extern char *v4l2_field_names[];
849 extern char *v4l2_type_names[];
850 extern char *v4l2_ioctl_names[];
851
852 #endif /* __KERNEL__ */
853 #endif /* __LINUX_VIDEODEV2_H */
854
855 /*
856  * Local variables:
857  * c-basic-offset: 8
858  * End:
859  */