From: Janghyuck Kim Date: Fri, 23 Mar 2018 07:34:55 +0000 (+0900) Subject: [media] vb2: add is_unordered callback for drivers X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=087d5a2870133e942b6f0a2aaee8e40c9f7b49d2;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [media] vb2: add is_unordered callback for drivers Explicit synchronization benefits a lot from ordered queues, they fit better in a pipeline with DRM for example so create a opt-in way for drivers notify videobuf2 that the queue is unordered. Drivers don't need implement it if the queue is ordered. v2: - improve comments for is_unordered flag (Hans) v3: - make it bool (Hans) - create vb2_ops_set_unordered() helper Signed-off-by: Gustavo Padovan Change-Id: I519c8576f2fd1b83e60a4da40c169b16b86ef825 Signed-off-by: Janghyuck Kim --- diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c index 466de62ad1e3..5f4a57d10f07 100644 --- a/drivers/media/v4l2-core/videobuf2-v4l2.c +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c @@ -960,6 +960,12 @@ void vb2_ops_wait_finish(struct vb2_queue *vq) } EXPORT_SYMBOL_GPL(vb2_ops_wait_finish); +bool vb2_ops_set_unordered(struct vb2_queue *q) +{ + return true; +} +EXPORT_SYMBOL_GPL(vb2_ops_set_unordered); + MODULE_DESCRIPTION("Driver helper framework for Video for Linux 2"); MODULE_AUTHOR("Pawel Osciak , Marek Szyprowski"); MODULE_LICENSE("GPL"); diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index ef9b64398c8c..87a7f3fec23d 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -368,6 +368,10 @@ struct vb2_buffer { * callback by calling vb2_buffer_done() with either * %VB2_BUF_STATE_DONE or %VB2_BUF_STATE_ERROR; may use * vb2_wait_for_all_buffers() function + * @is_unordered: tell if the queue is unordered, i.e. buffers can be + * dequeued in a different order from how they were queued. + * The default is assumed to be ordered and this function + * only needs to be implemented for unordered queues. * @buf_queue: passes buffer vb to the driver; driver may start * hardware operation on this buffer; driver should give * the buffer back by calling vb2_buffer_done() function; @@ -391,6 +395,7 @@ struct vb2_ops { int (*start_streaming)(struct vb2_queue *q, unsigned int count); void (*stop_streaming)(struct vb2_queue *q); + bool (*is_unordered)(struct vb2_queue *q); void (*buf_queue)(struct vb2_buffer *vb); }; @@ -564,6 +569,7 @@ struct vb2_queue { u32 cnt_wait_finish; u32 cnt_start_streaming; u32 cnt_stop_streaming; + u32 cnt_is_unordered; #endif }; diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 64bc7dfaddde..1922536c9da6 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -288,4 +288,14 @@ void vb2_ops_wait_prepare(struct vb2_queue *vq); */ void vb2_ops_wait_finish(struct vb2_queue *vq); +/** + * vb2_ops_set_unordered - helper function to mark queue as unordered + * + * @vq: pointer to &struct vb2_queue + * + * This helper just return true to notify that the driver can't deal with + * ordered queues. + */ +bool vb2_ops_set_unordered(struct vb2_queue *q); + #endif /* _MEDIA_VIDEOBUF2_V4L2_H */