• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
4  * Author: James.Qian.Wang <james.qian.wang@arm.com>
5  *
6  */
7 
8 #ifndef _KOMEDA_FORMAT_CAPS_H_
9 #define _KOMEDA_FORMAT_CAPS_H_
10 
11 #include <linux/types.h>
12 #include <uapi/drm/drm_fourcc.h>
13 #include <drm/drm_fourcc.h>
14 
15 #define AFBC(x)		DRM_FORMAT_MOD_ARM_AFBC(x)
16 
17 /* afbc layerout */
18 #define AFBC_16x16(x)	AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | (x))
19 #define AFBC_32x8(x)	AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 | (x))
20 
21 /* afbc features */
22 #define _YTR		AFBC_FORMAT_MOD_YTR
23 #define _SPLIT		AFBC_FORMAT_MOD_SPLIT
24 #define _SPARSE		AFBC_FORMAT_MOD_SPARSE
25 #define _CBR		AFBC_FORMAT_MOD_CBR
26 #define _TILED		AFBC_FORMAT_MOD_TILED
27 #define _SC		AFBC_FORMAT_MOD_SC
28 
29 /* layer_type */
30 #define KOMEDA_FMT_RICH_LAYER		BIT(0)
31 #define KOMEDA_FMT_SIMPLE_LAYER		BIT(1)
32 #define KOMEDA_FMT_WB_LAYER		BIT(2)
33 
34 #define AFBC_TH_LAYOUT_ALIGNMENT	8
35 #define AFBC_HEADER_SIZE		16
36 #define AFBC_SUPERBLK_ALIGNMENT		128
37 #define AFBC_SUPERBLK_PIXELS		256
38 #define AFBC_BODY_START_ALIGNMENT	1024
39 #define AFBC_TH_BODY_START_ALIGNMENT	4096
40 
41 /**
42  * struct komeda_format_caps
43  *
44  * komeda_format_caps is for describing ARM display specific features and
45  * limitations for a specific format, and format_caps will be linked into
46  * &komeda_framebuffer like a extension of &drm_format_info.
47  *
48  * NOTE: one fourcc may has two different format_caps items for fourcc and
49  * fourcc+modifier
50  *
51  * @hw_id: hw format id, hw specific value.
52  * @fourcc: drm fourcc format.
53  * @supported_layer_types: indicate which layer supports this format
54  * @supported_rots: allowed rotations for this format
55  * @supported_afbc_layouts: supported afbc layerout
56  * @supported_afbc_features: supported afbc features
57  */
58 struct komeda_format_caps {
59 	u32 hw_id;
60 	u32 fourcc;
61 	u32 supported_layer_types;
62 	u32 supported_rots;
63 	u32 supported_afbc_layouts;
64 	u64 supported_afbc_features;
65 };
66 
67 /**
68  * struct komeda_format_caps_table - format_caps mananger
69  *
70  * @n_formats: the size of format_caps list.
71  * @format_caps: format_caps list.
72  * @format_mod_supported: Optional. Some HW may have special requirements or
73  * limitations which can not be described by format_caps, this func supply HW
74  * the ability to do the further HW specific check.
75  */
76 struct komeda_format_caps_table {
77 	u32 n_formats;
78 	const struct komeda_format_caps *format_caps;
79 	bool (*format_mod_supported)(const struct komeda_format_caps *caps,
80 				     u32 layer_type, u64 modifier, u32 rot);
81 };
82 
83 extern u64 komeda_supported_modifiers[];
84 
komeda_get_format_name(u32 fourcc,u64 modifier)85 static inline const char *komeda_get_format_name(u32 fourcc, u64 modifier)
86 {
87 	struct drm_format_name_buf buf;
88 	static char name[64];
89 
90 	snprintf(name, sizeof(name), "%s with modifier: 0x%llx.",
91 		 drm_get_format_name(fourcc, &buf), modifier);
92 
93 	return name;
94 }
95 
96 const struct komeda_format_caps *
97 komeda_get_format_caps(struct komeda_format_caps_table *table,
98 		       u32 fourcc, u64 modifier);
99 
100 u32 komeda_get_afbc_format_bpp(const struct drm_format_info *info,
101 			       u64 modifier);
102 
103 u32 *komeda_get_layer_fourcc_list(struct komeda_format_caps_table *table,
104 				  u32 layer_type, u32 *n_fmts);
105 
106 void komeda_put_fourcc_list(u32 *fourcc_list);
107 
108 bool komeda_format_mod_supported(struct komeda_format_caps_table *table,
109 				 u32 layer_type, u32 fourcc, u64 modifier,
110 				 u32 rot);
111 
112 #endif
113