1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/video/omap2/dss/manager.c
5 * Copyright (C) 2009 Nokia Corporation
6 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
8 * Some code and ideas taken from drivers/video/omap/ driver
12 #define DSS_SUBSYS_NAME "MANAGER"
14 #include <linux/kernel.h>
15 #include <linux/slab.h>
16 #include <linux/module.h>
17 #include <linux/platform_device.h>
18 #include <linux/jiffies.h>
20 #include <video/omapfb_dss.h>
23 #include "dss_features.h"
25 static int num_managers
;
26 static struct omap_overlay_manager
*managers
;
28 int dss_init_overlay_managers(void)
32 num_managers
= dss_feat_get_num_mgrs();
34 managers
= kcalloc(num_managers
, sizeof(struct omap_overlay_manager
),
37 BUG_ON(managers
== NULL
);
39 for (i
= 0; i
< num_managers
; ++i
) {
40 struct omap_overlay_manager
*mgr
= &managers
[i
];
45 mgr
->id
= OMAP_DSS_CHANNEL_LCD
;
49 mgr
->id
= OMAP_DSS_CHANNEL_DIGIT
;
53 mgr
->id
= OMAP_DSS_CHANNEL_LCD2
;
57 mgr
->id
= OMAP_DSS_CHANNEL_LCD3
;
61 mgr
->supported_displays
=
62 dss_feat_get_supported_displays(mgr
->id
);
63 mgr
->supported_outputs
=
64 dss_feat_get_supported_outputs(mgr
->id
);
66 INIT_LIST_HEAD(&mgr
->overlays
);
72 int dss_init_overlay_managers_sysfs(struct platform_device
*pdev
)
76 for (i
= 0; i
< num_managers
; ++i
) {
77 struct omap_overlay_manager
*mgr
= &managers
[i
];
79 r
= dss_manager_kobj_init(mgr
, pdev
);
81 DSSERR("failed to create sysfs file\n");
87 void dss_uninit_overlay_managers(void)
94 void dss_uninit_overlay_managers_sysfs(struct platform_device
*pdev
)
98 for (i
= 0; i
< num_managers
; ++i
) {
99 struct omap_overlay_manager
*mgr
= &managers
[i
];
101 dss_manager_kobj_uninit(mgr
);
105 int omap_dss_get_num_overlay_managers(void)
109 EXPORT_SYMBOL(omap_dss_get_num_overlay_managers
);
111 struct omap_overlay_manager
*omap_dss_get_overlay_manager(int num
)
113 if (num
>= num_managers
)
116 return &managers
[num
];
118 EXPORT_SYMBOL(omap_dss_get_overlay_manager
);
120 int dss_mgr_simple_check(struct omap_overlay_manager
*mgr
,
121 const struct omap_overlay_manager_info
*info
)
123 if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER
)) {
125 * OMAP3 supports only graphics source transparency color key
126 * and alpha blending simultaneously. See TRM 15.4.2.4.2.2
129 if (info
->partial_alpha_enabled
&& info
->trans_enabled
130 && info
->trans_key_type
!= OMAP_DSS_COLOR_KEY_GFX_DST
) {
131 DSSERR("check_manager: illegal transparency key\n");
139 static int dss_mgr_check_zorder(struct omap_overlay_manager
*mgr
,
140 struct omap_overlay_info
**overlay_infos
)
142 struct omap_overlay
*ovl1
, *ovl2
;
143 struct omap_overlay_info
*info1
, *info2
;
145 list_for_each_entry(ovl1
, &mgr
->overlays
, list
) {
146 info1
= overlay_infos
[ovl1
->id
];
151 list_for_each_entry(ovl2
, &mgr
->overlays
, list
) {
155 info2
= overlay_infos
[ovl2
->id
];
160 if (info1
->zorder
== info2
->zorder
) {
161 DSSERR("overlays %d and %d have the same "
163 ovl1
->id
, ovl2
->id
, info1
->zorder
);
172 int dss_mgr_check_timings(struct omap_overlay_manager
*mgr
,
173 const struct omap_video_timings
*timings
)
175 if (!dispc_mgr_timings_ok(mgr
->id
, timings
)) {
176 DSSERR("check_manager: invalid timings\n");
183 static int dss_mgr_check_lcd_config(struct omap_overlay_manager
*mgr
,
184 const struct dss_lcd_mgr_config
*config
)
186 struct dispc_clock_info cinfo
= config
->clock_info
;
187 int dl
= config
->video_port_width
;
188 bool stallmode
= config
->stallmode
;
189 bool fifohandcheck
= config
->fifohandcheck
;
191 if (cinfo
.lck_div
< 1 || cinfo
.lck_div
> 255)
194 if (cinfo
.pck_div
< 1 || cinfo
.pck_div
> 255)
197 if (dl
!= 12 && dl
!= 16 && dl
!= 18 && dl
!= 24)
200 /* fifohandcheck should be used only with stallmode */
201 if (!stallmode
&& fifohandcheck
)
205 * io pad mode can be only checked by using dssdev connected to the
206 * manager. Ignore checking these for now, add checks when manager
207 * is capable of holding information related to the connected interface
213 int dss_mgr_check(struct omap_overlay_manager
*mgr
,
214 struct omap_overlay_manager_info
*info
,
215 const struct omap_video_timings
*mgr_timings
,
216 const struct dss_lcd_mgr_config
*lcd_config
,
217 struct omap_overlay_info
**overlay_infos
)
219 struct omap_overlay
*ovl
;
222 if (dss_has_feature(FEAT_ALPHA_FREE_ZORDER
)) {
223 r
= dss_mgr_check_zorder(mgr
, overlay_infos
);
228 r
= dss_mgr_check_timings(mgr
, mgr_timings
);
232 r
= dss_mgr_check_lcd_config(mgr
, lcd_config
);
236 list_for_each_entry(ovl
, &mgr
->overlays
, list
) {
237 struct omap_overlay_info
*oi
;
240 oi
= overlay_infos
[ovl
->id
];
245 r
= dss_ovl_check(ovl
, oi
, mgr_timings
);