1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2012 Texas Instruments Ltd
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>
13 #include <video/omapfb_dss.h>
17 static LIST_HEAD(output_list
);
18 static DEFINE_MUTEX(output_lock
);
20 int omapdss_output_set_device(struct omap_dss_device
*out
,
21 struct omap_dss_device
*dssdev
)
25 mutex_lock(&output_lock
);
28 DSSERR("output already has device %s connected to it\n",
34 if (out
->output_type
!= dssdev
->type
) {
35 DSSERR("output type and display type don't match\n");
43 mutex_unlock(&output_lock
);
47 mutex_unlock(&output_lock
);
51 EXPORT_SYMBOL(omapdss_output_set_device
);
53 int omapdss_output_unset_device(struct omap_dss_device
*out
)
57 mutex_lock(&output_lock
);
60 DSSERR("output doesn't have a device connected to it\n");
65 if (out
->dst
->state
!= OMAP_DSS_DISPLAY_DISABLED
) {
66 DSSERR("device %s is not disabled, cannot unset device\n",
75 mutex_unlock(&output_lock
);
79 mutex_unlock(&output_lock
);
83 EXPORT_SYMBOL(omapdss_output_unset_device
);
85 int omapdss_register_output(struct omap_dss_device
*out
)
87 list_add_tail(&out
->list
, &output_list
);
90 EXPORT_SYMBOL(omapdss_register_output
);
92 void omapdss_unregister_output(struct omap_dss_device
*out
)
96 EXPORT_SYMBOL(omapdss_unregister_output
);
98 struct omap_dss_device
*omap_dss_get_output(enum omap_dss_output_id id
)
100 struct omap_dss_device
*out
;
102 list_for_each_entry(out
, &output_list
, list
) {
109 EXPORT_SYMBOL(omap_dss_get_output
);
111 struct omap_dss_device
*omap_dss_find_output(const char *name
)
113 struct omap_dss_device
*out
;
115 list_for_each_entry(out
, &output_list
, list
) {
116 if (strcmp(out
->name
, name
) == 0)
117 return omap_dss_get_device(out
);
122 EXPORT_SYMBOL(omap_dss_find_output
);
124 struct omap_dss_device
*omap_dss_find_output_by_port_node(struct device_node
*port
)
126 struct device_node
*src_node
;
127 struct omap_dss_device
*out
;
130 src_node
= dss_of_port_get_parent_device(port
);
134 reg
= dss_of_port_get_port_number(port
);
136 list_for_each_entry(out
, &output_list
, list
) {
137 if (out
->dev
->of_node
== src_node
&& out
->port_num
== reg
) {
138 of_node_put(src_node
);
139 return omap_dss_get_device(out
);
143 of_node_put(src_node
);
147 EXPORT_SYMBOL(omap_dss_find_output_by_port_node
);
149 struct omap_dss_device
*omapdss_find_output_from_display(struct omap_dss_device
*dssdev
)
152 dssdev
= dssdev
->src
;
155 return omap_dss_get_device(dssdev
);
159 EXPORT_SYMBOL(omapdss_find_output_from_display
);
161 struct omap_overlay_manager
*omapdss_find_mgr_from_display(struct omap_dss_device
*dssdev
)
163 struct omap_dss_device
*out
;
164 struct omap_overlay_manager
*mgr
;
166 out
= omapdss_find_output_from_display(dssdev
);
173 omap_dss_put_device(out
);
177 EXPORT_SYMBOL(omapdss_find_mgr_from_display
);
179 static const struct dss_mgr_ops
*dss_mgr_ops
;
181 int dss_install_mgr_ops(const struct dss_mgr_ops
*mgr_ops
)
186 dss_mgr_ops
= mgr_ops
;
190 EXPORT_SYMBOL(dss_install_mgr_ops
);
192 void dss_uninstall_mgr_ops(void)
196 EXPORT_SYMBOL(dss_uninstall_mgr_ops
);
198 int dss_mgr_connect(struct omap_overlay_manager
*mgr
,
199 struct omap_dss_device
*dst
)
201 return dss_mgr_ops
->connect(mgr
, dst
);
203 EXPORT_SYMBOL(dss_mgr_connect
);
205 void dss_mgr_disconnect(struct omap_overlay_manager
*mgr
,
206 struct omap_dss_device
*dst
)
208 dss_mgr_ops
->disconnect(mgr
, dst
);
210 EXPORT_SYMBOL(dss_mgr_disconnect
);
212 void dss_mgr_set_timings(struct omap_overlay_manager
*mgr
,
213 const struct omap_video_timings
*timings
)
215 dss_mgr_ops
->set_timings(mgr
, timings
);
217 EXPORT_SYMBOL(dss_mgr_set_timings
);
219 void dss_mgr_set_lcd_config(struct omap_overlay_manager
*mgr
,
220 const struct dss_lcd_mgr_config
*config
)
222 dss_mgr_ops
->set_lcd_config(mgr
, config
);
224 EXPORT_SYMBOL(dss_mgr_set_lcd_config
);
226 int dss_mgr_enable(struct omap_overlay_manager
*mgr
)
228 return dss_mgr_ops
->enable(mgr
);
230 EXPORT_SYMBOL(dss_mgr_enable
);
232 void dss_mgr_disable(struct omap_overlay_manager
*mgr
)
234 dss_mgr_ops
->disable(mgr
);
236 EXPORT_SYMBOL(dss_mgr_disable
);
238 void dss_mgr_start_update(struct omap_overlay_manager
*mgr
)
240 dss_mgr_ops
->start_update(mgr
);
242 EXPORT_SYMBOL(dss_mgr_start_update
);
244 int dss_mgr_register_framedone_handler(struct omap_overlay_manager
*mgr
,
245 void (*handler
)(void *), void *data
)
247 return dss_mgr_ops
->register_framedone_handler(mgr
, handler
, data
);
249 EXPORT_SYMBOL(dss_mgr_register_framedone_handler
);
251 void dss_mgr_unregister_framedone_handler(struct omap_overlay_manager
*mgr
,
252 void (*handler
)(void *), void *data
)
254 dss_mgr_ops
->unregister_framedone_handler(mgr
, handler
, data
);
256 EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler
);