Commit 7bb6edd3 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] vb2: allow read/write as long as the format is single planar

It was impossible to read() or write() a frame if the queue type was multiplanar.
Even if the current format is single planar. Change this to just check whether
the number of planes is 1 or more.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 74753cff
......@@ -2658,6 +2658,7 @@ struct vb2_fileio_buf {
*/
struct vb2_fileio_data {
struct v4l2_requestbuffers req;
struct v4l2_plane p;
struct v4l2_buffer b;
struct vb2_fileio_buf bufs[VIDEO_MAX_FRAME];
unsigned int cur_index;
......@@ -2748,13 +2749,21 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
* Read mode requires pre queuing of all buffers.
*/
if (read) {
bool is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type);
/*
* Queue all buffers.
*/
for (i = 0; i < q->num_buffers; i++) {
struct v4l2_buffer *b = &fileio->b;
memset(b, 0, sizeof(*b));
b->type = q->type;
if (is_multiplanar) {
memset(&fileio->p, 0, sizeof(fileio->p));
b->m.planes = &fileio->p;
b->length = 1;
}
b->memory = q->memory;
b->index = i;
ret = vb2_internal_qbuf(q, b);
......@@ -2822,6 +2831,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
{
struct vb2_fileio_data *fileio;
struct vb2_fileio_buf *buf;
bool is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type);
/*
* When using write() to write data to an output video node the vb2 core
* should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody
......@@ -2861,6 +2871,11 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
memset(&fileio->b, 0, sizeof(fileio->b));
fileio->b.type = q->type;
fileio->b.memory = q->memory;
if (is_multiplanar) {
memset(&fileio->p, 0, sizeof(fileio->p));
fileio->b.m.planes = &fileio->p;
fileio->b.length = 1;
}
ret = vb2_internal_dqbuf(q, &fileio->b, nonblock);
dprintk(5, "vb2_dqbuf result: %d\n", ret);
if (ret)
......@@ -2931,6 +2946,12 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
fileio->b.memory = q->memory;
fileio->b.index = index;
fileio->b.bytesused = buf->pos;
if (is_multiplanar) {
memset(&fileio->p, 0, sizeof(fileio->p));
fileio->p.bytesused = buf->pos;
fileio->b.m.planes = &fileio->p;
fileio->b.length = 1;
}
if (set_timestamp)
v4l2_get_timestamp(&fileio->b.timestamp);
ret = vb2_internal_qbuf(q, &fileio->b);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment