dss_features.c 17.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * linux/drivers/video/omap2/dss/dss_features.c
 *
 * Copyright (C) 2010 Texas Instruments
 * Author: Archit Taneja <archit@ti.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <linux/kernel.h>
21
#include <linux/module.h>
22 23 24
#include <linux/types.h>
#include <linux/err.h>
#include <linux/slab.h>
25
#include <drm/drm_fourcc.h>
26

27
#include "omapdss.h"
28
#include "dss.h"
29 30 31 32 33 34 35
#include "dss_features.h"

/* Defines a generic omap register field */
struct dss_reg_field {
	u8 start, end;
};

36 37 38 39
struct dss_param_range {
	int min, max;
};

40 41 42 43
struct omap_dss_features {
	const struct dss_reg_field *reg_fields;
	const int num_reg_fields;

44 45
	const enum dss_feat_id *features;
	const int num_features;
46 47 48

	const int num_mgrs;
	const int num_ovls;
49
	const enum omap_dss_output_id *supported_outputs;
50
	const enum omap_overlay_caps *overlay_caps;
51
	const struct dss_param_range *dss_params;
52 53 54
};

/* This struct is assigned to one of the below during initialization */
55
static const struct omap_dss_features *omap_current_dss_features;
56 57

static const struct dss_reg_field omap2_dss_reg_fields[] = {
58 59 60 61 62 63 64 65
	[FEAT_REG_FIRHINC]			= { 11, 0 },
	[FEAT_REG_FIRVINC]			= { 27, 16 },
	[FEAT_REG_FIFOLOWTHRESHOLD]		= { 8, 0 },
	[FEAT_REG_FIFOHIGHTHRESHOLD]		= { 24, 16 },
	[FEAT_REG_FIFOSIZE]			= { 8, 0 },
	[FEAT_REG_HORIZONTALACCU]		= { 9, 0 },
	[FEAT_REG_VERTICALACCU]			= { 25, 16 },
	[FEAT_REG_DISPC_CLK_SWITCH]		= { 0, 0 },
66 67 68
};

static const struct dss_reg_field omap3_dss_reg_fields[] = {
69 70 71 72 73 74 75 76
	[FEAT_REG_FIRHINC]			= { 12, 0 },
	[FEAT_REG_FIRVINC]			= { 28, 16 },
	[FEAT_REG_FIFOLOWTHRESHOLD]		= { 11, 0 },
	[FEAT_REG_FIFOHIGHTHRESHOLD]		= { 27, 16 },
	[FEAT_REG_FIFOSIZE]			= { 10, 0 },
	[FEAT_REG_HORIZONTALACCU]		= { 9, 0 },
	[FEAT_REG_VERTICALACCU]			= { 25, 16 },
	[FEAT_REG_DISPC_CLK_SWITCH]		= { 0, 0 },
77 78
};

79 80 81 82 83 84 85 86 87 88 89
static const struct dss_reg_field am43xx_dss_reg_fields[] = {
	[FEAT_REG_FIRHINC]			= { 12, 0 },
	[FEAT_REG_FIRVINC]			= { 28, 16 },
	[FEAT_REG_FIFOLOWTHRESHOLD]	= { 11, 0 },
	[FEAT_REG_FIFOHIGHTHRESHOLD]		= { 27, 16 },
	[FEAT_REG_FIFOSIZE]		= { 10, 0 },
	[FEAT_REG_HORIZONTALACCU]		= { 9, 0 },
	[FEAT_REG_VERTICALACCU]			= { 25, 16 },
	[FEAT_REG_DISPC_CLK_SWITCH]		= { 0, 0 },
};

90
static const struct dss_reg_field omap4_dss_reg_fields[] = {
91 92 93 94 95 96 97 98
	[FEAT_REG_FIRHINC]			= { 12, 0 },
	[FEAT_REG_FIRVINC]			= { 28, 16 },
	[FEAT_REG_FIFOLOWTHRESHOLD]		= { 15, 0 },
	[FEAT_REG_FIFOHIGHTHRESHOLD]		= { 31, 16 },
	[FEAT_REG_FIFOSIZE]			= { 15, 0 },
	[FEAT_REG_HORIZONTALACCU]		= { 10, 0 },
	[FEAT_REG_VERTICALACCU]			= { 26, 16 },
	[FEAT_REG_DISPC_CLK_SWITCH]		= { 9, 8 },
99 100
};

