]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/omap: dss: Support for detecting display stack readiness
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Tue, 3 May 2016 19:07:10 +0000 (22:07 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 3 Apr 2017 09:36:40 +0000 (12:36 +0300)
When omapdss is loaded (all core components are in place) create a list of
devices used in the display graph. This list later can be used by omapdrm
via the omapdss_stack_is_ready() function to check that these components
are loaded. Based on this information, omapdrm can defer probe in case when
the omapdss stack is not ready yet.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/omapdrm/dss/base.c
drivers/gpu/drm/omapdrm/dss/dss.c
drivers/gpu/drm/omapdrm/dss/omapdss.h

index 7dd447e6c4d7cc1677ea443796e96ecdd64b8936..13e91faaf7a6549a1025f4c40a0a176a2a3173e4 100644 (file)
@@ -1,9 +1,21 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_graph.h>
+#include <linux/list.h>
+#include "omapdss.h"
 
 static bool dss_initialized;
 static const struct dispc_ops *ops;
 
+static struct list_head omapdss_comp_list;
+
+struct omapdss_comp_node {
+       struct list_head list;
+       struct device_node *node;
+       bool dss_core_component;
+};
+
 void omapdss_set_is_initialized(bool set)
 {
        dss_initialized = set;
@@ -28,6 +40,101 @@ const struct dispc_ops *dispc_get_ops(void)
 }
 EXPORT_SYMBOL(dispc_get_ops);
 
+static bool omapdss_list_contains(const struct device_node *node)
+{
+       struct omapdss_comp_node *comp;
+
+       list_for_each_entry(comp, &omapdss_comp_list, list) {
+               if (comp->node == node)
+                       return true;
+       }
+
+       return false;
+}
+
+static void omapdss_walk_device(struct device *dev, struct device_node *node,
+                               bool dss_core)
+{
+       struct device_node *n;
+       struct omapdss_comp_node *comp = devm_kzalloc(dev, sizeof(*comp),
+                                                     GFP_KERNEL);
+
+       if (comp) {
+               comp->node = node;
+               comp->dss_core_component = dss_core;
+               list_add(&comp->list, &omapdss_comp_list);
+       }
+
+       /*
+        * of_graph_get_remote_port_parent() prints an error if there is no
+        * port/ports node. To avoid that, check first that there's the node.
+        */
+       n = of_get_child_by_name(node, "ports");
+       if (!n)
+               n = of_get_child_by_name(node, "port");
+       if (!n)
+               return;
+
+       of_node_put(n);
+
+       n = NULL;
+       while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
+               struct device_node *pn = of_graph_get_remote_port_parent(n);
+
+               if (!pn)
+                       continue;
+
+               if (!of_device_is_available(pn) || omapdss_list_contains(pn)) {
+                       of_node_put(pn);
+                       continue;
+               }
+
+               omapdss_walk_device(dev, pn, false);
+       }
+}
+
+void omapdss_gather_components(struct device *dev)
+{
+       struct device_node *child;
+
+       INIT_LIST_HEAD(&omapdss_comp_list);
+
+       omapdss_walk_device(dev, dev->of_node, true);
+
+       for_each_available_child_of_node(dev->of_node, child) {
+               if (!of_find_property(child, "compatible", NULL))
+                       continue;
+
+               omapdss_walk_device(dev, child, true);
+       }
+}
+EXPORT_SYMBOL(omapdss_gather_components);
+
+static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
+{
+       if (comp->dss_core_component)
+               return true;
+       if (omapdss_component_is_display(comp->node))
+               return true;
+       if (omapdss_component_is_output(comp->node))
+               return true;
+
+       return false;
+}
+
+bool omapdss_stack_is_ready(void)
+{
+       struct omapdss_comp_node *comp;
+
+       list_for_each_entry(comp, &omapdss_comp_list, list) {
+               if (!omapdss_component_is_loaded(comp))
+                       return false;
+       }
+
+       return true;
+}
+EXPORT_SYMBOL(omapdss_stack_is_ready);
+
 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
 MODULE_DESCRIPTION("OMAP Display Subsystem Base");
 MODULE_LICENSE("GPL v2");
index 5eb2f126054713a118276c30f139faccdd96c108..ceb483650f8ca7753025e5f73d78407b692e4f6d 100644 (file)
@@ -1258,6 +1258,7 @@ static int dss_bind(struct device *dev)
 
        pm_set_vt_switch(0);
 
+       omapdss_gather_components(dev);
        omapdss_set_is_initialized(true);
 
        return 0;
index 7e1feb935137177191f90f1270bd64b5b9cffb76..d5c369bd565c72b953c17500e76aa8c8dec77ff9 100644 (file)
@@ -939,4 +939,7 @@ const struct dispc_ops *dispc_get_ops(void);
 bool omapdss_component_is_display(struct device_node *node);
 bool omapdss_component_is_output(struct device_node *node);
 
+bool omapdss_stack_is_ready(void);
+void omapdss_gather_components(struct device *dev);
+
 #endif /* __OMAP_DRM_DSS_H */