media: Revert "media: mtk-vcodec: Remove extra area allocation in an input buffer...
authorAlexandre Courbot <acourbot@chromium.org>
Fri, 21 Aug 2020 10:36:02 +0000 (12:36 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sat, 26 Sep 2020 08:08:49 +0000 (10:08 +0200)
This reverts commit 81735ecb62f882853a37a8c157407ec4aed44fd0.

The hardware needs data to follow the previous alignment, so this extra
space was not superfluous after all. Besides, this also made
v4l2-compliance's G_FMT and S_FMT tests regress.

Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
Acked-by: Tiffany Lin <tiffany.lin@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c

index 3f19826..a9d2c77 100644 (file)
@@ -299,12 +299,14 @@ static int vidioc_try_fmt(struct v4l2_format *f,
 
                pix_fmt_mp->num_planes = fmt->num_planes;
                pix_fmt_mp->plane_fmt[0].sizeimage =
-                       pix_fmt_mp->width * pix_fmt_mp->height;
+                               pix_fmt_mp->width * pix_fmt_mp->height +
+                               ((ALIGN(pix_fmt_mp->width, 16) * 2) * 16);
                pix_fmt_mp->plane_fmt[0].bytesperline = pix_fmt_mp->width;
 
                if (pix_fmt_mp->num_planes == 2) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2;
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2 +
+                               (ALIGN(pix_fmt_mp->width, 16) * 16);
                        pix_fmt_mp->plane_fmt[2].sizeimage = 0;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                                        pix_fmt_mp->width;
@@ -312,7 +314,8 @@ static int vidioc_try_fmt(struct v4l2_format *f,
                } else if (pix_fmt_mp->num_planes == 3) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
                        pix_fmt_mp->plane_fmt[2].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4;
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4 +
+                               ((ALIGN(pix_fmt_mp->width, 16) / 2) * 16);
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                pix_fmt_mp->plane_fmt[2].bytesperline =
                                pix_fmt_mp->width / 2;