MLK-16906: drm: imx: core: add possiblity to detect if chip has DCSS
authorLaurentiu Palcu <laurentiu.palcu@nxp.com>
Fri, 17 Nov 2017 09:03:52 +0000 (11:03 +0200)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
The Mscale Display Controller Subsystem does not support RGB565.
However, the default legacy FB pixel depth is 16. Hence, the users would
have to add a kernel cmdline option to set it to 32bpp:
imxdrm.legacyfb_depth=32

This patch changes imx-drm-core to detect if platform has DCSS and, if
it does, set the FB pixel depth to 32, so that user does not have to.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
drivers/gpu/drm/imx/imx-drm-core.c

index 7d91dce..e426a46 100644 (file)
@@ -147,6 +147,44 @@ static int compare_of(struct device *dev, void *data)
        return dev->of_node == np;
 }
 
+static const char *const imx_drm_dcss_comp_parents[] = {
+       "nxp,imx8mq-dcss",
+};
+
+static bool imx_drm_parent_is_compatible(struct device *dev,
+                                        const char *const comp_parents[],
+                                        int comp_parents_size)
+{
+       struct device_node *port, *parent;
+       bool ret = false;
+       int i;
+
+       port = of_parse_phandle(dev->of_node, "ports", 0);
+       if (!port)
+               return ret;
+
+       parent = of_get_parent(port);
+
+       for (i = 0; i < comp_parents_size; i++) {
+               if (of_device_is_compatible(parent, comp_parents[i])) {
+                       ret = true;
+                       break;
+               }
+       }
+
+       of_node_put(parent);
+
+       of_node_put(port);
+
+       return ret;
+}
+
+static inline bool has_dcss(struct device *dev)
+{
+       return imx_drm_parent_is_compatible(dev, imx_drm_dcss_comp_parents,
+                                       ARRAY_SIZE(imx_drm_dcss_comp_parents));
+}
+
 static int imx_drm_bind(struct device *dev)
 {
        struct drm_device *drm;
@@ -202,8 +240,13 @@ static int imx_drm_bind(struct device *dev)
                dev_warn(dev, "Invalid legacyfb_depth.  Defaulting to 16bpp\n");
                legacyfb_depth = 16;
        }
+
+       if (legacyfb_depth == 16 && has_dcss(dev))
+               legacyfb_depth = 32;
+
        ret = drm_fb_cma_fbdev_init(drm, legacyfb_depth, MAX_CRTC);
        if (ret)
+
                goto err_unbind;
 #endif