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 46783516b84a70ba0dfef9816324508f4c6103cb..e08886a600a3b3102999bd318ca92cd6503f5c52 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 946c23088308743d39b7053c92d8e94745c00a02..5a7eefe639a8199dcc959999793145d06d4d8526 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 =