MLK-25489 arm64: imx8mx: vpu: correct width-stride for RGB formats
authorShijie Qin <shijie.qin@nxp.com>
Thu, 13 May 2021 04:22:00 +0000 (12:22 +0800)
committerShijie Qin <shijie.qin@nxp.com>
Thu, 13 May 2021 05:29:53 +0000 (13:29 +0800)
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 <shijie.qin@nxp.com>
Reviewed-by: Hou Qi <qi.hou@nxp.com>
drivers/mxc/hantro_v4l2/vsi-v4l2-config.c

index e29d8ca..500d0f1 100755 (executable)
@@ -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;