101 102 103 104 105 106 107 108 109 110 111
static const struct dss_reg_field omap5_dss_reg_fields[] = {
	[FEAT_REG_FIRHINC]			= { 12, 0 },
	[FEAT_REG_FIRVINC]			= { 28, 16 },
	[FEAT_REG_FIFOLOWTHRESHOLD]		= { 15, 0 },
	[FEAT_REG_FIFOHIGHTHRESHOLD]		= { 31, 16 },
	[FEAT_REG_FIFOSIZE]			= { 15, 0 },
	[FEAT_REG_HORIZONTALACCU]		= { 10, 0 },
	[FEAT_REG_VERTICALACCU]			= { 26, 16 },
	[FEAT_REG_DISPC_CLK_SWITCH]		= { 9, 7 },
};

112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
static const enum omap_dss_output_id omap2_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,

	/* OMAP_DSS_CHANNEL_DIGIT */
	OMAP_DSS_OUTPUT_VENC,
};

static const enum omap_dss_output_id omap3430_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
	OMAP_DSS_OUTPUT_SDI | OMAP_DSS_OUTPUT_DSI1,

	/* OMAP_DSS_CHANNEL_DIGIT */
	OMAP_DSS_OUTPUT_VENC,
};

static const enum omap_dss_output_id omap3630_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
	OMAP_DSS_OUTPUT_DSI1,

	/* OMAP_DSS_CHANNEL_DIGIT */
	OMAP_DSS_OUTPUT_VENC,
};

138 139 140 141 142
static const enum omap_dss_output_id am43xx_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
};

143 144
static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
145
	OMAP_DSS_OUTPUT_DBI | OMAP_DSS_OUTPUT_DSI1,
146 147

	/* OMAP_DSS_CHANNEL_DIGIT */
148
	OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI,
149 150 151 152 153 154 155 156 157 158 159 160

	/* OMAP_DSS_CHANNEL_LCD2 */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
	OMAP_DSS_OUTPUT_DSI2,
};

static const enum omap_dss_output_id omap5_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
	OMAP_DSS_OUTPUT_DSI1 | OMAP_DSS_OUTPUT_DSI2,

	/* OMAP_DSS_CHANNEL_DIGIT */
161
	OMAP_DSS_OUTPUT_HDMI,
162 163 164 165 166 167 168 169 170 171

	/* OMAP_DSS_CHANNEL_LCD2 */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
	OMAP_DSS_OUTPUT_DSI1,

	/* OMAP_DSS_CHANNEL_LCD3 */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
	OMAP_DSS_OUTPUT_DSI2,
};

172 173
static const enum omap_overlay_caps omap2_dss_overlay_caps[] = {
	/* OMAP_DSS_GFX */
174
	OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
175 176

	/* OMAP_DSS_VIDEO1 */
177 178
	OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
		OMAP_DSS_OVL_CAP_REPLICATION,
179 180

	/* OMAP_DSS_VIDEO2 */
181 182
	OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
		OMAP_DSS_OVL_CAP_REPLICATION,
183 184 185 186
};

static const enum omap_overlay_caps omap3430_dss_overlay_caps[] = {
	/* OMAP_DSS_GFX */
187 188
	OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_POS |
		OMAP_DSS_OVL_CAP_REPLICATION,
189 190

	/* OMAP_DSS_VIDEO1 */
191 192
	OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
		OMAP_DSS_OVL_CAP_REPLICATION,
193 194

	/* OMAP_DSS_VIDEO2 */
195 196
	OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
		OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
197 198 199 200
};

static const enum omap_overlay_caps omap3630_dss_overlay_caps[] = {
	/* OMAP_DSS_GFX */
201 202
	OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
		OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
203 204

	/* OMAP_DSS_VIDEO1 */
205 206
	OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
		OMAP_DSS_OVL_CAP_REPLICATION,
207 208

	/* OMAP_DSS_VIDEO2 */
209
	OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
210 211
		OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_POS |
		OMAP_DSS_OVL_CAP_REPLICATION,
212 213 214 215
};

static const enum omap_overlay_caps omap4_dss_overlay_caps[] = {
	/* OMAP_DSS_GFX */
216
	OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
217 218
		OMAP_DSS_OVL_CAP_ZORDER | OMAP_DSS_OVL_CAP_POS |
		OMAP_DSS_OVL_CAP_REPLICATION,
219 220

	/* OMAP_DSS_VIDEO1 */
221
	OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
222 223
		OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
		OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
224 225

	/* OMAP_DSS_VIDEO2 */
226
	OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
227 228
		OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
		OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
229 230 231

	/* OMAP_DSS_VIDEO3 */
	OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
232 233
		OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
		OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
234 235
};

