media: mtk-vcodec: Align width and height to 64 bytes
authorYunfei Dong <yunfei.dong@mediatek.com>
Thu, 4 Nov 2021 12:24:26 +0000 (12:24 +0000)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 15 Nov 2021 08:12:04 +0000 (08:12 +0000)
Width and height need to 64 bytes aligned when setting the format.
Need to make sure all is 64 bytes align when use width and height to
calculate buffer size.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Steve Cho <stevecho@chromium.org>
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_dec.h
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c

index 4678351..e08886a 100644 (file)
@@ -11,6 +11,7 @@
 #include <media/videobuf2-core.h>
 #include <media/v4l2-mem2mem.h>
 
+#define VCODEC_DEC_ALIGNED_64 64
 #define VCODEC_CAPABILITY_4K_DISABLED  0x10
 #define VCODEC_DEC_4K_CODED_WIDTH      4096U
 #define VCODEC_DEC_4K_CODED_HEIGHT     2304U
index 946c230..5a7eefe 100644 (file)
@@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
 {
        struct mtk_vcodec_ctx *ctx = inst->ctx;
 
-       ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
-       ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
+       ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w, VCODEC_DEC_ALIGNED_64);
+       ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h, VCODEC_DEC_ALIGNED_64);
        ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
        ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
        inst->vsi_ctx.dec.cap_num_planes =