diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2018-05-21 04:54:51 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-08-31 11:20:10 -0400 |
commit | c07aa48ec57eca649e987e8f19a336d4373b8da6 (patch) | |
tree | b663c201f8732e4911fe11e35379ce58de848793 /drivers/media | |
parent | 394dc588809158826e2877adb670391829f91c63 (diff) | |
download | talos-op-linux-c07aa48ec57eca649e987e8f19a336d4373b8da6.tar.gz talos-op-linux-c07aa48ec57eca649e987e8f19a336d4373b8da6.zip |
media: videobuf2-core: add request helper functions
Add a new helper function to tell if a request object is a buffer.
Add a new helper function that returns true if a media_request
contains at least one buffer.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/common/videobuf2/videobuf2-core.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 16c9a08192cf..f941bf4bd55f 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1362,6 +1362,30 @@ static const struct media_request_object_ops vb2_core_req_ops = { .release = vb2_req_release, }; +bool vb2_request_object_is_buffer(struct media_request_object *obj) +{ + return obj->ops == &vb2_core_req_ops; +} +EXPORT_SYMBOL_GPL(vb2_request_object_is_buffer); + +bool vb2_request_has_buffers(struct media_request *req) +{ + struct media_request_object *obj; + unsigned long flags; + bool has_buffers = false; + + spin_lock_irqsave(&req->lock, flags); + list_for_each_entry(obj, &req->objects, list) { + if (vb2_request_object_is_buffer(obj)) { + has_buffers = true; + break; + } + } + spin_unlock_irqrestore(&req->lock, flags); + return has_buffers; +} +EXPORT_SYMBOL_GPL(vb2_request_has_buffers); + int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb) { struct vb2_buffer *vb; |