drm/imx: ipuv3-plane: do not advertise YUV formats on planes without CSC
authorPhilipp Zabel <p.zabel@pengutronix.de>
Tue, 19 Jan 2021 13:51:08 +0000 (14:51 +0100)
committerPhilipp Zabel <p.zabel@pengutronix.de>
Mon, 10 May 2021 08:06:08 +0000 (10:06 +0200)
Only planes that are displayed via the Display Processor (DP) path
support color space conversion. Limit formats on planes that are
shown via the direct Display Controller (DC) path to RGB.

Reported-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
drivers/gpu/drm/imx/ipuv3-plane.c

index fa50097..fc8f483 100644 (file)
@@ -35,7 +35,7 @@ static inline struct ipu_plane *to_ipu_plane(struct drm_plane *p)
        return container_of(p, struct ipu_plane, base);
 }
 
-static const uint32_t ipu_plane_formats[] = {
+static const uint32_t ipu_plane_all_formats[] = {
        DRM_FORMAT_ARGB1555,
        DRM_FORMAT_XRGB1555,
        DRM_FORMAT_ABGR1555,
@@ -72,6 +72,31 @@ static const uint32_t ipu_plane_formats[] = {
        DRM_FORMAT_BGRX8888_A8,
 };
 
+static const uint32_t ipu_plane_rgb_formats[] = {
+       DRM_FORMAT_ARGB1555,
+       DRM_FORMAT_XRGB1555,
+       DRM_FORMAT_ABGR1555,
+       DRM_FORMAT_XBGR1555,
+       DRM_FORMAT_RGBA5551,
+       DRM_FORMAT_BGRA5551,
+       DRM_FORMAT_ARGB4444,
+       DRM_FORMAT_ARGB8888,
+       DRM_FORMAT_XRGB8888,
+       DRM_FORMAT_ABGR8888,
+       DRM_FORMAT_XBGR8888,
+       DRM_FORMAT_RGBA8888,
+       DRM_FORMAT_RGBX8888,
+       DRM_FORMAT_BGRA8888,
+       DRM_FORMAT_BGRX8888,
+       DRM_FORMAT_RGB565,
+       DRM_FORMAT_RGB565_A8,
+       DRM_FORMAT_BGR565_A8,
+       DRM_FORMAT_RGB888_A8,
+       DRM_FORMAT_BGR888_A8,
+       DRM_FORMAT_RGBX8888_A8,
+       DRM_FORMAT_BGRX8888_A8,
+};
+
 static const uint64_t ipu_format_modifiers[] = {
        DRM_FORMAT_MOD_LINEAR,
        DRM_FORMAT_MOD_INVALID
@@ -830,16 +855,24 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
        struct ipu_plane *ipu_plane;
        const uint64_t *modifiers = ipu_format_modifiers;
        unsigned int zpos = (type == DRM_PLANE_TYPE_PRIMARY) ? 0 : 1;
+       unsigned int format_count;
+       const uint32_t *formats;
        int ret;
 
        DRM_DEBUG_KMS("channel %d, dp flow %d, possible_crtcs=0x%x\n",
                      dma, dp, possible_crtcs);
 
+       if (dp == IPU_DP_FLOW_SYNC_BG || dp == IPU_DP_FLOW_SYNC_FG) {
+               formats = ipu_plane_all_formats;
+               format_count = ARRAY_SIZE(ipu_plane_all_formats);
+       } else {
+               formats = ipu_plane_rgb_formats;
+               format_count = ARRAY_SIZE(ipu_plane_rgb_formats);
+       }
        ipu_plane = drmm_universal_plane_alloc(dev, struct ipu_plane, base,
                                               possible_crtcs, &ipu_plane_funcs,
-                                              ipu_plane_formats,
-                                              ARRAY_SIZE(ipu_plane_formats),
-                                              modifiers, type, NULL);
+                                              formats, format_count, modifiers,
+                                              type, NULL);
        if (IS_ERR(ipu_plane)) {
                DRM_ERROR("failed to allocate and initialize %s plane\n",
                          zpos ? "overlay" : "primary");