• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _SDE_DRM_H_
2 #define _SDE_DRM_H_
3 
4 #include "drm.h"
5 
6 /* Total number of supported color planes */
7 #define SDE_MAX_PLANES  4
8 
9 /* Total number of parameterized detail enhancer mapping curves */
10 #define SDE_MAX_DE_CURVES 3
11 
12  /* Y/RGB and UV filter configuration */
13 #define FILTER_EDGE_DIRECTED_2D		0x0
14 #define FILTER_CIRCULAR_2D		0x1
15 #define FILTER_SEPARABLE_1D		0x2
16 #define FILTER_BILINEAR			0x3
17 
18 /* Alpha filters */
19 #define FILTER_ALPHA_DROP_REPEAT	0x0
20 #define FILTER_ALPHA_BILINEAR		0x1
21 #define FILTER_ALPHA_2D			0x3
22 
23 /* Blend filters */
24 #define FILTER_BLEND_CIRCULAR_2D	0x0
25 #define FILTER_BLEND_SEPARABLE_1D	0x1
26 
27 /* LUT configuration flags */
28 #define SCALER_LUT_SWAP			0x1
29 #define SCALER_LUT_DIR_WR		0x2
30 #define SCALER_LUT_Y_CIR_WR		0x4
31 #define SCALER_LUT_UV_CIR_WR		0x8
32 #define SCALER_LUT_Y_SEP_WR		0x10
33 #define SCALER_LUT_UV_SEP_WR		0x20
34 
35 /**
36  * Blend operations for "blend_op" property
37  *
38  * @SDE_DRM_BLEND_OP_NOT_DEFINED:   No blend operation defined for the layer.
39  * @SDE_DRM_BLEND_OP_OPAQUE:        Apply a constant blend operation. The layer
40  *                                  would appear opaque in case fg plane alpha
41  *                                  is 0xff.
42  * @SDE_DRM_BLEND_OP_PREMULTIPLIED: Apply source over blend rule. Layer already
43  *                                  has alpha pre-multiplication done. If the fg
44  *                                  plane alpha is less than 0xff, apply
45  *                                  modulation as well. This operation is
46  *                                  intended on layers having alpha channel.
47  * @SDE_DRM_BLEND_OP_COVERAGE:      Apply source over blend rule. Layer is not
48  *                                  alpha pre-multiplied. Apply
49  *                                  pre-multiplication. If fg plane alpha is
50  *                                  less than 0xff, apply modulation as well.
51  * @SDE_DRM_BLEND_OP_MAX:           Used to track maximum blend operation
52  *                                  possible by mdp.
53  */
54 #define SDE_DRM_BLEND_OP_NOT_DEFINED    0
55 #define SDE_DRM_BLEND_OP_OPAQUE         1
56 #define SDE_DRM_BLEND_OP_PREMULTIPLIED  2
57 #define SDE_DRM_BLEND_OP_COVERAGE       3
58 #define SDE_DRM_BLEND_OP_MAX            4
59 
60 /**
61  * Bit masks for "src_config" property
62  * construct bitmask via (1UL << SDE_DRM_<flag>)
63  */
64 #define SDE_DRM_DEINTERLACE         0   /* Specifies interlaced input */
65 
66 /* DRM bitmasks are restricted to 0..63 */
67 #define SDE_DRM_BITMASK_COUNT       64
68 
69 /**
70  * Framebuffer modes for "fb_translation_mode" PLANE and CONNECTOR property
71  *
72  * @SDE_DRM_FB_NON_SEC:          IOMMU configuration for this framebuffer mode
73  *                               is non-secure domain and requires
74  *                               both stage I and stage II translations when
75  *                               this buffer is accessed by the display HW.
76  *                               This is the default mode of all frambuffers.
77  * @SDE_DRM_FB_SEC:              IOMMU configuration for this framebuffer mode
78  *                               is secure domain and requires
79  *                               both stage I and stage II translations when
80  *                               this buffer is accessed by the display HW.
81  * @SDE_DRM_FB_NON_SEC_DIR_TRANS: IOMMU configuration for this framebuffer mode
82  *                               is non-secure domain and requires
83  *                               only stage II translation when
84  *                               this buffer is accessed by the display HW.
85  * @SDE_DRM_FB_SEC_DIR_TRANS:    IOMMU configuration for this framebuffer mode
86  *                               is secure domain and requires
87  *                               only stage II translation when
88  *                               this buffer is accessed by the display HW.
89  */
90 
91 #define SDE_DRM_FB_NON_SEC              0
92 #define SDE_DRM_FB_SEC                  1
93 #define SDE_DRM_FB_NON_SEC_DIR_TRANS    2
94 #define SDE_DRM_FB_SEC_DIR_TRANS        3
95 
96 /**
97  * Secure levels for "security_level" CRTC property.
98  *                        CRTC property which specifies what plane types
99  *                        can be attached to this CRTC. Plane component
100  *                        derives the plane type based on the FB_MODE.
101  * @ SDE_DRM_SEC_NON_SEC: Both Secure and non-secure plane types can be
102  *                        attached to this CRTC. This is the default state of
103  *                        the CRTC.
104  * @ SDE_DRM_SEC_ONLY:    Only secure planes can be added to this CRTC. If a
105  *                        CRTC is instructed to be in this mode it follows the
106  *                        platform dependent restrictions.
107  */
108 #define SDE_DRM_SEC_NON_SEC            0
109 #define SDE_DRM_SEC_ONLY               1
110 
111 /**
112  * struct sde_drm_pix_ext_v1 - version 1 of pixel ext structure
113  * @num_ext_pxls_lr: Number of total horizontal pixels
114  * @num_ext_pxls_tb: Number of total vertical lines
115  * @left_ftch:       Number of extra pixels to overfetch from left
116  * @right_ftch:      Number of extra pixels to overfetch from right
117  * @top_ftch:        Number of extra lines to overfetch from top
118  * @btm_ftch:        Number of extra lines to overfetch from bottom
119  * @left_rpt:        Number of extra pixels to repeat from left
120  * @right_rpt:       Number of extra pixels to repeat from right
121  * @top_rpt:         Number of extra lines to repeat from top
122  * @btm_rpt:         Number of extra lines to repeat from bottom
123  */
124 struct sde_drm_pix_ext_v1 {
125 	/*
126 	 * Number of pixels ext in left, right, top and bottom direction
127 	 * for all color components.
128 	 */
129 	int32_t num_ext_pxls_lr[SDE_MAX_PLANES];
130 	int32_t num_ext_pxls_tb[SDE_MAX_PLANES];
131 
132 	/*
133 	 * Number of pixels needs to be overfetched in left, right, top
134 	 * and bottom directions from source image for scaling.
135 	 */
136 	int32_t left_ftch[SDE_MAX_PLANES];
137 	int32_t right_ftch[SDE_MAX_PLANES];
138 	int32_t top_ftch[SDE_MAX_PLANES];
139 	int32_t btm_ftch[SDE_MAX_PLANES];
140 	/*
141 	 * Number of pixels needs to be repeated in left, right, top and
142 	 * bottom directions for scaling.
143 	 */
144 	int32_t left_rpt[SDE_MAX_PLANES];
145 	int32_t right_rpt[SDE_MAX_PLANES];
146 	int32_t top_rpt[SDE_MAX_PLANES];
147 	int32_t btm_rpt[SDE_MAX_PLANES];
148 
149 };
150 
151 /**
152  * struct sde_drm_scaler_v1 - version 1 of struct sde_drm_scaler
153  * @lr:            Pixel extension settings for left/right
154  * @tb:            Pixel extension settings for top/botton
155  * @init_phase_x:  Initial scaler phase values for x
156  * @phase_step_x:  Phase step values for x
157  * @init_phase_y:  Initial scaler phase values for y
158  * @phase_step_y:  Phase step values for y
159  * @horz_filter:   Horizontal filter array
160  * @vert_filter:   Vertical filter array
161  */
162 struct sde_drm_scaler_v1 {
163 	/*
164 	 * Pix ext settings
165 	 */
166 	struct sde_drm_pix_ext_v1 pe;
167 	/*
168 	 * Phase settings
169 	 */
170 	int32_t init_phase_x[SDE_MAX_PLANES];
171 	int32_t phase_step_x[SDE_MAX_PLANES];
172 	int32_t init_phase_y[SDE_MAX_PLANES];
173 	int32_t phase_step_y[SDE_MAX_PLANES];
174 
175 	/*
176 	 * Filter type to be used for scaling in horizontal and vertical
177 	 * directions
178 	 */
179 	uint32_t horz_filter[SDE_MAX_PLANES];
180 	uint32_t vert_filter[SDE_MAX_PLANES];
181 };
182 
183 /**
184  * struct sde_drm_de_v1 - version 1 of detail enhancer structure
185  * @enable:         Enables/disables detail enhancer
186  * @sharpen_level1: Sharpening strength for noise
187  * @sharpen_level2: Sharpening strength for context
188  * @clip:           Clip coefficient
189  * @limit:          Detail enhancer limit factor
190  * @thr_quiet:      Quite zone threshold
191  * @thr_dieout:     Die-out zone threshold
192  * @thr_low:        Linear zone left threshold
193  * @thr_high:       Linear zone right threshold
194  * @prec_shift:     Detail enhancer precision
195  * @adjust_a:       Mapping curves A coefficients
196  * @adjust_b:       Mapping curves B coefficients
197  * @adjust_c:       Mapping curves C coefficients
198  */
199 struct sde_drm_de_v1 {
200 	uint32_t enable;
201 	int16_t sharpen_level1;
202 	int16_t sharpen_level2;
203 	uint16_t clip;
204 	uint16_t limit;
205 	uint16_t thr_quiet;
206 	uint16_t thr_dieout;
207 	uint16_t thr_low;
208 	uint16_t thr_high;
209 	uint16_t prec_shift;
210 	int16_t adjust_a[SDE_MAX_DE_CURVES];
211 	int16_t adjust_b[SDE_MAX_DE_CURVES];
212 	int16_t adjust_c[SDE_MAX_DE_CURVES];
213 };
214 
215 /**
216  * struct sde_drm_scaler_v2 - version 2 of struct sde_drm_scaler
217  * @enable:            Scaler enable
218  * @dir_en:            Detail enhancer enable
219  * @pe:                Pixel extension settings
220  * @horz_decimate:     Horizontal decimation factor
221  * @vert_decimate:     Vertical decimation factor
222  * @init_phase_x:      Initial scaler phase values for x
223  * @phase_step_x:      Phase step values for x
224  * @init_phase_y:      Initial scaler phase values for y
225  * @phase_step_y:      Phase step values for y
226  * @preload_x:         Horizontal preload value
227  * @preload_y:         Vertical preload value
228  * @src_width:         Source width
229  * @src_height:        Source height
230  * @dst_width:         Destination width
231  * @dst_height:        Destination height
232  * @y_rgb_filter_cfg:  Y/RGB plane filter configuration
233  * @uv_filter_cfg:     UV plane filter configuration
234  * @alpha_filter_cfg:  Alpha filter configuration
235  * @blend_cfg:         Selection of blend coefficients
236  * @lut_flag:          LUT configuration flags
237  * @dir_lut_idx:       2d 4x4 LUT index
238  * @y_rgb_cir_lut_idx: Y/RGB circular LUT index
239  * @uv_cir_lut_idx:    UV circular LUT index
240  * @y_rgb_sep_lut_idx: Y/RGB separable LUT index
241  * @uv_sep_lut_idx:    UV separable LUT index
242  * @de:                Detail enhancer settings
243  */
244 struct sde_drm_scaler_v2 {
245 	/*
246 	 * General definitions
247 	 */
248 	uint32_t enable;
249 	uint32_t dir_en;
250 
251 	/*
252 	 * Pix ext settings
253 	 */
254 	struct sde_drm_pix_ext_v1 pe;
255 
256 	/*
257 	 * Decimation settings
258 	 */
259 	uint32_t horz_decimate;
260 	uint32_t vert_decimate;
261 
262 	/*
263 	 * Phase settings
264 	 */
265 	int32_t init_phase_x[SDE_MAX_PLANES];
266 	int32_t phase_step_x[SDE_MAX_PLANES];
267 	int32_t init_phase_y[SDE_MAX_PLANES];
268 	int32_t phase_step_y[SDE_MAX_PLANES];
269 
270 	uint32_t preload_x[SDE_MAX_PLANES];
271 	uint32_t preload_y[SDE_MAX_PLANES];
272 	uint32_t src_width[SDE_MAX_PLANES];
273 	uint32_t src_height[SDE_MAX_PLANES];
274 
275 	uint32_t dst_width;
276 	uint32_t dst_height;
277 
278 	uint32_t y_rgb_filter_cfg;
279 	uint32_t uv_filter_cfg;
280 	uint32_t alpha_filter_cfg;
281 	uint32_t blend_cfg;
282 
283 	uint32_t lut_flag;
284 	uint32_t dir_lut_idx;
285 
286 	/* for Y(RGB) and UV planes*/
287 	uint32_t y_rgb_cir_lut_idx;
288 	uint32_t uv_cir_lut_idx;
289 	uint32_t y_rgb_sep_lut_idx;
290 	uint32_t uv_sep_lut_idx;
291 
292 	/*
293 	 * Detail enhancer settings
294 	 */
295 	struct sde_drm_de_v1 de;
296 };
297 
298 /* Number of dest scalers supported */
299 #define SDE_MAX_DS_COUNT 2
300 
301 /*
302  * Destination scaler flag config
303  */
304 #define SDE_DRM_DESTSCALER_ENABLE           0x1
305 #define SDE_DRM_DESTSCALER_SCALE_UPDATE     0x2
306 #define SDE_DRM_DESTSCALER_ENHANCER_UPDATE  0x4
307 #define SDE_DRM_DESTSCALER_PU_ENABLE        0x8
308 
309 /**
310  * struct sde_drm_dest_scaler_cfg - destination scaler config structure
311  * @flags:      Flag to switch between mode for destination scaler
312  *              refer to destination scaler flag config
313  * @index:      Destination scaler selection index
314  * @lm_width:   Layer mixer width configuration
315  * @lm_height:  Layer mixer height configuration
316  * @scaler_cfg: The scaling parameters for all the mode except disable
317  *              Userspace pointer to struct sde_drm_scaler_v2
318  */
319 struct sde_drm_dest_scaler_cfg {
320 	uint32_t flags;
321 	uint32_t index;
322 	uint32_t lm_width;
323 	uint32_t lm_height;
324 	uint64_t scaler_cfg;
325 };
326 
327 /**
328  * struct sde_drm_dest_scaler_data - destination scaler data struct
329  * @num_dest_scaler: Number of dest scalers to be configured
330  * @ds_cfg:          Destination scaler block configuration
331  */
332 struct sde_drm_dest_scaler_data {
333 	uint32_t num_dest_scaler;
334 	struct sde_drm_dest_scaler_cfg ds_cfg[SDE_MAX_DS_COUNT];
335 };
336 
337 /*
338  * Define constants for struct sde_drm_csc
339  */
340 #define SDE_CSC_MATRIX_COEFF_SIZE   9
341 #define SDE_CSC_CLAMP_SIZE          6
342 #define SDE_CSC_BIAS_SIZE           3
343 
344 /**
345  * struct sde_drm_csc_v1 - version 1 of struct sde_drm_csc
346  * @ctm_coeff:          Matrix coefficients, in S31.32 format
347  * @pre_bias:           Pre-bias array values
348  * @post_bias:          Post-bias array values
349  * @pre_clamp:          Pre-clamp array values
350  * @post_clamp:         Post-clamp array values
351  */
352 struct sde_drm_csc_v1 {
353 	int64_t ctm_coeff[SDE_CSC_MATRIX_COEFF_SIZE];
354 	uint32_t pre_bias[SDE_CSC_BIAS_SIZE];
355 	uint32_t post_bias[SDE_CSC_BIAS_SIZE];
356 	uint32_t pre_clamp[SDE_CSC_CLAMP_SIZE];
357 	uint32_t post_clamp[SDE_CSC_CLAMP_SIZE];
358 };
359 
360 /**
361  * struct sde_drm_color - struct to store the color and alpha values
362  * @color_0: Color 0 value
363  * @color_1: Color 1 value
364  * @color_2: Color 2 value
365  * @color_3: Color 3 value
366  */
367 struct sde_drm_color {
368 	uint32_t color_0;
369 	uint32_t color_1;
370 	uint32_t color_2;
371 	uint32_t color_3;
372 };
373 
374 /* Total number of supported dim layers */
375 #define SDE_MAX_DIM_LAYERS 7
376 
377 /* SDE_DRM_DIM_LAYER_CONFIG_FLAG - flags for Dim Layer */
378 /* Color fill inside of the rect, including border */
379 #define SDE_DRM_DIM_LAYER_INCLUSIVE     0x1
380 /* Color fill outside of the rect, excluding border */
381 #define SDE_DRM_DIM_LAYER_EXCLUSIVE     0x2
382 
383 /**
384  * struct sde_drm_dim_layer - dim layer cfg struct
385  * @flags:         Refer SDE_DRM_DIM_LAYER_CONFIG_FLAG for possible values
386  * @stage:         Blending stage of the dim layer
387  * @color_fill:    Color fill for dim layer
388  * @rect:          Dim layer coordinates
389  */
390 struct sde_drm_dim_layer_cfg {
391 	uint32_t flags;
392 	uint32_t stage;
393 	struct sde_drm_color color_fill;
394 	struct drm_clip_rect rect;
395 };
396 
397 /**
398  * struct sde_drm_dim_layer_v1 - version 1 of dim layer struct
399  * @num_layers:    Numer of Dim Layers
400  * @layer:         Dim layer user cfgs ptr for the num_layers
401  */
402 struct sde_drm_dim_layer_v1 {
403 	uint32_t num_layers;
404 	struct sde_drm_dim_layer_cfg layer_cfg[SDE_MAX_DIM_LAYERS];
405 };
406 
407 /* Writeback Config version definition */
408 #define SDE_DRM_WB_CFG		0x1
409 
410 /* SDE_DRM_WB_CONFIG_FLAGS - Writeback configuration flags */
411 #define SDE_DRM_WB_CFG_FLAGS_CONNECTED	(1<<0)
412 
413 /**
414  * struct sde_drm_wb_cfg - Writeback configuration structure
415  * @flags:		see DRM_MSM_WB_CONFIG_FLAGS
416  * @connector_id:	writeback connector identifier
417  * @count_modes:	Count of modes in modes_ptr
418  * @modes:		Pointer to struct drm_mode_modeinfo
419  */
420 struct sde_drm_wb_cfg {
421 	uint32_t flags;
422 	uint32_t connector_id;
423 	uint32_t count_modes;
424 	uint64_t modes;
425 };
426 
427 #define SDE_MAX_ROI_V1	4
428 
429 /**
430  * struct sde_drm_roi_v1 - list of regions of interest for a drm object
431  * @num_rects: number of valid rectangles in the roi array
432  * @roi: list of roi rectangles
433  */
434 struct sde_drm_roi_v1 {
435 	uint32_t num_rects;
436 	struct drm_clip_rect roi[SDE_MAX_ROI_V1];
437 };
438 
439 /**
440  * Define extended power modes supported by the SDE connectors.
441  */
442 #define SDE_MODE_DPMS_ON	0
443 #define SDE_MODE_DPMS_LP1	1
444 #define SDE_MODE_DPMS_LP2	2
445 #define SDE_MODE_DPMS_STANDBY	3
446 #define SDE_MODE_DPMS_SUSPEND	4
447 #define SDE_MODE_DPMS_OFF	5
448 
449 #endif /* _SDE_DRM_H_ */
450