dss_features.c 7.5 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
	const enum omap_dss_output_id *supported_outputs;
37
	const struct dss_param_range *dss_params;
38 39 40
};

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

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

69 70 71 72 73
static const enum omap_dss_output_id am43xx_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
	OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
};

74 75
static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
	/* OMAP_DSS_CHANNEL_LCD */
76
	OMAP_DSS_OUTPUT_DBI | OMAP_DSS_OUTPUT_DSI1,
77 78

	/* OMAP_DSS_CHANNEL_DIGIT */
79
	OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI,
80 81 82 83 84 85 86 87 88 89 90 91

	/* 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 */
92
	OMAP_DSS_OUTPUT_HDMI,
93 94 95 96 97 98 99 100 101 102

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

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

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

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

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

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

148
/* OMAP2 DSS Features */
149
static const struct omap_dss_features omap2_dss_features = {
150
	.supported_outputs = omap2_dss_supported_outputs,
151
	.dss_params = omap2_dss_param_range,
152 153 154
};

/* OMAP3 DSS Features */
155
static const struct omap_dss_features omap3430_dss_features = {
156
	.supported_outputs = omap3430_dss_supported_outputs,
157
	.dss_params = omap3_dss_param_range,
158 159
};

160 161 162 163 164
/*
 * AM35xx DSS Features. This is basically OMAP3 DSS Features without the
 * vdds_dsi regulator.
 */
static const struct omap_dss_features am35xx_dss_features = {
165
	.supported_outputs = omap3430_dss_supported_outputs,
166 167 168
	.dss_params = omap3_dss_param_range,
};

169 170 171 172 173
static const struct omap_dss_features am43xx_dss_features = {
	.supported_outputs = am43xx_dss_supported_outputs,
	.dss_params = am43xx_dss_param_range,
};

174
static const struct omap_dss_features omap3630_dss_features = {
175
	.supported_outputs = omap3630_dss_supported_outputs,
176
	.dss_params = omap3_dss_param_range,
177 178
};

179
/* OMAP4 DSS Features */
180 181
/* For OMAP4430 ES 1.0 revision */
static const struct omap_dss_features omap4430_es1_0_dss_features  = {
182
	.supported_outputs = omap4_dss_supported_outputs,
183 184 185
	.dss_params = omap4_dss_param_range,
};

186 187
/* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */
static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
188
	.supported_outputs = omap4_dss_supported_outputs,
189 190 191
	.dss_params = omap4_dss_param_range,
};

192
/* For all the other OMAP4 versions */
193
static const struct omap_dss_features omap4_dss_features = {
194
	.supported_outputs = omap4_dss_supported_outputs,
195
	.dss_params = omap4_dss_param_range,
196 197
};

198 199
/* OMAP5 DSS Features */
static const struct omap_dss_features omap5_dss_features = {
200
	.supported_outputs = omap5_dss_supported_outputs,
201 202 203
	.dss_params = omap5_dss_param_range,
};

204
/* Functions returning values related to a DSS feature */
205 206 207 208 209 210
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)
211
{
212
	return omap_current_dss_features->dss_params[param].max;
213 214
}

215 216 217 218 219
enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel)
{
	return omap_current_dss_features->supported_outputs[channel];
}

220
void dss_features_init(enum omapdss_version version)
221
{
222 223
	switch (version) {
	case OMAPDSS_VER_OMAP24xx:
224
		omap_current_dss_features = &omap2_dss_features;
225 226 227 228 229 230 231 232
		break;

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

	case OMAPDSS_VER_OMAP3630:
233
		omap_current_dss_features = &omap3630_dss_features;
234 235 236
		break;

	case OMAPDSS_VER_OMAP4430_ES1:
237
		omap_current_dss_features = &omap4430_es1_0_dss_features;
238 239 240
		break;

	case OMAPDSS_VER_OMAP4430_ES2:
241
		omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
242 243 244
		break;

	case OMAPDSS_VER_OMAP4:
245
		omap_current_dss_features = &omap4_dss_features;
246 247 248
		break;

	case OMAPDSS_VER_OMAP5:
249
	case OMAPDSS_VER_DRA7xx:
250
		omap_current_dss_features = &omap5_dss_features;
251 252 253 254 255 256
		break;

	case OMAPDSS_VER_AM35xx:
		omap_current_dss_features = &am35xx_dss_features;
		break;

257 258 259 260
	case OMAPDSS_VER_AM43xx:
		omap_current_dss_features = &am43xx_dss_features;
		break;

261
	default:
262
		DSSWARN("Unsupported OMAP version");
263 264
		break;
	}
265
}