blob: 0377d46acadb34a1f1ad2f41a1543d1941d116b4 [file] [log] [blame]
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001/*
2 * linux/drivers/video/omap2/dss/overlay.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 "OVERLAY"
24
25#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/err.h>
28#include <linux/sysfs.h>
29#include <linux/kobject.h>
30#include <linux/platform_device.h>
31#include <linux/delay.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090032#include <linux/slab.h>
Tomi Valkeineneed07e02009-08-07 13:43:20 +030033
Tomi Valkeinena0b38cc2011-05-11 14:05:07 +030034#include <video/omapdss.h>
Tomi Valkeineneed07e02009-08-07 13:43:20 +030035#include <plat/cpu.h>
36
37#include "dss.h"
Archit Tanejaa0acb552010-09-15 19:20:00 +053038#include "dss_features.h"
Tomi Valkeineneed07e02009-08-07 13:43:20 +030039
40static int num_overlays;
41static struct list_head overlay_list;
42
43static ssize_t overlay_name_show(struct omap_overlay *ovl, char *buf)
44{
45 return snprintf(buf, PAGE_SIZE, "%s\n", ovl->name);
46}
47
48static ssize_t overlay_manager_show(struct omap_overlay *ovl, char *buf)
49{
50 return snprintf(buf, PAGE_SIZE, "%s\n",
51 ovl->manager ? ovl->manager->name : "<none>");
52}
53
54static ssize_t overlay_manager_store(struct omap_overlay *ovl, const char *buf,
55 size_t size)
56{
57 int i, r;
58 struct omap_overlay_manager *mgr = NULL;
59 struct omap_overlay_manager *old_mgr;
60 int len = size;
61
62 if (buf[size-1] == '\n')
63 --len;
64
65 if (len > 0) {
66 for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
67 mgr = omap_dss_get_overlay_manager(i);
68
Archit Tanejaf3c77d62010-08-02 15:14:11 +020069 if (sysfs_streq(buf, mgr->name))
Tomi Valkeineneed07e02009-08-07 13:43:20 +030070 break;
71
72 mgr = NULL;
73 }
74 }
75
76 if (len > 0 && mgr == NULL)
77 return -EINVAL;
78
79 if (mgr)
80 DSSDBG("manager %s found\n", mgr->name);
81
82 if (mgr == ovl->manager)
83 return size;
84
85 old_mgr = ovl->manager;
86
87 /* detach old manager */
88 if (old_mgr) {
89 r = ovl->unset_manager(ovl);
90 if (r) {
91 DSSERR("detach failed\n");
92 return r;
93 }
94
95 r = old_mgr->apply(old_mgr);
96 if (r)
97 return r;
98 }
99
100 if (mgr) {
101 r = ovl->set_manager(ovl, mgr);
102 if (r) {
103 DSSERR("Failed to attach overlay\n");
104 return r;
105 }
106
107 r = mgr->apply(mgr);
108 if (r)
109 return r;
110 }
111
112 return size;
113}
114
115static ssize_t overlay_input_size_show(struct omap_overlay *ovl, char *buf)
116{
117 return snprintf(buf, PAGE_SIZE, "%d,%d\n",
118 ovl->info.width, ovl->info.height);
119}
120
121static ssize_t overlay_screen_width_show(struct omap_overlay *ovl, char *buf)
122{
123 return snprintf(buf, PAGE_SIZE, "%d\n", ovl->info.screen_width);
124}
125
126static ssize_t overlay_position_show(struct omap_overlay *ovl, char *buf)
127{
128 return snprintf(buf, PAGE_SIZE, "%d,%d\n",
129 ovl->info.pos_x, ovl->info.pos_y);
130}
131
132static ssize_t overlay_position_store(struct omap_overlay *ovl,
133 const char *buf, size_t size)
134{
135 int r;
136 char *last;
137 struct omap_overlay_info info;
138
139 ovl->get_overlay_info(ovl, &info);
140
141 info.pos_x = simple_strtoul(buf, &last, 10);
142 ++last;
143 if (last - buf >= size)
144 return -EINVAL;
145
146 info.pos_y = simple_strtoul(last, &last, 10);
147
148 r = ovl->set_overlay_info(ovl, &info);
149 if (r)
150 return r;
151
152 if (ovl->manager) {
153 r = ovl->manager->apply(ovl->manager);
154 if (r)
155 return r;
156 }
157
158 return size;
159}
160
161static ssize_t overlay_output_size_show(struct omap_overlay *ovl, char *buf)
162{
163 return snprintf(buf, PAGE_SIZE, "%d,%d\n",
164 ovl->info.out_width, ovl->info.out_height);
165}
166
167static ssize_t overlay_output_size_store(struct omap_overlay *ovl,
168 const char *buf, size_t size)
169{
170 int r;
171 char *last;
172 struct omap_overlay_info info;
173
174 ovl->get_overlay_info(ovl, &info);
175
176 info.out_width = simple_strtoul(buf, &last, 10);
177 ++last;
178 if (last - buf >= size)
179 return -EINVAL;
180
181 info.out_height = simple_strtoul(last, &last, 10);
182
183 r = ovl->set_overlay_info(ovl, &info);
184 if (r)
185 return r;
186
187 if (ovl->manager) {
188 r = ovl->manager->apply(ovl->manager);
189 if (r)
190 return r;
191 }
192
193 return size;
194}
195
196static ssize_t overlay_enabled_show(struct omap_overlay *ovl, char *buf)
197{
198 return snprintf(buf, PAGE_SIZE, "%d\n", ovl->info.enabled);
199}
200
201static ssize_t overlay_enabled_store(struct omap_overlay *ovl, const char *buf,
202 size_t size)
203{
204 int r;
205 struct omap_overlay_info info;
206
207 ovl->get_overlay_info(ovl, &info);
208
209 info.enabled = simple_strtoul(buf, NULL, 10);
210
211 r = ovl->set_overlay_info(ovl, &info);
212 if (r)
213 return r;
214
215 if (ovl->manager) {
216 r = ovl->manager->apply(ovl->manager);
217 if (r)
218 return r;
219 }
220
221 return size;
222}
223
224static ssize_t overlay_global_alpha_show(struct omap_overlay *ovl, char *buf)
225{
226 return snprintf(buf, PAGE_SIZE, "%d\n",
227 ovl->info.global_alpha);
228}
229
230static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl,
231 const char *buf, size_t size)
232{
233 int r;
234 struct omap_overlay_info info;
235
236 ovl->get_overlay_info(ovl, &info);
237
238 /* Video1 plane does not support global alpha
239 * to always make it 255 completely opaque
240 */
Archit Tanejaa0acb552010-09-15 19:20:00 +0530241 if (!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
242 ovl->id == OMAP_DSS_VIDEO1)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300243 info.global_alpha = 255;
244 else
245 info.global_alpha = simple_strtoul(buf, NULL, 10);
246
247 r = ovl->set_overlay_info(ovl, &info);
248 if (r)
249 return r;
250
251 if (ovl->manager) {
252 r = ovl->manager->apply(ovl->manager);
253 if (r)
254 return r;
255 }
256
257 return size;
258}
259
Rajkumar Nfd28a392010-11-04 12:28:42 +0100260static ssize_t overlay_pre_mult_alpha_show(struct omap_overlay *ovl,
261 char *buf)
262{
263 return snprintf(buf, PAGE_SIZE, "%d\n",
264 ovl->info.pre_mult_alpha);
265}
266
267static ssize_t overlay_pre_mult_alpha_store(struct omap_overlay *ovl,
268 const char *buf, size_t size)
269{
270 int r;
271 struct omap_overlay_info info;
272
273 ovl->get_overlay_info(ovl, &info);
274
275 /* only GFX and Video2 plane support pre alpha multiplied
276 * set zero for Video1 plane
277 */
278 if (!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
279 ovl->id == OMAP_DSS_VIDEO1)
280 info.pre_mult_alpha = 0;
281 else
282 info.pre_mult_alpha = simple_strtoul(buf, NULL, 10);
283
284 r = ovl->set_overlay_info(ovl, &info);
285 if (r)
286 return r;
287
288 if (ovl->manager) {
289 r = ovl->manager->apply(ovl->manager);
290 if (r)
291 return r;
292 }
293
294 return size;
295}
296
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300297struct overlay_attribute {
298 struct attribute attr;
299 ssize_t (*show)(struct omap_overlay *, char *);
300 ssize_t (*store)(struct omap_overlay *, const char *, size_t);
301};
302
303#define OVERLAY_ATTR(_name, _mode, _show, _store) \
304 struct overlay_attribute overlay_attr_##_name = \
305 __ATTR(_name, _mode, _show, _store)
306
307static OVERLAY_ATTR(name, S_IRUGO, overlay_name_show, NULL);
308static OVERLAY_ATTR(manager, S_IRUGO|S_IWUSR,
309 overlay_manager_show, overlay_manager_store);
310static OVERLAY_ATTR(input_size, S_IRUGO, overlay_input_size_show, NULL);
311static OVERLAY_ATTR(screen_width, S_IRUGO, overlay_screen_width_show, NULL);
312static OVERLAY_ATTR(position, S_IRUGO|S_IWUSR,
313 overlay_position_show, overlay_position_store);
314static OVERLAY_ATTR(output_size, S_IRUGO|S_IWUSR,
315 overlay_output_size_show, overlay_output_size_store);
316static OVERLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
317 overlay_enabled_show, overlay_enabled_store);
318static OVERLAY_ATTR(global_alpha, S_IRUGO|S_IWUSR,
319 overlay_global_alpha_show, overlay_global_alpha_store);
Rajkumar Nfd28a392010-11-04 12:28:42 +0100320static OVERLAY_ATTR(pre_mult_alpha, S_IRUGO|S_IWUSR,
321 overlay_pre_mult_alpha_show,
322 overlay_pre_mult_alpha_store);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300323
324static struct attribute *overlay_sysfs_attrs[] = {
325 &overlay_attr_name.attr,
326 &overlay_attr_manager.attr,
327 &overlay_attr_input_size.attr,
328 &overlay_attr_screen_width.attr,
329 &overlay_attr_position.attr,
330 &overlay_attr_output_size.attr,
331 &overlay_attr_enabled.attr,
332 &overlay_attr_global_alpha.attr,
Rajkumar Nfd28a392010-11-04 12:28:42 +0100333 &overlay_attr_pre_mult_alpha.attr,
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300334 NULL
335};
336
337static ssize_t overlay_attr_show(struct kobject *kobj, struct attribute *attr,
338 char *buf)
339{
340 struct omap_overlay *overlay;
341 struct overlay_attribute *overlay_attr;
342
343 overlay = container_of(kobj, struct omap_overlay, kobj);
344 overlay_attr = container_of(attr, struct overlay_attribute, attr);
345
346 if (!overlay_attr->show)
347 return -ENOENT;
348
349 return overlay_attr->show(overlay, buf);
350}
351
352static ssize_t overlay_attr_store(struct kobject *kobj, struct attribute *attr,
353 const char *buf, size_t size)
354{
355 struct omap_overlay *overlay;
356 struct overlay_attribute *overlay_attr;
357
358 overlay = container_of(kobj, struct omap_overlay, kobj);
359 overlay_attr = container_of(attr, struct overlay_attribute, attr);
360
361 if (!overlay_attr->store)
362 return -ENOENT;
363
364 return overlay_attr->store(overlay, buf, size);
365}
366
Emese Revfy52cf25d2010-01-19 02:58:23 +0100367static const struct sysfs_ops overlay_sysfs_ops = {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300368 .show = overlay_attr_show,
369 .store = overlay_attr_store,
370};
371
372static struct kobj_type overlay_ktype = {
373 .sysfs_ops = &overlay_sysfs_ops,
374 .default_attrs = overlay_sysfs_attrs,
375};
376
377/* Check if overlay parameters are compatible with display */
378int dss_check_overlay(struct omap_overlay *ovl, struct omap_dss_device *dssdev)
379{
380 struct omap_overlay_info *info;
381 u16 outw, outh;
382 u16 dw, dh;
383
384 if (!dssdev)
385 return 0;
386
387 if (!ovl->info.enabled)
388 return 0;
389
390 info = &ovl->info;
391
392 if (info->paddr == 0) {
393 DSSDBG("check_overlay failed: paddr 0\n");
394 return -EINVAL;
395 }
396
Tomi Valkeinen96adcec2010-01-11 13:54:33 +0200397 dssdev->driver->get_resolution(dssdev, &dw, &dh);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300398
399 DSSDBG("check_overlay %d: (%d,%d %dx%d -> %dx%d) disp (%dx%d)\n",
400 ovl->id,
401 info->pos_x, info->pos_y,
402 info->width, info->height,
403 info->out_width, info->out_height,
404 dw, dh);
405
406 if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
407 outw = info->width;
408 outh = info->height;
409 } else {
410 if (info->out_width == 0)
411 outw = info->width;
412 else
413 outw = info->out_width;
414
415 if (info->out_height == 0)
416 outh = info->height;
417 else
418 outh = info->out_height;
419 }
420
421 if (dw < info->pos_x + outw) {
422 DSSDBG("check_overlay failed 1: %d < %d + %d\n",
423 dw, info->pos_x, outw);
424 return -EINVAL;
425 }
426
427 if (dh < info->pos_y + outh) {
428 DSSDBG("check_overlay failed 2: %d < %d + %d\n",
429 dh, info->pos_y, outh);
430 return -EINVAL;
431 }
432
433 if ((ovl->supported_modes & info->color_mode) == 0) {
434 DSSERR("overlay doesn't support mode %d\n", info->color_mode);
435 return -EINVAL;
436 }
437
438 return 0;
439}
440
441static int dss_ovl_set_overlay_info(struct omap_overlay *ovl,
442 struct omap_overlay_info *info)
443{
444 int r;
445 struct omap_overlay_info old_info;
446
447 old_info = ovl->info;
448 ovl->info = *info;
449
450 if (ovl->manager) {
451 r = dss_check_overlay(ovl, ovl->manager->device);
452 if (r) {
453 ovl->info = old_info;
454 return r;
455 }
456 }
457
458 ovl->info_dirty = true;
459
460 return 0;
461}
462
463static void dss_ovl_get_overlay_info(struct omap_overlay *ovl,
464 struct omap_overlay_info *info)
465{
466 *info = ovl->info;
467}
468
469static int dss_ovl_wait_for_go(struct omap_overlay *ovl)
470{
471 return dss_mgr_wait_for_go_ovl(ovl);
472}
473
474static int omap_dss_set_manager(struct omap_overlay *ovl,
475 struct omap_overlay_manager *mgr)
476{
477 if (!mgr)
478 return -EINVAL;
479
480 if (ovl->manager) {
481 DSSERR("overlay '%s' already has a manager '%s'\n",
482 ovl->name, ovl->manager->name);
483 return -EINVAL;
484 }
485
486 if (ovl->info.enabled) {
487 DSSERR("overlay has to be disabled to change the manager\n");
488 return -EINVAL;
489 }
490
491 ovl->manager = mgr;
492
Archit Taneja6af9cd12011-01-31 16:27:44 +0000493 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK);
Tomi Valkeinend792eec2010-05-20 15:13:12 +0300494 /* XXX: When there is an overlay on a DSI manual update display, and
495 * the overlay is first disabled, then moved to tv, and enabled, we
496 * seem to get SYNC_LOST_DIGIT error.
497 *
498 * Waiting doesn't seem to help, but updating the manual update display
499 * after disabling the overlay seems to fix this. This hints that the
500 * overlay is perhaps somehow tied to the LCD output until the output
501 * is updated.
502 *
503 * Userspace workaround for this is to update the LCD after disabling
504 * the overlay, but before moving the overlay to TV.
505 */
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300506 dispc_set_channel_out(ovl->id, mgr->id);
Archit Taneja6af9cd12011-01-31 16:27:44 +0000507 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300508
509 return 0;
510}
511
512static int omap_dss_unset_manager(struct omap_overlay *ovl)
513{
514 int r;
515
516 if (!ovl->manager) {
517 DSSERR("failed to detach overlay: manager not set\n");
518 return -EINVAL;
519 }
520
521 if (ovl->info.enabled) {
522 DSSERR("overlay has to be disabled to unset the manager\n");
523 return -EINVAL;
524 }
525
526 r = ovl->wait_for_go(ovl);
527 if (r)
528 return r;
529
530 ovl->manager = NULL;
531
532 return 0;
533}
534
535int omap_dss_get_num_overlays(void)
536{
537 return num_overlays;
538}
539EXPORT_SYMBOL(omap_dss_get_num_overlays);
540
541struct omap_overlay *omap_dss_get_overlay(int num)
542{
543 int i = 0;
544 struct omap_overlay *ovl;
545
546 list_for_each_entry(ovl, &overlay_list, list) {
547 if (i++ == num)
548 return ovl;
549 }
550
551 return NULL;
552}
553EXPORT_SYMBOL(omap_dss_get_overlay);
554
555static void omap_dss_add_overlay(struct omap_overlay *overlay)
556{
557 ++num_overlays;
558 list_add_tail(&overlay->list, &overlay_list);
559}
560
Archit Tanejaa0acb552010-09-15 19:20:00 +0530561static struct omap_overlay *dispc_overlays[MAX_DSS_OVERLAYS];
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300562
563void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr)
564{
Archit Tanejaa0acb552010-09-15 19:20:00 +0530565 mgr->num_overlays = dss_feat_get_num_ovls();
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300566 mgr->overlays = dispc_overlays;
567}
568
569#ifdef L4_EXAMPLE
570static struct omap_overlay *l4_overlays[1];
571void dss_overlay_setup_l4_manager(struct omap_overlay_manager *mgr)
572{
573 mgr->num_overlays = 1;
574 mgr->overlays = l4_overlays;
575}
576#endif
577
578void dss_init_overlays(struct platform_device *pdev)
579{
580 int i, r;
581
582 INIT_LIST_HEAD(&overlay_list);
583
584 num_overlays = 0;
585
Archit Tanejaa0acb552010-09-15 19:20:00 +0530586 for (i = 0; i < dss_feat_get_num_ovls(); ++i) {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300587 struct omap_overlay *ovl;
588 ovl = kzalloc(sizeof(*ovl), GFP_KERNEL);
589
590 BUG_ON(ovl == NULL);
591
592 switch (i) {
593 case 0:
594 ovl->name = "gfx";
595 ovl->id = OMAP_DSS_GFX;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300596 ovl->caps = OMAP_DSS_OVL_CAP_DISPC;
597 ovl->info.global_alpha = 255;
598 break;
599 case 1:
600 ovl->name = "vid1";
601 ovl->id = OMAP_DSS_VIDEO1;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300602 ovl->caps = OMAP_DSS_OVL_CAP_SCALE |
603 OMAP_DSS_OVL_CAP_DISPC;
604 ovl->info.global_alpha = 255;
605 break;
606 case 2:
607 ovl->name = "vid2";
608 ovl->id = OMAP_DSS_VIDEO2;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300609 ovl->caps = OMAP_DSS_OVL_CAP_SCALE |
610 OMAP_DSS_OVL_CAP_DISPC;
611 ovl->info.global_alpha = 255;
612 break;
613 }
614
615 ovl->set_manager = &omap_dss_set_manager;
616 ovl->unset_manager = &omap_dss_unset_manager;
617 ovl->set_overlay_info = &dss_ovl_set_overlay_info;
618 ovl->get_overlay_info = &dss_ovl_get_overlay_info;
619 ovl->wait_for_go = &dss_ovl_wait_for_go;
620
Archit Tanejaa0acb552010-09-15 19:20:00 +0530621 ovl->supported_modes =
622 dss_feat_get_supported_color_modes(ovl->id);
623
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300624 omap_dss_add_overlay(ovl);
625
626 r = kobject_init_and_add(&ovl->kobj, &overlay_ktype,
627 &pdev->dev.kobj, "overlay%d", i);
628
629 if (r) {
630 DSSERR("failed to create sysfs file\n");
631 continue;
632 }
633
634 dispc_overlays[i] = ovl;
635 }
636
637#ifdef L4_EXAMPLE
638 {
639 struct omap_overlay *ovl;
640 ovl = kzalloc(sizeof(*ovl), GFP_KERNEL);
641
642 BUG_ON(ovl == NULL);
643
644 ovl->name = "l4";
645 ovl->supported_modes = OMAP_DSS_COLOR_RGB24U;
646
647 ovl->set_manager = &omap_dss_set_manager;
648 ovl->unset_manager = &omap_dss_unset_manager;
649 ovl->set_overlay_info = &dss_ovl_set_overlay_info;
650 ovl->get_overlay_info = &dss_ovl_get_overlay_info;
651
652 omap_dss_add_overlay(ovl);
653
654 r = kobject_init_and_add(&ovl->kobj, &overlay_ktype,
655 &pdev->dev.kobj, "overlayl4");
656
657 if (r)
658 DSSERR("failed to create sysfs file\n");
659
660 l4_overlays[0] = ovl;
661 }
662#endif
663}
664
665/* connect overlays to the new device, if not already connected. if force
666 * selected, connect always. */
667void dss_recheck_connections(struct omap_dss_device *dssdev, bool force)
668{
669 int i;
670 struct omap_overlay_manager *lcd_mgr;
671 struct omap_overlay_manager *tv_mgr;
Sumit Semwal18faa1b2010-12-02 11:27:14 +0000672 struct omap_overlay_manager *lcd2_mgr = NULL;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300673 struct omap_overlay_manager *mgr = NULL;
674
675 lcd_mgr = omap_dss_get_overlay_manager(OMAP_DSS_OVL_MGR_LCD);
676 tv_mgr = omap_dss_get_overlay_manager(OMAP_DSS_OVL_MGR_TV);
Sumit Semwal18faa1b2010-12-02 11:27:14 +0000677 if (dss_has_feature(FEAT_MGR_LCD2))
678 lcd2_mgr = omap_dss_get_overlay_manager(OMAP_DSS_OVL_MGR_LCD2);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300679
Sumit Semwal18faa1b2010-12-02 11:27:14 +0000680 if (dssdev->channel == OMAP_DSS_CHANNEL_LCD2) {
681 if (!lcd2_mgr->device || force) {
682 if (lcd2_mgr->device)
683 lcd2_mgr->unset_device(lcd2_mgr);
684 lcd2_mgr->set_device(lcd2_mgr, dssdev);
685 mgr = lcd2_mgr;
686 }
Mythri P Kb1196012011-03-08 17:15:54 +0530687 } else if (dssdev->type != OMAP_DISPLAY_TYPE_VENC
688 && dssdev->type != OMAP_DISPLAY_TYPE_HDMI) {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300689 if (!lcd_mgr->device || force) {
690 if (lcd_mgr->device)
691 lcd_mgr->unset_device(lcd_mgr);
692 lcd_mgr->set_device(lcd_mgr, dssdev);
693 mgr = lcd_mgr;
694 }
695 }
696
Mythri P Kb1196012011-03-08 17:15:54 +0530697 if (dssdev->type == OMAP_DISPLAY_TYPE_VENC
698 || dssdev->type == OMAP_DISPLAY_TYPE_HDMI) {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300699 if (!tv_mgr->device || force) {
700 if (tv_mgr->device)
701 tv_mgr->unset_device(tv_mgr);
702 tv_mgr->set_device(tv_mgr, dssdev);
703 mgr = tv_mgr;
704 }
705 }
706
707 if (mgr) {
Archit Tanejaa0acb552010-09-15 19:20:00 +0530708 for (i = 0; i < dss_feat_get_num_ovls(); i++) {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300709 struct omap_overlay *ovl;
710 ovl = omap_dss_get_overlay(i);
711 if (!ovl->manager || force) {
712 if (ovl->manager)
713 omap_dss_unset_manager(ovl);
714 omap_dss_set_manager(ovl, mgr);
715 }
716 }
717 }
718}
719
720void dss_uninit_overlays(struct platform_device *pdev)
721{
722 struct omap_overlay *ovl;
723
724 while (!list_empty(&overlay_list)) {
725 ovl = list_first_entry(&overlay_list,
726 struct omap_overlay, list);
727 list_del(&ovl->list);
728 kobject_del(&ovl->kobj);
729 kobject_put(&ovl->kobj);
730 kfree(ovl);
731 }
732
733 num_overlays = 0;
734}
735