xref: /linux/drivers/gpu/drm/msm/disp/mdp_format.h (revision 4b132aacb0768ac1e652cf517097ea6f237214b9)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
4  * Copyright (C) 2013 Red Hat
5  * Author: Rob Clark <robdclark@gmail.com>
6  */
7 
8 #ifndef __MSM_FORMAT_H__
9 #define __MSM_FORMAT_H__
10 
11 #include "mdp_common.xml.h"
12 
13 enum msm_format_flags {
14 	MSM_FORMAT_FLAG_YUV_BIT,
15 	MSM_FORMAT_FLAG_DX_BIT,
16 	MSM_FORMAT_FLAG_COMPRESSED_BIT,
17 	MSM_FORMAT_FLAG_UNPACK_TIGHT_BIT,
18 	MSM_FORMAT_FLAG_UNPACK_ALIGN_MSB_BIT,
19 };
20 
21 #define MSM_FORMAT_FLAG_YUV		BIT(MSM_FORMAT_FLAG_YUV_BIT)
22 #define MSM_FORMAT_FLAG_DX		BIT(MSM_FORMAT_FLAG_DX_BIT)
23 #define MSM_FORMAT_FLAG_COMPRESSED	BIT(MSM_FORMAT_FLAG_COMPRESSED_BIT)
24 #define MSM_FORMAT_FLAG_UNPACK_TIGHT	BIT(MSM_FORMAT_FLAG_UNPACK_TIGHT_BIT)
25 #define MSM_FORMAT_FLAG_UNPACK_ALIGN_MSB BIT(MSM_FORMAT_FLAG_UNPACK_ALIGN_MSB_BIT)
26 
27 /**
28  * DPU HW,Component order color map
29  */
30 enum {
31 	C0_G_Y = 0,
32 	C1_B_Cb = 1,
33 	C2_R_Cr = 2,
34 	C3_ALPHA = 3
35 };
36 
37 /**
38  * struct msm_format: defines the format configuration
39  * @pixel_format: format fourcc
40  * @element: element color ordering
41  * @fetch_type: how the color components are packed in pixel format
42  * @chroma_sample: chroma sub-samplng type
43  * @alpha_enable: whether the format has an alpha channel
44  * @unpack_count: number of the components to unpack
45  * @bpp: bytes per pixel
46  * @flags: usage bit flags
47  * @num_planes: number of planes (including meta data planes)
48  * @fetch_mode: linear, tiled, or ubwc hw fetch behavior
49  * @tile_height: format tile height
50  */
51 struct msm_format {
52 	uint32_t pixel_format;
53 	enum mdp_bpc bpc_g_y, bpc_b_cb, bpc_r_cr;
54 	enum mdp_bpc_alpha bpc_a;
55 	u8 element[4];
56 	enum mdp_fetch_type fetch_type;
57 	enum mdp_chroma_samp_type chroma_sample;
58 	bool alpha_enable;
59 	u8 unpack_count;
60 	u8 bpp;
61 	unsigned long flags;
62 	u8 num_planes;
63 	enum mdp_fetch_mode fetch_mode;
64 	u16 tile_height;
65 };
66 
67 #define MSM_FORMAT_IS_YUV(X)		((X)->flags & MSM_FORMAT_FLAG_YUV)
68 #define MSM_FORMAT_IS_DX(X)		((X)->flags & MSM_FORMAT_FLAG_DX)
69 #define MSM_FORMAT_IS_LINEAR(X)		((X)->fetch_mode == MDP_FETCH_LINEAR)
70 #define MSM_FORMAT_IS_TILE(X) \
71 	(((X)->fetch_mode == MDP_FETCH_UBWC) && \
72 	 !((X)->flags & MSM_FORMAT_FLAG_COMPRESSED))
73 #define MSM_FORMAT_IS_UBWC(X) \
74 	(((X)->fetch_mode == MDP_FETCH_UBWC) && \
75 	 ((X)->flags & MSM_FORMAT_FLAG_COMPRESSED))
76 
77 #endif
78