MA-18933-02: media: isi-m2m: add invalid format handle for ISI mem2mem
authorGuoniu.zhou <guoniu.zhou@nxp.com>
Tue, 20 Apr 2021 06:08:40 +0000 (14:08 +0800)
committerGuoniu.zhou <guoniu.zhou@nxp.com>
Wed, 21 Apr 2021 07:04:22 +0000 (15:04 +0800)
When user set invalid value for width or height, driver will return
error, so adding invalid format handle for the case. The value will
be selected among the minimum and maximum value of ISI support

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
drivers/staging/media/imx/imx8-isi-m2m.c

index b363f52..a263775 100644 (file)
@@ -495,17 +495,12 @@ static int isi_m2m_try_fmt(struct mxc_isi_frame *frame,
                return -EINVAL;
        }
 
-       if (pix->width <= 0 || pix->height <= 0) {
-               pr_err("%s, width %d, height %d is not valid\n"
-                               , __func__, pix->width, pix->height);
-               return -EINVAL;
-       }
 
        pix->num_planes = fmt->memplanes;
        pix->pixelformat = fmt->fourcc;
        pix->field = V4L2_FIELD_NONE;
-       pix->width  = frame->width;
-       pix->height = frame->height;
+       pix->width  = clamp(pix->width, ISI_MIN, ISI_4K);
+       pix->height = clamp(pix->height, ISI_MIN, ISI_8K);
        memset(pix->reserved, 0x00, sizeof(pix->reserved));
 
        for (i = 0; i < pix->num_planes; i++) {