• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * (C) COPYRIGHT 2017 ARM Limited. All rights reserved.
3  * Copyright (C) 2008 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef MALI_GRALLOC_USAGES_H_
19 #define MALI_GRALLOC_USAGES_H_
20 
21 /*
22  * Below usage types overlap, this is intentional.
23  * The reason is that for Gralloc 0.3 there are very
24  * few usage flags we have at our disposal.
25  *
26  * The overlapping is handled by processing the definitions
27  * in a specific order.
28  *
29  * MALI_GRALLOC_USAGE_PRIVATE_FORMAT and MALI_GRALLOC_USAGE_NO_AFBC
30  * don't overlap and are processed first.
31  *
32  * MALI_GRALLOC_USAGE_YUV_CONF are only for YUV formats and clients
33  * using MALI_GRALLOC_USAGE_NO_AFBC must never allocate YUV formats.
34  * The latter is strictly enforced and allocations will fail.
35  *
36  * MALI_GRALLOC_USAGE_AFBC_PADDING is only valid if MALI_GRALLOC_USAGE_NO_AFBC
37  * is not present.
38  */
39 
40 /*
41  * Gralloc private usage 0-3 are the same in 0.3 and 1.0.
42  * We defined based our usages based on what is available.
43  */
44 #if defined(GRALLOC_MODULE_API_VERSION_1_0)
45 typedef enum
46 {
47 	/* The client has specified a private format in the format parameter */
48 	MALI_GRALLOC_USAGE_PRIVATE_FORMAT = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_3,
49 
50 	/* Buffer won't be allocated as AFBC */
51 	MALI_GRALLOC_USAGE_NO_AFBC = (int)(GRALLOC1_PRODUCER_USAGE_PRIVATE_1 | GRALLOC1_PRODUCER_USAGE_PRIVATE_2),
52 
53 	/* Valid only for YUV allocations */
54 	MALI_GRALLOC_USAGE_YUV_CONF_0 = 0,
55 	MALI_GRALLOC_USAGE_YUV_CONF_1 = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_1,
56 	MALI_GRALLOC_USAGE_YUV_CONF_2 = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_0,
57 	MALI_GRALLOC_USAGE_YUV_CONF_3 = (int)(GRALLOC1_PRODUCER_USAGE_PRIVATE_0 | GRALLOC1_PRODUCER_USAGE_PRIVATE_1),
58 	MALI_GRALLOC_USAGE_YUV_CONF_MASK = MALI_GRALLOC_USAGE_YUV_CONF_3,
59 
60 	/* A very specific alignment is requested on some buffers */
61 	MALI_GRALLOC_USAGE_AFBC_PADDING = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_2,
62 
63 } mali_gralloc_usage_type;
64 #elif defined(GRALLOC_MODULE_API_VERSION_0_3)
65 typedef enum
66 {
67 	/* The client has specified a private format in the format parameter */
68 	MALI_GRALLOC_USAGE_PRIVATE_FORMAT = (int)GRALLOC_USAGE_PRIVATE_3,
69 
70 	/* Buffer won't be allocated as AFBC */
71 	MALI_GRALLOC_USAGE_NO_AFBC = (int)(GRALLOC_USAGE_PRIVATE_1 | GRALLOC_USAGE_PRIVATE_2),
72 
73 	/* Valid only for YUV allocations */
74 	MALI_GRALLOC_USAGE_YUV_CONF_0 = 0,
75 	MALI_GRALLOC_USAGE_YUV_CONF_1 = (int)GRALLOC_USAGE_PRIVATE_1,
76 	MALI_GRALLOC_USAGE_YUV_CONF_2 = (int)GRALLOC_USAGE_PRIVATE_0,
77 	MALI_GRALLOC_USAGE_YUV_CONF_3 = (int)(GRALLOC_USAGE_PRIVATE_0 | GRALLOC_USAGE_PRIVATE_1),
78 	MALI_GRALLOC_USAGE_YUV_CONF_MASK = MALI_GRALLOC_USAGE_YUV_CONF_3,
79 
80 	/* A very specific alignment is requested on some buffers */
81 	MALI_GRALLOC_USAGE_AFBC_PADDING = GRALLOC_USAGE_PRIVATE_2,
82 
83 } mali_gralloc_usage_type;
84 #else
85 #if defined(GRALLOC_LIBRARY_BUILD)
86 #error "Please include mali_gralloc_module.h before including other gralloc headers when building gralloc itself"
87 #else
88 #error "Please include either gralloc.h or gralloc1.h header before including gralloc_priv.h"
89 #endif
90 #endif
91 
92 #endif /*MALI_GRALLOC_USAGES_H_*/
93