1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
4 * Author: Archit Taneja <archit@ti.com>
7 #include <linux/bitops.h>
8 #include <linux/kernel.h>
9 #include <linux/module.h>
10 #include <linux/platform_device.h>
11 #include <linux/slab.h>
13 #include <linux/of_graph.h>
15 #include <drm/drm_panel.h>
20 int omapdss_device_init_output(struct omap_dss_device *out)
22 struct device_node *remote_node;
24 remote_node = of_graph_get_remote_node(out->dev->of_node,
25 ffs(out->of_ports) - 1, 0);
27 dev_dbg(out->dev, "failed to find video sink\n");
31 out->next = omapdss_find_device_by_node(remote_node);
32 out->bridge = of_drm_find_bridge(remote_node);
33 out->panel = of_drm_find_panel(remote_node);
34 if (IS_ERR(out->panel))
37 of_node_put(remote_node);
39 if (out->next && out->type != out->next->type) {
40 dev_err(out->dev, "output type and display type don't match\n");
41 omapdss_device_put(out->next);
46 return out->next || out->bridge || out->panel ? 0 : -EPROBE_DEFER;
48 EXPORT_SYMBOL(omapdss_device_init_output);
50 void omapdss_device_cleanup_output(struct omap_dss_device *out)
53 omapdss_device_put(out->next);
55 EXPORT_SYMBOL(omapdss_device_cleanup_output);
57 int dss_install_mgr_ops(struct dss_device *dss,
58 const struct dss_mgr_ops *mgr_ops,
59 struct omap_drm_private *priv)
64 dss->mgr_ops = mgr_ops;
65 dss->mgr_ops_priv = priv;
69 EXPORT_SYMBOL(dss_install_mgr_ops);
71 void dss_uninstall_mgr_ops(struct dss_device *dss)
74 dss->mgr_ops_priv = NULL;
76 EXPORT_SYMBOL(dss_uninstall_mgr_ops);
78 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
79 const struct videomode *vm)
81 dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv,
82 dssdev->dispc_channel, vm);
84 EXPORT_SYMBOL(dss_mgr_set_timings);
86 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
87 const struct dss_lcd_mgr_config *config)
89 dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv,
90 dssdev->dispc_channel, config);
92 EXPORT_SYMBOL(dss_mgr_set_lcd_config);
94 int dss_mgr_enable(struct omap_dss_device *dssdev)
96 return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv,
97 dssdev->dispc_channel);
99 EXPORT_SYMBOL(dss_mgr_enable);
101 void dss_mgr_disable(struct omap_dss_device *dssdev)
103 dssdev->dss->mgr_ops->disable(dssdev->dss->mgr_ops_priv,
104 dssdev->dispc_channel);
106 EXPORT_SYMBOL(dss_mgr_disable);
108 void dss_mgr_start_update(struct omap_dss_device *dssdev)
110 dssdev->dss->mgr_ops->start_update(dssdev->dss->mgr_ops_priv,
111 dssdev->dispc_channel);
113 EXPORT_SYMBOL(dss_mgr_start_update);
115 int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
116 void (*handler)(void *), void *data)
118 struct dss_device *dss = dssdev->dss;
120 return dss->mgr_ops->register_framedone_handler(dss->mgr_ops_priv,
121 dssdev->dispc_channel,
124 EXPORT_SYMBOL(dss_mgr_register_framedone_handler);
126 void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
127 void (*handler)(void *), void *data)
129 struct dss_device *dss = dssdev->dss;
131 dss->mgr_ops->unregister_framedone_handler(dss->mgr_ops_priv,
132 dssdev->dispc_channel,
135 EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler);