diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2018-05-23 07:51:25 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-08-31 11:22:56 -0400 |
commit | 61add367dda6309ee1702d85344b5fcbd6ede9a1 (patch) | |
tree | bf739b58b8bc1f89f456867732aa164faa739cda /drivers/media/common/videobuf2 | |
parent | 86f6bd3cf1222c62bcccd76daf1c831f22e595bf (diff) | |
download | linux-61add367dda6309ee1702d85344b5fcbd6ede9a1.tar.gz |
media: videobuf2-core: add uses_requests/qbuf flags
Set the first time a buffer from a request is queued to vb2
(uses_requests) or directly queued (uses_qbuf).
Cleared when the queue is canceled.
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/common/videobuf2')
-rw-r--r-- | drivers/media/common/videobuf2/videobuf2-core.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index f941bf4bd55f..2dc3fc935f87 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1491,9 +1491,17 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, vb = q->bufs[index]; + if ((req && q->uses_qbuf) || + (!req && vb->state != VB2_BUF_STATE_IN_REQUEST && + q->uses_requests)) { + dprintk(1, "queue in wrong mode (qbuf vs requests)\n"); + return -EPERM; + } + if (req) { int ret; + q->uses_requests = 1; if (vb->state != VB2_BUF_STATE_DEQUEUED) { dprintk(1, "buffer %d not in dequeued state\n", vb->index); @@ -1523,6 +1531,9 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, return 0; } + if (vb->state != VB2_BUF_STATE_IN_REQUEST) + q->uses_qbuf = 1; + switch (vb->state) { case VB2_BUF_STATE_DEQUEUED: case VB2_BUF_STATE_IN_REQUEST: @@ -1825,6 +1836,8 @@ static void __vb2_queue_cancel(struct vb2_queue *q) q->start_streaming_called = 0; q->queued_count = 0; q->error = 0; + q->uses_requests = 0; + q->uses_qbuf = 0; /* * Remove all buffers from videobuf's list... |