2 * linux/drivers/video/omap2/dss/dss_features.c
4 * Copyright (C) 2010 Texas Instruments
5 * Author: Archit Taneja <archit@ti.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <linux/kernel.h>
21 #include <linux/types.h>
22 #include <linux/err.h>
23 #include <linux/slab.h>
25 #include <plat/display.h>
28 #include "dss_features.h"
30 /* Defines a generic omap register field */
31 struct dss_reg_field {
32 enum dss_feat_reg_field id;
36 struct omap_dss_features {
37 const struct dss_reg_field *reg_fields;
38 const int num_reg_fields;
40 const u32 has_feature;
44 const enum omap_display_type *supported_displays;
45 const enum omap_color_mode *supported_color_modes;
48 /* This struct is assigned to one of the below during initialization */
49 static struct omap_dss_features *omap_current_dss_features;
51 static const struct dss_reg_field omap2_dss_reg_fields[] = {
52 { FEAT_REG_FIRHINC, 11, 0 },
53 { FEAT_REG_FIRVINC, 27, 16 },
54 { FEAT_REG_FIFOLOWTHRESHOLD, 8, 0 },
55 { FEAT_REG_FIFOHIGHTHRESHOLD, 24, 16 },
56 { FEAT_REG_FIFOSIZE, 8, 0 },
59 static const struct dss_reg_field omap3_dss_reg_fields[] = {
60 { FEAT_REG_FIRHINC, 12, 0 },
61 { FEAT_REG_FIRVINC, 28, 16 },
62 { FEAT_REG_FIFOLOWTHRESHOLD, 11, 0 },
63 { FEAT_REG_FIFOHIGHTHRESHOLD, 27, 16 },
64 { FEAT_REG_FIFOSIZE, 10, 0 },
67 static const enum omap_display_type omap2_dss_supported_displays[] = {
68 /* OMAP_DSS_CHANNEL_LCD */
69 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
70 OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
72 /* OMAP_DSS_CHANNEL_DIGIT */
73 OMAP_DISPLAY_TYPE_VENC,
76 static const enum omap_display_type omap3_dss_supported_displays[] = {
77 /* OMAP_DSS_CHANNEL_LCD */
78 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
79 OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
81 /* OMAP_DSS_CHANNEL_DIGIT */
82 OMAP_DISPLAY_TYPE_VENC,
85 static const enum omap_display_type omap4_dss_supported_displays[] = {
86 /* OMAP_DSS_CHANNEL_LCD */
87 OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI,
89 /* OMAP_DSS_CHANNEL_DIGIT */
90 OMAP_DISPLAY_TYPE_VENC,
92 /* OMAP_DSS_CHANNEL_LCD2 */
93 OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
94 OMAP_DISPLAY_TYPE_DSI,
97 static const enum omap_color_mode omap2_dss_supported_color_modes[] = {
99 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
100 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
101 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
102 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
104 /* OMAP_DSS_VIDEO1 */
105 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
106 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
109 /* OMAP_DSS_VIDEO2 */
110 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
111 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
115 static const enum omap_color_mode omap3_dss_supported_color_modes[] = {
117 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
118 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
119 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
120 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
121 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
122 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
124 /* OMAP_DSS_VIDEO1 */
125 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
126 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
127 OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
129 /* OMAP_DSS_VIDEO2 */
130 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
131 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
132 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
133 OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
134 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
137 /* OMAP2 DSS Features */
138 static struct omap_dss_features omap2_dss_features = {
139 .reg_fields = omap2_dss_reg_fields,
140 .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
143 FEAT_LCDENABLEPOL | FEAT_LCDENABLESIGNAL |
144 FEAT_PCKFREEENABLE | FEAT_FUNCGATED,
148 .supported_displays = omap2_dss_supported_displays,
149 .supported_color_modes = omap2_dss_supported_color_modes,
152 /* OMAP3 DSS Features */
153 static struct omap_dss_features omap3430_dss_features = {
154 .reg_fields = omap3_dss_reg_fields,
155 .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
158 FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL |
159 FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE |
164 .supported_displays = omap3_dss_supported_displays,
165 .supported_color_modes = omap3_dss_supported_color_modes,
168 static struct omap_dss_features omap3630_dss_features = {
169 .reg_fields = omap3_dss_reg_fields,
170 .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
173 FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL |
174 FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE |
175 FEAT_PRE_MULT_ALPHA | FEAT_FUNCGATED,
179 .supported_displays = omap3_dss_supported_displays,
180 .supported_color_modes = omap3_dss_supported_color_modes,
183 /* OMAP4 DSS Features */
184 static struct omap_dss_features omap4_dss_features = {
185 .reg_fields = omap3_dss_reg_fields,
186 .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
189 FEAT_GLOBAL_ALPHA | FEAT_PRE_MULT_ALPHA |
194 .supported_displays = omap4_dss_supported_displays,
195 .supported_color_modes = omap3_dss_supported_color_modes,
198 /* Functions returning values related to a DSS feature */
199 int dss_feat_get_num_mgrs(void)
201 return omap_current_dss_features->num_mgrs;
204 int dss_feat_get_num_ovls(void)
206 return omap_current_dss_features->num_ovls;
209 enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel)
211 return omap_current_dss_features->supported_displays[channel];
214 enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane)
216 return omap_current_dss_features->supported_color_modes[plane];
219 bool dss_feat_color_mode_supported(enum omap_plane plane,
220 enum omap_color_mode color_mode)
222 return omap_current_dss_features->supported_color_modes[plane] &
226 /* DSS has_feature check */
227 bool dss_has_feature(enum dss_feat_id id)
229 return omap_current_dss_features->has_feature & id;
232 void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
234 if (id >= omap_current_dss_features->num_reg_fields)
237 *start = omap_current_dss_features->reg_fields[id].start;
238 *end = omap_current_dss_features->reg_fields[id].end;
241 void dss_features_init(void)
243 if (cpu_is_omap24xx())
244 omap_current_dss_features = &omap2_dss_features;
245 else if (cpu_is_omap3630())
246 omap_current_dss_features = &omap3630_dss_features;
247 else if (cpu_is_omap34xx())
248 omap_current_dss_features = &omap3430_dss_features;
250 omap_current_dss_features = &omap4_dss_features;