MLK-19158-5 drm/imx: lcdif: add bus format check to CRTC's check
authorFancy Fang <chen.fang@nxp.com>
Sun, 12 Aug 2018 08:10:01 +0000 (16:10 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
Add the check to LCDIF CRTC atomic check for the requested bus
format by encoder with the bus format which can be supported by
LCDIF CRTC to refuse unsupported case.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit e98afe9b6b20c2494c8570427b7811ed9ce202e8)
(cherry picked from commit 9f1bb920916492fba4b6c82f4c25203ce8090298)

drivers/gpu/drm/imx/lcdif/lcdif-crtc.c

index e5c3b65..c9a617e 100644 (file)
@@ -91,6 +91,24 @@ static void lcdif_crtc_destroy_state(struct drm_crtc *crtc,
 static int lcdif_crtc_atomic_check(struct drm_crtc *crtc,
                                   struct drm_crtc_state *state)
 {
+       struct lcdif_crtc *lcdif_crtc = to_lcdif_crtc(crtc);
+       struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(state);
+
+       /* check the requested bus format can be
+        * supported by LCDIF CTRC or not
+        */
+       switch (imx_crtc_state->bus_format) {
+       case MEDIA_BUS_FMT_RGB565_1X16:
+       case MEDIA_BUS_FMT_RGB666_1X18:
+       case MEDIA_BUS_FMT_RGB888_1X24:
+               break;
+       default:
+               dev_err(lcdif_crtc->dev,
+                       "unsupported bus format: %#x\n",
+                       imx_crtc_state->bus_format);
+               return -EINVAL;
+       }
+
        return 0;
 }