Update the changelog
[opencv] / otherlibs / cvcam / src / unix / videodev.h
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41
42 #ifndef __LINUX_VIDEODEV_H
43 #define __LINUX_VIDEODEV_H
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #include <linux/types.h>
50 #include <linux/version.h>
51
52 #ifdef __KERNEL__
53
54 #if LINUX_VERSION_CODE >= 0x020100
55 #include <linux/poll.h>
56 #endif
57
58 struct video_device
59 {
60     char name[32];
61     int type;
62     int hardware;
63
64     int (*open)(struct video_device *, int mode);
65     void (*close)(struct video_device *);
66     long (*read)(struct video_device *, char *, unsigned long, int noblock);
67     /* Do we need a write method ? */
68     long (*write)(struct video_device *, const char *, unsigned long, int noblock);
69 #if LINUX_VERSION_CODE >= 0x020100
70     unsigned int (*poll)(struct video_device *, struct file *, poll_table *);
71 #endif
72     int (*ioctl)(struct video_device *, unsigned int , void *);
73     int (*mmap)(struct video_device *, const char *, unsigned long);
74     int (*initialize)(struct video_device *);   
75     void *priv;     /* Used to be 'private' but that upsets C++ */
76     int busy;
77     int minor;
78 };
79
80 extern int videodev_init(void);
81 #define VIDEO_MAJOR 81
82 extern int video_register_device(struct video_device *, int type);
83
84 #define VFL_TYPE_GRABBER    0
85 #define VFL_TYPE_VBI        1
86 #define VFL_TYPE_RADIO      2
87 #define VFL_TYPE_VTX        3
88
89 extern void video_unregister_device(struct video_device *);
90 #endif
91
92
93 #define VID_TYPE_CAPTURE    1   /* Can capture */
94 #define VID_TYPE_TUNER      2   /* Can tune */
95 #define VID_TYPE_TELETEXT   4   /* Does teletext */
96 #define VID_TYPE_OVERLAY    8   /* Overlay onto frame buffer */
97 #define VID_TYPE_CHROMAKEY  16  /* Overlay by chromakey */
98 #define VID_TYPE_CLIPPING   32  /* Can clip */
99 #define VID_TYPE_FRAMERAM   64  /* Uses the frame buffer memory */
100 #define VID_TYPE_SCALES     128 /* Scalable */
101 #define VID_TYPE_MONOCHROME 256 /* Monochrome only */
102 #define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
103
104 struct video_capability
105 {
106     char name[32];
107     int type;
108     int channels;   /* Num channels */
109     int audios; /* Num audio devices */
110     int maxwidth;   /* Supported width */
111     int maxheight;  /* And height */
112     int minwidth;   /* Supported width */
113     int minheight;  /* And height */
114 };
115
116
117 struct video_channel
118 {
119     int channel;
120     char name[32];
121     int tuners;
122     __u32  flags;
123 #define VIDEO_VC_TUNER      1   /* Channel has a tuner */
124 #define VIDEO_VC_AUDIO      2   /* Channel has audio */
125     __u16  type;
126 #define VIDEO_TYPE_TV       1
127 #define VIDEO_TYPE_CAMERA   2   
128     __u16 norm;         /* Norm set by channel */
129 };
130
131 struct video_tuner
132 {
133     int tuner;
134     char name[32];
135     __u32 rangelow, rangehigh;  /* Tuner range */
136     __u32 flags;
137 #define VIDEO_TUNER_PAL     1
138 #define VIDEO_TUNER_NTSC    2
139 #define VIDEO_TUNER_SECAM   4
140 #define VIDEO_TUNER_LOW     8   /* Uses KHz not MHz */
141 #define VIDEO_TUNER_NORM    16  /* Tuner can set norm */
142 #define VIDEO_TUNER_STEREO_ON   128 /* Tuner is seeing stereo */
143 #define VIDEO_TUNER_RDS_ON      256     /* Tuner is seeing an RDS datastream */
144 #define VIDEO_TUNER_MBS_ON      512     /* Tuner is seeing an MBS datastream */
145     __u16 mode;         /* PAL/NTSC/SECAM/OTHER */
146 #define VIDEO_MODE_PAL      0
147 #define VIDEO_MODE_NTSC     1
148 #define VIDEO_MODE_SECAM    2
149 #define VIDEO_MODE_AUTO     3
150     __u16 signal;           /* Signal strength 16bit scale */
151 };
152
153 struct video_picture
154 {
155     __u16   brightness;
156     __u16   hue;
157     __u16   colour;
158     __u16   contrast;
159     __u16   whiteness;  /* Black and white only */
160     __u16   depth;      /* Capture depth */
161     __u16   palette;    /* Palette in use */
162 #define VIDEO_PALETTE_GREY      1   /* Linear greyscale */
163 #define VIDEO_PALETTE_HI240     2   /* High 240 cube (BT848) */
164 #define VIDEO_PALETTE_RGB565    3   /* 565 16 bit RGB */
165 #define VIDEO_PALETTE_RGB24     4   /* 24bit RGB */
166 #define VIDEO_PALETTE_RGB32     5   /* 32bit RGB */ 
167 #define VIDEO_PALETTE_RGB555    6   /* 555 15bit RGB */
168 #define VIDEO_PALETTE_YUV422    7   /* YUV422 capture */
169 #define VIDEO_PALETTE_YUYV      8
170 #define VIDEO_PALETTE_UYVY      9   /* The great thing about standards is ... */
171 #define VIDEO_PALETTE_YUV420    10
172 #define VIDEO_PALETTE_YUV411    11  /* YUV411 capture */
173 #define VIDEO_PALETTE_RAW       12  /* RAW capture (BT848) */
174 #define VIDEO_PALETTE_YUV422P   13  /* YUV 4:2:2 Planar */
175 #define VIDEO_PALETTE_YUV411P   14  /* YUV 4:1:1 Planar */
176 #define VIDEO_PALETTE_YUV420P   15  /* YUV 4:2:0 Planar */
177 #define VIDEO_PALETTE_YUV410P   16  /* YUV 4:1:0 Planar */
178 #define VIDEO_PALETTE_PLANAR    13  /* start of planar entries */
179 #define VIDEO_PALETTE_COMPONENT 7   /* start of component entries */
180 };
181
182 struct video_audio
183 {
184     int audio;          /* Audio channel */
185     __u16   volume;     /* If settable */
186     __u16   bass, treble;
187     __u32   flags;
188 #define VIDEO_AUDIO_MUTE    1
189 #define VIDEO_AUDIO_MUTABLE 2
190 #define VIDEO_AUDIO_VOLUME  4
191 #define VIDEO_AUDIO_BASS    8
192 #define VIDEO_AUDIO_TREBLE  16  
193     char    name[16];
194 #define VIDEO_SOUND_MONO    1
195 #define VIDEO_SOUND_STEREO  2
196 #define VIDEO_SOUND_LANG1   4
197 #define VIDEO_SOUND_LANG2   8
198     __u16   umode;
199     __u16   balance;    /* Stereo balance */
200     __u16   step;       /* Step actual volume uses */
201 };
202
203 struct video_clip
204 {
205     __s32   x,y;
206     __s32   width, height;
207     struct  video_clip *next;   /* For user use/driver use only */
208 };
209
210 struct video_window
211 {
212     __u32   x,y;            /* Position of window */
213     __u32   width,height;       /* Its size */
214     __u32   chromakey;
215     __u32   flags;
216     struct  video_clip *clips;  /* Set only */
217     int clipcount;
218 #define VIDEO_WINDOW_INTERLACE  1
219 #define VIDEO_CLIP_BITMAP   -1
220 /* bitmap is 1024x625, a '1' bit represents a clipped pixel */
221 #define VIDEO_CLIPMAP_SIZE  (128 * 625)
222 };
223
224 struct video_capture
225 {
226     __u32   x,y;            /* Offsets into image */
227     __u32   width, height;      /* Area to capture */
228     __u16   decimation;     /* Decimation divder */
229     __u16   flags;          /* Flags for capture */
230 #define VIDEO_CAPTURE_ODD       0   /* Temporal */
231 #define VIDEO_CAPTURE_EVEN      1
232 };
233
234 struct video_buffer
235 {
236     void    *base;
237     int height,width;
238     int depth;
239     int bytesperline;
240 };
241
242 struct video_mmap
243 {
244     unsigned    int frame;      /* Frame (0 - n) for double buffer */
245     int     height,width;
246     unsigned    int format;     /* should be VIDEO_PALETTE_* */
247 };
248
249 struct video_key
250 {
251     __u8    key[8];
252     __u32   flags;
253 };
254
255
256 #define VIDEO_MAX_FRAME     32
257
258 struct video_mbuf
259 {
260     int size;       /* Total memory to map */
261     int frames;     /* Frames */
262     int offsets[VIDEO_MAX_FRAME];
263 };
264     
265
266 #define     VIDEO_NO_UNIT   (-1)
267
268     
269 struct video_unit
270 {
271     int     video;      /* Video minor */
272     int vbi;        /* VBI minor */
273     int radio;      /* Radio minor */
274     int audio;      /* Audio minor */
275     int teletext;   /* Teletext minor */
276 };
277
278 #define VIDIOCGCAP      _IOR('v',1,struct video_capability) /* Get capabilities */
279 #define VIDIOCGCHAN     _IOWR('v',2,struct video_channel)   /* Get channel info (sources) */
280 #define VIDIOCSCHAN     _IOW('v',3,struct video_channel)    /* Set channel  */
281 #define VIDIOCGTUNER        _IOWR('v',4,struct video_tuner)     /* Get tuner abilities */
282 #define VIDIOCSTUNER        _IOW('v',5,struct video_tuner)      /* Tune the tuner for the current channel */
283 #define VIDIOCGPICT     _IOR('v',6,struct video_picture)    /* Get picture properties */
284 #define VIDIOCSPICT     _IOW('v',7,struct video_picture)    /* Set picture properties */
285 #define VIDIOCCAPTURE       _IOW('v',8,int)             /* Start, end capture */
286 #define VIDIOCGWIN      _IOR('v',9, struct video_window)    /* Get the video overlay window */
287 #define VIDIOCSWIN      _IOW('v',10, struct video_window)   /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
288 #define VIDIOCGFBUF     _IOR('v',11, struct video_buffer)   /* Get frame buffer */
289 #define VIDIOCSFBUF     _IOW('v',12, struct video_buffer)   /* Set frame buffer - root only */
290 #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) */
291 #define VIDIOCGFREQ     _IOR('v',14, unsigned long)     /* Set tuner */
292 #define VIDIOCSFREQ     _IOW('v',15, unsigned long)     /* Set tuner */
293 #define VIDIOCGAUDIO        _IOR('v',16, struct video_audio)    /* Get audio info */
294 #define VIDIOCSAUDIO        _IOW('v',17, struct video_audio)    /* Audio source, mute etc */
295 #define VIDIOCSYNC      _IOW('v',18, int)           /* Sync with mmap grabbing */
296 #define VIDIOCMCAPTURE      _IOW('v',19, struct video_mmap)     /* Grab frames */
297 #define VIDIOCGMBUF     _IOR('v', 20, struct video_mbuf)    /* Memory map buffer info */
298 #define VIDIOCGUNIT     _IOR('v', 21, struct video_unit)    /* Get attached units */
299 #define VIDIOCGCAPTURE      _IOR('v',22, struct video_capture)  /* Get frame buffer */
300 #define VIDIOCSCAPTURE      _IOW('v',23, struct video_capture)  /* Set frame buffer - root only */
301
302 #define BASE_VIDIOCPRIVATE  192     /* 192-255 are private */
303
304
305 #define VID_HARDWARE_BT848  1
306 #define VID_HARDWARE_QCAM_BW    2
307 #define VID_HARDWARE_PMS    3
308 #define VID_HARDWARE_QCAM_C 4
309 #define VID_HARDWARE_PSEUDO 5
310 #define VID_HARDWARE_SAA5249    6
311 #define VID_HARDWARE_AZTECH 7
312 #define VID_HARDWARE_SF16MI 8
313 #define VID_HARDWARE_RTRACK 9
314 #define VID_HARDWARE_ZOLTRIX    10
315 #define VID_HARDWARE_SAA7146    11
316 #define VID_HARDWARE_VIDEUM 12  /* Reserved for Winnov videum */
317 #define VID_HARDWARE_RTRACK2    13
318 #define VID_HARDWARE_PERMEDIA2  14  /* Reserved for Permedia2 */
319 #define VID_HARDWARE_RIVA128    15  /* Reserved for RIVA 128 */
320 #define VID_HARDWARE_PLANB  16  /* PowerMac motherboard video-in */
321 #define VID_HARDWARE_BROADWAY   17  /* Broadway project */
322 #define VID_HARDWARE_GEMTEK 18
323 #define VID_HARDWARE_TYPHOON    19
324 #define VID_HARDWARE_VINO   20  /* Reserved for SGI Indy Vino */
325 #define VID_HARDWARE_CADET  21  /* Cadet radio */
326 #define VID_HARDWARE_TRUST  22  /* Trust FM Radio */
327
328 /*
329  *  Initialiser list
330  */
331  
332 struct video_init
333 {
334     char *name;
335     int (*init)(struct video_init *);
336 };
337
338 #ifdef __cplusplus
339 }
340 #endif
341
342 #endif