Commit 1f2f5107 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: vivid: add buf_out_validate callback

Validate the field for an output buffer. This ensures that the
field is validated when the buffer is queued to a request, and
not when the request itself is queued, which is too late.
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent ab7afaf3
...@@ -84,10 +84,24 @@ static int vid_out_queue_setup(struct vb2_queue *vq, ...@@ -84,10 +84,24 @@ static int vid_out_queue_setup(struct vb2_queue *vq,
return 0; return 0;
} }
static int vid_out_buf_prepare(struct vb2_buffer *vb) static int vid_out_buf_out_validate(struct vb2_buffer *vb)
{ {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
dprintk(dev, 1, "%s\n", __func__);
if (dev->field_out != V4L2_FIELD_ALTERNATE)
vbuf->field = dev->field_out;
else if (vbuf->field != V4L2_FIELD_TOP &&
vbuf->field != V4L2_FIELD_BOTTOM)
return -EINVAL;
return 0;
}
static int vid_out_buf_prepare(struct vb2_buffer *vb)
{
struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
unsigned long size; unsigned long size;
unsigned planes; unsigned planes;
unsigned p; unsigned p;
...@@ -108,12 +122,6 @@ static int vid_out_buf_prepare(struct vb2_buffer *vb) ...@@ -108,12 +122,6 @@ static int vid_out_buf_prepare(struct vb2_buffer *vb)
return -EINVAL; return -EINVAL;
} }
if (dev->field_out != V4L2_FIELD_ALTERNATE)
vbuf->field = dev->field_out;
else if (vbuf->field != V4L2_FIELD_TOP &&
vbuf->field != V4L2_FIELD_BOTTOM)
return -EINVAL;
for (p = 0; p < planes; p++) { for (p = 0; p < planes; p++) {
size = dev->bytesperline_out[p] * dev->fmt_out_rect.height + size = dev->bytesperline_out[p] * dev->fmt_out_rect.height +
vb->planes[p].data_offset; vb->planes[p].data_offset;
...@@ -191,6 +199,7 @@ static void vid_out_buf_request_complete(struct vb2_buffer *vb) ...@@ -191,6 +199,7 @@ static void vid_out_buf_request_complete(struct vb2_buffer *vb)
const struct vb2_ops vivid_vid_out_qops = { const struct vb2_ops vivid_vid_out_qops = {
.queue_setup = vid_out_queue_setup, .queue_setup = vid_out_queue_setup,
.buf_out_validate = vid_out_buf_out_validate,
.buf_prepare = vid_out_buf_prepare, .buf_prepare = vid_out_buf_prepare,
.buf_queue = vid_out_buf_queue, .buf_queue = vid_out_buf_queue,
.start_streaming = vid_out_start_streaming, .start_streaming = vid_out_start_streaming,
......
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