xref: /openbmc/linux/drivers/gpu/drm/omapdrm/dss/output.c (revision 176f011b)
1 /*
2  * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
3  * Author: Archit Taneja <archit@ti.com>
4  *
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.
8  *
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
12  * more details.
13  *
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/>.
16  */
17 
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21 #include <linux/slab.h>
22 #include <linux/of.h>
23 
24 #include "dss.h"
25 #include "omapdss.h"
26 
27 int omapdss_output_validate(struct omap_dss_device *out)
28 {
29 	if (out->next && out->output_type != out->next->type) {
30 		dev_err(out->dev, "output type and display type don't match\n");
31 		return -EINVAL;
32 	}
33 
34 	return 0;
35 }
36 EXPORT_SYMBOL(omapdss_output_validate);
37 
38 int dss_install_mgr_ops(struct dss_device *dss,
39 			const struct dss_mgr_ops *mgr_ops,
40 			struct omap_drm_private *priv)
41 {
42 	if (dss->mgr_ops)
43 		return -EBUSY;
44 
45 	dss->mgr_ops = mgr_ops;
46 	dss->mgr_ops_priv = priv;
47 
48 	return 0;
49 }
50 EXPORT_SYMBOL(dss_install_mgr_ops);
51 
52 void dss_uninstall_mgr_ops(struct dss_device *dss)
53 {
54 	dss->mgr_ops = NULL;
55 	dss->mgr_ops_priv = NULL;
56 }
57 EXPORT_SYMBOL(dss_uninstall_mgr_ops);
58 
59 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
60 			 const struct videomode *vm)
61 {
62 	dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv,
63 					  dssdev->dispc_channel, vm);
64 }
65 EXPORT_SYMBOL(dss_mgr_set_timings);
66 
67 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
68 		const struct dss_lcd_mgr_config *config)
69 {
70 	dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv,
71 					     dssdev->dispc_channel, config);
72 }
73 EXPORT_SYMBOL(dss_mgr_set_lcd_config);
74 
75 int dss_mgr_enable(struct omap_dss_device *dssdev)
76 {
77 	return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv,
78 					    dssdev->dispc_channel);
79 }
80 EXPORT_SYMBOL(dss_mgr_enable);
81 
82 void dss_mgr_disable(struct omap_dss_device *dssdev)
83 {
84 	dssdev->dss->mgr_ops->disable(dssdev->dss->mgr_ops_priv,
85 				      dssdev->dispc_channel);
86 }
87 EXPORT_SYMBOL(dss_mgr_disable);
88 
89 void dss_mgr_start_update(struct omap_dss_device *dssdev)
90 {
91 	dssdev->dss->mgr_ops->start_update(dssdev->dss->mgr_ops_priv,
92 					   dssdev->dispc_channel);
93 }
94 EXPORT_SYMBOL(dss_mgr_start_update);
95 
96 int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
97 		void (*handler)(void *), void *data)
98 {
99 	struct dss_device *dss = dssdev->dss;
100 
101 	return dss->mgr_ops->register_framedone_handler(dss->mgr_ops_priv,
102 							dssdev->dispc_channel,
103 							handler, data);
104 }
105 EXPORT_SYMBOL(dss_mgr_register_framedone_handler);
106 
107 void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
108 		void (*handler)(void *), void *data)
109 {
110 	struct dss_device *dss = dssdev->dss;
111 
112 	dss->mgr_ops->unregister_framedone_handler(dss->mgr_ops_priv,
113 						   dssdev->dispc_channel,
114 						   handler, data);
115 }
116 EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler);
117