dss_features.c 11.6 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
#include "dss_features.h"

31 32 33 34
struct dss_param_range {
	int min, max;
};

35
struct omap_dss_features {
36 37
	const enum dss_feat_id *features;
	const int num_features;
38

39
	const enum omap_dss_output_id *supported_outputs;
40
	const struct dss_param_range *dss_params;
41 42 43
};

/* This struct is assigned to one of the below during initialization */
44
static const struct omap_dss_features *omap_current_dss_features;
45

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
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,
};

72 73 74 75 76
static const enum omap_dss_output_id am43xx_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
};

77 78
static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
79
	OMAP_DSS_OUTPUT_DBI | OMAP_DSS_OUTPUT_DSI1,
80 81

	/* OMAP_DSS_CHANNEL_DIGIT */
82
	OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI,
83 84 85 86 87 88 89 90 91 92 93 94

	/* 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 */
95
	OMAP_DSS_OUTPUT_HDMI,
96 97 98 99 100 101 102 103 104 105

	/* 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,
};

106
static const struct dss_param_range omap2_dss_param_range[] = {
107
	[FEAT_PARAM_DSS_FCK]			= { 0, 133000000 },
108
	[FEAT_PARAM_DSS_PCD]			= { 2, 255 },
109
	[FEAT_PARAM_DOWNSCALE]			= { 1, 2 },
110 111 112 113 114
	/*
	 * 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 },
115 116 117
};

static const struct dss_param_range omap3_dss_param_range[] = {
118
	[FEAT_PARAM_DSS_FCK]			= { 0, 173000000 },
119
	[FEAT_PARAM_DSS_PCD]			= { 1, 255 },
120
	[FEAT_PARAM_DSIPLL_LPDIV]		= { 1, (1 << 13) - 1},
121
	[FEAT_PARAM_DSI_FCK]			= { 0, 173000000 },
122
	[FEAT_PARAM_DOWNSCALE]			= { 1, 4 },
123
	[FEAT_PARAM_LINEWIDTH]			= { 1, 1024 },
124 125
};

126 127
static const struct dss_param_range am43xx_dss_param_range[] = {
	[FEAT_PARAM_DSS_FCK]			= { 0, 200000000 },
128
	[FEAT_PARAM_DSS_PCD]			= { 1, 255 },
129 130 131 132
	[FEAT_PARAM_DOWNSCALE]			= { 1, 4 },
	[FEAT_PARAM_LINEWIDTH]			= { 1, 1024 },
};

133
static const struct dss_param_range omap4_dss_param_range[] = {
134
	[FEAT_PARAM_DSS_FCK]			= { 0, 186000000 },
135
	[FEAT_PARAM_DSS_PCD]			= { 1, 255 },
136
	[FEAT_PARAM_DSIPLL_LPDIV]		= { 0, (1 << 13) - 1 },
137
	[FEAT_PARAM_DSI_FCK]			= { 0, 170000000 },
138
	[FEAT_PARAM_DOWNSCALE]			= { 1, 4 },
139
	[FEAT_PARAM_LINEWIDTH]			= { 1, 2048 },
140 141
};

142
static const struct dss_param_range omap5_dss_param_range[] = {
143
	[FEAT_PARAM_DSS_FCK]			= { 0, 209250000 },
144 145
	[FEAT_PARAM_DSS_PCD]			= { 1, 255 },
	[FEAT_PARAM_DSIPLL_LPDIV]		= { 0, (1 << 13) - 1 },
146
	[FEAT_PARAM_DSI_FCK]			= { 0, 209250000 },
147 148 149 150
	[FEAT_PARAM_DOWNSCALE]			= { 1, 4 },
	[FEAT_PARAM_LINEWIDTH]			= { 1, 2048 },
};

151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
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_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FIXED_ZORDER,
	FEAT_FIFO_MERGE,
	FEAT_OMAP3_DSI_FIFO_BUG,
175
	FEAT_DPI_USES_VDDS_DSI,
176 177
};

178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
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_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FIXED_ZORDER,
	FEAT_FIFO_MERGE,
	FEAT_OMAP3_DSI_FIFO_BUG,
};

195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
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,
};

210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
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,
225
	FEAT_DPI_USES_VDDS_DSI,
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
};

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,
242
	FEAT_BURST_2D,
243 244
};

245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
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,
260
	FEAT_BURST_2D,
261 262
};

263 264 265 266 267 268 269 270
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,
271
	FEAT_HDMI_AUDIO_USE_MCLK,
272 273 274 275 276 277 278
	FEAT_HANDLE_UV_SEPARATE,
	FEAT_ATTR2,
	FEAT_CPR,
	FEAT_PRELOAD,
	FEAT_FIR_COEF_V,
	FEAT_ALPHA_FREE_ZORDER,
	FEAT_FIFO_MERGE,
279
	FEAT_BURST_2D,
280 281
};

282 283
static const enum dss_feat_id omap5_dss_feat_list[] = {
	FEAT_MGR_LCD2,
284
	FEAT_MGR_LCD3,
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
	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,
300
	FEAT_DSI_PHY_DCC,
T
Tomi Valkeinen 已提交
301
	FEAT_MFLAG,
302 303
};

304
/* OMAP2 DSS Features */
305
static const struct omap_dss_features omap2_dss_features = {
306 307
	.features = omap2_dss_feat_list,
	.num_features = ARRAY_SIZE(omap2_dss_feat_list),
308

309
	.supported_outputs = omap2_dss_supported_outputs,
310
	.dss_params = omap2_dss_param_range,
311 312 313
};

