1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
4 * Author: Archit Taneja <archit@ti.com>
7 #include <linux/kernel.h>
8 #include <linux/module.h>
9 #include <linux/platform_device.h>
10 #include <linux/slab.h>
12 #include <linux/of_graph.h>
14 #include <drm/drm_bridge.h>
15 #include <drm/drm_panel.h>
20 int omapdss_device_init_output(struct omap_dss_device
*out
,
21 struct drm_bridge
*local_bridge
)
23 struct device_node
*remote_node
;
26 remote_node
= of_graph_get_remote_node(out
->dev
->of_node
,
29 dev_dbg(out
->dev
, "failed to find video sink\n");
33 out
->next
= omapdss_find_device_by_node(remote_node
);
34 out
->bridge
= of_drm_find_bridge(remote_node
);
35 out
->panel
= of_drm_find_panel(remote_node
);
36 if (IS_ERR(out
->panel
))
39 of_node_put(remote_node
);
41 if (out
->next
&& out
->type
!= out
->next
->type
) {
42 dev_err(out
->dev
, "output type and display type don't match\n");
48 struct drm_bridge
*bridge
;
50 bridge
= drm_panel_bridge_add(out
->panel
);
53 "unable to create panel bridge (%ld)\n",
55 ret
= PTR_ERR(bridge
);
68 out
->next_bridge
= out
->bridge
;
69 out
->bridge
= local_bridge
;
72 if (!out
->next
&& !out
->bridge
) {
80 omapdss_device_cleanup_output(out
);
84 EXPORT_SYMBOL(omapdss_device_init_output
);
86 void omapdss_device_cleanup_output(struct omap_dss_device
*out
)
88 if (out
->bridge
&& out
->panel
)
89 drm_panel_bridge_remove(out
->next_bridge
?
90 out
->next_bridge
: out
->bridge
);
93 omapdss_device_put(out
->next
);
95 EXPORT_SYMBOL(omapdss_device_cleanup_output
);
97 int dss_install_mgr_ops(struct dss_device
*dss
,
98 const struct dss_mgr_ops
*mgr_ops
,
99 struct omap_drm_private
*priv
)
104 dss
->mgr_ops
= mgr_ops
;
105 dss
->mgr_ops_priv
= priv
;
109 EXPORT_SYMBOL(dss_install_mgr_ops
);
111 void dss_uninstall_mgr_ops(struct dss_device
*dss
)
114 dss
->mgr_ops_priv
= NULL
;
116 EXPORT_SYMBOL(dss_uninstall_mgr_ops
);
118 void dss_mgr_set_timings(struct omap_dss_device
*dssdev
,
119 const struct videomode
*vm
)
121 dssdev
->dss
->mgr_ops
->set_timings(dssdev
->dss
->mgr_ops_priv
,
122 dssdev
->dispc_channel
, vm
);
124 EXPORT_SYMBOL(dss_mgr_set_timings
);
126 void dss_mgr_set_lcd_config(struct omap_dss_device
*dssdev
,
127 const struct dss_lcd_mgr_config
*config
)
129 dssdev
->dss
->mgr_ops
->set_lcd_config(dssdev
->dss
->mgr_ops_priv
,
130 dssdev
->dispc_channel
, config
);
132 EXPORT_SYMBOL(dss_mgr_set_lcd_config
);
134 int dss_mgr_enable(struct omap_dss_device
*dssdev
)
136 return dssdev
->dss
->mgr_ops
->enable(dssdev
->dss
->mgr_ops_priv
,
137 dssdev
->dispc_channel
);
139 EXPORT_SYMBOL(dss_mgr_enable
);
141 void dss_mgr_disable(struct omap_dss_device
*dssdev
)
143 dssdev
->dss
->mgr_ops
->disable(dssdev
->dss
->mgr_ops_priv
,
144 dssdev
->dispc_channel
);
146 EXPORT_SYMBOL(dss_mgr_disable
);
148 void dss_mgr_start_update(struct omap_dss_device
*dssdev
)
150 dssdev
->dss
->mgr_ops
->start_update(dssdev
->dss
->mgr_ops_priv
,
151 dssdev
->dispc_channel
);
153 EXPORT_SYMBOL(dss_mgr_start_update
);
155 int dss_mgr_register_framedone_handler(struct omap_dss_device
*dssdev
,
156 void (*handler
)(void *), void *data
)
158 struct dss_device
*dss
= dssdev
->dss
;
160 return dss
->mgr_ops
->register_framedone_handler(dss
->mgr_ops_priv
,
161 dssdev
->dispc_channel
,
164 EXPORT_SYMBOL(dss_mgr_register_framedone_handler
);
166 void dss_mgr_unregister_framedone_handler(struct omap_dss_device
*dssdev
,
167 void (*handler
)(void *), void *data
)
169 struct dss_device
*dss
= dssdev
->dss
;
171 dss
->mgr_ops
->unregister_framedone_handler(dss
->mgr_ops_priv
,
172 dssdev
->dispc_channel
,
175 EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler
);