blob: 7d96b724c99260fc128e1260868d38e60bbf471a [file] [log] [blame]
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001/*
2 * linux/drivers/video/omap2/dss/display.c
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6 *
7 * Some code and ideas taken from drivers/video/omap/ driver
8 * by Imre Deak.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#define DSS_SUBSYS_NAME "DISPLAY"
24
25#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/jiffies.h>
Tomi Valkeineneed07e02009-08-07 13:43:20 +030028#include <linux/platform_device.h>
29
30#include <plat/display.h>
31#include "dss.h"
32
Tomi Valkeineneed07e02009-08-07 13:43:20 +030033static ssize_t display_enabled_show(struct device *dev,
34 struct device_attribute *attr, char *buf)
35{
36 struct omap_dss_device *dssdev = to_dss_device(dev);
37 bool enabled = dssdev->state != OMAP_DSS_DISPLAY_DISABLED;
38
39 return snprintf(buf, PAGE_SIZE, "%d\n", enabled);
40}
41
42static ssize_t display_enabled_store(struct device *dev,
43 struct device_attribute *attr,
44 const char *buf, size_t size)
45{
46 struct omap_dss_device *dssdev = to_dss_device(dev);
47 bool enabled, r;
48
49 enabled = simple_strtoul(buf, NULL, 10);
50
51 if (enabled != (dssdev->state != OMAP_DSS_DISPLAY_DISABLED)) {
52 if (enabled) {
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020053 r = dssdev->driver->enable(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +030054 if (r)
55 return r;
56 } else {
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020057 dssdev->driver->disable(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +030058 }
59 }
60
61 return size;
62}
63
64static ssize_t display_upd_mode_show(struct device *dev,
65 struct device_attribute *attr, char *buf)
66{
67 struct omap_dss_device *dssdev = to_dss_device(dev);
68 enum omap_dss_update_mode mode = OMAP_DSS_UPDATE_AUTO;
Tomi Valkeinen446f7bf2010-01-11 16:12:31 +020069 if (dssdev->driver->get_update_mode)
70 mode = dssdev->driver->get_update_mode(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +030071 return snprintf(buf, PAGE_SIZE, "%d\n", mode);
72}
73
74static ssize_t display_upd_mode_store(struct device *dev,
75 struct device_attribute *attr,
76 const char *buf, size_t size)
77{
78 struct omap_dss_device *dssdev = to_dss_device(dev);
79 int val, r;
80 enum omap_dss_update_mode mode;
81
Ville Syrjälä825f50b2010-03-02 21:30:52 +020082 if (!dssdev->driver->set_update_mode)
83 return -EINVAL;
84
Tomi Valkeineneed07e02009-08-07 13:43:20 +030085 val = simple_strtoul(buf, NULL, 10);
86
87 switch (val) {
88 case OMAP_DSS_UPDATE_DISABLED:
89 case OMAP_DSS_UPDATE_AUTO:
90 case OMAP_DSS_UPDATE_MANUAL:
91 mode = (enum omap_dss_update_mode)val;
92 break;
93 default:
94 return -EINVAL;
95 }
96
Tomi Valkeinen446f7bf2010-01-11 16:12:31 +020097 r = dssdev->driver->set_update_mode(dssdev, mode);
Tomi Valkeineneed07e02009-08-07 13:43:20 +030098 if (r)
99 return r;
100
101 return size;
102}
103
104static ssize_t display_tear_show(struct device *dev,
105 struct device_attribute *attr, char *buf)
106{
107 struct omap_dss_device *dssdev = to_dss_device(dev);
108 return snprintf(buf, PAGE_SIZE, "%d\n",
Tomi Valkeinen225b6502010-01-11 15:11:01 +0200109 dssdev->driver->get_te ?
110 dssdev->driver->get_te(dssdev) : 0);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300111}
112
113static ssize_t display_tear_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 unsigned long te;
118 int r;
119
Tomi Valkeinen225b6502010-01-11 15:11:01 +0200120 if (!dssdev->driver->enable_te || !dssdev->driver->get_te)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300121 return -ENOENT;
122
123 te = simple_strtoul(buf, NULL, 0);
124
Tomi Valkeinen225b6502010-01-11 15:11:01 +0200125 r = dssdev->driver->enable_te(dssdev, te);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300126 if (r)
127 return r;
128
129 return size;
130}
131
132static ssize_t display_timings_show(struct device *dev,
133 struct device_attribute *attr, char *buf)
134{
135 struct omap_dss_device *dssdev = to_dss_device(dev);
136 struct omap_video_timings t;
137
Tomi Valkeinen69b20482010-01-20 12:11:25 +0200138 if (!dssdev->driver->get_timings)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300139 return -ENOENT;
140
Tomi Valkeinen69b20482010-01-20 12:11:25 +0200141 dssdev->driver->get_timings(dssdev, &t);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300142
143 return snprintf(buf, PAGE_SIZE, "%u,%u/%u/%u/%u,%u/%u/%u/%u\n",
144 t.pixel_clock,
145 t.x_res, t.hfp, t.hbp, t.hsw,
146 t.y_res, t.vfp, t.vbp, t.vsw);
147}
148
149static ssize_t display_timings_store(struct device *dev,
150 struct device_attribute *attr, const char *buf, size_t size)
151{
152 struct omap_dss_device *dssdev = to_dss_device(dev);
153 struct omap_video_timings t;
154 int r, found;
155
Tomi Valkeinen69b20482010-01-20 12:11:25 +0200156 if (!dssdev->driver->set_timings || !dssdev->driver->check_timings)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300157 return -ENOENT;
158
159 found = 0;
160#ifdef CONFIG_OMAP2_DSS_VENC
161 if (strncmp("pal", buf, 3) == 0) {
162 t = omap_dss_pal_timings;
163 found = 1;
164 } else if (strncmp("ntsc", buf, 4) == 0) {
165 t = omap_dss_ntsc_timings;
166 found = 1;
167 }
168#endif
169 if (!found && sscanf(buf, "%u,%hu/%hu/%hu/%hu,%hu/%hu/%hu/%hu",
170 &t.pixel_clock,
171 &t.x_res, &t.hfp, &t.hbp, &t.hsw,
172 &t.y_res, &t.vfp, &t.vbp, &t.vsw) != 9)
173 return -EINVAL;
174
Tomi Valkeinen69b20482010-01-20 12:11:25 +0200175 r = dssdev->driver->check_timings(dssdev, &t);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300176 if (r)
177 return r;
178
Tomi Valkeinen69b20482010-01-20 12:11:25 +0200179 dssdev->driver->set_timings(dssdev, &t);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300180
181 return size;
182}
183
184static ssize_t display_rotate_show(struct device *dev,
185 struct device_attribute *attr, char *buf)
186{
187 struct omap_dss_device *dssdev = to_dss_device(dev);
188 int rotate;
Tomi Valkeinen87424e12010-01-08 16:52:48 +0200189 if (!dssdev->driver->get_rotate)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300190 return -ENOENT;
Tomi Valkeinen87424e12010-01-08 16:52:48 +0200191 rotate = dssdev->driver->get_rotate(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300192 return snprintf(buf, PAGE_SIZE, "%u\n", rotate);
193}
194
195static ssize_t display_rotate_store(struct device *dev,
196 struct device_attribute *attr, const char *buf, size_t size)
197{
198 struct omap_dss_device *dssdev = to_dss_device(dev);
199 unsigned long rot;
200 int r;
201
Tomi Valkeinen87424e12010-01-08 16:52:48 +0200202 if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300203 return -ENOENT;
204
205 rot = simple_strtoul(buf, NULL, 0);
206
Tomi Valkeinen87424e12010-01-08 16:52:48 +0200207 r = dssdev->driver->set_rotate(dssdev, rot);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300208 if (r)
209 return r;
210
211 return size;
212}
213
214static ssize_t display_mirror_show(struct device *dev,
215 struct device_attribute *attr, char *buf)
216{
217 struct omap_dss_device *dssdev = to_dss_device(dev);
218 int mirror;
Tomi Valkeinen8d8aa612010-01-08 16:30:33 +0200219 if (!dssdev->driver->get_mirror)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300220 return -ENOENT;
Tomi Valkeinen8d8aa612010-01-08 16:30:33 +0200221 mirror = dssdev->driver->get_mirror(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300222 return snprintf(buf, PAGE_SIZE, "%u\n", mirror);
223}
224
225static ssize_t display_mirror_store(struct device *dev,
226 struct device_attribute *attr, const char *buf, size_t size)
227{
228 struct omap_dss_device *dssdev = to_dss_device(dev);
229 unsigned long mirror;
230 int r;
231
Tomi Valkeinen8d8aa612010-01-08 16:30:33 +0200232 if (!dssdev->driver->set_mirror || !dssdev->driver->get_mirror)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300233 return -ENOENT;
234
235 mirror = simple_strtoul(buf, NULL, 0);
236
Tomi Valkeinen8d8aa612010-01-08 16:30:33 +0200237 r = dssdev->driver->set_mirror(dssdev, mirror);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300238 if (r)
239 return r;
240
241 return size;
242}
243
244static ssize_t display_wss_show(struct device *dev,
245 struct device_attribute *attr, char *buf)
246{
247 struct omap_dss_device *dssdev = to_dss_device(dev);
248 unsigned int wss;
249
Tomi Valkeinen36511312010-01-19 15:53:16 +0200250 if (!dssdev->driver->get_wss)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300251 return -ENOENT;
252
Tomi Valkeinen36511312010-01-19 15:53:16 +0200253 wss = dssdev->driver->get_wss(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300254
255 return snprintf(buf, PAGE_SIZE, "0x%05x\n", wss);
256}
257
258static ssize_t display_wss_store(struct device *dev,
259 struct device_attribute *attr, const char *buf, size_t size)
260{
261 struct omap_dss_device *dssdev = to_dss_device(dev);
262 unsigned long wss;
263 int r;
264
Tomi Valkeinen36511312010-01-19 15:53:16 +0200265 if (!dssdev->driver->get_wss || !dssdev->driver->set_wss)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300266 return -ENOENT;
267
268 if (strict_strtoul(buf, 0, &wss))
269 return -EINVAL;
270
271 if (wss > 0xfffff)
272 return -EINVAL;
273
Tomi Valkeinen36511312010-01-19 15:53:16 +0200274 r = dssdev->driver->set_wss(dssdev, wss);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300275 if (r)
276 return r;
277
278 return size;
279}
280
281static DEVICE_ATTR(enabled, S_IRUGO|S_IWUSR,
282 display_enabled_show, display_enabled_store);
283static DEVICE_ATTR(update_mode, S_IRUGO|S_IWUSR,
284 display_upd_mode_show, display_upd_mode_store);
285static DEVICE_ATTR(tear_elim, S_IRUGO|S_IWUSR,
286 display_tear_show, display_tear_store);
287static DEVICE_ATTR(timings, S_IRUGO|S_IWUSR,
288 display_timings_show, display_timings_store);
289static DEVICE_ATTR(rotate, S_IRUGO|S_IWUSR,
290 display_rotate_show, display_rotate_store);
291static DEVICE_ATTR(mirror, S_IRUGO|S_IWUSR,
292 display_mirror_show, display_mirror_store);
293static DEVICE_ATTR(wss, S_IRUGO|S_IWUSR,
294 display_wss_show, display_wss_store);
295
296static struct device_attribute *display_sysfs_attrs[] = {
297 &dev_attr_enabled,
298 &dev_attr_update_mode,
299 &dev_attr_tear_elim,
300 &dev_attr_timings,
301 &dev_attr_rotate,
302 &dev_attr_mirror,
303 &dev_attr_wss,
304 NULL
305};
306
Tomi Valkeinen96adcec2010-01-11 13:54:33 +0200307void omapdss_default_get_resolution(struct omap_dss_device *dssdev,
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300308 u16 *xres, u16 *yres)
309{
310 *xres = dssdev->panel.timings.x_res;
311 *yres = dssdev->panel.timings.y_res;
312}
Tomi Valkeinen96adcec2010-01-11 13:54:33 +0200313EXPORT_SYMBOL(omapdss_default_get_resolution);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300314
315void default_get_overlay_fifo_thresholds(enum omap_plane plane,
316 u32 fifo_size, enum omap_burst_size *burst_size,
317 u32 *fifo_low, u32 *fifo_high)
318{
319 unsigned burst_size_bytes;
320
321 *burst_size = OMAP_DSS_BURST_16x32;
322 burst_size_bytes = 16 * 32 / 8;
323
324 *fifo_high = fifo_size - 1;
325 *fifo_low = fifo_size - burst_size_bytes;
326}
327
Tomi Valkeinena2699502010-01-11 14:33:40 +0200328int omapdss_default_get_recommended_bpp(struct omap_dss_device *dssdev)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300329{
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300330 switch (dssdev->type) {
331 case OMAP_DISPLAY_TYPE_DPI:
332 if (dssdev->phy.dpi.data_lines == 24)
333 return 24;
334 else
335 return 16;
336
337 case OMAP_DISPLAY_TYPE_DBI:
338 case OMAP_DISPLAY_TYPE_DSI:
339 if (dssdev->ctrl.pixel_size == 24)
340 return 24;
341 else
342 return 16;
343 case OMAP_DISPLAY_TYPE_VENC:
344 case OMAP_DISPLAY_TYPE_SDI:
345 return 24;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300346 default:
347 BUG();
348 }
349}
Tomi Valkeinena2699502010-01-11 14:33:40 +0200350EXPORT_SYMBOL(omapdss_default_get_recommended_bpp);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300351
352/* Checks if replication logic should be used. Only use for active matrix,
353 * when overlay is in RGB12U or RGB16 mode, and LCD interface is
354 * 18bpp or 24bpp */
355bool dss_use_replication(struct omap_dss_device *dssdev,
356 enum omap_color_mode mode)
357{
358 int bpp;
359
360 if (mode != OMAP_DSS_COLOR_RGB12U && mode != OMAP_DSS_COLOR_RGB16)
361 return false;
362
363 if (dssdev->type == OMAP_DISPLAY_TYPE_DPI &&
364 (dssdev->panel.config & OMAP_DSS_LCD_TFT) == 0)
365 return false;
366
367 switch (dssdev->type) {
368 case OMAP_DISPLAY_TYPE_DPI:
369 bpp = dssdev->phy.dpi.data_lines;
370 break;
371 case OMAP_DISPLAY_TYPE_VENC:
372 case OMAP_DISPLAY_TYPE_SDI:
373 bpp = 24;
374 break;
375 case OMAP_DISPLAY_TYPE_DBI:
376 case OMAP_DISPLAY_TYPE_DSI:
377 bpp = dssdev->ctrl.pixel_size;
378 break;
379 default:
380 BUG();
381 }
382
383 return bpp > 16;
384}
385
386void dss_init_device(struct platform_device *pdev,
387 struct omap_dss_device *dssdev)
388{
389 struct device_attribute *attr;
390 int i;
391 int r;
392
393 switch (dssdev->type) {
Roger Quadrosb4d78bf2010-03-17 13:35:19 +0100394#ifdef CONFIG_OMAP2_DSS_DPI
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300395 case OMAP_DISPLAY_TYPE_DPI:
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300396 r = dpi_init_display(dssdev);
397 break;
Roger Quadrosb4d78bf2010-03-17 13:35:19 +0100398#endif
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300399#ifdef CONFIG_OMAP2_DSS_RFBI
400 case OMAP_DISPLAY_TYPE_DBI:
401 r = rfbi_init_display(dssdev);
402 break;
403#endif
404#ifdef CONFIG_OMAP2_DSS_VENC
405 case OMAP_DISPLAY_TYPE_VENC:
406 r = venc_init_display(dssdev);
407 break;
408#endif
409#ifdef CONFIG_OMAP2_DSS_SDI
410 case OMAP_DISPLAY_TYPE_SDI:
411 r = sdi_init_display(dssdev);
412 break;
413#endif
414#ifdef CONFIG_OMAP2_DSS_DSI
415 case OMAP_DISPLAY_TYPE_DSI:
416 r = dsi_init_display(dssdev);
417 break;
418#endif
419 default:
Tomi Valkeinene528e3a2011-02-24 13:59:13 +0200420 DSSERR("Support for display '%s' not compiled in.\n",
421 dssdev->name);
422 return;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300423 }
424
425 if (r) {
426 DSSERR("failed to init display %s\n", dssdev->name);
427 return;
428 }
429
430 /* create device sysfs files */
431 i = 0;
432 while ((attr = display_sysfs_attrs[i++]) != NULL) {
433 r = device_create_file(&dssdev->dev, attr);
434 if (r)
435 DSSERR("failed to create sysfs file\n");
436 }
437
438 /* create display? sysfs links */
439 r = sysfs_create_link(&pdev->dev.kobj, &dssdev->dev.kobj,
440 dev_name(&dssdev->dev));
441 if (r)
442 DSSERR("failed to create sysfs display link\n");
443}
444
445void dss_uninit_device(struct platform_device *pdev,
446 struct omap_dss_device *dssdev)
447{
448 struct device_attribute *attr;
449 int i = 0;
450
451 sysfs_remove_link(&pdev->dev.kobj, dev_name(&dssdev->dev));
452
453 while ((attr = display_sysfs_attrs[i++]) != NULL)
454 device_remove_file(&dssdev->dev, attr);
455
456 if (dssdev->manager)
457 dssdev->manager->unset_device(dssdev->manager);
458}
459
460static int dss_suspend_device(struct device *dev, void *data)
461{
462 int r;
463 struct omap_dss_device *dssdev = to_dss_device(dev);
464
465 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) {
466 dssdev->activate_after_resume = false;
467 return 0;
468 }
469
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200470 if (!dssdev->driver->suspend) {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300471 DSSERR("display '%s' doesn't implement suspend\n",
472 dssdev->name);
473 return -ENOSYS;
474 }
475
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200476 r = dssdev->driver->suspend(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300477 if (r)
478 return r;
479
480 dssdev->activate_after_resume = true;
481
482 return 0;
483}
484
485int dss_suspend_all_devices(void)
486{
487 int r;
488 struct bus_type *bus = dss_get_bus();
489
490 r = bus_for_each_dev(bus, NULL, NULL, dss_suspend_device);
491 if (r) {
492 /* resume all displays that were suspended */
493 dss_resume_all_devices();
494 return r;
495 }
496
497 return 0;
498}
499
500static int dss_resume_device(struct device *dev, void *data)
501{
502 int r;
503 struct omap_dss_device *dssdev = to_dss_device(dev);
504
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200505 if (dssdev->activate_after_resume && dssdev->driver->resume) {
506 r = dssdev->driver->resume(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300507 if (r)
508 return r;
509 }
510
511 dssdev->activate_after_resume = false;
512
513 return 0;
514}
515
516int dss_resume_all_devices(void)
517{
518 struct bus_type *bus = dss_get_bus();
519
520 return bus_for_each_dev(bus, NULL, NULL, dss_resume_device);
521}
522
523static int dss_disable_device(struct device *dev, void *data)
524{
525 struct omap_dss_device *dssdev = to_dss_device(dev);
Jani Nikula279fcd42010-03-24 11:59:38 +0100526
527 if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED)
528 dssdev->driver->disable(dssdev);
529
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300530 return 0;
531}
532
533void dss_disable_all_devices(void)
534{
535 struct bus_type *bus = dss_get_bus();
536 bus_for_each_dev(bus, NULL, NULL, dss_disable_device);
537}
538
539
540void omap_dss_get_device(struct omap_dss_device *dssdev)
541{
542 get_device(&dssdev->dev);
543}
544EXPORT_SYMBOL(omap_dss_get_device);
545
546void omap_dss_put_device(struct omap_dss_device *dssdev)
547{
548 put_device(&dssdev->dev);
549}
550EXPORT_SYMBOL(omap_dss_put_device);
551
552/* ref count of the found device is incremented. ref count
553 * of from-device is decremented. */
554struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
555{
556 struct device *dev;
557 struct device *dev_start = NULL;
558 struct omap_dss_device *dssdev = NULL;
559
560 int match(struct device *dev, void *data)
561 {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300562 return 1;
563 }
564
565 if (from)
566 dev_start = &from->dev;
567 dev = bus_find_device(dss_get_bus(), dev_start, NULL, match);
568 if (dev)
569 dssdev = to_dss_device(dev);
570 if (from)
571 put_device(&from->dev);
572
573 return dssdev;
574}
575EXPORT_SYMBOL(omap_dss_get_next_device);
576
577struct omap_dss_device *omap_dss_find_device(void *data,
578 int (*match)(struct omap_dss_device *dssdev, void *data))
579{
580 struct omap_dss_device *dssdev = NULL;
581
582 while ((dssdev = omap_dss_get_next_device(dssdev)) != NULL) {
583 if (match(dssdev, data))
584 return dssdev;
585 }
586
587 return NULL;
588}
589EXPORT_SYMBOL(omap_dss_find_device);
590
591int omap_dss_start_device(struct omap_dss_device *dssdev)
592{
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300593 if (!dssdev->driver) {
594 DSSDBG("no driver\n");
Tomi Valkeinene020f9a2010-02-17 13:36:48 +0200595 return -ENODEV;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300596 }
597
598 if (!try_module_get(dssdev->dev.driver->owner)) {
Tomi Valkeinene020f9a2010-02-17 13:36:48 +0200599 return -ENODEV;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300600 }
601
602 return 0;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300603}
604EXPORT_SYMBOL(omap_dss_start_device);
605
606void omap_dss_stop_device(struct omap_dss_device *dssdev)
607{
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300608 module_put(dssdev->dev.driver->owner);
609}
610EXPORT_SYMBOL(omap_dss_stop_device);
611