2 * linux/drivers/video/omap2/dss/overlay.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 "OVERLAY"
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/err.h>
28 #include <linux/sysfs.h>
29 #include <linux/platform_device.h>
30 #include <linux/delay.h>
31 #include <linux/slab.h>
33 #include <video/omapfb_dss.h>
36 #include "dss_features.h"
38 static int num_overlays
;
39 static struct omap_overlay
*overlays
;
41 int omap_dss_get_num_overlays(void)
45 EXPORT_SYMBOL(omap_dss_get_num_overlays
);
47 struct omap_overlay
*omap_dss_get_overlay(int num
)
49 if (num
>= num_overlays
)
52 return &overlays
[num
];
54 EXPORT_SYMBOL(omap_dss_get_overlay
);
56 void dss_init_overlays(struct platform_device
*pdev
)
60 num_overlays
= dss_feat_get_num_ovls();
62 overlays
= kzalloc(sizeof(struct omap_overlay
) * num_overlays
,
65 BUG_ON(overlays
== NULL
);
67 for (i
= 0; i
< num_overlays
; ++i
) {
68 struct omap_overlay
*ovl
= &overlays
[i
];
73 ovl
->id
= OMAP_DSS_GFX
;
77 ovl
->id
= OMAP_DSS_VIDEO1
;
81 ovl
->id
= OMAP_DSS_VIDEO2
;
85 ovl
->id
= OMAP_DSS_VIDEO3
;
89 ovl
->caps
= dss_feat_get_overlay_caps(ovl
->id
);
90 ovl
->supported_modes
=
91 dss_feat_get_supported_color_modes(ovl
->id
);
93 r
= dss_overlay_kobj_init(ovl
, pdev
);
95 DSSERR("failed to create sysfs file\n");
99 void dss_uninit_overlays(struct platform_device
*pdev
)
103 for (i
= 0; i
< num_overlays
; ++i
) {
104 struct omap_overlay
*ovl
= &overlays
[i
];
105 dss_overlay_kobj_uninit(ovl
);
113 int dss_ovl_simple_check(struct omap_overlay
*ovl
,
114 const struct omap_overlay_info
*info
)
116 if ((ovl
->caps
& OMAP_DSS_OVL_CAP_SCALE
) == 0) {
117 if (info
->out_width
!= 0 && info
->width
!= info
->out_width
) {
118 DSSERR("check_overlay: overlay %d doesn't support "
119 "scaling\n", ovl
->id
);
123 if (info
->out_height
!= 0 && info
->height
!= info
->out_height
) {
124 DSSERR("check_overlay: overlay %d doesn't support "
125 "scaling\n", ovl
->id
);
130 if ((ovl
->supported_modes
& info
->color_mode
) == 0) {
131 DSSERR("check_overlay: overlay %d doesn't support mode %d\n",
132 ovl
->id
, info
->color_mode
);
136 if (info
->zorder
>= omap_dss_get_num_overlays()) {
137 DSSERR("check_overlay: zorder %d too high\n", info
->zorder
);
141 if (dss_feat_rotation_type_supported(info
->rotation_type
) == 0) {
142 DSSERR("check_overlay: rotation type %d not supported\n",
143 info
->rotation_type
);
150 int dss_ovl_check(struct omap_overlay
*ovl
, struct omap_overlay_info
*info
,
151 const struct omap_video_timings
*mgr_timings
)
156 dw
= mgr_timings
->x_res
;
157 dh
= mgr_timings
->y_res
;
159 if ((ovl
->caps
& OMAP_DSS_OVL_CAP_SCALE
) == 0) {
163 if (info
->out_width
== 0)
166 outw
= info
->out_width
;
168 if (info
->out_height
== 0)
171 outh
= info
->out_height
;
174 if (dw
< info
->pos_x
+ outw
) {
175 DSSERR("overlay %d horizontally not inside the display area "
177 ovl
->id
, info
->pos_x
, outw
, dw
);
181 if (dh
< info
->pos_y
+ outh
) {
182 DSSERR("overlay %d vertically not inside the display area "
184 ovl
->id
, info
->pos_y
, outh
, dh
);
192 * Checks if replication logic should be used. Only use when overlay is in
193 * RGB12U or RGB16 mode, and video port width interface is 18bpp or 24bpp
195 bool dss_ovl_use_replication(struct dss_lcd_mgr_config config
,
196 enum omap_color_mode mode
)
198 if (mode
!= OMAP_DSS_COLOR_RGB12U
&& mode
!= OMAP_DSS_COLOR_RGB16
)
201 return config
.video_port_width
> 16;