2 * linux/drivers/video/omap2/dss/manager.c
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
7 * Some code and ideas taken from drivers/video/omap/ driver
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.
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
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/>.
23 #define DSS_SUBSYS_NAME "MANAGER"
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/platform_device.h>
28 #include <linux/spinlock.h>
29 #include <linux/jiffies.h>
31 #include <plat/display.h>
36 static int num_managers
;
37 static struct list_head manager_list
;
39 static ssize_t
manager_name_show(struct omap_overlay_manager
*mgr
, char *buf
)
41 return snprintf(buf
, PAGE_SIZE
, "%s\n", mgr
->name
);
44 static ssize_t
manager_display_show(struct omap_overlay_manager
*mgr
, char *buf
)
46 return snprintf(buf
, PAGE_SIZE
, "%s\n",
47 mgr
->device
? mgr
->device
->name
: "<none>");
50 static ssize_t
manager_display_store(struct omap_overlay_manager
*mgr
,
51 const char *buf
, size_t size
)
55 struct omap_dss_device
*dssdev
= NULL
;
57 int match(struct omap_dss_device
*dssdev
, void *data
)
59 const char *str
= data
;
60 return sysfs_streq(dssdev
->name
, str
);
63 if (buf
[size
-1] == '\n')
67 dssdev
= omap_dss_find_device((void *)buf
, match
);
69 if (len
> 0 && dssdev
== NULL
)
73 DSSDBG("display %s found\n", dssdev
->name
);
76 r
= mgr
->unset_device(mgr
);
78 DSSERR("failed to unset display\n");
84 r
= mgr
->set_device(mgr
, dssdev
);
86 DSSERR("failed to set manager\n");
92 DSSERR("failed to apply dispc config\n");
99 omap_dss_put_device(dssdev
);
104 static ssize_t
manager_default_color_show(struct omap_overlay_manager
*mgr
,
107 return snprintf(buf
, PAGE_SIZE
, "%d\n", mgr
->info
.default_color
);
110 static ssize_t
manager_default_color_store(struct omap_overlay_manager
*mgr
,
111 const char *buf
, size_t size
)
113 struct omap_overlay_manager_info info
;
117 if (sscanf(buf
, "%d", &color
) != 1)
120 mgr
->get_manager_info(mgr
, &info
);
122 info
.default_color
= color
;
124 r
= mgr
->set_manager_info(mgr
, &info
);
135 static const char *trans_key_type_str
[] = {
140 static ssize_t
manager_trans_key_type_show(struct omap_overlay_manager
*mgr
,
143 enum omap_dss_trans_key_type key_type
;
145 key_type
= mgr
->info
.trans_key_type
;
146 BUG_ON(key_type
>= ARRAY_SIZE(trans_key_type_str
));
148 return snprintf(buf
, PAGE_SIZE
, "%s\n", trans_key_type_str
[key_type
]);
151 static ssize_t
manager_trans_key_type_store(struct omap_overlay_manager
*mgr
,
152 const char *buf
, size_t size
)
154 enum omap_dss_trans_key_type key_type
;
155 struct omap_overlay_manager_info info
;
158 for (key_type
= OMAP_DSS_COLOR_KEY_GFX_DST
;
159 key_type
< ARRAY_SIZE(trans_key_type_str
); key_type
++) {
160 if (sysfs_streq(buf
, trans_key_type_str
[key_type
]))
164 if (key_type
== ARRAY_SIZE(trans_key_type_str
))
167 mgr
->get_manager_info(mgr
, &info
);
169 info
.trans_key_type
= key_type
;
171 r
= mgr
->set_manager_info(mgr
, &info
);
182 static ssize_t
manager_trans_key_value_show(struct omap_overlay_manager
*mgr
,
185 return snprintf(buf
, PAGE_SIZE
, "%d\n", mgr
->info
.trans_key
);
188 static ssize_t
manager_trans_key_value_store(struct omap_overlay_manager
*mgr
,
189 const char *buf
, size_t size
)
191 struct omap_overlay_manager_info info
;
195 if (sscanf(buf
, "%d", &key_value
) != 1)
198 mgr
->get_manager_info(mgr
, &info
);
200 info
.trans_key
= key_value
;
202 r
= mgr
->set_manager_info(mgr
, &info
);
213 static ssize_t
manager_trans_key_enabled_show(struct omap_overlay_manager
*mgr
,
216 return snprintf(buf
, PAGE_SIZE
, "%d\n", mgr
->info
.trans_enabled
);
219 static ssize_t
manager_trans_key_enabled_store(struct omap_overlay_manager
*mgr
,
220 const char *buf
, size_t size
)
222 struct omap_overlay_manager_info info
;
226 if (sscanf(buf
, "%d", &enable
) != 1)
229 mgr
->get_manager_info(mgr
, &info
);
231 info
.trans_enabled
= enable
? true : false;
233 r
= mgr
->set_manager_info(mgr
, &info
);
244 static ssize_t
manager_alpha_blending_enabled_show(
245 struct omap_overlay_manager
*mgr
, char *buf
)
247 return snprintf(buf
, PAGE_SIZE
, "%d\n", mgr
->info
.alpha_enabled
);
250 static ssize_t
manager_alpha_blending_enabled_store(
251 struct omap_overlay_manager
*mgr
,
252 const char *buf
, size_t size
)
254 struct omap_overlay_manager_info info
;
258 if (sscanf(buf
, "%d", &enable
) != 1)
261 mgr
->get_manager_info(mgr
, &info
);
263 info
.alpha_enabled
= enable
? true : false;
265 r
= mgr
->set_manager_info(mgr
, &info
);
276 struct manager_attribute
{
277 struct attribute attr
;
278 ssize_t (*show
)(struct omap_overlay_manager
*, char *);
279 ssize_t (*store
)(struct omap_overlay_manager
*, const char *, size_t);
282 #define MANAGER_ATTR(_name, _mode, _show, _store) \
283 struct manager_attribute manager_attr_##_name = \
284 __ATTR(_name, _mode, _show, _store)
286 static MANAGER_ATTR(name
, S_IRUGO
, manager_name_show
, NULL
);
287 static MANAGER_ATTR(display
, S_IRUGO
|S_IWUSR
,
288 manager_display_show
, manager_display_store
);
289 static MANAGER_ATTR(default_color
, S_IRUGO
|S_IWUSR
,
290 manager_default_color_show
, manager_default_color_store
);
291 static MANAGER_ATTR(trans_key_type
, S_IRUGO
|S_IWUSR
,
292 manager_trans_key_type_show
, manager_trans_key_type_store
);
293 static MANAGER_ATTR(trans_key_value
, S_IRUGO
|S_IWUSR
,
294 manager_trans_key_value_show
, manager_trans_key_value_store
);
295 static MANAGER_ATTR(trans_key_enabled
, S_IRUGO
|S_IWUSR
,
296 manager_trans_key_enabled_show
,
297 manager_trans_key_enabled_store
);
298 static MANAGER_ATTR(alpha_blending_enabled
, S_IRUGO
|S_IWUSR
,
299 manager_alpha_blending_enabled_show
,
300 manager_alpha_blending_enabled_store
);
303 static struct attribute
*manager_sysfs_attrs
[] = {
304 &manager_attr_name
.attr
,
305 &manager_attr_display
.attr
,
306 &manager_attr_default_color
.attr
,
307 &manager_attr_trans_key_type
.attr
,
308 &manager_attr_trans_key_value
.attr
,
309 &manager_attr_trans_key_enabled
.attr
,
310 &manager_attr_alpha_blending_enabled
.attr
,
314 static ssize_t
manager_attr_show(struct kobject
*kobj
, struct attribute
*attr
,
317 struct omap_overlay_manager
*manager
;
318 struct manager_attribute
*manager_attr
;
320 manager
= container_of(kobj
, struct omap_overlay_manager
, kobj
);
321 manager_attr
= container_of(attr
, struct manager_attribute
, attr
);
323 if (!manager_attr
->show
)
326 return manager_attr
->show(manager
, buf
);
329 static ssize_t
manager_attr_store(struct kobject
*kobj
, struct attribute
*attr
,
330 const char *buf
, size_t size
)
332 struct omap_overlay_manager
*manager
;
333 struct manager_attribute
*manager_attr
;
335 manager
= container_of(kobj
, struct omap_overlay_manager
, kobj
);
336 manager_attr
= container_of(attr
, struct manager_attribute
, attr
);
338 if (!manager_attr
->store
)
341 return manager_attr
->store(manager
, buf
, size
);
344 static struct sysfs_ops manager_sysfs_ops
= {
345 .show
= manager_attr_show
,
346 .store
= manager_attr_store
,
349 static struct kobj_type manager_ktype
= {
350 .sysfs_ops
= &manager_sysfs_ops
,
351 .default_attrs
= manager_sysfs_attrs
,
355 * We have 4 levels of cache for the dispc settings. First two are in SW and
356 * the latter two in HW.
358 * +--------------------+
359 * |overlay/manager_info|
360 * +--------------------+
364 * +--------------------+
366 * +--------------------+
370 * +--------------------+
371 * | shadow registers |
372 * +--------------------+
374 * VFP or lcd/digit_enable
376 * +--------------------+
378 * +--------------------+
381 struct overlay_cache_data
{
382 /* If true, cache changed, but not written to shadow registers. Set
383 * in apply(), cleared when registers written. */
385 /* If true, shadow registers contain changed values not yet in real
386 * registers. Set when writing to shadow registers, cleared at
397 enum omap_color_mode color_mode
;
399 enum omap_dss_rotation_type rotation_type
;
404 u16 out_width
; /* if 0, out_width == width */
405 u16 out_height
; /* if 0, out_height == height */
408 enum omap_channel channel
;
412 enum omap_burst_size burst_size
;
419 struct manager_cache_data
{
420 /* If true, cache changed, but not written to shadow registers. Set
421 * in apply(), cleared when registers written. */
423 /* If true, shadow registers contain changed values not yet in real
424 * registers. Set when writing to shadow registers, cleared at
430 enum omap_dss_trans_key_type trans_key_type
;
436 bool manual_upd_display
;
438 bool do_manual_update
;
440 /* manual update region */
446 struct overlay_cache_data overlay_cache
[3];
447 struct manager_cache_data manager_cache
[2];
454 static int omap_dss_set_device(struct omap_overlay_manager
*mgr
,
455 struct omap_dss_device
*dssdev
)
460 if (dssdev
->manager
) {
461 DSSERR("display '%s' already has a manager '%s'\n",
462 dssdev
->name
, dssdev
->manager
->name
);
466 if ((mgr
->supported_displays
& dssdev
->type
) == 0) {
467 DSSERR("display '%s' does not support manager '%s'\n",
468 dssdev
->name
, mgr
->name
);
472 for (i
= 0; i
< mgr
->num_overlays
; i
++) {
473 struct omap_overlay
*ovl
= mgr
->overlays
[i
];
475 if (ovl
->manager
!= mgr
|| !ovl
->info
.enabled
)
478 r
= dss_check_overlay(ovl
, dssdev
);
483 dssdev
->manager
= mgr
;
484 mgr
->device
= dssdev
;
485 mgr
->device_changed
= true;
490 static int omap_dss_unset_device(struct omap_overlay_manager
*mgr
)
493 DSSERR("failed to unset display, display not set.\n");
497 mgr
->device
->manager
= NULL
;
499 mgr
->device_changed
= true;
504 static int dss_mgr_wait_for_go(struct omap_overlay_manager
*mgr
)
506 unsigned long timeout
= msecs_to_jiffies(500);
507 struct manager_cache_data
*mc
;
508 enum omap_channel channel
;
516 if (mgr
->device
->type
== OMAP_DISPLAY_TYPE_VENC
) {
517 irq
= DISPC_IRQ_EVSYNC_ODD
| DISPC_IRQ_EVSYNC_EVEN
;
518 channel
= OMAP_DSS_CHANNEL_DIGIT
;
520 if (mgr
->device
->caps
& OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE
) {
521 enum omap_dss_update_mode mode
;
522 mode
= mgr
->device
->get_update_mode(mgr
->device
);
523 if (mode
!= OMAP_DSS_UPDATE_AUTO
)
526 irq
= DISPC_IRQ_FRAMEDONE
;
528 irq
= DISPC_IRQ_VSYNC
;
530 channel
= OMAP_DSS_CHANNEL_LCD
;
533 mc
= &dss_cache
.manager_cache
[mgr
->id
];
537 bool shadow_dirty
, dirty
;
539 spin_lock_irqsave(&dss_cache
.lock
, flags
);
541 shadow_dirty
= mc
->shadow_dirty
;
542 spin_unlock_irqrestore(&dss_cache
.lock
, flags
);
544 if (!dirty
&& !shadow_dirty
) {
549 /* 4 iterations is the worst case:
550 * 1 - initial iteration, dirty = true (between VFP and VSYNC)
551 * 2 - first VSYNC, dirty = true
552 * 3 - dirty = false, shadow_dirty = true
553 * 4 - shadow_dirty = false */
555 DSSERR("mgr(%d)->wait_for_go() not finishing\n",
561 r
= omap_dispc_wait_for_irq_interruptible_timeout(irq
, timeout
);
562 if (r
== -ERESTARTSYS
)
566 DSSERR("mgr(%d)->wait_for_go() timeout\n", mgr
->id
);
574 int dss_mgr_wait_for_go_ovl(struct omap_overlay
*ovl
)
576 unsigned long timeout
= msecs_to_jiffies(500);
577 enum omap_channel channel
;
578 struct overlay_cache_data
*oc
;
579 struct omap_dss_device
*dssdev
;
584 if (!ovl
->manager
|| !ovl
->manager
->device
)
587 dssdev
= ovl
->manager
->device
;
589 if (dssdev
->type
== OMAP_DISPLAY_TYPE_VENC
) {
590 irq
= DISPC_IRQ_EVSYNC_ODD
| DISPC_IRQ_EVSYNC_EVEN
;
591 channel
= OMAP_DSS_CHANNEL_DIGIT
;
593 if (dssdev
->caps
& OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE
) {
594 enum omap_dss_update_mode mode
;
595 mode
= dssdev
->get_update_mode(dssdev
);
596 if (mode
!= OMAP_DSS_UPDATE_AUTO
)
599 irq
= DISPC_IRQ_FRAMEDONE
;
601 irq
= DISPC_IRQ_VSYNC
;
603 channel
= OMAP_DSS_CHANNEL_LCD
;
606 oc
= &dss_cache
.overlay_cache
[ovl
->id
];
610 bool shadow_dirty
, dirty
;
612 spin_lock_irqsave(&dss_cache
.lock
, flags
);
614 shadow_dirty
= oc
->shadow_dirty
;
615 spin_unlock_irqrestore(&dss_cache
.lock
, flags
);
617 if (!dirty
&& !shadow_dirty
) {
622 /* 4 iterations is the worst case:
623 * 1 - initial iteration, dirty = true (between VFP and VSYNC)
624 * 2 - first VSYNC, dirty = true
625 * 3 - dirty = false, shadow_dirty = true
626 * 4 - shadow_dirty = false */
628 DSSERR("ovl(%d)->wait_for_go() not finishing\n",
634 r
= omap_dispc_wait_for_irq_interruptible_timeout(irq
, timeout
);
635 if (r
== -ERESTARTSYS
)
639 DSSERR("ovl(%d)->wait_for_go() timeout\n", ovl
->id
);
647 static int overlay_enabled(struct omap_overlay
*ovl
)
649 return ovl
->info
.enabled
&& ovl
->manager
&& ovl
->manager
->device
;
652 /* Is rect1 a subset of rect2? */
653 static bool rectangle_subset(int x1
, int y1
, int w1
, int h1
,
654 int x2
, int y2
, int w2
, int h2
)
656 if (x1
< x2
|| y1
< y2
)
659 if (x1
+ w1
> x2
+ w2
)
662 if (y1
+ h1
> y2
+ h2
)
668 /* Do rect1 and rect2 overlap? */
669 static bool rectangle_intersects(int x1
, int y1
, int w1
, int h1
,
670 int x2
, int y2
, int w2
, int h2
)
687 static bool dispc_is_overlay_scaled(struct overlay_cache_data
*oc
)
689 if (oc
->out_width
!= 0 && oc
->width
!= oc
->out_width
)
692 if (oc
->out_height
!= 0 && oc
->height
!= oc
->out_height
)
698 static int configure_overlay(enum omap_plane plane
)
700 struct overlay_cache_data
*c
;
701 struct manager_cache_data
*mc
;
707 DSSDBGF("%d", plane
);
709 c
= &dss_cache
.overlay_cache
[plane
];
712 dispc_enable_plane(plane
, 0);
716 mc
= &dss_cache
.manager_cache
[c
->channel
];
722 outw
= c
->out_width
== 0 ? c
->width
: c
->out_width
;
723 outh
= c
->out_height
== 0 ? c
->height
: c
->out_height
;
726 if (c
->manual_update
&& mc
->do_manual_update
) {
728 /* If the overlay is outside the update region, disable it */
729 if (!rectangle_intersects(mc
->x
, mc
->y
, mc
->w
, mc
->h
,
731 dispc_enable_plane(plane
, 0);
735 switch (c
->color_mode
) {
736 case OMAP_DSS_COLOR_RGB16
:
737 case OMAP_DSS_COLOR_ARGB16
:
738 case OMAP_DSS_COLOR_YUV2
:
739 case OMAP_DSS_COLOR_UYVY
:
743 case OMAP_DSS_COLOR_RGB24P
:
747 case OMAP_DSS_COLOR_RGB24U
:
748 case OMAP_DSS_COLOR_ARGB32
:
749 case OMAP_DSS_COLOR_RGBA32
:
750 case OMAP_DSS_COLOR_RGBX32
:
758 if (dispc_is_overlay_scaled(c
)) {
759 /* If the overlay is scaled, the update area has
760 * already been enlarged to cover the whole overlay. We
761 * only need to adjust x/y here */
762 x
= c
->pos_x
- mc
->x
;
763 y
= c
->pos_y
- mc
->y
;
765 if (mc
->x
> c
->pos_x
) {
767 w
-= (mc
->x
- c
->pos_x
);
768 paddr
+= (mc
->x
- c
->pos_x
) * bpp
/ 8;
770 x
= c
->pos_x
- mc
->x
;
773 if (mc
->y
> c
->pos_y
) {
775 h
-= (mc
->y
- c
->pos_y
);
776 paddr
+= (mc
->y
- c
->pos_y
) * c
->screen_width
*
779 y
= c
->pos_y
- mc
->y
;
783 w
-= (x
+w
) - (mc
->w
);
786 h
-= (y
+h
) - (mc
->h
);
793 r
= dispc_setup_plane(plane
,
807 /* this shouldn't happen */
808 DSSERR("dispc_setup_plane failed for ovl %d\n", plane
);
809 dispc_enable_plane(plane
, 0);
813 dispc_enable_replication(plane
, c
->replication
);
815 dispc_set_burst_size(plane
, c
->burst_size
);
816 dispc_setup_plane_fifo(plane
, c
->fifo_low
, c
->fifo_high
);
818 dispc_enable_plane(plane
, 1);
823 static void configure_manager(enum omap_channel channel
)
825 struct manager_cache_data
*c
;
827 DSSDBGF("%d", channel
);
829 c
= &dss_cache
.manager_cache
[channel
];
831 dispc_set_trans_key(channel
, c
->trans_key_type
, c
->trans_key
);
832 dispc_enable_trans_key(channel
, c
->trans_enabled
);
833 dispc_enable_alpha_blending(channel
, c
->alpha_enabled
);
836 /* configure_dispc() tries to write values from cache to shadow registers.
837 * It writes only to those managers/overlays that are not busy.
838 * returns 0 if everything could be written to shadow registers.
839 * returns 1 if not everything could be written to shadow registers. */
840 static int configure_dispc(void)
842 struct overlay_cache_data
*oc
;
843 struct manager_cache_data
*mc
;
844 const int num_ovls
= ARRAY_SIZE(dss_cache
.overlay_cache
);
845 const int num_mgrs
= ARRAY_SIZE(dss_cache
.manager_cache
);
855 mgr_busy
[0] = dispc_go_busy(0);
856 mgr_busy
[1] = dispc_go_busy(1);
860 /* Commit overlay settings */
861 for (i
= 0; i
< num_ovls
; ++i
) {
862 oc
= &dss_cache
.overlay_cache
[i
];
863 mc
= &dss_cache
.manager_cache
[oc
->channel
];
868 if (oc
->manual_update
&& !mc
->do_manual_update
)
871 if (mgr_busy
[oc
->channel
]) {
876 r
= configure_overlay(i
);
878 DSSERR("configure_overlay %d failed\n", i
);
881 oc
->shadow_dirty
= true;
882 mgr_go
[oc
->channel
] = true;
885 /* Commit manager settings */
886 for (i
= 0; i
< num_mgrs
; ++i
) {
887 mc
= &dss_cache
.manager_cache
[i
];
892 if (mc
->manual_update
&& !mc
->do_manual_update
)
900 configure_manager(i
);
902 mc
->shadow_dirty
= true;
907 for (i
= 0; i
< num_mgrs
; ++i
) {
908 mc
= &dss_cache
.manager_cache
[i
];
913 /* We don't need GO with manual update display. LCD iface will
914 * always be turned off after frame, and new settings will be
915 * taken in to use at next update */
916 if (!mc
->manual_upd_display
)
928 /* Configure dispc for partial update. Return possibly modified update
930 void dss_setup_partial_planes(struct omap_dss_device
*dssdev
,
931 u16
*xi
, u16
*yi
, u16
*wi
, u16
*hi
)
933 struct overlay_cache_data
*oc
;
934 struct manager_cache_data
*mc
;
935 const int num_ovls
= ARRAY_SIZE(dss_cache
.overlay_cache
);
936 struct omap_overlay_manager
*mgr
;
946 DSSDBG("dispc_setup_partial_planes %d,%d %dx%d\n",
949 mgr
= dssdev
->manager
;
952 DSSDBG("no manager\n");
956 spin_lock_irqsave(&dss_cache
.lock
, flags
);
958 /* We need to show the whole overlay if it is scaled. So look for
959 * those, and make the update area larger if found.
960 * Also mark the overlay cache dirty */
961 for (i
= 0; i
< num_ovls
; ++i
) {
962 unsigned x1
, y1
, x2
, y2
;
965 oc
= &dss_cache
.overlay_cache
[i
];
967 if (oc
->channel
!= mgr
->id
)
975 if (!dispc_is_overlay_scaled(oc
))
978 outw
= oc
->out_width
== 0 ? oc
->width
: oc
->out_width
;
979 outh
= oc
->out_height
== 0 ? oc
->height
: oc
->out_height
;
981 /* is the overlay outside the update region? */
982 if (!rectangle_intersects(x
, y
, w
, h
,
983 oc
->pos_x
, oc
->pos_y
,
987 /* if the overlay totally inside the update region? */
988 if (rectangle_subset(oc
->pos_x
, oc
->pos_y
, outw
, outh
,
1002 if ((x
+ w
) < (oc
->pos_x
+ outw
))
1003 x2
= oc
->pos_x
+ outw
;
1007 if ((y
+ h
) < (oc
->pos_y
+ outh
))
1008 y2
= oc
->pos_y
+ outh
;
1017 DSSDBG("changing upd area due to ovl(%d) scaling %d,%d %dx%d\n",
1021 mc
= &dss_cache
.manager_cache
[mgr
->id
];
1022 mc
->do_manual_update
= true;
1030 mc
->do_manual_update
= false;
1032 spin_unlock_irqrestore(&dss_cache
.lock
, flags
);
1040 void dss_start_update(struct omap_dss_device
*dssdev
)
1042 struct manager_cache_data
*mc
;
1043 struct overlay_cache_data
*oc
;
1044 const int num_ovls
= ARRAY_SIZE(dss_cache
.overlay_cache
);
1045 const int num_mgrs
= ARRAY_SIZE(dss_cache
.manager_cache
);
1046 struct omap_overlay_manager
*mgr
;
1049 mgr
= dssdev
->manager
;
1051 for (i
= 0; i
< num_ovls
; ++i
) {
1052 oc
= &dss_cache
.overlay_cache
[i
];
1053 if (oc
->channel
!= mgr
->id
)
1056 oc
->shadow_dirty
= false;
1059 for (i
= 0; i
< num_mgrs
; ++i
) {
1060 mc
= &dss_cache
.manager_cache
[i
];
1064 mc
->shadow_dirty
= false;
1067 dispc_enable_lcd_out(1);
1070 static void dss_apply_irq_handler(void *data
, u32 mask
)
1072 struct manager_cache_data
*mc
;
1073 struct overlay_cache_data
*oc
;
1074 const int num_ovls
= ARRAY_SIZE(dss_cache
.overlay_cache
);
1075 const int num_mgrs
= ARRAY_SIZE(dss_cache
.manager_cache
);
1079 mgr_busy
[0] = dispc_go_busy(0);
1080 mgr_busy
[1] = dispc_go_busy(1);
1082 spin_lock(&dss_cache
.lock
);
1084 for (i
= 0; i
< num_ovls
; ++i
) {
1085 oc
= &dss_cache
.overlay_cache
[i
];
1086 if (!mgr_busy
[oc
->channel
])
1087 oc
->shadow_dirty
= false;
1090 for (i
= 0; i
< num_mgrs
; ++i
) {
1091 mc
= &dss_cache
.manager_cache
[i
];
1093 mc
->shadow_dirty
= false;
1096 r
= configure_dispc();
1100 /* re-read busy flags */
1101 mgr_busy
[0] = dispc_go_busy(0);
1102 mgr_busy
[1] = dispc_go_busy(1);
1104 /* keep running as long as there are busy managers, so that
1105 * we can collect overlay-applied information */
1106 for (i
= 0; i
< num_mgrs
; ++i
) {
1111 omap_dispc_unregister_isr(dss_apply_irq_handler
, NULL
,
1112 DISPC_IRQ_VSYNC
| DISPC_IRQ_EVSYNC_ODD
|
1113 DISPC_IRQ_EVSYNC_EVEN
);
1114 dss_cache
.irq_enabled
= false;
1117 spin_unlock(&dss_cache
.lock
);
1120 static int omap_dss_mgr_apply(struct omap_overlay_manager
*mgr
)
1122 struct overlay_cache_data
*oc
;
1123 struct manager_cache_data
*mc
;
1125 struct omap_overlay
*ovl
;
1126 int num_planes_enabled
= 0;
1128 unsigned long flags
;
1131 DSSDBG("omap_dss_mgr_apply(%s)\n", mgr
->name
);
1133 spin_lock_irqsave(&dss_cache
.lock
, flags
);
1135 /* Configure overlays */
1136 for (i
= 0; i
< omap_dss_get_num_overlays(); ++i
) {
1137 struct omap_dss_device
*dssdev
;
1139 ovl
= omap_dss_get_overlay(i
);
1141 if (!(ovl
->caps
& OMAP_DSS_OVL_CAP_DISPC
))
1144 oc
= &dss_cache
.overlay_cache
[ovl
->id
];
1146 if (!overlay_enabled(ovl
)) {
1148 oc
->enabled
= false;
1154 if (!ovl
->info_dirty
) {
1156 ++num_planes_enabled
;
1160 dssdev
= ovl
->manager
->device
;
1162 if (dss_check_overlay(ovl
, dssdev
)) {
1164 oc
->enabled
= false;
1170 ovl
->info_dirty
= false;
1173 oc
->paddr
= ovl
->info
.paddr
;
1174 oc
->vaddr
= ovl
->info
.vaddr
;
1175 oc
->screen_width
= ovl
->info
.screen_width
;
1176 oc
->width
= ovl
->info
.width
;
1177 oc
->height
= ovl
->info
.height
;
1178 oc
->color_mode
= ovl
->info
.color_mode
;
1179 oc
->rotation
= ovl
->info
.rotation
;
1180 oc
->rotation_type
= ovl
->info
.rotation_type
;
1181 oc
->mirror
= ovl
->info
.mirror
;
1182 oc
->pos_x
= ovl
->info
.pos_x
;
1183 oc
->pos_y
= ovl
->info
.pos_y
;
1184 oc
->out_width
= ovl
->info
.out_width
;
1185 oc
->out_height
= ovl
->info
.out_height
;
1186 oc
->global_alpha
= ovl
->info
.global_alpha
;
1189 dss_use_replication(dssdev
, ovl
->info
.color_mode
);
1191 oc
->ilace
= dssdev
->type
== OMAP_DISPLAY_TYPE_VENC
;
1193 oc
->channel
= ovl
->manager
->id
;
1198 dssdev
->caps
& OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE
&&
1199 dssdev
->get_update_mode(dssdev
) != OMAP_DSS_UPDATE_AUTO
;
1201 ++num_planes_enabled
;
1204 /* Configure managers */
1205 list_for_each_entry(mgr
, &manager_list
, list
) {
1206 struct omap_dss_device
*dssdev
;
1208 if (!(mgr
->caps
& OMAP_DSS_OVL_MGR_CAP_DISPC
))
1211 mc
= &dss_cache
.manager_cache
[mgr
->id
];
1213 if (mgr
->device_changed
) {
1214 mgr
->device_changed
= false;
1215 mgr
->info_dirty
= true;
1218 if (!mgr
->info_dirty
)
1224 dssdev
= mgr
->device
;
1226 mgr
->info_dirty
= false;
1229 mc
->default_color
= mgr
->info
.default_color
;
1230 mc
->trans_key_type
= mgr
->info
.trans_key_type
;
1231 mc
->trans_key
= mgr
->info
.trans_key
;
1232 mc
->trans_enabled
= mgr
->info
.trans_enabled
;
1233 mc
->alpha_enabled
= mgr
->info
.alpha_enabled
;
1235 mc
->manual_upd_display
=
1236 dssdev
->caps
& OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE
;
1239 dssdev
->caps
& OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE
&&
1240 dssdev
->get_update_mode(dssdev
) != OMAP_DSS_UPDATE_AUTO
;
1243 /* XXX TODO: Try to get fifomerge working. The problem is that it
1244 * affects both managers, not individually but at the same time. This
1245 * means the change has to be well synchronized. I guess the proper way
1246 * is to have a two step process for fifo merge:
1248 * 1. disable other planes, leaving one plane enabled
1249 * 2. wait until the planes are disabled on HW
1250 * 3. config merged fifo thresholds, enable fifomerge
1251 * fifomerge disable:
1252 * 1. config unmerged fifo thresholds, disable fifomerge
1253 * 2. wait until fifo changes are in HW
1256 use_fifomerge
= false;
1258 /* Configure overlay fifos */
1259 for (i
= 0; i
< omap_dss_get_num_overlays(); ++i
) {
1260 struct omap_dss_device
*dssdev
;
1263 ovl
= omap_dss_get_overlay(i
);
1265 if (!(ovl
->caps
& OMAP_DSS_OVL_CAP_DISPC
))
1268 oc
= &dss_cache
.overlay_cache
[ovl
->id
];
1273 dssdev
= ovl
->manager
->device
;
1275 size
= dispc_get_plane_fifo_size(ovl
->id
);
1279 switch (dssdev
->type
) {
1280 case OMAP_DISPLAY_TYPE_DPI
:
1281 case OMAP_DISPLAY_TYPE_DBI
:
1282 case OMAP_DISPLAY_TYPE_SDI
:
1283 case OMAP_DISPLAY_TYPE_VENC
:
1284 default_get_overlay_fifo_thresholds(ovl
->id
, size
,
1285 &oc
->burst_size
, &oc
->fifo_low
,
1288 #ifdef CONFIG_OMAP2_DSS_DSI
1289 case OMAP_DISPLAY_TYPE_DSI
:
1290 dsi_get_overlay_fifo_thresholds(ovl
->id
, size
,
1291 &oc
->burst_size
, &oc
->fifo_low
,
1301 dss_clk_enable(DSS_CLK_ICK
| DSS_CLK_FCK1
);
1302 if (!dss_cache
.irq_enabled
) {
1303 r
= omap_dispc_register_isr(dss_apply_irq_handler
, NULL
,
1304 DISPC_IRQ_VSYNC
| DISPC_IRQ_EVSYNC_ODD
|
1305 DISPC_IRQ_EVSYNC_EVEN
);
1306 dss_cache
.irq_enabled
= true;
1309 dss_clk_disable(DSS_CLK_ICK
| DSS_CLK_FCK1
);
1311 spin_unlock_irqrestore(&dss_cache
.lock
, flags
);
1316 static int dss_check_manager(struct omap_overlay_manager
*mgr
)
1318 /* OMAP supports only graphics source transparency color key and alpha
1319 * blending simultaneously. See TRM 15.4.2.4.2.2 Alpha Mode */
1321 if (mgr
->info
.alpha_enabled
&& mgr
->info
.trans_enabled
&&
1322 mgr
->info
.trans_key_type
!= OMAP_DSS_COLOR_KEY_GFX_DST
)
1328 static int omap_dss_mgr_set_info(struct omap_overlay_manager
*mgr
,
1329 struct omap_overlay_manager_info
*info
)
1332 struct omap_overlay_manager_info old_info
;
1334 old_info
= mgr
->info
;
1337 r
= dss_check_manager(mgr
);
1339 mgr
->info
= old_info
;
1343 mgr
->info_dirty
= true;
1348 static void omap_dss_mgr_get_info(struct omap_overlay_manager
*mgr
,
1349 struct omap_overlay_manager_info
*info
)
1354 static void omap_dss_add_overlay_manager(struct omap_overlay_manager
*manager
)
1357 list_add_tail(&manager
->list
, &manager_list
);
1360 int dss_init_overlay_managers(struct platform_device
*pdev
)
1364 spin_lock_init(&dss_cache
.lock
);
1366 INIT_LIST_HEAD(&manager_list
);
1370 for (i
= 0; i
< 2; ++i
) {
1371 struct omap_overlay_manager
*mgr
;
1372 mgr
= kzalloc(sizeof(*mgr
), GFP_KERNEL
);
1374 BUG_ON(mgr
== NULL
);
1379 mgr
->id
= OMAP_DSS_CHANNEL_LCD
;
1380 mgr
->supported_displays
=
1381 OMAP_DISPLAY_TYPE_DPI
| OMAP_DISPLAY_TYPE_DBI
|
1382 OMAP_DISPLAY_TYPE_SDI
| OMAP_DISPLAY_TYPE_DSI
;
1386 mgr
->id
= OMAP_DSS_CHANNEL_DIGIT
;
1387 mgr
->supported_displays
= OMAP_DISPLAY_TYPE_VENC
;
1391 mgr
->set_device
= &omap_dss_set_device
;
1392 mgr
->unset_device
= &omap_dss_unset_device
;
1393 mgr
->apply
= &omap_dss_mgr_apply
;
1394 mgr
->set_manager_info
= &omap_dss_mgr_set_info
;
1395 mgr
->get_manager_info
= &omap_dss_mgr_get_info
;
1396 mgr
->wait_for_go
= &dss_mgr_wait_for_go
;
1398 mgr
->caps
= OMAP_DSS_OVL_MGR_CAP_DISPC
;
1400 dss_overlay_setup_dispc_manager(mgr
);
1402 omap_dss_add_overlay_manager(mgr
);
1404 r
= kobject_init_and_add(&mgr
->kobj
, &manager_ktype
,
1405 &pdev
->dev
.kobj
, "manager%d", i
);
1408 DSSERR("failed to create sysfs file\n");
1415 int omap_dss_mgr_apply_l4(struct omap_overlay_manager
*mgr
)
1417 DSSDBG("omap_dss_mgr_apply_l4(%s)\n", mgr
->name
);
1422 struct omap_overlay_manager
*mgr
;
1423 mgr
= kzalloc(sizeof(*mgr
), GFP_KERNEL
);
1425 BUG_ON(mgr
== NULL
);
1428 mgr
->supported_displays
=
1429 OMAP_DISPLAY_TYPE_DBI
| OMAP_DISPLAY_TYPE_DSI
;
1431 mgr
->set_device
= &omap_dss_set_device
;
1432 mgr
->unset_device
= &omap_dss_unset_device
;
1433 mgr
->apply
= &omap_dss_mgr_apply_l4
;
1434 mgr
->set_manager_info
= &omap_dss_mgr_set_info
;
1435 mgr
->get_manager_info
= &omap_dss_mgr_get_info
;
1437 dss_overlay_setup_l4_manager(mgr
);
1439 omap_dss_add_overlay_manager(mgr
);
1441 r
= kobject_init_and_add(&mgr
->kobj
, &manager_ktype
,
1442 &pdev
->dev
.kobj
, "managerl4");
1445 DSSERR("failed to create sysfs file\n");
1452 void dss_uninit_overlay_managers(struct platform_device
*pdev
)
1454 struct omap_overlay_manager
*mgr
;
1456 while (!list_empty(&manager_list
)) {
1457 mgr
= list_first_entry(&manager_list
,
1458 struct omap_overlay_manager
, list
);
1459 list_del(&mgr
->list
);
1460 kobject_del(&mgr
->kobj
);
1461 kobject_put(&mgr
->kobj
);
1468 int omap_dss_get_num_overlay_managers(void)
1470 return num_managers
;
1472 EXPORT_SYMBOL(omap_dss_get_num_overlay_managers
);
1474 struct omap_overlay_manager
*omap_dss_get_overlay_manager(int num
)
1477 struct omap_overlay_manager
*mgr
;
1479 list_for_each_entry(mgr
, &manager_list
, list
) {
1486 EXPORT_SYMBOL(omap_dss_get_overlay_manager
);