summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/msm/disp/mdp_format.h
blob: a00d646ff4d471edd6ff1b79225bb68bf50d25ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
69
70
71
72
73
74
75
76
77
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 * Copyright (C) 2013 Red Hat
 * Author: Rob Clark <robdclark@gmail.com>
 */

#ifndef __MSM_FORMAT_H__
#define __MSM_FORMAT_H__

#include "mdp_common.xml.h"

enum msm_format_flags {
	MSM_FORMAT_FLAG_YUV_BIT,
	MSM_FORMAT_FLAG_DX_BIT,
	MSM_FORMAT_FLAG_COMPRESSED_BIT,
	MSM_FORMAT_FLAG_UNPACK_TIGHT_BIT,
	MSM_FORMAT_FLAG_UNPACK_ALIGN_MSB_BIT,
};

#define MSM_FORMAT_FLAG_YUV		BIT(MSM_FORMAT_FLAG_YUV_BIT)
#define MSM_FORMAT_FLAG_DX		BIT(MSM_FORMAT_FLAG_DX_BIT)
#define MSM_FORMAT_FLAG_COMPRESSED	BIT(MSM_FORMAT_FLAG_COMPRESSED_BIT)
#define MSM_FORMAT_FLAG_UNPACK_TIGHT	BIT(MSM_FORMAT_FLAG_UNPACK_TIGHT_BIT)
#define MSM_FORMAT_FLAG_UNPACK_ALIGN_MSB BIT(MSM_FORMAT_FLAG_UNPACK_ALIGN_MSB_BIT)

/**
 * DPU HW,Component order color map
 */
enum {
	C0_G_Y = 0,
	C1_B_Cb = 1,
	C2_R_Cr = 2,
	C3_ALPHA = 3
};

/**
 * struct msm_format: defines the format configuration
 * @pixel_format: format fourcc
 * @element: element color ordering
 * @fetch_type: how the color components are packed in pixel format
 * @chroma_sample: chroma sub-samplng type
 * @alpha_enable: whether the format has an alpha channel
 * @unpack_count: number of the components to unpack
 * @bpp: bytes per pixel
 * @flags: usage bit flags
 * @num_planes: number of planes (including meta data planes)
 * @fetch_mode: linear, tiled, or ubwc hw fetch behavior
 * @tile_height: format tile height
 */
struct msm_format {
	uint32_t pixel_format;
	enum mdp_bpc bpc_g_y, bpc_b_cb, bpc_r_cr;
	enum mdp_bpc_alpha bpc_a;
	u8 element[4];
	enum mdp_fetch_type fetch_type;
	enum mdp_chroma_samp_type chroma_sample;
	bool alpha_enable;
	u8 unpack_count;
	u8 bpp;
	unsigned long flags;
	u8 num_planes;
	enum mdp_fetch_mode fetch_mode;
	u16 tile_height;
};

#define MSM_FORMAT_IS_YUV(X)		((X)->flags & MSM_FORMAT_FLAG_YUV)
#define MSM_FORMAT_IS_DX(X)		((X)->flags & MSM_FORMAT_FLAG_DX)
#define MSM_FORMAT_IS_LINEAR(X)		((X)->fetch_mode == MDP_FETCH_LINEAR)
#define MSM_FORMAT_IS_TILE(X) \
	(((X)->fetch_mode == MDP_FETCH_UBWC) && \
	 !((X)->flags & MSM_FORMAT_FLAG_COMPRESSED))
#define MSM_FORMAT_IS_UBWC(X) \
	(((X)->fetch_mode == MDP_FETCH_UBWC) && \
	 ((X)->flags & MSM_FORMAT_FLAG_COMPRESSED))

#endif