diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2012-11-08 06:13:02 -0500 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2012-11-27 05:47:25 -0500 |
commit | 3f30b8c2b6f20a00a97929fdbe7191e2a5e74064 (patch) | |
tree | da2603edc624d80c4f2dd55c8f7f64659ddae1cd | |
parent | 74e164588ec0b0c570f5525d10800f54342833b1 (diff) |
OMAPDSS: create display-sysfs.c
Move display sysfs related code from display.c to display-sysfs.c, for
clarity. The sysfs code will only be used for compat mode.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r-- | drivers/video/omap2/dss/Makefile | 3 | ||||
-rw-r--r-- | drivers/video/omap2/dss/display-sysfs.c | 321 | ||||
-rw-r--r-- | drivers/video/omap2/dss/display.c | 281 | ||||
-rw-r--r-- | drivers/video/omap2/dss/dss.h | 5 |
4 files changed, 331 insertions, 279 deletions
diff --git a/drivers/video/omap2/dss/Makefile b/drivers/video/omap2/dss/Makefile index 40701910f737..af866d0b7942 100644 --- a/drivers/video/omap2/dss/Makefile +++ b/drivers/video/omap2/dss/Makefile | |||
@@ -1,6 +1,7 @@ | |||
1 | obj-$(CONFIG_OMAP2_DSS) += omapdss.o | 1 | obj-$(CONFIG_OMAP2_DSS) += omapdss.o |
2 | omapdss-y := core.o dss.o dss_features.o dispc.o dispc_coefs.o display.o \ | 2 | omapdss-y := core.o dss.o dss_features.o dispc.o dispc_coefs.o display.o \ |
3 | manager.o manager-sysfs.o overlay.o overlay-sysfs.o output.o apply.o | 3 | manager.o manager-sysfs.o overlay.o overlay-sysfs.o output.o apply.o \ |
4 | display-sysfs.o | ||
4 | omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o | 5 | omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o |
5 | omapdss-$(CONFIG_OMAP2_DSS_RFBI) += rfbi.o | 6 | omapdss-$(CONFIG_OMAP2_DSS_RFBI) += rfbi.o |
6 | omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o venc_panel.o | 7 | omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o venc_panel.o |
diff --git a/drivers/video/omap2/dss/display-sysfs.c b/drivers/video/omap2/dss/display-sysfs.c new file mode 100644 index 000000000000..18211a9ab354 --- /dev/null +++ b/drivers/video/omap2/dss/display-sysfs.c | |||
@@ -0,0 +1,321 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 Nokia Corporation | ||
3 | * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> | ||
4 | * | ||
5 | * Some code and ideas taken from drivers/video/omap/ driver | ||
6 | * by Imre Deak. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License version 2 as published by | ||
10 | * the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
15 | * more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License along with | ||
18 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #define DSS_SUBSYS_NAME "DISPLAY" | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/jiffies.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | |||
28 | #include <video/omapdss.h> | ||
29 | #include "dss.h" | ||
30 | #include "dss_features.h" | ||
31 | |||
32 | static ssize_t display_enabled_show(struct device *dev, | ||
33 | struct device_attribute *attr, char *buf) | ||
34 | { | ||
35 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
36 | bool enabled = dssdev->state != OMAP_DSS_DISPLAY_DISABLED; | ||
37 | |||
38 | return snprintf(buf, PAGE_SIZE, "%d\n", enabled); | ||
39 | } | ||
40 | |||
41 | static ssize_t display_enabled_store(struct device *dev, | ||
42 | struct device_attribute *attr, | ||
43 | const char *buf, size_t size) | ||
44 | { | ||
45 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
46 | int r; | ||
47 | bool enabled; | ||
48 | |||
49 | r = strtobool(buf, &enabled); | ||
50 | if (r) | ||
51 | return r; | ||
52 | |||
53 | if (enabled != (dssdev->state != OMAP_DSS_DISPLAY_DISABLED)) { | ||
54 | if (enabled) { | ||
55 | r = dssdev->driver->enable(dssdev); | ||
56 | if (r) | ||
57 | return r; | ||
58 | } else { | ||
59 | dssdev->driver->disable(dssdev); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | return size; | ||
64 | } | ||
65 | |||
66 | static ssize_t display_tear_show(struct device *dev, | ||
67 | struct device_attribute *attr, char *buf) | ||
68 | { | ||
69 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
70 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
71 | dssdev->driver->get_te ? | ||
72 | dssdev->driver->get_te(dssdev) : 0); | ||
73 | } | ||
74 | |||
75 | static ssize_t display_tear_store(struct device *dev, | ||
76 | struct device_attribute *attr, const char *buf, size_t size) | ||
77 | { | ||
78 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
79 | int r; | ||
80 | bool te; | ||
81 | |||
82 | if (!dssdev->driver->enable_te || !dssdev->driver->get_te) | ||
83 | return -ENOENT; | ||
84 | |||
85 | r = strtobool(buf, &te); | ||
86 | if (r) | ||
87 | return r; | ||
88 | |||
89 | r = dssdev->driver->enable_te(dssdev, te); | ||
90 | if (r) | ||
91 | return r; | ||
92 | |||
93 | return size; | ||
94 | } | ||
95 | |||
96 | static ssize_t display_timings_show(struct device *dev, | ||
97 | struct device_attribute *attr, char *buf) | ||
98 | { | ||
99 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
100 | struct omap_video_timings t; | ||
101 | |||
102 | if (!dssdev->driver->get_timings) | ||
103 | return -ENOENT; | ||
104 | |||
105 | dssdev->driver->get_timings(dssdev, &t); | ||
106 | |||
107 | return snprintf(buf, PAGE_SIZE, "%u,%u/%u/%u/%u,%u/%u/%u/%u\n", | ||
108 | t.pixel_clock, | ||
109 | t.x_res, t.hfp, t.hbp, t.hsw, | ||
110 | t.y_res, t.vfp, t.vbp, t.vsw); | ||
111 | } | ||
112 | |||
113 | static ssize_t display_timings_store(struct device *dev, | ||
114 | struct device_attribute *attr, const char *buf, size_t size) | ||
115 | { | ||
116 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
117 | struct omap_video_timings t = dssdev->panel.timings; | ||
118 | int r, found; | ||
119 | |||
120 | if (!dssdev->driver->set_timings || !dssdev->driver->check_timings) | ||
121 | return -ENOENT; | ||
122 | |||
123 | found = 0; | ||
124 | #ifdef CONFIG_OMAP2_DSS_VENC | ||
125 | if (strncmp("pal", buf, 3) == 0) { | ||
126 | t = omap_dss_pal_timings; | ||
127 | found = 1; | ||
128 | } else if (strncmp("ntsc", buf, 4) == 0) { | ||
129 | t = omap_dss_ntsc_timings; | ||
130 | found = 1; | ||
131 | } | ||
132 | #endif | ||
133 | if (!found && sscanf(buf, "%u,%hu/%hu/%hu/%hu,%hu/%hu/%hu/%hu", | ||
134 | &t.pixel_clock, | ||
135 | &t.x_res, &t.hfp, &t.hbp, &t.hsw, | ||
136 | &t.y_res, &t.vfp, &t.vbp, &t.vsw) != 9) | ||
137 | return -EINVAL; | ||
138 | |||
139 | r = dssdev->driver->check_timings(dssdev, &t); | ||
140 | if (r) | ||
141 | return r; | ||
142 | |||
143 | dssdev->driver->disable(dssdev); | ||
144 | dssdev->driver->set_timings(dssdev, &t); | ||
145 | r = dssdev->driver->enable(dssdev); | ||
146 | if (r) | ||
147 | return r; | ||
148 | |||
149 | return size; | ||
150 | } | ||
151 | |||
152 | static ssize_t display_rotate_show(struct device *dev, | ||
153 | struct device_attribute *attr, char *buf) | ||
154 | { | ||
155 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
156 | int rotate; | ||
157 | if (!dssdev->driver->get_rotate) | ||
158 | return -ENOENT; | ||
159 | rotate = dssdev->driver->get_rotate(dssdev); | ||
160 | return snprintf(buf, PAGE_SIZE, "%u\n", rotate); | ||
161 | } | ||
162 | |||
163 | static ssize_t display_rotate_store(struct device *dev, | ||
164 | struct device_attribute *attr, const char *buf, size_t size) | ||
165 | { | ||
166 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
167 | int rot, r; | ||
168 | |||
169 | if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate) | ||
170 | return -ENOENT; | ||
171 | |||
172 | r = kstrtoint(buf, 0, &rot); | ||
173 | if (r) | ||
174 | return r; | ||
175 | |||
176 | r = dssdev->driver->set_rotate(dssdev, rot); | ||
177 | if (r) | ||
178 | return r; | ||
179 | |||
180 | return size; | ||
181 | } | ||
182 | |||
183 | static ssize_t display_mirror_show(struct device *dev, | ||
184 | struct device_attribute *attr, char *buf) | ||
185 | { | ||
186 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
187 | int mirror; | ||
188 | if (!dssdev->driver->get_mirror) | ||
189 | return -ENOENT; | ||
190 | mirror = dssdev->driver->get_mirror(dssdev); | ||
191 | return snprintf(buf, PAGE_SIZE, "%u\n", mirror); | ||
192 | } | ||
193 | |||
194 | static ssize_t display_mirror_store(struct device *dev, | ||
195 | struct device_attribute *attr, const char *buf, size_t size) | ||
196 | { | ||
197 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
198 | int r; | ||
199 | bool mirror; | ||
200 | |||
201 | if (!dssdev->driver->set_mirror || !dssdev->driver->get_mirror) | ||
202 | return -ENOENT; | ||
203 | |||
204 | r = strtobool(buf, &mirror); | ||
205 | if (r) | ||
206 | return r; | ||
207 | |||
208 | r = dssdev->driver->set_mirror(dssdev, mirror); | ||
209 | if (r) | ||
210 | return r; | ||
211 | |||
212 | return size; | ||
213 | } | ||
214 | |||
215 | static ssize_t display_wss_show(struct device *dev, | ||
216 | struct device_attribute *attr, char *buf) | ||
217 | { | ||
218 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
219 | unsigned int wss; | ||
220 | |||
221 | if (!dssdev->driver->get_wss) | ||
222 | return -ENOENT; | ||
223 | |||
224 | wss = dssdev->driver->get_wss(dssdev); | ||
225 | |||
226 | return snprintf(buf, PAGE_SIZE, "0x%05x\n", wss); | ||
227 | } | ||
228 | |||
229 | static ssize_t display_wss_store(struct device *dev, | ||
230 | struct device_attribute *attr, const char *buf, size_t size) | ||
231 | { | ||
232 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
233 | u32 wss; | ||
234 | int r; | ||
235 | |||
236 | if (!dssdev->driver->get_wss || !dssdev->driver->set_wss) | ||
237 | return -ENOENT; | ||
238 | |||
239 | r = kstrtou32(buf, 0, &wss); | ||
240 | if (r) | ||
241 | return r; | ||
242 | |||
243 | if (wss > 0xfffff) | ||
244 | return -EINVAL; | ||
245 | |||
246 | r = dssdev->driver->set_wss(dssdev, wss); | ||
247 | if (r) | ||
248 | return r; | ||
249 | |||
250 | return size; | ||
251 | } | ||
252 | |||
253 | static DEVICE_ATTR(enabled, S_IRUGO|S_IWUSR, | ||
254 | display_enabled_show, display_enabled_store); | ||
255 | static DEVICE_ATTR(tear_elim, S_IRUGO|S_IWUSR, | ||
256 | display_tear_show, display_tear_store); | ||
257 | static DEVICE_ATTR(timings, S_IRUGO|S_IWUSR, | ||
258 | display_timings_show, display_timings_store); | ||
259 | static DEVICE_ATTR(rotate, S_IRUGO|S_IWUSR, | ||
260 | display_rotate_show, display_rotate_store); | ||
261 | static DEVICE_ATTR(mirror, S_IRUGO|S_IWUSR, | ||
262 | display_mirror_show, display_mirror_store); | ||
263 | static DEVICE_ATTR(wss, S_IRUGO|S_IWUSR, | ||
264 | display_wss_show, display_wss_store); | ||
265 | |||
266 | static struct device_attribute *display_sysfs_attrs[] = { | ||
267 | &dev_attr_enabled, | ||
268 | &dev_attr_tear_elim, | ||
269 | &dev_attr_timings, | ||
270 | &dev_attr_rotate, | ||
271 | &dev_attr_mirror, | ||
272 | &dev_attr_wss, | ||
273 | NULL | ||
274 | }; | ||
275 | |||
276 | int display_init_sysfs(struct platform_device *pdev, | ||
277 | struct omap_dss_device *dssdev) | ||
278 | { | ||
279 | struct device_attribute *attr; | ||
280 | int i, r; | ||
281 | |||
282 | /* create device sysfs files */ | ||
283 | i = 0; | ||
284 | while ((attr = display_sysfs_attrs[i++]) != NULL) { | ||
285 | r = device_create_file(&dssdev->dev, attr); | ||
286 | if (r) { | ||
287 | for (i = i - 2; i >= 0; i--) { | ||
288 | attr = display_sysfs_attrs[i]; | ||
289 | device_remove_file(&dssdev->dev, attr); | ||
290 | } | ||
291 | |||
292 | DSSERR("failed to create sysfs file\n"); | ||
293 | return r; | ||
294 | } | ||
295 | } | ||
296 | |||
297 | /* create display? sysfs links */ | ||
298 | r = sysfs_create_link(&pdev->dev.kobj, &dssdev->dev.kobj, | ||
299 | dev_name(&dssdev->dev)); | ||
300 | if (r) { | ||
301 | while ((attr = display_sysfs_attrs[i++]) != NULL) | ||
302 | device_remove_file(&dssdev->dev, attr); | ||
303 | |||
304 | DSSERR("failed to create sysfs display link\n"); | ||
305 | return r; | ||
306 | } | ||
307 | |||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | void display_uninit_sysfs(struct platform_device *pdev, | ||
312 | struct omap_dss_device *dssdev) | ||
313 | { | ||
314 | struct device_attribute *attr; | ||
315 | int i = 0; | ||
316 | |||
317 | sysfs_remove_link(&pdev->dev.kobj, dev_name(&dssdev->dev)); | ||
318 | |||
319 | while ((attr = display_sysfs_attrs[i++]) != NULL) | ||
320 | device_remove_file(&dssdev->dev, attr); | ||
321 | } | ||
diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c index 6d33112c599c..008e9eecaf72 100644 --- a/drivers/video/omap2/dss/display.c +++ b/drivers/video/omap2/dss/display.c | |||
@@ -31,250 +31,6 @@ | |||
31 | #include "dss.h" | 31 | #include "dss.h" |
32 | #include "dss_features.h" | 32 | #include "dss_features.h" |
33 | 33 | ||
34 | static ssize_t display_enabled_show(struct device *dev, | ||
35 | struct device_attribute *attr, char *buf) | ||
36 | { | ||
37 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
38 | bool enabled = dssdev->state != OMAP_DSS_DISPLAY_DISABLED; | ||
39 | |||
40 | return snprintf(buf, PAGE_SIZE, "%d\n", enabled); | ||
41 | } | ||
42 | |||
43 | static ssize_t display_enabled_store(struct device *dev, | ||
44 | struct device_attribute *attr, | ||
45 | const char *buf, size_t size) | ||
46 | { | ||
47 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
48 | int r; | ||
49 | bool enabled; | ||
50 | |||
51 | r = strtobool(buf, &enabled); | ||
52 | if (r) | ||
53 | return r; | ||
54 | |||
55 | if (enabled != (dssdev->state != OMAP_DSS_DISPLAY_DISABLED)) { | ||
56 | if (enabled) { | ||
57 | r = dssdev->driver->enable(dssdev); | ||
58 | if (r) | ||
59 | return r; | ||
60 | } else { | ||
61 | dssdev->driver->disable(dssdev); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | return size; | ||
66 | } | ||
67 | |||
68 | static ssize_t display_tear_show(struct device *dev, | ||
69 | struct device_attribute *attr, char *buf) | ||
70 | { | ||
71 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
72 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
73 | dssdev->driver->get_te ? | ||
74 | dssdev->driver->get_te(dssdev) : 0); | ||
75 | } | ||
76 | |||
77 | static ssize_t display_tear_store(struct device *dev, | ||
78 | struct device_attribute *attr, const char *buf, size_t size) | ||
79 | { | ||
80 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
81 | int r; | ||
82 | bool te; | ||
83 | |||
84 | if (!dssdev->driver->enable_te || !dssdev->driver->get_te) | ||
85 | return -ENOENT; | ||
86 | |||
87 | r = strtobool(buf, &te); | ||
88 | if (r) | ||
89 | return r; | ||
90 | |||
91 | r = dssdev->driver->enable_te(dssdev, te); | ||
92 | if (r) | ||
93 | return r; | ||
94 | |||
95 | return size; | ||
96 | } | ||
97 | |||
98 | static ssize_t display_timings_show(struct device *dev, | ||
99 | struct device_attribute *attr, char *buf) | ||
100 | { | ||
101 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
102 | struct omap_video_timings t; | ||
103 | |||
104 | if (!dssdev->driver->get_timings) | ||
105 | return -ENOENT; | ||
106 | |||
107 | dssdev->driver->get_timings(dssdev, &t); | ||
108 | |||
109 | return snprintf(buf, PAGE_SIZE, "%u,%u/%u/%u/%u,%u/%u/%u/%u\n", | ||
110 | t.pixel_clock, | ||
111 | t.x_res, t.hfp, t.hbp, t.hsw, | ||
112 | t.y_res, t.vfp, t.vbp, t.vsw); | ||
113 | } | ||
114 | |||
115 | static ssize_t display_timings_store(struct device *dev, | ||
116 | struct device_attribute *attr, const char *buf, size_t size) | ||
117 | { | ||
118 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
119 | struct omap_video_timings t = dssdev->panel.timings; | ||
120 | int r, found; | ||
121 | |||
122 | if (!dssdev->driver->set_timings || !dssdev->driver->check_timings) | ||
123 | return -ENOENT; | ||
124 | |||
125 | found = 0; | ||
126 | #ifdef CONFIG_OMAP2_DSS_VENC | ||
127 | if (strncmp("pal", buf, 3) == 0) { | ||
128 | t = omap_dss_pal_timings; | ||
129 | found = 1; | ||
130 | } else if (strncmp("ntsc", buf, 4) == 0) { | ||
131 | t = omap_dss_ntsc_timings; | ||
132 | found = 1; | ||
133 | } | ||
134 | #endif | ||
135 | if (!found && sscanf(buf, "%u,%hu/%hu/%hu/%hu,%hu/%hu/%hu/%hu", | ||
136 | &t.pixel_clock, | ||
137 | &t.x_res, &t.hfp, &t.hbp, &t.hsw, | ||
138 | &t.y_res, &t.vfp, &t.vbp, &t.vsw) != 9) | ||
139 | return -EINVAL; | ||
140 | |||
141 | r = dssdev->driver->check_timings(dssdev, &t); | ||
142 | if (r) | ||
143 | return r; | ||
144 | |||
145 | dssdev->driver->disable(dssdev); | ||
146 | dssdev->driver->set_timings(dssdev, &t); | ||
147 | r = dssdev->driver->enable(dssdev); | ||
148 | if (r) | ||
149 | return r; | ||
150 | |||
151 | return size; | ||
152 | } | ||
153 | |||
154 | static ssize_t display_rotate_show(struct device *dev, | ||
155 | struct device_attribute *attr, char *buf) | ||
156 | { | ||
157 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
158 | int rotate; | ||
159 | if (!dssdev->driver->get_rotate) | ||
160 | return -ENOENT; | ||
161 | rotate = dssdev->driver->get_rotate(dssdev); | ||
162 | return snprintf(buf, PAGE_SIZE, "%u\n", rotate); | ||
163 | } | ||
164 | |||
165 | static ssize_t display_rotate_store(struct device *dev, | ||
166 | struct device_attribute *attr, const char *buf, size_t size) | ||
167 | { | ||
168 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
169 | int rot, r; | ||
170 | |||
171 | if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate) | ||
172 | return -ENOENT; | ||
173 | |||
174 | r = kstrtoint(buf, 0, &rot); | ||
175 | if (r) | ||
176 | return r; | ||
177 | |||
178 | r = dssdev->driver->set_rotate(dssdev, rot); | ||
179 | if (r) | ||
180 | return r; | ||
181 | |||
182 | return size; | ||
183 | } | ||
184 | |||
185 | static ssize_t display_mirror_show(struct device *dev, | ||
186 | struct device_attribute *attr, char *buf) | ||
187 | { | ||
188 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
189 | int mirror; | ||
190 | if (!dssdev->driver->get_mirror) | ||
191 | return -ENOENT; | ||
192 | mirror = dssdev->driver->get_mirror(dssdev); | ||
193 | return snprintf(buf, PAGE_SIZE, "%u\n", mirror); | ||
194 | } | ||
195 | |||
196 | static ssize_t display_mirror_store(struct device *dev, | ||
197 | struct device_attribute *attr, const char *buf, size_t size) | ||
198 | { | ||
199 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
200 | int r; | ||
201 | bool mirror; | ||
202 | |||
203 | if (!dssdev->driver->set_mirror || !dssdev->driver->get_mirror) | ||
204 | return -ENOENT; | ||
205 | |||
206 | r = strtobool(buf, &mirror); | ||
207 | if (r) | ||
208 | return r; | ||
209 | |||
210 | r = dssdev->driver->set_mirror(dssdev, mirror); | ||
211 | if (r) | ||
212 | return r; | ||
213 | |||
214 | return size; | ||
215 | } | ||
216 | |||
217 | static ssize_t display_wss_show(struct device *dev, | ||
218 | struct device_attribute *attr, char *buf) | ||
219 | { | ||
220 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
221 | unsigned int wss; | ||
222 | |||
223 | if (!dssdev->driver->get_wss) | ||
224 | return -ENOENT; | ||
225 | |||
226 | wss = dssdev->driver->get_wss(dssdev); | ||
227 | |||
228 | return snprintf(buf, PAGE_SIZE, "0x%05x\n", wss); | ||
229 | } | ||
230 | |||
231 | static ssize_t display_wss_store(struct device *dev, | ||
232 | struct device_attribute *attr, const char *buf, size_t size) | ||
233 | { | ||
234 | struct omap_dss_device *dssdev = to_dss_device(dev); | ||
235 | u32 wss; | ||
236 | int r; | ||
237 | |||
238 | if (!dssdev->driver->get_wss || !dssdev->driver->set_wss) | ||
239 | return -ENOENT; | ||
240 | |||
241 | r = kstrtou32(buf, 0, &wss); | ||
242 | if (r) | ||
243 | return r; | ||
244 | |||
245 | if (wss > 0xfffff) | ||
246 | return -EINVAL; | ||
247 | |||
248 | r = dssdev->driver->set_wss(dssdev, wss); | ||
249 | if (r) | ||
250 | return r; | ||
251 | |||
252 | return size; | ||
253 | } | ||
254 | |||
255 | static DEVICE_ATTR(enabled, S_IRUGO|S_IWUSR, | ||
256 | display_enabled_show, display_enabled_store); | ||
257 | static DEVICE_ATTR(tear_elim, S_IRUGO|S_IWUSR, | ||
258 | display_tear_show, display_tear_store); | ||
259 | static DEVICE_ATTR(timings, S_IRUGO|S_IWUSR, | ||
260 | display_timings_show, display_timings_store); | ||
261 | static DEVICE_ATTR(rotate, S_IRUGO|S_IWUSR, | ||
262 | display_rotate_show, display_rotate_store); | ||
263 | static DEVICE_ATTR(mirror, S_IRUGO|S_IWUSR, | ||
264 | display_mirror_show, display_mirror_store); | ||
265 | static DEVICE_ATTR(wss, S_IRUGO|S_IWUSR, | ||
266 | display_wss_show, display_wss_store); | ||
267 | |||
268 | static struct device_attribute *display_sysfs_attrs[] = { | ||
269 | &dev_attr_enabled, | ||
270 | &dev_attr_tear_elim, | ||
271 | &dev_attr_timings, | ||
272 | &dev_attr_rotate, | ||
273 | &dev_attr_mirror, | ||
274 | &dev_attr_wss, | ||
275 | NULL | ||
276 | }; | ||
277 | |||
278 | void omapdss_default_get_resolution(struct omap_dss_device *dssdev, | 34 | void omapdss_default_get_resolution(struct omap_dss_device *dssdev, |
279 | u16 *xres, u16 *yres) | 35 | u16 *xres, u16 *yres) |
280 | { | 36 | { |
@@ -323,9 +79,8 @@ EXPORT_SYMBOL(omapdss_default_get_timings); | |||
323 | int dss_init_device(struct platform_device *pdev, | 79 | int dss_init_device(struct platform_device *pdev, |
324 | struct omap_dss_device *dssdev) | 80 | struct omap_dss_device *dssdev) |
325 | { | 81 | { |
326 | struct device_attribute *attr; | ||
327 | struct omap_dss_output *out; | 82 | struct omap_dss_output *out; |
328 | int i, r; | 83 | int r; |
329 | 84 | ||
330 | out = omapdss_get_output_from_dssdev(dssdev); | 85 | out = omapdss_get_output_from_dssdev(dssdev); |
331 | 86 | ||
@@ -335,33 +90,9 @@ int dss_init_device(struct platform_device *pdev, | |||
335 | return r; | 90 | return r; |
336 | } | 91 | } |
337 | 92 | ||
338 | /* create device sysfs files */ | 93 | r = display_init_sysfs(pdev, dssdev); |
339 | i = 0; | ||
340 | while ((attr = display_sysfs_attrs[i++]) != NULL) { | ||
341 | r = device_create_file(&dssdev->dev, attr); | ||
342 | if (r) { | ||
343 | for (i = i - 2; i >= 0; i--) { | ||
344 | attr = display_sysfs_attrs[i]; | ||
345 | device_remove_file(&dssdev->dev, attr); | ||
346 | } | ||
347 | |||
348 | omapdss_output_unset_device(dssdev->output); | ||
349 | |||
350 | DSSERR("failed to create sysfs file\n"); | ||
351 | return r; | ||
352 | } | ||
353 | } | ||
354 | |||
355 | /* create display? sysfs links */ | ||
356 | r = sysfs_create_link(&pdev->dev.kobj, &dssdev->dev.kobj, | ||
357 | dev_name(&dssdev->dev)); | ||
358 | if (r) { | 94 | if (r) { |
359 | while ((attr = display_sysfs_attrs[i++]) != NULL) | ||
360 | device_remove_file(&dssdev->dev, attr); | ||
361 | |||
362 | omapdss_output_unset_device(dssdev->output); | 95 | omapdss_output_unset_device(dssdev->output); |
363 | |||
364 | DSSERR("failed to create sysfs display link\n"); | ||
365 | return r; | 96 | return r; |
366 | } | 97 | } |
367 | 98 | ||
@@ -371,13 +102,7 @@ int dss_init_device(struct platform_device *pdev, | |||
371 | void dss_uninit_device(struct platform_device *pdev, | 102 | void dss_uninit_device(struct platform_device *pdev, |
372 | struct omap_dss_device *dssdev) | 103 | struct omap_dss_device *dssdev) |
373 | { | 104 | { |
374 | struct device_attribute *attr; | 105 | display_uninit_sysfs(pdev, dssdev); |
375 | int i = 0; | ||
376 | |||
377 | sysfs_remove_link(&pdev->dev.kobj, dev_name(&dssdev->dev)); | ||
378 | |||
379 | while ((attr = display_sysfs_attrs[i++]) != NULL) | ||
380 | device_remove_file(&dssdev->dev, attr); | ||
381 | 106 | ||
382 | if (dssdev->output) | 107 | if (dssdev->output) |
383 | omapdss_output_unset_device(dssdev->output); | 108 | omapdss_output_unset_device(dssdev->output); |
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h index 09d0651469a3..6c3cfb3352df 100644 --- a/drivers/video/omap2/dss/dss.h +++ b/drivers/video/omap2/dss/dss.h | |||
@@ -224,6 +224,11 @@ int dss_init_device(struct platform_device *pdev, | |||
224 | void dss_uninit_device(struct platform_device *pdev, | 224 | void dss_uninit_device(struct platform_device *pdev, |
225 | struct omap_dss_device *dssdev); | 225 | struct omap_dss_device *dssdev); |
226 | 226 | ||
227 | int display_init_sysfs(struct platform_device *pdev, | ||
228 | struct omap_dss_device *dssdev); | ||
229 | void display_uninit_sysfs(struct platform_device *pdev, | ||
230 | struct omap_dss_device *dssdev); | ||
231 | |||
227 | /* manager */ | 232 | /* manager */ |
228 | int dss_init_overlay_managers(struct platform_device *pdev); | 233 | int dss_init_overlay_managers(struct platform_device *pdev); |
229 | void dss_uninit_overlay_managers(struct platform_device *pdev); | 234 | void dss_uninit_overlay_managers(struct platform_device *pdev); |