/* OMAP3 DSS Features */
314
static const struct omap_dss_features omap3430_dss_features = {
315 316
	.features = omap3430_dss_feat_list,
	.num_features = ARRAY_SIZE(omap3430_dss_feat_list),
317

318
	.supported_outputs = omap3430_dss_supported_outputs,
319
	.dss_params = omap3_dss_param_range,
320 321
};

322 323 324 325 326 327 328 329
/*
 * AM35xx DSS Features. This is basically OMAP3 DSS Features without the
 * vdds_dsi regulator.
 */
static const struct omap_dss_features am35xx_dss_features = {
	.features = am35xx_dss_feat_list,
	.num_features = ARRAY_SIZE(am35xx_dss_feat_list),

330
	.supported_outputs = omap3430_dss_supported_outputs,
331 332 333
	.dss_params = omap3_dss_param_range,
};

334 335 336 337 338 339 340 341
static const struct omap_dss_features am43xx_dss_features = {
	.features = am43xx_dss_feat_list,
	.num_features = ARRAY_SIZE(am43xx_dss_feat_list),

	.supported_outputs = am43xx_dss_supported_outputs,
	.dss_params = am43xx_dss_param_range,
};

342
static const struct omap_dss_features omap3630_dss_features = {
343 344
	.features = omap3630_dss_feat_list,
	.num_features = ARRAY_SIZE(omap3630_dss_feat_list),
345

346
	.supported_outputs = omap3630_dss_supported_outputs,
347
	.dss_params = omap3_dss_param_range,
348 349
};

350
/* OMAP4 DSS Features */
351 352
/* For OMAP4430 ES 1.0 revision */
static const struct omap_dss_features omap4430_es1_0_dss_features  = {
353 354
	.features = omap4430_es1_0_dss_feat_list,
	.num_features = ARRAY_SIZE(omap4430_es1_0_dss_feat_list),
355

356
	.supported_outputs = omap4_dss_supported_outputs,
357 358 359
	.dss_params = omap4_dss_param_range,
};

360 361 362 363 364
/* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */
static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
	.features = omap4430_es2_0_1_2_dss_feat_list,
	.num_features = ARRAY_SIZE(omap4430_es2_0_1_2_dss_feat_list),

365
	.supported_outputs = omap4_dss_supported_outputs,
366 367 368
	.dss_params = omap4_dss_param_range,
};

369
/* For all the other OMAP4 versions */
370
static const struct omap_dss_features omap4_dss_features = {
371 372
	.features = omap4_dss_feat_list,
	.num_features = ARRAY_SIZE(omap4_dss_feat_list),
373

374
	.supported_outputs = omap4_dss_supported_outputs,
375
	.dss_params = omap4_dss_param_range,
376 377
};

378 379 380 381 382
/* OMAP5 DSS Features */
static const struct omap_dss_features omap5_dss_features = {
	.features = omap5_dss_feat_list,
	.num_features = ARRAY_SIZE(omap5_dss_feat_list),

383
	.supported_outputs = omap5_dss_supported_outputs,
384 385 386
	.dss_params = omap5_dss_param_range,
};

387
/* Functions returning values related to a DSS feature */
388 389 390 391 392 393
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)
394
{
395
	return omap_current_dss_features->dss_params[param].max;
396 397
}

398 399 400 401 402
enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel)
{
	return omap_current_dss_features->supported_outputs[channel];
}

403 404 405
/* DSS has_feature check */
bool dss_has_feature(enum dss_feat_id id)
{
406 407 408 409 410 411 412 413 414 415
	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;
416 417
}

418
void dss_features_init(enum omapdss_version version)
419
{
420 421
	switch (version) {
	case OMAPDSS_VER_OMAP24xx:
422
		omap_current_dss_features = &omap2_dss_features;
423 424 425 426 427 428 429 430
		break;

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

	case OMAPDSS_VER_OMAP3630:
431
		omap_current_dss_features = &omap3630_dss_features;
432 433 434
		break;

	case OMAPDSS_VER_OMAP4430_ES1:
435
		omap_current_dss_features = &omap4430_es1_0_dss_features;
436 437 438
		break;

	case OMAPDSS_VER_OMAP4430_ES2:
439
		omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
440 441 442
		break;

	case OMAPDSS_VER_OMAP4:
443
		omap_current_dss_features = &omap4_dss_features;
444 445 446
		break;

	case OMAPDSS_VER_OMAP5:
447
	case OMAPDSS_VER_DRA7xx:
448
		omap_current_dss_features = &omap5_dss_features;
449 450 451 452 453 454
		break;

	case OMAPDSS_VER_AM35xx:
		omap_current_dss_features = &am35xx_dss_features;
		break;

455 456 457 458
	case OMAPDSS_VER_AM43xx:
		omap_current_dss_features = &am43xx_dss_features;
		break;

459
	default:
460
		DSSWARN("Unsupported OMAP version");
461 462
		break;
	}
463
}