236
static const struct dss_param_range omap2_dss_param_range[] = {
237
	[FEAT_PARAM_DSS_FCK]			= { 0, 133000000 },
238
	[FEAT_PARAM_DSS_PCD]			= { 2, 255 },
239
	[FEAT_PARAM_DOWNSCALE]			= { 1, 2 },
240 241 242 243 244
	/*
	 * Assuming the line width buffer to be 768 pixels as OMAP2 DISPC
	 * scaler cannot scale a image with width more than 768.
	 */
	[FEAT_PARAM_LINEWIDTH]			= { 1, 768 },
245 246 247
};

static const struct dss_param_range omap3_dss_param_range[] = {
248
	[FEAT_PARAM_DSS_FCK]			= { 0, 173000000 },
249
	[FEAT_PARAM_DSS_PCD]			= { 1, 255 },
250
	[FEAT_PARAM_DSIPLL_LPDIV]		= { 1, (1 << 13) - 1},
251
	[FEAT_PARAM_DSI_FCK]			= { 0, 173000000 },
252
	[FEAT_PARAM_DOWNSCALE]			= { 1, 4 },
253
	[FEAT_PARAM_LINEWIDTH]			= { 1, 1024 },
254 255
};

256 257
static const struct dss_param_range am43xx_dss_param_range[] = {
	[FEAT_PARAM_DSS_FCK]			= { 0, 200000000 },
258
	[FEAT_PARAM_DSS_PCD]			= { 1, 255 },
259 260 261 262
	[FEAT_PARAM_DOWNSCALE]			= { 1, 4 },
	[FEAT_PARAM_LINEWIDTH]			= { 1, 1024 },
};

263
static const struct dss_param_range omap4_dss_param_range[] = {
264
	[FEAT_PARAM_DSS_FCK]			= { 0, 186000000 },
265
	[FEAT_PARAM_DSS_PCD]			= { 1, 255 },
266
	[FEAT_PARAM_DSIPLL_LPDIV]		= { 0, (1 << 13) - 1 },
267
	[FEAT_PARAM_DSI_FCK]			= { 0, 170000000 },
268
	[FEAT_PARAM_DOWNSCALE]			= { 1, 4 },
269
	[FEAT_PARAM_LINEWIDTH]			= { 1, 2048 },
270 271
};

272
static const struct dss_param_range omap5_dss_param_range[] = {
273
	[FEAT_PARAM_DSS_FCK]			= { 0, 209250000 },
274 275
	[FEAT_PARAM_DSS_PCD]			= { 1, 255 },
	[FEAT_PARAM_DSIPLL_LPDIV]		= { 0, (1 << 13) - 1 },
276
	[FEAT_PARAM_DSI_FCK]			= { 0, 209250000 },
277 278 279 280
	[FEAT_PARAM_DOWNSCALE]			= { 1, 4 },
	[FEAT_PARAM_LINEWIDTH]			= { 1, 2048 },
};

281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
static const enum dss_feat_id omap2_dss_feat_list[] = {
	FEAT_LCDENABLEPOL,
	FEAT_LCDENABLESIGNAL,
	FEAT_PCKFREEENABLE,
	FEAT_FUNCGATED,
	FEAT_ROWREPEATENABLE,
	FEAT_RESIZECONF,
};

static const enum dss_feat_id omap3430_dss_feat_list[] = {
	FEAT_LCDENABLEPOL,
	FEAT_LCDENABLESIGNAL,
	FEAT_PCKFREEENABLE,
	FEAT_FUNCGATED,
	FEAT_LINEBUFFERSPLIT,
	FEAT_ROWREPEATENABLE,
	FEAT_RESIZECONF,
	FEAT_DSI_REVERSE_TXCLKESC,
	FEAT_VENC_REQUIRES_TV_DAC_CLK,
	FEAT_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FIXED_ZORDER,
	FEAT_FIFO_MERGE,
	FEAT_OMAP3_DSI_FIFO_BUG,
306
	FEAT_DPI_USES_VDDS_DSI,
307 308
};

