1 /*
2  * Copyright (C) 2016-2019 ARM Limited. All rights reserved.
3  *
4  * Copyright (C) 2008 The Android Open Source Project
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef MALI_GRALLOC_FORMATS_H_
20 #define MALI_GRALLOC_FORMATS_H_
21 
22 #include <system/graphics.h>
23 #include <log/log.h>
24 
25 /* Internal formats are represented in gralloc as a 64bit identifier
26  * where the 32 lower bits are a base format and the 32 upper bits are modifiers.
27  *
28  * Modifier bits are divided into mutually exclusive ones and those that are not.
29  */
30 /* Internal format type */
31 typedef uint64_t mali_gralloc_internal_format;
32 
33 /* Internal format masks */
34 #define MALI_GRALLOC_INTFMT_FMT_MASK  0x00000000ffffffffULL
35 #define MALI_GRALLOC_INTFMT_EXT_MASK  0xffffffff00000000ULL
36 #define MALI_GRALLOC_INTFMT_FMT_WRAP_MASK 0x0000ffffULL
37 #define MALI_GRALLOC_INTFMT_EXT_WRAP_MASK 0xffff0000ULL
38 #define MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT 16
39 
40 /* Format Modifier Bits Locations */
41 #define MALI_GRALLOC_INTFMT_EXTENSION_BIT_START 32
42 
43 /* Internal base formats */
44 
45 /* Base formats that do not have an identical HAL match
46  * are defined starting at the Android private range
47  */
48 #define MALI_GRALLOC_FORMAT_INTERNAL_RANGE_BASE 0x200
49 
50 typedef enum
51 {
52 	MALI_GRALLOC_FORMAT_TYPE_USAGE,
53 	MALI_GRALLOC_FORMAT_TYPE_INTERNAL,
54 } mali_gralloc_format_type;
55 
56 /*
57  * Internal formats defined to either match HAL_PIXEL_FORMAT_* or extend
58  * where missing. Private formats can be used where no CPU usage is requested.
59  * All pixel formats in this list must explicitly define a strict memory
60  * layout which can be allocated and used by producer(s) and consumer(s).
61  * Flex formats are therefore not included and will be mapped to suitable
62  * internal formats.
63  */
64 typedef enum
65 {
66 	/* Internal definitions for HAL formats. */
67 	MALI_GRALLOC_FORMAT_INTERNAL_UNDEFINED = 0,
68 	MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888,
69 	MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888,
70 	MALI_GRALLOC_FORMAT_INTERNAL_RGB_888 = HAL_PIXEL_FORMAT_RGB_888,
71 	MALI_GRALLOC_FORMAT_INTERNAL_RGB_565 = HAL_PIXEL_FORMAT_RGB_565,
72 	MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888,
73 #if PLATFORM_SDK_VERSION >= 26
74 	MALI_GRALLOC_FORMAT_INTERNAL_RGBA_1010102 = HAL_PIXEL_FORMAT_RGBA_1010102,
75 	MALI_GRALLOC_FORMAT_INTERNAL_RGBA_16161616 = HAL_PIXEL_FORMAT_RGBA_FP16,
76 #endif /* PLATFORM_SDK_VERSION >= 26 */
77 	MALI_GRALLOC_FORMAT_INTERNAL_YV12 = HAL_PIXEL_FORMAT_YV12,
78 	MALI_GRALLOC_FORMAT_INTERNAL_Y8 = HAL_PIXEL_FORMAT_Y8,
79 	MALI_GRALLOC_FORMAT_INTERNAL_Y16 = HAL_PIXEL_FORMAT_Y16,
80 	MALI_GRALLOC_FORMAT_INTERNAL_NV16 = HAL_PIXEL_FORMAT_YCbCr_422_SP,
81 
82 	/* Camera specific HAL formats */
83 	MALI_GRALLOC_FORMAT_INTERNAL_RAW16 = HAL_PIXEL_FORMAT_RAW16,
84 	MALI_GRALLOC_FORMAT_INTERNAL_RAW12 = HAL_PIXEL_FORMAT_RAW12,
85 	MALI_GRALLOC_FORMAT_INTERNAL_RAW10 = HAL_PIXEL_FORMAT_RAW10,
86 	MALI_GRALLOC_FORMAT_INTERNAL_RAW_OPAQUE = HAL_PIXEL_FORMAT_RAW_OPAQUE,
87 	MALI_GRALLOC_FORMAT_INTERNAL_BLOB = HAL_PIXEL_FORMAT_BLOB,
88 
89 #if PLATFORM_SDK_VERSION >= 28
90 	/* Depth and stencil formats */
91 	MALI_GRALLOC_FORMAT_INTERNAL_DEPTH_16 = HAL_PIXEL_FORMAT_DEPTH_16,
92 	MALI_GRALLOC_FORMAT_INTERNAL_DEPTH_24 = HAL_PIXEL_FORMAT_DEPTH_24,
93 	MALI_GRALLOC_FORMAT_INTERNAL_DEPTH_24_STENCIL_8 = HAL_PIXEL_FORMAT_DEPTH_24_STENCIL_8,
94 	MALI_GRALLOC_FORMAT_INTERNAL_DEPTH_32F = HAL_PIXEL_FORMAT_DEPTH_32F,
95 	MALI_GRALLOC_FORMAT_INTERNAL_DEPTH_32F_STENCIL_8 = HAL_PIXEL_FORMAT_DEPTH_32F_STENCIL_8,
96 	MALI_GRALLOC_FORMAT_INTERNAL_STENCIL_8 = HAL_PIXEL_FORMAT_STENCIL_8,
97 #endif
98 
99 	/* Flexible YUV formats would be parsed but not have any representation as
100 	 * internal format itself but one of the ones below.
101 	 */
102 
103 	/* The internal private formats that have no HAL equivivalent are defined
104 	 * afterwards starting at a specific base range.
105 	 */
106 	MALI_GRALLOC_FORMAT_INTERNAL_NV12 = MALI_GRALLOC_FORMAT_INTERNAL_RANGE_BASE,
107 	MALI_GRALLOC_FORMAT_INTERNAL_NV21,
108 	MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT,
109 
110 	/* Extended YUV formats. */
111 	MALI_GRALLOC_FORMAT_INTERNAL_Y0L2,
112 	MALI_GRALLOC_FORMAT_INTERNAL_P010,
113 	MALI_GRALLOC_FORMAT_INTERNAL_P210,
114 	MALI_GRALLOC_FORMAT_INTERNAL_Y210,
115 	MALI_GRALLOC_FORMAT_INTERNAL_Y410,
116 
117 	/*
118 	 * Single-plane (I = interleaved) variants of 8/10-bit YUV formats,
119 	 * where previously not defined.
120 	 */
121 	MALI_GRALLOC_FORMAT_INTERNAL_YUV420_8BIT_I,
122 	MALI_GRALLOC_FORMAT_INTERNAL_YUV420_10BIT_I,
123 	MALI_GRALLOC_FORMAT_INTERNAL_YUV444_10BIT_I,
124 
125 	/* Add more internal formats here. Make sure decode_internal_format() is updated. */
126 
127 	/* These are legacy 0.3 gralloc formats used only by the wrap/unwrap macros. */
128 	MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP,
129 	MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP,
130 	MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP,
131 
132 	MALI_GRALLOC_FORMAT_INTERNAL_RANGE_LAST,
133 } mali_gralloc_pixel_format;
134 
135 
136 /* Modifier Bits - these are now independent. */
137 
138 /* This format will use AFBC */
139 #define MALI_GRALLOC_INTFMT_AFBC_BASIC (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START + 0))
140 
141 /* This format uses AFBC split block mode */
142 #define MALI_GRALLOC_INTFMT_AFBC_SPLITBLK (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START + 1))
143 
144 /* This format uses AFBC wide block mode */
145 #define MALI_GRALLOC_INTFMT_AFBC_WIDEBLK (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START + 2))
146 
147 /* This format uses AFBC tiled headers */
148 #define MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START + 3))
149 
150 /* This format uses AFBC extra wide superblocks. */
151 #define MALI_GRALLOC_INTFMT_AFBC_EXTRAWIDEBLK (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START + 4))
152 
153 /* This format is AFBC with double body buffer (used as a frontbuffer) */
154 #define MALI_GRALLOC_INTFMT_AFBC_DOUBLE_BODY (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START + 5))
155 
156 /* This format uses AFBC buffer content hints in LSB of superblock offset. */
157 #define MALI_GRALLOC_INTFMT_AFBC_BCH (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START + 6))
158 
159 /* This format uses AFBC with YUV transform.
160  * This is automatically enabled, and should not be set with GRALLOC_USAGE_PRIVATE_3. */
161 #define MALI_GRALLOC_INTFMT_AFBC_YUV_TRANSFORM 0
162 
163 /* This mask should be used to check or clear support for AFBC for an internal format.
164  */
165 #define MALI_GRALLOC_INTFMT_AFBCENABLE_MASK (uint64_t)(MALI_GRALLOC_INTFMT_AFBC_BASIC)
166 
167 /* These are legacy Gralloc 0.3 support macros for passing private formats through the 0.3 alloc interface.
168  * It packs modifier bits together with base format into a 32 bit format identifier.
169  * Gralloc 1.0 interface should use private functions to set private buffer format in the buffer descriptor.
170  *
171  * Packing:
172  *
173  * Bits 15-0:    mali_gralloc_pixel_format format
174  * Bits 31-16:   modifier bits
175  */
mali_gralloc_format_wrapper(int format,int modifiers)176 static inline int mali_gralloc_format_wrapper(int format, int modifiers)
177 {
178 	/* Internal formats that are identical to HAL formats
179 	 * have the same definition. This is convenient for
180 	 * client parsing code to not have to parse them separately.
181 	 *
182 	 * For 3 of the HAL YUV formats that have very large definitions
183 	 * this causes problems for packing in modifier bits.
184 	 * Because of this reason we redefine these three formats
185 	 * while packing/unpacking them.
186 	 */
187 	if (format == MALI_GRALLOC_FORMAT_INTERNAL_YV12)
188 	{
189 		format = MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP;
190 	}
191 	else if (format == MALI_GRALLOC_FORMAT_INTERNAL_Y8)
192 	{
193 		format = MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP;
194 	}
195 	else if (format == MALI_GRALLOC_FORMAT_INTERNAL_Y16)
196 	{
197 		format = MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP;
198 	}
199 
200 	if (format & ~MALI_GRALLOC_INTFMT_FMT_WRAP_MASK)
201 	{
202 		format = MALI_GRALLOC_FORMAT_INTERNAL_UNDEFINED;
203 		ALOGE("Format is too large for private format wrapping");
204 	}
205 
206 	return (modifiers | format);
207 }
208 
mali_gralloc_format_unwrap(int x)209 static inline uint64_t mali_gralloc_format_unwrap(int x)
210 {
211 	uint64_t internal_format = (uint64_t)(((((uint64_t)(x)) & MALI_GRALLOC_INTFMT_EXT_WRAP_MASK) << MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT) | // Modifier bits
212 	                                       (((uint64_t)(x)) & MALI_GRALLOC_INTFMT_FMT_WRAP_MASK)); // Private format
213 
214 	uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
215 	uint64_t modifiers = internal_format & MALI_GRALLOC_INTFMT_EXT_MASK;
216 
217 	if (base_format == MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP)
218 	{
219 		base_format = MALI_GRALLOC_FORMAT_INTERNAL_YV12;
220 	}
221 	else if (base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP)
222 	{
223 	 	base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y8;
224 	}
225 	else if (base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP)
226 	{
227 		base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y16;
228 	}
229 
230 	return (modifiers | base_format);
231 }
232 
233 
234 #define GRALLOC_PRIVATE_FORMAT_WRAPPER(x) (mali_gralloc_format_wrapper(x, 0))
235 
236 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC(x) (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT)))
237 
238 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_SPLITBLK(x) \
239 		(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_SPLITBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT | \
240 		                             (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT))))
241 
242 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_WIDEBLK(x) \
243 		(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT | \
244 		                             (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT))))
245 
246 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_WIDE_SPLIT(x) \
247 		(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT | \
248 		                             (MALI_GRALLOC_INTFMT_AFBC_SPLITBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT) | \
249 		                             (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT))))
250 
251 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_BASIC(x)                   \
252 		(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT) | \
253 		                             (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT)))
254 
255 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_WIDE(x)                    \
256 		(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT | \
257 		                             (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT) | \
258 		                             (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT))))
259 
260 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_SPLIT(x) \
261 		(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT | \
262 		                             (MALI_GRALLOC_INTFMT_AFBC_SPLITBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT) | \
263 		                             (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT))))
264 
265 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_WIDE_SPLIT(x) \
266 		(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT | \
267 		                             (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT) | \
268 		                             (MALI_GRALLOC_INTFMT_AFBC_SPLITBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT) | \
269 		                             (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT))))
270 
271 /*
272  * AFBC format with extra-wide (64x4) superblocks.
273  *
274  * NOTE: Tiled headers are mandatory for this format.
275  */
276 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_EXTRAWIDEBLK(x) \
277 	(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT | \
278 	                             (MALI_GRALLOC_INTFMT_AFBC_EXTRAWIDEBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT | \
279 	                             (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT)))))
280 
281 /*
282  * AFBC multi-plane YUV format where luma (wide, 32x8) and
283  * chroma (extra-wide, 64x4) planes are stored in separate AFBC buffers.
284  *
285  * NOTE: Tiled headers are mandatory for this format.
286  * NOTE: Base format (x) must be a multi-plane YUV format.
287  */
288 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_WIDE_EXTRAWIDE(x) \
289     (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT | \
290                                         (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT) | \
291                                         (MALI_GRALLOC_INTFMT_AFBC_EXTRAWIDEBLK >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT) | \
292                                         (MALI_GRALLOC_INTFMT_AFBC_BASIC >> MALI_GRALLOC_INTFMT_EXT_WRAP_SHIFT))))
293 
294 
295 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_DOUBLE_BODY(x) \
296     (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 16 | \
297                                         (MALI_GRALLOC_INTFMT_AFBC_DOUBLE_BODY >> 16) | \
298                                         (MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16))))
299 
300 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_SPLIT_DOUBLE_BODY(x) \
301     (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 16 | \
302                                         (MALI_GRALLOC_INTFMT_AFBC_SPLITBLK >> 16) | \
303                                         (MALI_GRALLOC_INTFMT_AFBC_DOUBLE_BODY >> 16) | \
304                                         (MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16))))
305 
306 /*
307  * Macro to add additional modifier(s) to existing wrapped private format.
308  * Arguments include wrapped private format and new modifier(s) to add.
309  */
310 #define GRALLOC_PRIVATE_FORMAT_WRAPPER_ADD_MODIFIER(x, modifiers) \
311     ((int)((x) | ((int)((modifiers) >> 16))))
312 
313 
314 #define GRALLOC_PRIVATE_FORMAT_UNWRAP(x) mali_gralloc_format_unwrap(x)
315 
316 /* IP block capability masks */
317 #define MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT ((uint64_t)1 << 0)
318 
319 /* For IPs which can't read/write YUV with AFBC encoding use flag AFBC_YUV_READ/AFBC_YUV_WRITE */
320 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC ((uint64_t)1 << 1)
321 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK ((uint64_t)1 << 2)
322 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK ((uint64_t)1 << 3)
323 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_RESERVED_1 ((uint64_t)1 << 4)
324 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_RESERVED_2 ((uint64_t)1 << 5)
325 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_RESERVED_3 ((uint64_t)1 << 6)
326 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS ((uint64_t)1 << 7)
327 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_EXTRAWIDEBLK ((uint64_t)1 << 8)
328 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_MULTIPLANE_READ ((uint64_t)1 << 9)
329 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_DOUBLE_BODY ((uint64_t)1 << 10)
330 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_READ ((uint64_t)1 << 11)
331 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_WRITE ((uint64_t)1 << 12)
332 
333 #define MALI_GRALLOC_FORMAT_CAPABILITY_PIXFMT_RGBA1010102 ((uint64_t)1 << 32)
334 #define MALI_GRALLOC_FORMAT_CAPABILITY_PIXFMT_RGBA16161616 ((uint64_t)1 << 33)
335 
336 #define MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK                                                     \
337 	((uint64_t)(MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC | MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK | \
338 	            MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK | MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS))
339 
340 struct mali_gralloc_format_caps
341 {
342 	uint64_t caps_mask;
343 };
344 typedef struct mali_gralloc_format_caps mali_gralloc_format_caps;
345 
346 #define MALI_GRALLOC_FORMATCAPS_SYM_NAME mali_gralloc_format_capabilities
347 #define MALI_GRALLOC_FORMATCAPS_SYM_NAME_STR "mali_gralloc_format_capabilities"
348 
349 /* Internal prototypes */
350 #if defined(GRALLOC_LIBRARY_BUILD)
351 
352 void mali_gralloc_adjust_dimensions(const uint64_t internal_format,
353                                     const uint64_t usage,
354                                     int* const width,
355                                     int* const height);
356 
357 uint64_t mali_gralloc_select_format(const uint64_t req_format,
358                                     const mali_gralloc_format_type type,
359                                     const uint64_t usage,
360                                     const int buffer_size,
361                                     uint64_t * const internal_format);
362 
363 bool is_subsampled_yuv(const uint32_t base_format);
364 #endif
365 
366 #ifdef __cplusplus
367 extern "C" {
368 #endif
369 
370 void mali_gralloc_get_caps(struct mali_gralloc_format_caps *gpu_caps,
371                            struct mali_gralloc_format_caps *vpu_caps,
372                            struct mali_gralloc_format_caps *dpu_caps,
373                            struct mali_gralloc_format_caps *dpu_aeu_caps,
374                            struct mali_gralloc_format_caps *cam_caps);
375 #ifdef __cplusplus
376 }
377 #endif
378 
379 bool is_exynos_format(uint32_t base_format);
380 
381 #endif /* MALI_GRALLOC_FORMATS_H_ */
382