Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

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