1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
8 #include <linux/kernel.h>
13 #define DPU_DBG_NAME "dpu"
17 #ifndef DPU_CSC_MATRIX_COEFF_SIZE
18 #define DPU_CSC_MATRIX_COEFF_SIZE 9
21 #ifndef DPU_CSC_CLAMP_SIZE
22 #define DPU_CSC_CLAMP_SIZE 6
25 #ifndef DPU_CSC_BIAS_SIZE
26 #define DPU_CSC_BIAS_SIZE 3
29 #ifndef DPU_MAX_PLANES
30 #define DPU_MAX_PLANES 4
33 #define PIPES_PER_STAGE 2
34 #ifndef DPU_MAX_DE_CURVES
35 #define DPU_MAX_DE_CURVES 3
38 enum dpu_format_flags {
39 DPU_FORMAT_FLAG_YUV_BIT,
40 DPU_FORMAT_FLAG_DX_BIT,
41 DPU_FORMAT_FLAG_COMPRESSED_BIT,
42 DPU_FORMAT_FLAG_BIT_MAX,
45 #define DPU_FORMAT_FLAG_YUV BIT(DPU_FORMAT_FLAG_YUV_BIT)
46 #define DPU_FORMAT_FLAG_DX BIT(DPU_FORMAT_FLAG_DX_BIT)
47 #define DPU_FORMAT_FLAG_COMPRESSED BIT(DPU_FORMAT_FLAG_COMPRESSED_BIT)
48 #define DPU_FORMAT_IS_YUV(X) \
49 (test_bit(DPU_FORMAT_FLAG_YUV_BIT, (X)->flag))
50 #define DPU_FORMAT_IS_DX(X) \
51 (test_bit(DPU_FORMAT_FLAG_DX_BIT, (X)->flag))
52 #define DPU_FORMAT_IS_LINEAR(X) ((X)->fetch_mode == DPU_FETCH_LINEAR)
53 #define DPU_FORMAT_IS_TILE(X) \
54 (((X)->fetch_mode == DPU_FETCH_UBWC) && \
55 !test_bit(DPU_FORMAT_FLAG_COMPRESSED_BIT, (X)->flag))
56 #define DPU_FORMAT_IS_UBWC(X) \
57 (((X)->fetch_mode == DPU_FETCH_UBWC) && \
58 test_bit(DPU_FORMAT_FLAG_COMPRESSED_BIT, (X)->flag))
60 #define DPU_BLEND_FG_ALPHA_FG_CONST (0 << 0)
61 #define DPU_BLEND_FG_ALPHA_BG_CONST (1 << 0)
62 #define DPU_BLEND_FG_ALPHA_FG_PIXEL (2 << 0)
63 #define DPU_BLEND_FG_ALPHA_BG_PIXEL (3 << 0)
64 #define DPU_BLEND_FG_INV_ALPHA (1 << 2)
65 #define DPU_BLEND_FG_MOD_ALPHA (1 << 3)
66 #define DPU_BLEND_FG_INV_MOD_ALPHA (1 << 4)
67 #define DPU_BLEND_FG_TRANSP_EN (1 << 5)
68 #define DPU_BLEND_BG_ALPHA_FG_CONST (0 << 8)
69 #define DPU_BLEND_BG_ALPHA_BG_CONST (1 << 8)
70 #define DPU_BLEND_BG_ALPHA_FG_PIXEL (2 << 8)
71 #define DPU_BLEND_BG_ALPHA_BG_PIXEL (3 << 8)
72 #define DPU_BLEND_BG_INV_ALPHA (1 << 10)
73 #define DPU_BLEND_BG_MOD_ALPHA (1 << 11)
74 #define DPU_BLEND_BG_INV_MOD_ALPHA (1 << 12)
75 #define DPU_BLEND_BG_TRANSP_EN (1 << 13)
77 #define DPU_VSYNC0_SOURCE_GPIO 0
78 #define DPU_VSYNC1_SOURCE_GPIO 1
79 #define DPU_VSYNC2_SOURCE_GPIO 2
80 #define DPU_VSYNC_SOURCE_INTF_0 3
81 #define DPU_VSYNC_SOURCE_INTF_1 4
82 #define DPU_VSYNC_SOURCE_INTF_2 5
83 #define DPU_VSYNC_SOURCE_INTF_3 6
84 #define DPU_VSYNC_SOURCE_WD_TIMER_4 11
85 #define DPU_VSYNC_SOURCE_WD_TIMER_3 12
86 #define DPU_VSYNC_SOURCE_WD_TIMER_2 13
87 #define DPU_VSYNC_SOURCE_WD_TIMER_1 14
88 #define DPU_VSYNC_SOURCE_WD_TIMER_0 15
90 enum dpu_hw_blk_type {
206 /* virtual interfaces */
254 * DPU HW,Component order color map
264 * enum dpu_plane_type - defines how the color component pixel packing
265 * @DPU_PLANE_INTERLEAVED : Color components in single plane
266 * @DPU_PLANE_PLANAR : Color component in separate planes
267 * @DPU_PLANE_PSEUDO_PLANAR : Chroma components interleaved in separate plane
269 enum dpu_plane_type {
270 DPU_PLANE_INTERLEAVED,
272 DPU_PLANE_PSEUDO_PLANAR,
276 * enum dpu_chroma_samp_type - chroma sub-samplng type
277 * @DPU_CHROMA_RGB : No chroma subsampling
278 * @DPU_CHROMA_H2V1 : Chroma pixels are horizontally subsampled
279 * @DPU_CHROMA_H1V2 : Chroma pixels are vertically subsampled
280 * @DPU_CHROMA_420 : 420 subsampling
282 enum dpu_chroma_samp_type {
290 * dpu_fetch_type - Defines How DPU HW fetches data
291 * @DPU_FETCH_LINEAR : fetch is line by line
292 * @DPU_FETCH_TILE : fetches data in Z order from a tile
293 * @DPU_FETCH_UBWC : fetch and decompress data
295 enum dpu_fetch_type {
302 * Value of enum chosen to fit the number of bits
303 * expected by the HW programming.
306 COLOR_ALPHA_1BIT = 0,
307 COLOR_ALPHA_4BIT = 1,
309 COLOR_5BIT = 1, /* No 5-bit Alpha */
310 COLOR_6BIT = 2, /* 6-Bit Alpha also = 2 */
311 COLOR_8BIT = 3, /* 8-Bit Alpha also = 3 */
315 * enum dpu_3d_blend_mode
316 * Desribes how the 3d data is blended
317 * @BLEND_3D_NONE : 3d blending not enabled
318 * @BLEND_3D_FRAME_INT : Frame interleaving
319 * @BLEND_3D_H_ROW_INT : Horizontal row interleaving
320 * @BLEND_3D_V_ROW_INT : vertical row interleaving
321 * @BLEND_3D_COL_INT : column interleaving
324 enum dpu_3d_blend_mode {
333 /** struct dpu_format - defines the format configuration which
334 * allows DPU HW to correctly fetch and decode the format
335 * @base: base msm_format struture containing fourcc code
336 * @fetch_planes: how the color components are packed in pixel format
337 * @element: element color ordering
338 * @bits: element bit widths
339 * @chroma_sample: chroma sub-samplng type
340 * @unpack_align_msb: unpack aligned, 0 to LSB, 1 to MSB
341 * @unpack_tight: 0 for loose, 1 for tight
342 * @unpack_count: 0 = 1 component, 1 = 2 component
343 * @bpp: bytes per pixel
344 * @alpha_enable: whether the format has an alpha channel
345 * @num_planes: number of planes (including meta data planes)
346 * @fetch_mode: linear, tiled, or ubwc hw fetch behavior
347 * @flag: usage bit flags
348 * @tile_width: format tile width
349 * @tile_height: format tile height
352 struct msm_format base;
353 enum dpu_plane_type fetch_planes;
354 u8 element[DPU_MAX_PLANES];
355 u8 bits[DPU_MAX_PLANES];
356 enum dpu_chroma_samp_type chroma_sample;
363 enum dpu_fetch_type fetch_mode;
364 DECLARE_BITMAP(flag, DPU_FORMAT_FLAG_BIT_MAX);
368 #define to_dpu_format(x) container_of(x, struct dpu_format, base)
371 * struct dpu_hw_fmt_layout - format information of the source pixel data
372 * @format: pixel format parameters
373 * @num_planes: number of planes (including meta data planes)
374 * @width: image width
375 * @height: image height
376 * @total_size: total size in bytes
377 * @plane_addr: address of each plane
378 * @plane_size: length of each plane
379 * @plane_pitch: pitch of each plane
381 struct dpu_hw_fmt_layout {
382 const struct dpu_format *format;
387 uint32_t plane_addr[DPU_MAX_PLANES];
388 uint32_t plane_size[DPU_MAX_PLANES];
389 uint32_t plane_pitch[DPU_MAX_PLANES];
393 /* matrix coefficients in S15.16 format */
394 uint32_t csc_mv[DPU_CSC_MATRIX_COEFF_SIZE];
395 uint32_t csc_pre_bv[DPU_CSC_BIAS_SIZE];
396 uint32_t csc_post_bv[DPU_CSC_BIAS_SIZE];
397 uint32_t csc_pre_lv[DPU_CSC_CLAMP_SIZE];
398 uint32_t csc_post_lv[DPU_CSC_CLAMP_SIZE];
402 * struct dpu_mdss_color - mdss color description
408 struct dpu_mdss_color {
416 * Define bit masks for h/w logging.
418 #define DPU_DBG_MASK_NONE (1 << 0)
419 #define DPU_DBG_MASK_INTF (1 << 1)
420 #define DPU_DBG_MASK_LM (1 << 2)
421 #define DPU_DBG_MASK_CTL (1 << 3)
422 #define DPU_DBG_MASK_PINGPONG (1 << 4)
423 #define DPU_DBG_MASK_SSPP (1 << 5)
424 #define DPU_DBG_MASK_WB (1 << 6)
425 #define DPU_DBG_MASK_TOP (1 << 7)
426 #define DPU_DBG_MASK_VBIF (1 << 8)
427 #define DPU_DBG_MASK_ROT (1 << 9)
429 #endif /* _DPU_HW_MDSS_H */