MLK-16353-3 video: fbdev: dcss: add alignment check in check_var()
authorFancy Fang <chen.fang@nxp.com>
Mon, 4 Sep 2017 04:03:42 +0000 (12:03 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:38:27 +0000 (15:38 -0500)
Add alignment check for SCALER which requires both
width and height to be divisable by 4. Put the check
in fb_check_var hook.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
drivers/video/fbdev/mxc/imx_dcss.c

index 7c70216..3239dc0 100644 (file)
@@ -2433,6 +2433,27 @@ static int dcss_check_var(struct fb_var_screeninfo *var,
                }
                var->bits_per_pixel = format->bpp;
        }
+
+       /* Add alignment check for scaler */
+       switch (fmt_is_yuv(var->grayscale)) {
+       case 0:         /* ARGB8888 */
+               if (ALIGN(var->xres, 4) != var->xres ||
+                   ALIGN(var->yres, 4) != var->yres) {
+                       dev_err(&pdev->dev, "width or height is not aligned\n");
+                       return -EINVAL;
+               }
+               break;
+       case 2:         /* YUV420 */
+               if (ALIGN(var->xres, 16) != var->xres ||
+                   ALIGN(var->yres, 8) != var->yres) {
+                       dev_err(&pdev->dev, "width or height is not aligned\n");
+                       return -EINVAL;
+               }
+               break;
+       default:
+               return -EINVAL;
+       }
+
        fix->line_length = var->xres * (var->bits_per_pixel >> 3);
        fb_size = var->yres_virtual * fix->line_length;