blob: 7e1ec5af6c703765359cb9c8b65d2e83b8947072 [file] [log] [blame]
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001/*
2 * linux/drivers/video/omap2/dss/manager.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 "MANAGER"
24
25#include <linux/kernel.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090026#include <linux/slab.h>
Tomi Valkeineneed07e02009-08-07 13:43:20 +030027#include <linux/module.h>
28#include <linux/platform_device.h>
29#include <linux/spinlock.h>
30#include <linux/jiffies.h>
31
32#include <plat/display.h>
33#include <plat/cpu.h>
34
35#include "dss.h"
36
37static int num_managers;
38static struct list_head manager_list;
39
40static ssize_t manager_name_show(struct omap_overlay_manager *mgr, char *buf)
41{
42 return snprintf(buf, PAGE_SIZE, "%s\n", mgr->name);
43}
44
45static ssize_t manager_display_show(struct omap_overlay_manager *mgr, char *buf)
46{
47 return snprintf(buf, PAGE_SIZE, "%s\n",
48 mgr->device ? mgr->device->name : "<none>");
49}
50
51static ssize_t manager_display_store(struct omap_overlay_manager *mgr,
52 const char *buf, size_t size)
53{
54 int r = 0;
55 size_t len = size;
56 struct omap_dss_device *dssdev = NULL;
57
58 int match(struct omap_dss_device *dssdev, void *data)
59 {
60 const char *str = data;
61 return sysfs_streq(dssdev->name, str);
62 }
63
64 if (buf[size-1] == '\n')
65 --len;
66
67 if (len > 0)
68 dssdev = omap_dss_find_device((void *)buf, match);
69
70 if (len > 0 && dssdev == NULL)
71 return -EINVAL;
72
73 if (dssdev)
74 DSSDBG("display %s found\n", dssdev->name);
75
76 if (mgr->device) {
77 r = mgr->unset_device(mgr);
78 if (r) {
79 DSSERR("failed to unset display\n");
80 goto put_device;
81 }
82 }
83
84 if (dssdev) {
85 r = mgr->set_device(mgr, dssdev);
86 if (r) {
87 DSSERR("failed to set manager\n");
88 goto put_device;
89 }
90
91 r = mgr->apply(mgr);
92 if (r) {
93 DSSERR("failed to apply dispc config\n");
94 goto put_device;
95 }
96 }
97
98put_device:
99 if (dssdev)
100 omap_dss_put_device(dssdev);
101
102 return r ? r : size;
103}
104
105static ssize_t manager_default_color_show(struct omap_overlay_manager *mgr,
106 char *buf)
107{
108 return snprintf(buf, PAGE_SIZE, "%d\n", mgr->info.default_color);
109}
110
111static ssize_t manager_default_color_store(struct omap_overlay_manager *mgr,
112 const char *buf, size_t size)
113{
114 struct omap_overlay_manager_info info;
115 u32 color;
116 int r;
117
118 if (sscanf(buf, "%d", &color) != 1)
119 return -EINVAL;
120
121 mgr->get_manager_info(mgr, &info);
122
123 info.default_color = color;
124
125 r = mgr->set_manager_info(mgr, &info);
126 if (r)
127 return r;
128
129 r = mgr->apply(mgr);
130 if (r)
131 return r;
132
133 return size;
134}
135
136static const char *trans_key_type_str[] = {
137 "gfx-destination",
138 "video-source",
139};
140
141static ssize_t manager_trans_key_type_show(struct omap_overlay_manager *mgr,
142 char *buf)
143{
144 enum omap_dss_trans_key_type key_type;
145
146 key_type = mgr->info.trans_key_type;
147 BUG_ON(key_type >= ARRAY_SIZE(trans_key_type_str));
148
149 return snprintf(buf, PAGE_SIZE, "%s\n", trans_key_type_str[key_type]);
150}
151
152static ssize_t manager_trans_key_type_store(struct omap_overlay_manager *mgr,
153 const char *buf, size_t size)
154{
155 enum omap_dss_trans_key_type key_type;
156 struct omap_overlay_manager_info info;
157 int r;
158
159 for (key_type = OMAP_DSS_COLOR_KEY_GFX_DST;
160 key_type < ARRAY_SIZE(trans_key_type_str); key_type++) {
161 if (sysfs_streq(buf, trans_key_type_str[key_type]))
162 break;
163 }
164
165 if (key_type == ARRAY_SIZE(trans_key_type_str))
166 return -EINVAL;
167
168 mgr->get_manager_info(mgr, &info);
169
170 info.trans_key_type = key_type;
171
172 r = mgr->set_manager_info(mgr, &info);
173 if (r)
174 return r;
175
176 r = mgr->apply(mgr);
177 if (r)
178 return r;
179
180 return size;
181}
182
183static ssize_t manager_trans_key_value_show(struct omap_overlay_manager *mgr,
184 char *buf)
185{
186 return snprintf(buf, PAGE_SIZE, "%d\n", mgr->info.trans_key);
187}
188
189static ssize_t manager_trans_key_value_store(struct omap_overlay_manager *mgr,
190 const char *buf, size_t size)
191{
192 struct omap_overlay_manager_info info;
193 u32 key_value;
194 int r;
195
196 if (sscanf(buf, "%d", &key_value) != 1)
197 return -EINVAL;
198
199 mgr->get_manager_info(mgr, &info);
200
201 info.trans_key = key_value;
202
203 r = mgr->set_manager_info(mgr, &info);
204 if (r)
205 return r;
206
207 r = mgr->apply(mgr);
208 if (r)
209 return r;
210
211 return size;
212}
213
214static ssize_t manager_trans_key_enabled_show(struct omap_overlay_manager *mgr,
215 char *buf)
216{
217 return snprintf(buf, PAGE_SIZE, "%d\n", mgr->info.trans_enabled);
218}
219
220static ssize_t manager_trans_key_enabled_store(struct omap_overlay_manager *mgr,
221 const char *buf, size_t size)
222{
223 struct omap_overlay_manager_info info;
224 int enable;
225 int r;
226
227 if (sscanf(buf, "%d", &enable) != 1)
228 return -EINVAL;
229
230 mgr->get_manager_info(mgr, &info);
231
232 info.trans_enabled = enable ? true : false;
233
234 r = mgr->set_manager_info(mgr, &info);
235 if (r)
236 return r;
237
238 r = mgr->apply(mgr);
239 if (r)
240 return r;
241
242 return size;
243}
244
245static ssize_t manager_alpha_blending_enabled_show(
246 struct omap_overlay_manager *mgr, char *buf)
247{
248 return snprintf(buf, PAGE_SIZE, "%d\n", mgr->info.alpha_enabled);
249}
250
251static ssize_t manager_alpha_blending_enabled_store(
252 struct omap_overlay_manager *mgr,
253 const char *buf, size_t size)
254{
255 struct omap_overlay_manager_info info;
256 int enable;
257 int r;
258
259 if (sscanf(buf, "%d", &enable) != 1)
260 return -EINVAL;
261
262 mgr->get_manager_info(mgr, &info);
263
264 info.alpha_enabled = enable ? true : false;
265
266 r = mgr->set_manager_info(mgr, &info);
267 if (r)
268 return r;
269
270 r = mgr->apply(mgr);
271 if (r)
272 return r;
273
274 return size;
275}
276
277struct manager_attribute {
278 struct attribute attr;
279 ssize_t (*show)(struct omap_overlay_manager *, char *);
280 ssize_t (*store)(struct omap_overlay_manager *, const char *, size_t);
281};
282
283#define MANAGER_ATTR(_name, _mode, _show, _store) \
284 struct manager_attribute manager_attr_##_name = \
285 __ATTR(_name, _mode, _show, _store)
286
287static MANAGER_ATTR(name, S_IRUGO, manager_name_show, NULL);
288static MANAGER_ATTR(display, S_IRUGO|S_IWUSR,
289 manager_display_show, manager_display_store);
290static MANAGER_ATTR(default_color, S_IRUGO|S_IWUSR,
291 manager_default_color_show, manager_default_color_store);
292static MANAGER_ATTR(trans_key_type, S_IRUGO|S_IWUSR,
293 manager_trans_key_type_show, manager_trans_key_type_store);
294static MANAGER_ATTR(trans_key_value, S_IRUGO|S_IWUSR,
295 manager_trans_key_value_show, manager_trans_key_value_store);
296static MANAGER_ATTR(trans_key_enabled, S_IRUGO|S_IWUSR,
297 manager_trans_key_enabled_show,
298 manager_trans_key_enabled_store);
299static MANAGER_ATTR(alpha_blending_enabled, S_IRUGO|S_IWUSR,
300 manager_alpha_blending_enabled_show,
301 manager_alpha_blending_enabled_store);
302
303
304static struct attribute *manager_sysfs_attrs[] = {
305 &manager_attr_name.attr,
306 &manager_attr_display.attr,
307 &manager_attr_default_color.attr,
308 &manager_attr_trans_key_type.attr,
309 &manager_attr_trans_key_value.attr,
310 &manager_attr_trans_key_enabled.attr,
311 &manager_attr_alpha_blending_enabled.attr,
312 NULL
313};
314
315static ssize_t manager_attr_show(struct kobject *kobj, struct attribute *attr,
316 char *buf)
317{
318 struct omap_overlay_manager *manager;
319 struct manager_attribute *manager_attr;
320
321 manager = container_of(kobj, struct omap_overlay_manager, kobj);
322 manager_attr = container_of(attr, struct manager_attribute, attr);
323
324 if (!manager_attr->show)
325 return -ENOENT;
326
327 return manager_attr->show(manager, buf);
328}
329
330static ssize_t manager_attr_store(struct kobject *kobj, struct attribute *attr,
331 const char *buf, size_t size)
332{
333 struct omap_overlay_manager *manager;
334 struct manager_attribute *manager_attr;
335
336 manager = container_of(kobj, struct omap_overlay_manager, kobj);
337 manager_attr = container_of(attr, struct manager_attribute, attr);
338
339 if (!manager_attr->store)
340 return -ENOENT;
341
342 return manager_attr->store(manager, buf, size);
343}
344
Emese Revfy52cf25d2010-01-19 02:58:23 +0100345static const struct sysfs_ops manager_sysfs_ops = {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300346 .show = manager_attr_show,
347 .store = manager_attr_store,
348};
349
350static struct kobj_type manager_ktype = {
351 .sysfs_ops = &manager_sysfs_ops,
352 .default_attrs = manager_sysfs_attrs,
353};
354
355/*
356 * We have 4 levels of cache for the dispc settings. First two are in SW and
357 * the latter two in HW.
358 *
359 * +--------------------+
360 * |overlay/manager_info|
361 * +--------------------+
362 * v
363 * apply()
364 * v
365 * +--------------------+
366 * | dss_cache |
367 * +--------------------+
368 * v
369 * configure()
370 * v
371 * +--------------------+
372 * | shadow registers |
373 * +--------------------+
374 * v
375 * VFP or lcd/digit_enable
376 * v
377 * +--------------------+
378 * | registers |
379 * +--------------------+
380 */
381
382struct overlay_cache_data {
383 /* If true, cache changed, but not written to shadow registers. Set
384 * in apply(), cleared when registers written. */
385 bool dirty;
386 /* If true, shadow registers contain changed values not yet in real
387 * registers. Set when writing to shadow registers, cleared at
388 * VSYNC/EVSYNC */
389 bool shadow_dirty;
390
391 bool enabled;
392
393 u32 paddr;
394 void __iomem *vaddr;
395 u16 screen_width;
396 u16 width;
397 u16 height;
398 enum omap_color_mode color_mode;
399 u8 rotation;
400 enum omap_dss_rotation_type rotation_type;
401 bool mirror;
402
403 u16 pos_x;
404 u16 pos_y;
405 u16 out_width; /* if 0, out_width == width */
406 u16 out_height; /* if 0, out_height == height */
407 u8 global_alpha;
408
409 enum omap_channel channel;
410 bool replication;
411 bool ilace;
412
413 enum omap_burst_size burst_size;
414 u32 fifo_low;
415 u32 fifo_high;
416
417 bool manual_update;
418};
419
420struct manager_cache_data {
421 /* If true, cache changed, but not written to shadow registers. Set
422 * in apply(), cleared when registers written. */
423 bool dirty;
424 /* If true, shadow registers contain changed values not yet in real
425 * registers. Set when writing to shadow registers, cleared at
426 * VSYNC/EVSYNC */
427 bool shadow_dirty;
428
429 u32 default_color;
430
431 enum omap_dss_trans_key_type trans_key_type;
432 u32 trans_key;
433 bool trans_enabled;
434
435 bool alpha_enabled;
436
437 bool manual_upd_display;
438 bool manual_update;
439 bool do_manual_update;
440
441 /* manual update region */
442 u16 x, y, w, h;
443};
444
445static struct {
446 spinlock_t lock;
447 struct overlay_cache_data overlay_cache[3];
448 struct manager_cache_data manager_cache[2];
449
450 bool irq_enabled;
451} dss_cache;
452
453
454
455static int omap_dss_set_device(struct omap_overlay_manager *mgr,
456 struct omap_dss_device *dssdev)
457{
458 int i;
459 int r;
460
461 if (dssdev->manager) {
462 DSSERR("display '%s' already has a manager '%s'\n",
463 dssdev->name, dssdev->manager->name);
464 return -EINVAL;
465 }
466
467 if ((mgr->supported_displays & dssdev->type) == 0) {
468 DSSERR("display '%s' does not support manager '%s'\n",
469 dssdev->name, mgr->name);
470 return -EINVAL;
471 }
472
473 for (i = 0; i < mgr->num_overlays; i++) {
474 struct omap_overlay *ovl = mgr->overlays[i];
475
476 if (ovl->manager != mgr || !ovl->info.enabled)
477 continue;
478
479 r = dss_check_overlay(ovl, dssdev);
480 if (r)
481 return r;
482 }
483
484 dssdev->manager = mgr;
485 mgr->device = dssdev;
486 mgr->device_changed = true;
487
488 return 0;
489}
490
491static int omap_dss_unset_device(struct omap_overlay_manager *mgr)
492{
493 if (!mgr->device) {
494 DSSERR("failed to unset display, display not set.\n");
495 return -EINVAL;
496 }
497
498 mgr->device->manager = NULL;
499 mgr->device = NULL;
500 mgr->device_changed = true;
501
502 return 0;
503}
504
Tomi Valkeinen3f71cbe2010-01-08 17:06:04 +0200505static int dss_mgr_wait_for_vsync(struct omap_overlay_manager *mgr)
506{
507 unsigned long timeout = msecs_to_jiffies(500);
508 u32 irq;
509
510 if (mgr->device->type == OMAP_DISPLAY_TYPE_VENC)
511 irq = DISPC_IRQ_EVSYNC_ODD;
512 else
513 irq = DISPC_IRQ_VSYNC;
514
515 return omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout);
516}
517
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300518static int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr)
519{
520 unsigned long timeout = msecs_to_jiffies(500);
521 struct manager_cache_data *mc;
522 enum omap_channel channel;
523 u32 irq;
524 int r;
525 int i;
Tomi Valkeinen446f7bf2010-01-11 16:12:31 +0200526 struct omap_dss_device *dssdev = mgr->device;
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300527
Ville Syrjäläa74b2602010-03-04 16:03:56 +0200528 if (!dssdev || dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300529 return 0;
530
Tomi Valkeinen446f7bf2010-01-11 16:12:31 +0200531 if (dssdev->type == OMAP_DISPLAY_TYPE_VENC) {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300532 irq = DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_EVSYNC_EVEN;
533 channel = OMAP_DSS_CHANNEL_DIGIT;
534 } else {
Tomi Valkeinen446f7bf2010-01-11 16:12:31 +0200535 if (dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) {
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300536 enum omap_dss_update_mode mode;
Tomi Valkeinen446f7bf2010-01-11 16:12:31 +0200537 mode = dssdev->driver->get_update_mode(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300538 if (mode != OMAP_DSS_UPDATE_AUTO)
539 return 0;
540
541 irq = DISPC_IRQ_FRAMEDONE;
542 } else {
543 irq = DISPC_IRQ_VSYNC;
544 }
545 channel = OMAP_DSS_CHANNEL_LCD;
546 }
547
548 mc = &dss_cache.manager_cache[mgr->id];
549 i = 0;
550 while (1) {
551 unsigned long flags;
552 bool shadow_dirty, dirty;
553
554 spin_lock_irqsave(&dss_cache.lock, flags);
555 dirty = mc->dirty;
556 shadow_dirty = mc->shadow_dirty;
557 spin_unlock_irqrestore(&dss_cache.lock, flags);
558
559 if (!dirty && !shadow_dirty) {
560 r = 0;
561 break;
562 }
563
564 /* 4 iterations is the worst case:
565 * 1 - initial iteration, dirty = true (between VFP and VSYNC)
566 * 2 - first VSYNC, dirty = true
567 * 3 - dirty = false, shadow_dirty = true
568 * 4 - shadow_dirty = false */
569 if (i++ == 3) {
570 DSSERR("mgr(%d)->wait_for_go() not finishing\n",
571 mgr->id);
572 r = 0;
573 break;
574 }
575
576 r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout);
577 if (r == -ERESTARTSYS)
578 break;
579
580 if (r) {
581 DSSERR("mgr(%d)->wait_for_go() timeout\n", mgr->id);
582 break;
583 }
584 }
585
586 return r;
587}
588
589int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl)
590{
591 unsigned long timeout = msecs_to_jiffies(500);
592 enum omap_channel channel;
593 struct overlay_cache_data *oc;
594 struct omap_dss_device *dssdev;
595 u32 irq;
596 int r;
597 int i;
598
Ville Syrjäläa74b2602010-03-04 16:03:56 +0200599 if (!ovl->manager)
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300600 return 0;
601
602 dssdev = ovl->manager->device;
603
Ville Syrjäläa74b2602010-03-04 16:03:56 +0200604 if (!dssdev || dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
605 return 0;
606
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300607 if (dssdev->type == OMAP_DISPLAY_TYPE_VENC) {
608 irq = DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_EVSYNC_EVEN;
609 channel = OMAP_DSS_CHANNEL_DIGIT;
610 } else {
611 if (dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) {
612 enum omap_dss_update_mode mode;
Tomi Valkeinen446f7bf2010-01-11 16:12:31 +0200613 mode = dssdev->driver->get_update_mode(dssdev);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300614 if (mode != OMAP_DSS_UPDATE_AUTO)
615 return 0;
616
617 irq = DISPC_IRQ_FRAMEDONE;
618 } else {
619 irq = DISPC_IRQ_VSYNC;
620 }
621 channel = OMAP_DSS_CHANNEL_LCD;
622 }
623
624 oc = &dss_cache.overlay_cache[ovl->id];
625 i = 0;
626 while (1) {
627 unsigned long flags;
628 bool shadow_dirty, dirty;
629
630 spin_lock_irqsave(&dss_cache.lock, flags);
631 dirty = oc->dirty;
632 shadow_dirty = oc->shadow_dirty;
633 spin_unlock_irqrestore(&dss_cache.lock, flags);
634
635 if (!dirty && !shadow_dirty) {
636 r = 0;
637 break;
638 }
639
640 /* 4 iterations is the worst case:
641 * 1 - initial iteration, dirty = true (between VFP and VSYNC)
642 * 2 - first VSYNC, dirty = true
643 * 3 - dirty = false, shadow_dirty = true
644 * 4 - shadow_dirty = false */
645 if (i++ == 3) {
646 DSSERR("ovl(%d)->wait_for_go() not finishing\n",
647 ovl->id);
648 r = 0;
649 break;
650 }
651
652 r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout);
653 if (r == -ERESTARTSYS)
654 break;
655
656 if (r) {
657 DSSERR("ovl(%d)->wait_for_go() timeout\n", ovl->id);
658 break;
659 }
660 }
661
662 return r;
663}
664
665static int overlay_enabled(struct omap_overlay *ovl)
666{
667 return ovl->info.enabled && ovl->manager && ovl->manager->device;
668}
669
670/* Is rect1 a subset of rect2? */
671static bool rectangle_subset(int x1, int y1, int w1, int h1,
672 int x2, int y2, int w2, int h2)
673{
674 if (x1 < x2 || y1 < y2)
675 return false;
676
677 if (x1 + w1 > x2 + w2)
678 return false;
679
680 if (y1 + h1 > y2 + h2)
681 return false;
682
683 return true;
684}
685
686/* Do rect1 and rect2 overlap? */
687static bool rectangle_intersects(int x1, int y1, int w1, int h1,
688 int x2, int y2, int w2, int h2)
689{
690 if (x1 >= x2 + w2)
691 return false;
692
693 if (x2 >= x1 + w1)
694 return false;
695
696 if (y1 >= y2 + h2)
697 return false;
698
699 if (y2 >= y1 + h1)
700 return false;
701
702 return true;
703}
704
705static bool dispc_is_overlay_scaled(struct overlay_cache_data *oc)
706{
707 if (oc->out_width != 0 && oc->width != oc->out_width)
708 return true;
709
710 if (oc->out_height != 0 && oc->height != oc->out_height)
711 return true;
712
713 return false;
714}
715
716static int configure_overlay(enum omap_plane plane)
717{
718 struct overlay_cache_data *c;
719 struct manager_cache_data *mc;
720 u16 outw, outh;
721 u16 x, y, w, h;
722 u32 paddr;
723 int r;
724
725 DSSDBGF("%d", plane);
726
727 c = &dss_cache.overlay_cache[plane];
728
729 if (!c->enabled) {
730 dispc_enable_plane(plane, 0);
731 return 0;
732 }
733
734 mc = &dss_cache.manager_cache[c->channel];
735
736 x = c->pos_x;
737 y = c->pos_y;
738 w = c->width;
739 h = c->height;
740 outw = c->out_width == 0 ? c->width : c->out_width;
741 outh = c->out_height == 0 ? c->height : c->out_height;
742 paddr = c->paddr;
743
744 if (c->manual_update && mc->do_manual_update) {
745 unsigned bpp;
746 /* If the overlay is outside the update region, disable it */
747 if (!rectangle_intersects(mc->x, mc->y, mc->w, mc->h,
748 x, y, outw, outh)) {
749 dispc_enable_plane(plane, 0);
750 return 0;
751 }
752
753 switch (c->color_mode) {
754 case OMAP_DSS_COLOR_RGB16:
755 case OMAP_DSS_COLOR_ARGB16:
756 case OMAP_DSS_COLOR_YUV2:
757 case OMAP_DSS_COLOR_UYVY:
758 bpp = 16;
759 break;
760
761 case OMAP_DSS_COLOR_RGB24P:
762 bpp = 24;
763 break;
764
765 case OMAP_DSS_COLOR_RGB24U:
766 case OMAP_DSS_COLOR_ARGB32:
767 case OMAP_DSS_COLOR_RGBA32:
768 case OMAP_DSS_COLOR_RGBX32:
769 bpp = 32;
770 break;
771
772 default:
773 BUG();
774 }
775
776 if (dispc_is_overlay_scaled(c)) {
777 /* If the overlay is scaled, the update area has
778 * already been enlarged to cover the whole overlay. We
779 * only need to adjust x/y here */
780 x = c->pos_x - mc->x;
781 y = c->pos_y - mc->y;
782 } else {
783 if (mc->x > c->pos_x) {
784 x = 0;
785 w -= (mc->x - c->pos_x);
786 paddr += (mc->x - c->pos_x) * bpp / 8;
787 } else {
788 x = c->pos_x - mc->x;
789 }
790
791 if (mc->y > c->pos_y) {
792 y = 0;
793 h -= (mc->y - c->pos_y);
794 paddr += (mc->y - c->pos_y) * c->screen_width *
795 bpp / 8;
796 } else {
797 y = c->pos_y - mc->y;
798 }
799
800 if (mc->w < (x+w))
801 w -= (x+w) - (mc->w);
802
803 if (mc->h < (y+h))
804 h -= (y+h) - (mc->h);
805
806 outw = w;
807 outh = h;
808 }
809 }
810
811 r = dispc_setup_plane(plane,
812 paddr,
813 c->screen_width,
814 x, y,
815 w, h,
816 outw, outh,
817 c->color_mode,
818 c->ilace,
819 c->rotation_type,
820 c->rotation,
821 c->mirror,
822 c->global_alpha);
823
824 if (r) {
825 /* this shouldn't happen */
826 DSSERR("dispc_setup_plane failed for ovl %d\n", plane);
827 dispc_enable_plane(plane, 0);
828 return r;
829 }
830
831 dispc_enable_replication(plane, c->replication);
832
833 dispc_set_burst_size(plane, c->burst_size);
834 dispc_setup_plane_fifo(plane, c->fifo_low, c->fifo_high);
835
836 dispc_enable_plane(plane, 1);
837
838 return 0;
839}
840
841static void configure_manager(enum omap_channel channel)
842{
843 struct manager_cache_data *c;
844
845 DSSDBGF("%d", channel);
846
847 c = &dss_cache.manager_cache[channel];
848
Carlos Lopeza3bb67a2010-04-25 12:53:35 +0200849 dispc_set_default_color(channel, c->default_color);
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300850 dispc_set_trans_key(channel, c->trans_key_type, c->trans_key);
851 dispc_enable_trans_key(channel, c->trans_enabled);
852 dispc_enable_alpha_blending(channel, c->alpha_enabled);
853}
854
855/* configure_dispc() tries to write values from cache to shadow registers.
856 * It writes only to those managers/overlays that are not busy.
857 * returns 0 if everything could be written to shadow registers.
858 * returns 1 if not everything could be written to shadow registers. */
859static int configure_dispc(void)
860{
861 struct overlay_cache_data *oc;
862 struct manager_cache_data *mc;
863 const int num_ovls = ARRAY_SIZE(dss_cache.overlay_cache);
864 const int num_mgrs = ARRAY_SIZE(dss_cache.manager_cache);
865 int i;
866 int r;
867 bool mgr_busy[2];
868 bool mgr_go[2];
869 bool busy;
870
871 r = 0;
872 busy = false;
873
874 mgr_busy[0] = dispc_go_busy(0);
875 mgr_busy[1] = dispc_go_busy(1);
876 mgr_go[0] = false;
877 mgr_go[1] = false;
878
879 /* Commit overlay settings */
880 for (i = 0; i < num_ovls; ++i) {
881 oc = &dss_cache.overlay_cache[i];
882 mc = &dss_cache.manager_cache[oc->channel];
883
884 if (!oc->dirty)
885 continue;
886
887 if (oc->manual_update && !mc->do_manual_update)
888 continue;
889
890 if (mgr_busy[oc->channel]) {
891 busy = true;
892 continue;
893 }
894
895 r = configure_overlay(i);
896 if (r)
897 DSSERR("configure_overlay %d failed\n", i);
898
899 oc->dirty = false;
900 oc->shadow_dirty = true;
901 mgr_go[oc->channel] = true;
902 }
903
904 /* Commit manager settings */
905 for (i = 0; i < num_mgrs; ++i) {
906 mc = &dss_cache.manager_cache[i];
907
908 if (!mc->dirty)
909 continue;
910
911 if (mc->manual_update && !mc->do_manual_update)
912 continue;
913
914 if (mgr_busy[i]) {
915 busy = true;
916 continue;
917 }
918
919 configure_manager(i);
920 mc->dirty = false;
921 mc->shadow_dirty = true;
922 mgr_go[i] = true;
923 }
924
925 /* set GO */
926 for (i = 0; i < num_mgrs; ++i) {
927 mc = &dss_cache.manager_cache[i];
928
929 if (!mgr_go[i])
930 continue;
931
932 /* We don't need GO with manual update display. LCD iface will
933 * always be turned off after frame, and new settings will be
934 * taken in to use at next update */
935 if (!mc->manual_upd_display)
936 dispc_go(i);
937 }
938
939 if (busy)
940 r = 1;
941 else
942 r = 0;
943
944 return r;
945}
946
Tomi Valkeinenf49a9512010-03-26 16:26:37 +0200947/* Make the coordinates even. There are some strange problems with OMAP and
948 * partial DSI update when the update widths are odd. */
949static void make_even(u16 *x, u16 *w)
950{
951 u16 x1, x2;
952
953 x1 = *x;
954 x2 = *x + *w;
955
956 x1 &= ~1;
957 x2 = ALIGN(x2, 2);
958
959 *x = x1;
960 *w = x2 - x1;
961}
962
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300963/* Configure dispc for partial update. Return possibly modified update
964 * area */
965void dss_setup_partial_planes(struct omap_dss_device *dssdev,
966 u16 *xi, u16 *yi, u16 *wi, u16 *hi)
967{
968 struct overlay_cache_data *oc;
969 struct manager_cache_data *mc;
970 const int num_ovls = ARRAY_SIZE(dss_cache.overlay_cache);
971 struct omap_overlay_manager *mgr;
972 int i;
973 u16 x, y, w, h;
974 unsigned long flags;
975
976 x = *xi;
977 y = *yi;
978 w = *wi;
979 h = *hi;
980
981 DSSDBG("dispc_setup_partial_planes %d,%d %dx%d\n",
982 *xi, *yi, *wi, *hi);
983
984 mgr = dssdev->manager;
985
986 if (!mgr) {
987 DSSDBG("no manager\n");
988 return;
989 }
990
Tomi Valkeinenf49a9512010-03-26 16:26:37 +0200991 make_even(&x, &w);
992
Tomi Valkeineneed07e02009-08-07 13:43:20 +0300993 spin_lock_irqsave(&dss_cache.lock, flags);
994
995 /* We need to show the whole overlay if it is scaled. So look for
996 * those, and make the update area larger if found.
997 * Also mark the overlay cache dirty */
998 for (i = 0; i < num_ovls; ++i) {
999 unsigned x1, y1, x2, y2;
1000 unsigned outw, outh;
1001
1002 oc = &dss_cache.overlay_cache[i];
1003
1004 if (oc->channel != mgr->id)
1005 continue;
1006
1007 oc->dirty = true;
1008
1009 if (!oc->enabled)
1010 continue;
1011
1012 if (!dispc_is_overlay_scaled(oc))
1013 continue;
1014
1015 outw = oc->out_width == 0 ? oc->width : oc->out_width;
1016 outh = oc->out_height == 0 ? oc->height : oc->out_height;
1017
1018 /* is the overlay outside the update region? */
1019 if (!rectangle_intersects(x, y, w, h,
1020 oc->pos_x, oc->pos_y,
1021 outw, outh))
1022 continue;
1023
1024 /* if the overlay totally inside the update region? */
1025 if (rectangle_subset(oc->pos_x, oc->pos_y, outw, outh,
1026 x, y, w, h))
1027 continue;
1028
1029 if (x > oc->pos_x)
1030 x1 = oc->pos_x;
1031 else
1032 x1 = x;
1033
1034 if (y > oc->pos_y)
1035 y1 = oc->pos_y;
1036 else
1037 y1 = y;
1038
1039 if ((x + w) < (oc->pos_x + outw))
1040 x2 = oc->pos_x + outw;
1041 else
1042 x2 = x + w;
1043
1044 if ((y + h) < (oc->pos_y + outh))
1045 y2 = oc->pos_y + outh;
1046 else
1047 y2 = y + h;
1048
1049 x = x1;
1050 y = y1;
1051 w = x2 - x1;
1052 h = y2 - y1;
1053
Tomi Valkeinenf49a9512010-03-26 16:26:37 +02001054 make_even(&x, &w);
1055
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001056 DSSDBG("changing upd area due to ovl(%d) scaling %d,%d %dx%d\n",
1057 i, x, y, w, h);
1058 }
1059
1060 mc = &dss_cache.manager_cache[mgr->id];
1061 mc->do_manual_update = true;
1062 mc->x = x;
1063 mc->y = y;
1064 mc->w = w;
1065 mc->h = h;
1066
1067 configure_dispc();
1068
1069 mc->do_manual_update = false;
1070
1071 spin_unlock_irqrestore(&dss_cache.lock, flags);
1072
1073 *xi = x;
1074 *yi = y;
1075 *wi = w;
1076 *hi = h;
1077}
1078
1079void dss_start_update(struct omap_dss_device *dssdev)
1080{
1081 struct manager_cache_data *mc;
1082 struct overlay_cache_data *oc;
1083 const int num_ovls = ARRAY_SIZE(dss_cache.overlay_cache);
1084 const int num_mgrs = ARRAY_SIZE(dss_cache.manager_cache);
1085 struct omap_overlay_manager *mgr;
1086 int i;
1087
1088 mgr = dssdev->manager;
1089
1090 for (i = 0; i < num_ovls; ++i) {
1091 oc = &dss_cache.overlay_cache[i];
1092 if (oc->channel != mgr->id)
1093 continue;
1094
1095 oc->shadow_dirty = false;
1096 }
1097
1098 for (i = 0; i < num_mgrs; ++i) {
1099 mc = &dss_cache.manager_cache[i];
1100 if (mgr->id != i)
1101 continue;
1102
1103 mc->shadow_dirty = false;
1104 }
1105
Tomi Valkeinena2faee82010-01-08 17:14:53 +02001106 dssdev->manager->enable(dssdev->manager);
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001107}
1108
1109static void dss_apply_irq_handler(void *data, u32 mask)
1110{
1111 struct manager_cache_data *mc;
1112 struct overlay_cache_data *oc;
1113 const int num_ovls = ARRAY_SIZE(dss_cache.overlay_cache);
1114 const int num_mgrs = ARRAY_SIZE(dss_cache.manager_cache);
1115 int i, r;
1116 bool mgr_busy[2];
1117
1118 mgr_busy[0] = dispc_go_busy(0);
1119 mgr_busy[1] = dispc_go_busy(1);
1120
1121 spin_lock(&dss_cache.lock);
1122
1123 for (i = 0; i < num_ovls; ++i) {
1124 oc = &dss_cache.overlay_cache[i];
1125 if (!mgr_busy[oc->channel])
1126 oc->shadow_dirty = false;
1127 }
1128
1129 for (i = 0; i < num_mgrs; ++i) {
1130 mc = &dss_cache.manager_cache[i];
1131 if (!mgr_busy[i])
1132 mc->shadow_dirty = false;
1133 }
1134
1135 r = configure_dispc();
1136 if (r == 1)
1137 goto end;
1138
1139 /* re-read busy flags */
1140 mgr_busy[0] = dispc_go_busy(0);
1141 mgr_busy[1] = dispc_go_busy(1);
1142
1143 /* keep running as long as there are busy managers, so that
1144 * we can collect overlay-applied information */
1145 for (i = 0; i < num_mgrs; ++i) {
1146 if (mgr_busy[i])
1147 goto end;
1148 }
1149
1150 omap_dispc_unregister_isr(dss_apply_irq_handler, NULL,
1151 DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_ODD |
1152 DISPC_IRQ_EVSYNC_EVEN);
1153 dss_cache.irq_enabled = false;
1154
1155end:
1156 spin_unlock(&dss_cache.lock);
1157}
1158
1159static int omap_dss_mgr_apply(struct omap_overlay_manager *mgr)
1160{
1161 struct overlay_cache_data *oc;
1162 struct manager_cache_data *mc;
1163 int i;
1164 struct omap_overlay *ovl;
1165 int num_planes_enabled = 0;
1166 bool use_fifomerge;
1167 unsigned long flags;
1168 int r;
1169
1170 DSSDBG("omap_dss_mgr_apply(%s)\n", mgr->name);
1171
1172 spin_lock_irqsave(&dss_cache.lock, flags);
1173
1174 /* Configure overlays */
1175 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
1176 struct omap_dss_device *dssdev;
1177
1178 ovl = omap_dss_get_overlay(i);
1179
1180 if (!(ovl->caps & OMAP_DSS_OVL_CAP_DISPC))
1181 continue;
1182
1183 oc = &dss_cache.overlay_cache[ovl->id];
1184
1185 if (!overlay_enabled(ovl)) {
1186 if (oc->enabled) {
1187 oc->enabled = false;
1188 oc->dirty = true;
1189 }
1190 continue;
1191 }
1192
1193 if (!ovl->info_dirty) {
1194 if (oc->enabled)
1195 ++num_planes_enabled;
1196 continue;
1197 }
1198
1199 dssdev = ovl->manager->device;
1200
1201 if (dss_check_overlay(ovl, dssdev)) {
1202 if (oc->enabled) {
1203 oc->enabled = false;
1204 oc->dirty = true;
1205 }
1206 continue;
1207 }
1208
1209 ovl->info_dirty = false;
1210 oc->dirty = true;
1211
1212 oc->paddr = ovl->info.paddr;
1213 oc->vaddr = ovl->info.vaddr;
1214 oc->screen_width = ovl->info.screen_width;
1215 oc->width = ovl->info.width;
1216 oc->height = ovl->info.height;
1217 oc->color_mode = ovl->info.color_mode;
1218 oc->rotation = ovl->info.rotation;
1219 oc->rotation_type = ovl->info.rotation_type;
1220 oc->mirror = ovl->info.mirror;
1221 oc->pos_x = ovl->info.pos_x;
1222 oc->pos_y = ovl->info.pos_y;
1223 oc->out_width = ovl->info.out_width;
1224 oc->out_height = ovl->info.out_height;
1225 oc->global_alpha = ovl->info.global_alpha;
1226
1227 oc->replication =
1228 dss_use_replication(dssdev, ovl->info.color_mode);
1229
1230 oc->ilace = dssdev->type == OMAP_DISPLAY_TYPE_VENC;
1231
1232 oc->channel = ovl->manager->id;
1233
1234 oc->enabled = true;
1235
1236 oc->manual_update =
1237 dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE &&
Tomi Valkeinen446f7bf2010-01-11 16:12:31 +02001238 dssdev->driver->get_update_mode(dssdev) !=
1239 OMAP_DSS_UPDATE_AUTO;
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001240
1241 ++num_planes_enabled;
1242 }
1243
1244 /* Configure managers */
1245 list_for_each_entry(mgr, &manager_list, list) {
1246 struct omap_dss_device *dssdev;
1247
1248 if (!(mgr->caps & OMAP_DSS_OVL_MGR_CAP_DISPC))
1249 continue;
1250
1251 mc = &dss_cache.manager_cache[mgr->id];
1252
1253 if (mgr->device_changed) {
1254 mgr->device_changed = false;
1255 mgr->info_dirty = true;
1256 }
1257
1258 if (!mgr->info_dirty)
1259 continue;
1260
1261 if (!mgr->device)
1262 continue;
1263
1264 dssdev = mgr->device;
1265
1266 mgr->info_dirty = false;
1267 mc->dirty = true;
1268
1269 mc->default_color = mgr->info.default_color;
1270 mc->trans_key_type = mgr->info.trans_key_type;
1271 mc->trans_key = mgr->info.trans_key;
1272 mc->trans_enabled = mgr->info.trans_enabled;
1273 mc->alpha_enabled = mgr->info.alpha_enabled;
1274
1275 mc->manual_upd_display =
1276 dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE;
1277
1278 mc->manual_update =
1279 dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE &&
Tomi Valkeinen446f7bf2010-01-11 16:12:31 +02001280 dssdev->driver->get_update_mode(dssdev) !=
1281 OMAP_DSS_UPDATE_AUTO;
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001282 }
1283
1284 /* XXX TODO: Try to get fifomerge working. The problem is that it
1285 * affects both managers, not individually but at the same time. This
1286 * means the change has to be well synchronized. I guess the proper way
1287 * is to have a two step process for fifo merge:
1288 * fifomerge enable:
1289 * 1. disable other planes, leaving one plane enabled
1290 * 2. wait until the planes are disabled on HW
1291 * 3. config merged fifo thresholds, enable fifomerge
1292 * fifomerge disable:
1293 * 1. config unmerged fifo thresholds, disable fifomerge
1294 * 2. wait until fifo changes are in HW
1295 * 3. enable planes
1296 */
1297 use_fifomerge = false;
1298
1299 /* Configure overlay fifos */
1300 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
1301 struct omap_dss_device *dssdev;
1302 u32 size;
1303
1304 ovl = omap_dss_get_overlay(i);
1305
1306 if (!(ovl->caps & OMAP_DSS_OVL_CAP_DISPC))
1307 continue;
1308
1309 oc = &dss_cache.overlay_cache[ovl->id];
1310
1311 if (!oc->enabled)
1312 continue;
1313
1314 dssdev = ovl->manager->device;
1315
1316 size = dispc_get_plane_fifo_size(ovl->id);
1317 if (use_fifomerge)
1318 size *= 3;
1319
1320 switch (dssdev->type) {
1321 case OMAP_DISPLAY_TYPE_DPI:
1322 case OMAP_DISPLAY_TYPE_DBI:
1323 case OMAP_DISPLAY_TYPE_SDI:
1324 case OMAP_DISPLAY_TYPE_VENC:
1325 default_get_overlay_fifo_thresholds(ovl->id, size,
1326 &oc->burst_size, &oc->fifo_low,
1327 &oc->fifo_high);
1328 break;
1329#ifdef CONFIG_OMAP2_DSS_DSI
1330 case OMAP_DISPLAY_TYPE_DSI:
1331 dsi_get_overlay_fifo_thresholds(ovl->id, size,
1332 &oc->burst_size, &oc->fifo_low,
1333 &oc->fifo_high);
1334 break;
1335#endif
1336 default:
1337 BUG();
1338 }
1339 }
1340
1341 r = 0;
1342 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
1343 if (!dss_cache.irq_enabled) {
1344 r = omap_dispc_register_isr(dss_apply_irq_handler, NULL,
1345 DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_ODD |
1346 DISPC_IRQ_EVSYNC_EVEN);
1347 dss_cache.irq_enabled = true;
1348 }
1349 configure_dispc();
1350 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
1351
1352 spin_unlock_irqrestore(&dss_cache.lock, flags);
1353
1354 return r;
1355}
1356
1357static int dss_check_manager(struct omap_overlay_manager *mgr)
1358{
1359 /* OMAP supports only graphics source transparency color key and alpha
1360 * blending simultaneously. See TRM 15.4.2.4.2.2 Alpha Mode */
1361
1362 if (mgr->info.alpha_enabled && mgr->info.trans_enabled &&
1363 mgr->info.trans_key_type != OMAP_DSS_COLOR_KEY_GFX_DST)
1364 return -EINVAL;
1365
1366 return 0;
1367}
1368
1369static int omap_dss_mgr_set_info(struct omap_overlay_manager *mgr,
1370 struct omap_overlay_manager_info *info)
1371{
1372 int r;
1373 struct omap_overlay_manager_info old_info;
1374
1375 old_info = mgr->info;
1376 mgr->info = *info;
1377
1378 r = dss_check_manager(mgr);
1379 if (r) {
1380 mgr->info = old_info;
1381 return r;
1382 }
1383
1384 mgr->info_dirty = true;
1385
1386 return 0;
1387}
1388
1389static void omap_dss_mgr_get_info(struct omap_overlay_manager *mgr,
1390 struct omap_overlay_manager_info *info)
1391{
1392 *info = mgr->info;
1393}
1394
Tomi Valkeinena2faee82010-01-08 17:14:53 +02001395static int dss_mgr_enable(struct omap_overlay_manager *mgr)
1396{
1397 dispc_enable_channel(mgr->id, 1);
1398 return 0;
1399}
1400
1401static int dss_mgr_disable(struct omap_overlay_manager *mgr)
1402{
1403 dispc_enable_channel(mgr->id, 0);
1404 return 0;
1405}
1406
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001407static void omap_dss_add_overlay_manager(struct omap_overlay_manager *manager)
1408{
1409 ++num_managers;
1410 list_add_tail(&manager->list, &manager_list);
1411}
1412
1413int dss_init_overlay_managers(struct platform_device *pdev)
1414{
1415 int i, r;
1416
1417 spin_lock_init(&dss_cache.lock);
1418
1419 INIT_LIST_HEAD(&manager_list);
1420
1421 num_managers = 0;
1422
1423 for (i = 0; i < 2; ++i) {
1424 struct omap_overlay_manager *mgr;
1425 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
1426
1427 BUG_ON(mgr == NULL);
1428
1429 switch (i) {
1430 case 0:
1431 mgr->name = "lcd";
1432 mgr->id = OMAP_DSS_CHANNEL_LCD;
1433 mgr->supported_displays =
1434 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
1435 OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI;
1436 break;
1437 case 1:
1438 mgr->name = "tv";
1439 mgr->id = OMAP_DSS_CHANNEL_DIGIT;
1440 mgr->supported_displays = OMAP_DISPLAY_TYPE_VENC;
1441 break;
1442 }
1443
1444 mgr->set_device = &omap_dss_set_device;
1445 mgr->unset_device = &omap_dss_unset_device;
1446 mgr->apply = &omap_dss_mgr_apply;
1447 mgr->set_manager_info = &omap_dss_mgr_set_info;
1448 mgr->get_manager_info = &omap_dss_mgr_get_info;
1449 mgr->wait_for_go = &dss_mgr_wait_for_go;
Tomi Valkeinen3f71cbe2010-01-08 17:06:04 +02001450 mgr->wait_for_vsync = &dss_mgr_wait_for_vsync;
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001451
Tomi Valkeinena2faee82010-01-08 17:14:53 +02001452 mgr->enable = &dss_mgr_enable;
1453 mgr->disable = &dss_mgr_disable;
1454
Tomi Valkeineneed07e02009-08-07 13:43:20 +03001455 mgr->caps = OMAP_DSS_OVL_MGR_CAP_DISPC;
1456
1457 dss_overlay_setup_dispc_manager(mgr);
1458
1459 omap_dss_add_overlay_manager(mgr);
1460
1461 r = kobject_init_and_add(&mgr->kobj, &manager_ktype,
1462 &pdev->dev.kobj, "manager%d", i);
1463
1464 if (r) {
1465 DSSERR("failed to create sysfs file\n");
1466 continue;
1467 }
1468 }
1469
1470#ifdef L4_EXAMPLE
1471 {
1472 int omap_dss_mgr_apply_l4(struct omap_overlay_manager *mgr)
1473 {
1474 DSSDBG("omap_dss_mgr_apply_l4(%s)\n", mgr->name);
1475
1476 return 0;
1477 }
1478
1479 struct omap_overlay_manager *mgr;
1480 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
1481
1482 BUG_ON(mgr == NULL);
1483
1484 mgr->name = "l4";
1485 mgr->supported_displays =
1486 OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI;
1487
1488 mgr->set_device = &omap_dss_set_device;
1489 mgr->unset_device = &omap_dss_unset_device;
1490 mgr->apply = &omap_dss_mgr_apply_l4;
1491 mgr->set_manager_info = &omap_dss_mgr_set_info;
1492 mgr->get_manager_info = &omap_dss_mgr_get_info;
1493
1494 dss_overlay_setup_l4_manager(mgr);
1495
1496 omap_dss_add_overlay_manager(mgr);
1497
1498 r = kobject_init_and_add(&mgr->kobj, &manager_ktype,
1499 &pdev->dev.kobj, "managerl4");
1500
1501 if (r)
1502 DSSERR("failed to create sysfs file\n");
1503 }
1504#endif
1505
1506 return 0;
1507}
1508
1509void dss_uninit_overlay_managers(struct platform_device *pdev)
1510{
1511 struct omap_overlay_manager *mgr;
1512
1513 while (!list_empty(&manager_list)) {
1514 mgr = list_first_entry(&manager_list,
1515 struct omap_overlay_manager, list);
1516 list_del(&mgr->list);
1517 kobject_del(&mgr->kobj);
1518 kobject_put(&mgr->kobj);
1519 kfree(mgr);
1520 }
1521
1522 num_managers = 0;
1523}
1524
1525int omap_dss_get_num_overlay_managers(void)
1526{
1527 return num_managers;
1528}
1529EXPORT_SYMBOL(omap_dss_get_num_overlay_managers);
1530
1531struct omap_overlay_manager *omap_dss_get_overlay_manager(int num)
1532{
1533 int i = 0;
1534 struct omap_overlay_manager *mgr;
1535
1536 list_for_each_entry(mgr, &manager_list, list) {
1537 if (i++ == num)
1538 return mgr;
1539 }
1540
1541 return NULL;
1542}
1543EXPORT_SYMBOL(omap_dss_get_overlay_manager);
1544