From: Shijie Qin Date: Thu, 13 May 2021 04:22:00 +0000 (+0800) Subject: MLK-25489 arm64: imx8mx: vpu: correct width-stride for RGB formats X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~77 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=56a6398ab387ae17aa7fe6a4f89c15a074ee57ba;p=linux.git MLK-25489 arm64: imx8mx: vpu: correct width-stride for RGB formats For imx8mm(hantro h1 encoder), per width-stride need to align to 16. RGB16: width-strde = bytesperline / 2 RGBX: width-stride = bytesperline / 4 Signed-off-by: Shijie Qin Reviewed-by: Hou Qi --- diff --git a/drivers/mxc/hantro_v4l2/vsi-v4l2-config.c b/drivers/mxc/hantro_v4l2/vsi-v4l2-config.c index e29d8ca071eb..500d0f1132ba 100755 --- a/drivers/mxc/hantro_v4l2/vsi-v4l2-config.c +++ b/drivers/mxc/hantro_v4l2/vsi-v4l2-config.c @@ -1054,6 +1054,24 @@ static int config_planeno(int pixelformat) } } +static int is_doublesizefmt(int fmt) +{ + if (fmt == VCENC_YUV422_INTERLEAVED_YUYV || + fmt == VCENC_RGB565 || + fmt == VCENC_BGR565 || + fmt == VCENC_RGB555) + return 1; + return 0; +} + +static int is_quadsizefmt(int fmt) +{ + if (fmt == VCENC_RGB888 || + fmt == VCENC_BGR888) + return 1; + return 0; +} + static int vsiv4l2_enc_getalign(u32 srcfmt, u32 dstfmt, int width) { int bytesperline = width; @@ -1065,33 +1083,20 @@ static int vsiv4l2_enc_getalign(u32 srcfmt, u32 dstfmt, int width) case V4L2_DAEMON_CODEC_ENC_H264: case V4L2_DAEMON_CODEC_ENC_VP8: default: - if (srcfmt == VCENC_YUV422_INTERLEAVED_YUYV && vsi_v4l2_hwconfig.enc_isH1) - bytesperline = ALIGN(bytesperline, 32); - else + if (vsi_v4l2_hwconfig.enc_isH1) { + if (is_doublesizefmt(srcfmt)) + bytesperline = ALIGN(bytesperline, 32); + else if (is_quadsizefmt(srcfmt)) + bytesperline = ALIGN(bytesperline, 64); + else + bytesperline = ALIGN(bytesperline, 16); + } else bytesperline = ALIGN(bytesperline, 16); break; } return bytesperline; } -static int is_doublesizefmt(int fmt) -{ - if (fmt == V4L2_PIX_FMT_RGB565 || fmt == V4L2_PIX_FMT_RGB555 || - fmt == V4L2_PIX_FMT_BGR565 || fmt == V4L2_PIX_FMT_YUYV) - return 1; - return 0; -} - -static int is_quadsizefmt(int fmt) -{ - if (fmt == V4L2_PIX_FMT_RGBA32 - || fmt == V4L2_PIX_FMT_BGR32 - || fmt == V4L2_PIX_FMT_ABGR32 - || fmt == V4L2_PIX_FMT_RGBX32) - return 1; - return 0; -} - static int vsiv4l2_setfmt_enc(struct vsi_v4l2_ctx *ctx, struct v4l2_format *fmt) { struct vsi_v4l2_mediacfg *pcfg = &ctx->mediacfg; @@ -1141,9 +1146,9 @@ static int vsiv4l2_setfmt_enc(struct vsi_v4l2_ctx *ctx, struct v4l2_format *fmt) for (i = 0; i < fmt->fmt.pix_mp.num_planes; i++) fmt->fmt.pix_mp.plane_fmt[i].bytesperline = pcfg->bytesperline; } - if (is_doublesizefmt(fmt->fmt.pix_mp.pixelformat)) + if (is_doublesizefmt(targetfmt->enc_fmt)) pcfg->encparams.general.lumWidthSrc = pcfg->bytesperline/2; - else if (is_quadsizefmt(fmt->fmt.pix_mp.pixelformat)) + else if (is_quadsizefmt(targetfmt->enc_fmt)) pcfg->encparams.general.lumWidthSrc = pcfg->bytesperline/4; else pcfg->encparams.general.lumWidthSrc = pcfg->bytesperline;