summaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2018-06-26 09:26:52 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-07-25 08:10:31 -0400
commitee1228cca15ce097b7badebfdd0fef23a2cca9e1 (patch)
tree21a2a345180ad0a86e4faa9f2cca1d514909c7fe /drivers/media/v4l2-core
parent62c3fce04154777e6a3ce3a27f123b645d36dcff (diff)
downloadlinux-ee1228cca15ce097b7badebfdd0fef23a2cca9e1.tar.gz
linux-ee1228cca15ce097b7badebfdd0fef23a2cca9e1.tar.bz2
linux-ee1228cca15ce097b7badebfdd0fef23a2cca9e1.zip
media: v4l2-mem2mem: add v4l2_m2m_last_buf()
This can be used to mark the last queued source buffer as the last buffer. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r--drivers/media/v4l2-core/v4l2-mem2mem.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 4aeedb91594a..d9565ee44578 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -129,6 +129,24 @@ void *v4l2_m2m_next_buf(struct v4l2_m2m_queue_ctx *q_ctx)
}
EXPORT_SYMBOL_GPL(v4l2_m2m_next_buf);
+void *v4l2_m2m_last_buf(struct v4l2_m2m_queue_ctx *q_ctx)
+{
+ struct v4l2_m2m_buffer *b;
+ unsigned long flags;
+
+ spin_lock_irqsave(&q_ctx->rdy_spinlock, flags);
+
+ if (list_empty(&q_ctx->rdy_queue)) {
+ spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
+ return NULL;
+ }
+
+ b = list_last_entry(&q_ctx->rdy_queue, struct v4l2_m2m_buffer, list);
+ spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
+ return &b->vb;
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_last_buf);
+
void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx)
{
struct v4l2_m2m_buffer *b;