aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/video4linux/v4l2-framework.txt
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-05-10 01:51:31 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 08:13:43 -0400
commit8ab75e3ecd8f232d9564510f0c601a6aa7a149ea (patch)
treed0a0a2e1b8fa4cef8234c09582c622a3e1aa1d42 /Documentation/video4linux/v4l2-framework.txt
parentccfc97bdb5ae8b8edc55169ac6924e08449836ac (diff)
[media] v4l2-dev: make it possible to skip locking for selected ioctls
Using the V4L2 core lock is a very robust method that is usually very good at doing the right thing. But some drivers, particularly USB drivers, may want to prevent the core from taking the lock for specific ioctls, particularly buffer queuing ioctls. The reason is that certain commands like S_CTRL can take a long time to process over USB and all the time the core has the lock, preventing VIDIOC_DQBUF from proceeding, even though a frame may be ready in the queue. This introduces unwanted latency. Since the buffer queuing commands often have their own internal lock it is often not necessary to take the core lock. Drivers can now say that they don't want the core to take the lock for specific ioctls. As it is a specific opt-out it makes it clear to the reviewer that those ioctls will need more care when reviewing. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'Documentation/video4linux/v4l2-framework.txt')
-rw-r--r--Documentation/video4linux/v4l2-framework.txt27
1 files changed, 24 insertions, 3 deletions
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index fe53177f0d3c..e1e6a01d7ac6 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -580,19 +580,25 @@ allocated memory.
580You should also set these fields: 580You should also set these fields:
581 581
582- v4l2_dev: set to the v4l2_device parent device. 582- v4l2_dev: set to the v4l2_device parent device.
583
583- name: set to something descriptive and unique. 584- name: set to something descriptive and unique.
585
584- fops: set to the v4l2_file_operations struct. 586- fops: set to the v4l2_file_operations struct.
587
585- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance 588- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance
586 (highly recommended to use this and it might become compulsory in the 589 (highly recommended to use this and it might become compulsory in the
587 future!), then set this to your v4l2_ioctl_ops struct. 590 future!), then set this to your v4l2_ioctl_ops struct.
591
588- lock: leave to NULL if you want to do all the locking in the driver. 592- lock: leave to NULL if you want to do all the locking in the driver.
589 Otherwise you give it a pointer to a struct mutex_lock and before any 593 Otherwise you give it a pointer to a struct mutex_lock and before any
590 of the v4l2_file_operations is called this lock will be taken by the 594 of the v4l2_file_operations is called this lock will be taken by the
591 core and released afterwards. 595 core and released afterwards. See the next section for more details.
596
592- prio: keeps track of the priorities. Used to implement VIDIOC_G/S_PRIORITY. 597- prio: keeps track of the priorities. Used to implement VIDIOC_G/S_PRIORITY.
593 If left to NULL, then it will use the struct v4l2_prio_state in v4l2_device. 598 If left to NULL, then it will use the struct v4l2_prio_state in v4l2_device.
594 If you want to have a separate priority state per (group of) device node(s), 599 If you want to have a separate priority state per (group of) device node(s),
595 then you can point it to your own struct v4l2_prio_state. 600 then you can point it to your own struct v4l2_prio_state.
601
596- parent: you only set this if v4l2_device was registered with NULL as 602- parent: you only set this if v4l2_device was registered with NULL as
597 the parent device struct. This only happens in cases where one hardware 603 the parent device struct. This only happens in cases where one hardware
598 device has multiple PCI devices that all share the same v4l2_device core. 604 device has multiple PCI devices that all share the same v4l2_device core.
@@ -602,6 +608,7 @@ You should also set these fields:
602 (cx8802). Since the v4l2_device cannot be associated with a particular 608 (cx8802). Since the v4l2_device cannot be associated with a particular
603 PCI device it is setup without a parent device. But when the struct 609 PCI device it is setup without a parent device. But when the struct
604 video_device is setup you do know which parent PCI device to use. 610 video_device is setup you do know which parent PCI device to use.
611
605- flags: optional. Set to V4L2_FL_USE_FH_PRIO if you want to let the framework 612- flags: optional. Set to V4L2_FL_USE_FH_PRIO if you want to let the framework
606 handle the VIDIOC_G/S_PRIORITY ioctls. This requires that you use struct 613 handle the VIDIOC_G/S_PRIORITY ioctls. This requires that you use struct
607 v4l2_fh. Eventually this flag will disappear once all drivers use the core 614 v4l2_fh. Eventually this flag will disappear once all drivers use the core
@@ -634,8 +641,22 @@ v4l2_file_operations and locking
634-------------------------------- 641--------------------------------
635 642
636You can set a pointer to a mutex_lock in struct video_device. Usually this 643You can set a pointer to a mutex_lock in struct video_device. Usually this
637will be either a top-level mutex or a mutex per device node. If you want 644will be either a top-level mutex or a mutex per device node. By default this
638finer-grained locking then you have to set it to NULL and do you own locking. 645lock will be used for each file operation and ioctl, but you can disable
646locking for selected ioctls by calling:
647
648 void v4l2_dont_use_lock(struct video_device *vdev, unsigned int cmd);
649
650E.g.: v4l2_dont_use_lock(vdev, VIDIOC_DQBUF);
651
652You have to call this before you register the video_device.
653
654Particularly with USB drivers where certain commands such as setting controls
655can take a long time you may want to do your own locking for the buffer queuing
656ioctls.
657
658If you want still finer-grained locking then you have to set mutex_lock to NULL
659and do you own locking completely.
639 660
640It is up to the driver developer to decide which method to use. However, if 661It is up to the driver developer to decide which method to use. However, if
641your driver has high-latency operations (for example, changing the exposure 662your driver has high-latency operations (for example, changing the exposure