]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: vivid: add vertical down sampling to imagesize calc
authorAndré Almeida <andre.almeida@collabora.com>
Mon, 4 Feb 2019 17:37:33 +0000 (12:37 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 7 Feb 2019 17:24:03 +0000 (12:24 -0500)
To correctly set the size of the image in a plane, it's needed
to divide the height of image by the vertical down sampling factor.
This was only happening in vivid_try_fmt_vid_cap(), but now it
applied in others sizeimage calculations as well.

Signed-off-by: André Almeida <andre.almeida@collabora.com>
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-cap.c

index c059fc12668a8157b684f50c5dd124abbe23db27..52eeda624d7e440ad1a725b75649871270c22b7f 100644 (file)
@@ -124,7 +124,8 @@ static int vid_cap_queue_setup(struct vb2_queue *vq,
                }
        } else {
                for (p = 0; p < buffers; p++)
-                       sizes[p] = tpg_g_line_width(&dev->tpg, p) * h +
+                       sizes[p] = (tpg_g_line_width(&dev->tpg, p) * h) /
+                                       dev->fmt_cap->vdownsampling[p] +
                                        dev->fmt_cap->data_offset[p];
        }
 
@@ -161,7 +162,9 @@ static int vid_cap_buf_prepare(struct vb2_buffer *vb)
                return -EINVAL;
        }
        for (p = 0; p < buffers; p++) {
-               size = tpg_g_line_width(&dev->tpg, p) * dev->fmt_cap_rect.height +
+               size = (tpg_g_line_width(&dev->tpg, p) *
+                       dev->fmt_cap_rect.height) /
+                       dev->fmt_cap->vdownsampling[p] +
                        dev->fmt_cap->data_offset[p];
 
                if (vb2_plane_size(vb, p) < size) {
@@ -545,7 +548,8 @@ int vivid_g_fmt_vid_cap(struct file *file, void *priv,
        for (p = 0; p < mp->num_planes; p++) {
                mp->plane_fmt[p].bytesperline = tpg_g_bytesperline(&dev->tpg, p);
                mp->plane_fmt[p].sizeimage =
-                       tpg_g_line_width(&dev->tpg, p) * mp->height +
+                       (tpg_g_line_width(&dev->tpg, p) * mp->height) /
+                       dev->fmt_cap->vdownsampling[p] +
                        dev->fmt_cap->data_offset[p];
        }
        return 0;