OMAPDSS: provide a way to set number of overlays
[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 static int num_ovls;
33 MODULE_PARM_DESC(num_ovls, "Number of pipelines used for composition");
34 module_param(num_ovls, int, 0600);
36 /* Defines a generic omap register field */
37 struct dss_reg_field {
38         u8 start, end;
39 };
41 struct dss_param_range {
42         int min, max;
43 };
45 struct omap_dss_features {
46         const struct dss_reg_field *reg_fields;
47         const int num_reg_fields;
49         const enum dss_feat_id *features;
50         const int num_features;
52         const int num_mgrs;
53         const int num_ovls;
54         const int num_wbs;
55         const enum omap_display_type *supported_displays;
56         const enum omap_dss_output_id *supported_outputs;
57         const enum omap_color_mode *supported_color_modes;
58         const enum omap_overlay_caps *overlay_caps;
59         const char * const *clksrc_names;
60         const struct dss_param_range *dss_params;
62         const enum omap_dss_rotation_type supported_rotation_types;
64         const u32 buffer_size_unit;
65         const u32 burst_size_unit;
66 };
68 /* This struct is assigned to one of the below during initialization */
69 static const struct omap_dss_features *omap_current_dss_features;
71 static const struct dss_reg_field omap2_dss_reg_fields[] = {
72         [FEAT_REG_FIRHINC]                      = { 11, 0 },
73         [FEAT_REG_FIRVINC]                      = { 27, 16 },
74         [FEAT_REG_FIFOLOWTHRESHOLD]             = { 8, 0 },
75         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 24, 16 },
76         [FEAT_REG_FIFOSIZE]                     = { 8, 0 },
77         [FEAT_REG_HORIZONTALACCU]               = { 9, 0 },
78         [FEAT_REG_VERTICALACCU]                 = { 25, 16 },
79         [FEAT_REG_DISPC_CLK_SWITCH]             = { 0, 0 },
80 };
82 static const struct dss_reg_field omap3_dss_reg_fields[] = {
83         [FEAT_REG_FIRHINC]                      = { 12, 0 },
84         [FEAT_REG_FIRVINC]                      = { 28, 16 },
85         [FEAT_REG_FIFOLOWTHRESHOLD]             = { 11, 0 },
86         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 27, 16 },
87         [FEAT_REG_FIFOSIZE]                     = { 10, 0 },
88         [FEAT_REG_HORIZONTALACCU]               = { 9, 0 },
89         [FEAT_REG_VERTICALACCU]                 = { 25, 16 },
90         [FEAT_REG_DISPC_CLK_SWITCH]             = { 0, 0 },
91 };
93 static const struct dss_reg_field am43xx_dss_reg_fields[] = {
94         [FEAT_REG_FIRHINC]                      = { 12, 0 },
95         [FEAT_REG_FIRVINC]                      = { 28, 16 },
96         [FEAT_REG_FIFOLOWTHRESHOLD]     = { 11, 0 },
97         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 27, 16 },
98         [FEAT_REG_FIFOSIZE]             = { 10, 0 },
99         [FEAT_REG_HORIZONTALACCU]               = { 9, 0 },
100         [FEAT_REG_VERTICALACCU]                 = { 25, 16 },
101         [FEAT_REG_DISPC_CLK_SWITCH]             = { 0, 0 },
102 };
104 static const struct dss_reg_field omap4_dss_reg_fields[] = {
105         [FEAT_REG_FIRHINC]                      = { 12, 0 },
106         [FEAT_REG_FIRVINC]                      = { 28, 16 },
107         [FEAT_REG_FIFOLOWTHRESHOLD]             = { 15, 0 },
108         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 31, 16 },
109         [FEAT_REG_FIFOSIZE]                     = { 15, 0 },
110         [FEAT_REG_HORIZONTALACCU]               = { 10, 0 },
111         [FEAT_REG_VERTICALACCU]                 = { 26, 16 },
112         [FEAT_REG_DISPC_CLK_SWITCH]             = { 9, 8 },
113 };
115 static const struct dss_reg_field omap5_dss_reg_fields[] = {
116         [FEAT_REG_FIRHINC]                      = { 12, 0 },
117         [FEAT_REG_FIRVINC]                      = { 28, 16 },
118         [FEAT_REG_FIFOLOWTHRESHOLD]             = { 15, 0 },
119         [FEAT_REG_FIFOHIGHTHRESHOLD]            = { 31, 16 },
120         [FEAT_REG_FIFOSIZE]                     = { 15, 0 },
121         [FEAT_REG_HORIZONTALACCU]               = { 10, 0 },
122         [FEAT_REG_VERTICALACCU]                 = { 26, 16 },
123         [FEAT_REG_DISPC_CLK_SWITCH]             = { 9, 7 },
124 };
126 static const enum omap_display_type omap2_dss_supported_displays[] = {
127         /* OMAP_DSS_CHANNEL_LCD */
128         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI,
130         /* OMAP_DSS_CHANNEL_DIGIT */
131         OMAP_DISPLAY_TYPE_VENC,
132 };
134 static const enum omap_display_type omap3430_dss_supported_displays[] = {
135         /* OMAP_DSS_CHANNEL_LCD */
136         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
137         OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI,
139         /* OMAP_DSS_CHANNEL_DIGIT */
140         OMAP_DISPLAY_TYPE_VENC,
141 };
143 static const enum omap_display_type omap3630_dss_supported_displays[] = {
144         /* OMAP_DSS_CHANNEL_LCD */
145         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
146         OMAP_DISPLAY_TYPE_DSI,
148         /* OMAP_DSS_CHANNEL_DIGIT */
149         OMAP_DISPLAY_TYPE_VENC,
150 };
152 static const enum omap_display_type am43xx_dss_supported_displays[] = {
153         /* OMAP_DSS_CHANNEL_LCD */
154         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI,
155 };
157 static const enum omap_display_type omap4_dss_supported_displays[] = {
158         /* OMAP_DSS_CHANNEL_LCD */
159         OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI,
161         /* OMAP_DSS_CHANNEL_DIGIT */
162         OMAP_DISPLAY_TYPE_VENC | OMAP_DISPLAY_TYPE_HDMI,
164         /* OMAP_DSS_CHANNEL_LCD2 */
165         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
166         OMAP_DISPLAY_TYPE_DSI,
167 };
169 static const enum omap_display_type omap5_dss_supported_displays[] = {
170         /* OMAP_DSS_CHANNEL_LCD */
171         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
172         OMAP_DISPLAY_TYPE_DSI,
174         /* OMAP_DSS_CHANNEL_DIGIT */
175         OMAP_DISPLAY_TYPE_HDMI | OMAP_DISPLAY_TYPE_DPI,
177         /* OMAP_DSS_CHANNEL_LCD2 */
178         OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI |
179         OMAP_DISPLAY_TYPE_DSI,
180 };
182 static const enum omap_dss_output_id omap2_dss_supported_outputs[] = {
183         /* OMAP_DSS_CHANNEL_LCD */
184         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
186         /* OMAP_DSS_CHANNEL_DIGIT */
187         OMAP_DSS_OUTPUT_VENC,
188 };
190 static const enum omap_dss_output_id omap3430_dss_supported_outputs[] = {
191         /* OMAP_DSS_CHANNEL_LCD */
192         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
193         OMAP_DSS_OUTPUT_SDI | OMAP_DSS_OUTPUT_DSI1,
195         /* OMAP_DSS_CHANNEL_DIGIT */
196         OMAP_DSS_OUTPUT_VENC,
197 };
199 static const enum omap_dss_output_id omap3630_dss_supported_outputs[] = {
200         /* OMAP_DSS_CHANNEL_LCD */
201         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
202         OMAP_DSS_OUTPUT_DSI1,
204         /* OMAP_DSS_CHANNEL_DIGIT */
205         OMAP_DSS_OUTPUT_VENC,
206 };
208 static const enum omap_dss_output_id am43xx_dss_supported_outputs[] = {
209         /* OMAP_DSS_CHANNEL_LCD */
210         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
211 };
213 static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
214         /* OMAP_DSS_CHANNEL_LCD */
215         OMAP_DSS_OUTPUT_DBI | OMAP_DSS_OUTPUT_DSI1,
217         /* OMAP_DSS_CHANNEL_DIGIT */
218         OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI,
220         /* OMAP_DSS_CHANNEL_LCD2 */
221         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
222         OMAP_DSS_OUTPUT_DSI2,
223 };
225 static const enum omap_dss_output_id omap5_dss_supported_outputs[] = {
226         /* OMAP_DSS_CHANNEL_LCD */
227         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
228         OMAP_DSS_OUTPUT_DSI1 | OMAP_DSS_OUTPUT_DSI2,
230         /* OMAP_DSS_CHANNEL_DIGIT */
231         OMAP_DSS_OUTPUT_HDMI | OMAP_DSS_OUTPUT_DPI,
233         /* OMAP_DSS_CHANNEL_LCD2 */
234         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
235         OMAP_DSS_OUTPUT_DSI1,
237         /* OMAP_DSS_CHANNEL_LCD3 */
238         OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
239         OMAP_DSS_OUTPUT_DSI2,
240 };
242 static const enum omap_color_mode omap2_dss_supported_color_modes[] = {
243         /* OMAP_DSS_GFX */
244         OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
245         OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
246         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
247         OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
249         /* OMAP_DSS_VIDEO1 */
250         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
251         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
252         OMAP_DSS_COLOR_UYVY,
254         /* OMAP_DSS_VIDEO2 */
255         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
256         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
257         OMAP_DSS_COLOR_UYVY,
258 };
260 static const enum omap_color_mode omap3_dss_supported_color_modes[] = {
261         /* OMAP_DSS_GFX */
262         OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
263         OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
264         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
265         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
266         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
267         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
269         /* OMAP_DSS_VIDEO1 */
270         OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
271         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
272         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
274         /* OMAP_DSS_VIDEO2 */
275         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
276         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
277         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
278         OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
279         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
280 };
282 static const enum omap_color_mode omap4_dss_supported_color_modes[] = {
283         /* OMAP_DSS_GFX */
284         OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
285         OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
286         OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
287         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
288         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
289         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32 |
290         OMAP_DSS_COLOR_ARGB16_1555 | OMAP_DSS_COLOR_RGBX16 |
291         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_XRGB16_1555,
293         /* OMAP_DSS_VIDEO1 */
294         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
295         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
296         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
297         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
298         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
299         OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
300         OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
301         OMAP_DSS_COLOR_RGBX32,
303        /* OMAP_DSS_VIDEO2 */
304         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
305         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
306         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
307         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
308         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
309         OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
310         OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
311         OMAP_DSS_COLOR_RGBX32,
313         /* OMAP_DSS_VIDEO3 */
314         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
315         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
316         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
317         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
318         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
319         OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
320         OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
321         OMAP_DSS_COLOR_RGBX32,
323         /* OMAP_DSS_WB */
324         OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
325         OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
326         OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
327         OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
328         OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
329         OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
330         OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
331         OMAP_DSS_COLOR_RGBX32,
332 };
334 static const enum omap_overlay_caps omap2_dss_overlay_caps[] = {
335         /* OMAP_DSS_GFX */
336         OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
338         /* OMAP_DSS_VIDEO1 */
339         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
340                 OMAP_DSS_OVL_CAP_REPLICATION,
342         /* OMAP_DSS_VIDEO2 */
343         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
344                 OMAP_DSS_OVL_CAP_REPLICATION,
345 };
347 static const enum omap_overlay_caps omap3430_dss_overlay_caps[] = {
348         /* OMAP_DSS_GFX */
349         OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_POS |
350                 OMAP_DSS_OVL_CAP_REPLICATION,
352         /* OMAP_DSS_VIDEO1 */
353         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
354                 OMAP_DSS_OVL_CAP_REPLICATION,
356         /* OMAP_DSS_VIDEO2 */
357         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
358                 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
359 };
361 static const enum omap_overlay_caps omap3630_dss_overlay_caps[] = {
362         /* OMAP_DSS_GFX */
363         OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
364                 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
366         /* OMAP_DSS_VIDEO1 */
367         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
368                 OMAP_DSS_OVL_CAP_REPLICATION,
370         /* OMAP_DSS_VIDEO2 */
371         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
372                 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_POS |
373                 OMAP_DSS_OVL_CAP_REPLICATION,
374 };
376 static const enum omap_overlay_caps omap4_dss_overlay_caps[] = {
377         /* OMAP_DSS_GFX */
378         OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
379                 OMAP_DSS_OVL_CAP_ZORDER | OMAP_DSS_OVL_CAP_POS |
380                 OMAP_DSS_OVL_CAP_REPLICATION,
382         /* OMAP_DSS_VIDEO1 */
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_VIDEO2 */
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,
392         /* OMAP_DSS_VIDEO3 */
393         OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
394                 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
395                 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
396 };
398 static const char * const omap2_dss_clk_source_names[] = {
399         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC]  = "N/A",
400         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI]    = "N/A",
401         [OMAP_DSS_CLK_SRC_FCK]                  = "DSS_FCLK1",
402 };
404 static const char * const omap3_dss_clk_source_names[] = {
405         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC]  = "DSI1_PLL_FCLK",
406         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI]    = "DSI2_PLL_FCLK",
407         [OMAP_DSS_CLK_SRC_FCK]                  = "DSS1_ALWON_FCLK",
408 };
410 static const char * const omap4_dss_clk_source_names[] = {
411         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC]  = "PLL1_CLK1",
412         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI]    = "PLL1_CLK2",
413         [OMAP_DSS_CLK_SRC_FCK]                  = "DSS_FCLK",
414         [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC] = "PLL2_CLK1",
415         [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI]   = "PLL2_CLK2",
416 };
418 static const char * const omap5_dss_clk_source_names[] = {
419         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC]  = "DPLL_DSI1_A_CLK1",
420         [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI]    = "DPLL_DSI1_A_CLK2",
421         [OMAP_DSS_CLK_SRC_FCK]                  = "DSS_CLK",
422         [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC] = "DPLL_DSI1_C_CLK1",
423         [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI]   = "DPLL_DSI1_C_CLK2",
424 };
426 static const struct dss_param_range omap2_dss_param_range[] = {
427         [FEAT_PARAM_DSS_FCK]                    = { 0, 133000000 },
428         [FEAT_PARAM_DSS_PCD]                    = { 2, 255 },
429         [FEAT_PARAM_DSIPLL_LPDIV]               = { 0, 0 },
430         [FEAT_PARAM_DOWNSCALE]                  = { 1, 2 },
431         /*
432          * Assuming the line width buffer to be 768 pixels as OMAP2 DISPC
433          * scaler cannot scale a image with width more than 768.
434          */
435         [FEAT_PARAM_LINEWIDTH]                  = { 1, 768 },
436 };
438 static const struct dss_param_range omap3_dss_param_range[] = {
439         [FEAT_PARAM_DSS_FCK]                    = { 0, 173000000 },
440         [FEAT_PARAM_DSS_PCD]                    = { 1, 255 },
441         [FEAT_PARAM_DSIPLL_LPDIV]               = { 1, (1 << 13) - 1},
442         [FEAT_PARAM_DSI_FCK]                    = { 0, 173000000 },
443         [FEAT_PARAM_DOWNSCALE]                  = { 1, 4 },
444         [FEAT_PARAM_LINEWIDTH]                  = { 1, 1024 },
445 };
447 static const struct dss_param_range am43xx_dss_param_range[] = {
448         [FEAT_PARAM_DSS_FCK]                    = { 0, 200000000 },
449         [FEAT_PARAM_DSS_PCD]                    = { 1, 255 },
450         [FEAT_PARAM_DOWNSCALE]                  = { 1, 4 },
451         [FEAT_PARAM_LINEWIDTH]                  = { 1, 1024 },
452 };
454 static const struct dss_param_range omap4_dss_param_range[] = {
455         [FEAT_PARAM_DSS_FCK]                    = { 0, 186000000 },
456         [FEAT_PARAM_DSS_PCD]                    = { 1, 255 },
457         [FEAT_PARAM_DSIPLL_LPDIV]               = { 0, (1 << 13) - 1 },
458         [FEAT_PARAM_DSI_FCK]                    = { 0, 170000000 },
459         [FEAT_PARAM_DOWNSCALE]                  = { 1, 4 },
460         [FEAT_PARAM_LINEWIDTH]                  = { 1, 2048 },
461 };
463 static const struct dss_param_range omap5_dss_param_range[] = {
464         [FEAT_PARAM_DSS_FCK]                    = { 0, 209250000 },
465         [FEAT_PARAM_DSS_PCD]                    = { 1, 255 },
466         [FEAT_PARAM_DSIPLL_LPDIV]               = { 0, (1 << 13) - 1 },
467         [FEAT_PARAM_DSI_FCK]                    = { 0, 209250000 },
468         [FEAT_PARAM_DOWNSCALE]                  = { 1, 4 },
469         [FEAT_PARAM_LINEWIDTH]                  = { 1, 2048 },
470 };
472 static const enum dss_feat_id omap2_dss_feat_list[] = {
473         FEAT_LCDENABLEPOL,
474         FEAT_LCDENABLESIGNAL,
475         FEAT_PCKFREEENABLE,
476         FEAT_FUNCGATED,
477         FEAT_ROWREPEATENABLE,
478         FEAT_RESIZECONF,
479 };
481 static const enum dss_feat_id omap3430_dss_feat_list[] = {
482         FEAT_LCDENABLEPOL,
483         FEAT_LCDENABLESIGNAL,
484         FEAT_PCKFREEENABLE,
485         FEAT_FUNCGATED,
486         FEAT_LINEBUFFERSPLIT,
487         FEAT_ROWREPEATENABLE,
488         FEAT_RESIZECONF,
489         FEAT_DSI_REVERSE_TXCLKESC,
490         FEAT_VENC_REQUIRES_TV_DAC_CLK,
491         FEAT_CPR,
492         FEAT_PRELOAD,
493         FEAT_FIR_COEF_V,
494         FEAT_ALPHA_FIXED_ZORDER,
495         FEAT_FIFO_MERGE,
496         FEAT_OMAP3_DSI_FIFO_BUG,
497         FEAT_DPI_USES_VDDS_DSI,
498 };
500 static const enum dss_feat_id am35xx_dss_feat_list[] = {
501         FEAT_LCDENABLEPOL,
502         FEAT_LCDENABLESIGNAL,
503         FEAT_PCKFREEENABLE,
504         FEAT_FUNCGATED,
505         FEAT_LINEBUFFERSPLIT,
506         FEAT_ROWREPEATENABLE,
507         FEAT_RESIZECONF,
508         FEAT_DSI_REVERSE_TXCLKESC,
509         FEAT_VENC_REQUIRES_TV_DAC_CLK,
510         FEAT_CPR,
511         FEAT_PRELOAD,
512         FEAT_FIR_COEF_V,
513         FEAT_ALPHA_FIXED_ZORDER,
514         FEAT_FIFO_MERGE,
515         FEAT_OMAP3_DSI_FIFO_BUG,
516 };
518 static const enum dss_feat_id am43xx_dss_feat_list[] = {
519         FEAT_LCDENABLEPOL,
520         FEAT_LCDENABLESIGNAL,
521         FEAT_PCKFREEENABLE,
522         FEAT_FUNCGATED,
523         FEAT_LINEBUFFERSPLIT,
524         FEAT_ROWREPEATENABLE,
525         FEAT_RESIZECONF,
526         FEAT_CPR,
527         FEAT_PRELOAD,
528         FEAT_FIR_COEF_V,
529         FEAT_ALPHA_FIXED_ZORDER,
530         FEAT_FIFO_MERGE,
531 };
533 static const enum dss_feat_id omap3630_dss_feat_list[] = {
534         FEAT_LCDENABLEPOL,
535         FEAT_LCDENABLESIGNAL,
536         FEAT_PCKFREEENABLE,
537         FEAT_FUNCGATED,
538         FEAT_LINEBUFFERSPLIT,
539         FEAT_ROWREPEATENABLE,
540         FEAT_RESIZECONF,
541         FEAT_DSI_PLL_PWR_BUG,
542         FEAT_CPR,
543         FEAT_PRELOAD,
544         FEAT_FIR_COEF_V,
545         FEAT_ALPHA_FIXED_ZORDER,
546         FEAT_FIFO_MERGE,
547         FEAT_OMAP3_DSI_FIFO_BUG,
548         FEAT_DPI_USES_VDDS_DSI,
549 };
551 static const enum dss_feat_id omap4430_es1_0_dss_feat_list[] = {
552         FEAT_MGR_LCD2,
553         FEAT_CORE_CLK_DIV,
554         FEAT_LCD_CLK_SRC,
555         FEAT_DSI_DCS_CMD_CONFIG_VC,
556         FEAT_DSI_VC_OCP_WIDTH,
557         FEAT_DSI_GNQ,
558         FEAT_HANDLE_UV_SEPARATE,
559         FEAT_ATTR2,
560         FEAT_CPR,
561         FEAT_PRELOAD,
562         FEAT_FIR_COEF_V,
563         FEAT_ALPHA_FREE_ZORDER,
564         FEAT_FIFO_MERGE,
565         FEAT_BURST_2D,
566 };
568 static const enum dss_feat_id omap4430_es2_0_1_2_dss_feat_list[] = {
569         FEAT_MGR_LCD2,
570         FEAT_CORE_CLK_DIV,
571         FEAT_LCD_CLK_SRC,
572         FEAT_DSI_DCS_CMD_CONFIG_VC,
573         FEAT_DSI_VC_OCP_WIDTH,
574         FEAT_DSI_GNQ,
575         FEAT_HDMI_CTS_SWMODE,
576         FEAT_HANDLE_UV_SEPARATE,
577         FEAT_ATTR2,
578         FEAT_CPR,
579         FEAT_PRELOAD,
580         FEAT_FIR_COEF_V,
581         FEAT_ALPHA_FREE_ZORDER,
582         FEAT_FIFO_MERGE,
583         FEAT_BURST_2D,
584 };
586 static const enum dss_feat_id omap4_dss_feat_list[] = {
587         FEAT_MGR_LCD2,
588         FEAT_CORE_CLK_DIV,
589         FEAT_LCD_CLK_SRC,
590         FEAT_DSI_DCS_CMD_CONFIG_VC,
591         FEAT_DSI_VC_OCP_WIDTH,
592         FEAT_DSI_GNQ,
593         FEAT_HDMI_CTS_SWMODE,
594         FEAT_HDMI_AUDIO_USE_MCLK,
595         FEAT_HANDLE_UV_SEPARATE,
596         FEAT_ATTR2,
597         FEAT_CPR,
598         FEAT_PRELOAD,
599         FEAT_FIR_COEF_V,
600         FEAT_ALPHA_FREE_ZORDER,
601         FEAT_FIFO_MERGE,
602         FEAT_BURST_2D,
603 };
605 static const enum dss_feat_id omap5_dss_feat_list[] = {
606         FEAT_MGR_LCD2,
607         FEAT_MGR_LCD3,
608         FEAT_CORE_CLK_DIV,
609         FEAT_LCD_CLK_SRC,
610         FEAT_DSI_DCS_CMD_CONFIG_VC,
611         FEAT_DSI_VC_OCP_WIDTH,
612         FEAT_DSI_GNQ,
613         FEAT_HDMI_CTS_SWMODE,
614         FEAT_HDMI_AUDIO_USE_MCLK,
615         FEAT_HANDLE_UV_SEPARATE,
616         FEAT_ATTR2,
617         FEAT_CPR,
618         FEAT_PRELOAD,
619         FEAT_FIR_COEF_V,
620         FEAT_ALPHA_FREE_ZORDER,
621         FEAT_FIFO_MERGE,
622         FEAT_BURST_2D,
623         FEAT_DSI_PHY_DCC,
624         FEAT_MFLAG,
625 };
627 /* OMAP2 DSS Features */
628 static const struct omap_dss_features omap2_dss_features = {
629         .reg_fields = omap2_dss_reg_fields,
630         .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
632         .features = omap2_dss_feat_list,
633         .num_features = ARRAY_SIZE(omap2_dss_feat_list),
635         .num_mgrs = 2,
636         .num_ovls = 3,
637         .supported_displays = omap2_dss_supported_displays,
638         .supported_outputs = omap2_dss_supported_outputs,
639         .supported_color_modes = omap2_dss_supported_color_modes,
640         .overlay_caps = omap2_dss_overlay_caps,
641         .clksrc_names = omap2_dss_clk_source_names,
642         .dss_params = omap2_dss_param_range,
643         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB,
644         .buffer_size_unit = 1,
645         .burst_size_unit = 8,
646 };
648 /* OMAP3 DSS Features */
649 static const struct omap_dss_features omap3430_dss_features = {
650         .reg_fields = omap3_dss_reg_fields,
651         .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
653         .features = omap3430_dss_feat_list,
654         .num_features = ARRAY_SIZE(omap3430_dss_feat_list),
656         .num_mgrs = 2,
657         .num_ovls = 3,
658         .supported_displays = omap3430_dss_supported_displays,
659         .supported_outputs = omap3430_dss_supported_outputs,
660         .supported_color_modes = omap3_dss_supported_color_modes,
661         .overlay_caps = omap3430_dss_overlay_caps,
662         .clksrc_names = omap3_dss_clk_source_names,
663         .dss_params = omap3_dss_param_range,
664         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB,
665         .buffer_size_unit = 1,
666         .burst_size_unit = 8,
667 };
669 /*
670  * AM35xx DSS Features. This is basically OMAP3 DSS Features without the
671  * vdds_dsi regulator.
672  */
673 static const struct omap_dss_features am35xx_dss_features = {
674         .reg_fields = omap3_dss_reg_fields,
675         .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
677         .features = am35xx_dss_feat_list,
678         .num_features = ARRAY_SIZE(am35xx_dss_feat_list),
680         .num_mgrs = 2,
681         .num_ovls = 3,
682         .supported_displays = omap3430_dss_supported_displays,
683         .supported_outputs = omap3430_dss_supported_outputs,
684         .supported_color_modes = omap3_dss_supported_color_modes,
685         .overlay_caps = omap3430_dss_overlay_caps,
686         .clksrc_names = omap3_dss_clk_source_names,
687         .dss_params = omap3_dss_param_range,
688         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB,
689         .buffer_size_unit = 1,
690         .burst_size_unit = 8,
691 };
693 static const struct omap_dss_features am43xx_dss_features = {
694         .reg_fields = am43xx_dss_reg_fields,
695         .num_reg_fields = ARRAY_SIZE(am43xx_dss_reg_fields),
697         .features = am43xx_dss_feat_list,
698         .num_features = ARRAY_SIZE(am43xx_dss_feat_list),
700         .num_mgrs = 1,
701         .num_ovls = 3,
702         .supported_displays = am43xx_dss_supported_displays,
703         .supported_outputs = am43xx_dss_supported_outputs,
704         .supported_color_modes = omap3_dss_supported_color_modes,
705         .overlay_caps = omap3430_dss_overlay_caps,
706         .clksrc_names = omap2_dss_clk_source_names,
707         .dss_params = am43xx_dss_param_range,
708         .supported_rotation_types = OMAP_DSS_ROT_DMA,
709         .buffer_size_unit = 1,
710         .burst_size_unit = 8,
711 };
713 static const struct omap_dss_features omap3630_dss_features = {
714         .reg_fields = omap3_dss_reg_fields,
715         .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
717         .features = omap3630_dss_feat_list,
718         .num_features = ARRAY_SIZE(omap3630_dss_feat_list),
720         .num_mgrs = 2,
721         .num_ovls = 3,
722         .supported_displays = omap3630_dss_supported_displays,
723         .supported_outputs = omap3630_dss_supported_outputs,
724         .supported_color_modes = omap3_dss_supported_color_modes,
725         .overlay_caps = omap3630_dss_overlay_caps,
726         .clksrc_names = omap3_dss_clk_source_names,
727         .dss_params = omap3_dss_param_range,
728         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB,
729         .buffer_size_unit = 1,
730         .burst_size_unit = 8,
731 };
733 /* OMAP4 DSS Features */
734 /* For OMAP4430 ES 1.0 revision */
735 static const struct omap_dss_features omap4430_es1_0_dss_features  = {
736         .reg_fields = omap4_dss_reg_fields,
737         .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
739         .features = omap4430_es1_0_dss_feat_list,
740         .num_features = ARRAY_SIZE(omap4430_es1_0_dss_feat_list),
742         .num_mgrs = 3,
743         .num_ovls = 4,
744         .num_wbs = 1,
745         .supported_displays = omap4_dss_supported_displays,
746         .supported_outputs = omap4_dss_supported_outputs,
747         .supported_color_modes = omap4_dss_supported_color_modes,
748         .overlay_caps = omap4_dss_overlay_caps,
749         .clksrc_names = omap4_dss_clk_source_names,
750         .dss_params = omap4_dss_param_range,
751         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER,
752         .buffer_size_unit = 16,
753         .burst_size_unit = 16,
754 };
756 /* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */
757 static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
758         .reg_fields = omap4_dss_reg_fields,
759         .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
761         .features = omap4430_es2_0_1_2_dss_feat_list,
762         .num_features = ARRAY_SIZE(omap4430_es2_0_1_2_dss_feat_list),
764         .num_mgrs = 3,
765         .num_ovls = 4,
766         .num_wbs = 1,
767         .supported_displays = omap4_dss_supported_displays,
768         .supported_outputs = omap4_dss_supported_outputs,
769         .supported_color_modes = omap4_dss_supported_color_modes,
770         .overlay_caps = omap4_dss_overlay_caps,
771         .clksrc_names = omap4_dss_clk_source_names,
772         .dss_params = omap4_dss_param_range,
773         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER,
774         .buffer_size_unit = 16,
775         .burst_size_unit = 16,
776 };
778 /* For all the other OMAP4 versions */
779 static const struct omap_dss_features omap4_dss_features = {
780         .reg_fields = omap4_dss_reg_fields,
781         .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
783         .features = omap4_dss_feat_list,
784         .num_features = ARRAY_SIZE(omap4_dss_feat_list),
786         .num_mgrs = 3,
787         .num_ovls = 4,
788         .num_wbs = 1,
789         .supported_displays = omap4_dss_supported_displays,
790         .supported_outputs = omap4_dss_supported_outputs,
791         .supported_color_modes = omap4_dss_supported_color_modes,
792         .overlay_caps = omap4_dss_overlay_caps,
793         .clksrc_names = omap4_dss_clk_source_names,
794         .dss_params = omap4_dss_param_range,
795         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER,
796         .buffer_size_unit = 16,
797         .burst_size_unit = 16,
798 };
800 /* OMAP5 DSS Features */
801 static const struct omap_dss_features omap5_dss_features = {
802         .reg_fields = omap5_dss_reg_fields,
803         .num_reg_fields = ARRAY_SIZE(omap5_dss_reg_fields),
805         .features = omap5_dss_feat_list,
806         .num_features = ARRAY_SIZE(omap5_dss_feat_list),
808         .num_mgrs = 4,
809         .num_ovls = CONFIG_OMAP2_DSS_NUM_OVLS,
810         .supported_displays = omap5_dss_supported_displays,
811         .supported_outputs = omap5_dss_supported_outputs,
812         .supported_color_modes = omap4_dss_supported_color_modes,
813         .overlay_caps = omap4_dss_overlay_caps,
814         .clksrc_names = omap5_dss_clk_source_names,
815         .dss_params = omap5_dss_param_range,
816         .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER,
817         .buffer_size_unit = 16,
818         .burst_size_unit = 16,
819 };
821 /* Functions returning values related to a DSS feature */
822 int dss_feat_get_num_mgrs(void)
824         return omap_current_dss_features->num_mgrs;
826 EXPORT_SYMBOL(dss_feat_get_num_mgrs);
828 int dss_feat_get_num_ovls(void)
830         return num_ovls ? num_ovls : omap_current_dss_features->num_ovls;
832 EXPORT_SYMBOL(dss_feat_get_num_ovls);
834 int dss_feat_get_num_wbs(void)
836         return omap_current_dss_features->num_wbs;
839 unsigned long dss_feat_get_param_min(enum dss_range_param param)
841         return omap_current_dss_features->dss_params[param].min;
844 unsigned long dss_feat_get_param_max(enum dss_range_param param)
846         return omap_current_dss_features->dss_params[param].max;
849 enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel)
851         return omap_current_dss_features->supported_displays[channel];
853 EXPORT_SYMBOL(dss_feat_get_supported_displays);
855 enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel)
857         return omap_current_dss_features->supported_outputs[channel];
859 EXPORT_SYMBOL(dss_feat_get_supported_outputs);
861 enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane)
863         return omap_current_dss_features->supported_color_modes[plane];
865 EXPORT_SYMBOL(dss_feat_get_supported_color_modes);
867 enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane plane)
869         return omap_current_dss_features->overlay_caps[plane];
872 bool dss_feat_color_mode_supported(enum omap_plane plane,
873                 enum omap_color_mode color_mode)
875         return omap_current_dss_features->supported_color_modes[plane] &
876                         color_mode;
879 const char *dss_feat_get_clk_source_name(enum omap_dss_clk_source id)
881         return omap_current_dss_features->clksrc_names[id];
884 u32 dss_feat_get_buffer_size_unit(void)
886         return omap_current_dss_features->buffer_size_unit;
889 u32 dss_feat_get_burst_size_unit(void)
891         return omap_current_dss_features->burst_size_unit;
894 /* DSS has_feature check */
895 bool dss_has_feature(enum dss_feat_id id)
897         int i;
898         const enum dss_feat_id *features = omap_current_dss_features->features;
899         const int num_features = omap_current_dss_features->num_features;
901         for (i = 0; i < num_features; i++) {
902                 if (features[i] == id)
903                         return true;
904         }
906         return false;
909 void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
911         if (id >= omap_current_dss_features->num_reg_fields)
912                 BUG();
914         *start = omap_current_dss_features->reg_fields[id].start;
915         *end = omap_current_dss_features->reg_fields[id].end;
918 bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type)
920         return omap_current_dss_features->supported_rotation_types & rot_type;
923 void dss_features_init(enum omapdss_version version)
925         switch (version) {
926         case OMAPDSS_VER_OMAP24xx:
927                 omap_current_dss_features = &omap2_dss_features;
928                 break;
930         case OMAPDSS_VER_OMAP34xx_ES1:
931         case OMAPDSS_VER_OMAP34xx_ES3:
932                 omap_current_dss_features = &omap3430_dss_features;
933                 break;
935         case OMAPDSS_VER_OMAP3630:
936                 omap_current_dss_features = &omap3630_dss_features;
937                 break;
939         case OMAPDSS_VER_OMAP4430_ES1:
940                 omap_current_dss_features = &omap4430_es1_0_dss_features;
941                 break;
943         case OMAPDSS_VER_OMAP4430_ES2:
944                 omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
945                 break;
947         case OMAPDSS_VER_OMAP4:
948                 omap_current_dss_features = &omap4_dss_features;
949                 break;
951         case OMAPDSS_VER_OMAP5:
952         case OMAPDSS_VER_DRA74xx:
953         case OMAPDSS_VER_DRA72xx:
954                 omap_current_dss_features = &omap5_dss_features;
955                 break;
957         case OMAPDSS_VER_AM35xx:
958                 omap_current_dss_features = &am35xx_dss_features;
959                 break;
961         case OMAPDSS_VER_AM43xx:
962                 omap_current_dss_features = &am43xx_dss_features;
963                 break;
965         default:
966                 DSSWARN("Unsupported OMAP version");
967                 break;
968         }