diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-04 09:06:18 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-25 01:05:04 -0400 |
commit | 401998fa96fe18b057af3f906527196522dd2d9d (patch) | |
tree | 32d656e18410ab05204c83b57969db23665e4fe9 | |
parent | 7565ab082de88ec274283d6b83980144e520a2fc (diff) |
V4L/DVB (4065): Several improvements at videodev.c
Videodev now is capable of better handling V4L2 api, by
processing V4L2 ioctls and using callbacks to the driver.
The drivers should be migrated to the newer way and the older
one will be obsoleted soon.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/video/cx88/cx88.h | 1 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 1 | ||||
-rw-r--r-- | drivers/media/video/v4l2-common.c | 13 | ||||
-rw-r--r-- | drivers/media/video/videodev.c | 1172 | ||||
-rw-r--r-- | include/linux/videodev.h | 58 | ||||
-rw-r--r-- | include/linux/videodev2.h | 135 | ||||
-rw-r--r-- | include/media/v4l2-common.h | 6 | ||||
-rw-r--r-- | include/media/v4l2-dev.h | 371 | ||||
-rw-r--r-- | include/media/video-buf.h | 1 |
9 files changed, 1579 insertions, 179 deletions
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 46a21f8f79ef..b9501295a416 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/videodev2.h> | 25 | #include <linux/videodev2.h> |
26 | #include <linux/kdev_t.h> | 26 | #include <linux/kdev_t.h> |
27 | 27 | ||
28 | #include <media/v4l2-common.h> | ||
28 | #include <media/tuner.h> | 29 | #include <media/tuner.h> |
29 | #include <media/tveeprom.h> | 30 | #include <media/tveeprom.h> |
30 | #include <media/video-buf.h> | 31 | #include <media/video-buf.h> |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 9048d2c29899..6cba6c1ef584 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -33,6 +33,7 @@ | |||
33 | 33 | ||
34 | #include <asm/io.h> | 34 | #include <asm/io.h> |
35 | 35 | ||
36 | #include <media/v4l2-common.h> | ||
36 | #include <media/tuner.h> | 37 | #include <media/tuner.h> |
37 | #include <media/ir-common.h> | 38 | #include <media/ir-common.h> |
38 | #include <media/ir-kbd-i2c.h> | 39 | #include <media/ir-kbd-i2c.h> |
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index ad92e07e74f7..bffe48275eb0 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -59,6 +59,7 @@ | |||
59 | #include <asm/io.h> | 59 | #include <asm/io.h> |
60 | #include <asm/div64.h> | 60 | #include <asm/div64.h> |
61 | #include <linux/video_decoder.h> | 61 | #include <linux/video_decoder.h> |
62 | #define __OLD_VIDIOC_ /* To allow fixing old calls*/ | ||
62 | #include <media/v4l2-common.h> | 63 | #include <media/v4l2-common.h> |
63 | 64 | ||
64 | #ifdef CONFIG_KMOD | 65 | #ifdef CONFIG_KMOD |
@@ -424,7 +425,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg) | |||
424 | case TUNER_SET_TYPE_ADDR: | 425 | case TUNER_SET_TYPE_ADDR: |
425 | case TUNER_SET_STANDBY: | 426 | case TUNER_SET_STANDBY: |
426 | case TDA9887_SET_CONFIG: | 427 | case TDA9887_SET_CONFIG: |
428 | #ifdef __OLD_VIDIOC_ | ||
427 | case VIDIOC_OVERLAY_OLD: | 429 | case VIDIOC_OVERLAY_OLD: |
430 | #endif | ||
428 | case VIDIOC_STREAMOFF: | 431 | case VIDIOC_STREAMOFF: |
429 | case VIDIOC_G_OUTPUT: | 432 | case VIDIOC_G_OUTPUT: |
430 | case VIDIOC_S_OUTPUT: | 433 | case VIDIOC_S_OUTPUT: |
@@ -440,7 +443,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg) | |||
440 | case VIDIOC_G_AUDIO: | 443 | case VIDIOC_G_AUDIO: |
441 | case VIDIOC_S_AUDIO: | 444 | case VIDIOC_S_AUDIO: |
442 | case VIDIOC_ENUMAUDIO: | 445 | case VIDIOC_ENUMAUDIO: |
446 | #ifdef __OLD_VIDIOC_ | ||
443 | case VIDIOC_G_AUDIO_OLD: | 447 | case VIDIOC_G_AUDIO_OLD: |
448 | #endif | ||
444 | { | 449 | { |
445 | struct v4l2_audio *p=arg; | 450 | struct v4l2_audio *p=arg; |
446 | 451 | ||
@@ -451,7 +456,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg) | |||
451 | case VIDIOC_G_AUDOUT: | 456 | case VIDIOC_G_AUDOUT: |
452 | case VIDIOC_S_AUDOUT: | 457 | case VIDIOC_S_AUDOUT: |
453 | case VIDIOC_ENUMAUDOUT: | 458 | case VIDIOC_ENUMAUDOUT: |
459 | #ifdef __OLD_VIDIOC_ | ||
454 | case VIDIOC_G_AUDOUT_OLD: | 460 | case VIDIOC_G_AUDOUT_OLD: |
461 | #endif | ||
455 | { | 462 | { |
456 | struct v4l2_audioout *p=arg; | 463 | struct v4l2_audioout *p=arg; |
457 | printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n", s, | 464 | printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n", s, |
@@ -496,7 +503,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg) | |||
496 | } | 503 | } |
497 | case VIDIOC_G_CTRL: | 504 | case VIDIOC_G_CTRL: |
498 | case VIDIOC_S_CTRL: | 505 | case VIDIOC_S_CTRL: |
506 | #ifdef __OLD_VIDIOC_ | ||
499 | case VIDIOC_S_CTRL_OLD: | 507 | case VIDIOC_S_CTRL_OLD: |
508 | #endif | ||
500 | { | 509 | { |
501 | struct v4l2_control *p=arg; | 510 | struct v4l2_control *p=arg; |
502 | printk ("%s: id=%d, value=%d\n", s, p->id, p->value); | 511 | printk ("%s: id=%d, value=%d\n", s, p->id, p->value); |
@@ -511,7 +520,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg) | |||
511 | break; | 520 | break; |
512 | } | 521 | } |
513 | case VIDIOC_CROPCAP: | 522 | case VIDIOC_CROPCAP: |
523 | #ifdef __OLD_VIDIOC_ | ||
514 | case VIDIOC_CROPCAP_OLD: | 524 | case VIDIOC_CROPCAP_OLD: |
525 | #endif | ||
515 | { | 526 | { |
516 | struct v4l2_cropcap *p=arg; | 527 | struct v4l2_cropcap *p=arg; |
517 | /*FIXME: Should also show rect structs */ | 528 | /*FIXME: Should also show rect structs */ |
@@ -703,7 +714,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg) | |||
703 | } | 714 | } |
704 | case VIDIOC_G_PARM: | 715 | case VIDIOC_G_PARM: |
705 | case VIDIOC_S_PARM: | 716 | case VIDIOC_S_PARM: |
717 | #ifdef __OLD_VIDIOC_ | ||
706 | case VIDIOC_S_PARM_OLD: | 718 | case VIDIOC_S_PARM_OLD: |
719 | #endif | ||
707 | { | 720 | { |
708 | struct v4l2_streamparm *p=arg; | 721 | struct v4l2_streamparm *p=arg; |
709 | printk ("%s: type=%d\n", s, p->type); | 722 | printk ("%s: type=%d\n", s, p->type); |
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 5f87dd5f1d0b..3f7a94b80c63 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -1,20 +1,31 @@ | |||
1 | /* | 1 | /* |
2 | * Video capture interface for Linux | 2 | * Video capture interface for Linux version 2 |
3 | * | 3 | * |
4 | * A generic video device interface for the LINUX operating system | 4 | * A generic video device interface for the LINUX operating system |
5 | * using a set of device structures/vectors for low level operations. | 5 | * using a set of device structures/vectors for low level operations. |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
9 | * as published by the Free Software Foundation; either version | 9 | * as published by the Free Software Foundation; either version |
10 | * 2 of the License, or (at your option) any later version. | 10 | * 2 of the License, or (at your option) any later version. |
11 | * | 11 | * |
12 | * Author: Alan Cox, <alan@redhat.com> | 12 | * Authors: Alan Cox, <alan@redhat.com> (version 1) |
13 | * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2) | ||
13 | * | 14 | * |
14 | * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com> | 15 | * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com> |
15 | * - Added procfs support | 16 | * - Added procfs support |
16 | */ | 17 | */ |
17 | 18 | ||
19 | #define dbgarg(cmd, fmt, arg...) \ | ||
20 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ | ||
21 | printk (KERN_DEBUG "%s: ", vfd->name); \ | ||
22 | v4l_printk_ioctl(cmd); \ | ||
23 | printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); | ||
24 | |||
25 | #define dbgarg2(fmt, arg...) \ | ||
26 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ | ||
27 | printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); | ||
28 | |||
18 | #include <linux/module.h> | 29 | #include <linux/module.h> |
19 | #include <linux/types.h> | 30 | #include <linux/types.h> |
20 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
@@ -30,7 +41,13 @@ | |||
30 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
31 | #include <asm/system.h> | 42 | #include <asm/system.h> |
32 | 43 | ||
44 | #define __OLD_VIDIOC_ /* To allow fixing old calls*/ | ||
45 | #include <linux/videodev2.h> | ||
46 | |||
47 | #ifdef CONFIG_VIDEO_V4L1 | ||
33 | #include <linux/videodev.h> | 48 | #include <linux/videodev.h> |
49 | #endif | ||
50 | #include <media/v4l2-common.h> | ||
34 | 51 | ||
35 | #define VIDEO_NUM_DEVICES 256 | 52 | #define VIDEO_NUM_DEVICES 256 |
36 | #define VIDEO_NAME "video4linux" | 53 | #define VIDEO_NAME "video4linux" |
@@ -41,7 +58,8 @@ | |||
41 | 58 | ||
42 | static ssize_t show_name(struct class_device *cd, char *buf) | 59 | static ssize_t show_name(struct class_device *cd, char *buf) |
43 | { | 60 | { |
44 | struct video_device *vfd = container_of(cd, struct video_device, class_dev); | 61 | struct video_device *vfd = container_of(cd, struct video_device, |
62 | class_dev); | ||
45 | return sprintf(buf,"%.*s\n",(int)sizeof(vfd->name),vfd->name); | 63 | return sprintf(buf,"%.*s\n",(int)sizeof(vfd->name),vfd->name); |
46 | } | 64 | } |
47 | 65 | ||
@@ -62,7 +80,8 @@ void video_device_release(struct video_device *vfd) | |||
62 | 80 | ||
63 | static void video_release(struct class_device *cd) | 81 | static void video_release(struct class_device *cd) |
64 | { | 82 | { |
65 | struct video_device *vfd = container_of(cd, struct video_device, class_dev); | 83 | struct video_device *vfd = container_of(cd, struct video_device, |
84 | class_dev); | ||
66 | 85 | ||
67 | #if 1 | 86 | #if 1 |
68 | /* needed until all drivers are fixed */ | 87 | /* needed until all drivers are fixed */ |
@@ -90,7 +109,7 @@ struct video_device* video_devdata(struct file *file) | |||
90 | } | 109 | } |
91 | 110 | ||
92 | /* | 111 | /* |
93 | * Open a video device. | 112 | * Open a video device - FIXME: Obsoleted |
94 | */ | 113 | */ |
95 | static int video_open(struct inode *inode, struct file *file) | 114 | static int video_open(struct inode *inode, struct file *file) |
96 | { | 115 | { |
@@ -130,6 +149,7 @@ static int video_open(struct inode *inode, struct file *file) | |||
130 | * helper function -- handles userspace copying for ioctl arguments | 149 | * helper function -- handles userspace copying for ioctl arguments |
131 | */ | 150 | */ |
132 | 151 | ||
152 | #ifdef __OLD_VIDIOC_ | ||
133 | static unsigned int | 153 | static unsigned int |
134 | video_fix_command(unsigned int cmd) | 154 | video_fix_command(unsigned int cmd) |
135 | { | 155 | { |
@@ -155,7 +175,11 @@ video_fix_command(unsigned int cmd) | |||
155 | } | 175 | } |
156 | return cmd; | 176 | return cmd; |
157 | } | 177 | } |
178 | #endif | ||
158 | 179 | ||
180 | /* | ||
181 | * Obsolete usercopy function - Should be removed soon | ||
182 | */ | ||
159 | int | 183 | int |
160 | video_usercopy(struct inode *inode, struct file *file, | 184 | video_usercopy(struct inode *inode, struct file *file, |
161 | unsigned int cmd, unsigned long arg, | 185 | unsigned int cmd, unsigned long arg, |
@@ -167,7 +191,9 @@ video_usercopy(struct inode *inode, struct file *file, | |||
167 | void *parg = NULL; | 191 | void *parg = NULL; |
168 | int err = -EINVAL; | 192 | int err = -EINVAL; |
169 | 193 | ||
194 | #ifdef __OLD_VIDIOC_ | ||
170 | cmd = video_fix_command(cmd); | 195 | cmd = video_fix_command(cmd); |
196 | #endif | ||
171 | 197 | ||
172 | /* Copy arguments into temp kernel buffer */ | 198 | /* Copy arguments into temp kernel buffer */ |
173 | switch (_IOC_DIR(cmd)) { | 199 | switch (_IOC_DIR(cmd)) { |
@@ -189,7 +215,8 @@ video_usercopy(struct inode *inode, struct file *file, | |||
189 | 215 | ||
190 | err = -EFAULT; | 216 | err = -EFAULT; |
191 | if (_IOC_DIR(cmd) & _IOC_WRITE) | 217 | if (_IOC_DIR(cmd) & _IOC_WRITE) |
192 | if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) | 218 | if (copy_from_user(parg, (void __user *)arg, |
219 | _IOC_SIZE(cmd))) | ||
193 | goto out; | 220 | goto out; |
194 | break; | 221 | break; |
195 | } | 222 | } |
@@ -218,6 +245,7 @@ out: | |||
218 | 245 | ||
219 | /* | 246 | /* |
220 | * open/release helper functions -- handle exclusive opens | 247 | * open/release helper functions -- handle exclusive opens |
248 | * Should be removed soon | ||
221 | */ | 249 | */ |
222 | int video_exclusive_open(struct inode *inode, struct file *file) | 250 | int video_exclusive_open(struct inode *inode, struct file *file) |
223 | { | 251 | { |
@@ -242,6 +270,1115 @@ int video_exclusive_release(struct inode *inode, struct file *file) | |||
242 | return 0; | 270 | return 0; |
243 | } | 271 | } |
244 | 272 | ||
273 | static char *v4l2_memory_names[] = { | ||
274 | [V4L2_MEMORY_MMAP] = "mmap", | ||
275 | [V4L2_MEMORY_USERPTR] = "userptr", | ||
276 | [V4L2_MEMORY_OVERLAY] = "overlay", | ||
277 | }; | ||
278 | |||
279 | |||
280 | /* FIXME: Those stuff are replicated also on v4l2-common.c */ | ||
281 | static char *v4l2_type_names_FIXME[] = { | ||
282 | [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap", | ||
283 | [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over", | ||
284 | [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out", | ||
285 | [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap", | ||
286 | [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out", | ||
287 | [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out", | ||
288 | [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-capture", | ||
289 | [V4L2_BUF_TYPE_PRIVATE] = "private", | ||
290 | }; | ||
291 | |||
292 | static char *v4l2_field_names_FIXME[] = { | ||
293 | [V4L2_FIELD_ANY] = "any", | ||
294 | [V4L2_FIELD_NONE] = "none", | ||
295 | [V4L2_FIELD_TOP] = "top", | ||
296 | [V4L2_FIELD_BOTTOM] = "bottom", | ||
297 | [V4L2_FIELD_INTERLACED] = "interlaced", | ||
298 | [V4L2_FIELD_SEQ_TB] = "seq-tb", | ||
299 | [V4L2_FIELD_SEQ_BT] = "seq-bt", | ||
300 | [V4L2_FIELD_ALTERNATE] = "alternate", | ||
301 | }; | ||
302 | |||
303 | #define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown" | ||
304 | |||
305 | static void dbgbuf(unsigned int cmd, struct video_device *vfd, | ||
306 | struct v4l2_buffer *p) | ||
307 | { | ||
308 | struct v4l2_timecode *tc=&p->timecode; | ||
309 | |||
310 | dbgarg (cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, " | ||
311 | "bytesused=%d, flags=0x%08d, " | ||
312 | "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx\n", | ||
313 | (p->timestamp.tv_sec/3600), | ||
314 | (int)(p->timestamp.tv_sec/60)%60, | ||
315 | (int)(p->timestamp.tv_sec%60), | ||
316 | p->timestamp.tv_usec, | ||
317 | p->index, | ||
318 | prt_names(p->type,v4l2_type_names_FIXME), | ||
319 | p->bytesused,p->flags, | ||
320 | p->field,p->sequence, | ||
321 | prt_names(p->memory,v4l2_memory_names), | ||
322 | p->m.userptr); | ||
323 | dbgarg2 ("timecode= %02d:%02d:%02d type=%d, " | ||
324 | "flags=0x%08d, frames=%d, userbits=0x%08x\n", | ||
325 | tc->hours,tc->minutes,tc->seconds, | ||
326 | tc->type, tc->flags, tc->frames, (__u32) tc->userbits); | ||
327 | } | ||
328 | |||
329 | static inline void dbgrect(struct video_device *vfd, char *s, | ||
330 | struct v4l2_rect *r) | ||
331 | { | ||
332 | dbgarg2 ("%sRect start at %dx%d, size= %dx%d\n", s, r->left, r->top, | ||
333 | r->width, r->height); | ||
334 | }; | ||
335 | |||
336 | static inline void v4l_print_pix_fmt (struct video_device *vfd, | ||
337 | struct v4l2_pix_format *fmt) | ||
338 | { | ||
339 | dbgarg2 ("width=%d, height=%d, format=0x%08x, field=%s, " | ||
340 | "bytesperline=%d sizeimage=%d, colorspace=%d\n", | ||
341 | fmt->width,fmt->height,fmt->pixelformat, | ||
342 | prt_names(fmt->field,v4l2_field_names_FIXME), | ||
343 | fmt->bytesperline,fmt->sizeimage,fmt->colorspace); | ||
344 | }; | ||
345 | |||
346 | |||
347 | static int check_fmt (struct video_device *vfd, enum v4l2_buf_type type) | ||
348 | { | ||
349 | switch (type) { | ||
350 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
351 | if (vfd->vidioc_try_fmt_cap) | ||
352 | return (0); | ||
353 | break; | ||
354 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
355 | if (vfd->vidioc_try_fmt_overlay) | ||
356 | return (0); | ||
357 | break; | ||
358 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
359 | if (vfd->vidioc_try_fmt_vbi) | ||
360 | return (0); | ||
361 | break; | ||
362 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | ||
363 | if (vfd->vidioc_try_fmt_vbi_output) | ||
364 | return (0); | ||
365 | break; | ||
366 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | ||
367 | if (vfd->vidioc_try_fmt_vbi_capture) | ||
368 | return (0); | ||
369 | break; | ||
370 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | ||
371 | if (vfd->vidioc_try_fmt_video_output) | ||
372 | return (0); | ||
373 | break; | ||
374 | case V4L2_BUF_TYPE_VBI_OUTPUT: | ||
375 | if (vfd->vidioc_try_fmt_vbi_output) | ||
376 | return (0); | ||
377 | break; | ||
378 | case V4L2_BUF_TYPE_PRIVATE: | ||
379 | if (vfd->vidioc_try_fmt_type_private) | ||
380 | return (0); | ||
381 | break; | ||
382 | } | ||
383 | return (-EINVAL); | ||
384 | } | ||
385 | |||
386 | static int __video_do_ioctl(struct inode *inode, struct file *file, | ||
387 | unsigned int cmd, void *arg) | ||
388 | { | ||
389 | struct video_device *vfd = video_devdata(file); | ||
390 | void *fh = file->private_data; | ||
391 | int ret = -EINVAL; | ||
392 | |||
393 | if ( (vfd->debug & V4L2_DEBUG_IOCTL) && | ||
394 | !(vfd->debug | V4L2_DEBUG_IOCTL_ARG)) { | ||
395 | v4l_print_ioctl(vfd->name, cmd); | ||
396 | } | ||
397 | |||
398 | switch(cmd) { | ||
399 | /* --- capabilities ------------------------------------------ */ | ||
400 | case VIDIOC_QUERYCAP: | ||
401 | { | ||
402 | struct v4l2_capability *cap = (struct v4l2_capability*)arg; | ||
403 | memset(cap, 0, sizeof(*cap)); | ||
404 | |||
405 | if (!vfd->vidioc_querycap) | ||
406 | break; | ||
407 | |||
408 | ret=vfd->vidioc_querycap(file, fh, cap); | ||
409 | if (!ret) | ||
410 | dbgarg (cmd, "driver=%s, card=%s, bus=%s, " | ||
411 | "version=0x%08x, " | ||
412 | "capabilities=0x%08x\n", | ||
413 | cap->driver,cap->card,cap->bus_info, | ||
414 | cap->version, | ||
415 | cap->capabilities); | ||
416 | break; | ||
417 | } | ||
418 | |||
419 | /* --- priority ------------------------------------------ */ | ||
420 | case VIDIOC_G_PRIORITY: | ||
421 | { | ||
422 | enum v4l2_priority *p=arg; | ||
423 | |||
424 | if (!vfd->vidioc_g_priority) | ||
425 | break; | ||
426 | ret=vfd->vidioc_g_priority(file, fh, p); | ||
427 | if (!ret) | ||
428 | dbgarg(cmd, "priority is %d\n", *p); | ||
429 | break; | ||
430 | } | ||
431 | case VIDIOC_S_PRIORITY: | ||
432 | { | ||
433 | enum v4l2_priority *p=arg; | ||
434 | |||
435 | if (!vfd->vidioc_s_priority) | ||
436 | break; | ||
437 | dbgarg(cmd, "setting priority to %d\n", *p); | ||
438 | ret=vfd->vidioc_s_priority(file, fh, *p); | ||
439 | break; | ||
440 | } | ||
441 | |||
442 | /* --- capture ioctls ---------------------------------------- */ | ||
443 | case VIDIOC_ENUM_FMT: | ||
444 | { | ||
445 | struct v4l2_fmtdesc *f = arg; | ||
446 | enum v4l2_buf_type type; | ||
447 | unsigned int index; | ||
448 | |||
449 | index = f->index; | ||
450 | type = f->type; | ||
451 | memset(f,0,sizeof(*f)); | ||
452 | f->index = index; | ||
453 | f->type = type; | ||
454 | |||
455 | switch (type) { | ||
456 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
457 | if (vfd->vidioc_enum_fmt_cap) | ||
458 | ret=vfd->vidioc_enum_fmt_cap(file, fh, f); | ||
459 | break; | ||
460 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
461 | if (vfd->vidioc_enum_fmt_overlay) | ||
462 | ret=vfd->vidioc_enum_fmt_overlay(file, fh, f); | ||
463 | break; | ||
464 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
465 | if (vfd->vidioc_enum_fmt_vbi) | ||
466 | ret=vfd->vidioc_enum_fmt_vbi(file, fh, f); | ||
467 | break; | ||
468 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | ||
469 | if (vfd->vidioc_enum_fmt_vbi_output) | ||
470 | ret=vfd->vidioc_enum_fmt_vbi_output(file, | ||
471 | fh, f); | ||
472 | break; | ||
473 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | ||
474 | if (vfd->vidioc_enum_fmt_vbi_capture) | ||
475 | ret=vfd->vidioc_enum_fmt_vbi_capture(file, | ||
476 | fh, f); | ||
477 | break; | ||
478 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | ||
479 | if (vfd->vidioc_enum_fmt_video_output) | ||
480 | ret=vfd->vidioc_enum_fmt_video_output(file, | ||
481 | fh, f); | ||
482 | break; | ||
483 | case V4L2_BUF_TYPE_VBI_OUTPUT: | ||
484 | if (vfd->vidioc_enum_fmt_vbi_output) | ||
485 | ret=vfd->vidioc_enum_fmt_vbi_output(file, | ||
486 | fh, f); | ||
487 | break; | ||
488 | case V4L2_BUF_TYPE_PRIVATE: | ||
489 | if (vfd->vidioc_enum_fmt_type_private) | ||
490 | ret=vfd->vidioc_enum_fmt_type_private(file, | ||
491 | fh, f); | ||
492 | break; | ||
493 | } | ||
494 | if (!ret) | ||
495 | dbgarg (cmd, "index=%d, type=%d, flags=%d, " | ||
496 | "description=%s," | ||
497 | " pixelformat=0x%8x\n", | ||
498 | f->index, f->type, f->flags, | ||
499 | f->description, | ||
500 | f->pixelformat); | ||
501 | |||
502 | break; | ||
503 | } | ||
504 | case VIDIOC_G_FMT: | ||
505 | { | ||
506 | struct v4l2_format *f = (struct v4l2_format *)arg; | ||
507 | enum v4l2_buf_type type=f->type; | ||
508 | |||
509 | memset(&f->fmt.pix,0,sizeof(f->fmt.pix)); | ||
510 | f->type=type; | ||
511 | |||
512 | /* FIXME: Should be one dump per type */ | ||
513 | dbgarg (cmd, "type=%s\n", prt_names(type, | ||
514 | v4l2_type_names_FIXME)); | ||
515 | |||
516 | switch (type) { | ||
517 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
518 | if (vfd->vidioc_g_fmt_cap) | ||
519 | ret=vfd->vidioc_g_fmt_cap(file, fh, f); | ||
520 | if (!ret) | ||
521 | v4l_print_pix_fmt(vfd,&f->fmt.pix); | ||
522 | break; | ||
523 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
524 | if (vfd->vidioc_g_fmt_overlay) | ||
525 | ret=vfd->vidioc_g_fmt_overlay(file, fh, f); | ||
526 | break; | ||
527 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
528 | if (vfd->vidioc_g_fmt_vbi) | ||
529 | ret=vfd->vidioc_g_fmt_vbi(file, fh, f); | ||
530 | break; | ||
531 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | ||
532 | if (vfd->vidioc_g_fmt_vbi_output) | ||
533 | ret=vfd->vidioc_g_fmt_vbi_output(file, fh, f); | ||
534 | break; | ||
535 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | ||
536 | if (vfd->vidioc_g_fmt_vbi_capture) | ||
537 | ret=vfd->vidioc_g_fmt_vbi_capture(file, fh, f); | ||
538 | break; | ||
539 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | ||
540 | if (vfd->vidioc_g_fmt_video_output) | ||
541 | ret=vfd->vidioc_g_fmt_video_output(file, | ||
542 | fh, f); | ||
543 | break; | ||
544 | case V4L2_BUF_TYPE_VBI_OUTPUT: | ||
545 | if (vfd->vidioc_g_fmt_vbi_output) | ||
546 | ret=vfd->vidioc_g_fmt_vbi_output(file, fh, f); | ||
547 | break; | ||
548 | case V4L2_BUF_TYPE_PRIVATE: | ||
549 | if (vfd->vidioc_g_fmt_type_private) | ||
550 | ret=vfd->vidioc_g_fmt_type_private(file, | ||
551 | fh, f); | ||
552 | break; | ||
553 | } | ||
554 | |||
555 | break; | ||
556 | } | ||
557 | case VIDIOC_S_FMT: | ||
558 | { | ||
559 | struct v4l2_format *f = (struct v4l2_format *)arg; | ||
560 | |||
561 | /* FIXME: Should be one dump per type */ | ||
562 | dbgarg (cmd, "type=%s\n", prt_names(f->type, | ||
563 | v4l2_type_names_FIXME)); | ||
564 | |||
565 | switch (f->type) { | ||
566 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
567 | v4l_print_pix_fmt(vfd,&f->fmt.pix); | ||
568 | if (vfd->vidioc_s_fmt_cap) | ||
569 | ret=vfd->vidioc_s_fmt_cap(file, fh, f); | ||
570 | break; | ||
571 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
572 | if (vfd->vidioc_s_fmt_overlay) | ||
573 | ret=vfd->vidioc_s_fmt_overlay(file, fh, f); | ||
574 | break; | ||
575 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
576 | if (vfd->vidioc_s_fmt_vbi) | ||
577 | ret=vfd->vidioc_s_fmt_vbi(file, fh, f); | ||
578 | break; | ||
579 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | ||
580 | if (vfd->vidioc_s_fmt_vbi_output) | ||
581 | ret=vfd->vidioc_s_fmt_vbi_output(file, fh, f); | ||
582 | break; | ||
583 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | ||
584 | if (vfd->vidioc_s_fmt_vbi_capture) | ||
585 | ret=vfd->vidioc_s_fmt_vbi_capture(file, fh, f); | ||
586 | break; | ||
587 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | ||
588 | if (vfd->vidioc_s_fmt_video_output) | ||
589 | ret=vfd->vidioc_s_fmt_video_output(file, | ||
590 | fh, f); | ||
591 | break; | ||
592 | case V4L2_BUF_TYPE_VBI_OUTPUT: | ||
593 | if (vfd->vidioc_s_fmt_vbi_output) | ||
594 | ret=vfd->vidioc_s_fmt_vbi_output(file, | ||
595 | fh, f); | ||
596 | break; | ||
597 | case V4L2_BUF_TYPE_PRIVATE: | ||
598 | if (vfd->vidioc_s_fmt_type_private) | ||
599 | ret=vfd->vidioc_s_fmt_type_private(file, | ||
600 | fh, f); | ||
601 | break; | ||
602 | } | ||
603 | break; | ||
604 | } | ||
605 | case VIDIOC_TRY_FMT: | ||
606 | { | ||
607 | struct v4l2_format *f = (struct v4l2_format *)arg; | ||
608 | |||
609 | /* FIXME: Should be one dump per type */ | ||
610 | dbgarg (cmd, "type=%s\n", prt_names(f->type, | ||
611 | v4l2_type_names_FIXME)); | ||
612 | switch (f->type) { | ||
613 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
614 | if (vfd->vidioc_try_fmt_cap) | ||
615 | ret=vfd->vidioc_try_fmt_cap(file, fh, f); | ||
616 | if (!ret) | ||
617 | v4l_print_pix_fmt(vfd,&f->fmt.pix); | ||
618 | break; | ||
619 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
620 | if (vfd->vidioc_try_fmt_overlay) | ||
621 | ret=vfd->vidioc_try_fmt_overlay(file, fh, f); | ||
622 | break; | ||
623 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
624 | if (vfd->vidioc_try_fmt_vbi) | ||
625 | ret=vfd->vidioc_try_fmt_vbi(file, fh, f); | ||
626 | break; | ||
627 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | ||
628 | if (vfd->vidioc_try_fmt_vbi_output) | ||
629 | ret=vfd->vidioc_try_fmt_vbi_output(file, | ||
630 | fh, f); | ||
631 | break; | ||
632 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | ||
633 | if (vfd->vidioc_try_fmt_vbi_capture) | ||
634 | ret=vfd->vidioc_try_fmt_vbi_capture(file, | ||
635 | fh, f); | ||
636 | break; | ||
637 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | ||
638 | if (vfd->vidioc_try_fmt_video_output) | ||
639 | ret=vfd->vidioc_try_fmt_video_output(file, | ||
640 | fh, f); | ||
641 | break; | ||
642 | case V4L2_BUF_TYPE_VBI_OUTPUT: | ||
643 | if (vfd->vidioc_try_fmt_vbi_output) | ||
644 | ret=vfd->vidioc_try_fmt_vbi_output(file, | ||
645 | fh, f); | ||
646 | break; | ||
647 | case V4L2_BUF_TYPE_PRIVATE: | ||
648 | if (vfd->vidioc_try_fmt_type_private) | ||
649 | ret=vfd->vidioc_try_fmt_type_private(file, | ||
650 | fh, f); | ||
651 | break; | ||
652 | } | ||
653 | |||
654 | break; | ||
655 | } | ||
656 | /* FIXME: Those buf reqs could be handled here, | ||
657 | with some changes on videobuf to allow its header to be included at | ||
658 | videodev2.h or being merged at videodev2. | ||
659 | */ | ||
660 | case VIDIOC_REQBUFS: | ||
661 | { | ||
662 | struct v4l2_requestbuffers *p=arg; | ||
663 | |||
664 | if (!vfd->vidioc_reqbufs) | ||
665 | break; | ||
666 | ret = check_fmt (vfd, p->type); | ||
667 | if (ret) | ||
668 | break; | ||
669 | |||
670 | ret=vfd->vidioc_reqbufs(file, fh, p); | ||
671 | dbgarg (cmd, "count=%d, type=%s, memory=%s\n", | ||
672 | p->count, | ||
673 | prt_names(p->type,v4l2_type_names_FIXME), | ||
674 | prt_names(p->memory,v4l2_memory_names)); | ||
675 | break; | ||
676 | } | ||
677 | case VIDIOC_QUERYBUF: | ||
678 | { | ||
679 | struct v4l2_buffer *p=arg; | ||
680 | |||
681 | if (!vfd->vidioc_querybuf) | ||
682 | break; | ||
683 | ret = check_fmt (vfd, p->type); | ||
684 | if (ret) | ||
685 | break; | ||
686 | |||
687 | ret=vfd->vidioc_querybuf(file, fh, p); | ||
688 | if (!ret) | ||
689 | dbgbuf(cmd,vfd,p); | ||
690 | break; | ||
691 | } | ||
692 | case VIDIOC_QBUF: | ||
693 | { | ||
694 | struct v4l2_buffer *p=arg; | ||
695 | |||
696 | if (!vfd->vidioc_qbuf) | ||
697 | break; | ||
698 | ret = check_fmt (vfd, p->type); | ||
699 | if (ret) | ||
700 | break; | ||
701 | |||
702 | ret=vfd->vidioc_qbuf(file, fh, p); | ||
703 | if (!ret) | ||
704 | dbgbuf(cmd,vfd,p); | ||
705 | break; | ||
706 | } | ||
707 | case VIDIOC_DQBUF: | ||
708 | { | ||
709 | struct v4l2_buffer *p=arg; | ||
710 | if (!vfd->vidioc_qbuf) | ||
711 | break; | ||
712 | ret = check_fmt (vfd, p->type); | ||
713 | if (ret) | ||
714 | break; | ||
715 | |||
716 | ret=vfd->vidioc_qbuf(file, fh, p); | ||
717 | if (!ret) | ||
718 | dbgbuf(cmd,vfd,p); | ||
719 | break; | ||
720 | } | ||
721 | case VIDIOC_OVERLAY: | ||
722 | { | ||
723 | int *i = arg; | ||
724 | |||
725 | if (!vfd->vidioc_overlay) | ||
726 | break; | ||
727 | dbgarg (cmd, "value=%d\n",*i); | ||
728 | ret=vfd->vidioc_overlay(file, fh, *i); | ||
729 | break; | ||
730 | } | ||
731 | #ifdef HAVE_V4L1 | ||
732 | /* --- streaming capture ------------------------------------- */ | ||
733 | case VIDIOCGMBUF: | ||
734 | { | ||
735 | struct video_mbuf *p=arg; | ||
736 | |||
737 | memset(&p,0,sizeof(p)); | ||
738 | |||
739 | if (!vfd->vidiocgmbuf) | ||
740 | break; | ||
741 | ret=vfd->vidiocgmbuf(file, fh, p); | ||
742 | if (!ret) | ||
743 | dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n", | ||
744 | p->size, p->frames, | ||
745 | (unsigned long)p->offsets); | ||
746 | break; | ||
747 | } | ||
748 | #endif | ||
749 | case VIDIOC_G_FBUF: | ||
750 | { | ||
751 | struct v4l2_framebuffer *p=arg; | ||
752 | if (!vfd->vidioc_g_fbuf) | ||
753 | break; | ||
754 | ret=vfd->vidioc_g_fbuf(file, fh, arg); | ||
755 | if (!ret) { | ||
756 | dbgarg (cmd, "capability=%d, flags=%d, base=0x%08lx\n", | ||
757 | p->capability,p->flags, | ||
758 | (unsigned long)p->base); | ||
759 | v4l_print_pix_fmt (vfd, &p->fmt); | ||
760 | } | ||
761 | break; | ||
762 | } | ||
763 | case VIDIOC_S_FBUF: | ||
764 | { | ||
765 | struct v4l2_framebuffer *p=arg; | ||
766 | if (!vfd->vidioc_s_fbuf) | ||
767 | break; | ||
768 | |||
769 | dbgarg (cmd, "capability=%d, flags=%d, base=0x%08lx\n", | ||
770 | p->capability,p->flags,(unsigned long)p->base); | ||
771 | v4l_print_pix_fmt (vfd, &p->fmt); | ||
772 | ret=vfd->vidioc_s_fbuf(file, fh, arg); | ||
773 | |||
774 | break; | ||
775 | } | ||
776 | case VIDIOC_STREAMON: | ||
777 | { | ||
778 | enum v4l2_buf_type i = *(int *)arg; | ||
779 | if (!vfd->vidioc_streamon) | ||
780 | break; | ||
781 | dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME)); | ||
782 | ret=vfd->vidioc_streamon(file, fh,i); | ||
783 | break; | ||
784 | } | ||
785 | case VIDIOC_STREAMOFF: | ||
786 | { | ||
787 | enum v4l2_buf_type i = *(int *)arg; | ||
788 | |||
789 | if (!vfd->vidioc_streamoff) | ||
790 | break; | ||
791 | dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME)); | ||
792 | ret=vfd->vidioc_streamoff(file, fh, i); | ||
793 | break; | ||
794 | } | ||
795 | /* ---------- tv norms ---------- */ | ||
796 | case VIDIOC_ENUMSTD: | ||
797 | { | ||
798 | struct v4l2_standard *p = arg; | ||
799 | unsigned int index = p->index; | ||
800 | |||
801 | if (!vfd->tvnormsize) { | ||
802 | printk (KERN_WARNING "%s: no TV norms defined!\n", | ||
803 | vfd->name); | ||
804 | break; | ||
805 | } | ||
806 | |||
807 | if (index<=0 || index >= vfd->tvnormsize) { | ||
808 | ret=-EINVAL; | ||
809 | break; | ||
810 | } | ||
811 | v4l2_video_std_construct(p, vfd->tvnorms[p->index].id, | ||
812 | vfd->tvnorms[p->index].name); | ||
813 | p->index = index; | ||
814 | |||
815 | dbgarg (cmd, "index=%d, id=%Ld, name=%s, fps=%d/%d, " | ||
816 | "framelines=%d\n", p->index, | ||
817 | (unsigned long long)p->id, p->name, | ||
818 | p->frameperiod.numerator, | ||
819 | p->frameperiod.denominator, | ||
820 | p->framelines); | ||
821 | |||
822 | ret=0; | ||
823 | break; | ||
824 | } | ||
825 | case VIDIOC_G_STD: | ||
826 | { | ||
827 | v4l2_std_id *id = arg; | ||
828 | |||
829 | *id = vfd->current_norm; | ||
830 | |||
831 | dbgarg (cmd, "value=%Lu\n", (long long unsigned) *id); | ||
832 | |||
833 | ret=0; | ||
834 | break; | ||
835 | } | ||
836 | case VIDIOC_S_STD: | ||
837 | { | ||
838 | v4l2_std_id *id = arg; | ||
839 | unsigned int i; | ||
840 | |||
841 | if (!vfd->tvnormsize) { | ||
842 | printk (KERN_WARNING "%s: no TV norms defined!\n", | ||
843 | vfd->name); | ||
844 | break; | ||
845 | } | ||
846 | |||
847 | dbgarg (cmd, "value=%Lu\n", (long long unsigned) *id); | ||
848 | |||
849 | /* First search for exact match */ | ||
850 | for (i = 0; i < vfd->tvnormsize; i++) | ||
851 | if (*id == vfd->tvnorms[i].id) | ||
852 | break; | ||
853 | /* Then for a generic video std that contains desired std */ | ||
854 | if (i == vfd->tvnormsize) | ||
855 | for (i = 0; i < vfd->tvnormsize; i++) | ||
856 | if (*id & vfd->tvnorms[i].id) | ||
857 | break; | ||
858 | if (i == vfd->tvnormsize) { | ||
859 | break; | ||
860 | } | ||
861 | |||
862 | /* Calls the specific handler */ | ||
863 | if (vfd->vidioc_s_std) | ||
864 | ret=vfd->vidioc_s_std(file, fh, i); | ||
865 | else | ||
866 | ret=-EINVAL; | ||
867 | |||
868 | /* Updates standard information */ | ||
869 | if (!ret) | ||
870 | vfd->current_norm=*id; | ||
871 | |||
872 | break; | ||
873 | } | ||
874 | case VIDIOC_QUERYSTD: | ||
875 | { | ||
876 | v4l2_std_id *p=arg; | ||
877 | |||
878 | if (!vfd->vidioc_querystd) | ||
879 | break; | ||
880 | ret=vfd->vidioc_querystd(file, fh, arg); | ||
881 | if (!ret) | ||
882 | dbgarg (cmd, "detected std=%Lu\n", | ||
883 | (unsigned long long)*p); | ||
884 | break; | ||
885 | } | ||
886 | /* ------ input switching ---------- */ | ||
887 | /* FIXME: Inputs can be handled inside videodev2 */ | ||
888 | case VIDIOC_ENUMINPUT: | ||
889 | { | ||
890 | struct v4l2_input *p=arg; | ||
891 | int i=p->index; | ||
892 | |||
893 | if (!vfd->vidioc_enum_input) | ||
894 | break; | ||
895 | memset(p, 0, sizeof(*p)); | ||
896 | p->index=i; | ||
897 | |||
898 | ret=vfd->vidioc_enum_input(file, fh, p); | ||
899 | if (!ret) | ||
900 | dbgarg (cmd, "index=%d, name=%s, type=%d, " | ||
901 | "audioset=%d, " | ||
902 | "tuner=%d, std=%Ld, status=%d\n", | ||
903 | p->index,p->name,p->type,p->audioset, | ||
904 | p->tuner, | ||
905 | (unsigned long long)p->std, | ||
906 | p->status); | ||
907 | break; | ||
908 | } | ||
909 | case VIDIOC_G_INPUT: | ||
910 | { | ||
911 | unsigned int *i = arg; | ||
912 | |||
913 | if (!vfd->vidioc_g_input) | ||
914 | break; | ||
915 | ret=vfd->vidioc_g_input(file, fh, i); | ||
916 | if (!ret) | ||
917 | dbgarg (cmd, "value=%d\n",*i); | ||
918 | break; | ||
919 | } | ||
920 | case VIDIOC_S_INPUT: | ||
921 | { | ||
922 | unsigned int *i = arg; | ||
923 | |||
924 | if (!vfd->vidioc_s_input) | ||
925 | break; | ||
926 | dbgarg (cmd, "value=%d\n",*i); | ||
927 | ret=vfd->vidioc_s_input(file, fh, *i); | ||
928 | break; | ||
929 | } | ||
930 | |||
931 | /* ------ output switching ---------- */ | ||
932 | case VIDIOC_G_OUTPUT: | ||
933 | { | ||
934 | unsigned int *i = arg; | ||
935 | |||
936 | if (!vfd->vidioc_g_output) | ||
937 | break; | ||
938 | ret=vfd->vidioc_g_output(file, fh, i); | ||
939 | if (!ret) | ||
940 | dbgarg (cmd, "value=%d\n",*i); | ||
941 | break; | ||
942 | } | ||
943 | case VIDIOC_S_OUTPUT: | ||
944 | { | ||
945 | unsigned int *i = arg; | ||
946 | |||
947 | if (!vfd->vidioc_s_output) | ||
948 | break; | ||
949 | dbgarg (cmd, "value=%d\n",*i); | ||
950 | ret=vfd->vidioc_s_output(file, fh, *i); | ||
951 | break; | ||
952 | } | ||
953 | |||
954 | /* --- controls ---------------------------------------------- */ | ||
955 | case VIDIOC_QUERYCTRL: | ||
956 | { | ||
957 | struct v4l2_queryctrl *p=arg; | ||
958 | |||
959 | if (!vfd->vidioc_queryctrl) | ||
960 | break; | ||
961 | ret=vfd->vidioc_queryctrl(file, fh, p); | ||
962 | |||
963 | if (!ret) | ||
964 | dbgarg (cmd, "id=%d, type=%d, name=%s, " | ||
965 | "min/max=%d/%d," | ||
966 | " step=%d, default=%d, flags=0x%08x\n", | ||
967 | p->id,p->type,p->name,p->minimum, | ||
968 | p->maximum,p->step,p->default_value, | ||
969 | p->flags); | ||
970 | break; | ||
971 | } | ||
972 | case VIDIOC_G_CTRL: | ||
973 | { | ||
974 | struct v4l2_control *p = arg; | ||
975 | |||
976 | if (!vfd->vidioc_g_ctrl) | ||
977 | break; | ||
978 | dbgarg(cmd, "Enum for index=%d\n", p->id); | ||
979 | |||
980 | ret=vfd->vidioc_g_ctrl(file, fh, p); | ||
981 | if (!ret) | ||
982 | dbgarg2 ( "id=%d, value=%d\n", p->id, p->value); | ||
983 | break; | ||
984 | } | ||
985 | case VIDIOC_S_CTRL: | ||
986 | { | ||
987 | struct v4l2_control *p = arg; | ||
988 | |||
989 | if (!vfd->vidioc_s_ctrl) | ||
990 | break; | ||
991 | dbgarg (cmd, "id=%d, value=%d\n", p->id, p->value); | ||
992 | |||
993 | ret=vfd->vidioc_s_ctrl(file, fh, p); | ||
994 | break; | ||
995 | } | ||
996 | case VIDIOC_QUERYMENU: | ||
997 | { | ||
998 | struct v4l2_querymenu *p=arg; | ||
999 | if (!vfd->vidioc_querymenu) | ||
1000 | break; | ||
1001 | ret=vfd->vidioc_querymenu(file, fh, p); | ||
1002 | if (!ret) | ||
1003 | dbgarg (cmd, "id=%d, index=%d, name=%s\n", | ||
1004 | p->id,p->index,p->name); | ||
1005 | break; | ||
1006 | } | ||
1007 | /* --- audio ---------------------------------------------- */ | ||
1008 | case VIDIOC_ENUMAUDIO: | ||
1009 | { | ||
1010 | struct v4l2_audio *p=arg; | ||
1011 | |||
1012 | if (!vfd->vidioc_enumaudio) | ||
1013 | break; | ||
1014 | dbgarg(cmd, "Enum for index=%d\n", p->index); | ||
1015 | ret=vfd->vidioc_enumaudio(file, fh, p); | ||
1016 | if (!ret) | ||
1017 | dbgarg2("index=%d, name=%s, capability=%d, " | ||
1018 | "mode=%d\n",p->index,p->name, | ||
1019 | p->capability, p->mode); | ||
1020 | break; | ||
1021 | } | ||
1022 | case VIDIOC_G_AUDIO: | ||
1023 | { | ||
1024 | struct v4l2_audio *p=arg; | ||
1025 | |||
1026 | if (!vfd->vidioc_g_audio) | ||
1027 | break; | ||
1028 | dbgarg(cmd, "Get for index=%d\n", p->index); | ||
1029 | ret=vfd->vidioc_g_audio(file, fh, p); | ||
1030 | if (!ret) | ||
1031 | dbgarg2("index=%d, name=%s, capability=%d, " | ||
1032 | "mode=%d\n",p->index, | ||
1033 | p->name,p->capability, p->mode); | ||
1034 | break; | ||
1035 | } | ||
1036 | case VIDIOC_S_AUDIO: | ||
1037 | { | ||
1038 | struct v4l2_audio *p=arg; | ||
1039 | |||
1040 | if (!vfd->vidioc_s_audio) | ||
1041 | break; | ||
1042 | dbgarg(cmd, "index=%d, name=%s, capability=%d, " | ||
1043 | "mode=%d\n", p->index, p->name, | ||
1044 | p->capability, p->mode); | ||
1045 | ret=vfd->vidioc_s_audio(file, fh, p); | ||
1046 | break; | ||
1047 | } | ||
1048 | case VIDIOC_ENUMAUDOUT: | ||
1049 | { | ||
1050 | struct v4l2_audioout *p=arg; | ||
1051 | |||
1052 | if (!vfd->vidioc_enumaudout) | ||
1053 | break; | ||
1054 | dbgarg(cmd, "Enum for index=%d\n", p->index); | ||
1055 | ret=vfd->vidioc_enumaudout(file, fh, p); | ||
1056 | if (!ret) | ||
1057 | dbgarg2("index=%d, name=%s, capability=%d, " | ||
1058 | "mode=%d\n", p->index, p->name, | ||
1059 | p->capability,p->mode); | ||
1060 | break; | ||
1061 | } | ||
1062 | case VIDIOC_G_AUDOUT: | ||
1063 | { | ||
1064 | struct v4l2_audioout *p=arg; | ||
1065 | |||
1066 | if (!vfd->vidioc_g_audout) | ||
1067 | break; | ||
1068 | dbgarg(cmd, "Enum for index=%d\n", p->index); | ||
1069 | ret=vfd->vidioc_g_audout(file, fh, p); | ||
1070 | if (!ret) | ||
1071 | dbgarg2("index=%d, name=%s, capability=%d, " | ||
1072 | "mode=%d\n", p->index, p->name, | ||
1073 | p->capability,p->mode); | ||
1074 | break; | ||
1075 | } | ||
1076 | case VIDIOC_S_AUDOUT: | ||
1077 | { | ||
1078 | struct v4l2_audioout *p=arg; | ||
1079 | |||
1080 | if (!vfd->vidioc_s_audout) | ||
1081 | break; | ||
1082 | dbgarg(cmd, "index=%d, name=%s, capability=%d, " | ||
1083 | "mode=%d\n", p->index, p->name, | ||
1084 | p->capability,p->mode); | ||
1085 | |||
1086 | ret=vfd->vidioc_s_audout(file, fh, p); | ||
1087 | break; | ||
1088 | } | ||
1089 | case VIDIOC_G_MODULATOR: | ||
1090 | { | ||
1091 | struct v4l2_modulator *p=arg; | ||
1092 | if (!vfd->vidioc_g_modulator) | ||
1093 | break; | ||
1094 | ret=vfd->vidioc_g_modulator(file, fh, p); | ||
1095 | if (!ret) | ||
1096 | dbgarg(cmd, "index=%d, name=%s, " | ||
1097 | "capability=%d, rangelow=%d," | ||
1098 | " rangehigh=%d, txsubchans=%d\n", | ||
1099 | p->index, p->name,p->capability, | ||
1100 | p->rangelow, p->rangehigh, | ||
1101 | p->txsubchans); | ||
1102 | break; | ||
1103 | } | ||
1104 | case VIDIOC_S_MODULATOR: | ||
1105 | { | ||
1106 | struct v4l2_modulator *p=arg; | ||
1107 | if (!vfd->vidioc_s_modulator) | ||
1108 | break; | ||
1109 | dbgarg(cmd, "index=%d, name=%s, capability=%d, " | ||
1110 | "rangelow=%d, rangehigh=%d, txsubchans=%d\n", | ||
1111 | p->index, p->name,p->capability,p->rangelow, | ||
1112 | p->rangehigh,p->txsubchans); | ||
1113 | ret=vfd->vidioc_s_modulator(file, fh, p); | ||
1114 | break; | ||
1115 | } | ||
1116 | case VIDIOC_G_CROP: | ||
1117 | { | ||
1118 | struct v4l2_crop *p=arg; | ||
1119 | if (!vfd->vidioc_g_crop) | ||
1120 | break; | ||
1121 | ret=vfd->vidioc_g_crop(file, fh, p); | ||
1122 | if (!ret) { | ||
1123 | dbgarg(cmd, "type=%d\n", p->type); | ||
1124 | dbgrect(vfd, "", &p->c); | ||
1125 | } | ||
1126 | break; | ||
1127 | } | ||
1128 | case VIDIOC_S_CROP: | ||
1129 | { | ||
1130 | struct v4l2_crop *p=arg; | ||
1131 | if (!vfd->vidioc_s_crop) | ||
1132 | break; | ||
1133 | dbgarg(cmd, "type=%d\n", p->type); | ||
1134 | dbgrect(vfd, "", &p->c); | ||
1135 | ret=vfd->vidioc_s_crop(file, fh, p); | ||
1136 | break; | ||
1137 | } | ||
1138 | case VIDIOC_CROPCAP: | ||
1139 | { | ||
1140 | struct v4l2_cropcap *p=arg; | ||
1141 | /*FIXME: Should also show v4l2_fract pixelaspect */ | ||
1142 | if (!vfd->vidioc_cropcap) | ||
1143 | break; | ||
1144 | dbgarg(cmd, "type=%d\n", p->type); | ||
1145 | dbgrect(vfd, "bounds ", &p->bounds); | ||
1146 | dbgrect(vfd, "defrect ", &p->defrect); | ||
1147 | ret=vfd->vidioc_cropcap(file, fh, p); | ||
1148 | break; | ||
1149 | } | ||
1150 | case VIDIOC_G_MPEGCOMP: | ||
1151 | { | ||
1152 | struct v4l2_mpeg_compression *p=arg; | ||
1153 | /*FIXME: Several fields not shown */ | ||
1154 | if (!vfd->vidioc_g_mpegcomp) | ||
1155 | break; | ||
1156 | ret=vfd->vidioc_g_mpegcomp(file, fh, p); | ||
1157 | if (!ret) | ||
1158 | dbgarg (cmd, "ts_pid_pmt=%d, ts_pid_audio=%d," | ||
1159 | " ts_pid_video=%d, ts_pid_pcr=%d, " | ||
1160 | "ps_size=%d, au_sample_rate=%d, " | ||
1161 | "au_pesid=%c, vi_frame_rate=%d, " | ||
1162 | "vi_frames_per_gop=%d, " | ||
1163 | "vi_bframes_count=%d, vi_pesid=%c\n", | ||
1164 | p->ts_pid_pmt,p->ts_pid_audio, | ||
1165 | p->ts_pid_video,p->ts_pid_pcr, | ||
1166 | p->ps_size, p->au_sample_rate, | ||
1167 | p->au_pesid, p->vi_frame_rate, | ||
1168 | p->vi_frames_per_gop, | ||
1169 | p->vi_bframes_count, p->vi_pesid); | ||
1170 | break; | ||
1171 | } | ||
1172 | case VIDIOC_S_MPEGCOMP: | ||
1173 | { | ||
1174 | struct v4l2_mpeg_compression *p=arg; | ||
1175 | /*FIXME: Several fields not shown */ | ||
1176 | if (!vfd->vidioc_s_mpegcomp) | ||
1177 | break; | ||
1178 | dbgarg (cmd, "ts_pid_pmt=%d, ts_pid_audio=%d, " | ||
1179 | "ts_pid_video=%d, ts_pid_pcr=%d, ps_size=%d, " | ||
1180 | "au_sample_rate=%d, au_pesid=%c, " | ||
1181 | "vi_frame_rate=%d, vi_frames_per_gop=%d, " | ||
1182 | "vi_bframes_count=%d, vi_pesid=%c\n", | ||
1183 | p->ts_pid_pmt,p->ts_pid_audio, p->ts_pid_video, | ||
1184 | p->ts_pid_pcr, p->ps_size, p->au_sample_rate, | ||
1185 | p->au_pesid, p->vi_frame_rate, | ||
1186 | p->vi_frames_per_gop, p->vi_bframes_count, | ||
1187 | p->vi_pesid); | ||
1188 | ret=vfd->vidioc_s_mpegcomp(file, fh, p); | ||
1189 | break; | ||
1190 | } | ||
1191 | case VIDIOC_G_JPEGCOMP: | ||
1192 | { | ||
1193 | struct v4l2_jpegcompression *p=arg; | ||
1194 | if (!vfd->vidioc_g_jpegcomp) | ||
1195 | break; | ||
1196 | ret=vfd->vidioc_g_jpegcomp(file, fh, p); | ||
1197 | if (!ret) | ||
1198 | dbgarg (cmd, "quality=%d, APPn=%d, " | ||
1199 | "APP_len=%d, COM_len=%d, " | ||
1200 | "jpeg_markers=%d\n", | ||
1201 | p->quality,p->APPn,p->APP_len, | ||
1202 | p->COM_len,p->jpeg_markers); | ||
1203 | break; | ||
1204 | } | ||
1205 | case VIDIOC_S_JPEGCOMP: | ||
1206 | { | ||
1207 | struct v4l2_jpegcompression *p=arg; | ||
1208 | if (!vfd->vidioc_g_jpegcomp) | ||
1209 | break; | ||
1210 | dbgarg (cmd, "quality=%d, APPn=%d, APP_len=%d, " | ||
1211 | "COM_len=%d, jpeg_markers=%d\n", | ||
1212 | p->quality,p->APPn,p->APP_len, | ||
1213 | p->COM_len,p->jpeg_markers); | ||
1214 | ret=vfd->vidioc_s_jpegcomp(file, fh, p); | ||
1215 | break; | ||
1216 | } | ||
1217 | case VIDIOC_G_PARM: | ||
1218 | { | ||
1219 | struct v4l2_streamparm *p=arg; | ||
1220 | if (!vfd->vidioc_g_parm) | ||
1221 | break; | ||
1222 | ret=vfd->vidioc_g_parm(file, fh, p); | ||
1223 | dbgarg (cmd, "type=%d\n", p->type); | ||
1224 | break; | ||
1225 | } | ||
1226 | case VIDIOC_S_PARM: | ||
1227 | { | ||
1228 | struct v4l2_streamparm *p=arg; | ||
1229 | if (!vfd->vidioc_s_parm) | ||
1230 | break; | ||
1231 | dbgarg (cmd, "type=%d\n", p->type); | ||
1232 | ret=vfd->vidioc_s_parm(file, fh, p); | ||
1233 | break; | ||
1234 | } | ||
1235 | case VIDIOC_G_TUNER: | ||
1236 | { | ||
1237 | struct v4l2_tuner *p=arg; | ||
1238 | if (!vfd->vidioc_g_tuner) | ||
1239 | break; | ||
1240 | ret=vfd->vidioc_g_tuner(file, fh, p); | ||
1241 | if (!ret) | ||
1242 | dbgarg (cmd, "index=%d, name=%s, type=%d, " | ||
1243 | "capability=%d, rangelow=%d, " | ||
1244 | "rangehigh=%d, signal=%d, afc=%d, " | ||
1245 | "rxsubchans=%d, audmode=%d\n", | ||
1246 | p->index, p->name, p->type, | ||
1247 | p->capability, p->rangelow, | ||
1248 | p->rangehigh, p->rxsubchans, | ||
1249 | p->audmode, p->signal, p->afc); | ||
1250 | break; | ||
1251 | } | ||
1252 | case VIDIOC_S_TUNER: | ||
1253 | { | ||
1254 | struct v4l2_tuner *p=arg; | ||
1255 | if (!vfd->vidioc_s_tuner) | ||
1256 | break; | ||
1257 | dbgarg (cmd, "index=%d, name=%s, type=%d, " | ||
1258 | "capability=%d, rangelow=%d, rangehigh=%d, " | ||
1259 | "signal=%d, afc=%d, rxsubchans=%d, " | ||
1260 | "audmode=%d\n",p->index, p->name, p->type, | ||
1261 | p->capability, p->rangelow,p->rangehigh, | ||
1262 | p->rxsubchans, p->audmode, p->signal, | ||
1263 | p->afc); | ||
1264 | ret=vfd->vidioc_s_tuner(file, fh, p); | ||
1265 | break; | ||
1266 | } | ||
1267 | case VIDIOC_G_FREQUENCY: | ||
1268 | { | ||
1269 | struct v4l2_frequency *p=arg; | ||
1270 | if (!vfd->vidioc_g_frequency) | ||
1271 | break; | ||
1272 | ret=vfd->vidioc_g_frequency(file, fh, p); | ||
1273 | if (!ret) | ||
1274 | dbgarg (cmd, "tuner=%d, type=%d, frequency=%d\n", | ||
1275 | p->tuner,p->type,p->frequency); | ||
1276 | break; | ||
1277 | } | ||
1278 | case VIDIOC_S_FREQUENCY: | ||
1279 | { | ||
1280 | struct v4l2_frequency *p=arg; | ||
1281 | if (!vfd->vidioc_s_frequency) | ||
1282 | break; | ||
1283 | dbgarg (cmd, "tuner=%d, type=%d, frequency=%d\n", | ||
1284 | p->tuner,p->type,p->frequency); | ||
1285 | ret=vfd->vidioc_s_frequency(file, fh, p); | ||
1286 | break; | ||
1287 | } | ||
1288 | case VIDIOC_G_SLICED_VBI_CAP: | ||
1289 | { | ||
1290 | struct v4l2_sliced_vbi_cap *p=arg; | ||
1291 | if (!vfd->vidioc_g_sliced_vbi_cap) | ||
1292 | break; | ||
1293 | ret=vfd->vidioc_g_sliced_vbi_cap(file, fh, p); | ||
1294 | if (!ret) | ||
1295 | dbgarg (cmd, "service_set=%d\n", p->service_set); | ||
1296 | break; | ||
1297 | } | ||
1298 | case VIDIOC_LOG_STATUS: | ||
1299 | { | ||
1300 | if (!vfd->vidioc_log_status) | ||
1301 | break; | ||
1302 | ret=vfd->vidioc_log_status(file, fh); | ||
1303 | break; | ||
1304 | } | ||
1305 | |||
1306 | /* --- Others --------------------------------------------- */ | ||
1307 | |||
1308 | default: | ||
1309 | ret=v4l_compat_translate_ioctl(inode,file,cmd,arg,__video_do_ioctl); | ||
1310 | } | ||
1311 | |||
1312 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { | ||
1313 | if (ret<0) { | ||
1314 | printk ("%s: err:\n", vfd->name); | ||
1315 | v4l_print_ioctl(vfd->name, cmd); | ||
1316 | } | ||
1317 | } | ||
1318 | |||
1319 | return ret; | ||
1320 | } | ||
1321 | |||
1322 | int video_ioctl2 (struct inode *inode, struct file *file, | ||
1323 | unsigned int cmd, unsigned long arg) | ||
1324 | { | ||
1325 | char sbuf[128]; | ||
1326 | void *mbuf = NULL; | ||
1327 | void *parg = NULL; | ||
1328 | int err = -EINVAL; | ||
1329 | |||
1330 | #ifdef __OLD_VIDIOC_ | ||
1331 | cmd = video_fix_command(cmd); | ||
1332 | #endif | ||
1333 | |||
1334 | /* Copy arguments into temp kernel buffer */ | ||
1335 | switch (_IOC_DIR(cmd)) { | ||
1336 | case _IOC_NONE: | ||
1337 | parg = NULL; | ||
1338 | break; | ||
1339 | case _IOC_READ: | ||
1340 | case _IOC_WRITE: | ||
1341 | case (_IOC_WRITE | _IOC_READ): | ||
1342 | if (_IOC_SIZE(cmd) <= sizeof(sbuf)) { | ||
1343 | parg = sbuf; | ||
1344 | } else { | ||
1345 | /* too big to allocate from stack */ | ||
1346 | mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); | ||
1347 | if (NULL == mbuf) | ||
1348 | return -ENOMEM; | ||
1349 | parg = mbuf; | ||
1350 | } | ||
1351 | |||
1352 | err = -EFAULT; | ||
1353 | if (_IOC_DIR(cmd) & _IOC_WRITE) | ||
1354 | if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) | ||
1355 | goto out; | ||
1356 | break; | ||
1357 | } | ||
1358 | |||
1359 | /* Handles IOCTL */ | ||
1360 | err = __video_do_ioctl(inode, file, cmd, parg); | ||
1361 | if (err == -ENOIOCTLCMD) | ||
1362 | err = -EINVAL; | ||
1363 | if (err < 0) | ||
1364 | goto out; | ||
1365 | |||
1366 | /* Copy results into user buffer */ | ||
1367 | switch (_IOC_DIR(cmd)) | ||
1368 | { | ||
1369 | case _IOC_READ: | ||
1370 | case (_IOC_WRITE | _IOC_READ): | ||
1371 | if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd))) | ||
1372 | err = -EFAULT; | ||
1373 | break; | ||
1374 | } | ||
1375 | |||
1376 | out: | ||
1377 | kfree(mbuf); | ||
1378 | return err; | ||
1379 | } | ||
1380 | |||
1381 | |||
245 | static struct file_operations video_fops; | 1382 | static struct file_operations video_fops; |
246 | 1383 | ||
247 | /** | 1384 | /** |
@@ -371,7 +1508,9 @@ void video_unregister_device(struct video_device *vfd) | |||
371 | mutex_unlock(&videodev_lock); | 1508 | mutex_unlock(&videodev_lock); |
372 | } | 1509 | } |
373 | 1510 | ||
374 | 1511 | /* | |
1512 | * Video fs operations | ||
1513 | */ | ||
375 | static struct file_operations video_fops= | 1514 | static struct file_operations video_fops= |
376 | { | 1515 | { |
377 | .owner = THIS_MODULE, | 1516 | .owner = THIS_MODULE, |
@@ -387,7 +1526,7 @@ static int __init videodev_init(void) | |||
387 | { | 1526 | { |
388 | int ret; | 1527 | int ret; |
389 | 1528 | ||
390 | printk(KERN_INFO "Linux video capture interface: v1.00\n"); | 1529 | printk(KERN_INFO "Linux video capture interface: v2.00\n"); |
391 | if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, &video_fops)) { | 1530 | if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, &video_fops)) { |
392 | printk(KERN_WARNING "video_dev: unable to get major %d\n", VIDEO_MAJOR); | 1531 | printk(KERN_WARNING "video_dev: unable to get major %d\n", VIDEO_MAJOR); |
393 | return -EIO; | 1532 | return -EIO; |
@@ -418,11 +1557,12 @@ EXPORT_SYMBOL(video_devdata); | |||
418 | EXPORT_SYMBOL(video_usercopy); | 1557 | EXPORT_SYMBOL(video_usercopy); |
419 | EXPORT_SYMBOL(video_exclusive_open); | 1558 | EXPORT_SYMBOL(video_exclusive_open); |
420 | EXPORT_SYMBOL(video_exclusive_release); | 1559 | EXPORT_SYMBOL(video_exclusive_release); |
1560 | EXPORT_SYMBOL(video_ioctl2); | ||
421 | EXPORT_SYMBOL(video_device_alloc); | 1561 | EXPORT_SYMBOL(video_device_alloc); |
422 | EXPORT_SYMBOL(video_device_release); | 1562 | EXPORT_SYMBOL(video_device_release); |
423 | 1563 | ||
424 | MODULE_AUTHOR("Alan Cox"); | 1564 | MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>"); |
425 | MODULE_DESCRIPTION("Device registrar for Video4Linux drivers"); | 1565 | MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2"); |
426 | MODULE_LICENSE("GPL"); | 1566 | MODULE_LICENSE("GPL"); |
427 | 1567 | ||
428 | 1568 | ||
diff --git a/include/linux/videodev.h b/include/linux/videodev.h index 91140091ced2..5b6205544a7a 100644 --- a/include/linux/videodev.h +++ b/include/linux/videodev.h | |||
@@ -1,49 +1,28 @@ | |||
1 | /* | ||
2 | * Video for Linux version 1 - OBSOLETE | ||
3 | * | ||
4 | * Header file for v4l1 drivers and applications, for | ||
5 | * Linux kernels 2.2.x or 2.4.x. | ||
6 | * | ||
7 | * Provides header for legacy drivers and applications | ||
8 | * | ||
9 | * See http://linuxtv.org for more info | ||
10 | * | ||
11 | */ | ||
1 | #ifndef __LINUX_VIDEODEV_H | 12 | #ifndef __LINUX_VIDEODEV_H |
2 | #define __LINUX_VIDEODEV_H | 13 | #define __LINUX_VIDEODEV_H |
3 | 14 | ||
4 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include <linux/poll.h> | ||
17 | #include <linux/fs.h> | ||
18 | #include <linux/device.h> | ||
19 | #include <linux/mutex.h> | ||
20 | #include <linux/compiler.h> /* need __user */ | ||
5 | 21 | ||
6 | #define HAVE_V4L1 1 | 22 | #define HAVE_V4L1 1 |
7 | 23 | ||
8 | #include <linux/videodev2.h> | 24 | #include <linux/videodev2.h> |
9 | 25 | ||
10 | #ifdef __KERNEL__ | ||
11 | |||
12 | #include <linux/mm.h> | ||
13 | |||
14 | extern struct video_device* video_devdata(struct file*); | ||
15 | |||
16 | #define to_video_device(cd) container_of(cd, struct video_device, class_dev) | ||
17 | static inline void | ||
18 | video_device_create_file(struct video_device *vfd, | ||
19 | struct class_device_attribute *attr) | ||
20 | { | ||
21 | class_device_create_file(&vfd->class_dev, attr); | ||
22 | } | ||
23 | static inline void | ||
24 | video_device_remove_file(struct video_device *vfd, | ||
25 | struct class_device_attribute *attr) | ||
26 | { | ||
27 | class_device_remove_file(&vfd->class_dev, attr); | ||
28 | } | ||
29 | |||
30 | #if OBSOLETE_OWNER /* to be removed in 2.6.15 */ | ||
31 | /* helper functions to access driver private data. */ | ||
32 | static inline void *video_get_drvdata(struct video_device *dev) | ||
33 | { | ||
34 | return dev->priv; | ||
35 | } | ||
36 | |||
37 | static inline void video_set_drvdata(struct video_device *dev, void *data) | ||
38 | { | ||
39 | dev->priv = data; | ||
40 | } | ||
41 | #endif | ||
42 | |||
43 | extern int video_exclusive_open(struct inode *inode, struct file *file); | ||
44 | extern int video_exclusive_release(struct inode *inode, struct file *file); | ||
45 | #endif /* __KERNEL__ */ | ||
46 | |||
47 | struct video_capability | 26 | struct video_capability |
48 | { | 27 | { |
49 | char name[32]; | 28 | char name[32]; |
@@ -363,6 +342,11 @@ struct video_code | |||
363 | #define VID_HARDWARE_SAA7114H 37 | 342 | #define VID_HARDWARE_SAA7114H 37 |
364 | #define VID_HARDWARE_SN9C102 38 | 343 | #define VID_HARDWARE_SN9C102 38 |
365 | #define VID_HARDWARE_ARV 39 | 344 | #define VID_HARDWARE_ARV 39 |
345 | |||
346 | #ifdef __KERNEL__ | ||
347 | #include <media/v4l2-dev.h> | ||
348 | #endif /* __KERNEL__ */ | ||
349 | |||
366 | #endif /* __LINUX_VIDEODEV_H */ | 350 | #endif /* __LINUX_VIDEODEV_H */ |
367 | 351 | ||
368 | /* | 352 | /* |
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index b3a848b6fb1c..bb58197ab6b9 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h | |||
@@ -1,29 +1,23 @@ | |||
1 | #ifndef __LINUX_VIDEODEV2_H | ||
2 | #define __LINUX_VIDEODEV2_H | ||
3 | /* | 1 | /* |
4 | * Video for Linux Two | 2 | * Video for Linux Two |
5 | * | 3 | * |
6 | * Header file for v4l or V4L2 drivers and applications, for | 4 | * Header file for v4l or V4L2 drivers and applications |
7 | * Linux kernels 2.2.x or 2.4.x. | 5 | * with public API. |
6 | * All kernel-specific stuff were moved to media/v4l2-dev.h, so | ||
7 | * no #if __KERNEL tests are allowed here | ||
8 | * | 8 | * |
9 | * See http://bytesex.org/v4l/ for API specs and other | 9 | * See http://linuxtv.org for more info |
10 | * v4l2 documentation. | ||
11 | * | 10 | * |
12 | * Author: Bill Dirks <bdirks@pacbell.net> | 11 | * Author: Bill Dirks <bdirks@pacbell.net> |
13 | * Justin Schoeman | 12 | * Justin Schoeman |
14 | * et al. | 13 | * et al. |
15 | */ | 14 | */ |
16 | #ifdef __KERNEL__ | 15 | #ifndef __LINUX_VIDEODEV2_H |
16 | #define __LINUX_VIDEODEV2_H | ||
17 | #include <linux/time.h> /* need struct timeval */ | 17 | #include <linux/time.h> /* need struct timeval */ |
18 | #include <linux/poll.h> | ||
19 | #include <linux/device.h> | ||
20 | #include <linux/mutex.h> | ||
21 | #endif | ||
22 | #include <linux/types.h> | 18 | #include <linux/types.h> |
23 | #include <linux/compiler.h> /* need __user */ | 19 | #include <linux/compiler.h> /* need __user */ |
24 | 20 | ||
25 | |||
26 | #define OBSOLETE_OWNER 1 /* It will be removed for 2.6.17 */ | ||
27 | #define HAVE_V4L2 1 | 21 | #define HAVE_V4L2 1 |
28 | 22 | ||
29 | /* | 23 | /* |
@@ -48,71 +42,6 @@ | |||
48 | #define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ | 42 | #define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ |
49 | #define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ | 43 | #define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ |
50 | 44 | ||
51 | #ifdef __KERNEL__ | ||
52 | |||
53 | /* Minor device allocation */ | ||
54 | #define MINOR_VFL_TYPE_GRABBER_MIN 0 | ||
55 | #define MINOR_VFL_TYPE_GRABBER_MAX 63 | ||
56 | #define MINOR_VFL_TYPE_RADIO_MIN 64 | ||
57 | #define MINOR_VFL_TYPE_RADIO_MAX 127 | ||
58 | #define MINOR_VFL_TYPE_VTX_MIN 192 | ||
59 | #define MINOR_VFL_TYPE_VTX_MAX 223 | ||
60 | #define MINOR_VFL_TYPE_VBI_MIN 224 | ||
61 | #define MINOR_VFL_TYPE_VBI_MAX 255 | ||
62 | |||
63 | #define VFL_TYPE_GRABBER 0 | ||
64 | #define VFL_TYPE_VBI 1 | ||
65 | #define VFL_TYPE_RADIO 2 | ||
66 | #define VFL_TYPE_VTX 3 | ||
67 | |||
68 | struct video_device | ||
69 | { | ||
70 | /* device info */ | ||
71 | struct device *dev; | ||
72 | char name[32]; | ||
73 | int type; /* v4l1 */ | ||
74 | int type2; /* v4l2 */ | ||
75 | int hardware; | ||
76 | int minor; | ||
77 | |||
78 | /* device ops + callbacks */ | ||
79 | const struct file_operations *fops; | ||
80 | void (*release)(struct video_device *vfd); | ||
81 | |||
82 | |||
83 | #if OBSOLETE_OWNER /* to be removed in 2.6.15 */ | ||
84 | /* obsolete -- fops->owner is used instead */ | ||
85 | struct module *owner; | ||
86 | /* dev->driver_data will be used instead some day. | ||
87 | * Use the video_{get|set}_drvdata() helper functions, | ||
88 | * so the switch over will be transparent for you. | ||
89 | * Or use {pci|usb}_{get|set}_drvdata() directly. */ | ||
90 | void *priv; | ||
91 | #endif | ||
92 | |||
93 | /* for videodev.c intenal usage -- please don't touch */ | ||
94 | int users; /* video_exclusive_{open|close} ... */ | ||
95 | struct mutex lock; /* ... helper function uses these */ | ||
96 | char devfs_name[64]; /* devfs */ | ||
97 | struct class_device class_dev; /* sysfs */ | ||
98 | }; | ||
99 | |||
100 | #define VIDEO_MAJOR 81 | ||
101 | |||
102 | extern int video_register_device(struct video_device *, int type, int nr); | ||
103 | extern void video_unregister_device(struct video_device *); | ||
104 | extern int video_usercopy(struct inode *inode, struct file *file, | ||
105 | unsigned int cmd, unsigned long arg, | ||
106 | int (*func)(struct inode *inode, struct file *file, | ||
107 | unsigned int cmd, void *arg)); | ||
108 | |||
109 | /* helper functions to alloc / release struct video_device, the | ||
110 | later can be used for video_device->release() */ | ||
111 | struct video_device *video_device_alloc(void); | ||
112 | void video_device_release(struct video_device *vfd); | ||
113 | |||
114 | #endif | ||
115 | |||
116 | /* | 45 | /* |
117 | * M I S C E L L A N E O U S | 46 | * M I S C E L L A N E O U S |
118 | */ | 47 | */ |
@@ -1098,6 +1027,7 @@ struct v4l2_streamparm | |||
1098 | #endif | 1027 | #endif |
1099 | #define VIDIOC_LOG_STATUS _IO ('V', 70) | 1028 | #define VIDIOC_LOG_STATUS _IO ('V', 70) |
1100 | 1029 | ||
1030 | #ifdef __OLD_VIDIOC_ | ||
1101 | /* for compatibility, will go away some day */ | 1031 | /* for compatibility, will go away some day */ |
1102 | #define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) | 1032 | #define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) |
1103 | #define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) | 1033 | #define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) |
@@ -1105,57 +1035,10 @@ struct v4l2_streamparm | |||
1105 | #define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) | 1035 | #define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) |
1106 | #define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) | 1036 | #define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) |
1107 | #define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap) | 1037 | #define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap) |
1108 | |||
1109 | #define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ | ||
1110 | |||
1111 | |||
1112 | #ifdef __KERNEL__ | ||
1113 | /* | ||
1114 | * | ||
1115 | * V 4 L 2 D R I V E R H E L P E R A P I | ||
1116 | * | ||
1117 | * Some commonly needed functions for drivers (v4l2-common.o module) | ||
1118 | */ | ||
1119 | #include <linux/fs.h> | ||
1120 | |||
1121 | /* Video standard functions */ | ||
1122 | extern unsigned int v4l2_video_std_fps(struct v4l2_standard *vs); | ||
1123 | extern int v4l2_video_std_construct(struct v4l2_standard *vs, | ||
1124 | int id, char *name); | ||
1125 | |||
1126 | /* prority handling */ | ||
1127 | struct v4l2_prio_state { | ||
1128 | atomic_t prios[4]; | ||
1129 | }; | ||
1130 | int v4l2_prio_init(struct v4l2_prio_state *global); | ||
1131 | int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, | ||
1132 | enum v4l2_priority new); | ||
1133 | int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local); | ||
1134 | int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local); | ||
1135 | enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global); | ||
1136 | int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local); | ||
1137 | |||
1138 | /* names for fancy debug output */ | ||
1139 | extern char *v4l2_field_names[]; | ||
1140 | extern char *v4l2_type_names[]; | ||
1141 | |||
1142 | /* Compatibility layer interface -- v4l1-compat module */ | ||
1143 | typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file, | ||
1144 | unsigned int cmd, void *arg); | ||
1145 | |||
1146 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
1147 | int v4l_compat_translate_ioctl(struct inode *inode, struct file *file, | ||
1148 | int cmd, void *arg, v4l2_kioctl driver_ioctl); | ||
1149 | #else | ||
1150 | #define v4l_compat_translate_ioctl(inode,file,cmd,arg,ioctl) -EINVAL | ||
1151 | #endif | 1038 | #endif |
1152 | 1039 | ||
1153 | /* 32 Bits compatibility layer for 64 bits processors */ | 1040 | #define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ |
1154 | extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd, | ||
1155 | unsigned long arg); | ||
1156 | |||
1157 | 1041 | ||
1158 | #endif /* __KERNEL__ */ | ||
1159 | #endif /* __LINUX_VIDEODEV2_H */ | 1042 | #endif /* __LINUX_VIDEODEV2_H */ |
1160 | 1043 | ||
1161 | /* | 1044 | /* |
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index e94aff029cc5..1440d4ab6af9 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h | |||
@@ -26,8 +26,14 @@ | |||
26 | #ifndef V4L2_COMMON_H_ | 26 | #ifndef V4L2_COMMON_H_ |
27 | #define V4L2_COMMON_H_ | 27 | #define V4L2_COMMON_H_ |
28 | 28 | ||
29 | #include <media/v4l2-dev.h> | ||
30 | |||
29 | /* v4l debugging and diagnostics */ | 31 | /* v4l debugging and diagnostics */ |
30 | 32 | ||
33 | /* Debug bitmask flags to be used on V4L2 */ | ||
34 | #define V4L2_DEBUG_IOCTL 0x01 | ||
35 | #define V4L2_DEBUG_IOCTL_ARG 0x02 | ||
36 | |||
31 | /* Common printk constucts for v4l-i2c drivers. These macros create a unique | 37 | /* Common printk constucts for v4l-i2c drivers. These macros create a unique |
32 | prefix consisting of the driver name, the adapter number and the i2c | 38 | prefix consisting of the driver name, the adapter number and the i2c |
33 | address. */ | 39 | address. */ |
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h new file mode 100644 index 000000000000..c2f54d2c9a4c --- /dev/null +++ b/include/media/v4l2-dev.h | |||
@@ -0,0 +1,371 @@ | |||
1 | /* | ||
2 | * | ||
3 | * V 4 L 2 D R I V E R H E L P E R A P I | ||
4 | * | ||
5 | * Moved from videodev2.h | ||
6 | * | ||
7 | * Some commonly needed functions for drivers (v4l2-common.o module) | ||
8 | */ | ||
9 | #ifndef _V4L2_DEV_H | ||
10 | #define _V4L2_DEV_H | ||
11 | |||
12 | #define OBSOLETE_OWNER 1 /* to be removed soon */ | ||
13 | |||
14 | #include <linux/poll.h> | ||
15 | #include <linux/fs.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/mutex.h> | ||
18 | #include <linux/compiler.h> /* need __user */ | ||
19 | #ifdef CONFIG_VIDEO_V4L1 | ||
20 | #include <linux/videodev.h> | ||
21 | #else | ||
22 | #include <linux/videodev2.h> | ||
23 | #endif | ||
24 | |||
25 | #include <linux/fs.h> | ||
26 | |||
27 | #define VIDEO_MAJOR 81 | ||
28 | /* Minor device allocation */ | ||
29 | #define MINOR_VFL_TYPE_GRABBER_MIN 0 | ||
30 | #define MINOR_VFL_TYPE_GRABBER_MAX 63 | ||
31 | #define MINOR_VFL_TYPE_RADIO_MIN 64 | ||
32 | #define MINOR_VFL_TYPE_RADIO_MAX 127 | ||
33 | #define MINOR_VFL_TYPE_VTX_MIN 192 | ||
34 | #define MINOR_VFL_TYPE_VTX_MAX 223 | ||
35 | #define MINOR_VFL_TYPE_VBI_MIN 224 | ||
36 | #define MINOR_VFL_TYPE_VBI_MAX 255 | ||
37 | |||
38 | #define VFL_TYPE_GRABBER 0 | ||
39 | #define VFL_TYPE_VBI 1 | ||
40 | #define VFL_TYPE_RADIO 2 | ||
41 | #define VFL_TYPE_VTX 3 | ||
42 | |||
43 | const struct file_operations *fops; | ||
44 | |||
45 | /* Video standard functions */ | ||
46 | extern unsigned int v4l2_video_std_fps(struct v4l2_standard *vs); | ||
47 | extern int v4l2_video_std_construct(struct v4l2_standard *vs, | ||
48 | int id, char *name); | ||
49 | |||
50 | /* prority handling */ | ||
51 | struct v4l2_prio_state { | ||
52 | atomic_t prios[4]; | ||
53 | }; | ||
54 | int v4l2_prio_init(struct v4l2_prio_state *global); | ||
55 | int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, | ||
56 | enum v4l2_priority new); | ||
57 | int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local); | ||
58 | int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local); | ||
59 | enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global); | ||
60 | int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local); | ||
61 | |||
62 | /* names for fancy debug output */ | ||
63 | extern char *v4l2_field_names[]; | ||
64 | extern char *v4l2_type_names[]; | ||
65 | |||
66 | /* Compatibility layer interface -- v4l1-compat module */ | ||
67 | typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file, | ||
68 | unsigned int cmd, void *arg); | ||
69 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
70 | int v4l_compat_translate_ioctl(struct inode *inode, struct file *file, | ||
71 | int cmd, void *arg, v4l2_kioctl driver_ioctl); | ||
72 | #else | ||
73 | #define v4l_compat_translate_ioctl(inode,file,cmd,arg,ioctl) -EINVAL | ||
74 | #endif | ||
75 | |||
76 | /* 32 Bits compatibility layer for 64 bits processors */ | ||
77 | extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd, | ||
78 | unsigned long arg); | ||
79 | |||
80 | /* | ||
81 | * Newer version of video_device, handled by videodev2.c | ||
82 | * This version moves redundant code from video device code to | ||
83 | * the common handler | ||
84 | */ | ||
85 | struct v4l2_tvnorm { | ||
86 | char *name; | ||
87 | v4l2_std_id id; | ||
88 | |||
89 | void *priv_data; | ||
90 | }; | ||
91 | |||
92 | struct video_device | ||
93 | { | ||
94 | /* device ops */ | ||
95 | struct file_operations *fops; | ||
96 | |||
97 | /* device info */ | ||
98 | struct device *dev; | ||
99 | char name[32]; | ||
100 | int type; /* v4l1 */ | ||
101 | int type2; /* v4l2 */ | ||
102 | int hardware; | ||
103 | int minor; | ||
104 | |||
105 | int debug; /* Activates debug level*/ | ||
106 | |||
107 | /* Video standard vars */ | ||
108 | int tvnormsize; /* Size of tvnorm array */ | ||
109 | v4l2_std_id current_norm; /* Current tvnorm */ | ||
110 | struct v4l2_tvnorm *tvnorms; | ||
111 | |||
112 | /* callbacks */ | ||
113 | void (*release)(struct video_device *vfd); | ||
114 | |||
115 | /* ioctl callbacks */ | ||
116 | |||
117 | /* VIDIOC_QUERYCAP handler */ | ||
118 | int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap); | ||
119 | |||
120 | /* Priority handling */ | ||
121 | int (*vidioc_g_priority) (struct file *file, void *fh, | ||
122 | enum v4l2_priority *p); | ||
123 | int (*vidioc_s_priority) (struct file *file, void *fh, | ||
124 | enum v4l2_priority p); | ||
125 | |||
126 | /* VIDIOC_ENUM_FMT handlers */ | ||
127 | int (*vidioc_enum_fmt_cap) (struct file *file, void *fh, | ||
128 | struct v4l2_fmtdesc *f); | ||
129 | int (*vidioc_enum_fmt_overlay) (struct file *file, void *fh, | ||
130 | struct v4l2_fmtdesc *f); | ||
131 | int (*vidioc_enum_fmt_vbi) (struct file *file, void *fh, | ||
132 | struct v4l2_fmtdesc *f); | ||
133 | int (*vidioc_enum_fmt_vbi_capture) (struct file *file, void *fh, | ||
134 | struct v4l2_fmtdesc *f); | ||
135 | int (*vidioc_enum_fmt_video_output)(struct file *file, void *fh, | ||
136 | struct v4l2_fmtdesc *f); | ||
137 | int (*vidioc_enum_fmt_vbi_output) (struct file *file, void *fh, | ||
138 | struct v4l2_fmtdesc *f); | ||
139 | int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh, | ||
140 | struct v4l2_fmtdesc *f); | ||
141 | |||
142 | /* VIDIOC_G_FMT handlers */ | ||
143 | int (*vidioc_g_fmt_cap) (struct file *file, void *fh, | ||
144 | struct v4l2_format *f); | ||
145 | int (*vidioc_g_fmt_overlay) (struct file *file, void *fh, | ||
146 | struct v4l2_format *f); | ||
147 | int (*vidioc_g_fmt_vbi) (struct file *file, void *fh, | ||
148 | struct v4l2_format *f); | ||
149 | int (*vidioc_g_fmt_vbi_output) (struct file *file, void *fh, | ||
150 | struct v4l2_format *f); | ||
151 | int (*vidioc_g_fmt_vbi_capture)(struct file *file, void *fh, | ||
152 | struct v4l2_format *f); | ||
153 | int (*vidioc_g_fmt_video_output)(struct file *file, void *fh, | ||
154 | struct v4l2_format *f); | ||
155 | int (*vidioc_g_fmt_type_private)(struct file *file, void *fh, | ||
156 | struct v4l2_format *f); | ||
157 | |||
158 | /* VIDIOC_S_FMT handlers */ | ||
159 | int (*vidioc_s_fmt_cap) (struct file *file, void *fh, | ||
160 | struct v4l2_format *f); | ||
161 | |||
162 | int (*vidioc_s_fmt_overlay) (struct file *file, void *fh, | ||
163 | struct v4l2_format *f); | ||
164 | int (*vidioc_s_fmt_vbi) (struct file *file, void *fh, | ||
165 | struct v4l2_format *f); | ||
166 | int (*vidioc_s_fmt_vbi_output) (struct file *file, void *fh, | ||
167 | struct v4l2_format *f); | ||
168 | int (*vidioc_s_fmt_vbi_capture)(struct file *file, void *fh, | ||
169 | struct v4l2_format *f); | ||
170 | int (*vidioc_s_fmt_video_output)(struct file *file, void *fh, | ||
171 | struct v4l2_format *f); | ||
172 | int (*vidioc_s_fmt_type_private)(struct file *file, void *fh, | ||
173 | struct v4l2_format *f); | ||
174 | |||
175 | /* VIDIOC_TRY_FMT handlers */ | ||
176 | int (*vidioc_try_fmt_cap) (struct file *file, void *fh, | ||
177 | struct v4l2_format *f); | ||
178 | int (*vidioc_try_fmt_overlay) (struct file *file, void *fh, | ||
179 | struct v4l2_format *f); | ||
180 | int (*vidioc_try_fmt_vbi) (struct file *file, void *fh, | ||
181 | struct v4l2_format *f); | ||
182 | int (*vidioc_try_fmt_vbi_output) (struct file *file, void *fh, | ||
183 | struct v4l2_format *f); | ||
184 | int (*vidioc_try_fmt_vbi_capture)(struct file *file, void *fh, | ||
185 | struct v4l2_format *f); | ||
186 | int (*vidioc_try_fmt_video_output)(struct file *file, void *fh, | ||
187 | struct v4l2_format *f); | ||
188 | int (*vidioc_try_fmt_type_private)(struct file *file, void *fh, | ||
189 | struct v4l2_format *f); | ||
190 | |||
191 | /* Buffer handlers */ | ||
192 | int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b); | ||
193 | int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b); | ||
194 | int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b); | ||
195 | int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b); | ||
196 | |||
197 | |||
198 | int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i); | ||
199 | #ifdef HAVE_V4L1 | ||
200 | /* buffer type is struct vidio_mbuf * */ | ||
201 | int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p); | ||
202 | #endif | ||
203 | int (*vidioc_g_fbuf) (struct file *file, void *fh, | ||
204 | struct v4l2_framebuffer *a); | ||
205 | int (*vidioc_s_fbuf) (struct file *file, void *fh, | ||
206 | struct v4l2_framebuffer *a); | ||
207 | |||
208 | /* Stream on/off */ | ||
209 | int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i); | ||
210 | int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i); | ||
211 | |||
212 | /* Standard handling | ||
213 | G_STD and ENUMSTD are handled by videodev.c | ||
214 | */ | ||
215 | int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id a); | ||
216 | int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a); | ||
217 | |||
218 | /* Input handling */ | ||
219 | int (*vidioc_enum_input)(struct file *file, void *fh, | ||
220 | struct v4l2_input *inp); | ||
221 | int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i); | ||
222 | int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i); | ||
223 | |||
224 | /* Output handling */ | ||
225 | int (*vidioc_enumoutput) (struct file *file, void *fh, | ||
226 | struct v4l2_output *a); | ||
227 | int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i); | ||
228 | int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i); | ||
229 | |||
230 | /* Control handling */ | ||
231 | int (*vidioc_queryctrl) (struct file *file, void *fh, | ||
232 | struct v4l2_queryctrl *a); | ||
233 | int (*vidioc_g_ctrl) (struct file *file, void *fh, | ||
234 | struct v4l2_control *a); | ||
235 | int (*vidioc_s_ctrl) (struct file *file, void *fh, | ||
236 | struct v4l2_control *a); | ||
237 | int (*vidioc_querymenu) (struct file *file, void *fh, | ||
238 | struct v4l2_querymenu *a); | ||
239 | |||
240 | /* Audio ioctls */ | ||
241 | int (*vidioc_enumaudio) (struct file *file, void *fh, | ||
242 | struct v4l2_audio *a); | ||
243 | int (*vidioc_g_audio) (struct file *file, void *fh, | ||
244 | struct v4l2_audio *a); | ||
245 | int (*vidioc_s_audio) (struct file *file, void *fh, | ||
246 | struct v4l2_audio *a); | ||
247 | |||
248 | /* Audio out ioctls */ | ||
249 | int (*vidioc_enumaudout) (struct file *file, void *fh, | ||
250 | struct v4l2_audioout *a); | ||
251 | int (*vidioc_g_audout) (struct file *file, void *fh, | ||
252 | struct v4l2_audioout *a); | ||
253 | int (*vidioc_s_audout) (struct file *file, void *fh, | ||
254 | struct v4l2_audioout *a); | ||
255 | int (*vidioc_g_modulator) (struct file *file, void *fh, | ||
256 | struct v4l2_modulator *a); | ||
257 | int (*vidioc_s_modulator) (struct file *file, void *fh, | ||
258 | struct v4l2_modulator *a); | ||
259 | /* Crop ioctls */ | ||
260 | int (*vidioc_cropcap) (struct file *file, void *fh, | ||
261 | struct v4l2_cropcap *a); | ||
262 | int (*vidioc_g_crop) (struct file *file, void *fh, | ||
263 | struct v4l2_crop *a); | ||
264 | int (*vidioc_s_crop) (struct file *file, void *fh, | ||
265 | struct v4l2_crop *a); | ||
266 | /* Compression ioctls */ | ||
267 | int (*vidioc_g_mpegcomp) (struct file *file, void *fh, | ||
268 | struct v4l2_mpeg_compression *a); | ||
269 | int (*vidioc_s_mpegcomp) (struct file *file, void *fh, | ||
270 | struct v4l2_mpeg_compression *a); | ||
271 | int (*vidioc_g_jpegcomp) (struct file *file, void *fh, | ||
272 | struct v4l2_jpegcompression *a); | ||
273 | int (*vidioc_s_jpegcomp) (struct file *file, void *fh, | ||
274 | struct v4l2_jpegcompression *a); | ||
275 | |||
276 | /* Stream type-dependent parameter ioctls */ | ||
277 | int (*vidioc_g_parm) (struct file *file, void *fh, | ||
278 | struct v4l2_streamparm *a); | ||
279 | int (*vidioc_s_parm) (struct file *file, void *fh, | ||
280 | struct v4l2_streamparm *a); | ||
281 | |||
282 | /* Tuner ioctls */ | ||
283 | int (*vidioc_g_tuner) (struct file *file, void *fh, | ||
284 | struct v4l2_tuner *a); | ||
285 | int (*vidioc_s_tuner) (struct file *file, void *fh, | ||
286 | struct v4l2_tuner *a); | ||
287 | int (*vidioc_g_frequency) (struct file *file, void *fh, | ||
288 | struct v4l2_frequency *a); | ||
289 | int (*vidioc_s_frequency) (struct file *file, void *fh, | ||
290 | struct v4l2_frequency *a); | ||
291 | |||
292 | /* Sliced VBI cap */ | ||
293 | int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh, | ||
294 | struct v4l2_sliced_vbi_cap *a); | ||
295 | |||
296 | /* Log status ioctl */ | ||
297 | int (*vidioc_log_status) (struct file *file, void *fh); | ||
298 | |||
299 | |||
300 | #if OBSOLETE_OWNER /* to be removed soon */ | ||
301 | /* obsolete -- fops->owner is used instead */ | ||
302 | struct module *owner; | ||
303 | /* dev->driver_data will be used instead some day. | ||
304 | * Use the video_{get|set}_drvdata() helper functions, | ||
305 | * so the switch over will be transparent for you. | ||
306 | * Or use {pci|usb}_{get|set}_drvdata() directly. */ | ||
307 | void *priv; | ||
308 | #endif | ||
309 | |||
310 | /* for videodev.c intenal usage -- please don't touch */ | ||
311 | int users; /* video_exclusive_{open|close} ... */ | ||
312 | struct mutex lock; /* ... helper function uses these */ | ||
313 | char devfs_name[64]; /* devfs */ | ||
314 | struct class_device class_dev; /* sysfs */ | ||
315 | }; | ||
316 | |||
317 | /* Version 2 functions */ | ||
318 | extern int video_register_device(struct video_device *vfd, int type, int nr); | ||
319 | void video_unregister_device(struct video_device *); | ||
320 | extern int video_ioctl2(struct inode *inode, struct file *file, | ||
321 | unsigned int cmd, unsigned long arg); | ||
322 | |||
323 | /* helper functions to alloc / release struct video_device, the | ||
324 | later can be used for video_device->release() */ | ||
325 | struct video_device *video_device_alloc(void); | ||
326 | void video_device_release(struct video_device *vfd); | ||
327 | |||
328 | /* Include support for obsoleted stuff */ | ||
329 | extern int video_usercopy(struct inode *inode, struct file *file, | ||
330 | unsigned int cmd, unsigned long arg, | ||
331 | int (*func)(struct inode *inode, struct file *file, | ||
332 | unsigned int cmd, void *arg)); | ||
333 | |||
334 | |||
335 | #ifdef HAVE_V4L1 | ||
336 | #include <linux/mm.h> | ||
337 | |||
338 | extern struct video_device* video_devdata(struct file*); | ||
339 | |||
340 | #define to_video_device(cd) container_of(cd, struct video_device, class_dev) | ||
341 | static inline void | ||
342 | video_device_create_file(struct video_device *vfd, | ||
343 | struct class_device_attribute *attr) | ||
344 | { | ||
345 | class_device_create_file(&vfd->class_dev, attr); | ||
346 | } | ||
347 | static inline void | ||
348 | video_device_remove_file(struct video_device *vfd, | ||
349 | struct class_device_attribute *attr) | ||
350 | { | ||
351 | class_device_remove_file(&vfd->class_dev, attr); | ||
352 | } | ||
353 | |||
354 | #if OBSOLETE_OWNER /* to be removed soon */ | ||
355 | /* helper functions to access driver private data. */ | ||
356 | static inline void *video_get_drvdata(struct video_device *dev) | ||
357 | { | ||
358 | return dev->priv; | ||
359 | } | ||
360 | |||
361 | static inline void video_set_drvdata(struct video_device *dev, void *data) | ||
362 | { | ||
363 | dev->priv = data; | ||
364 | } | ||
365 | #endif | ||
366 | |||
367 | extern int video_exclusive_open(struct inode *inode, struct file *file); | ||
368 | extern int video_exclusive_release(struct inode *inode, struct file *file); | ||
369 | #endif /* HAVE_V4L1 */ | ||
370 | |||
371 | #endif /* _V4L2_DEV_H */ | ||
diff --git a/include/media/video-buf.h b/include/media/video-buf.h index fff3fd0fbf94..1115a256969f 100644 --- a/include/media/video-buf.h +++ b/include/media/video-buf.h | |||
@@ -23,6 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/videodev2.h> | 25 | #include <linux/videodev2.h> |
26 | #include <linux/poll.h> | ||
26 | 27 | ||
27 | #define UNSET (-1U) | 28 | #define UNSET (-1U) |
28 | 29 | ||