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