aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/videobuf2-v4l2.h
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2020-07-13 13:30:42 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-08-28 14:58:48 +0200
commitf729ef5796d82a95758d9edc7eea5879a3a12b25 (patch)
tree60ccd83fdbbb0e43b9eb32412fd70999f81c4e69 /include/media/videobuf2-v4l2.h
parentmedia: MAINTAINERS: Fix sort order for RDACM20 (diff)
downloadlinux-dev-f729ef5796d82a95758d9edc7eea5879a3a12b25.tar.xz
linux-dev-f729ef5796d82a95758d9edc7eea5879a3a12b25.zip
media: videobuf2-v4l2.c: add vb2_video_unregister_device helper function
If a driver calls (_)vb2_fop_release(), then such a driver should also call vb2_video_unregister_device() instead of video_unregister_device(). This helper will call vb2_queue_release() if a filehandle is marked as owner of the queue. This ensures that at unregister time any streaming is cancelled and all buffers are returned to userspace. This is very useful for complex drivers since this stops all streaming in all subdevs in the pipeline controlled by this video device. Otherwise this would be delayed until the owner filehandle is closed, which can be quite some time later. Bonus points for ordering the includes :-) Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'include/media/videobuf2-v4l2.h')
-rw-r--r--include/media/videobuf2-v4l2.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h
index b7b5a9cb5a28..c203047eb834 100644
--- a/include/media/videobuf2-v4l2.h
+++ b/include/media/videobuf2-v4l2.h
@@ -23,6 +23,8 @@
#error VB2_MAX_PLANES != VIDEO_MAX_PLANES
#endif
+struct video_device;
+
/**
* struct vb2_v4l2_buffer - video buffer information for v4l2.
*
@@ -320,6 +322,21 @@ unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr,
#endif
/**
+ * vb2_video_unregister_device - unregister the video device and release queue
+ *
+ * @vdev: pointer to &struct video_device
+ *
+ * If the driver uses vb2_fop_release()/_vb2_fop_release(), then it should use
+ * vb2_video_unregister_device() instead of video_unregister_device().
+ *
+ * This function will call video_unregister_device() and then release the
+ * vb2_queue if streaming is in progress. This will stop streaming and
+ * this will simplify the unbind sequence since after this call all subdevs
+ * will have stopped streaming as well.
+ */
+void vb2_video_unregister_device(struct video_device *vdev);
+
+/**
* vb2_ops_wait_prepare - helper function to lock a struct &vb2_queue
*
* @vq: pointer to &struct vb2_queue