ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / videodev.h
1 #ifndef __LINUX_VIDEODEV_H
2 #define __LINUX_VIDEODEV_H
3
4 #include <linux/types.h>
5 #include <linux/version.h>
6
7 #define HAVE_V4L2 1
8 #include <linux/videodev2.h>
9
10 #ifdef __KERNEL__
11
12 #include <linux/poll.h>
13 #include <linux/mm.h>
14 #include <linux/device.h>
15
16 struct video_device
17 {
18         /* device info */
19         struct device *dev;
20         char name[32];
21         int type;       /* v4l1 */
22         int type2;      /* v4l2 */
23         int hardware;
24         int minor;
25
26         /* device ops + callbacks */
27         struct file_operations *fops;
28         void (*release)(struct video_device *vfd);
29
30
31 #if 1 /* to be removed in 2.7.x */
32         /* obsolete -- fops->owner is used instead */
33         struct module *owner;
34         /* dev->driver_data will be used instead some day.
35          * Use the video_{get|set}_drvdata() helper functions,
36          * so the switch over will be transparent for you.
37          * Or use {pci|usb}_{get|set}_drvdata() directly. */
38         void *priv;
39 #endif
40
41         /* for videodev.c intenal usage -- please don't touch */
42         int users;                     /* video_exclusive_{open|close} ... */
43         struct semaphore lock;         /* ... helper function uses these   */
44         char devfs_name[64];           /* devfs */
45         struct class_device class_dev; /* sysfs */
46 };
47
48 #define VIDEO_MAJOR     81
49
50 #define VFL_TYPE_GRABBER        0
51 #define VFL_TYPE_VBI            1
52 #define VFL_TYPE_RADIO          2
53 #define VFL_TYPE_VTX            3
54
55 extern int video_register_device(struct video_device *, int type, int nr);
56 extern void video_unregister_device(struct video_device *);
57 extern struct video_device* video_devdata(struct file*);
58
59 #define to_video_device(cd) container_of(cd, struct video_device, class_dev)
60 static inline void
61 video_device_create_file(struct video_device *vfd,
62                          struct class_device_attribute *attr)
63 {
64         class_device_create_file(&vfd->class_dev, attr);
65 }
66 static inline void
67 video_device_remove_file(struct video_device *vfd,
68                          struct class_device_attribute *attr)
69 {
70         class_device_remove_file(&vfd->class_dev, attr);
71 }
72
73 /* helper functions to alloc / release struct video_device, the
74    later can be used for video_device->release() */
75 struct video_device *video_device_alloc(void);
76 void video_device_release(struct video_device *vfd);
77
78 /* helper functions to access driver private data. */
79 static inline void *video_get_drvdata(struct video_device *dev)
80 {
81         return dev->priv;
82 }
83
84 static inline void video_set_drvdata(struct video_device *dev, void *data)
85 {
86         dev->priv = data;
87 }
88
89 extern int video_exclusive_open(struct inode *inode, struct file *file);
90 extern int video_exclusive_release(struct inode *inode, struct file *file);
91 extern int video_usercopy(struct inode *inode, struct file *file,
92                           unsigned int cmd, unsigned long arg,
93                           int (*func)(struct inode *inode, struct file *file,
94                                       unsigned int cmd, void *arg));
95 #endif /* __KERNEL__ */
96
97 #define VID_TYPE_CAPTURE        1       /* Can capture */
98 #define VID_TYPE_TUNER          2       /* Can tune */
99 #define VID_TYPE_TELETEXT       4       /* Does teletext */
100 #define VID_TYPE_OVERLAY        8       /* Overlay onto frame buffer */
101 #define VID_TYPE_CHROMAKEY      16      /* Overlay by chromakey */
102 #define VID_TYPE_CLIPPING       32      /* Can clip */
103 #define VID_TYPE_FRAMERAM       64      /* Uses the frame buffer memory */
104 #define VID_TYPE_SCALES         128     /* Scalable */
105 #define VID_TYPE_MONOCHROME     256     /* Monochrome only */
106 #define VID_TYPE_SUBCAPTURE     512     /* Can capture subareas of the image */
107 #define VID_TYPE_MPEG_DECODER   1024    /* Can decode MPEG streams */
108 #define VID_TYPE_MPEG_ENCODER   2048    /* Can encode MPEG streams */
109 #define VID_TYPE_MJPEG_DECODER  4096    /* Can decode MJPEG streams */
110 #define VID_TYPE_MJPEG_ENCODER  8192    /* Can encode MJPEG streams */
111
112 struct video_capability
113 {
114         char name[32];
115         int type;
116         int channels;   /* Num channels */
117         int audios;     /* Num audio devices */
118         int maxwidth;   /* Supported width */
119         int maxheight;  /* And height */
120         int minwidth;   /* Supported width */
121         int minheight;  /* And height */
122 };
123
124
125 struct video_channel
126 {
127         int channel;
128         char name[32];
129         int tuners;
130         __u32  flags;
131 #define VIDEO_VC_TUNER          1       /* Channel has a tuner */
132 #define VIDEO_VC_AUDIO          2       /* Channel has audio */
133         __u16  type;
134 #define VIDEO_TYPE_TV           1
135 #define VIDEO_TYPE_CAMERA       2       
136         __u16 norm;                     /* Norm set by channel */
137 };
138
139 struct video_tuner
140 {
141         int tuner;
142         char name[32];
143         unsigned long rangelow, rangehigh;      /* Tuner range */
144         __u32 flags;
145 #define VIDEO_TUNER_PAL         1
146 #define VIDEO_TUNER_NTSC        2
147 #define VIDEO_TUNER_SECAM       4
148 #define VIDEO_TUNER_LOW         8       /* Uses KHz not MHz */
149 #define VIDEO_TUNER_NORM        16      /* Tuner can set norm */
150 #define VIDEO_TUNER_STEREO_ON   128     /* Tuner is seeing stereo */
151 #define VIDEO_TUNER_RDS_ON      256     /* Tuner is seeing an RDS datastream */
152 #define VIDEO_TUNER_MBS_ON      512     /* Tuner is seeing an MBS datastream */
153         __u16 mode;                     /* PAL/NTSC/SECAM/OTHER */
154 #define VIDEO_MODE_PAL          0
155 #define VIDEO_MODE_NTSC         1
156 #define VIDEO_MODE_SECAM        2
157 #define VIDEO_MODE_AUTO         3
158         __u16 signal;                   /* Signal strength 16bit scale */
159 };
160
161 struct video_picture
162 {
163         __u16   brightness;
164         __u16   hue;
165         __u16   colour;
166         __u16   contrast;
167         __u16   whiteness;      /* Black and white only */
168         __u16   depth;          /* Capture depth */
169         __u16   palette;        /* Palette in use */
170 #define VIDEO_PALETTE_GREY      1       /* Linear greyscale */
171 #define VIDEO_PALETTE_HI240     2       /* High 240 cube (BT848) */
172 #define VIDEO_PALETTE_RGB565    3       /* 565 16 bit RGB */
173 #define VIDEO_PALETTE_RGB24     4       /* 24bit RGB */
174 #define VIDEO_PALETTE_RGB32     5       /* 32bit RGB */ 
175 #define VIDEO_PALETTE_RGB555    6       /* 555 15bit RGB */
176 #define VIDEO_PALETTE_YUV422    7       /* YUV422 capture */
177 #define VIDEO_PALETTE_YUYV      8
178 #define VIDEO_PALETTE_UYVY      9       /* The great thing about standards is ... */
179 #define VIDEO_PALETTE_YUV420    10
180 #define VIDEO_PALETTE_YUV411    11      /* YUV411 capture */
181 #define VIDEO_PALETTE_RAW       12      /* RAW capture (BT848) */
182 #define VIDEO_PALETTE_YUV422P   13      /* YUV 4:2:2 Planar */
183 #define VIDEO_PALETTE_YUV411P   14      /* YUV 4:1:1 Planar */
184 #define VIDEO_PALETTE_YUV420P   15      /* YUV 4:2:0 Planar */
185 #define VIDEO_PALETTE_YUV410P   16      /* YUV 4:1:0 Planar */
186 #define VIDEO_PALETTE_PLANAR    13      /* start of planar entries */
187 #define VIDEO_PALETTE_COMPONENT 7       /* start of component entries */
188 };
189
190 struct video_audio
191 {
192         int     audio;          /* Audio channel */
193         __u16   volume;         /* If settable */
194         __u16   bass, treble;
195         __u32   flags;
196 #define VIDEO_AUDIO_MUTE        1
197 #define VIDEO_AUDIO_MUTABLE     2
198 #define VIDEO_AUDIO_VOLUME      4
199 #define VIDEO_AUDIO_BASS        8
200 #define VIDEO_AUDIO_TREBLE      16      
201 #define VIDEO_AUDIO_BALANCE     32
202         char    name[16];
203 #define VIDEO_SOUND_MONO        1
204 #define VIDEO_SOUND_STEREO      2
205 #define VIDEO_SOUND_LANG1       4
206 #define VIDEO_SOUND_LANG2       8
207         __u16   mode;
208         __u16   balance;        /* Stereo balance */
209         __u16   step;           /* Step actual volume uses */
210 };
211
212 struct video_clip
213 {
214         __s32   x,y;
215         __s32   width, height;
216         struct  video_clip *next;       /* For user use/driver use only */
217 };
218
219 struct video_window
220 {
221         __u32   x,y;                    /* Position of window */
222         __u32   width,height;           /* Its size */
223         __u32   chromakey;
224         __u32   flags;
225         struct  video_clip *clips;      /* Set only */
226         int     clipcount;
227 #define VIDEO_WINDOW_INTERLACE  1
228 #define VIDEO_WINDOW_CHROMAKEY  16      /* Overlay by chromakey */
229 #define VIDEO_CLIP_BITMAP       -1
230 /* bitmap is 1024x625, a '1' bit represents a clipped pixel */
231 #define VIDEO_CLIPMAP_SIZE      (128 * 625)
232 };
233
234 struct video_capture
235 {
236         __u32   x,y;                    /* Offsets into image */
237         __u32   width, height;          /* Area to capture */
238         __u16   decimation;             /* Decimation divider */
239         __u16   flags;                  /* Flags for capture */
240 #define VIDEO_CAPTURE_ODD               0       /* Temporal */
241 #define VIDEO_CAPTURE_EVEN              1
242 };
243
244 struct video_buffer
245 {
246         void    *base;
247         int     height,width;
248         int     depth;
249         int     bytesperline;
250 };
251
252 struct video_mmap
253 {
254         unsigned        int frame;              /* Frame (0 - n) for double buffer */
255         int             height,width;
256         unsigned        int format;             /* should be VIDEO_PALETTE_* */
257 };
258
259 struct video_key
260 {
261         __u8    key[8];
262         __u32   flags;
263 };
264
265
266 #define VIDEO_MAX_FRAME         32
267
268 struct video_mbuf
269 {
270         int     size;           /* Total memory to map */
271         int     frames;         /* Frames */
272         int     offsets[VIDEO_MAX_FRAME];
273 };
274         
275
276 #define         VIDEO_NO_UNIT   (-1)
277
278         
279 struct video_unit
280 {
281         int     video;          /* Video minor */
282         int     vbi;            /* VBI minor */
283         int     radio;          /* Radio minor */
284         int     audio;          /* Audio minor */
285         int     teletext;       /* Teletext minor */
286 };
287
288 struct vbi_format {
289         __u32   sampling_rate;  /* in Hz */
290         __u32   samples_per_line;
291         __u32   sample_format;  /* VIDEO_PALETTE_RAW only (1 byte) */
292         __s32   start[2];       /* starting line for each frame */
293         __u32   count[2];       /* count of lines for each frame */
294         __u32   flags;
295 #define VBI_UNSYNC      1       /* can distingues between top/bottom field */
296 #define VBI_INTERLACED  2       /* lines are interlaced */
297 };
298
299 /* video_info is biased towards hardware mpeg encode/decode */
300 /* but it could apply generically to any hardware compressor/decompressor */
301 struct video_info
302 {
303         __u32   frame_count;    /* frames output since decode/encode began */
304         __u32   h_size;         /* current unscaled horizontal size */
305         __u32   v_size;         /* current unscaled veritcal size */
306         __u32   smpte_timecode; /* current SMPTE timecode (for current GOP) */
307         __u32   picture_type;   /* current picture type */
308         __u32   temporal_reference;     /* current temporal reference */
309         __u8    user_data[256]; /* user data last found in compressed stream */
310         /* user_data[0] contains user data flags, user_data[1] has count */
311 };
312
313 /* generic structure for setting playback modes */
314 struct video_play_mode
315 {
316         int     mode;
317         int     p1;
318         int     p2;
319 };
320
321 /* for loading microcode / fpga programming */
322 struct video_code
323 {
324         char    loadwhat[16];   /* name or tag of file being passed */
325         int     datasize;
326         __u8    *data;
327 };
328
329 #define VIDIOCGCAP              _IOR('v',1,struct video_capability)     /* Get capabilities */
330 #define VIDIOCGCHAN             _IOWR('v',2,struct video_channel)       /* Get channel info (sources) */
331 #define VIDIOCSCHAN             _IOW('v',3,struct video_channel)        /* Set channel  */
332 #define VIDIOCGTUNER            _IOWR('v',4,struct video_tuner)         /* Get tuner abilities */
333 #define VIDIOCSTUNER            _IOW('v',5,struct video_tuner)          /* Tune the tuner for the current channel */
334 #define VIDIOCGPICT             _IOR('v',6,struct video_picture)        /* Get picture properties */
335 #define VIDIOCSPICT             _IOW('v',7,struct video_picture)        /* Set picture properties */
336 #define VIDIOCCAPTURE           _IOW('v',8,int)                         /* Start, end capture */
337 #define VIDIOCGWIN              _IOR('v',9, struct video_window)        /* Get the video overlay window */
338 #define VIDIOCSWIN              _IOW('v',10, struct video_window)       /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
339 #define VIDIOCGFBUF             _IOR('v',11, struct video_buffer)       /* Get frame buffer */
340 #define VIDIOCSFBUF             _IOW('v',12, struct video_buffer)       /* Set frame buffer - root only */
341 #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) */
342 #define VIDIOCGFREQ             _IOR('v',14, unsigned long)             /* Set tuner */
343 #define VIDIOCSFREQ             _IOW('v',15, unsigned long)             /* Set tuner */
344 #define VIDIOCGAUDIO            _IOR('v',16, struct video_audio)        /* Get audio info */
345 #define VIDIOCSAUDIO            _IOW('v',17, struct video_audio)        /* Audio source, mute etc */
346 #define VIDIOCSYNC              _IOW('v',18, int)                       /* Sync with mmap grabbing */
347 #define VIDIOCMCAPTURE          _IOW('v',19, struct video_mmap)         /* Grab frames */
348 #define VIDIOCGMBUF             _IOR('v',20, struct video_mbuf)         /* Memory map buffer info */
349 #define VIDIOCGUNIT             _IOR('v',21, struct video_unit)         /* Get attached units */
350 #define VIDIOCGCAPTURE          _IOR('v',22, struct video_capture)      /* Get subcapture */
351 #define VIDIOCSCAPTURE          _IOW('v',23, struct video_capture)      /* Set subcapture */
352 #define VIDIOCSPLAYMODE         _IOW('v',24, struct video_play_mode)    /* Set output video mode/feature */
353 #define VIDIOCSWRITEMODE        _IOW('v',25, int)                       /* Set write mode */
354 #define VIDIOCGPLAYINFO         _IOR('v',26, struct video_info)         /* Get current playback info from hardware */
355 #define VIDIOCSMICROCODE        _IOW('v',27, struct video_code)         /* Load microcode into hardware */
356 #define VIDIOCGVBIFMT           _IOR('v',28, struct vbi_format)         /* Get VBI information */
357 #define VIDIOCSVBIFMT           _IOW('v',29, struct vbi_format)         /* Set VBI information */
358
359
360 #define BASE_VIDIOCPRIVATE      192             /* 192-255 are private */
361
362 /* VIDIOCSWRITEMODE */
363 #define VID_WRITE_MPEG_AUD              0
364 #define VID_WRITE_MPEG_VID              1
365 #define VID_WRITE_OSD                   2
366 #define VID_WRITE_TTX                   3
367 #define VID_WRITE_CC                    4
368 #define VID_WRITE_MJPEG                 5
369
370 /* VIDIOCSPLAYMODE */
371 #define VID_PLAY_VID_OUT_MODE           0
372         /* p1: = VIDEO_MODE_PAL, VIDEO_MODE_NTSC, etc ... */
373 #define VID_PLAY_GENLOCK                1
374         /* p1: 0 = OFF, 1 = ON */
375         /* p2: GENLOCK FINE DELAY value */ 
376 #define VID_PLAY_NORMAL                 2
377 #define VID_PLAY_PAUSE                  3
378 #define VID_PLAY_SINGLE_FRAME           4
379 #define VID_PLAY_FAST_FORWARD           5
380 #define VID_PLAY_SLOW_MOTION            6
381 #define VID_PLAY_IMMEDIATE_NORMAL       7
382 #define VID_PLAY_SWITCH_CHANNELS        8
383 #define VID_PLAY_FREEZE_FRAME           9
384 #define VID_PLAY_STILL_MODE             10
385 #define VID_PLAY_MASTER_MODE            11
386         /* p1: see below */
387 #define         VID_PLAY_MASTER_NONE    1
388 #define         VID_PLAY_MASTER_VIDEO   2
389 #define         VID_PLAY_MASTER_AUDIO   3
390 #define VID_PLAY_ACTIVE_SCANLINES       12
391         /* p1 = first active; p2 = last active */
392 #define VID_PLAY_RESET                  13
393 #define VID_PLAY_END_MARK               14
394
395
396
397 #define VID_HARDWARE_BT848      1
398 #define VID_HARDWARE_QCAM_BW    2
399 #define VID_HARDWARE_PMS        3
400 #define VID_HARDWARE_QCAM_C     4
401 #define VID_HARDWARE_PSEUDO     5
402 #define VID_HARDWARE_SAA5249    6
403 #define VID_HARDWARE_AZTECH     7
404 #define VID_HARDWARE_SF16MI     8
405 #define VID_HARDWARE_RTRACK     9
406 #define VID_HARDWARE_ZOLTRIX    10
407 #define VID_HARDWARE_SAA7146    11
408 #define VID_HARDWARE_VIDEUM     12      /* Reserved for Winnov videum */
409 #define VID_HARDWARE_RTRACK2    13
410 #define VID_HARDWARE_PERMEDIA2  14      /* Reserved for Permedia2 */
411 #define VID_HARDWARE_RIVA128    15      /* Reserved for RIVA 128 */
412 #define VID_HARDWARE_PLANB      16      /* PowerMac motherboard video-in */
413 #define VID_HARDWARE_BROADWAY   17      /* Broadway project */
414 #define VID_HARDWARE_GEMTEK     18
415 #define VID_HARDWARE_TYPHOON    19
416 #define VID_HARDWARE_VINO       20      /* SGI Indy Vino */
417 #define VID_HARDWARE_CADET      21      /* Cadet radio */
418 #define VID_HARDWARE_TRUST      22      /* Trust FM Radio */
419 #define VID_HARDWARE_TERRATEC   23      /* TerraTec ActiveRadio */
420 #define VID_HARDWARE_CPIA       24
421 #define VID_HARDWARE_ZR36120    25      /* Zoran ZR36120/ZR36125 */
422 #define VID_HARDWARE_ZR36067    26      /* Zoran ZR36067/36060 */
423 #define VID_HARDWARE_OV511      27      
424 #define VID_HARDWARE_ZR356700   28      /* Zoran 36700 series */
425 #define VID_HARDWARE_W9966      29
426 #define VID_HARDWARE_SE401      30      /* SE401 USB webcams */
427 #define VID_HARDWARE_PWC        31      /* Philips webcams */
428 #define VID_HARDWARE_MEYE       32      /* Sony Vaio MotionEye cameras */
429 #define VID_HARDWARE_CPIA2      33
430 #define VID_HARDWARE_VICAM      34
431 #define VID_HARDWARE_SF16FMR2   35
432 #define VID_HARDWARE_W9968CF    36
433 #define VID_HARDWARE_SAA7114H   37
434 #endif /* __LINUX_VIDEODEV_H */
435
436 /*
437  * Local variables:
438  * c-basic-offset: 8
439  * End:
440  */