2 * Copyright (C) 2012 Texas Instruments Ltd
3 * Author: Archit Taneja <archit@ti.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21 #include <linux/slab.h>
24 #include <video/omapfb_dss.h>
28 static LIST_HEAD(output_list
);
29 static DEFINE_MUTEX(output_lock
);
31 int omapdss_output_set_device(struct omap_dss_device
*out
,
32 struct omap_dss_device
*dssdev
)
36 mutex_lock(&output_lock
);
39 DSSERR("output already has device %s connected to it\n",
45 if (out
->output_type
!= dssdev
->type
) {
46 DSSERR("output type and display type don't match\n");
54 mutex_unlock(&output_lock
);
58 mutex_unlock(&output_lock
);
62 EXPORT_SYMBOL(omapdss_output_set_device
);
64 int omapdss_output_unset_device(struct omap_dss_device
*out
)
68 mutex_lock(&output_lock
);
71 DSSERR("output doesn't have a device connected to it\n");
76 if (out
->dst
->state
!= OMAP_DSS_DISPLAY_DISABLED
) {
77 DSSERR("device %s is not disabled, cannot unset device\n",
86 mutex_unlock(&output_lock
);
90 mutex_unlock(&output_lock
);
94 EXPORT_SYMBOL(omapdss_output_unset_device
);
96 int omapdss_register_output(struct omap_dss_device
*out
)
98 list_add_tail(&out
->list
, &output_list
);
101 EXPORT_SYMBOL(omapdss_register_output
);
103 void omapdss_unregister_output(struct omap_dss_device
*out
)
105 list_del(&out
->list
);
107 EXPORT_SYMBOL(omapdss_unregister_output
);
109 struct omap_dss_device
*omap_dss_get_output(enum omap_dss_output_id id
)
111 struct omap_dss_device
*out
;
113 list_for_each_entry(out
, &output_list
, list
) {
120 EXPORT_SYMBOL(omap_dss_get_output
);
122 struct omap_dss_device
*omap_dss_find_output(const char *name
)
124 struct omap_dss_device
*out
;
126 list_for_each_entry(out
, &output_list
, list
) {
127 if (strcmp(out
->name
, name
) == 0)
128 return omap_dss_get_device(out
);
133 EXPORT_SYMBOL(omap_dss_find_output
);
135 struct omap_dss_device
*omap_dss_find_output_by_port_node(struct device_node
*port
)
137 struct device_node
*src_node
;
138 struct omap_dss_device
*out
;
141 src_node
= dss_of_port_get_parent_device(port
);
145 reg
= dss_of_port_get_port_number(port
);
147 list_for_each_entry(out
, &output_list
, list
) {
148 if (out
->dev
->of_node
== src_node
&& out
->port_num
== reg
) {
149 of_node_put(src_node
);
150 return omap_dss_get_device(out
);
154 of_node_put(src_node
);
158 EXPORT_SYMBOL(omap_dss_find_output_by_port_node
);
160 struct omap_dss_device
*omapdss_find_output_from_display(struct omap_dss_device
*dssdev
)
163 dssdev
= dssdev
->src
;
166 return omap_dss_get_device(dssdev
);
170 EXPORT_SYMBOL(omapdss_find_output_from_display
);
172 struct omap_overlay_manager
*omapdss_find_mgr_from_display(struct omap_dss_device
*dssdev
)
174 struct omap_dss_device
*out
;
175 struct omap_overlay_manager
*mgr
;
177 out
= omapdss_find_output_from_display(dssdev
);
184 omap_dss_put_device(out
);
188 EXPORT_SYMBOL(omapdss_find_mgr_from_display
);
190 static const struct dss_mgr_ops
*dss_mgr_ops
;
192 int dss_install_mgr_ops(const struct dss_mgr_ops
*mgr_ops
)
197 dss_mgr_ops
= mgr_ops
;
201 EXPORT_SYMBOL(dss_install_mgr_ops
);
203 void dss_uninstall_mgr_ops(void)
207 EXPORT_SYMBOL(dss_uninstall_mgr_ops
);
209 int dss_mgr_connect(struct omap_overlay_manager
*mgr
,
210 struct omap_dss_device
*dst
)
212 return dss_mgr_ops
->connect(mgr
, dst
);
214 EXPORT_SYMBOL(dss_mgr_connect
);
216 void dss_mgr_disconnect(struct omap_overlay_manager
*mgr
,
217 struct omap_dss_device
*dst
)
219 dss_mgr_ops
->disconnect(mgr
, dst
);
221 EXPORT_SYMBOL(dss_mgr_disconnect
);
223 void dss_mgr_set_timings(struct omap_overlay_manager
*mgr
,
224 const struct omap_video_timings
*timings
)
226 dss_mgr_ops
->set_timings(mgr
, timings
);
228 EXPORT_SYMBOL(dss_mgr_set_timings
);
230 void dss_mgr_set_lcd_config(struct omap_overlay_manager
*mgr
,
231 const struct dss_lcd_mgr_config
*config
)
233 dss_mgr_ops
->set_lcd_config(mgr
, config
);
235 EXPORT_SYMBOL(dss_mgr_set_lcd_config
);
237 int dss_mgr_enable(struct omap_overlay_manager
*mgr
)
239 return dss_mgr_ops
->enable(mgr
);
241 EXPORT_SYMBOL(dss_mgr_enable
);
243 void dss_mgr_disable(struct omap_overlay_manager
*mgr
)
245 dss_mgr_ops
->disable(mgr
);
247 EXPORT_SYMBOL(dss_mgr_disable
);
249 void dss_mgr_start_update(struct omap_overlay_manager
*mgr
)
251 dss_mgr_ops
->start_update(mgr
);
253 EXPORT_SYMBOL(dss_mgr_start_update
);
255 int dss_mgr_register_framedone_handler(struct omap_overlay_manager
*mgr
,
256 void (*handler
)(void *), void *data
)
258 return dss_mgr_ops
->register_framedone_handler(mgr
, handler
, data
);
260 EXPORT_SYMBOL(dss_mgr_register_framedone_handler
);
262 void dss_mgr_unregister_framedone_handler(struct omap_overlay_manager
*mgr
,
263 void (*handler
)(void *), void *data
)
265 dss_mgr_ops
->unregister_framedone_handler(mgr
, handler
, data
);
267 EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler
);