2 * Video capture interface for Linux version 2
4 * A generic video device interface for the LINUX operating system
5 * using a set of device structures/vectors for low level operations.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
12 * Authors: Alan Cox, <alan@redhat.com> (version 1)
13 * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2)
15 * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com>
16 * - Added procfs support
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); \
26 #define dbgarg2(fmt, arg...) \
27 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \
28 printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg);
30 #include <linux/module.h>
31 #include <linux/types.h>
32 #include <linux/kernel.h>
34 #include <linux/string.h>
35 #include <linux/errno.h>
36 #include <linux/init.h>
37 #include <linux/kmod.h>
38 #include <linux/slab.h>
39 #include <asm/uaccess.h>
40 #include <asm/system.h>
42 #define __OLD_VIDIOC_ /* To allow fixing old calls*/
43 #include <linux/videodev2.h>
45 #ifdef CONFIG_VIDEO_V4L1
46 #include <linux/videodev.h>
48 #include <media/v4l2-common.h>
49 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
51 #include <linux/video_decoder.h>
52 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
54 #define VIDEO_NUM_DEVICES 256
55 #define VIDEO_NAME "video4linux"
57 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
59 /* video4linux standard ID conversion to standard name
61 char *v4l2_norm_to_name(v4l2_std_id id
)
66 /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
67 64 bit comparations. So, on that architecture, with some gcc
68 variants, compilation fails. Currently, the max value is 30bit wide.
100 case V4L2_STD_PAL_D1
:
112 case V4L2_STD_PAL_Nc
:
115 case V4L2_STD_PAL_60
:
121 case V4L2_STD_NTSC_M
:
124 case V4L2_STD_NTSC_M_JP
:
127 case V4L2_STD_NTSC_443
:
130 case V4L2_STD_NTSC_M_KR
:
136 case V4L2_STD_SECAM_DK
:
139 case V4L2_STD_SECAM_B
:
142 case V4L2_STD_SECAM_D
:
145 case V4L2_STD_SECAM_G
:
148 case V4L2_STD_SECAM_H
:
151 case V4L2_STD_SECAM_K
:
154 case V4L2_STD_SECAM_K1
:
157 case V4L2_STD_SECAM_L
:
160 case V4L2_STD_SECAM_LC
:
170 EXPORT_SYMBOL(v4l2_norm_to_name
);
172 /* Fill in the fields of a v4l2_standard structure according to the
173 'id' and 'transmission' parameters. Returns negative on error. */
174 int v4l2_video_std_construct(struct v4l2_standard
*vs
,
177 u32 index
= vs
->index
;
179 memset(vs
, 0, sizeof(struct v4l2_standard
));
182 if (id
& V4L2_STD_525_60
) {
183 vs
->frameperiod
.numerator
= 1001;
184 vs
->frameperiod
.denominator
= 30000;
185 vs
->framelines
= 525;
187 vs
->frameperiod
.numerator
= 1;
188 vs
->frameperiod
.denominator
= 25;
189 vs
->framelines
= 625;
191 strlcpy(vs
->name
, name
, sizeof(vs
->name
));
194 EXPORT_SYMBOL(v4l2_video_std_construct
);
196 /* ----------------------------------------------------------------- */
197 /* some arrays for pretty-printing debug messages of enum types */
199 char *v4l2_field_names
[] = {
200 [V4L2_FIELD_ANY
] = "any",
201 [V4L2_FIELD_NONE
] = "none",
202 [V4L2_FIELD_TOP
] = "top",
203 [V4L2_FIELD_BOTTOM
] = "bottom",
204 [V4L2_FIELD_INTERLACED
] = "interlaced",
205 [V4L2_FIELD_SEQ_TB
] = "seq-tb",
206 [V4L2_FIELD_SEQ_BT
] = "seq-bt",
207 [V4L2_FIELD_ALTERNATE
] = "alternate",
208 [V4L2_FIELD_INTERLACED_TB
] = "interlaced-tb",
209 [V4L2_FIELD_INTERLACED_BT
] = "interlaced-bt",
211 EXPORT_SYMBOL(v4l2_field_names
);
213 char *v4l2_type_names
[] = {
214 [V4L2_BUF_TYPE_VIDEO_CAPTURE
] = "video-cap",
215 [V4L2_BUF_TYPE_VIDEO_OVERLAY
] = "video-over",
216 [V4L2_BUF_TYPE_VIDEO_OUTPUT
] = "video-out",
217 [V4L2_BUF_TYPE_VBI_CAPTURE
] = "vbi-cap",
218 [V4L2_BUF_TYPE_VBI_OUTPUT
] = "vbi-out",
219 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
] = "sliced-vbi-cap",
220 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
] = "sliced-vbi-out",
221 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
] = "video-out-over",
223 EXPORT_SYMBOL(v4l2_type_names
);
225 static char *v4l2_memory_names
[] = {
226 [V4L2_MEMORY_MMAP
] = "mmap",
227 [V4L2_MEMORY_USERPTR
] = "userptr",
228 [V4L2_MEMORY_OVERLAY
] = "overlay",
231 #define prt_names(a, arr) ((((a) >= 0) && ((a) < ARRAY_SIZE(arr))) ? \
234 /* ------------------------------------------------------------------ */
235 /* debug help functions */
237 #ifdef CONFIG_VIDEO_V4L1_COMPAT
238 static const char *v4l1_ioctls
[] = {
239 [_IOC_NR(VIDIOCGCAP
)] = "VIDIOCGCAP",
240 [_IOC_NR(VIDIOCGCHAN
)] = "VIDIOCGCHAN",
241 [_IOC_NR(VIDIOCSCHAN
)] = "VIDIOCSCHAN",
242 [_IOC_NR(VIDIOCGTUNER
)] = "VIDIOCGTUNER",
243 [_IOC_NR(VIDIOCSTUNER
)] = "VIDIOCSTUNER",
244 [_IOC_NR(VIDIOCGPICT
)] = "VIDIOCGPICT",
245 [_IOC_NR(VIDIOCSPICT
)] = "VIDIOCSPICT",
246 [_IOC_NR(VIDIOCCAPTURE
)] = "VIDIOCCAPTURE",
247 [_IOC_NR(VIDIOCGWIN
)] = "VIDIOCGWIN",
248 [_IOC_NR(VIDIOCSWIN
)] = "VIDIOCSWIN",
249 [_IOC_NR(VIDIOCGFBUF
)] = "VIDIOCGFBUF",
250 [_IOC_NR(VIDIOCSFBUF
)] = "VIDIOCSFBUF",
251 [_IOC_NR(VIDIOCKEY
)] = "VIDIOCKEY",
252 [_IOC_NR(VIDIOCGFREQ
)] = "VIDIOCGFREQ",
253 [_IOC_NR(VIDIOCSFREQ
)] = "VIDIOCSFREQ",
254 [_IOC_NR(VIDIOCGAUDIO
)] = "VIDIOCGAUDIO",
255 [_IOC_NR(VIDIOCSAUDIO
)] = "VIDIOCSAUDIO",
256 [_IOC_NR(VIDIOCSYNC
)] = "VIDIOCSYNC",
257 [_IOC_NR(VIDIOCMCAPTURE
)] = "VIDIOCMCAPTURE",
258 [_IOC_NR(VIDIOCGMBUF
)] = "VIDIOCGMBUF",
259 [_IOC_NR(VIDIOCGUNIT
)] = "VIDIOCGUNIT",
260 [_IOC_NR(VIDIOCGCAPTURE
)] = "VIDIOCGCAPTURE",
261 [_IOC_NR(VIDIOCSCAPTURE
)] = "VIDIOCSCAPTURE",
262 [_IOC_NR(VIDIOCSPLAYMODE
)] = "VIDIOCSPLAYMODE",
263 [_IOC_NR(VIDIOCSWRITEMODE
)] = "VIDIOCSWRITEMODE",
264 [_IOC_NR(VIDIOCGPLAYINFO
)] = "VIDIOCGPLAYINFO",
265 [_IOC_NR(VIDIOCSMICROCODE
)] = "VIDIOCSMICROCODE",
266 [_IOC_NR(VIDIOCGVBIFMT
)] = "VIDIOCGVBIFMT",
267 [_IOC_NR(VIDIOCSVBIFMT
)] = "VIDIOCSVBIFMT"
269 #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
272 static const char *v4l2_ioctls
[] = {
273 [_IOC_NR(VIDIOC_QUERYCAP
)] = "VIDIOC_QUERYCAP",
274 [_IOC_NR(VIDIOC_RESERVED
)] = "VIDIOC_RESERVED",
275 [_IOC_NR(VIDIOC_ENUM_FMT
)] = "VIDIOC_ENUM_FMT",
276 [_IOC_NR(VIDIOC_G_FMT
)] = "VIDIOC_G_FMT",
277 [_IOC_NR(VIDIOC_S_FMT
)] = "VIDIOC_S_FMT",
278 [_IOC_NR(VIDIOC_REQBUFS
)] = "VIDIOC_REQBUFS",
279 [_IOC_NR(VIDIOC_QUERYBUF
)] = "VIDIOC_QUERYBUF",
280 [_IOC_NR(VIDIOC_G_FBUF
)] = "VIDIOC_G_FBUF",
281 [_IOC_NR(VIDIOC_S_FBUF
)] = "VIDIOC_S_FBUF",
282 [_IOC_NR(VIDIOC_OVERLAY
)] = "VIDIOC_OVERLAY",
283 [_IOC_NR(VIDIOC_QBUF
)] = "VIDIOC_QBUF",
284 [_IOC_NR(VIDIOC_DQBUF
)] = "VIDIOC_DQBUF",
285 [_IOC_NR(VIDIOC_STREAMON
)] = "VIDIOC_STREAMON",
286 [_IOC_NR(VIDIOC_STREAMOFF
)] = "VIDIOC_STREAMOFF",
287 [_IOC_NR(VIDIOC_G_PARM
)] = "VIDIOC_G_PARM",
288 [_IOC_NR(VIDIOC_S_PARM
)] = "VIDIOC_S_PARM",
289 [_IOC_NR(VIDIOC_G_STD
)] = "VIDIOC_G_STD",
290 [_IOC_NR(VIDIOC_S_STD
)] = "VIDIOC_S_STD",
291 [_IOC_NR(VIDIOC_ENUMSTD
)] = "VIDIOC_ENUMSTD",
292 [_IOC_NR(VIDIOC_ENUMINPUT
)] = "VIDIOC_ENUMINPUT",
293 [_IOC_NR(VIDIOC_G_CTRL
)] = "VIDIOC_G_CTRL",
294 [_IOC_NR(VIDIOC_S_CTRL
)] = "VIDIOC_S_CTRL",
295 [_IOC_NR(VIDIOC_G_TUNER
)] = "VIDIOC_G_TUNER",
296 [_IOC_NR(VIDIOC_S_TUNER
)] = "VIDIOC_S_TUNER",
297 [_IOC_NR(VIDIOC_G_AUDIO
)] = "VIDIOC_G_AUDIO",
298 [_IOC_NR(VIDIOC_S_AUDIO
)] = "VIDIOC_S_AUDIO",
299 [_IOC_NR(VIDIOC_QUERYCTRL
)] = "VIDIOC_QUERYCTRL",
300 [_IOC_NR(VIDIOC_QUERYMENU
)] = "VIDIOC_QUERYMENU",
301 [_IOC_NR(VIDIOC_G_INPUT
)] = "VIDIOC_G_INPUT",
302 [_IOC_NR(VIDIOC_S_INPUT
)] = "VIDIOC_S_INPUT",
303 [_IOC_NR(VIDIOC_G_OUTPUT
)] = "VIDIOC_G_OUTPUT",
304 [_IOC_NR(VIDIOC_S_OUTPUT
)] = "VIDIOC_S_OUTPUT",
305 [_IOC_NR(VIDIOC_ENUMOUTPUT
)] = "VIDIOC_ENUMOUTPUT",
306 [_IOC_NR(VIDIOC_G_AUDOUT
)] = "VIDIOC_G_AUDOUT",
307 [_IOC_NR(VIDIOC_S_AUDOUT
)] = "VIDIOC_S_AUDOUT",
308 [_IOC_NR(VIDIOC_G_MODULATOR
)] = "VIDIOC_G_MODULATOR",
309 [_IOC_NR(VIDIOC_S_MODULATOR
)] = "VIDIOC_S_MODULATOR",
310 [_IOC_NR(VIDIOC_G_FREQUENCY
)] = "VIDIOC_G_FREQUENCY",
311 [_IOC_NR(VIDIOC_S_FREQUENCY
)] = "VIDIOC_S_FREQUENCY",
312 [_IOC_NR(VIDIOC_CROPCAP
)] = "VIDIOC_CROPCAP",
313 [_IOC_NR(VIDIOC_G_CROP
)] = "VIDIOC_G_CROP",
314 [_IOC_NR(VIDIOC_S_CROP
)] = "VIDIOC_S_CROP",
315 [_IOC_NR(VIDIOC_G_JPEGCOMP
)] = "VIDIOC_G_JPEGCOMP",
316 [_IOC_NR(VIDIOC_S_JPEGCOMP
)] = "VIDIOC_S_JPEGCOMP",
317 [_IOC_NR(VIDIOC_QUERYSTD
)] = "VIDIOC_QUERYSTD",
318 [_IOC_NR(VIDIOC_TRY_FMT
)] = "VIDIOC_TRY_FMT",
319 [_IOC_NR(VIDIOC_ENUMAUDIO
)] = "VIDIOC_ENUMAUDIO",
320 [_IOC_NR(VIDIOC_ENUMAUDOUT
)] = "VIDIOC_ENUMAUDOUT",
321 [_IOC_NR(VIDIOC_G_PRIORITY
)] = "VIDIOC_G_PRIORITY",
322 [_IOC_NR(VIDIOC_S_PRIORITY
)] = "VIDIOC_S_PRIORITY",
323 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP
)] = "VIDIOC_G_SLICED_VBI_CAP",
324 [_IOC_NR(VIDIOC_LOG_STATUS
)] = "VIDIOC_LOG_STATUS",
325 [_IOC_NR(VIDIOC_G_EXT_CTRLS
)] = "VIDIOC_G_EXT_CTRLS",
326 [_IOC_NR(VIDIOC_S_EXT_CTRLS
)] = "VIDIOC_S_EXT_CTRLS",
327 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS
)] = "VIDIOC_TRY_EXT_CTRLS",
329 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES
)] = "VIDIOC_ENUM_FRAMESIZES",
330 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS
)] = "VIDIOC_ENUM_FRAMEINTERVALS",
331 [_IOC_NR(VIDIOC_G_ENC_INDEX
)] = "VIDIOC_G_ENC_INDEX",
332 [_IOC_NR(VIDIOC_ENCODER_CMD
)] = "VIDIOC_ENCODER_CMD",
333 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD
)] = "VIDIOC_TRY_ENCODER_CMD",
335 [_IOC_NR(VIDIOC_DBG_S_REGISTER
)] = "VIDIOC_DBG_S_REGISTER",
336 [_IOC_NR(VIDIOC_DBG_G_REGISTER
)] = "VIDIOC_DBG_G_REGISTER",
338 [_IOC_NR(VIDIOC_G_CHIP_IDENT
)] = "VIDIOC_G_CHIP_IDENT",
341 #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
343 static const char *v4l2_int_ioctls
[] = {
344 #ifdef CONFIG_VIDEO_V4L1_COMPAT
345 [_IOC_NR(DECODER_GET_CAPABILITIES
)] = "DECODER_GET_CAPABILITIES",
346 [_IOC_NR(DECODER_GET_STATUS
)] = "DECODER_GET_STATUS",
347 [_IOC_NR(DECODER_SET_NORM
)] = "DECODER_SET_NORM",
348 [_IOC_NR(DECODER_SET_INPUT
)] = "DECODER_SET_INPUT",
349 [_IOC_NR(DECODER_SET_OUTPUT
)] = "DECODER_SET_OUTPUT",
350 [_IOC_NR(DECODER_ENABLE_OUTPUT
)] = "DECODER_ENABLE_OUTPUT",
351 [_IOC_NR(DECODER_SET_PICTURE
)] = "DECODER_SET_PICTURE",
352 [_IOC_NR(DECODER_SET_GPIO
)] = "DECODER_SET_GPIO",
353 [_IOC_NR(DECODER_INIT
)] = "DECODER_INIT",
354 [_IOC_NR(DECODER_SET_VBI_BYPASS
)] = "DECODER_SET_VBI_BYPASS",
355 [_IOC_NR(DECODER_DUMP
)] = "DECODER_DUMP",
357 [_IOC_NR(AUDC_SET_RADIO
)] = "AUDC_SET_RADIO",
359 [_IOC_NR(TUNER_SET_TYPE_ADDR
)] = "TUNER_SET_TYPE_ADDR",
360 [_IOC_NR(TUNER_SET_STANDBY
)] = "TUNER_SET_STANDBY",
361 [_IOC_NR(TUNER_SET_CONFIG
)] = "TUNER_SET_CONFIG",
363 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE
)] = "VIDIOC_INT_S_TUNER_MODE",
364 [_IOC_NR(VIDIOC_INT_RESET
)] = "VIDIOC_INT_RESET",
365 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ
)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
366 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE
)] = "VIDIOC_INT_DECODE_VBI_LINE",
367 [_IOC_NR(VIDIOC_INT_S_VBI_DATA
)] = "VIDIOC_INT_S_VBI_DATA",
368 [_IOC_NR(VIDIOC_INT_G_VBI_DATA
)] = "VIDIOC_INT_G_VBI_DATA",
369 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ
)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
370 [_IOC_NR(VIDIOC_INT_S_STANDBY
)] = "VIDIOC_INT_S_STANDBY",
371 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING
)] = "VIDIOC_INT_S_AUDIO_ROUTING",
372 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING
)] = "VIDIOC_INT_G_AUDIO_ROUTING",
373 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING
)] = "VIDIOC_INT_S_VIDEO_ROUTING",
374 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING
)] = "VIDIOC_INT_G_VIDEO_ROUTING",
375 [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ
)] = "VIDIOC_INT_S_CRYSTAL_FREQ",
376 [_IOC_NR(VIDIOC_INT_INIT
)] = "VIDIOC_INT_INIT",
377 [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT
)] = "VIDIOC_INT_G_STD_OUTPUT",
378 [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT
)] = "VIDIOC_INT_S_STD_OUTPUT",
380 #define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
382 /* Common ioctl debug function. This function can be used by
383 external ioctl messages as well as internal V4L ioctl */
384 void v4l_printk_ioctl(unsigned int cmd
)
388 switch (_IOC_DIR(cmd
)) {
389 case _IOC_NONE
: dir
= "--"; break;
390 case _IOC_READ
: dir
= "r-"; break;
391 case _IOC_WRITE
: dir
= "-w"; break;
392 case _IOC_READ
| _IOC_WRITE
: dir
= "rw"; break;
393 default: dir
= "*ERR*"; break;
395 switch (_IOC_TYPE(cmd
)) {
397 printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n",
398 (_IOC_NR(cmd
) < V4L2_INT_IOCTLS
) ?
399 v4l2_int_ioctls
[_IOC_NR(cmd
)] : "UNKNOWN", dir
, cmd
);
401 #ifdef CONFIG_VIDEO_V4L1_COMPAT
403 printk("v4l1 ioctl %s, dir=%s (0x%08x)\n",
404 (_IOC_NR(cmd
) < V4L1_IOCTLS
) ?
405 v4l1_ioctls
[_IOC_NR(cmd
)] : "UNKNOWN", dir
, cmd
);
409 printk("v4l2 ioctl %s, dir=%s (0x%08x)\n",
410 (_IOC_NR(cmd
) < V4L2_IOCTLS
) ?
411 v4l2_ioctls
[_IOC_NR(cmd
)] : "UNKNOWN", dir
, cmd
);
415 printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n",
416 _IOC_TYPE(cmd
), dir
, _IOC_NR(cmd
), cmd
);
419 EXPORT_SYMBOL(v4l_printk_ioctl
);
421 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
426 static ssize_t
show_name(struct device
*cd
,
427 struct device_attribute
*attr
, char *buf
)
429 struct video_device
*vfd
= container_of(cd
, struct video_device
,
431 return sprintf(buf
, "%.*s\n", (int)sizeof(vfd
->name
), vfd
->name
);
434 struct video_device
*video_device_alloc(void)
436 struct video_device
*vfd
;
438 vfd
= kzalloc(sizeof(*vfd
),GFP_KERNEL
);
441 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
443 EXPORT_SYMBOL(video_device_alloc
);
444 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
446 void video_device_release(struct video_device
*vfd
)
450 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
452 EXPORT_SYMBOL(video_device_release
);
453 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
455 static void video_release(struct device
*cd
)
457 struct video_device
*vfd
= container_of(cd
, struct video_device
,
461 /* needed until all drivers are fixed */
468 static struct device_attribute video_device_attrs
[] = {
469 __ATTR(name
, S_IRUGO
, show_name
, NULL
),
473 static struct class video_class
= {
475 .dev_attrs
= video_device_attrs
,
476 .dev_release
= video_release
,
483 static struct video_device
*video_device
[VIDEO_NUM_DEVICES
];
484 static DEFINE_MUTEX(videodev_lock
);
486 struct video_device
* video_devdata(struct file
*file
)
488 return video_device
[iminor(file
->f_path
.dentry
->d_inode
)];
490 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
492 EXPORT_SYMBOL(video_devdata
);
493 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
496 * Open a video device - FIXME: Obsoleted
498 static int video_open(struct inode
*inode
, struct file
*file
)
500 unsigned int minor
= iminor(inode
);
502 struct video_device
*vfl
;
503 const struct file_operations
*old_fops
;
505 if(minor
>=VIDEO_NUM_DEVICES
)
507 mutex_lock(&videodev_lock
);
508 vfl
=video_device
[minor
];
510 mutex_unlock(&videodev_lock
);
511 request_module("char-major-%d-%d", VIDEO_MAJOR
, minor
);
512 mutex_lock(&videodev_lock
);
513 vfl
=video_device
[minor
];
515 mutex_unlock(&videodev_lock
);
519 old_fops
= file
->f_op
;
520 file
->f_op
= fops_get(vfl
->fops
);
522 err
= file
->f_op
->open(inode
,file
);
524 fops_put(file
->f_op
);
525 file
->f_op
= fops_get(old_fops
);
528 mutex_unlock(&videodev_lock
);
533 * helper function -- handles userspace copying for ioctl arguments
538 video_fix_command(unsigned int cmd
)
541 case VIDIOC_OVERLAY_OLD
:
542 cmd
= VIDIOC_OVERLAY
;
544 case VIDIOC_S_PARM_OLD
:
547 case VIDIOC_S_CTRL_OLD
:
550 case VIDIOC_G_AUDIO_OLD
:
551 cmd
= VIDIOC_G_AUDIO
;
553 case VIDIOC_G_AUDOUT_OLD
:
554 cmd
= VIDIOC_G_AUDOUT
;
556 case VIDIOC_CROPCAP_OLD
:
557 cmd
= VIDIOC_CROPCAP
;
565 * Obsolete usercopy function - Should be removed soon
568 video_usercopy(struct inode
*inode
, struct file
*file
,
569 unsigned int cmd
, unsigned long arg
,
570 int (*func
)(struct inode
*inode
, struct file
*file
,
571 unsigned int cmd
, void *arg
))
578 size_t ctrls_size
= 0;
579 void __user
*user_ptr
= NULL
;
582 cmd
= video_fix_command(cmd
);
584 is_ext_ctrl
= (cmd
== VIDIOC_S_EXT_CTRLS
|| cmd
== VIDIOC_G_EXT_CTRLS
||
585 cmd
== VIDIOC_TRY_EXT_CTRLS
);
587 /* Copy arguments into temp kernel buffer */
588 switch (_IOC_DIR(cmd
)) {
594 case (_IOC_WRITE
| _IOC_READ
):
595 if (_IOC_SIZE(cmd
) <= sizeof(sbuf
)) {
598 /* too big to allocate from stack */
599 mbuf
= kmalloc(_IOC_SIZE(cmd
),GFP_KERNEL
);
606 if (_IOC_DIR(cmd
) & _IOC_WRITE
)
607 if (copy_from_user(parg
, (void __user
*)arg
, _IOC_SIZE(cmd
)))
612 struct v4l2_ext_controls
*p
= parg
;
614 /* In case of an error, tell the caller that it wasn't
615 a specific control that caused it. */
616 p
->error_idx
= p
->count
;
617 user_ptr
= (void __user
*)p
->controls
;
619 ctrls_size
= sizeof(struct v4l2_ext_control
) * p
->count
;
620 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
621 mbuf
= kmalloc(ctrls_size
, GFP_KERNEL
);
626 if (copy_from_user(mbuf
, user_ptr
, ctrls_size
))
633 err
= func(inode
, file
, cmd
, parg
);
634 if (err
== -ENOIOCTLCMD
)
637 struct v4l2_ext_controls
*p
= parg
;
639 p
->controls
= (void *)user_ptr
;
640 if (p
->count
&& err
== 0 && copy_to_user(user_ptr
, mbuf
, ctrls_size
))
648 /* Copy results into user buffer */
649 switch (_IOC_DIR(cmd
))
652 case (_IOC_WRITE
| _IOC_READ
):
653 if (copy_to_user((void __user
*)arg
, parg
, _IOC_SIZE(cmd
)))
662 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
664 EXPORT_SYMBOL(video_usercopy
);
665 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
668 * open/release helper functions -- handle exclusive opens
669 * Should be removed soon
671 int video_exclusive_open(struct inode
*inode
, struct file
*file
)
673 struct video_device
*vfl
= video_devdata(file
);
676 mutex_lock(&vfl
->lock
);
682 mutex_unlock(&vfl
->lock
);
685 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
687 EXPORT_SYMBOL(video_exclusive_open
);
688 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
690 int video_exclusive_release(struct inode
*inode
, struct file
*file
)
692 struct video_device
*vfl
= video_devdata(file
);
697 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
699 static char *v4l2_memory_names
[] = {
700 [V4L2_MEMORY_MMAP
] = "mmap",
701 [V4L2_MEMORY_USERPTR
] = "userptr",
702 [V4L2_MEMORY_OVERLAY
] = "overlay",
706 /* FIXME: Those stuff are replicated also on v4l2-common.c */
707 static char *v4l2_type_names_FIXME
[] = {
708 [V4L2_BUF_TYPE_VIDEO_CAPTURE
] = "video-cap",
709 [V4L2_BUF_TYPE_VIDEO_OVERLAY
] = "video-over",
710 [V4L2_BUF_TYPE_VIDEO_OUTPUT
] = "video-out",
711 [V4L2_BUF_TYPE_VBI_CAPTURE
] = "vbi-cap",
712 [V4L2_BUF_TYPE_VBI_OUTPUT
] = "vbi-out",
713 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
] = "sliced-vbi-out",
714 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
] = "sliced-vbi-capture",
715 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
] = "video-out-over",
716 [V4L2_BUF_TYPE_PRIVATE
] = "private",
719 static char *v4l2_field_names_FIXME
[] = {
720 [V4L2_FIELD_ANY
] = "any",
721 [V4L2_FIELD_NONE
] = "none",
722 [V4L2_FIELD_TOP
] = "top",
723 [V4L2_FIELD_BOTTOM
] = "bottom",
724 [V4L2_FIELD_INTERLACED
] = "interlaced",
725 [V4L2_FIELD_SEQ_TB
] = "seq-tb",
726 [V4L2_FIELD_SEQ_BT
] = "seq-bt",
727 [V4L2_FIELD_ALTERNATE
] = "alternate",
728 [V4L2_FIELD_INTERLACED_TB
] = "interlaced-tb",
729 [V4L2_FIELD_INTERLACED_BT
] = "interlaced-bt",
732 #define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown"
734 EXPORT_SYMBOL(video_exclusive_release
);
735 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
737 static void dbgbuf(unsigned int cmd
, struct video_device
*vfd
,
738 struct v4l2_buffer
*p
)
740 struct v4l2_timecode
*tc
=&p
->timecode
;
742 dbgarg (cmd
, "%02ld:%02d:%02d.%08ld index=%d, type=%s, "
743 "bytesused=%d, flags=0x%08d, "
744 "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx, length=%d\n",
745 (p
->timestamp
.tv_sec
/3600),
746 (int)(p
->timestamp
.tv_sec
/60)%60,
747 (int)(p
->timestamp
.tv_sec
%60),
748 p
->timestamp
.tv_usec
,
750 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
751 prt_names(p
->type
,v4l2_type_names_FIXME
),
752 p
->bytesused
,p
->flags
,
753 p
->field
,p
->sequence
,
754 prt_names(p
->memory
,v4l2_memory_names
),
756 prt_names(p
->type
, v4l2_type_names
),
757 p
->bytesused
, p
->flags
,
758 p
->field
, p
->sequence
,
759 prt_names(p
->memory
, v4l2_memory_names
),
760 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
761 p
->m
.userptr
, p
->length
);
762 dbgarg2 ("timecode= %02d:%02d:%02d type=%d, "
763 "flags=0x%08d, frames=%d, userbits=0x%08x\n",
764 tc
->hours
,tc
->minutes
,tc
->seconds
,
765 tc
->type
, tc
->flags
, tc
->frames
, *(__u32
*) tc
->userbits
);
768 static inline void dbgrect(struct video_device
*vfd
, char *s
,
771 dbgarg2 ("%sRect start at %dx%d, size= %dx%d\n", s
, r
->left
, r
->top
,
772 r
->width
, r
->height
);
775 static inline void v4l_print_pix_fmt (struct video_device
*vfd
,
776 struct v4l2_pix_format
*fmt
)
778 dbgarg2 ("width=%d, height=%d, format=%c%c%c%c, field=%s, "
779 "bytesperline=%d sizeimage=%d, colorspace=%d\n",
780 fmt
->width
,fmt
->height
,
781 (fmt
->pixelformat
& 0xff),
782 (fmt
->pixelformat
>> 8) & 0xff,
783 (fmt
->pixelformat
>> 16) & 0xff,
784 (fmt
->pixelformat
>> 24) & 0xff,
785 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
786 prt_names(fmt
->field
,v4l2_field_names_FIXME
),
787 fmt
->bytesperline
,fmt
->sizeimage
,fmt
->colorspace
);
789 prt_names(fmt
->field
, v4l2_field_names
),
790 fmt
->bytesperline
, fmt
->sizeimage
, fmt
->colorspace
);
791 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
795 static int check_fmt (struct video_device
*vfd
, enum v4l2_buf_type type
)
798 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
799 if (vfd
->vidioc_try_fmt_cap
)
802 case V4L2_BUF_TYPE_VIDEO_OVERLAY
:
803 if (vfd
->vidioc_try_fmt_overlay
)
806 case V4L2_BUF_TYPE_VBI_CAPTURE
:
807 if (vfd
->vidioc_try_fmt_vbi
)
810 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
811 if (vfd
->vidioc_try_fmt_vbi_output
)
814 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
815 if (vfd
->vidioc_try_fmt_vbi_capture
)
818 case V4L2_BUF_TYPE_VIDEO_OUTPUT
:
819 if (vfd
->vidioc_try_fmt_video_output
)
822 case V4L2_BUF_TYPE_VBI_OUTPUT
:
823 if (vfd
->vidioc_try_fmt_vbi_output
)
826 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
827 if (vfd
->vidioc_try_fmt_output_overlay
)
830 case V4L2_BUF_TYPE_PRIVATE
:
831 if (vfd
->vidioc_try_fmt_type_private
)
838 static int __video_do_ioctl(struct inode
*inode
, struct file
*file
,
839 unsigned int cmd
, void *arg
)
841 struct video_device
*vfd
= video_devdata(file
);
842 void *fh
= file
->private_data
;
845 if ( (vfd
->debug
& V4L2_DEBUG_IOCTL
) &&
846 !(vfd
->debug
& V4L2_DEBUG_IOCTL_ARG
)) {
847 v4l_print_ioctl(vfd
->name
, cmd
);
850 #ifdef CONFIG_VIDEO_V4L1_COMPAT
851 /***********************************************************
852 Handles calls to the obsoleted V4L1 API
853 Due to the nature of VIDIOCGMBUF, each driver that supports
854 V4L1 should implement its own handler for this ioctl.
855 ***********************************************************/
857 /* --- streaming capture ------------------------------------- */
858 if (cmd
== VIDIOCGMBUF
) {
859 struct video_mbuf
*p
=arg
;
861 memset(p
, 0, sizeof(*p
));
863 if (!vfd
->vidiocgmbuf
)
865 ret
=vfd
->vidiocgmbuf(file
, fh
, p
);
867 dbgarg (cmd
, "size=%d, frames=%d, offsets=0x%08lx\n",
869 (unsigned long)p
->offsets
);
873 /********************************************************
874 All other V4L1 calls are handled by v4l1_compat module.
875 Those calls will be translated into V4L2 calls, and
876 __video_do_ioctl will be called again, with one or more
878 ********************************************************/
879 if (_IOC_TYPE(cmd
)=='v')
880 return v4l_compat_translate_ioctl(inode
,file
,cmd
,arg
,
885 /* --- capabilities ------------------------------------------ */
886 case VIDIOC_QUERYCAP
:
888 struct v4l2_capability
*cap
= (struct v4l2_capability
*)arg
;
889 memset(cap
, 0, sizeof(*cap
));
891 if (!vfd
->vidioc_querycap
)
894 ret
=vfd
->vidioc_querycap(file
, fh
, cap
);
896 dbgarg (cmd
, "driver=%s, card=%s, bus=%s, "
898 "capabilities=0x%08x\n",
899 cap
->driver
,cap
->card
,cap
->bus_info
,
905 /* --- priority ------------------------------------------ */
906 case VIDIOC_G_PRIORITY
:
908 enum v4l2_priority
*p
=arg
;
910 if (!vfd
->vidioc_g_priority
)
912 ret
=vfd
->vidioc_g_priority(file
, fh
, p
);
914 dbgarg(cmd
, "priority is %d\n", *p
);
917 case VIDIOC_S_PRIORITY
:
919 enum v4l2_priority
*p
=arg
;
921 if (!vfd
->vidioc_s_priority
)
923 dbgarg(cmd
, "setting priority to %d\n", *p
);
924 ret
=vfd
->vidioc_s_priority(file
, fh
, *p
);
928 /* --- capture ioctls ---------------------------------------- */
929 case VIDIOC_ENUM_FMT
:
931 struct v4l2_fmtdesc
*f
= arg
;
932 enum v4l2_buf_type type
;
937 memset(f
,0,sizeof(*f
));
942 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
943 if (vfd
->vidioc_enum_fmt_cap
)
944 ret
=vfd
->vidioc_enum_fmt_cap(file
, fh
, f
);
946 case V4L2_BUF_TYPE_VIDEO_OVERLAY
:
947 if (vfd
->vidioc_enum_fmt_overlay
)
948 ret
=vfd
->vidioc_enum_fmt_overlay(file
, fh
, f
);
950 case V4L2_BUF_TYPE_VBI_CAPTURE
:
951 if (vfd
->vidioc_enum_fmt_vbi
)
952 ret
=vfd
->vidioc_enum_fmt_vbi(file
, fh
, f
);
954 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
955 if (vfd
->vidioc_enum_fmt_vbi_output
)
956 ret
=vfd
->vidioc_enum_fmt_vbi_output(file
,
959 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
960 if (vfd
->vidioc_enum_fmt_vbi_capture
)
961 ret
=vfd
->vidioc_enum_fmt_vbi_capture(file
,
964 case V4L2_BUF_TYPE_VIDEO_OUTPUT
:
965 if (vfd
->vidioc_enum_fmt_video_output
)
966 ret
=vfd
->vidioc_enum_fmt_video_output(file
,
969 case V4L2_BUF_TYPE_VBI_OUTPUT
:
970 if (vfd
->vidioc_enum_fmt_vbi_output
)
971 ret
=vfd
->vidioc_enum_fmt_vbi_output(file
,
974 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
975 if (vfd
->vidioc_enum_fmt_output_overlay
)
976 ret
=vfd
->vidioc_enum_fmt_output_overlay(file
, fh
, f
);
978 case V4L2_BUF_TYPE_PRIVATE
:
979 if (vfd
->vidioc_enum_fmt_type_private
)
980 ret
=vfd
->vidioc_enum_fmt_type_private(file
,
985 dbgarg (cmd
, "index=%d, type=%d, flags=%d, "
986 "pixelformat=%c%c%c%c, description='%s'\n",
987 f
->index
, f
->type
, f
->flags
,
988 (f
->pixelformat
& 0xff),
989 (f
->pixelformat
>> 8) & 0xff,
990 (f
->pixelformat
>> 16) & 0xff,
991 (f
->pixelformat
>> 24) & 0xff,
997 struct v4l2_format
*f
= (struct v4l2_format
*)arg
;
998 enum v4l2_buf_type type
=f
->type
;
1000 memset(&f
->fmt
.pix
,0,sizeof(f
->fmt
.pix
));
1003 /* FIXME: Should be one dump per type */
1004 dbgarg (cmd
, "type=%s\n", prt_names(type
,
1005 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
1006 v4l2_type_names_FIXME
));
1009 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
1012 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
1013 if (vfd
->vidioc_g_fmt_cap
)
1014 ret
=vfd
->vidioc_g_fmt_cap(file
, fh
, f
);
1016 v4l_print_pix_fmt(vfd
,&f
->fmt
.pix
);
1018 case V4L2_BUF_TYPE_VIDEO_OVERLAY
:
1019 if (vfd
->vidioc_g_fmt_overlay
)
1020 ret
=vfd
->vidioc_g_fmt_overlay(file
, fh
, f
);
1022 case V4L2_BUF_TYPE_VBI_CAPTURE
:
1023 if (vfd
->vidioc_g_fmt_vbi
)
1024 ret
=vfd
->vidioc_g_fmt_vbi(file
, fh
, f
);
1026 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
1027 if (vfd
->vidioc_g_fmt_vbi_output
)
1028 ret
=vfd
->vidioc_g_fmt_vbi_output(file
, fh
, f
);
1030 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
1031 if (vfd
->vidioc_g_fmt_vbi_capture
)
1032 ret
=vfd
->vidioc_g_fmt_vbi_capture(file
, fh
, f
);
1034 case V4L2_BUF_TYPE_VIDEO_OUTPUT
:
1035 if (vfd
->vidioc_g_fmt_video_output
)
1036 ret
=vfd
->vidioc_g_fmt_video_output(file
,
1039 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
1040 if (vfd
->vidioc_g_fmt_output_overlay
)
1041 ret
=vfd
->vidioc_g_fmt_output_overlay(file
, fh
, f
);
1043 case V4L2_BUF_TYPE_VBI_OUTPUT
:
1044 if (vfd
->vidioc_g_fmt_vbi_output
)
1045 ret
=vfd
->vidioc_g_fmt_vbi_output(file
, fh
, f
);
1047 case V4L2_BUF_TYPE_PRIVATE
:
1048 if (vfd
->vidioc_g_fmt_type_private
)
1049 ret
=vfd
->vidioc_g_fmt_type_private(file
,
1058 struct v4l2_format
*f
= (struct v4l2_format
*)arg
;
1060 /* FIXME: Should be one dump per type */
1061 dbgarg (cmd
, "type=%s\n", prt_names(f
->type
,
1062 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
1063 v4l2_type_names_FIXME
));
1066 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
1069 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
1070 v4l_print_pix_fmt(vfd
,&f
->fmt
.pix
);
1071 if (vfd
->vidioc_s_fmt_cap
)
1072 ret
=vfd
->vidioc_s_fmt_cap(file
, fh
, f
);
1074 case V4L2_BUF_TYPE_VIDEO_OVERLAY
:
1075 if (vfd
->vidioc_s_fmt_overlay
)
1076 ret
=vfd
->vidioc_s_fmt_overlay(file
, fh
, f
);
1078 case V4L2_BUF_TYPE_VBI_CAPTURE
:
1079 if (vfd
->vidioc_s_fmt_vbi
)
1080 ret
=vfd
->vidioc_s_fmt_vbi(file
, fh
, f
);
1082 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
1083 if (vfd
->vidioc_s_fmt_vbi_output
)
1084 ret
=vfd
->vidioc_s_fmt_vbi_output(file
, fh
, f
);
1086 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
1087 if (vfd
->vidioc_s_fmt_vbi_capture
)
1088 ret
=vfd
->vidioc_s_fmt_vbi_capture(file
, fh
, f
);
1090 case V4L2_BUF_TYPE_VIDEO_OUTPUT
:
1091 if (vfd
->vidioc_s_fmt_video_output
)
1092 ret
=vfd
->vidioc_s_fmt_video_output(file
,
1095 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
1096 if (vfd
->vidioc_s_fmt_output_overlay
)
1097 ret
=vfd
->vidioc_s_fmt_output_overlay(file
, fh
, f
);
1099 case V4L2_BUF_TYPE_VBI_OUTPUT
:
1100 if (vfd
->vidioc_s_fmt_vbi_output
)
1101 ret
=vfd
->vidioc_s_fmt_vbi_output(file
,
1104 case V4L2_BUF_TYPE_PRIVATE
:
1105 if (vfd
->vidioc_s_fmt_type_private
)
1106 ret
=vfd
->vidioc_s_fmt_type_private(file
,
1112 case VIDIOC_TRY_FMT
:
1114 struct v4l2_format
*f
= (struct v4l2_format
*)arg
;
1116 /* FIXME: Should be one dump per type */
1117 dbgarg (cmd
, "type=%s\n", prt_names(f
->type
,
1118 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
1119 v4l2_type_names_FIXME
));
1122 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
1124 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
1125 if (vfd
->vidioc_try_fmt_cap
)
1126 ret
=vfd
->vidioc_try_fmt_cap(file
, fh
, f
);
1128 v4l_print_pix_fmt(vfd
,&f
->fmt
.pix
);
1130 case V4L2_BUF_TYPE_VIDEO_OVERLAY
:
1131 if (vfd
->vidioc_try_fmt_overlay
)
1132 ret
=vfd
->vidioc_try_fmt_overlay(file
, fh
, f
);
1134 case V4L2_BUF_TYPE_VBI_CAPTURE
:
1135 if (vfd
->vidioc_try_fmt_vbi
)
1136 ret
=vfd
->vidioc_try_fmt_vbi(file
, fh
, f
);
1138 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
1139 if (vfd
->vidioc_try_fmt_vbi_output
)
1140 ret
=vfd
->vidioc_try_fmt_vbi_output(file
,
1143 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
1144 if (vfd
->vidioc_try_fmt_vbi_capture
)
1145 ret
=vfd
->vidioc_try_fmt_vbi_capture(file
,
1148 case V4L2_BUF_TYPE_VIDEO_OUTPUT
:
1149 if (vfd
->vidioc_try_fmt_video_output
)
1150 ret
=vfd
->vidioc_try_fmt_video_output(file
,
1153 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
1154 if (vfd
->vidioc_try_fmt_output_overlay
)
1155 ret
=vfd
->vidioc_try_fmt_output_overlay(file
, fh
, f
);
1157 case V4L2_BUF_TYPE_VBI_OUTPUT
:
1158 if (vfd
->vidioc_try_fmt_vbi_output
)
1159 ret
=vfd
->vidioc_try_fmt_vbi_output(file
,
1162 case V4L2_BUF_TYPE_PRIVATE
:
1163 if (vfd
->vidioc_try_fmt_type_private
)
1164 ret
=vfd
->vidioc_try_fmt_type_private(file
,
1171 /* FIXME: Those buf reqs could be handled here,
1172 with some changes on videobuf to allow its header to be included at
1173 videodev2.h or being merged at videodev2.
1175 case VIDIOC_REQBUFS
:
1177 struct v4l2_requestbuffers
*p
=arg
;
1179 if (!vfd
->vidioc_reqbufs
)
1181 ret
= check_fmt (vfd
, p
->type
);
1185 ret
=vfd
->vidioc_reqbufs(file
, fh
, p
);
1186 dbgarg (cmd
, "count=%d, type=%s, memory=%s\n",
1188 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
1189 prt_names(p
->type
,v4l2_type_names_FIXME
),
1190 prt_names(p
->memory
,v4l2_memory_names
));
1192 prt_names(p
->type
, v4l2_type_names
),
1193 prt_names(p
->memory
, v4l2_memory_names
));
1194 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
1197 case VIDIOC_QUERYBUF
:
1199 struct v4l2_buffer
*p
=arg
;
1201 if (!vfd
->vidioc_querybuf
)
1203 ret
= check_fmt (vfd
, p
->type
);
1207 ret
=vfd
->vidioc_querybuf(file
, fh
, p
);
1214 struct v4l2_buffer
*p
=arg
;
1216 if (!vfd
->vidioc_qbuf
)
1218 ret
= check_fmt (vfd
, p
->type
);
1222 ret
=vfd
->vidioc_qbuf(file
, fh
, p
);
1229 struct v4l2_buffer
*p
=arg
;
1230 if (!vfd
->vidioc_dqbuf
)
1232 ret
= check_fmt (vfd
, p
->type
);
1236 ret
=vfd
->vidioc_dqbuf(file
, fh
, p
);
1241 case VIDIOC_OVERLAY
:
1245 if (!vfd
->vidioc_overlay
)
1247 dbgarg (cmd
, "value=%d\n",*i
);
1248 ret
=vfd
->vidioc_overlay(file
, fh
, *i
);
1253 struct v4l2_framebuffer
*p
=arg
;
1254 if (!vfd
->vidioc_g_fbuf
)
1256 ret
=vfd
->vidioc_g_fbuf(file
, fh
, arg
);
1258 dbgarg (cmd
, "capability=%d, flags=%d, base=0x%08lx\n",
1259 p
->capability
,p
->flags
,
1260 (unsigned long)p
->base
);
1261 v4l_print_pix_fmt (vfd
, &p
->fmt
);
1267 struct v4l2_framebuffer
*p
=arg
;
1268 if (!vfd
->vidioc_s_fbuf
)
1271 dbgarg (cmd
, "capability=%d, flags=%d, base=0x%08lx\n",
1272 p
->capability
,p
->flags
,(unsigned long)p
->base
);
1273 v4l_print_pix_fmt (vfd
, &p
->fmt
);
1274 ret
=vfd
->vidioc_s_fbuf(file
, fh
, arg
);
1278 case VIDIOC_STREAMON
:
1280 enum v4l2_buf_type i
= *(int *)arg
;
1281 if (!vfd
->vidioc_streamon
)
1283 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
1284 dbgarg (cmd
, "type=%s\n", prt_names(i
,v4l2_type_names_FIXME
));
1286 dbgarg(cmd
, "type=%s\n", prt_names(i
, v4l2_type_names
));
1287 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
1288 ret
=vfd
->vidioc_streamon(file
, fh
,i
);
1291 case VIDIOC_STREAMOFF
:
1293 enum v4l2_buf_type i
= *(int *)arg
;
1295 if (!vfd
->vidioc_streamoff
)
1297 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
1298 dbgarg (cmd
, "type=%s\n", prt_names(i
,v4l2_type_names_FIXME
));
1300 dbgarg(cmd
, "type=%s\n", prt_names(i
, v4l2_type_names
));
1301 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
1302 ret
=vfd
->vidioc_streamoff(file
, fh
, i
);
1305 /* ---------- tv norms ---------- */
1306 case VIDIOC_ENUMSTD
:
1308 struct v4l2_standard
*p
= arg
;
1309 v4l2_std_id id
= vfd
->tvnorms
,curr_id
=0;
1310 unsigned int index
= p
->index
,i
;
1317 /* Return norm array on a canonical way */
1318 for (i
=0;i
<= index
&& id
; i
++) {
1319 if ( (id
& V4L2_STD_PAL
) == V4L2_STD_PAL
) {
1320 curr_id
= V4L2_STD_PAL
;
1321 } else if ( (id
& V4L2_STD_PAL_BG
) == V4L2_STD_PAL_BG
) {
1322 curr_id
= V4L2_STD_PAL_BG
;
1323 } else if ( (id
& V4L2_STD_PAL_DK
) == V4L2_STD_PAL_DK
) {
1324 curr_id
= V4L2_STD_PAL_DK
;
1325 } else if ( (id
& V4L2_STD_PAL_B
) == V4L2_STD_PAL_B
) {
1326 curr_id
= V4L2_STD_PAL_B
;
1327 } else if ( (id
& V4L2_STD_PAL_B1
) == V4L2_STD_PAL_B1
) {
1328 curr_id
= V4L2_STD_PAL_B1
;
1329 } else if ( (id
& V4L2_STD_PAL_G
) == V4L2_STD_PAL_G
) {
1330 curr_id
= V4L2_STD_PAL_G
;
1331 } else if ( (id
& V4L2_STD_PAL_H
) == V4L2_STD_PAL_H
) {
1332 curr_id
= V4L2_STD_PAL_H
;
1333 } else if ( (id
& V4L2_STD_PAL_I
) == V4L2_STD_PAL_I
) {
1334 curr_id
= V4L2_STD_PAL_I
;
1335 } else if ( (id
& V4L2_STD_PAL_D
) == V4L2_STD_PAL_D
) {
1336 curr_id
= V4L2_STD_PAL_D
;
1337 } else if ( (id
& V4L2_STD_PAL_D1
) == V4L2_STD_PAL_D1
) {
1338 curr_id
= V4L2_STD_PAL_D1
;
1339 } else if ( (id
& V4L2_STD_PAL_K
) == V4L2_STD_PAL_K
) {
1340 curr_id
= V4L2_STD_PAL_K
;
1341 } else if ( (id
& V4L2_STD_PAL_M
) == V4L2_STD_PAL_M
) {
1342 curr_id
= V4L2_STD_PAL_M
;
1343 } else if ( (id
& V4L2_STD_PAL_N
) == V4L2_STD_PAL_N
) {
1344 curr_id
= V4L2_STD_PAL_N
;
1345 } else if ( (id
& V4L2_STD_PAL_Nc
) == V4L2_STD_PAL_Nc
) {
1346 curr_id
= V4L2_STD_PAL_Nc
;
1347 } else if ( (id
& V4L2_STD_PAL_60
) == V4L2_STD_PAL_60
) {
1348 curr_id
= V4L2_STD_PAL_60
;
1349 } else if ( (id
& V4L2_STD_NTSC
) == V4L2_STD_NTSC
) {
1350 curr_id
= V4L2_STD_NTSC
;
1351 } else if ( (id
& V4L2_STD_NTSC_M
) == V4L2_STD_NTSC_M
) {
1352 curr_id
= V4L2_STD_NTSC_M
;
1353 } else if ( (id
& V4L2_STD_NTSC_M_JP
) == V4L2_STD_NTSC_M_JP
) {
1354 curr_id
= V4L2_STD_NTSC_M_JP
;
1355 } else if ( (id
& V4L2_STD_NTSC_443
) == V4L2_STD_NTSC_443
) {
1356 curr_id
= V4L2_STD_NTSC_443
;
1357 } else if ( (id
& V4L2_STD_NTSC_M_KR
) == V4L2_STD_NTSC_M_KR
) {
1358 curr_id
= V4L2_STD_NTSC_M_KR
;
1359 } else if ( (id
& V4L2_STD_SECAM
) == V4L2_STD_SECAM
) {
1360 curr_id
= V4L2_STD_SECAM
;
1361 } else if ( (id
& V4L2_STD_SECAM_DK
) == V4L2_STD_SECAM_DK
) {
1362 curr_id
= V4L2_STD_SECAM_DK
;
1363 } else if ( (id
& V4L2_STD_SECAM_B
) == V4L2_STD_SECAM_B
) {
1364 curr_id
= V4L2_STD_SECAM_B
;
1365 } else if ( (id
& V4L2_STD_SECAM_D
) == V4L2_STD_SECAM_D
) {
1366 curr_id
= V4L2_STD_SECAM_D
;
1367 } else if ( (id
& V4L2_STD_SECAM_G
) == V4L2_STD_SECAM_G
) {
1368 curr_id
= V4L2_STD_SECAM_G
;
1369 } else if ( (id
& V4L2_STD_SECAM_H
) == V4L2_STD_SECAM_H
) {
1370 curr_id
= V4L2_STD_SECAM_H
;
1371 } else if ( (id
& V4L2_STD_SECAM_K
) == V4L2_STD_SECAM_K
) {
1372 curr_id
= V4L2_STD_SECAM_K
;
1373 } else if ( (id
& V4L2_STD_SECAM_K1
) == V4L2_STD_SECAM_K1
) {
1374 curr_id
= V4L2_STD_SECAM_K1
;
1375 } else if ( (id
& V4L2_STD_SECAM_L
) == V4L2_STD_SECAM_L
) {
1376 curr_id
= V4L2_STD_SECAM_L
;
1377 } else if ( (id
& V4L2_STD_SECAM_LC
) == V4L2_STD_SECAM_LC
) {
1378 curr_id
= V4L2_STD_SECAM_LC
;
1387 v4l2_video_std_construct(p
, curr_id
,v4l2_norm_to_name(curr_id
));
1390 dbgarg (cmd
, "index=%d, id=%Ld, name=%s, fps=%d/%d, "
1391 "framelines=%d\n", p
->index
,
1392 (unsigned long long)p
->id
, p
->name
,
1393 p
->frameperiod
.numerator
,
1394 p
->frameperiod
.denominator
,
1402 v4l2_std_id
*id
= arg
;
1404 *id
= vfd
->current_norm
;
1406 dbgarg (cmd
, "value=%08Lx\n", (long long unsigned) *id
);
1413 v4l2_std_id
*id
= arg
,norm
;
1415 dbgarg (cmd
, "value=%08Lx\n", (long long unsigned) *id
);
1417 norm
= (*id
) & vfd
->tvnorms
;
1418 if ( vfd
->tvnorms
&& !norm
) /* Check if std is supported */
1421 /* Calls the specific handler */
1422 if (vfd
->vidioc_s_std
)
1423 ret
=vfd
->vidioc_s_std(file
, fh
, &norm
);
1427 /* Updates standard information */
1429 vfd
->current_norm
=norm
;
1433 case VIDIOC_QUERYSTD
:
1437 if (!vfd
->vidioc_querystd
)
1439 ret
=vfd
->vidioc_querystd(file
, fh
, arg
);
1441 dbgarg (cmd
, "detected std=%08Lx\n",
1442 (unsigned long long)*p
);
1445 /* ------ input switching ---------- */
1446 /* FIXME: Inputs can be handled inside videodev2 */
1447 case VIDIOC_ENUMINPUT
:
1449 struct v4l2_input
*p
=arg
;
1452 if (!vfd
->vidioc_enum_input
)
1454 memset(p
, 0, sizeof(*p
));
1457 ret
=vfd
->vidioc_enum_input(file
, fh
, p
);
1459 dbgarg (cmd
, "index=%d, name=%s, type=%d, "
1461 "tuner=%d, std=%08Lx, status=%d\n",
1462 p
->index
,p
->name
,p
->type
,p
->audioset
,
1464 (unsigned long long)p
->std
,
1468 case VIDIOC_G_INPUT
:
1470 unsigned int *i
= arg
;
1472 if (!vfd
->vidioc_g_input
)
1474 ret
=vfd
->vidioc_g_input(file
, fh
, i
);
1476 dbgarg (cmd
, "value=%d\n",*i
);
1479 case VIDIOC_S_INPUT
:
1481 unsigned int *i
= arg
;
1483 if (!vfd
->vidioc_s_input
)
1485 dbgarg (cmd
, "value=%d\n",*i
);
1486 ret
=vfd
->vidioc_s_input(file
, fh
, *i
);
1490 /* ------ output switching ---------- */
1491 case VIDIOC_G_OUTPUT
:
1493 unsigned int *i
= arg
;
1495 if (!vfd
->vidioc_g_output
)
1497 ret
=vfd
->vidioc_g_output(file
, fh
, i
);
1499 dbgarg (cmd
, "value=%d\n",*i
);
1502 case VIDIOC_S_OUTPUT
:
1504 unsigned int *i
= arg
;
1506 if (!vfd
->vidioc_s_output
)
1508 dbgarg (cmd
, "value=%d\n",*i
);
1509 ret
=vfd
->vidioc_s_output(file
, fh
, *i
);
1513 /* --- controls ---------------------------------------------- */
1514 case VIDIOC_QUERYCTRL
:
1516 struct v4l2_queryctrl
*p
=arg
;
1518 if (!vfd
->vidioc_queryctrl
)
1520 ret
=vfd
->vidioc_queryctrl(file
, fh
, p
);
1523 dbgarg (cmd
, "id=%d, type=%d, name=%s, "
1525 " step=%d, default=%d, flags=0x%08x\n",
1526 p
->id
,p
->type
,p
->name
,p
->minimum
,
1527 p
->maximum
,p
->step
,p
->default_value
,
1533 struct v4l2_control
*p
= arg
;
1535 if (!vfd
->vidioc_g_ctrl
)
1537 dbgarg(cmd
, "Enum for index=%d\n", p
->id
);
1539 ret
=vfd
->vidioc_g_ctrl(file
, fh
, p
);
1541 dbgarg2 ( "id=%d, value=%d\n", p
->id
, p
->value
);
1546 struct v4l2_control
*p
= arg
;
1548 if (!vfd
->vidioc_s_ctrl
)
1550 dbgarg (cmd
, "id=%d, value=%d\n", p
->id
, p
->value
);
1552 ret
=vfd
->vidioc_s_ctrl(file
, fh
, p
);
1555 case VIDIOC_G_EXT_CTRLS
:
1557 struct v4l2_ext_controls
*p
= arg
;
1559 if (vfd
->vidioc_g_ext_ctrls
) {
1560 dbgarg(cmd
, "count=%d\n", p
->count
);
1562 ret
=vfd
->vidioc_g_ext_ctrls(file
, fh
, p
);
1566 case VIDIOC_S_EXT_CTRLS
:
1568 struct v4l2_ext_controls
*p
= arg
;
1570 if (vfd
->vidioc_s_ext_ctrls
) {
1571 dbgarg(cmd
, "count=%d\n", p
->count
);
1573 ret
=vfd
->vidioc_s_ext_ctrls(file
, fh
, p
);
1577 case VIDIOC_TRY_EXT_CTRLS
:
1579 struct v4l2_ext_controls
*p
= arg
;
1581 if (vfd
->vidioc_try_ext_ctrls
) {
1582 dbgarg(cmd
, "count=%d\n", p
->count
);
1584 ret
=vfd
->vidioc_try_ext_ctrls(file
, fh
, p
);
1588 case VIDIOC_QUERYMENU
:
1590 struct v4l2_querymenu
*p
=arg
;
1591 if (!vfd
->vidioc_querymenu
)
1593 ret
=vfd
->vidioc_querymenu(file
, fh
, p
);
1595 dbgarg (cmd
, "id=%d, index=%d, name=%s\n",
1596 p
->id
,p
->index
,p
->name
);
1599 /* --- audio ---------------------------------------------- */
1600 case VIDIOC_ENUMAUDIO
:
1602 struct v4l2_audio
*p
=arg
;
1604 if (!vfd
->vidioc_enumaudio
)
1606 dbgarg(cmd
, "Enum for index=%d\n", p
->index
);
1607 ret
=vfd
->vidioc_enumaudio(file
, fh
, p
);
1609 dbgarg2("index=%d, name=%s, capability=%d, "
1610 "mode=%d\n",p
->index
,p
->name
,
1611 p
->capability
, p
->mode
);
1614 case VIDIOC_G_AUDIO
:
1616 struct v4l2_audio
*p
=arg
;
1617 __u32 index
=p
->index
;
1619 if (!vfd
->vidioc_g_audio
)
1622 memset(p
,0,sizeof(*p
));
1624 dbgarg(cmd
, "Get for index=%d\n", p
->index
);
1625 ret
=vfd
->vidioc_g_audio(file
, fh
, p
);
1627 dbgarg2("index=%d, name=%s, capability=%d, "
1628 "mode=%d\n",p
->index
,
1629 p
->name
,p
->capability
, p
->mode
);
1632 case VIDIOC_S_AUDIO
:
1634 struct v4l2_audio
*p
=arg
;
1636 if (!vfd
->vidioc_s_audio
)
1638 dbgarg(cmd
, "index=%d, name=%s, capability=%d, "
1639 "mode=%d\n", p
->index
, p
->name
,
1640 p
->capability
, p
->mode
);
1641 ret
=vfd
->vidioc_s_audio(file
, fh
, p
);
1644 case VIDIOC_ENUMAUDOUT
:
1646 struct v4l2_audioout
*p
=arg
;
1648 if (!vfd
->vidioc_enumaudout
)
1650 dbgarg(cmd
, "Enum for index=%d\n", p
->index
);
1651 ret
=vfd
->vidioc_enumaudout(file
, fh
, p
);
1653 dbgarg2("index=%d, name=%s, capability=%d, "
1654 "mode=%d\n", p
->index
, p
->name
,
1655 p
->capability
,p
->mode
);
1658 case VIDIOC_G_AUDOUT
:
1660 struct v4l2_audioout
*p
=arg
;
1662 if (!vfd
->vidioc_g_audout
)
1664 dbgarg(cmd
, "Enum for index=%d\n", p
->index
);
1665 ret
=vfd
->vidioc_g_audout(file
, fh
, p
);
1667 dbgarg2("index=%d, name=%s, capability=%d, "
1668 "mode=%d\n", p
->index
, p
->name
,
1669 p
->capability
,p
->mode
);
1672 case VIDIOC_S_AUDOUT
:
1674 struct v4l2_audioout
*p
=arg
;
1676 if (!vfd
->vidioc_s_audout
)
1678 dbgarg(cmd
, "index=%d, name=%s, capability=%d, "
1679 "mode=%d\n", p
->index
, p
->name
,
1680 p
->capability
,p
->mode
);
1682 ret
=vfd
->vidioc_s_audout(file
, fh
, p
);
1685 case VIDIOC_G_MODULATOR
:
1687 struct v4l2_modulator
*p
=arg
;
1688 if (!vfd
->vidioc_g_modulator
)
1690 ret
=vfd
->vidioc_g_modulator(file
, fh
, p
);
1692 dbgarg(cmd
, "index=%d, name=%s, "
1693 "capability=%d, rangelow=%d,"
1694 " rangehigh=%d, txsubchans=%d\n",
1695 p
->index
, p
->name
,p
->capability
,
1696 p
->rangelow
, p
->rangehigh
,
1700 case VIDIOC_S_MODULATOR
:
1702 struct v4l2_modulator
*p
=arg
;
1703 if (!vfd
->vidioc_s_modulator
)
1705 dbgarg(cmd
, "index=%d, name=%s, capability=%d, "
1706 "rangelow=%d, rangehigh=%d, txsubchans=%d\n",
1707 p
->index
, p
->name
,p
->capability
,p
->rangelow
,
1708 p
->rangehigh
,p
->txsubchans
);
1709 ret
=vfd
->vidioc_s_modulator(file
, fh
, p
);
1714 struct v4l2_crop
*p
=arg
;
1715 if (!vfd
->vidioc_g_crop
)
1717 ret
=vfd
->vidioc_g_crop(file
, fh
, p
);
1719 dbgarg(cmd
, "type=%d\n", p
->type
);
1720 dbgrect(vfd
, "", &p
->c
);
1726 struct v4l2_crop
*p
=arg
;
1727 if (!vfd
->vidioc_s_crop
)
1729 dbgarg(cmd
, "type=%d\n", p
->type
);
1730 dbgrect(vfd
, "", &p
->c
);
1731 ret
=vfd
->vidioc_s_crop(file
, fh
, p
);
1734 case VIDIOC_CROPCAP
:
1736 struct v4l2_cropcap
*p
=arg
;
1737 /*FIXME: Should also show v4l2_fract pixelaspect */
1738 if (!vfd
->vidioc_cropcap
)
1740 dbgarg(cmd
, "type=%d\n", p
->type
);
1741 dbgrect(vfd
, "bounds ", &p
->bounds
);
1742 dbgrect(vfd
, "defrect ", &p
->defrect
);
1743 ret
=vfd
->vidioc_cropcap(file
, fh
, p
);
1746 case VIDIOC_G_JPEGCOMP
:
1748 struct v4l2_jpegcompression
*p
=arg
;
1749 if (!vfd
->vidioc_g_jpegcomp
)
1751 ret
=vfd
->vidioc_g_jpegcomp(file
, fh
, p
);
1753 dbgarg (cmd
, "quality=%d, APPn=%d, "
1754 "APP_len=%d, COM_len=%d, "
1755 "jpeg_markers=%d\n",
1756 p
->quality
,p
->APPn
,p
->APP_len
,
1757 p
->COM_len
,p
->jpeg_markers
);
1760 case VIDIOC_S_JPEGCOMP
:
1762 struct v4l2_jpegcompression
*p
=arg
;
1763 if (!vfd
->vidioc_g_jpegcomp
)
1765 dbgarg (cmd
, "quality=%d, APPn=%d, APP_len=%d, "
1766 "COM_len=%d, jpeg_markers=%d\n",
1767 p
->quality
,p
->APPn
,p
->APP_len
,
1768 p
->COM_len
,p
->jpeg_markers
);
1769 ret
=vfd
->vidioc_s_jpegcomp(file
, fh
, p
);
1772 case VIDIOC_G_ENC_INDEX
:
1774 struct v4l2_enc_idx
*p
=arg
;
1776 if (!vfd
->vidioc_g_enc_index
)
1778 ret
=vfd
->vidioc_g_enc_index(file
, fh
, p
);
1780 dbgarg (cmd
, "entries=%d, entries_cap=%d\n",
1781 p
->entries
,p
->entries_cap
);
1784 case VIDIOC_ENCODER_CMD
:
1786 struct v4l2_encoder_cmd
*p
=arg
;
1788 if (!vfd
->vidioc_encoder_cmd
)
1790 ret
=vfd
->vidioc_encoder_cmd(file
, fh
, p
);
1792 dbgarg (cmd
, "cmd=%d, flags=%d\n",
1796 case VIDIOC_TRY_ENCODER_CMD
:
1798 struct v4l2_encoder_cmd
*p
=arg
;
1800 if (!vfd
->vidioc_try_encoder_cmd
)
1802 ret
=vfd
->vidioc_try_encoder_cmd(file
, fh
, p
);
1804 dbgarg (cmd
, "cmd=%d, flags=%d\n",
1810 struct v4l2_streamparm
*p
=arg
;
1813 memset(p
,0,sizeof(*p
));
1816 if (vfd
->vidioc_g_parm
) {
1817 ret
=vfd
->vidioc_g_parm(file
, fh
, p
);
1819 struct v4l2_standard s
;
1821 if (p
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1824 v4l2_video_std_construct(&s
, vfd
->current_norm
,
1825 v4l2_norm_to_name(vfd
->current_norm
));
1827 p
->parm
.capture
.timeperframe
= s
.frameperiod
;
1831 dbgarg (cmd
, "type=%d\n", p
->type
);
1836 struct v4l2_streamparm
*p
=arg
;
1837 if (!vfd
->vidioc_s_parm
)
1839 dbgarg (cmd
, "type=%d\n", p
->type
);
1840 ret
=vfd
->vidioc_s_parm(file
, fh
, p
);
1843 case VIDIOC_G_TUNER
:
1845 struct v4l2_tuner
*p
=arg
;
1846 __u32 index
=p
->index
;
1848 if (!vfd
->vidioc_g_tuner
)
1851 memset(p
,0,sizeof(*p
));
1854 ret
=vfd
->vidioc_g_tuner(file
, fh
, p
);
1856 dbgarg (cmd
, "index=%d, name=%s, type=%d, "
1857 "capability=%d, rangelow=%d, "
1858 "rangehigh=%d, signal=%d, afc=%d, "
1859 "rxsubchans=%d, audmode=%d\n",
1860 p
->index
, p
->name
, p
->type
,
1861 p
->capability
, p
->rangelow
,
1862 p
->rangehigh
, p
->rxsubchans
,
1863 p
->audmode
, p
->signal
, p
->afc
);
1866 case VIDIOC_S_TUNER
:
1868 struct v4l2_tuner
*p
=arg
;
1869 if (!vfd
->vidioc_s_tuner
)
1871 dbgarg (cmd
, "index=%d, name=%s, type=%d, "
1872 "capability=%d, rangelow=%d, rangehigh=%d, "
1873 "signal=%d, afc=%d, rxsubchans=%d, "
1874 "audmode=%d\n",p
->index
, p
->name
, p
->type
,
1875 p
->capability
, p
->rangelow
,p
->rangehigh
,
1876 p
->rxsubchans
, p
->audmode
, p
->signal
,
1878 ret
=vfd
->vidioc_s_tuner(file
, fh
, p
);
1881 case VIDIOC_G_FREQUENCY
:
1883 struct v4l2_frequency
*p
=arg
;
1884 if (!vfd
->vidioc_g_frequency
)
1887 memset(p
,0,sizeof(*p
));
1889 ret
=vfd
->vidioc_g_frequency(file
, fh
, p
);
1891 dbgarg (cmd
, "tuner=%d, type=%d, frequency=%d\n",
1892 p
->tuner
,p
->type
,p
->frequency
);
1895 case VIDIOC_S_FREQUENCY
:
1897 struct v4l2_frequency
*p
=arg
;
1898 if (!vfd
->vidioc_s_frequency
)
1900 dbgarg (cmd
, "tuner=%d, type=%d, frequency=%d\n",
1901 p
->tuner
,p
->type
,p
->frequency
);
1902 ret
=vfd
->vidioc_s_frequency(file
, fh
, p
);
1905 case VIDIOC_G_SLICED_VBI_CAP
:
1907 struct v4l2_sliced_vbi_cap
*p
=arg
;
1908 if (!vfd
->vidioc_g_sliced_vbi_cap
)
1910 ret
=vfd
->vidioc_g_sliced_vbi_cap(file
, fh
, p
);
1912 dbgarg (cmd
, "service_set=%d\n", p
->service_set
);
1915 case VIDIOC_LOG_STATUS
:
1917 if (!vfd
->vidioc_log_status
)
1919 ret
=vfd
->vidioc_log_status(file
, fh
);
1922 #ifdef CONFIG_VIDEO_ADV_DEBUG
1923 case VIDIOC_DBG_G_REGISTER
:
1925 struct v4l2_register
*p
=arg
;
1926 if (!capable(CAP_SYS_ADMIN
))
1928 else if (vfd
->vidioc_g_register
)
1929 ret
=vfd
->vidioc_g_register(file
, fh
, p
);
1932 case VIDIOC_DBG_S_REGISTER
:
1934 struct v4l2_register
*p
=arg
;
1935 if (!capable(CAP_SYS_ADMIN
))
1937 else if (vfd
->vidioc_s_register
)
1938 ret
=vfd
->vidioc_s_register(file
, fh
, p
);
1942 case VIDIOC_G_CHIP_IDENT
:
1944 struct v4l2_chip_ident
*p
=arg
;
1945 if (!vfd
->vidioc_g_chip_ident
)
1947 ret
=vfd
->vidioc_g_chip_ident(file
, fh
, p
);
1949 dbgarg (cmd
, "chip_ident=%u, revision=0x%x\n", p
->ident
, p
->revision
);
1954 if (vfd
->debug
& V4L2_DEBUG_IOCTL_ARG
) {
1956 printk ("%s: err:\n", vfd
->name
);
1957 v4l_print_ioctl(vfd
->name
, cmd
);
1964 int video_ioctl2 (struct inode
*inode
, struct file
*file
,
1965 unsigned int cmd
, unsigned long arg
)
1972 size_t ctrls_size
= 0;
1973 void __user
*user_ptr
= NULL
;
1975 #ifdef __OLD_VIDIOC_
1976 cmd
= video_fix_command(cmd
);
1978 is_ext_ctrl
= (cmd
== VIDIOC_S_EXT_CTRLS
|| cmd
== VIDIOC_G_EXT_CTRLS
||
1979 cmd
== VIDIOC_TRY_EXT_CTRLS
);
1981 /* Copy arguments into temp kernel buffer */
1982 switch (_IOC_DIR(cmd
)) {
1988 case (_IOC_WRITE
| _IOC_READ
):
1989 if (_IOC_SIZE(cmd
) <= sizeof(sbuf
)) {
1992 /* too big to allocate from stack */
1993 mbuf
= kmalloc(_IOC_SIZE(cmd
),GFP_KERNEL
);
2000 if (_IOC_DIR(cmd
) & _IOC_WRITE
)
2001 if (copy_from_user(parg
, (void __user
*)arg
, _IOC_SIZE(cmd
)))
2007 struct v4l2_ext_controls
*p
= parg
;
2009 /* In case of an error, tell the caller that it wasn't
2010 a specific control that caused it. */
2011 p
->error_idx
= p
->count
;
2012 user_ptr
= (void __user
*)p
->controls
;
2014 ctrls_size
= sizeof(struct v4l2_ext_control
) * p
->count
;
2015 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
2016 mbuf
= kmalloc(ctrls_size
, GFP_KERNEL
);
2021 if (copy_from_user(mbuf
, user_ptr
, ctrls_size
))
2028 err
= __video_do_ioctl(inode
, file
, cmd
, parg
);
2029 if (err
== -ENOIOCTLCMD
)
2032 struct v4l2_ext_controls
*p
= parg
;
2034 p
->controls
= (void *)user_ptr
;
2035 if (p
->count
&& err
== 0 && copy_to_user(user_ptr
, mbuf
, ctrls_size
))
2043 /* Copy results into user buffer */
2044 switch (_IOC_DIR(cmd
))
2047 case (_IOC_WRITE
| _IOC_READ
):
2048 if (copy_to_user((void __user
*)arg
, parg
, _IOC_SIZE(cmd
)))
2057 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
2060 EXPORT_SYMBOL(video_ioctl2
);
2061 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
2063 static const struct file_operations video_fops
;
2066 * video_register_device - register video4linux devices
2067 * @vfd: video device structure we want to register
2068 * @type: type of device to register
2069 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
2072 * The registration code assigns minor numbers based on the type
2073 * requested. -ENFILE is returned in all the device slots for this
2074 * category are full. If not then the minor field is set and the
2075 * driver initialize function is called (if non %NULL).
2077 * Zero is returned on success.
2081 * %VFL_TYPE_GRABBER - A frame grabber
2083 * %VFL_TYPE_VTX - A teletext device
2085 * %VFL_TYPE_VBI - Vertical blank data (undecoded)
2087 * %VFL_TYPE_RADIO - A radio card
2090 int video_register_device(struct video_device
*vfd
, int type
, int nr
)
2100 case VFL_TYPE_GRABBER
:
2101 base
=MINOR_VFL_TYPE_GRABBER_MIN
;
2102 end
=MINOR_VFL_TYPE_GRABBER_MAX
+1;
2103 name_base
= "video";
2106 base
=MINOR_VFL_TYPE_VTX_MIN
;
2107 end
=MINOR_VFL_TYPE_VTX_MAX
+1;
2111 base
=MINOR_VFL_TYPE_VBI_MIN
;
2112 end
=MINOR_VFL_TYPE_VBI_MAX
+1;
2115 case VFL_TYPE_RADIO
:
2116 base
=MINOR_VFL_TYPE_RADIO_MIN
;
2117 end
=MINOR_VFL_TYPE_RADIO_MAX
+1;
2118 name_base
= "radio";
2121 printk(KERN_ERR
"%s called with unknown type: %d\n",
2122 __FUNCTION__
, type
);
2126 /* pick a minor number */
2127 mutex_lock(&videodev_lock
);
2128 if (nr
>= 0 && nr
< end
-base
) {
2129 /* use the one the driver asked for */
2131 if (NULL
!= video_device
[i
]) {
2132 mutex_unlock(&videodev_lock
);
2136 /* use first free */
2137 for(i
=base
;i
<end
;i
++)
2138 if (NULL
== video_device
[i
])
2141 mutex_unlock(&videodev_lock
);
2145 video_device
[i
]=vfd
;
2147 mutex_unlock(&videodev_lock
);
2148 mutex_init(&vfd
->lock
);
2151 memset(&vfd
->class_dev
, 0x00, sizeof(vfd
->class_dev
));
2153 vfd
->class_dev
.parent
= vfd
->dev
;
2154 vfd
->class_dev
.class = &video_class
;
2155 vfd
->class_dev
.devt
= MKDEV(VIDEO_MAJOR
, vfd
->minor
);
2156 sprintf(vfd
->class_dev
.bus_id
, "%s%d", name_base
, i
- base
);
2157 ret
= device_register(&vfd
->class_dev
);
2159 printk(KERN_ERR
"%s: device_register failed\n",
2165 /* needed until all drivers are fixed */
2167 printk(KERN_WARNING
"videodev: \"%s\" has no release callback. "
2168 "Please fix your driver for proper sysfs support, see "
2169 "http://lwn.net/Articles/36850/\n", vfd
->name
);
2174 mutex_lock(&videodev_lock
);
2175 video_device
[vfd
->minor
] = NULL
;
2177 mutex_unlock(&videodev_lock
);
2180 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
2182 EXPORT_SYMBOL(video_register_device
);
2183 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
2186 * video_unregister_device - unregister a video4linux device
2187 * @vfd: the device to unregister
2189 * This unregisters the passed device and deassigns the minor
2190 * number. Future open calls will be met with errors.
2193 void video_unregister_device(struct video_device
*vfd
)
2195 mutex_lock(&videodev_lock
);
2196 if(video_device
[vfd
->minor
]!=vfd
)
2197 panic("videodev: bad unregister");
2199 video_device
[vfd
->minor
]=NULL
;
2200 device_unregister(&vfd
->class_dev
);
2201 mutex_unlock(&videodev_lock
);
2203 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
2205 EXPORT_SYMBOL(video_unregister_device
);
2206 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
2209 * Video fs operations
2211 static const struct file_operations video_fops
=
2213 .owner
= THIS_MODULE
,
2214 .llseek
= no_llseek
,
2219 * Initialise video for linux
2222 static int __init
videodev_init(void)
2226 printk(KERN_INFO
"Linux video capture interface: v2.00\n");
2227 if (register_chrdev(VIDEO_MAJOR
, VIDEO_NAME
, &video_fops
)) {
2228 printk(KERN_WARNING
"video_dev: unable to get major %d\n", VIDEO_MAJOR
);
2232 ret
= class_register(&video_class
);
2234 unregister_chrdev(VIDEO_MAJOR
, VIDEO_NAME
);
2235 printk(KERN_WARNING
"video_dev: class_register failed\n");
2242 static void __exit
videodev_exit(void)
2244 class_unregister(&video_class
);
2245 unregister_chrdev(VIDEO_MAJOR
, VIDEO_NAME
);
2248 module_init(videodev_init
)
2249 module_exit(videodev_exit
)
2251 <<<<<<< HEAD
:drivers
/media
/video
/videodev
.c
2252 EXPORT_SYMBOL(video_register_device
);
2253 EXPORT_SYMBOL(video_unregister_device
);
2254 EXPORT_SYMBOL(video_devdata
);
2255 EXPORT_SYMBOL(video_usercopy
);
2256 EXPORT_SYMBOL(video_exclusive_open
);
2257 EXPORT_SYMBOL(video_exclusive_release
);
2258 EXPORT_SYMBOL(video_ioctl2
);
2259 EXPORT_SYMBOL(video_device_alloc
);
2260 EXPORT_SYMBOL(video_device_release
);
2263 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/video
/videodev
.c
2264 MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>");
2265 MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2");
2266 MODULE_LICENSE("GPL");