mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-20 08:38:24 +08:00
[media] V4L: add a new videobuf2 buffer state VB2_BUF_STATE_PREPARED
This patch prepares for a better separation of the buffer preparation stage. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
2b3d0457b8
commit
ebc087d090
@ -366,6 +366,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
|
|||||||
b->flags |= V4L2_BUF_FLAG_DONE;
|
b->flags |= V4L2_BUF_FLAG_DONE;
|
||||||
break;
|
break;
|
||||||
case VB2_BUF_STATE_DEQUEUED:
|
case VB2_BUF_STATE_DEQUEUED:
|
||||||
|
case VB2_BUF_STATE_PREPARED:
|
||||||
/* nothing */
|
/* nothing */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -832,6 +833,33 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
|
|||||||
q->ops->buf_queue(vb);
|
q->ops->buf_queue(vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __buf_prepare(struct vb2_buffer *vb, struct v4l2_buffer *b)
|
||||||
|
{
|
||||||
|
struct vb2_queue *q = vb->vb2_queue;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
switch (q->memory) {
|
||||||
|
case V4L2_MEMORY_MMAP:
|
||||||
|
ret = __qbuf_mmap(vb, b);
|
||||||
|
break;
|
||||||
|
case V4L2_MEMORY_USERPTR:
|
||||||
|
ret = __qbuf_userptr(vb, b);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WARN(1, "Invalid queue type\n");
|
||||||
|
ret = -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
ret = call_qop(q, buf_prepare, vb);
|
||||||
|
if (ret)
|
||||||
|
dprintk(1, "qbuf: buffer preparation failed: %d\n", ret);
|
||||||
|
else
|
||||||
|
vb->state = VB2_BUF_STATE_PREPARED;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vb2_qbuf() - Queue a buffer from userspace
|
* vb2_qbuf() - Queue a buffer from userspace
|
||||||
* @q: videobuf2 queue
|
* @q: videobuf2 queue
|
||||||
@ -841,8 +869,8 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
|
|||||||
* Should be called from vidioc_qbuf ioctl handler of a driver.
|
* Should be called from vidioc_qbuf ioctl handler of a driver.
|
||||||
* This function:
|
* This function:
|
||||||
* 1) verifies the passed buffer,
|
* 1) verifies the passed buffer,
|
||||||
* 2) calls buf_prepare callback in the driver (if provided), in which
|
* 2) if necessary, calls buf_prepare callback in the driver (if provided), in
|
||||||
* driver-specific buffer initialization can be performed,
|
* which driver-specific buffer initialization can be performed,
|
||||||
* 3) if streaming is on, queues the buffer in driver by the means of buf_queue
|
* 3) if streaming is on, queues the buffer in driver by the means of buf_queue
|
||||||
* callback for processing.
|
* callback for processing.
|
||||||
*
|
*
|
||||||
@ -852,7 +880,7 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
|
|||||||
int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
|
int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
|
||||||
{
|
{
|
||||||
struct vb2_buffer *vb;
|
struct vb2_buffer *vb;
|
||||||
int ret = 0;
|
int ret;
|
||||||
|
|
||||||
if (q->fileio) {
|
if (q->fileio) {
|
||||||
dprintk(1, "qbuf: file io in progress\n");
|
dprintk(1, "qbuf: file io in progress\n");
|
||||||
@ -881,29 +909,18 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vb->state != VB2_BUF_STATE_DEQUEUED) {
|
switch (vb->state) {
|
||||||
|
case VB2_BUF_STATE_DEQUEUED:
|
||||||
|
ret = __buf_prepare(vb, b);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
case VB2_BUF_STATE_PREPARED:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
dprintk(1, "qbuf: buffer already in use\n");
|
dprintk(1, "qbuf: buffer already in use\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (q->memory == V4L2_MEMORY_MMAP)
|
|
||||||
ret = __qbuf_mmap(vb, b);
|
|
||||||
else if (q->memory == V4L2_MEMORY_USERPTR)
|
|
||||||
ret = __qbuf_userptr(vb, b);
|
|
||||||
else {
|
|
||||||
WARN(1, "Invalid queue type\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = call_qop(q, buf_prepare, vb);
|
|
||||||
if (ret) {
|
|
||||||
dprintk(1, "qbuf: buffer preparation failed\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add to the queued buffers list, a buffer will stay on it until
|
* Add to the queued buffers list, a buffer will stay on it until
|
||||||
* dequeued in dqbuf.
|
* dequeued in dqbuf.
|
||||||
|
@ -105,6 +105,7 @@ enum vb2_fileio_flags {
|
|||||||
/**
|
/**
|
||||||
* enum vb2_buffer_state - current video buffer state
|
* enum vb2_buffer_state - current video buffer state
|
||||||
* @VB2_BUF_STATE_DEQUEUED: buffer under userspace control
|
* @VB2_BUF_STATE_DEQUEUED: buffer under userspace control
|
||||||
|
* @VB2_BUF_STATE_PREPARED: buffer prepared in videobuf and by the driver
|
||||||
* @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver
|
* @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver
|
||||||
* @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used
|
* @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used
|
||||||
* in a hardware operation
|
* in a hardware operation
|
||||||
@ -116,6 +117,7 @@ enum vb2_fileio_flags {
|
|||||||
*/
|
*/
|
||||||
enum vb2_buffer_state {
|
enum vb2_buffer_state {
|
||||||
VB2_BUF_STATE_DEQUEUED,
|
VB2_BUF_STATE_DEQUEUED,
|
||||||
|
VB2_BUF_STATE_PREPARED,
|
||||||
VB2_BUF_STATE_QUEUED,
|
VB2_BUF_STATE_QUEUED,
|
||||||
VB2_BUF_STATE_ACTIVE,
|
VB2_BUF_STATE_ACTIVE,
|
||||||
VB2_BUF_STATE_DONE,
|
VB2_BUF_STATE_DONE,
|
||||||
|
Loading…
Reference in New Issue
Block a user