]>
Commit | Line | Data |
---|---|---|
484dc404 AT |
1 | /* |
2 | * Copyright (C) 2012 Texas Instruments Ltd | |
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> | |
6d71b923 | 19 | #include <linux/module.h> |
484dc404 AT |
20 | #include <linux/platform_device.h> |
21 | #include <linux/slab.h> | |
ef691ff4 | 22 | #include <linux/of.h> |
484dc404 | 23 | |
32043da7 | 24 | #include "omapdss.h" |
484dc404 AT |
25 | #include "dss.h" |
26 | ||
27 | static LIST_HEAD(output_list); | |
6d71b923 AT |
28 | static DEFINE_MUTEX(output_lock); |
29 | ||
1f68d9c4 | 30 | int omapdss_output_set_device(struct omap_dss_device *out, |
6d71b923 AT |
31 | struct omap_dss_device *dssdev) |
32 | { | |
33 | int r; | |
34 | ||
35 | mutex_lock(&output_lock); | |
36 | ||
9560dc10 | 37 | if (out->dst) { |
6d71b923 | 38 | DSSERR("output already has device %s connected to it\n", |
9560dc10 | 39 | out->dst->name); |
6d71b923 AT |
40 | r = -EINVAL; |
41 | goto err; | |
42 | } | |
43 | ||
1f68d9c4 | 44 | if (out->output_type != dssdev->type) { |
6d71b923 AT |
45 | DSSERR("output type and display type don't match\n"); |
46 | r = -EINVAL; | |
47 | goto err; | |
48 | } | |
49 | ||
9560dc10 | 50 | out->dst = dssdev; |
a73fdc64 | 51 | dssdev->src = out; |
6d71b923 AT |
52 | |
53 | mutex_unlock(&output_lock); | |
54 | ||
55 | return 0; | |
56 | err: | |
57 | mutex_unlock(&output_lock); | |
58 | ||
59 | return r; | |
60 | } | |
61 | EXPORT_SYMBOL(omapdss_output_set_device); | |
62 | ||
1f68d9c4 | 63 | int omapdss_output_unset_device(struct omap_dss_device *out) |
6d71b923 AT |
64 | { |
65 | int r; | |
66 | ||
67 | mutex_lock(&output_lock); | |
68 | ||
9560dc10 | 69 | if (!out->dst) { |
6d71b923 AT |
70 | DSSERR("output doesn't have a device connected to it\n"); |
71 | r = -EINVAL; | |
72 | goto err; | |
73 | } | |
74 | ||
9560dc10 | 75 | if (out->dst->state != OMAP_DSS_DISPLAY_DISABLED) { |
6d71b923 | 76 | DSSERR("device %s is not disabled, cannot unset device\n", |
9560dc10 | 77 | out->dst->name); |
6d71b923 AT |
78 | r = -EINVAL; |
79 | goto err; | |
80 | } | |
81 | ||
9560dc10 TV |
82 | out->dst->src = NULL; |
83 | out->dst = NULL; | |
6d71b923 AT |
84 | |
85 | mutex_unlock(&output_lock); | |
86 | ||
87 | return 0; | |
88 | err: | |
89 | mutex_unlock(&output_lock); | |
90 | ||
91 | return r; | |
92 | } | |
93 | EXPORT_SYMBOL(omapdss_output_unset_device); | |
484dc404 | 94 | |
5d47dbc8 | 95 | int omapdss_register_output(struct omap_dss_device *out) |
484dc404 AT |
96 | { |
97 | list_add_tail(&out->list, &output_list); | |
5d47dbc8 | 98 | return 0; |
484dc404 | 99 | } |
5d47dbc8 | 100 | EXPORT_SYMBOL(omapdss_register_output); |
484dc404 | 101 | |
5d47dbc8 | 102 | void omapdss_unregister_output(struct omap_dss_device *out) |
484dc404 AT |
103 | { |
104 | list_del(&out->list); | |
105 | } | |
5d47dbc8 | 106 | EXPORT_SYMBOL(omapdss_unregister_output); |
484dc404 | 107 | |
1f68d9c4 | 108 | struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id) |
484dc404 | 109 | { |
1f68d9c4 | 110 | struct omap_dss_device *out; |
484dc404 AT |
111 | |
112 | list_for_each_entry(out, &output_list, list) { | |
113 | if (out->id == id) | |
114 | return out; | |
115 | } | |
116 | ||
117 | return NULL; | |
118 | } | |
27831620 | 119 | EXPORT_SYMBOL(omap_dss_get_output); |
74b65ec2 | 120 | |
1f68d9c4 | 121 | struct omap_dss_device *omap_dss_find_output(const char *name) |
805cc2d1 | 122 | { |
1f68d9c4 | 123 | struct omap_dss_device *out; |
805cc2d1 TV |
124 | |
125 | list_for_each_entry(out, &output_list, list) { | |
126 | if (strcmp(out->name, name) == 0) | |
820caabf | 127 | return omap_dss_get_device(out); |
805cc2d1 TV |
128 | } |
129 | ||
130 | return NULL; | |
131 | } | |
132 | EXPORT_SYMBOL(omap_dss_find_output); | |
133 | ||
ef691ff4 | 134 | struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *port) |
12ca755b | 135 | { |
ef691ff4 | 136 | struct device_node *src_node; |
1f68d9c4 | 137 | struct omap_dss_device *out; |
ef691ff4 AT |
138 | u32 reg; |
139 | ||
140 | src_node = dss_of_port_get_parent_device(port); | |
141 | if (!src_node) | |
142 | return NULL; | |
143 | ||
144 | reg = dss_of_port_get_port_number(port); | |
12ca755b TV |
145 | |
146 | list_for_each_entry(out, &output_list, list) { | |
ef691ff4 AT |
147 | if (out->dev->of_node == src_node && out->port_num == reg) { |
148 | of_node_put(src_node); | |
820caabf | 149 | return omap_dss_get_device(out); |
ef691ff4 | 150 | } |
12ca755b TV |
151 | } |
152 | ||
ef691ff4 AT |
153 | of_node_put(src_node); |
154 | ||
12ca755b TV |
155 | return NULL; |
156 | } | |
ef691ff4 | 157 | EXPORT_SYMBOL(omap_dss_find_output_by_port_node); |
12ca755b | 158 | |
1f68d9c4 | 159 | struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev) |
be8e8e1c | 160 | { |
a73fdc64 TV |
161 | while (dssdev->src) |
162 | dssdev = dssdev->src; | |
efedce14 TV |
163 | |
164 | if (dssdev->id != 0) | |
165 | return omap_dss_get_device(dssdev); | |
166 | ||
167 | return NULL; | |
be8e8e1c TV |
168 | } |
169 | EXPORT_SYMBOL(omapdss_find_output_from_display); | |
170 | ||
74b65ec2 TV |
171 | static const struct dss_mgr_ops *dss_mgr_ops; |
172 | ||
173 | int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops) | |
174 | { | |
175 | if (dss_mgr_ops) | |
176 | return -EBUSY; | |
177 | ||
178 | dss_mgr_ops = mgr_ops; | |
179 | ||
180 | return 0; | |
181 | } | |
a97a9634 | 182 | EXPORT_SYMBOL(dss_install_mgr_ops); |
74b65ec2 TV |
183 | |
184 | void dss_uninstall_mgr_ops(void) | |
185 | { | |
186 | dss_mgr_ops = NULL; | |
187 | } | |
a97a9634 | 188 | EXPORT_SYMBOL(dss_uninstall_mgr_ops); |
74b65ec2 | 189 | |
1b07b066 | 190 | int dss_mgr_connect(enum omap_channel channel, |
1f68d9c4 | 191 | struct omap_dss_device *dst) |
a7e71e7f | 192 | { |
1b07b066 | 193 | return dss_mgr_ops->connect(channel, dst); |
a7e71e7f TV |
194 | } |
195 | EXPORT_SYMBOL(dss_mgr_connect); | |
196 | ||
bdac3bb9 | 197 | void dss_mgr_disconnect(enum omap_channel channel, |
1f68d9c4 | 198 | struct omap_dss_device *dst) |
a7e71e7f | 199 | { |
bdac3bb9 | 200 | dss_mgr_ops->disconnect(channel, dst); |
a7e71e7f TV |
201 | } |
202 | EXPORT_SYMBOL(dss_mgr_disconnect); | |
203 | ||
5c6ff3cd | 204 | void dss_mgr_set_timings(enum omap_channel channel, |
4520ff28 | 205 | const struct videomode *timings) |
74b65ec2 | 206 | { |
5c6ff3cd | 207 | dss_mgr_ops->set_timings(channel, timings); |
74b65ec2 | 208 | } |
a97a9634 | 209 | EXPORT_SYMBOL(dss_mgr_set_timings); |
74b65ec2 | 210 | |
bb772e1a | 211 | void dss_mgr_set_lcd_config(enum omap_channel channel, |
74b65ec2 TV |
212 | const struct dss_lcd_mgr_config *config) |
213 | { | |
bb772e1a | 214 | dss_mgr_ops->set_lcd_config(channel, config); |
74b65ec2 | 215 | } |
a97a9634 | 216 | EXPORT_SYMBOL(dss_mgr_set_lcd_config); |
74b65ec2 | 217 | |
85a8c622 | 218 | int dss_mgr_enable(enum omap_channel channel) |
74b65ec2 | 219 | { |
85a8c622 | 220 | return dss_mgr_ops->enable(channel); |
74b65ec2 | 221 | } |
a97a9634 | 222 | EXPORT_SYMBOL(dss_mgr_enable); |
74b65ec2 | 223 | |
705fd454 | 224 | void dss_mgr_disable(enum omap_channel channel) |
74b65ec2 | 225 | { |
705fd454 | 226 | dss_mgr_ops->disable(channel); |
74b65ec2 | 227 | } |
a97a9634 | 228 | EXPORT_SYMBOL(dss_mgr_disable); |
74b65ec2 | 229 | |
1f03f934 | 230 | void dss_mgr_start_update(enum omap_channel channel) |
74b65ec2 | 231 | { |
1f03f934 | 232 | dss_mgr_ops->start_update(channel); |
74b65ec2 | 233 | } |
a97a9634 | 234 | EXPORT_SYMBOL(dss_mgr_start_update); |
1550202d | 235 | |
af235e31 | 236 | int dss_mgr_register_framedone_handler(enum omap_channel channel, |
1550202d TV |
237 | void (*handler)(void *), void *data) |
238 | { | |
af235e31 | 239 | return dss_mgr_ops->register_framedone_handler(channel, handler, data); |
1550202d | 240 | } |
a97a9634 | 241 | EXPORT_SYMBOL(dss_mgr_register_framedone_handler); |
1550202d | 242 | |
34218998 | 243 | void dss_mgr_unregister_framedone_handler(enum omap_channel channel, |
1550202d TV |
244 | void (*handler)(void *), void *data) |
245 | { | |
34218998 | 246 | dss_mgr_ops->unregister_framedone_handler(channel, handler, data); |
1550202d | 247 | } |
a97a9634 | 248 | EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler); |