]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: vivid: add buf_out_validate callback
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 16 Jan 2019 12:01:15 +0000 (10:01 -0200)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 31 Jan 2019 11:30:38 +0000 (09:30 -0200)
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: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/vivid/vivid-vid-out.c

index 55c0628ee9e184ccf7ae6b622cc9dcdc6cb2c341..b42b7fcc6145bcad9fbb25ccf077397098a45e7c 100644 (file)
@@ -84,10 +84,24 @@ static int vid_out_queue_setup(struct vb2_queue *vq,
        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 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 planes;
        unsigned p;
@@ -108,12 +122,6 @@ static int vid_out_buf_prepare(struct vb2_buffer *vb)
                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++) {
                size = dev->bytesperline_out[p] * dev->fmt_out_rect.height +
                        vb->planes[p].data_offset;
@@ -191,6 +199,7 @@ static void vid_out_buf_request_complete(struct vb2_buffer *vb)
 
 const struct vb2_ops vivid_vid_out_qops = {
        .queue_setup            = vid_out_queue_setup,
+       .buf_out_validate               = vid_out_buf_out_validate,
        .buf_prepare            = vid_out_buf_prepare,
        .buf_queue              = vid_out_buf_queue,
        .start_streaming        = vid_out_start_streaming,