1 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
13 #ifndef _DPU_HW_MDSS_H
14 #define _DPU_HW_MDSS_H
16 #include <linux/kernel.h>
17 #include <linux/err.h>
21 #define DPU_DBG_NAME "dpu"
25 #ifndef DPU_CSC_MATRIX_COEFF_SIZE
26 #define DPU_CSC_MATRIX_COEFF_SIZE 9
29 #ifndef DPU_CSC_CLAMP_SIZE
30 #define DPU_CSC_CLAMP_SIZE 6
33 #ifndef DPU_CSC_BIAS_SIZE
34 #define DPU_CSC_BIAS_SIZE 3
37 #ifndef DPU_MAX_PLANES
38 #define DPU_MAX_PLANES 4
41 #define PIPES_PER_STAGE 2
42 #ifndef DPU_MAX_DE_CURVES
43 #define DPU_MAX_DE_CURVES 3
46 enum dpu_format_flags {
47 DPU_FORMAT_FLAG_YUV_BIT,
48 DPU_FORMAT_FLAG_DX_BIT,
49 DPU_FORMAT_FLAG_COMPRESSED_BIT,
50 DPU_FORMAT_FLAG_BIT_MAX,
53 #define DPU_FORMAT_FLAG_YUV BIT(DPU_FORMAT_FLAG_YUV_BIT)
54 #define DPU_FORMAT_FLAG_DX BIT(DPU_FORMAT_FLAG_DX_BIT)
55 #define DPU_FORMAT_FLAG_COMPRESSED BIT(DPU_FORMAT_FLAG_COMPRESSED_BIT)
56 #define DPU_FORMAT_IS_YUV(X) \
57 (test_bit(DPU_FORMAT_FLAG_YUV_BIT, (X)->flag))
58 #define DPU_FORMAT_IS_DX(X) \
59 (test_bit(DPU_FORMAT_FLAG_DX_BIT, (X)->flag))
60 #define DPU_FORMAT_IS_LINEAR(X) ((X)->fetch_mode == DPU_FETCH_LINEAR)
61 #define DPU_FORMAT_IS_TILE(X) \
62 (((X)->fetch_mode == DPU_FETCH_UBWC) && \
63 !test_bit(DPU_FORMAT_FLAG_COMPRESSED_BIT, (X)->flag))
64 #define DPU_FORMAT_IS_UBWC(X) \
65 (((X)->fetch_mode == DPU_FETCH_UBWC) && \
66 test_bit(DPU_FORMAT_FLAG_COMPRESSED_BIT, (X)->flag))
68 #define DPU_BLEND_FG_ALPHA_FG_CONST (0 << 0)
69 #define DPU_BLEND_FG_ALPHA_BG_CONST (1 << 0)
70 #define DPU_BLEND_FG_ALPHA_FG_PIXEL (2 << 0)
71 #define DPU_BLEND_FG_ALPHA_BG_PIXEL (3 << 0)
72 #define DPU_BLEND_FG_INV_ALPHA (1 << 2)
73 #define DPU_BLEND_FG_MOD_ALPHA (1 << 3)
74 #define DPU_BLEND_FG_INV_MOD_ALPHA (1 << 4)
75 #define DPU_BLEND_FG_TRANSP_EN (1 << 5)
76 #define DPU_BLEND_BG_ALPHA_FG_CONST (0 << 8)
77 #define DPU_BLEND_BG_ALPHA_BG_CONST (1 << 8)
78 #define DPU_BLEND_BG_ALPHA_FG_PIXEL (2 << 8)
79 #define DPU_BLEND_BG_ALPHA_BG_PIXEL (3 << 8)
80 #define DPU_BLEND_BG_INV_ALPHA (1 << 10)
81 #define DPU_BLEND_BG_MOD_ALPHA (1 << 11)
82 #define DPU_BLEND_BG_INV_MOD_ALPHA (1 << 12)
83 #define DPU_BLEND_BG_TRANSP_EN (1 << 13)
85 #define DPU_VSYNC0_SOURCE_GPIO 0
86 #define DPU_VSYNC1_SOURCE_GPIO 1
87 #define DPU_VSYNC2_SOURCE_GPIO 2
88 #define DPU_VSYNC_SOURCE_INTF_0 3
89 #define DPU_VSYNC_SOURCE_INTF_1 4
90 #define DPU_VSYNC_SOURCE_INTF_2 5
91 #define DPU_VSYNC_SOURCE_INTF_3 6
92 #define DPU_VSYNC_SOURCE_WD_TIMER_4 11
93 #define DPU_VSYNC_SOURCE_WD_TIMER_3 12
94 #define DPU_VSYNC_SOURCE_WD_TIMER_2 13
95 #define DPU_VSYNC_SOURCE_WD_TIMER_1 14
96 #define DPU_VSYNC_SOURCE_WD_TIMER_0 15
98 enum dpu_hw_blk_type {
228 /* virtual interfaces */
281 enum dpu_iommu_domain {
282 DPU_IOMMU_DOMAIN_UNSECURE,
283 DPU_IOMMU_DOMAIN_SECURE,
288 * DPU HW,Component order color map
298 * enum dpu_plane_type - defines how the color component pixel packing
299 * @DPU_PLANE_INTERLEAVED : Color components in single plane
300 * @DPU_PLANE_PLANAR : Color component in separate planes
301 * @DPU_PLANE_PSEUDO_PLANAR : Chroma components interleaved in separate plane
303 enum dpu_plane_type {
304 DPU_PLANE_INTERLEAVED,
306 DPU_PLANE_PSEUDO_PLANAR,
310 * enum dpu_chroma_samp_type - chroma sub-samplng type
311 * @DPU_CHROMA_RGB : No chroma subsampling
312 * @DPU_CHROMA_H2V1 : Chroma pixels are horizontally subsampled
313 * @DPU_CHROMA_H1V2 : Chroma pixels are vertically subsampled
314 * @DPU_CHROMA_420 : 420 subsampling
316 enum dpu_chroma_samp_type {
324 * dpu_fetch_type - Defines How DPU HW fetches data
325 * @DPU_FETCH_LINEAR : fetch is line by line
326 * @DPU_FETCH_TILE : fetches data in Z order from a tile
327 * @DPU_FETCH_UBWC : fetch and decompress data
329 enum dpu_fetch_type {
336 * Value of enum chosen to fit the number of bits
337 * expected by the HW programming.
340 COLOR_ALPHA_1BIT = 0,
341 COLOR_ALPHA_4BIT = 1,
343 COLOR_5BIT = 1, /* No 5-bit Alpha */
344 COLOR_6BIT = 2, /* 6-Bit Alpha also = 2 */
345 COLOR_8BIT = 3, /* 8-Bit Alpha also = 3 */
349 * enum dpu_3d_blend_mode
350 * Desribes how the 3d data is blended
351 * @BLEND_3D_NONE : 3d blending not enabled
352 * @BLEND_3D_FRAME_INT : Frame interleaving
353 * @BLEND_3D_H_ROW_INT : Horizontal row interleaving
354 * @BLEND_3D_V_ROW_INT : vertical row interleaving
355 * @BLEND_3D_COL_INT : column interleaving
358 enum dpu_3d_blend_mode {
367 /** struct dpu_format - defines the format configuration which
368 * allows DPU HW to correctly fetch and decode the format
369 * @base: base msm_format struture containing fourcc code
370 * @fetch_planes: how the color components are packed in pixel format
371 * @element: element color ordering
372 * @bits: element bit widths
373 * @chroma_sample: chroma sub-samplng type
374 * @unpack_align_msb: unpack aligned, 0 to LSB, 1 to MSB
375 * @unpack_tight: 0 for loose, 1 for tight
376 * @unpack_count: 0 = 1 component, 1 = 2 component
377 * @bpp: bytes per pixel
378 * @alpha_enable: whether the format has an alpha channel
379 * @num_planes: number of planes (including meta data planes)
380 * @fetch_mode: linear, tiled, or ubwc hw fetch behavior
381 * @is_yuv: is format a yuv variant
382 * @flag: usage bit flags
383 * @tile_width: format tile width
384 * @tile_height: format tile height
387 struct msm_format base;
388 enum dpu_plane_type fetch_planes;
389 u8 element[DPU_MAX_PLANES];
390 u8 bits[DPU_MAX_PLANES];
391 enum dpu_chroma_samp_type chroma_sample;
398 enum dpu_fetch_type fetch_mode;
399 DECLARE_BITMAP(flag, DPU_FORMAT_FLAG_BIT_MAX);
403 #define to_dpu_format(x) container_of(x, struct dpu_format, base)
406 * struct dpu_hw_fmt_layout - format information of the source pixel data
407 * @format: pixel format parameters
408 * @num_planes: number of planes (including meta data planes)
409 * @width: image width
410 * @height: image height
411 * @total_size: total size in bytes
412 * @plane_addr: address of each plane
413 * @plane_size: length of each plane
414 * @plane_pitch: pitch of each plane
416 struct dpu_hw_fmt_layout {
417 const struct dpu_format *format;
422 uint32_t plane_addr[DPU_MAX_PLANES];
423 uint32_t plane_size[DPU_MAX_PLANES];
424 uint32_t plane_pitch[DPU_MAX_PLANES];
428 /* matrix coefficients in S15.16 format */
429 uint32_t csc_mv[DPU_CSC_MATRIX_COEFF_SIZE];
430 uint32_t csc_pre_bv[DPU_CSC_BIAS_SIZE];
431 uint32_t csc_post_bv[DPU_CSC_BIAS_SIZE];
432 uint32_t csc_pre_lv[DPU_CSC_CLAMP_SIZE];
433 uint32_t csc_post_lv[DPU_CSC_CLAMP_SIZE];
437 * struct dpu_mdss_color - mdss color description
443 struct dpu_mdss_color {
451 * Define bit masks for h/w logging.
453 #define DPU_DBG_MASK_NONE (1 << 0)
454 #define DPU_DBG_MASK_CDM (1 << 1)
455 #define DPU_DBG_MASK_INTF (1 << 2)
456 #define DPU_DBG_MASK_LM (1 << 3)
457 #define DPU_DBG_MASK_CTL (1 << 4)
458 #define DPU_DBG_MASK_PINGPONG (1 << 5)
459 #define DPU_DBG_MASK_SSPP (1 << 6)
460 #define DPU_DBG_MASK_WB (1 << 7)
461 #define DPU_DBG_MASK_TOP (1 << 8)
462 #define DPU_DBG_MASK_VBIF (1 << 9)
463 #define DPU_DBG_MASK_ROT (1 << 10)
465 #endif /* _DPU_HW_MDSS_H */