• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 GRALLOC3_PRIV_H_
20 #define GRALLOC3_PRIV_H_
21 
22 #include <linux/fb.h>
23 #include <hardware/gralloc1.h>
24 #include <inttypes.h>
25 #include <log/log.h>
26 
27 #define AFBC_INFO_SIZE                              (sizeof(int))
28 #define AFBC_ENABLE                                 (0xafbc)
29 
30 /* Exynos specific usages */
31 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_NONSECURE               GRALLOC1_PRODUCER_USAGE_PRIVATE_8
32 #define GRALLOC1_PRODUCER_USAGE_NOZEROED                        GRALLOC1_PRODUCER_USAGE_PRIVATE_9
33 
34 #define GRALLOC1_CONSUMER_USAGE_VIDEO_PRIVATE_DATA              GRALLOC1_CONSUMER_USAGE_PRIVATE_7
35 
36 #define GRALLOC_USAGE_GOOGLE_IP_BO                              GRALLOC1_CONSUMER_USAGE_PRIVATE_16
37 #define GRALLOC_USAGE_GOOGLE_IP_BW                              GRALLOC1_CONSUMER_USAGE_PRIVATE_16 /* Alias to BO */
38 #define GRALLOC_USAGE_GOOGLE_IP_MFC                             GRALLOC1_CONSUMER_USAGE_PRIVATE_17
39 
40 #define GS101_GRALLOC_USAGE_TPU_INPUT                           GRALLOC1_CONSUMER_USAGE_PRIVATE_5
41 #define GS101_GRALLOC_USAGE_TPU_OUTPUT                          GRALLOC1_PRODUCER_USAGE_PRIVATE_3
42 #define GS101_GRALLOC_USAGE_CAMERA_STATS                        GRALLOC1_PRODUCER_USAGE_PRIVATE_2
43 
44 /* for legacy */
45 #define GRALLOC_USAGE_PRIVATE_NONSECURE                         GRALLOC1_PRODUCER_USAGE_PRIVATE_NONSECURE
46 
47 typedef int ion_user_handle_t;
48 
49 typedef enum
50 {
51 	/*
52 	 * Allocation will be used as a front-buffer, which
53 	 * supports concurrent producer-consumer access.
54 	 *
55 	 * NOTE: Must not be used with MALI_GRALLOC_USAGE_FORCE_BACKBUFFER
56 	 */
57 	MALI_GRALLOC_USAGE_FRONTBUFFER = GRALLOC1_PRODUCER_USAGE_PRIVATE_12,
58 
59 	/*
60 	 * Allocation will be used as a back-buffer.
61 	 * Use when switching from front-buffer as a workaround for Android
62 	 * buffer queue, which does not re-allocate for a sub-set of
63 	 * existing usage.
64 	 *
65 	 * NOTE: Must not be used with MALI_GRALLOC_USAGE_FRONTBUFFER.
66 	 */
67 	MALI_GRALLOC_USAGE_FORCE_BACKBUFFER = GRALLOC1_PRODUCER_USAGE_PRIVATE_13,
68 
69 	/*
70 	 * Buffer will not be allocated with AFBC.
71 	 *
72 	 * NOTE: Not compatible with MALI_GRALLOC_USAGE_FORCE_BACKBUFFER so cannot be
73 	 * used when switching from front-buffer to back-buffer.
74 	 */
75 	MALI_GRALLOC_USAGE_NO_AFBC = GRALLOC1_PRODUCER_USAGE_PRIVATE_1,
76 
77 	/* Custom alignment for AFBC headers.
78 	 *
79 	 * NOTE: due to usage flag overlap, AFBC_PADDING cannot be used with FORCE_BACKBUFFER.
80 	 */
81 	MALI_GRALLOC_USAGE_AFBC_PADDING = GRALLOC1_PRODUCER_USAGE_PRIVATE_14,
82 	/* Private format usage.
83 	 * 'format' argument to allocation function will be interpreted in a
84 	 * private manner and must be constructed via GRALLOC_PRIVATE_FORMAT_WRAPPER_*
85 	 * macros which pack base format and AFBC format modifiers into 32-bit value.
86 	 */
87 	MALI_GRALLOC_USAGE_PRIVATE_FORMAT = GRALLOC1_PRODUCER_USAGE_PRIVATE_15,
88 
89 	/* YUV only. */
90 	MALI_GRALLOC_USAGE_YUV_COLOR_SPACE_DEFAULT = 0,
91 	MALI_GRALLOC_USAGE_YUV_COLOR_SPACE_BT601 = GRALLOC1_PRODUCER_USAGE_PRIVATE_18,
92 	MALI_GRALLOC_USAGE_YUV_COLOR_SPACE_BT709 = GRALLOC1_PRODUCER_USAGE_PRIVATE_19,
93 	MALI_GRALLOC_USAGE_YUV_COLOR_SPACE_BT2020 = (GRALLOC1_PRODUCER_USAGE_PRIVATE_18 | GRALLOC1_PRODUCER_USAGE_PRIVATE_19),
94 	MALI_GRALLOC_USAGE_YUV_COLOR_SPACE_MASK = MALI_GRALLOC_USAGE_YUV_COLOR_SPACE_BT2020,
95 
96 	MALI_GRALLOC_USAGE_RANGE_DEFAULT = 0,
97 	MALI_GRALLOC_USAGE_RANGE_NARROW = GRALLOC1_PRODUCER_USAGE_PRIVATE_16,
98 	MALI_GRALLOC_USAGE_RANGE_WIDE = GRALLOC1_PRODUCER_USAGE_PRIVATE_17,
99 	MALI_GRALLOC_USAGE_RANGE_MASK = (GRALLOC1_PRODUCER_USAGE_PRIVATE_16 | GRALLOC1_PRODUCER_USAGE_PRIVATE_17),
100 } mali_gralloc_usage_type;
101 
102 typedef struct
103 {
104 	struct hw_module_t common;
105 } gralloc1_module_t;
106 
107 typedef enum
108 {
109 	MALI_DPY_TYPE_UNKNOWN = 0,
110 	MALI_DPY_TYPE_CLCD,
111 	MALI_DPY_TYPE_HDLCD
112 } mali_dpy_type;
113 
114 typedef enum
115 {
116 	MALI_YUV_NO_INFO,
117 	MALI_YUV_BT601_NARROW,
118 	MALI_YUV_BT601_WIDE,
119 	MALI_YUV_BT709_NARROW,
120 	MALI_YUV_BT709_WIDE,
121 	MALI_YUV_BT2020_NARROW,
122 	MALI_YUV_BT2020_WIDE
123 } mali_gralloc_yuv_info;
124 
125 #endif /* GRALLOC3_PRIV_H_ */
126