309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
static const enum dss_feat_id am35xx_dss_feat_list[] = {
	FEAT_LCDENABLEPOL,
	FEAT_LCDENABLESIGNAL,
	FEAT_PCKFREEENABLE,
	FEAT_FUNCGATED,
	FEAT_LINEBUFFERSPLIT,
	FEAT_ROWREPEATENABLE,
	FEAT_RESIZECONF,
	FEAT_DSI_REVERSE_TXCLKESC,
	FEAT_VENC_REQUIRES_TV_DAC_CLK,
	FEAT_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FIXED_ZORDER,
	FEAT_FIFO_MERGE,
	FEAT_OMAP3_DSI_FIFO_BUG,
};

327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
static const enum dss_feat_id am43xx_dss_feat_list[] = {
	FEAT_LCDENABLEPOL,
	FEAT_LCDENABLESIGNAL,
	FEAT_PCKFREEENABLE,
	FEAT_FUNCGATED,
	FEAT_LINEBUFFERSPLIT,
	FEAT_ROWREPEATENABLE,
	FEAT_RESIZECONF,
	FEAT_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FIXED_ZORDER,
	FEAT_FIFO_MERGE,
};

342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
static const enum dss_feat_id omap3630_dss_feat_list[] = {
	FEAT_LCDENABLEPOL,
	FEAT_LCDENABLESIGNAL,
	FEAT_PCKFREEENABLE,
	FEAT_FUNCGATED,
	FEAT_LINEBUFFERSPLIT,
	FEAT_ROWREPEATENABLE,
	FEAT_RESIZECONF,
	FEAT_DSI_PLL_PWR_BUG,
	FEAT_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FIXED_ZORDER,
	FEAT_FIFO_MERGE,
	FEAT_OMAP3_DSI_FIFO_BUG,
357
	FEAT_DPI_USES_VDDS_DSI,
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
};

static const enum dss_feat_id omap4430_es1_0_dss_feat_list[] = {
	FEAT_MGR_LCD2,
	FEAT_CORE_CLK_DIV,
	FEAT_LCD_CLK_SRC,
	FEAT_DSI_DCS_CMD_CONFIG_VC,
	FEAT_DSI_VC_OCP_WIDTH,
	FEAT_DSI_GNQ,
	FEAT_HANDLE_UV_SEPARATE,
	FEAT_ATTR2,
	FEAT_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FREE_ZORDER,
	FEAT_FIFO_MERGE,
374
	FEAT_BURST_2D,
375 376
};

377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
static const enum dss_feat_id omap4430_es2_0_1_2_dss_feat_list[] = {
	FEAT_MGR_LCD2,
	FEAT_CORE_CLK_DIV,
	FEAT_LCD_CLK_SRC,
	FEAT_DSI_DCS_CMD_CONFIG_VC,
	FEAT_DSI_VC_OCP_WIDTH,
	FEAT_DSI_GNQ,
	FEAT_HDMI_CTS_SWMODE,
	FEAT_HANDLE_UV_SEPARATE,
	FEAT_ATTR2,
	FEAT_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FREE_ZORDER,
	FEAT_FIFO_MERGE,
392
	FEAT_BURST_2D,
393 394
};

395 396 397 398 399 400 401 402
static const enum dss_feat_id omap4_dss_feat_list[] = {
	FEAT_MGR_LCD2,
	FEAT_CORE_CLK_DIV,
	FEAT_LCD_CLK_SRC,
	FEAT_DSI_DCS_CMD_CONFIG_VC,
	FEAT_DSI_VC_OCP_WIDTH,
	FEAT_DSI_GNQ,
	FEAT_HDMI_CTS_SWMODE,
403
	FEAT_HDMI_AUDIO_USE_MCLK,
404 405 406 407 408 409 410
	FEAT_HANDLE_UV_SEPARATE,
	FEAT_ATTR2,
	FEAT_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FREE_ZORDER,
	FEAT_FIFO_MERGE,
411
	FEAT_BURST_2D,
412 413
};

414 415
static const enum dss_feat_id omap5_dss_feat_list[] = {
	FEAT_MGR_LCD2,
416
	FEAT_MGR_LCD3,
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
	FEAT_CORE_CLK_DIV,
	FEAT_LCD_CLK_SRC,
	FEAT_DSI_DCS_CMD_CONFIG_VC,
	FEAT_DSI_VC_OCP_WIDTH,
	FEAT_DSI_GNQ,
	FEAT_HDMI_CTS_SWMODE,
	FEAT_HDMI_AUDIO_USE_MCLK,
	FEAT_HANDLE_UV_SEPARATE,
	FEAT_ATTR2,
	FEAT_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FREE_ZORDER,
	FEAT_FIFO_MERGE,
	FEAT_BURST_2D,
432
	FEAT_DSI_PHY_DCC,
T
Tomi Valkeinen 已提交
433
	FEAT_MFLAG,
434 435
};

