94836f8ef961c53d0d8963042024f6698d13b72c
[android-sdk/kernel-video.git] / drivers / video / fbdev / omap2 / dss / dss_features.c
1 /*
2  * linux/drivers/video/omap2/dss/dss_features.c
3  *
4  * Copyright (C) 2010 Texas Instruments
5  * Author: Archit Taneja <archit@ti.com>
6  *
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.
10  *
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
14  * more details.
15  *
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/>.
18  */
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/types.h>
23 #include <linux/err.h>
24 #include <linux/slab.h>
26 #include <video/omapdss.h>
28 #include "dss.h"
29 #include "dss_features.h"
31 /* Defines a generic omap register field */
32 struct dss_reg_field {
33         u8 start, end;
34 };
36 struct dss_param_range {
37         int min, max;
38 };
40 struct omap_dss_features {
41         const struct dss_reg_field *reg_fields;
42         const int num_reg_fields;
44         const enum dss_feat_id *features;
45         const int num_features;
47         const int num_mgrs;
48         const int num_ovls;
49         const int num_wbs;
50         const enum omap_display_type *supported_displays;
51         const enum omap_dss_output_id *supported_outputs;
52         const enum omap_color_mode *supported_color_modes;
53         const enum omap_overlay_caps *overlay_caps;
54         const char * const *clksrc_names;
55         const struct dss_param_range *dss_params;
57         const enum omap_dss_rotation_type supported_rotation_types;
59         const u32 buffer_size_unit;
60         const u32 burst_size_unit;
61 };
63 /* This struct is assigned to one of the below during initialization */
64 static const struct omap_dss_features *omap_current_dss_features;
66 static const struct dss_reg_field omap2_dss_reg_fields[] = {
67         [FEAT_REG_FIRHINC]                      = { 11, 0 },
68         [FEAT_REG_FIRVINC]                      = { 27, 16 },
69         [FEAT_REG_FIFOLOWTHRESHOLD]             = { 8, 0 },
70         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 24, 16 },
71         [FEAT_REG_FIFOSIZE]                     = { 8, 0 },
72         [FEAT_REG_HORIZONTALACCU]               = { 9, 0 },
73         [FEAT_REG_VERTICALACCU]                 = { 25, 16 },
74         [FEAT_REG_DISPC_CLK_SWITCH]             = { 0, 0 },
75 };
77 static const struct dss_reg_field omap3_dss_reg_fields[] = {
78         [FEAT_REG_FIRHINC]                      = { 12, 0 },
79         [FEAT_REG_FIRVINC]                      = { 28, 16 },
80         [FEAT_REG_FIFOLOWTHRESHOLD]             = { 11, 0 },
81         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 27, 16 },
82         [FEAT_REG_FIFOSIZE]                     = { 10, 0 },
83         [FEAT_REG_HORIZONTALACCU]               = { 9, 0 },
84         [FEAT_REG_VERTICALACCU]                 = { 25, 16 },
85         [FEAT_REG_DISPC_CLK_SWITCH]             = { 0, 0 },
86 };
88 static const struct dss_reg_field am43xx_dss_reg_fields[] = {
89         [FEAT_REG_FIRHINC]                      = { 12, 0 },
90         [FEAT_REG_FIRVINC]                      = { 28, 16 },
91         [FEAT_REG_FIFOLOWTHRESHOLD]     = { 11, 0 },
92         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 27, 16 },
93         [FEAT_REG_FIFOSIZE]             = { 10, 0 },
94         [FEAT_REG_HORIZONTALACCU]               = { 9, 0 },
95         [FEAT_REG_VERTICALACCU]                 = { 25, 16 },
96         [FEAT_REG_DISPC_CLK_SWITCH]             = { 0, 0 },
97 };
99 static const struct dss_reg_field omap4_dss_reg_fields[] = {
100         [FEAT_REG_FIRHINC]                      = { 12, 0 },
101         [FEAT_REG_FIRVINC]                      = { 28, 16 },
102         [FEAT_REG_FIFOLOWTHRESHOLD]             = { 15, 0 },
103         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 31, 16 },
104         [FEAT_REG_FIFOSIZE]                     = { 15, 0 },
105         [FEAT_REG_HORIZONTALACCU]               = { 10, 0 },
106         [FEAT_REG_VERTICALACCU]                 = { 26, 16 },
107         [FEAT_REG_DISPC_CLK_SWITCH]             = { 9, 8 },
108 };
110 static const struct dss_reg_field omap5_dss_reg_fields[] = {
111         [FEAT_REG_FIRHINC]                      = { 12, 0 },
112         [FEAT_REG_FIRVINC]                      = { 28, 16 },
113         [FEAT_REG_FIFOLOWTHRESHOLD]             = { 15, 0 },
114         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 31, 16 },
115         [FEAT_REG_FIFOSIZE]                     = { 15, 0 },
116         [FEAT_REG_HORIZONTALACCU]               = { 10, 0 },
117         [FEAT_REG_VERTICALACCU]                 = { 26, 16 },
118         [FEAT_REG_DISPC_CLK_SWITCH]             = { 9, 7 },
119 };
121 static const enum omap_display_type omap2_dss_supported_displays[] = {
122         /* OMAP_DSS_CHANNEL_LCD */
123         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI,
125         /* OMAP_DSS_CHANNEL_DIGIT */
126         OMAP_DISPLAY_TYPE_VENC,
127 };
129 static const enum omap_display_type omap3430_dss_supported_displays[] = {
130         /* OMAP_DSS_CHANNEL_LCD */
131         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
132         OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
134         /* OMAP_DSS_CHANNEL_DIGIT */
135         OMAP_DISPLAY_TYPE_VENC,
136 };
138 static const enum omap_display_type omap3630_dss_supported_displays[] = {
139         /* OMAP_DSS_CHANNEL_LCD */
140         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
141         OMAP_DISPLAY_TYPE_DSI,
143         /* OMAP_DSS_CHANNEL_DIGIT */
144         OMAP_DISPLAY_TYPE_VENC,
145 };
147 static const enum omap_display_type am43xx_dss_supported_displays[] = {
148         /* OMAP_DSS_CHANNEL_LCD */
149         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI,
150 };
152 static const enum omap_display_type omap4_dss_supported_displays[] = {
153         /* OMAP_DSS_CHANNEL_LCD */
154         OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI,
156         /* OMAP_DSS_CHANNEL_DIGIT */
157         OMAP_DISPLAY_TYPE_VENC | OMAP_DISPLAY_TYPE_HDMI,
159         /* OMAP_DSS_CHANNEL_LCD2 */
160         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
161         OMAP_DISPLAY_TYPE_DSI,
162 };
164 static const enum omap_display_type omap5_dss_supported_displays[] = {
165         /* OMAP_DSS_CHANNEL_LCD */
166         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
167         OMAP_DISPLAY_TYPE_DSI,
169         /* OMAP_DSS_CHANNEL_DIGIT */
170         OMAP_DISPLAY_TYPE_HDMI | OMAP_DISPLAY_TYPE_DPI,
172         /* OMAP_DSS_CHANNEL_LCD2 */
173         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
174         OMAP_DISPLAY_TYPE_DSI,
175 };
177 static const enum omap_dss_output_id omap2_dss_supported_outputs[] = {
178         /* OMAP_DSS_CHANNEL_LCD */
179         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
181         /* OMAP_DSS_CHANNEL_DIGIT */
182         OMAP_DSS_OUTPUT_VENC,
183 };
185 static const enum omap_dss_output_id omap3430_dss_supported_outputs[] = {
186         /* OMAP_DSS_CHANNEL_LCD */
187         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
188         OMAP_DSS_OUTPUT_SDI | OMAP_DSS_OUTPUT_DSI1,
190         /* OMAP_DSS_CHANNEL_DIGIT */
191         OMAP_DSS_OUTPUT_VENC,
192 };
194 static const enum omap_dss_output_id omap3630_dss_supported_outputs[] = {
195         /* OMAP_DSS_CHANNEL_LCD */
196         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
197         OMAP_DSS_OUTPUT_DSI1,
199         /* OMAP_DSS_CHANNEL_DIGIT */
200         OMAP_DSS_OUTPUT_VENC,
201 };
203 static const enum omap_dss_output_id am43xx_dss_supported_outputs[] = {
204         /* OMAP_DSS_CHANNEL_LCD */
205         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
206 };
208 static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
209         /* OMAP_DSS_CHANNEL_LCD */
210         OMAP_DSS_OUTPUT_DBI | OMAP_DSS_OUTPUT_DSI1,
212         /* OMAP_DSS_CHANNEL_DIGIT */
213         OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI,
215         /* OMAP_DSS_CHANNEL_LCD2 */
216         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
217         OMAP_DSS_OUTPUT_DSI2,
218 };
220 static const enum omap_dss_output_id omap5_dss_supported_outputs[] = {
221         /* OMAP_DSS_CHANNEL_LCD */
222         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
223         OMAP_DSS_OUTPUT_DSI1 | OMAP_DSS_OUTPUT_DSI2,
225         /* OMAP_DSS_CHANNEL_DIGIT */
226         OMAP_DSS_OUTPUT_HDMI | OMAP_DSS_OUTPUT_DPI,
228         /* OMAP_DSS_CHANNEL_LCD2 */
229         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
230         OMAP_DSS_OUTPUT_DSI1,
232         /* OMAP_DSS_CHANNEL_LCD3 */
233         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
234         OMAP_DSS_OUTPUT_DSI2,
235 };
237 static const enum omap_color_mode omap2_dss_supported_color_modes[] = {
238         /* OMAP_DSS_GFX */
239         OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
240         OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
241         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
242         OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
244         /* OMAP_DSS_VIDEO1 */
245         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
246         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
247         OMAP_DSS_COLOR_UYVY,
249         /* OMAP_DSS_VIDEO2 */
250         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
251         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
252         OMAP_DSS_COLOR_UYVY,
253 };
255 static const enum omap_color_mode omap3_dss_supported_color_modes[] = {
256         /* OMAP_DSS_GFX */
257         OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
258         OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
259         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
260         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
261         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
262         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
264         /* OMAP_DSS_VIDEO1 */
265         OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
266         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
267         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
269         /* OMAP_DSS_VIDEO2 */
270         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
271         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
272         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
273         OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
274         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
275 };
277 static const enum omap_color_mode omap4_dss_supported_color_modes[] = {
278         /* OMAP_DSS_GFX */
279         OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
280         OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
281         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
282         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
283         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
284         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32 |
285         OMAP_DSS_COLOR_ARGB16_1555 | OMAP_DSS_COLOR_RGBX16 |
286         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_XRGB16_1555,
288         /* OMAP_DSS_VIDEO1 */
289         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
290         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
291         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
292         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
293         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
294         OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
295         OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
296         OMAP_DSS_COLOR_RGBX32,
298        /* OMAP_DSS_VIDEO2 */
299         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
300         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
301         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
302         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
303         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
304         OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
305         OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
306         OMAP_DSS_COLOR_RGBX32,
308         /* OMAP_DSS_VIDEO3 */
309         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
310         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
311         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
312         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
313         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
314         OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
315         OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
316         OMAP_DSS_COLOR_RGBX32,
318         /* OMAP_DSS_WB */
319         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
320         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
321         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
322         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
323         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
324         OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
325         OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
326         OMAP_DSS_COLOR_RGBX32,
327 };
329 static const enum omap_overlay_caps omap2_dss_overlay_caps[] = {
330         /* OMAP_DSS_GFX */
331         OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
333         /* OMAP_DSS_VIDEO1 */
334         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
335                 OMAP_DSS_OVL_CAP_REPLICATION,
337         /* OMAP_DSS_VIDEO2 */
338         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
339                 OMAP_DSS_OVL_CAP_REPLICATION,
340 };
342 static const enum omap_overlay_caps omap3430_dss_overlay_caps[] = {
343         /* OMAP_DSS_GFX */
344         OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_POS |
345                 OMAP_DSS_OVL_CAP_REPLICATION,
347         /* OMAP_DSS_VIDEO1 */
348         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
349                 OMAP_DSS_OVL_CAP_REPLICATION,
351         /* OMAP_DSS_VIDEO2 */
352         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
353                 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
354 };
356 static const enum omap_overlay_caps omap3630_dss_overlay_caps[] = {
357         /* OMAP_DSS_GFX */
358         OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
359                 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
361         /* OMAP_DSS_VIDEO1 */
362         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
363                 OMAP_DSS_OVL_CAP_REPLICATION,
365         /* OMAP_DSS_VIDEO2 */
366         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
367                 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_POS |
368                 OMAP_DSS_OVL_CAP_REPLICATION,
369 };
371 static const enum omap_overlay_caps omap4_dss_overlay_caps[] = {
372         /* OMAP_DSS_GFX */
373         OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
374                 OMAP_DSS_OVL_CAP_ZORDER | OMAP_DSS_OVL_CAP_POS |
375                 OMAP_DSS_OVL_CAP_REPLICATION,
377         /* OMAP_DSS_VIDEO1 */
378         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
379                 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
380                 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
382         /* OMAP_DSS_VIDEO2 */
383         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
384                 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
385                 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
387         /* OMAP_DSS_VIDEO3 */
388         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
389                 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
390                 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
391 };
393 static const char * const omap2_dss_clk_source_names[] = {
394         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC]  = "N/A",
395         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI]    = "N/A",
396         [OMAP_DSS_CLK_SRC_FCK]                  = "DSS_FCLK1",
397 };
399 static const char * const omap3_dss_clk_source_names[] = {
400         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC]  = "DSI1_PLL_FCLK",
401         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI]    = "DSI2_PLL_FCLK",
402         [OMAP_DSS_CLK_SRC_FCK]                  = "DSS1_ALWON_FCLK",
403 };
405 static const char * const omap4_dss_clk_source_names[] = {
406         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC]  = "PLL1_CLK1",
407         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI]    = "PLL1_CLK2",
408         [OMAP_DSS_CLK_SRC_FCK]                  = "DSS_FCLK",
409         [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC] = "PLL2_CLK1",
410         [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI]   = "PLL2_CLK2",
411 };
413 static const char * const omap5_dss_clk_source_names[] = {
414         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC]  = "DPLL_DSI1_A_CLK1",
415         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI]    = "DPLL_DSI1_A_CLK2",
416         [OMAP_DSS_CLK_SRC_FCK]                  = "DSS_CLK",
417         [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC] = "DPLL_DSI1_C_CLK1",
418         [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI]   = "DPLL_DSI1_C_CLK2",
419 };
421 static const struct dss_param_range omap2_dss_param_range[] = {
422         [FEAT_PARAM_DSS_FCK]                    = { 0, 133000000 },
423         [FEAT_PARAM_DSS_PCD]                    = { 2, 255 },
424         [FEAT_PARAM_DSIPLL_LPDIV]               = { 0, 0 },
425         [FEAT_PARAM_DOWNSCALE]                  = { 1, 2 },
426         /*
427          * Assuming the line width buffer to be 768 pixels as OMAP2 DISPC
428          * scaler cannot scale a image with width more than 768.
429          */
430         [FEAT_PARAM_LINEWIDTH]                  = { 1, 768 },
431 };
433 static const struct dss_param_range omap3_dss_param_range[] = {
434         [FEAT_PARAM_DSS_FCK]                    = { 0, 173000000 },
435         [FEAT_PARAM_DSS_PCD]                    = { 1, 255 },
436         [FEAT_PARAM_DSIPLL_LPDIV]               = { 1, (1 << 13) - 1},
437         [FEAT_PARAM_DSI_FCK]                    = { 0, 173000000 },
438         [FEAT_PARAM_DOWNSCALE]                  = { 1, 4 },
439         [FEAT_PARAM_LINEWIDTH]                  = { 1, 1024 },
440 };
442 static const struct dss_param_range am43xx_dss_param_range[] = {
443         [FEAT_PARAM_DSS_FCK]                    = { 0, 200000000 },
444         [FEAT_PARAM_DSS_PCD]                    = { 1, 255 },
445         [FEAT_PARAM_DOWNSCALE]                  = { 1, 4 },
446         [FEAT_PARAM_LINEWIDTH]                  = { 1, 1024 },
447 };
449 static const struct dss_param_range omap4_dss_param_range[] = {
450         [FEAT_PARAM_DSS_FCK]                    = { 0, 186000000 },
451         [FEAT_PARAM_DSS_PCD]                    = { 1, 255 },
452         [FEAT_PARAM_DSIPLL_LPDIV]               = { 0, (1 << 13) - 1 },
453         [FEAT_PARAM_DSI_FCK]                    = { 0, 170000000 },
454         [FEAT_PARAM_DOWNSCALE]                  = { 1, 4 },
455         [FEAT_PARAM_LINEWIDTH]                  = { 1, 2048 },
456 };
458 static const struct dss_param_range omap5_dss_param_range[] = {
459         [FEAT_PARAM_DSS_FCK]                    = { 0, 209250000 },
460         [FEAT_PARAM_DSS_PCD]                    = { 1, 255 },
461         [FEAT_PARAM_DSIPLL_LPDIV]               = { 0, (1 << 13) - 1 },
462         [FEAT_PARAM_DSI_FCK]                    = { 0, 209250000 },
463         [FEAT_PARAM_DOWNSCALE]                  = { 1, 4 },
464         [FEAT_PARAM_LINEWIDTH]                  = { 1, 2048 },
465 };
467 static const enum dss_feat_id omap2_dss_feat_list[] = {
468         FEAT_LCDENABLEPOL,
469         FEAT_LCDENABLESIGNAL,
470         FEAT_PCKFREEENABLE,
471         FEAT_FUNCGATED,
472         FEAT_ROWREPEATENABLE,
473         FEAT_RESIZECONF,
474 };
476 static const enum dss_feat_id omap3430_dss_feat_list[] = {
477         FEAT_LCDENABLEPOL,
478         FEAT_LCDENABLESIGNAL,
479         FEAT_PCKFREEENABLE,
480         FEAT_FUNCGATED,
481         FEAT_LINEBUFFERSPLIT,
482         FEAT_ROWREPEATENABLE,
483         FEAT_RESIZECONF,
484         FEAT_DSI_REVERSE_TXCLKESC,
485         FEAT_VENC_REQUIRES_TV_DAC_CLK,
486         FEAT_CPR,
487         FEAT_PRELOAD,
488         FEAT_FIR_COEF_V,
489         FEAT_ALPHA_FIXED_ZORDER,
490         FEAT_FIFO_MERGE,
491         FEAT_OMAP3_DSI_FIFO_BUG,
492         FEAT_DPI_USES_VDDS_DSI,
493 };
495 static const enum dss_feat_id am35xx_dss_feat_list[] = {
496         FEAT_LCDENABLEPOL,
497         FEAT_LCDENABLESIGNAL,
498         FEAT_PCKFREEENABLE,
499         FEAT_FUNCGATED,
500         FEAT_LINEBUFFERSPLIT,
501         FEAT_ROWREPEATENABLE,
502         FEAT_RESIZECONF,
503         FEAT_DSI_REVERSE_TXCLKESC,
504         FEAT_VENC_REQUIRES_TV_DAC_CLK,
505         FEAT_CPR,
506         FEAT_PRELOAD,
507         FEAT_FIR_COEF_V,
508         FEAT_ALPHA_FIXED_ZORDER,
509         FEAT_FIFO_MERGE,
510         FEAT_OMAP3_DSI_FIFO_BUG,
511 };
513 static const enum dss_feat_id am43xx_dss_feat_list[] = {
514         FEAT_LCDENABLEPOL,
515         FEAT_LCDENABLESIGNAL,
516         FEAT_PCKFREEENABLE,
517         FEAT_FUNCGATED,
518         FEAT_LINEBUFFERSPLIT,
519         FEAT_ROWREPEATENABLE,
520         FEAT_RESIZECONF,
521         FEAT_CPR,
522         FEAT_PRELOAD,
523         FEAT_FIR_COEF_V,
524         FEAT_ALPHA_FIXED_ZORDER,
525         FEAT_FIFO_MERGE,
526 };
528 static const enum dss_feat_id omap3630_dss_feat_list[] = {
529         FEAT_LCDENABLEPOL,
530         FEAT_LCDENABLESIGNAL,
531         FEAT_PCKFREEENABLE,
532         FEAT_FUNCGATED,
533         FEAT_LINEBUFFERSPLIT,
534         FEAT_ROWREPEATENABLE,
535         FEAT_RESIZECONF,
536         FEAT_DSI_PLL_PWR_BUG,
537         FEAT_CPR,
538         FEAT_PRELOAD,
539         FEAT_FIR_COEF_V,
540         FEAT_ALPHA_FIXED_ZORDER,
541         FEAT_FIFO_MERGE,
542         FEAT_OMAP3_DSI_FIFO_BUG,
543         FEAT_DPI_USES_VDDS_DSI,
544 };
546 static const enum dss_feat_id omap4430_es1_0_dss_feat_list[] = {
547         FEAT_MGR_LCD2,
548         FEAT_CORE_CLK_DIV,
549         FEAT_LCD_CLK_SRC,
550         FEAT_DSI_DCS_CMD_CONFIG_VC,
551         FEAT_DSI_VC_OCP_WIDTH,
552         FEAT_DSI_GNQ,
553         FEAT_HANDLE_UV_SEPARATE,
554         FEAT_ATTR2,
555         FEAT_CPR,
556         FEAT_PRELOAD,
557         FEAT_FIR_COEF_V,
558         FEAT_ALPHA_FREE_ZORDER,
559         FEAT_FIFO_MERGE,
560         FEAT_BURST_2D,
561 };
563 static const enum dss_feat_id omap4430_es2_0_1_2_dss_feat_list[] = {
564         FEAT_MGR_LCD2,
565         FEAT_CORE_CLK_DIV,
566         FEAT_LCD_CLK_SRC,
567         FEAT_DSI_DCS_CMD_CONFIG_VC,
568         FEAT_DSI_VC_OCP_WIDTH,
569         FEAT_DSI_GNQ,
570         FEAT_HDMI_CTS_SWMODE,
571         FEAT_HANDLE_UV_SEPARATE,
572         FEAT_ATTR2,
573         FEAT_CPR,
574         FEAT_PRELOAD,
575         FEAT_FIR_COEF_V,
576         FEAT_ALPHA_FREE_ZORDER,
577         FEAT_FIFO_MERGE,
578         FEAT_BURST_2D,
579 };
581 static const enum dss_feat_id omap4_dss_feat_list[] = {
582         FEAT_MGR_LCD2,
583         FEAT_CORE_CLK_DIV,
584         FEAT_LCD_CLK_SRC,
585         FEAT_DSI_DCS_CMD_CONFIG_VC,
586         FEAT_DSI_VC_OCP_WIDTH,
587         FEAT_DSI_GNQ,
588         FEAT_HDMI_CTS_SWMODE,
589         FEAT_HDMI_AUDIO_USE_MCLK,
590         FEAT_HANDLE_UV_SEPARATE,
591         FEAT_ATTR2,
592         FEAT_CPR,
593         FEAT_PRELOAD,
594         FEAT_FIR_COEF_V,
595         FEAT_ALPHA_FREE_ZORDER,
596         FEAT_FIFO_MERGE,
597         FEAT_BURST_2D,
598 };
600 static const enum dss_feat_id omap5_dss_feat_list[] = {
601         FEAT_MGR_LCD2,
602         FEAT_MGR_LCD3,
603         FEAT_CORE_CLK_DIV,
604         FEAT_LCD_CLK_SRC,
605         FEAT_DSI_DCS_CMD_CONFIG_VC,
606         FEAT_DSI_VC_OCP_WIDTH,
607         FEAT_DSI_GNQ,
608         FEAT_HDMI_CTS_SWMODE,
609         FEAT_HDMI_AUDIO_USE_MCLK,
610         FEAT_HANDLE_UV_SEPARATE,
611         FEAT_ATTR2,
612         FEAT_CPR,
613         FEAT_PRELOAD,
614         FEAT_FIR_COEF_V,
615         FEAT_ALPHA_FREE_ZORDER,
616         FEAT_FIFO_MERGE,
617         FEAT_BURST_2D,
618         FEAT_DSI_PHY_DCC,
619         FEAT_MFLAG,
620 };
622 /* OMAP2 DSS Features */
623 static const struct omap_dss_features omap2_dss_features = {
624         .reg_fields = omap2_dss_reg_fields,
625         .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
627         .features = omap2_dss_feat_list,
628         .num_features = ARRAY_SIZE(omap2_dss_feat_list),
630         .num_mgrs = 2,
631         .num_ovls = 3,
632         .supported_displays = omap2_dss_supported_displays,
633         .supported_outputs = omap2_dss_supported_outputs,
634         .supported_color_modes = omap2_dss_supported_color_modes,
635         .overlay_caps = omap2_dss_overlay_caps,
636         .clksrc_names = omap2_dss_clk_source_names,
637         .dss_params = omap2_dss_param_range,
638         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB,
639         .buffer_size_unit = 1,
640         .burst_size_unit = 8,
641 };
643 /* OMAP3 DSS Features */
644 static const struct omap_dss_features omap3430_dss_features = {
645         .reg_fields = omap3_dss_reg_fields,
646         .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
648         .features = omap3430_dss_feat_list,
649         .num_features = ARRAY_SIZE(omap3430_dss_feat_list),
651         .num_mgrs = 2,
652         .num_ovls = 3,
653         .supported_displays = omap3430_dss_supported_displays,
654         .supported_outputs = omap3430_dss_supported_outputs,
655         .supported_color_modes = omap3_dss_supported_color_modes,
656         .overlay_caps = omap3430_dss_overlay_caps,
657         .clksrc_names = omap3_dss_clk_source_names,
658         .dss_params = omap3_dss_param_range,
659         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB,
660         .buffer_size_unit = 1,
661         .burst_size_unit = 8,
662 };
664 /*
665  * AM35xx DSS Features. This is basically OMAP3 DSS Features without the
666  * vdds_dsi regulator.
667  */
668 static const struct omap_dss_features am35xx_dss_features = {
669         .reg_fields = omap3_dss_reg_fields,
670         .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
672         .features = am35xx_dss_feat_list,
673         .num_features = ARRAY_SIZE(am35xx_dss_feat_list),
675         .num_mgrs = 2,
676         .num_ovls = 3,
677         .supported_displays = omap3430_dss_supported_displays,
678         .supported_outputs = omap3430_dss_supported_outputs,
679         .supported_color_modes = omap3_dss_supported_color_modes,
680         .overlay_caps = omap3430_dss_overlay_caps,
681         .clksrc_names = omap3_dss_clk_source_names,
682         .dss_params = omap3_dss_param_range,
683         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB,
684         .buffer_size_unit = 1,
685         .burst_size_unit = 8,
686 };
688 static const struct omap_dss_features am43xx_dss_features = {
689         .reg_fields = am43xx_dss_reg_fields,
690         .num_reg_fields = ARRAY_SIZE(am43xx_dss_reg_fields),
692         .features = am43xx_dss_feat_list,
693         .num_features = ARRAY_SIZE(am43xx_dss_feat_list),
695         .num_mgrs = 1,
696         .num_ovls = 3,
697         .supported_displays = am43xx_dss_supported_displays,
698         .supported_outputs = am43xx_dss_supported_outputs,
699         .supported_color_modes = omap3_dss_supported_color_modes,
700         .overlay_caps = omap3430_dss_overlay_caps,
701         .clksrc_names = omap2_dss_clk_source_names,
702         .dss_params = am43xx_dss_param_range,
703         .supported_rotation_types = OMAP_DSS_ROT_DMA,
704         .buffer_size_unit = 1,
705         .burst_size_unit = 8,
706 };
708 static const struct omap_dss_features omap3630_dss_features = {
709         .reg_fields = omap3_dss_reg_fields,
710         .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
712         .features = omap3630_dss_feat_list,
713         .num_features = ARRAY_SIZE(omap3630_dss_feat_list),
715         .num_mgrs = 2,
716         .num_ovls = 3,
717         .supported_displays = omap3630_dss_supported_displays,
718         .supported_outputs = omap3630_dss_supported_outputs,
719         .supported_color_modes = omap3_dss_supported_color_modes,
720         .overlay_caps = omap3630_dss_overlay_caps,
721         .clksrc_names = omap3_dss_clk_source_names,
722         .dss_params = omap3_dss_param_range,
723         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB,
724         .buffer_size_unit = 1,
725         .burst_size_unit = 8,
726 };
728 /* OMAP4 DSS Features */
729 /* For OMAP4430 ES 1.0 revision */
730 static const struct omap_dss_features omap4430_es1_0_dss_features  = {
731         .reg_fields = omap4_dss_reg_fields,
732         .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
734         .features = omap4430_es1_0_dss_feat_list,
735         .num_features = ARRAY_SIZE(omap4430_es1_0_dss_feat_list),
737         .num_mgrs = 3,
738         .num_ovls = 4,
739         .num_wbs = 1,
740         .supported_displays = omap4_dss_supported_displays,
741         .supported_outputs = omap4_dss_supported_outputs,
742         .supported_color_modes = omap4_dss_supported_color_modes,
743         .overlay_caps = omap4_dss_overlay_caps,
744         .clksrc_names = omap4_dss_clk_source_names,
745         .dss_params = omap4_dss_param_range,
746         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER,
747         .buffer_size_unit = 16,
748         .burst_size_unit = 16,
749 };
751 /* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */
752 static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
753         .reg_fields = omap4_dss_reg_fields,
754         .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
756         .features = omap4430_es2_0_1_2_dss_feat_list,
757         .num_features = ARRAY_SIZE(omap4430_es2_0_1_2_dss_feat_list),
759         .num_mgrs = 3,
760         .num_ovls = 4,
761         .num_wbs = 1,
762         .supported_displays = omap4_dss_supported_displays,
763         .supported_outputs = omap4_dss_supported_outputs,
764         .supported_color_modes = omap4_dss_supported_color_modes,
765         .overlay_caps = omap4_dss_overlay_caps,
766         .clksrc_names = omap4_dss_clk_source_names,
767         .dss_params = omap4_dss_param_range,
768         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER,
769         .buffer_size_unit = 16,
770         .burst_size_unit = 16,
771 };
773 /* For all the other OMAP4 versions */
774 static const struct omap_dss_features omap4_dss_features = {
775         .reg_fields = omap4_dss_reg_fields,
776         .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
778         .features = omap4_dss_feat_list,
779         .num_features = ARRAY_SIZE(omap4_dss_feat_list),
781         .num_mgrs = 3,
782         .num_ovls = 4,
783         .num_wbs = 1,
784         .supported_displays = omap4_dss_supported_displays,
785         .supported_outputs = omap4_dss_supported_outputs,
786         .supported_color_modes = omap4_dss_supported_color_modes,
787         .overlay_caps = omap4_dss_overlay_caps,
788         .clksrc_names = omap4_dss_clk_source_names,
789         .dss_params = omap4_dss_param_range,
790         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER,
791         .buffer_size_unit = 16,
792         .burst_size_unit = 16,
793 };
795 /* OMAP5 DSS Features */
796 static const struct omap_dss_features omap5_dss_features = {
797         .reg_fields = omap5_dss_reg_fields,
798         .num_reg_fields = ARRAY_SIZE(omap5_dss_reg_fields),
800         .features = omap5_dss_feat_list,
801         .num_features = ARRAY_SIZE(omap5_dss_feat_list),
803         .num_mgrs = 4,
804         .num_ovls = 4,
805         .supported_displays = omap5_dss_supported_displays,
806         .supported_outputs = omap5_dss_supported_outputs,
807         .supported_color_modes = omap4_dss_supported_color_modes,
808         .overlay_caps = omap4_dss_overlay_caps,
809         .clksrc_names = omap5_dss_clk_source_names,
810         .dss_params = omap5_dss_param_range,
811         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER,
812         .buffer_size_unit = 16,
813         .burst_size_unit = 16,
814 };
816 /* Functions returning values related to a DSS feature */
817 int dss_feat_get_num_mgrs(void)
819         return omap_current_dss_features->num_mgrs;
821 EXPORT_SYMBOL(dss_feat_get_num_mgrs);
823 int dss_feat_get_num_ovls(void)
825         return omap_current_dss_features->num_ovls;
827 EXPORT_SYMBOL(dss_feat_get_num_ovls);
829 int dss_feat_get_num_wbs(void)
831         return omap_current_dss_features->num_wbs;
834 unsigned long dss_feat_get_param_min(enum dss_range_param param)
836         return omap_current_dss_features->dss_params[param].min;
839 unsigned long dss_feat_get_param_max(enum dss_range_param param)
841         return omap_current_dss_features->dss_params[param].max;
844 enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel)
846         return omap_current_dss_features->supported_displays[channel];
848 EXPORT_SYMBOL(dss_feat_get_supported_displays);
850 enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel)
852         return omap_current_dss_features->supported_outputs[channel];
854 EXPORT_SYMBOL(dss_feat_get_supported_outputs);
856 enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane)
858         return omap_current_dss_features->supported_color_modes[plane];
860 EXPORT_SYMBOL(dss_feat_get_supported_color_modes);
862 enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane plane)
864         return omap_current_dss_features->overlay_caps[plane];
867 bool dss_feat_color_mode_supported(enum omap_plane plane,
868                 enum omap_color_mode color_mode)
870         return omap_current_dss_features->supported_color_modes[plane] &
871                         color_mode;
874 const char *dss_feat_get_clk_source_name(enum omap_dss_clk_source id)
876         return omap_current_dss_features->clksrc_names[id];
879 u32 dss_feat_get_buffer_size_unit(void)
881         return omap_current_dss_features->buffer_size_unit;
884 u32 dss_feat_get_burst_size_unit(void)
886         return omap_current_dss_features->burst_size_unit;
889 /* DSS has_feature check */
890 bool dss_has_feature(enum dss_feat_id id)
892         int i;
893         const enum dss_feat_id *features = omap_current_dss_features->features;
894         const int num_features = omap_current_dss_features->num_features;
896         for (i = 0; i < num_features; i++) {
897                 if (features[i] == id)
898                         return true;
899         }
901         return false;
904 void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
906         if (id >= omap_current_dss_features->num_reg_fields)
907                 BUG();
909         *start = omap_current_dss_features->reg_fields[id].start;
910         *end = omap_current_dss_features->reg_fields[id].end;
913 bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type)
915         return omap_current_dss_features->supported_rotation_types & rot_type;
918 void dss_features_init(enum omapdss_version version)
920         switch (version) {
921         case OMAPDSS_VER_OMAP24xx:
922                 omap_current_dss_features = &omap2_dss_features;
923                 break;
925         case OMAPDSS_VER_OMAP34xx_ES1:
926         case OMAPDSS_VER_OMAP34xx_ES3:
927                 omap_current_dss_features = &omap3430_dss_features;
928                 break;
930         case OMAPDSS_VER_OMAP3630:
931                 omap_current_dss_features = &omap3630_dss_features;
932                 break;
934         case OMAPDSS_VER_OMAP4430_ES1:
935                 omap_current_dss_features = &omap4430_es1_0_dss_features;
936                 break;
938         case OMAPDSS_VER_OMAP4430_ES2:
939                 omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
940                 break;
942         case OMAPDSS_VER_OMAP4:
943                 omap_current_dss_features = &omap4_dss_features;
944                 break;
946         case OMAPDSS_VER_OMAP5:
947         case OMAPDSS_VER_DRA74xx:
948         case OMAPDSS_VER_DRA72xx:
949                 omap_current_dss_features = &omap5_dss_features;
950                 break;
952         case OMAPDSS_VER_AM35xx:
953                 omap_current_dss_features = &am35xx_dss_features;
954                 break;
956         case OMAPDSS_VER_AM43xx:
957                 omap_current_dss_features = &am43xx_dss_features;
958                 break;
960         default:
961                 DSSWARN("Unsupported OMAP version");
962                 break;
963         }