Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 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 | */ |
| 19 | |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/types.h> |
| 22 | #include <linux/err.h> |
| 23 | #include <linux/slab.h> |
| 24 | |
| 25 | #include <plat/display.h> |
| 26 | #include <plat/cpu.h> |
| 27 | |
| 28 | #include "dss_features.h" |
| 29 | |
| 30 | /* Defines a generic omap register field */ |
| 31 | struct dss_reg_field { |
| 32 | enum dss_feat_reg_field id; |
| 33 | u8 start, end; |
| 34 | }; |
| 35 | |
| 36 | struct omap_dss_features { |
| 37 | const struct dss_reg_field *reg_fields; |
| 38 | const int num_reg_fields; |
| 39 | |
| 40 | const u32 has_feature; |
| 41 | |
| 42 | const int num_mgrs; |
| 43 | const int num_ovls; |
| 44 | const enum omap_display_type *supported_displays; |
| 45 | const enum omap_color_mode *supported_color_modes; |
| 46 | }; |
| 47 | |
| 48 | /* This struct is assigned to one of the below during initialization */ |
| 49 | static struct omap_dss_features *omap_current_dss_features; |
| 50 | |
| 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 }, |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame^] | 57 | { FEAT_REG_HORIZONTALACCU, 9, 0 }, |
| 58 | { FEAT_REG_VERTICALACCU, 25, 16 }, |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static const struct dss_reg_field omap3_dss_reg_fields[] = { |
| 62 | { FEAT_REG_FIRHINC, 12, 0 }, |
| 63 | { FEAT_REG_FIRVINC, 28, 16 }, |
| 64 | { FEAT_REG_FIFOLOWTHRESHOLD, 11, 0 }, |
| 65 | { FEAT_REG_FIFOHIGHTHRESHOLD, 27, 16 }, |
| 66 | { FEAT_REG_FIFOSIZE, 10, 0 }, |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame^] | 67 | { FEAT_REG_HORIZONTALACCU, 9, 0 }, |
| 68 | { FEAT_REG_VERTICALACCU, 25, 16 }, |
| 69 | }; |
| 70 | |
| 71 | static const struct dss_reg_field omap4_dss_reg_fields[] = { |
| 72 | { FEAT_REG_FIRHINC, 12, 0 }, |
| 73 | { FEAT_REG_FIRVINC, 28, 16 }, |
| 74 | { FEAT_REG_FIFOLOWTHRESHOLD, 15, 0 }, |
| 75 | { FEAT_REG_FIFOHIGHTHRESHOLD, 31, 16 }, |
| 76 | { FEAT_REG_FIFOSIZE, 15, 0 }, |
| 77 | { FEAT_REG_HORIZONTALACCU, 10, 0 }, |
| 78 | { FEAT_REG_VERTICALACCU, 26, 16 }, |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | static const enum omap_display_type omap2_dss_supported_displays[] = { |
| 82 | /* OMAP_DSS_CHANNEL_LCD */ |
Tomi Valkeinen | f8df01f | 2011-02-24 14:21:25 +0200 | [diff] [blame] | 83 | OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI, |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 84 | |
| 85 | /* OMAP_DSS_CHANNEL_DIGIT */ |
| 86 | OMAP_DISPLAY_TYPE_VENC, |
| 87 | }; |
| 88 | |
Tomi Valkeinen | 4e777dd | 2011-02-24 14:20:31 +0200 | [diff] [blame] | 89 | static const enum omap_display_type omap3430_dss_supported_displays[] = { |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 90 | /* OMAP_DSS_CHANNEL_LCD */ |
| 91 | OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI | |
| 92 | OMAP_DISPLAY_TYPE_SDI | OMAP_DISPLAY_TYPE_DSI, |
| 93 | |
| 94 | /* OMAP_DSS_CHANNEL_DIGIT */ |
| 95 | OMAP_DISPLAY_TYPE_VENC, |
| 96 | }; |
| 97 | |
Tomi Valkeinen | 4e777dd | 2011-02-24 14:20:31 +0200 | [diff] [blame] | 98 | static const enum omap_display_type omap3630_dss_supported_displays[] = { |
| 99 | /* OMAP_DSS_CHANNEL_LCD */ |
| 100 | OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI | |
| 101 | OMAP_DISPLAY_TYPE_DSI, |
| 102 | |
| 103 | /* OMAP_DSS_CHANNEL_DIGIT */ |
| 104 | OMAP_DISPLAY_TYPE_VENC, |
| 105 | }; |
| 106 | |
Archit Taneja | d50cd03 | 2010-12-02 11:27:08 +0000 | [diff] [blame] | 107 | static const enum omap_display_type omap4_dss_supported_displays[] = { |
| 108 | /* OMAP_DSS_CHANNEL_LCD */ |
| 109 | OMAP_DISPLAY_TYPE_DBI | OMAP_DISPLAY_TYPE_DSI, |
| 110 | |
| 111 | /* OMAP_DSS_CHANNEL_DIGIT */ |
| 112 | OMAP_DISPLAY_TYPE_VENC, |
| 113 | |
| 114 | /* OMAP_DSS_CHANNEL_LCD2 */ |
| 115 | OMAP_DISPLAY_TYPE_DPI | OMAP_DISPLAY_TYPE_DBI | |
| 116 | OMAP_DISPLAY_TYPE_DSI, |
| 117 | }; |
| 118 | |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 119 | static const enum omap_color_mode omap2_dss_supported_color_modes[] = { |
| 120 | /* OMAP_DSS_GFX */ |
| 121 | OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 | |
| 122 | OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 | |
| 123 | OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 | |
| 124 | OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P, |
| 125 | |
| 126 | /* OMAP_DSS_VIDEO1 */ |
| 127 | OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | |
| 128 | OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 | |
| 129 | OMAP_DSS_COLOR_UYVY, |
| 130 | |
| 131 | /* OMAP_DSS_VIDEO2 */ |
| 132 | OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | |
| 133 | OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 | |
| 134 | OMAP_DSS_COLOR_UYVY, |
| 135 | }; |
| 136 | |
| 137 | static const enum omap_color_mode omap3_dss_supported_color_modes[] = { |
| 138 | /* OMAP_DSS_GFX */ |
| 139 | OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 | |
| 140 | OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 | |
| 141 | OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 | |
| 142 | OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | |
| 143 | OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 | |
| 144 | OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32, |
| 145 | |
| 146 | /* OMAP_DSS_VIDEO1 */ |
| 147 | OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P | |
| 148 | OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 | |
| 149 | OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY, |
| 150 | |
| 151 | /* OMAP_DSS_VIDEO2 */ |
| 152 | OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 | |
| 153 | OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | |
| 154 | OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 | |
| 155 | OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 | |
| 156 | OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32, |
| 157 | }; |
| 158 | |
| 159 | /* OMAP2 DSS Features */ |
| 160 | static struct omap_dss_features omap2_dss_features = { |
| 161 | .reg_fields = omap2_dss_reg_fields, |
| 162 | .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields), |
| 163 | |
Archit Taneja | d50cd03 | 2010-12-02 11:27:08 +0000 | [diff] [blame] | 164 | .has_feature = |
| 165 | FEAT_LCDENABLEPOL | FEAT_LCDENABLESIGNAL | |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame^] | 166 | FEAT_PCKFREEENABLE | FEAT_FUNCGATED | |
| 167 | FEAT_ROWREPEATENABLE | FEAT_RESIZECONF, |
Archit Taneja | d50cd03 | 2010-12-02 11:27:08 +0000 | [diff] [blame] | 168 | |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 169 | .num_mgrs = 2, |
| 170 | .num_ovls = 3, |
| 171 | .supported_displays = omap2_dss_supported_displays, |
| 172 | .supported_color_modes = omap2_dss_supported_color_modes, |
| 173 | }; |
| 174 | |
| 175 | /* OMAP3 DSS Features */ |
Samreen | 8fbde10 | 2010-11-04 12:28:41 +0100 | [diff] [blame] | 176 | static struct omap_dss_features omap3430_dss_features = { |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 177 | .reg_fields = omap3_dss_reg_fields, |
| 178 | .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields), |
| 179 | |
Archit Taneja | d50cd03 | 2010-12-02 11:27:08 +0000 | [diff] [blame] | 180 | .has_feature = |
| 181 | FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL | |
| 182 | FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE | |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame^] | 183 | FEAT_FUNCGATED | FEAT_ROWREPEATENABLE | |
| 184 | FEAT_LINEBUFFERSPLIT | FEAT_RESIZECONF, |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 185 | |
| 186 | .num_mgrs = 2, |
| 187 | .num_ovls = 3, |
Tomi Valkeinen | 4e777dd | 2011-02-24 14:20:31 +0200 | [diff] [blame] | 188 | .supported_displays = omap3430_dss_supported_displays, |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 189 | .supported_color_modes = omap3_dss_supported_color_modes, |
| 190 | }; |
| 191 | |
Samreen | 8fbde10 | 2010-11-04 12:28:41 +0100 | [diff] [blame] | 192 | static struct omap_dss_features omap3630_dss_features = { |
| 193 | .reg_fields = omap3_dss_reg_fields, |
| 194 | .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields), |
| 195 | |
Archit Taneja | d50cd03 | 2010-12-02 11:27:08 +0000 | [diff] [blame] | 196 | .has_feature = |
| 197 | FEAT_GLOBAL_ALPHA | FEAT_LCDENABLEPOL | |
| 198 | FEAT_LCDENABLESIGNAL | FEAT_PCKFREEENABLE | |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame^] | 199 | FEAT_PRE_MULT_ALPHA | FEAT_FUNCGATED | |
| 200 | FEAT_ROWREPEATENABLE | FEAT_LINEBUFFERSPLIT | |
| 201 | FEAT_RESIZECONF, |
Samreen | 8fbde10 | 2010-11-04 12:28:41 +0100 | [diff] [blame] | 202 | |
| 203 | .num_mgrs = 2, |
| 204 | .num_ovls = 3, |
Tomi Valkeinen | 4e777dd | 2011-02-24 14:20:31 +0200 | [diff] [blame] | 205 | .supported_displays = omap3630_dss_supported_displays, |
Samreen | 8fbde10 | 2010-11-04 12:28:41 +0100 | [diff] [blame] | 206 | .supported_color_modes = omap3_dss_supported_color_modes, |
| 207 | }; |
| 208 | |
Archit Taneja | d50cd03 | 2010-12-02 11:27:08 +0000 | [diff] [blame] | 209 | /* OMAP4 DSS Features */ |
| 210 | static struct omap_dss_features omap4_dss_features = { |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame^] | 211 | .reg_fields = omap4_dss_reg_fields, |
| 212 | .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields), |
Archit Taneja | d50cd03 | 2010-12-02 11:27:08 +0000 | [diff] [blame] | 213 | |
| 214 | .has_feature = |
| 215 | FEAT_GLOBAL_ALPHA | FEAT_PRE_MULT_ALPHA | |
Archit Taneja | 87a7484 | 2011-03-02 11:19:50 +0530 | [diff] [blame^] | 216 | FEAT_MGR_LCD2 | FEAT_GLOBAL_ALPHA_VID1, |
Archit Taneja | d50cd03 | 2010-12-02 11:27:08 +0000 | [diff] [blame] | 217 | |
| 218 | .num_mgrs = 3, |
| 219 | .num_ovls = 3, |
| 220 | .supported_displays = omap4_dss_supported_displays, |
| 221 | .supported_color_modes = omap3_dss_supported_color_modes, |
| 222 | }; |
| 223 | |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 224 | /* Functions returning values related to a DSS feature */ |
| 225 | int dss_feat_get_num_mgrs(void) |
| 226 | { |
| 227 | return omap_current_dss_features->num_mgrs; |
| 228 | } |
| 229 | |
| 230 | int dss_feat_get_num_ovls(void) |
| 231 | { |
| 232 | return omap_current_dss_features->num_ovls; |
| 233 | } |
| 234 | |
| 235 | enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel) |
| 236 | { |
| 237 | return omap_current_dss_features->supported_displays[channel]; |
| 238 | } |
| 239 | |
| 240 | enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane) |
| 241 | { |
| 242 | return omap_current_dss_features->supported_color_modes[plane]; |
| 243 | } |
| 244 | |
Archit Taneja | 8dad2ab | 2010-11-25 17:58:10 +0530 | [diff] [blame] | 245 | bool dss_feat_color_mode_supported(enum omap_plane plane, |
| 246 | enum omap_color_mode color_mode) |
| 247 | { |
| 248 | return omap_current_dss_features->supported_color_modes[plane] & |
| 249 | color_mode; |
| 250 | } |
| 251 | |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 252 | /* DSS has_feature check */ |
| 253 | bool dss_has_feature(enum dss_feat_id id) |
| 254 | { |
| 255 | return omap_current_dss_features->has_feature & id; |
| 256 | } |
| 257 | |
| 258 | void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end) |
| 259 | { |
| 260 | if (id >= omap_current_dss_features->num_reg_fields) |
| 261 | BUG(); |
| 262 | |
| 263 | *start = omap_current_dss_features->reg_fields[id].start; |
| 264 | *end = omap_current_dss_features->reg_fields[id].end; |
| 265 | } |
| 266 | |
| 267 | void dss_features_init(void) |
| 268 | { |
| 269 | if (cpu_is_omap24xx()) |
| 270 | omap_current_dss_features = &omap2_dss_features; |
Samreen | 8fbde10 | 2010-11-04 12:28:41 +0100 | [diff] [blame] | 271 | else if (cpu_is_omap3630()) |
| 272 | omap_current_dss_features = &omap3630_dss_features; |
| 273 | else if (cpu_is_omap34xx()) |
| 274 | omap_current_dss_features = &omap3430_dss_features; |
Archit Taneja | d50cd03 | 2010-12-02 11:27:08 +0000 | [diff] [blame] | 275 | else |
| 276 | omap_current_dss_features = &omap4_dss_features; |
Archit Taneja | e1ef4d2 | 2010-09-15 18:47:29 +0530 | [diff] [blame] | 277 | } |