436
/* OMAP2 DSS Features */
437
static const struct omap_dss_features omap2_dss_features = {
438 439 440
	.reg_fields = omap2_dss_reg_fields,
	.num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),

441 442
	.features = omap2_dss_feat_list,
	.num_features = ARRAY_SIZE(omap2_dss_feat_list),
443

444 445
	.num_mgrs = 2,
	.num_ovls = 3,
446
	.supported_outputs = omap2_dss_supported_outputs,
447
	.overlay_caps = omap2_dss_overlay_caps,
448
	.dss_params = omap2_dss_param_range,
449 450 451
};

/* OMAP3 DSS Features */
452
static const struct omap_dss_features omap3430_dss_features = {
453 454 455
	.reg_fields = omap3_dss_reg_fields,
	.num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),

456 457
	.features = omap3430_dss_feat_list,
	.num_features = ARRAY_SIZE(omap3430_dss_feat_list),
458 459 460

	.num_mgrs = 2,
	.num_ovls = 3,
461
	.supported_outputs = omap3430_dss_supported_outputs,
462
	.overlay_caps = omap3430_dss_overlay_caps,
463
	.dss_params = omap3_dss_param_range,
464 465
};

466 467 468 469 470 471 472 473 474 475 476 477 478
/*
 * AM35xx DSS Features. This is basically OMAP3 DSS Features without the
 * vdds_dsi regulator.
 */
static const struct omap_dss_features am35xx_dss_features = {
	.reg_fields = omap3_dss_reg_fields,
	.num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),

	.features = am35xx_dss_feat_list,
	.num_features = ARRAY_SIZE(am35xx_dss_feat_list),

	.num_mgrs = 2,
	.num_ovls = 3,
479
	.supported_outputs = omap3430_dss_supported_outputs,
480 481 482 483
	.overlay_caps = omap3430_dss_overlay_caps,
	.dss_params = omap3_dss_param_range,
};

484 485 486 487 488 489 490 491 492 493 494 495 496 497
static const struct omap_dss_features am43xx_dss_features = {
	.reg_fields = am43xx_dss_reg_fields,
	.num_reg_fields = ARRAY_SIZE(am43xx_dss_reg_fields),

	.features = am43xx_dss_feat_list,
	.num_features = ARRAY_SIZE(am43xx_dss_feat_list),

	.num_mgrs = 1,
	.num_ovls = 3,
	.supported_outputs = am43xx_dss_supported_outputs,
	.overlay_caps = omap3430_dss_overlay_caps,
	.dss_params = am43xx_dss_param_range,
};

498
static const struct omap_dss_features omap3630_dss_features = {
499 500 501
	.reg_fields = omap3_dss_reg_fields,
	.num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),

502 503
	.features = omap3630_dss_feat_list,
	.num_features = ARRAY_SIZE(omap3630_dss_feat_list),
504 505 506

	.num_mgrs = 2,
	.num_ovls = 3,
507
	.supported_outputs = omap3630_dss_supported_outputs,
508
	.overlay_caps = omap3630_dss_overlay_caps,
509
	.dss_params = omap3_dss_param_range,
510 511
};

512
/* OMAP4 DSS Features */
513 514 515 516 517
/* For OMAP4430 ES 1.0 revision */
static const struct omap_dss_features omap4430_es1_0_dss_features  = {
	.reg_fields = omap4_dss_reg_fields,
	.num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),

518 519
	.features = omap4430_es1_0_dss_feat_list,
	.num_features = ARRAY_SIZE(omap4430_es1_0_dss_feat_list),
520 521

	.num_mgrs = 3,
522
	.num_ovls = 4,
523
	.supported_outputs = omap4_dss_supported_outputs,
524
	.overlay_caps = omap4_dss_overlay_caps,
525 526 527
	.dss_params = omap4_dss_param_range,
};

528 529 530 531 532 533 534 535 536 537
/* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */
static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
	.reg_fields = omap4_dss_reg_fields,
	.num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),

	.features = omap4430_es2_0_1_2_dss_feat_list,
	.num_features = ARRAY_SIZE(omap4430_es2_0_1_2_dss_feat_list),

	.num_mgrs = 3,
	.num_ovls = 4,
538
	.supported_outputs = omap4_dss_supported_outputs,
