2 * Copyright (C) 2011 Texas Instruments
3 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
18 #define DSS_SUBSYS_NAME "APPLY"
20 #include <linux/kernel.h>
21 #include <linux/slab.h>
22 #include <linux/spinlock.h>
23 #include <linux/jiffies.h>
25 #include <video/omapdss.h>
28 #include "dss_features.h"
31 * We have 4 levels of cache for the dispc settings. First two are in SW and
32 * the latter two in HW.
36 * +--------------------+
38 * +--------------------+
42 * +--------------------+
44 * +--------------------+
48 * +--------------------+
49 * | shadow registers |
50 * +--------------------+
52 * VFP or lcd/digit_enable
54 * +--------------------+
56 * +--------------------+
59 struct ovl_priv_data
{
62 struct omap_overlay_info user_info
;
65 struct omap_overlay_info info
;
67 bool shadow_info_dirty
;
69 bool extra_info_dirty
;
70 bool shadow_extra_info_dirty
;
73 enum omap_channel channel
;
74 u32 fifo_low
, fifo_high
;
77 * True if overlay is to be enabled. Used to check and calculate configs
78 * for the overlay before it is enabled in the HW.
83 struct mgr_priv_data
{
86 struct omap_overlay_manager_info user_info
;
89 struct omap_overlay_manager_info info
;
91 bool shadow_info_dirty
;
93 /* If true, GO bit is up and shadow registers cannot be written.
94 * Never true for manual update displays */
97 /* If true, dispc output is enabled */
100 /* If true, a display is enabled using this manager */
105 struct ovl_priv_data ovl_priv_data_array
[MAX_DSS_OVERLAYS
];
106 struct mgr_priv_data mgr_priv_data_array
[MAX_DSS_MANAGERS
];
111 /* protects dss_data */
112 static spinlock_t data_lock
;
113 /* lock for blocking functions */
114 static DEFINE_MUTEX(apply_lock
);
115 static DECLARE_COMPLETION(extra_updated_completion
);
117 static void dss_register_vsync_isr(void);
119 static struct ovl_priv_data
*get_ovl_priv(struct omap_overlay
*ovl
)
121 return &dss_data
.ovl_priv_data_array
[ovl
->id
];
124 static struct mgr_priv_data
*get_mgr_priv(struct omap_overlay_manager
*mgr
)
126 return &dss_data
.mgr_priv_data_array
[mgr
->id
];
129 void dss_apply_init(void)
131 const int num_ovls
= dss_feat_get_num_ovls();
134 spin_lock_init(&data_lock
);
136 for (i
= 0; i
< num_ovls
; ++i
) {
137 struct ovl_priv_data
*op
;
139 op
= &dss_data
.ovl_priv_data_array
[i
];
141 op
->info
.global_alpha
= 255;
149 dss_has_feature(FEAT_ALPHA_FREE_ZORDER
) ? 3 : 0;
153 dss_has_feature(FEAT_ALPHA_FREE_ZORDER
) ? 2 : 0;
157 dss_has_feature(FEAT_ALPHA_FREE_ZORDER
) ? 1 : 0;
161 op
->user_info
= op
->info
;
165 static bool ovl_manual_update(struct omap_overlay
*ovl
)
167 return ovl
->manager
->device
->caps
& OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE
;
170 static bool mgr_manual_update(struct omap_overlay_manager
*mgr
)
172 return mgr
->device
->caps
& OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE
;
175 static int dss_check_settings_low(struct omap_overlay_manager
*mgr
,
176 struct omap_dss_device
*dssdev
, bool applying
)
178 struct omap_overlay_info
*oi
;
179 struct omap_overlay_manager_info
*mi
;
180 struct omap_overlay
*ovl
;
181 struct omap_overlay_info
*ois
[MAX_DSS_OVERLAYS
];
182 struct ovl_priv_data
*op
;
183 struct mgr_priv_data
*mp
;
185 mp
= get_mgr_priv(mgr
);
187 if (applying
&& mp
->user_info_dirty
)
192 /* collect the infos to be tested into the array */
193 list_for_each_entry(ovl
, &mgr
->overlays
, list
) {
194 op
= get_ovl_priv(ovl
);
196 if (!op
->enabled
&& !op
->enabling
)
198 else if (applying
&& op
->user_info_dirty
)
206 return dss_mgr_check(mgr
, dssdev
, mi
, ois
);
210 * check manager and overlay settings using overlay_info from data->info
212 static int dss_check_settings(struct omap_overlay_manager
*mgr
,
213 struct omap_dss_device
*dssdev
)
215 return dss_check_settings_low(mgr
, dssdev
, false);
219 * check manager and overlay settings using overlay_info from ovl->info if
220 * dirty and from data->info otherwise
222 static int dss_check_settings_apply(struct omap_overlay_manager
*mgr
,
223 struct omap_dss_device
*dssdev
)
225 return dss_check_settings_low(mgr
, dssdev
, true);
228 static bool need_isr(void)
230 const int num_mgrs
= dss_feat_get_num_mgrs();
233 for (i
= 0; i
< num_mgrs
; ++i
) {
234 struct omap_overlay_manager
*mgr
;
235 struct mgr_priv_data
*mp
;
236 struct omap_overlay
*ovl
;
238 mgr
= omap_dss_get_overlay_manager(i
);
239 mp
= get_mgr_priv(mgr
);
244 if (mgr_manual_update(mgr
)) {
245 /* to catch FRAMEDONE */
249 /* to catch GO bit going down */
253 /* to write new values to registers */
258 if (mp
->shadow_info_dirty
)
261 list_for_each_entry(ovl
, &mgr
->overlays
, list
) {
262 struct ovl_priv_data
*op
;
264 op
= get_ovl_priv(ovl
);
267 * NOTE: we check extra_info flags even for
268 * disabled overlays, as extra_infos need to be
272 /* to write new values to registers */
273 if (op
->extra_info_dirty
)
277 if (op
->shadow_extra_info_dirty
)
283 /* to write new values to registers */
288 if (op
->shadow_info_dirty
)
297 static bool need_go(struct omap_overlay_manager
*mgr
)
299 struct omap_overlay
*ovl
;
300 struct mgr_priv_data
*mp
;
301 struct ovl_priv_data
*op
;
303 mp
= get_mgr_priv(mgr
);
305 if (mp
->shadow_info_dirty
)
308 list_for_each_entry(ovl
, &mgr
->overlays
, list
) {
309 op
= get_ovl_priv(ovl
);
310 if (op
->shadow_info_dirty
|| op
->shadow_extra_info_dirty
)
317 /* returns true if an extra_info field is currently being updated */
318 static bool extra_info_update_ongoing(void)
320 const int num_ovls
= omap_dss_get_num_overlays();
321 struct ovl_priv_data
*op
;
322 struct omap_overlay
*ovl
;
323 struct mgr_priv_data
*mp
;
326 for (i
= 0; i
< num_ovls
; ++i
) {
327 ovl
= omap_dss_get_overlay(i
);
328 op
= get_ovl_priv(ovl
);
333 mp
= get_mgr_priv(ovl
->manager
);
341 if (op
->extra_info_dirty
|| op
->shadow_extra_info_dirty
)
348 /* wait until no extra_info updates are pending */
349 static void wait_pending_extra_info_updates(void)
355 spin_lock_irqsave(&data_lock
, flags
);
357 updating
= extra_info_update_ongoing();
360 spin_unlock_irqrestore(&data_lock
, flags
);
364 init_completion(&extra_updated_completion
);
366 spin_unlock_irqrestore(&data_lock
, flags
);
368 t
= msecs_to_jiffies(500);
369 wait_for_completion_timeout(&extra_updated_completion
, t
);
371 updating
= extra_info_update_ongoing();
376 int dss_mgr_wait_for_go(struct omap_overlay_manager
*mgr
)
378 unsigned long timeout
= msecs_to_jiffies(500);
379 struct mgr_priv_data
*mp
;
383 struct omap_dss_device
*dssdev
= mgr
->device
;
385 if (!dssdev
|| dssdev
->state
!= OMAP_DSS_DISPLAY_ACTIVE
)
388 if (mgr_manual_update(mgr
))
391 irq
= dispc_mgr_get_vsync_irq(mgr
->id
);
393 mp
= get_mgr_priv(mgr
);
397 bool shadow_dirty
, dirty
;
399 spin_lock_irqsave(&data_lock
, flags
);
400 dirty
= mp
->info_dirty
;
401 shadow_dirty
= mp
->shadow_info_dirty
;
402 spin_unlock_irqrestore(&data_lock
, flags
);
404 if (!dirty
&& !shadow_dirty
) {
409 /* 4 iterations is the worst case:
410 * 1 - initial iteration, dirty = true (between VFP and VSYNC)
411 * 2 - first VSYNC, dirty = true
412 * 3 - dirty = false, shadow_dirty = true
413 * 4 - shadow_dirty = false */
415 DSSERR("mgr(%d)->wait_for_go() not finishing\n",
421 r
= omap_dispc_wait_for_irq_interruptible_timeout(irq
, timeout
);
422 if (r
== -ERESTARTSYS
)
426 DSSERR("mgr(%d)->wait_for_go() timeout\n", mgr
->id
);
434 int dss_mgr_wait_for_go_ovl(struct omap_overlay
*ovl
)
436 unsigned long timeout
= msecs_to_jiffies(500);
437 struct ovl_priv_data
*op
;
438 struct omap_dss_device
*dssdev
;
446 dssdev
= ovl
->manager
->device
;
448 if (!dssdev
|| dssdev
->state
!= OMAP_DSS_DISPLAY_ACTIVE
)
451 if (ovl_manual_update(ovl
))
454 irq
= dispc_mgr_get_vsync_irq(ovl
->manager
->id
);
456 op
= get_ovl_priv(ovl
);
460 bool shadow_dirty
, dirty
;
462 spin_lock_irqsave(&data_lock
, flags
);
463 dirty
= op
->info_dirty
;
464 shadow_dirty
= op
->shadow_info_dirty
;
465 spin_unlock_irqrestore(&data_lock
, flags
);
467 if (!dirty
&& !shadow_dirty
) {
472 /* 4 iterations is the worst case:
473 * 1 - initial iteration, dirty = true (between VFP and VSYNC)
474 * 2 - first VSYNC, dirty = true
475 * 3 - dirty = false, shadow_dirty = true
476 * 4 - shadow_dirty = false */
478 DSSERR("ovl(%d)->wait_for_go() not finishing\n",
484 r
= omap_dispc_wait_for_irq_interruptible_timeout(irq
, timeout
);
485 if (r
== -ERESTARTSYS
)
489 DSSERR("ovl(%d)->wait_for_go() timeout\n", ovl
->id
);
497 static void dss_ovl_write_regs(struct omap_overlay
*ovl
)
499 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
500 struct omap_overlay_info
*oi
;
501 bool ilace
, replication
;
502 struct mgr_priv_data
*mp
;
505 DSSDBGF("%d", ovl
->id
);
507 if (!op
->enabled
|| !op
->info_dirty
)
512 replication
= dss_use_replication(ovl
->manager
->device
, oi
->color_mode
);
514 ilace
= ovl
->manager
->device
->type
== OMAP_DISPLAY_TYPE_VENC
;
516 r
= dispc_ovl_setup(ovl
->id
, oi
, ilace
, replication
);
519 * We can't do much here, as this function can be called from
522 DSSERR("dispc_ovl_setup failed for ovl %d\n", ovl
->id
);
524 /* This will leave fifo configurations in a nonoptimal state */
526 dispc_ovl_enable(ovl
->id
, false);
530 mp
= get_mgr_priv(ovl
->manager
);
532 op
->info_dirty
= false;
534 op
->shadow_info_dirty
= true;
537 static void dss_ovl_write_regs_extra(struct omap_overlay
*ovl
)
539 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
540 struct mgr_priv_data
*mp
;
542 DSSDBGF("%d", ovl
->id
);
544 if (!op
->extra_info_dirty
)
547 /* note: write also when op->enabled == false, so that the ovl gets
550 dispc_ovl_enable(ovl
->id
, op
->enabled
);
551 dispc_ovl_set_channel_out(ovl
->id
, op
->channel
);
552 dispc_ovl_set_fifo_threshold(ovl
->id
, op
->fifo_low
, op
->fifo_high
);
554 mp
= get_mgr_priv(ovl
->manager
);
556 op
->extra_info_dirty
= false;
558 op
->shadow_extra_info_dirty
= true;
561 static void dss_mgr_write_regs(struct omap_overlay_manager
*mgr
)
563 struct mgr_priv_data
*mp
= get_mgr_priv(mgr
);
564 struct omap_overlay
*ovl
;
566 DSSDBGF("%d", mgr
->id
);
573 /* Commit overlay settings */
574 list_for_each_entry(ovl
, &mgr
->overlays
, list
) {
575 dss_ovl_write_regs(ovl
);
576 dss_ovl_write_regs_extra(ovl
);
579 if (mp
->info_dirty
) {
580 dispc_mgr_setup(mgr
->id
, &mp
->info
);
582 mp
->info_dirty
= false;
584 mp
->shadow_info_dirty
= true;
588 static void dss_write_regs(void)
590 const int num_mgrs
= omap_dss_get_num_overlay_managers();
593 for (i
= 0; i
< num_mgrs
; ++i
) {
594 struct omap_overlay_manager
*mgr
;
595 struct mgr_priv_data
*mp
;
598 mgr
= omap_dss_get_overlay_manager(i
);
599 mp
= get_mgr_priv(mgr
);
601 if (!mp
->enabled
|| mgr_manual_update(mgr
) || mp
->busy
)
604 r
= dss_check_settings(mgr
, mgr
->device
);
606 DSSERR("cannot write registers for manager %s: "
607 "illegal configuration\n", mgr
->name
);
611 dss_mgr_write_regs(mgr
);
615 static void dss_set_go_bits(void)
617 const int num_mgrs
= omap_dss_get_num_overlay_managers();
620 for (i
= 0; i
< num_mgrs
; ++i
) {
621 struct omap_overlay_manager
*mgr
;
622 struct mgr_priv_data
*mp
;
624 mgr
= omap_dss_get_overlay_manager(i
);
625 mp
= get_mgr_priv(mgr
);
627 if (!mp
->enabled
|| mgr_manual_update(mgr
) || mp
->busy
)
635 if (!dss_data
.irq_enabled
&& need_isr())
636 dss_register_vsync_isr();
638 dispc_mgr_go(mgr
->id
);
643 void dss_mgr_start_update(struct omap_overlay_manager
*mgr
)
645 struct mgr_priv_data
*mp
= get_mgr_priv(mgr
);
649 spin_lock_irqsave(&data_lock
, flags
);
651 WARN_ON(mp
->updating
);
653 r
= dss_check_settings(mgr
, mgr
->device
);
655 DSSERR("cannot start manual update: illegal configuration\n");
656 spin_unlock_irqrestore(&data_lock
, flags
);
660 dss_mgr_write_regs(mgr
);
664 if (!dss_data
.irq_enabled
&& need_isr())
665 dss_register_vsync_isr();
667 dispc_mgr_enable(mgr
->id
, true);
669 spin_unlock_irqrestore(&data_lock
, flags
);
672 static void dss_apply_irq_handler(void *data
, u32 mask
);
674 static void dss_register_vsync_isr(void)
676 const int num_mgrs
= dss_feat_get_num_mgrs();
681 for (i
= 0; i
< num_mgrs
; ++i
)
682 mask
|= dispc_mgr_get_vsync_irq(i
);
684 for (i
= 0; i
< num_mgrs
; ++i
)
685 mask
|= dispc_mgr_get_framedone_irq(i
);
687 r
= omap_dispc_register_isr(dss_apply_irq_handler
, NULL
, mask
);
690 dss_data
.irq_enabled
= true;
693 static void dss_unregister_vsync_isr(void)
695 const int num_mgrs
= dss_feat_get_num_mgrs();
700 for (i
= 0; i
< num_mgrs
; ++i
)
701 mask
|= dispc_mgr_get_vsync_irq(i
);
703 for (i
= 0; i
< num_mgrs
; ++i
)
704 mask
|= dispc_mgr_get_framedone_irq(i
);
706 r
= omap_dispc_unregister_isr(dss_apply_irq_handler
, NULL
, mask
);
709 dss_data
.irq_enabled
= false;
712 static void mgr_clear_shadow_dirty(struct omap_overlay_manager
*mgr
)
714 struct omap_overlay
*ovl
;
715 struct mgr_priv_data
*mp
;
716 struct ovl_priv_data
*op
;
718 mp
= get_mgr_priv(mgr
);
719 mp
->shadow_info_dirty
= false;
721 list_for_each_entry(ovl
, &mgr
->overlays
, list
) {
722 op
= get_ovl_priv(ovl
);
723 op
->shadow_info_dirty
= false;
724 op
->shadow_extra_info_dirty
= false;
728 static void dss_apply_irq_handler(void *data
, u32 mask
)
730 const int num_mgrs
= dss_feat_get_num_mgrs();
734 spin_lock(&data_lock
);
736 /* clear busy, updating flags, shadow_dirty flags */
737 for (i
= 0; i
< num_mgrs
; i
++) {
738 struct omap_overlay_manager
*mgr
;
739 struct mgr_priv_data
*mp
;
742 mgr
= omap_dss_get_overlay_manager(i
);
743 mp
= get_mgr_priv(mgr
);
748 was_updating
= mp
->updating
;
749 mp
->updating
= dispc_mgr_is_enabled(i
);
751 if (!mgr_manual_update(mgr
)) {
752 bool was_busy
= mp
->busy
;
753 mp
->busy
= dispc_mgr_go_busy(i
);
755 if (was_busy
&& !mp
->busy
)
756 mgr_clear_shadow_dirty(mgr
);
758 if (was_updating
&& !mp
->updating
)
759 mgr_clear_shadow_dirty(mgr
);
766 extra_updating
= extra_info_update_ongoing();
768 complete_all(&extra_updated_completion
);
771 dss_unregister_vsync_isr();
773 spin_unlock(&data_lock
);
776 static void omap_dss_mgr_apply_ovl(struct omap_overlay
*ovl
)
778 struct ovl_priv_data
*op
;
780 op
= get_ovl_priv(ovl
);
782 if (!op
->user_info_dirty
)
785 op
->user_info_dirty
= false;
786 op
->info_dirty
= true;
787 op
->info
= op
->user_info
;
790 static void omap_dss_mgr_apply_mgr(struct omap_overlay_manager
*mgr
)
792 struct mgr_priv_data
*mp
;
794 mp
= get_mgr_priv(mgr
);
796 if (!mp
->user_info_dirty
)
799 mp
->user_info_dirty
= false;
800 mp
->info_dirty
= true;
801 mp
->info
= mp
->user_info
;
804 int omap_dss_mgr_apply(struct omap_overlay_manager
*mgr
)
807 struct omap_overlay
*ovl
;
810 DSSDBG("omap_dss_mgr_apply(%s)\n", mgr
->name
);
812 spin_lock_irqsave(&data_lock
, flags
);
814 r
= dss_check_settings_apply(mgr
, mgr
->device
);
816 spin_unlock_irqrestore(&data_lock
, flags
);
817 DSSERR("failed to apply settings: illegal configuration.\n");
821 /* Configure overlays */
822 list_for_each_entry(ovl
, &mgr
->overlays
, list
)
823 omap_dss_mgr_apply_ovl(ovl
);
825 /* Configure manager */
826 omap_dss_mgr_apply_mgr(mgr
);
831 spin_unlock_irqrestore(&data_lock
, flags
);
836 static void dss_apply_ovl_enable(struct omap_overlay
*ovl
, bool enable
)
838 struct ovl_priv_data
*op
;
840 op
= get_ovl_priv(ovl
);
842 if (op
->enabled
== enable
)
845 op
->enabled
= enable
;
846 op
->extra_info_dirty
= true;
849 static void dss_apply_ovl_fifo_thresholds(struct omap_overlay
*ovl
,
850 u32 fifo_low
, u32 fifo_high
)
852 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
854 if (op
->fifo_low
== fifo_low
&& op
->fifo_high
== fifo_high
)
857 op
->fifo_low
= fifo_low
;
858 op
->fifo_high
= fifo_high
;
859 op
->extra_info_dirty
= true;
862 static void dss_ovl_setup_fifo(struct omap_overlay
*ovl
)
864 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
865 struct omap_dss_device
*dssdev
;
866 u32 size
, burst_size
;
867 u32 fifo_low
, fifo_high
;
869 if (!op
->enabled
&& !op
->enabling
)
872 dssdev
= ovl
->manager
->device
;
874 size
= dispc_ovl_get_fifo_size(ovl
->id
);
876 burst_size
= dispc_ovl_get_burst_size(ovl
->id
);
878 switch (dssdev
->type
) {
879 case OMAP_DISPLAY_TYPE_DPI
:
880 case OMAP_DISPLAY_TYPE_DBI
:
881 case OMAP_DISPLAY_TYPE_SDI
:
882 case OMAP_DISPLAY_TYPE_VENC
:
883 case OMAP_DISPLAY_TYPE_HDMI
:
884 default_get_overlay_fifo_thresholds(ovl
->id
, size
,
885 burst_size
, &fifo_low
, &fifo_high
);
887 #ifdef CONFIG_OMAP2_DSS_DSI
888 case OMAP_DISPLAY_TYPE_DSI
:
889 dsi_get_overlay_fifo_thresholds(ovl
->id
, size
,
890 burst_size
, &fifo_low
, &fifo_high
);
897 dss_apply_ovl_fifo_thresholds(ovl
, fifo_low
, fifo_high
);
900 static void dss_mgr_setup_fifos(struct omap_overlay_manager
*mgr
)
902 struct omap_overlay
*ovl
;
903 struct mgr_priv_data
*mp
;
905 mp
= get_mgr_priv(mgr
);
910 list_for_each_entry(ovl
, &mgr
->overlays
, list
)
911 dss_ovl_setup_fifo(ovl
);
914 static void dss_setup_fifos(void)
916 const int num_mgrs
= omap_dss_get_num_overlay_managers();
917 struct omap_overlay_manager
*mgr
;
920 for (i
= 0; i
< num_mgrs
; ++i
) {
921 mgr
= omap_dss_get_overlay_manager(i
);
922 dss_mgr_setup_fifos(mgr
);
926 int dss_mgr_enable(struct omap_overlay_manager
*mgr
)
928 struct mgr_priv_data
*mp
= get_mgr_priv(mgr
);
932 mutex_lock(&apply_lock
);
937 spin_lock_irqsave(&data_lock
, flags
);
941 r
= dss_check_settings(mgr
, mgr
->device
);
943 DSSERR("failed to enable manager %d: check_settings failed\n",
953 if (!mgr_manual_update(mgr
))
956 spin_unlock_irqrestore(&data_lock
, flags
);
958 if (!mgr_manual_update(mgr
))
959 dispc_mgr_enable(mgr
->id
, true);
962 mutex_unlock(&apply_lock
);
968 spin_unlock_irqrestore(&data_lock
, flags
);
969 mutex_unlock(&apply_lock
);
973 void dss_mgr_disable(struct omap_overlay_manager
*mgr
)
975 struct mgr_priv_data
*mp
= get_mgr_priv(mgr
);
978 mutex_lock(&apply_lock
);
983 if (!mgr_manual_update(mgr
))
984 dispc_mgr_enable(mgr
->id
, false);
986 spin_lock_irqsave(&data_lock
, flags
);
988 mp
->updating
= false;
991 spin_unlock_irqrestore(&data_lock
, flags
);
994 mutex_unlock(&apply_lock
);
997 int dss_mgr_set_info(struct omap_overlay_manager
*mgr
,
998 struct omap_overlay_manager_info
*info
)
1000 struct mgr_priv_data
*mp
= get_mgr_priv(mgr
);
1001 unsigned long flags
;
1004 r
= dss_mgr_simple_check(mgr
, info
);
1008 spin_lock_irqsave(&data_lock
, flags
);
1010 mp
->user_info
= *info
;
1011 mp
->user_info_dirty
= true;
1013 spin_unlock_irqrestore(&data_lock
, flags
);
1018 void dss_mgr_get_info(struct omap_overlay_manager
*mgr
,
1019 struct omap_overlay_manager_info
*info
)
1021 struct mgr_priv_data
*mp
= get_mgr_priv(mgr
);
1022 unsigned long flags
;
1024 spin_lock_irqsave(&data_lock
, flags
);
1026 *info
= mp
->user_info
;
1028 spin_unlock_irqrestore(&data_lock
, flags
);
1031 int dss_mgr_set_device(struct omap_overlay_manager
*mgr
,
1032 struct omap_dss_device
*dssdev
)
1036 mutex_lock(&apply_lock
);
1038 if (dssdev
->manager
) {
1039 DSSERR("display '%s' already has a manager '%s'\n",
1040 dssdev
->name
, dssdev
->manager
->name
);
1045 if ((mgr
->supported_displays
& dssdev
->type
) == 0) {
1046 DSSERR("display '%s' does not support manager '%s'\n",
1047 dssdev
->name
, mgr
->name
);
1052 dssdev
->manager
= mgr
;
1053 mgr
->device
= dssdev
;
1055 mutex_unlock(&apply_lock
);
1059 mutex_unlock(&apply_lock
);
1063 int dss_mgr_unset_device(struct omap_overlay_manager
*mgr
)
1067 mutex_lock(&apply_lock
);
1070 DSSERR("failed to unset display, display not set.\n");
1076 * Don't allow currently enabled displays to have the overlay manager
1077 * pulled out from underneath them
1079 if (mgr
->device
->state
!= OMAP_DSS_DISPLAY_DISABLED
) {
1084 mgr
->device
->manager
= NULL
;
1087 mutex_unlock(&apply_lock
);
1091 mutex_unlock(&apply_lock
);
1096 int dss_ovl_set_info(struct omap_overlay
*ovl
,
1097 struct omap_overlay_info
*info
)
1099 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
1100 unsigned long flags
;
1103 r
= dss_ovl_simple_check(ovl
, info
);
1107 spin_lock_irqsave(&data_lock
, flags
);
1109 op
->user_info
= *info
;
1110 op
->user_info_dirty
= true;
1112 spin_unlock_irqrestore(&data_lock
, flags
);
1117 void dss_ovl_get_info(struct omap_overlay
*ovl
,
1118 struct omap_overlay_info
*info
)
1120 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
1121 unsigned long flags
;
1123 spin_lock_irqsave(&data_lock
, flags
);
1125 *info
= op
->user_info
;
1127 spin_unlock_irqrestore(&data_lock
, flags
);
1130 int dss_ovl_set_manager(struct omap_overlay
*ovl
,
1131 struct omap_overlay_manager
*mgr
)
1133 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
1134 unsigned long flags
;
1140 mutex_lock(&apply_lock
);
1143 DSSERR("overlay '%s' already has a manager '%s'\n",
1144 ovl
->name
, ovl
->manager
->name
);
1149 spin_lock_irqsave(&data_lock
, flags
);
1152 spin_unlock_irqrestore(&data_lock
, flags
);
1153 DSSERR("overlay has to be disabled to change the manager\n");
1158 op
->channel
= mgr
->id
;
1159 op
->extra_info_dirty
= true;
1162 list_add_tail(&ovl
->list
, &mgr
->overlays
);
1164 spin_unlock_irqrestore(&data_lock
, flags
);
1166 /* XXX: When there is an overlay on a DSI manual update display, and
1167 * the overlay is first disabled, then moved to tv, and enabled, we
1168 * seem to get SYNC_LOST_DIGIT error.
1170 * Waiting doesn't seem to help, but updating the manual update display
1171 * after disabling the overlay seems to fix this. This hints that the
1172 * overlay is perhaps somehow tied to the LCD output until the output
1175 * Userspace workaround for this is to update the LCD after disabling
1176 * the overlay, but before moving the overlay to TV.
1179 mutex_unlock(&apply_lock
);
1183 mutex_unlock(&apply_lock
);
1187 int dss_ovl_unset_manager(struct omap_overlay
*ovl
)
1189 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
1190 unsigned long flags
;
1193 mutex_lock(&apply_lock
);
1195 if (!ovl
->manager
) {
1196 DSSERR("failed to detach overlay: manager not set\n");
1201 spin_lock_irqsave(&data_lock
, flags
);
1204 spin_unlock_irqrestore(&data_lock
, flags
);
1205 DSSERR("overlay has to be disabled to unset the manager\n");
1212 ovl
->manager
= NULL
;
1213 list_del(&ovl
->list
);
1215 spin_unlock_irqrestore(&data_lock
, flags
);
1217 mutex_unlock(&apply_lock
);
1221 mutex_unlock(&apply_lock
);
1225 bool dss_ovl_is_enabled(struct omap_overlay
*ovl
)
1227 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
1228 unsigned long flags
;
1231 spin_lock_irqsave(&data_lock
, flags
);
1235 spin_unlock_irqrestore(&data_lock
, flags
);
1240 int dss_ovl_enable(struct omap_overlay
*ovl
)
1242 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
1243 unsigned long flags
;
1246 mutex_lock(&apply_lock
);
1253 if (ovl
->manager
== NULL
|| ovl
->manager
->device
== NULL
) {
1258 spin_lock_irqsave(&data_lock
, flags
);
1260 op
->enabling
= true;
1262 r
= dss_check_settings(ovl
->manager
, ovl
->manager
->device
);
1264 DSSERR("failed to enable overlay %d: check_settings failed\n",
1271 op
->enabling
= false;
1272 dss_apply_ovl_enable(ovl
, true);
1277 spin_unlock_irqrestore(&data_lock
, flags
);
1279 /* wait for overlay to be enabled */
1280 wait_pending_extra_info_updates();
1282 mutex_unlock(&apply_lock
);
1286 op
->enabling
= false;
1287 spin_unlock_irqrestore(&data_lock
, flags
);
1289 mutex_unlock(&apply_lock
);
1293 int dss_ovl_disable(struct omap_overlay
*ovl
)
1295 struct ovl_priv_data
*op
= get_ovl_priv(ovl
);
1296 unsigned long flags
;
1299 mutex_lock(&apply_lock
);
1306 if (ovl
->manager
== NULL
|| ovl
->manager
->device
== NULL
) {
1311 spin_lock_irqsave(&data_lock
, flags
);
1313 dss_apply_ovl_enable(ovl
, false);
1317 spin_unlock_irqrestore(&data_lock
, flags
);
1319 /* wait for the overlay to be disabled */
1320 wait_pending_extra_info_updates();
1322 mutex_unlock(&apply_lock
);
1327 mutex_unlock(&apply_lock
);