aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-09-26 07:47:38 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-20 23:06:14 -0400
commitee6869afc922a9849979e49bb3bbcad794872fcb (patch)
tree2266050d01da694d04b533a6509873888327108b /Documentation
parentc29fcff3daafbf46d64a543c1950bbd206ad8c1c (diff)
V4L/DVB: v4l2: add core serialization lock
Drivers can optionally set a pointer to a mutex in struct video_device. The core will use that to lock before calling open, read, write, unlocked_ioctl, poll, mmap or release. Updated the documentation as well and ensure that v4l2-event knows about the lock: it will unlock it before doing a blocking wait on an event and relock it afterwards. Ensure that the 'video_is_registered' check is done when the lock is held: a typical disconnect will take the lock as well before unregistering the device nodes, so to prevent race conditions the video_is_registered check should also be done with the lock held. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/video4linux/v4l2-framework.txt20
1 files changed, 20 insertions, 0 deletions
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 9b1d81c26b7d..a128e012a45c 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -453,6 +453,10 @@ You should also set these fields:
453- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance 453- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance
454 (highly recommended to use this and it might become compulsory in the 454 (highly recommended to use this and it might become compulsory in the
455 future!), then set this to your v4l2_ioctl_ops struct. 455 future!), then set this to your v4l2_ioctl_ops struct.
456- lock: leave to NULL if you want to do all the locking in the driver.
457 Otherwise you give it a pointer to a struct mutex_lock and before any
458 of the v4l2_file_operations is called this lock will be taken by the
459 core and released afterwards.
456- parent: you only set this if v4l2_device was registered with NULL as 460- parent: you only set this if v4l2_device was registered with NULL as
457 the parent device struct. This only happens in cases where one hardware 461 the parent device struct. This only happens in cases where one hardware
458 device has multiple PCI devices that all share the same v4l2_device core. 462 device has multiple PCI devices that all share the same v4l2_device core.
@@ -469,6 +473,22 @@ If you use v4l2_ioctl_ops, then you should set either .unlocked_ioctl or
469The v4l2_file_operations struct is a subset of file_operations. The main 473The v4l2_file_operations struct is a subset of file_operations. The main
470difference is that the inode argument is omitted since it is never used. 474difference is that the inode argument is omitted since it is never used.
471 475
476v4l2_file_operations and locking
477--------------------------------
478
479You can set a pointer to a mutex_lock in struct video_device. Usually this
480will be either a top-level mutex or a mutex per device node. If you want
481finer-grained locking then you have to set it to NULL and do you own locking.
482
483If a lock is specified then all file operations will be serialized on that
484lock. If you use videobuf then you must pass the same lock to the videobuf
485queue initialize function: if videobuf has to wait for a frame to arrive, then
486it will temporarily unlock the lock and relock it afterwards. If your driver
487also waits in the code, then you should do the same to allow other processes
488to access the device node while the first process is waiting for something.
489
490The implementation of a hotplug disconnect should also take the lock before
491calling v4l2_device_disconnect and video_unregister_device.
472 492
473video_device registration 493video_device registration
474------------------------- 494-------------------------