539 540 541 542
	.overlay_caps = omap4_dss_overlay_caps,
	.dss_params = omap4_dss_param_range,
};

543
/* For all the other OMAP4 versions */
544
static const struct omap_dss_features omap4_dss_features = {
545 546
	.reg_fields = omap4_dss_reg_fields,
	.num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
547

548 549
	.features = omap4_dss_feat_list,
	.num_features = ARRAY_SIZE(omap4_dss_feat_list),
550 551

	.num_mgrs = 3,
552
	.num_ovls = 4,
553
	.supported_outputs = omap4_dss_supported_outputs,
554
	.overlay_caps = omap4_dss_overlay_caps,
555
	.dss_params = omap4_dss_param_range,
556 557
};

558 559 560 561 562 563 564 565
/* OMAP5 DSS Features */
static const struct omap_dss_features omap5_dss_features = {
	.reg_fields = omap5_dss_reg_fields,
	.num_reg_fields = ARRAY_SIZE(omap5_dss_reg_fields),

	.features = omap5_dss_feat_list,
	.num_features = ARRAY_SIZE(omap5_dss_feat_list),

566
	.num_mgrs = 4,
567
	.num_ovls = 4,
568
	.supported_outputs = omap5_dss_supported_outputs,
569 570 571 572
	.overlay_caps = omap4_dss_overlay_caps,
	.dss_params = omap5_dss_param_range,
};

573 574 575 576 577 578 579 580 581 582 583
/* Functions returning values related to a DSS feature */
int dss_feat_get_num_mgrs(void)
{
	return omap_current_dss_features->num_mgrs;
}

int dss_feat_get_num_ovls(void)
{
	return omap_current_dss_features->num_ovls;
}

584 585 586 587 588 589
unsigned long dss_feat_get_param_min(enum dss_range_param param)
{
	return omap_current_dss_features->dss_params[param].min;
}

unsigned long dss_feat_get_param_max(enum dss_range_param param)
590
{
591
	return omap_current_dss_features->dss_params[param].max;
592 593
}

594 595 596 597 598
enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel)
{
	return omap_current_dss_features->supported_outputs[channel];
}

599
enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane_id plane)
600 601 602 603
{
	return omap_current_dss_features->overlay_caps[plane];
}

604 605 606
/* DSS has_feature check */
bool dss_has_feature(enum dss_feat_id id)
{
607 608 609 610 611 612 613 614 615 616
	int i;
	const enum dss_feat_id *features = omap_current_dss_features->features;
	const int num_features = omap_current_dss_features->num_features;

	for (i = 0; i < num_features; i++) {
		if (features[i] == id)
			return true;
	}

	return false;
617 618 619 620 621 622 623 624 625 626 627
}

void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end)
{
	if (id >= omap_current_dss_features->num_reg_fields)
		BUG();

	*start = omap_current_dss_features->reg_fields[id].start;
	*end = omap_current_dss_features->reg_fields[id].end;
}

628
void dss_features_init(enum omapdss_version version)
629
{
630 631
	switch (version) {
	case OMAPDSS_VER_OMAP24xx:
632
		omap_current_dss_features = &omap2_dss_features;
633 634 635 636 637 638 639 640
		break;

	case OMAPDSS_VER_OMAP34xx_ES1:
	case OMAPDSS_VER_OMAP34xx_ES3:
		omap_current_dss_features = &omap3430_dss_features;
		break;

	case OMAPDSS_VER_OMAP3630:
641
		omap_current_dss_features = &omap3630_dss_features;
642 643 644
		break;

	case OMAPDSS_VER_OMAP4430_ES1:
645
		omap_current_dss_features = &omap4430_es1_0_dss_features;
646 647 648
		break;

	case OMAPDSS_VER_OMAP4430_ES2:
649
		omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
650 651 652
		break;

	case OMAPDSS_VER_OMAP4:
653
		omap_current_dss_features = &omap4_dss_features;
654 655 656
		break;

	case OMAPDSS_VER_OMAP5:
657
	case OMAPDSS_VER_DRA7xx:
658
		omap_current_dss_features = &omap5_dss_features;
659 660 661 662 663 664
		break;

	case OMAPDSS_VER_AM35xx:
		omap_current_dss_features = &am35xx_dss_features;
		break;

665 666 667 668
	case OMAPDSS_VER_AM43xx:
		omap_current_dss_features = &am43xx_dss_features;
		break;

669
	default:
670
		DSSWARN("Unsupported OMAP version");
671 672
		break;
	}
673
}