1 // Copyright 2018 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expresso or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #pragma once
15 
16 typedef enum {
17     HAL_PIXEL_FORMAT_RGBA_8888 = 1,
18     HAL_PIXEL_FORMAT_RGBX_8888 = 2,
19     HAL_PIXEL_FORMAT_RGB_888 = 3,
20     HAL_PIXEL_FORMAT_RGB_565 = 4,
21     HAL_PIXEL_FORMAT_BGRA_8888 = 5,
22     HAL_PIXEL_FORMAT_RGBA_1010102 = 43,            // 0x2B
23     HAL_PIXEL_FORMAT_RGBA_FP16 = 22,               // 0x16
24     HAL_PIXEL_FORMAT_YV12 = 842094169,             // 0x32315659
25     HAL_PIXEL_FORMAT_Y8 = 538982489,               // 0x20203859
26     HAL_PIXEL_FORMAT_Y16 = 540422489,              // 0x20363159
27     HAL_PIXEL_FORMAT_RAW16 = 32,                   // 0x20
28     HAL_PIXEL_FORMAT_RAW10 = 37,                   // 0x25
29     HAL_PIXEL_FORMAT_RAW12 = 38,                   // 0x26
30     HAL_PIXEL_FORMAT_RAW_OPAQUE = 36,              // 0x24
31     HAL_PIXEL_FORMAT_BLOB = 33,                    // 0x21
32     HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 34,  // 0x22
33     HAL_PIXEL_FORMAT_YCBCR_420_888 = 35,           // 0x23
34     HAL_PIXEL_FORMAT_YCBCR_422_888 = 39,           // 0x27
35     HAL_PIXEL_FORMAT_YCBCR_444_888 = 40,           // 0x28
36     HAL_PIXEL_FORMAT_FLEX_RGB_888 = 41,            // 0x29
37     HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 42,          // 0x2A
38     HAL_PIXEL_FORMAT_YCBCR_422_SP = 16,            // 0x10
39     HAL_PIXEL_FORMAT_YCRCB_420_SP = 17,            // 0x11
40     HAL_PIXEL_FORMAT_YCBCR_422_I = 20,             // 0x14
41     HAL_PIXEL_FORMAT_JPEG = 256,                   // 0x100
42 } android_pixel_format_t;
43 
44 enum {
45     /* buffer is never read in software */
46     GRALLOC_USAGE_SW_READ_NEVER = 0x00000000U,
47     /* buffer is rarely read in software */
48     GRALLOC_USAGE_SW_READ_RARELY = 0x00000002U,
49     /* buffer is often read in software */
50     GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003U,
51     /* mask for the software read values */
52     GRALLOC_USAGE_SW_READ_MASK = 0x0000000FU,
53 
54     /* buffer is never written in software */
55     GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000U,
56     /* buffer is rarely written in software */
57     GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020U,
58     /* buffer is often written in software */
59     GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030U,
60     /* mask for the software write values */
61     GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0U,
62 
63     /* buffer will be used as an OpenGL ES texture */
64     GRALLOC_USAGE_HW_TEXTURE = 0x00000100U,
65     /* buffer will be used as an OpenGL ES render target */
66     GRALLOC_USAGE_HW_RENDER = 0x00000200U,
67     /* buffer will be used by the 2D hardware blitter */
68     GRALLOC_USAGE_HW_2D = 0x00000400U,
69     /* buffer will be used by the HWComposer HAL module */
70     GRALLOC_USAGE_HW_COMPOSER = 0x00000800U,
71     /* buffer will be used with the framebuffer device */
72     GRALLOC_USAGE_HW_FB = 0x00001000U,
73 
74     /* buffer should be displayed full-screen on an external display when
75      * possible */
76     GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000U,
77 
78     /* Must have a hardware-protected path to external display sink for
79      * this buffer.  If a hardware-protected path is not available, then
80      * either don't composite only this buffer (preferred) to the
81      * external sink, or (less desirable) do not route the entire
82      * composition to the external sink.  */
83     GRALLOC_USAGE_PROTECTED = 0x00004000U,
84 
85     /* buffer may be used as a cursor */
86     GRALLOC_USAGE_CURSOR = 0x00008000U,
87 
88     /* buffer will be used with the HW video encoder */
89     GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000U,
90     /* buffer will be written by the HW camera pipeline */
91     GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000U,
92     /* buffer will be read by the HW camera pipeline */
93     GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000U,
94     /* buffer will be used as part of zero-shutter-lag queue */
95     GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000U,
96     /* mask for the camera access values */
97     GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000U,
98     /* mask for the software usage bit-mask */
99     GRALLOC_USAGE_HW_MASK = 0x00071F00U,
100 
101     /* buffer will be used as a RenderScript Allocation */
102     GRALLOC_USAGE_RENDERSCRIPT = 0x00100000U,
103 
104     /* Set by the consumer to indicate to the producer that they may attach a
105      * buffer that they did not detach from the BufferQueue. Will be filtered
106      * out by GRALLOC_USAGE_ALLOC_MASK, so gralloc modules will not need to
107      * handle this flag. */
108     GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000U,
109 
110     /* Mask of all flags which could be passed to a gralloc module for buffer
111      * allocation. Any flags not in this mask do not need to be handled by
112      * gralloc modules. */
113     GRALLOC_USAGE_ALLOC_MASK = ~(GRALLOC_USAGE_FOREIGN_BUFFERS),
114 
115     /* implementation-specific private usage flags */
116     GRALLOC_USAGE_PRIVATE_0 = 0x10000000U,
117     GRALLOC_USAGE_PRIVATE_1 = 0x20000000U,
118     GRALLOC_USAGE_PRIVATE_2 = 0x40000000U,
119     GRALLOC_USAGE_PRIVATE_3 = 0x80000000U,
120     GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000U,
121 };
122 
123 typedef enum {
124     GRALLOC1_CONSUMER_USAGE_NONE = 0,
125     GRALLOC1_CONSUMER_USAGE_CPU_READ_NEVER = 0,
126     /* 1ULL << 0 */
127     GRALLOC1_CONSUMER_USAGE_CPU_READ = 1ULL << 1,
128     GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN = 1ULL << 2 | GRALLOC1_CONSUMER_USAGE_CPU_READ,
129     /* 1ULL << 3 */
130     /* 1ULL << 4 */
131     /* 1ULL << 5 */
132     /* 1ULL << 6 */
133     /* 1ULL << 7 */
134     GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE = 1ULL << 8,
135     /* 1ULL << 9 */
136     /* 1ULL << 10 */
137     GRALLOC1_CONSUMER_USAGE_HWCOMPOSER = 1ULL << 11,
138     GRALLOC1_CONSUMER_USAGE_CLIENT_TARGET = 1ULL << 12,
139     /* 1ULL << 13 */
140     /* 1ULL << 14 */
141     GRALLOC1_CONSUMER_USAGE_CURSOR = 1ULL << 15,
142     GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER = 1ULL << 16,
143     /* 1ULL << 17 */
144     GRALLOC1_CONSUMER_USAGE_CAMERA = 1ULL << 18,
145     /* 1ULL << 19 */
146     GRALLOC1_CONSUMER_USAGE_RENDERSCRIPT = 1ULL << 20,
147 
148     /* Indicates that the consumer may attach buffers to their end of the
149      * BufferQueue, which means that the producer may never have seen a given
150      * dequeued buffer before. May be ignored by the gralloc device. */
151     GRALLOC1_CONSUMER_USAGE_FOREIGN_BUFFERS = 1ULL << 21,
152 
153     /* 1ULL << 22 */
154     GRALLOC1_CONSUMER_USAGE_GPU_DATA_BUFFER = 1ULL << 23,
155     /* 1ULL << 24 */
156     /* 1ULL << 25 */
157     /* 1ULL << 26 */
158     /* 1ULL << 27 */
159 
160     /* Bits reserved for implementation-specific usage flags */
161     GRALLOC1_CONSUMER_USAGE_PRIVATE_0 = 1ULL << 28,
162     GRALLOC1_CONSUMER_USAGE_PRIVATE_1 = 1ULL << 29,
163     GRALLOC1_CONSUMER_USAGE_PRIVATE_2 = 1ULL << 30,
164     GRALLOC1_CONSUMER_USAGE_PRIVATE_3 = 1ULL << 31,
165 
166     /* 1ULL << 32 */
167     /* 1ULL << 33 */
168     /* 1ULL << 34 */
169     /* 1ULL << 35 */
170     /* 1ULL << 36 */
171     /* 1ULL << 37 */
172     /* 1ULL << 38 */
173     /* 1ULL << 39 */
174     /* 1ULL << 40 */
175     /* 1ULL << 41 */
176     /* 1ULL << 42 */
177     /* 1ULL << 43 */
178     /* 1ULL << 44 */
179     /* 1ULL << 45 */
180     /* 1ULL << 46 */
181     /* 1ULL << 47 */
182 
183     /* Bits reserved for implementation-specific usage flags */
184     GRALLOC1_CONSUMER_USAGE_PRIVATE_19 = 1ULL << 48,
185     GRALLOC1_CONSUMER_USAGE_PRIVATE_18 = 1ULL << 49,
186     GRALLOC1_CONSUMER_USAGE_PRIVATE_17 = 1ULL << 50,
187     GRALLOC1_CONSUMER_USAGE_PRIVATE_16 = 1ULL << 51,
188     GRALLOC1_CONSUMER_USAGE_PRIVATE_15 = 1ULL << 52,
189     GRALLOC1_CONSUMER_USAGE_PRIVATE_14 = 1ULL << 53,
190     GRALLOC1_CONSUMER_USAGE_PRIVATE_13 = 1ULL << 54,
191     GRALLOC1_CONSUMER_USAGE_PRIVATE_12 = 1ULL << 55,
192     GRALLOC1_CONSUMER_USAGE_PRIVATE_11 = 1ULL << 56,
193     GRALLOC1_CONSUMER_USAGE_PRIVATE_10 = 1ULL << 57,
194     GRALLOC1_CONSUMER_USAGE_PRIVATE_9 = 1ULL << 58,
195     GRALLOC1_CONSUMER_USAGE_PRIVATE_8 = 1ULL << 59,
196     GRALLOC1_CONSUMER_USAGE_PRIVATE_7 = 1ULL << 60,
197     GRALLOC1_CONSUMER_USAGE_PRIVATE_6 = 1ULL << 61,
198     GRALLOC1_CONSUMER_USAGE_PRIVATE_5 = 1ULL << 62,
199     GRALLOC1_CONSUMER_USAGE_PRIVATE_4 = 1ULL << 63,
200 } gralloc1_consumer_usage_t;
201 
202 typedef enum {
203     GRALLOC1_PRODUCER_USAGE_NONE = 0,
204     GRALLOC1_PRODUCER_USAGE_CPU_WRITE_NEVER = 0,
205     /* 1ULL << 0 */
206     GRALLOC1_PRODUCER_USAGE_CPU_READ = 1ULL << 1,
207     GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN = 1ULL << 2 | GRALLOC1_PRODUCER_USAGE_CPU_READ,
208     /* 1ULL << 3 */
209     /* 1ULL << 4 */
210     GRALLOC1_PRODUCER_USAGE_CPU_WRITE = 1ULL << 5,
211     GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN = 1ULL << 6 | GRALLOC1_PRODUCER_USAGE_CPU_WRITE,
212     /* 1ULL << 7 */
213     /* 1ULL << 8 */
214     GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET = 1ULL << 9,
215     /* 1ULL << 10 */
216     /* 1ULL << 11 */
217     /* 1ULL << 12 */
218     /* 1ULL << 13 */
219 
220     /* The consumer must have a hardware-protected path to an external display
221      * sink for this buffer. If a hardware-protected path is not available, then
222      * do not attempt to display this buffer. */
223     GRALLOC1_PRODUCER_USAGE_PROTECTED = 1ULL << 14,
224 
225     /* 1ULL << 15 */
226     /* 1ULL << 16 */
227     GRALLOC1_PRODUCER_USAGE_CAMERA = 1ULL << 17,
228     /* 1ULL << 18 */
229     /* 1ULL << 19 */
230     /* 1ULL << 20 */
231     /* 1ULL << 21 */
232     GRALLOC1_PRODUCER_USAGE_VIDEO_DECODER = 1ULL << 22,
233     GRALLOC1_PRODUCER_USAGE_SENSOR_DIRECT_DATA = 1ULL << 23,
234     /* 1ULL << 24 */
235     /* 1ULL << 25 */
236     /* 1ULL << 26 */
237     /* 1ULL << 27 */
238 
239     /* Bits reserved for implementation-specific usage flags */
240     GRALLOC1_PRODUCER_USAGE_PRIVATE_0 = 1ULL << 28,
241     GRALLOC1_PRODUCER_USAGE_PRIVATE_1 = 1ULL << 29,
242     GRALLOC1_PRODUCER_USAGE_PRIVATE_2 = 1ULL << 30,
243     GRALLOC1_PRODUCER_USAGE_PRIVATE_3 = 1ULL << 31,
244 
245     /* 1ULL << 32 */
246     /* 1ULL << 33 */
247     /* 1ULL << 34 */
248     /* 1ULL << 35 */
249     /* 1ULL << 36 */
250     /* 1ULL << 37 */
251     /* 1ULL << 38 */
252     /* 1ULL << 39 */
253     /* 1ULL << 40 */
254     /* 1ULL << 41 */
255     /* 1ULL << 42 */
256     /* 1ULL << 43 */
257     /* 1ULL << 44 */
258     /* 1ULL << 45 */
259     /* 1ULL << 46 */
260     /* 1ULL << 47 */
261 
262     /* Bits reserved for implementation-specific usage flags */
263     GRALLOC1_PRODUCER_USAGE_PRIVATE_19 = 1ULL << 48,
264     GRALLOC1_PRODUCER_USAGE_PRIVATE_18 = 1ULL << 49,
265     GRALLOC1_PRODUCER_USAGE_PRIVATE_17 = 1ULL << 50,
266     GRALLOC1_PRODUCER_USAGE_PRIVATE_16 = 1ULL << 51,
267     GRALLOC1_PRODUCER_USAGE_PRIVATE_15 = 1ULL << 52,
268     GRALLOC1_PRODUCER_USAGE_PRIVATE_14 = 1ULL << 53,
269     GRALLOC1_PRODUCER_USAGE_PRIVATE_13 = 1ULL << 54,
270     GRALLOC1_PRODUCER_USAGE_PRIVATE_12 = 1ULL << 55,
271     GRALLOC1_PRODUCER_USAGE_PRIVATE_11 = 1ULL << 56,
272     GRALLOC1_PRODUCER_USAGE_PRIVATE_10 = 1ULL << 57,
273     GRALLOC1_PRODUCER_USAGE_PRIVATE_9 = 1ULL << 58,
274     GRALLOC1_PRODUCER_USAGE_PRIVATE_8 = 1ULL << 59,
275     GRALLOC1_PRODUCER_USAGE_PRIVATE_7 = 1ULL << 60,
276     GRALLOC1_PRODUCER_USAGE_PRIVATE_6 = 1ULL << 61,
277     GRALLOC1_PRODUCER_USAGE_PRIVATE_5 = 1ULL << 62,
278     GRALLOC1_PRODUCER_USAGE_PRIVATE_4 = 1ULL << 63,
279 } gralloc1_producer_usage_t;