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 }, |
| 57 | }; |
| 58 | |
| 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 }, |
| 65 | }; |
| 66 | |
| 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, |
| 71 | |
| 72 | /* OMAP_DSS_CHANNEL_DIGIT */ |
| 73 | OMAP_DISPLAY_TYPE_VENC, |
| 74 | }; |
| 75 | |
| 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, |
| 80 | |
| 81 | /* OMAP_DSS_CHANNEL_DIGIT */ |
| 82 | OMAP_DISPLAY_TYPE_VENC, |
| 83 | }; |
| 84 | |
| 85 | static const enum omap_color_mode omap2_dss_supported_color_modes[] = { |
| 86 | /* OMAP_DSS_GFX */ |
| 87 | OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 | |
| 88 | OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 | |
| 89 | OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 | |
| 90 | OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P, |
| 91 | |
| 92 | /* OMAP_DSS_VIDEO1 */ |
| 93 | OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | |
| 94 | OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 | |
| 95 | OMAP_DSS_COLOR_UYVY, |
| 96 | |
| 97 | /* OMAP_DSS_VIDEO2 */ |
| 98 | OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | |
| 99 | OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 | |
| 100 | OMAP_DSS_COLOR_UYVY, |
| 101 | }; |
| 102 | |
| 103 | static const enum omap_color_mode omap3_dss_supported_color_modes[] = { |
| 104 | /* OMAP_DSS_GFX */ |
| 105 | OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 | |
| 106 | OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 | |
| 107 | OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 | |
| 108 | OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | |
| 109 | OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 | |
| 110 | OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32, |
| 111 | |
| 112 | /* OMAP_DSS_VIDEO1 */ |
| 113 | OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P | |
| 114 | OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 | |
| 115 | OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY, |
| 116 | |
| 117 | /* OMAP_DSS_VIDEO2 */ |
| 118 | OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 | |
| 119 | OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | |
| 120 | OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 | |
| 121 | OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 | |
| 122 | OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32, |
| 123 | }; |
| 124 | |
| 125 | /* OMAP2 DSS Features */ |
| 126 | static struct omap_dss_features omap2_dss_features = { |
| 127 | .reg_fields = omap2_dss_reg_fields, |
| 128 | .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields), |
| 129 | |
| 130 | .num_mgrs = 2, |
| 131 | .num_ovls = 3, |
| 132 | .supported_displays = omap2_dss_supported_displays, |
| 133 | .supported_color_modes = omap2_dss_supported_color_modes, |
| 134 | }; |
| 135 | |
| 136 | /* OMAP3 DSS Features */ |
| 137 | static struct omap_dss_features omap3_dss_features = { |
| 138 | .reg_fields = omap3_dss_reg_fields, |
| 139 | .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields), |
| 140 | |
| 141 | .has_feature = FEAT_GLOBAL_ALPHA, |
| 142 | |
| 143 | .num_mgrs = 2, |
| 144 | .num_ovls = 3, |
| 145 | .supported_displays = omap3_dss_supported_displays, |
| 146 | .supported_color_modes = omap3_dss_supported_color_modes, |
| 147 | }; |
| 148 | |
| 149 | /* Functions returning values related to a DSS feature */ |
| 150 | int dss_feat_get_num_mgrs(void) |
| 151 | { |
| 152 | return omap_current_dss_features->num_mgrs; |
| 153 | } |
| 154 | |
| 155 | int dss_feat_get_num_ovls(void) |
| 156 | { |
| 157 | return omap_current_dss_features->num_ovls; |
| 158 | } |
| 159 | |
| 160 | enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel) |
| 161 | { |
| 162 | return omap_current_dss_features->supported_displays[channel]; |
| 163 | } |
| 164 | |
| 165 | enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane) |
| 166 | { |
| 167 | return omap_current_dss_features->supported_color_modes[plane]; |
| 168 | } |
| 169 | |
| 170 | /* DSS has_feature check */ |
| 171 | bool dss_has_feature(enum dss_feat_id id) |
| 172 | { |
| 173 | return omap_current_dss_features->has_feature & id; |
| 174 | } |
| 175 | |
| 176 | void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end) |
| 177 | { |
| 178 | if (id >= omap_current_dss_features->num_reg_fields) |
| 179 | BUG(); |
| 180 | |
| 181 | *start = omap_current_dss_features->reg_fields[id].start; |
| 182 | *end = omap_current_dss_features->reg_fields[id].end; |
| 183 | } |
| 184 | |
| 185 | void dss_features_init(void) |
| 186 | { |
| 187 | if (cpu_is_omap24xx()) |
| 188 | omap_current_dss_features = &omap2_dss_features; |
| 189 | else |
| 190 | omap_current_dss_features = &omap3_dss_features; |
| 191 | } |