Imported Upstream version 0.1.0+git20131207+e452e83
[deb_libhybris.git] / hybris / egl / platforms / common / hybris_nativebufferext.h
1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 * Copyright (C) 2013 Jolla Ltd.
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 EGL_HYBRIS_native_buffer
19 #define EGL_HYBRIS_native_buffer 1
20
21 #define EGL_NATIVE_BUFFER_HYBRIS 0x3140
22 typedef EGLBoolean (EGLAPIENTRYP PFNEGLHYBRISCREATENATIVEBUFFERPROC)(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint *stride, EGLClientBuffer *buffer);
23 typedef EGLBoolean (EGLAPIENTRYP PFNEGLHYBRISLOCKNATIVEBUFFERPROC)(EGLClientBuffer buffer, EGLint usage, EGLint l, EGLint t, EGLint w, EGLint h, void **vaddr);
24 typedef EGLBoolean (EGLAPIENTRYP PFNEGLHYBRISUNLOCKNATIVEBUFFERPROC)(EGLClientBuffer buffer);
25 typedef EGLBoolean (EGLAPIENTRYP PFNEGLHYBRISRELEASENATIVEBUFFERPROC)(EGLClientBuffer buffer);
26
27 enum {
28 /* buffer is never read in software */
29 HYBRIS_USAGE_SW_READ_NEVER = 0x00000000,
30 /* buffer is rarely read in software */
31 HYBRIS_USAGE_SW_READ_RARELY = 0x00000002,
32 /* buffer is often read in software */
33 HYBRIS_USAGE_SW_READ_OFTEN = 0x00000003,
34 /* mask for the software read values */
35 HYBRIS_USAGE_SW_READ_MASK = 0x0000000F,
36
37 /* buffer is never written in software */
38 HYBRIS_USAGE_SW_WRITE_NEVER = 0x00000000,
39 /* buffer is rarely written in software */
40 HYBRIS_USAGE_SW_WRITE_RARELY = 0x00000020,
41 /* buffer is often written in software */
42 HYBRIS_USAGE_SW_WRITE_OFTEN = 0x00000030,
43 /* mask for the software write values */
44 HYBRIS_USAGE_SW_WRITE_MASK = 0x000000F0,
45
46 /* buffer will be used as an OpenGL ES texture */
47 HYBRIS_USAGE_HW_TEXTURE = 0x00000100,
48 /* buffer will be used as an OpenGL ES render target */
49 HYBRIS_USAGE_HW_RENDER = 0x00000200,
50 /* buffer will be used by the 2D hardware blitter */
51 HYBRIS_USAGE_HW_2D = 0x00000400,
52 /* buffer will be used by the HWComposer HAL module */
53 HYBRIS_USAGE_HW_COMPOSER = 0x00000800,
54 /* buffer will be used with the framebuffer device */
55 HYBRIS_USAGE_HW_FB = 0x00001000,
56 /* buffer will be used with the HW video encoder */
57 HYBRIS_USAGE_HW_VIDEO_ENCODER = 0x00010000,
58 /* buffer will be written by the HW camera pipeline */
59 HYBRIS_USAGE_HW_CAMERA_WRITE = 0x00020000,
60 /* buffer will be read by the HW camera pipeline */
61 HYBRIS_USAGE_HW_CAMERA_READ = 0x00040000,
62 /* buffer will be used as part of zero-shutter-lag queue */
63 HYBRIS_USAGE_HW_CAMERA_ZSL = 0x00060000,
64 /* mask for the camera access values */
65 HYBRIS_USAGE_HW_CAMERA_MASK = 0x00060000,
66 /* mask for the software usage bit-mask */
67 HYBRIS_USAGE_HW_MASK = 0x00071F00,
68
69 /* buffer should be displayed full-screen on an external display when
70 * possible
71 */
72 HYBRIS_USAGE_EXTERNAL_DISP = 0x00002000,
73
74 /* Must have a hardware-protected path to external display sink for
75 * this buffer. If a hardware-protected path is not available, then
76 * either don't composite only this buffer (preferred) to the
77 * external sink, or (less desirable) do not route the entire
78 * composition to the external sink.
79 */
80 HYBRIS_USAGE_PROTECTED = 0x00004000,
81 };
82
83 /**
84 * pixel format definitions
85 */
86
87 enum {
88 HYBRIS_PIXEL_FORMAT_RGBA_8888 = 1,
89 HYBRIS_PIXEL_FORMAT_RGBX_8888 = 2,
90 HYBRIS_PIXEL_FORMAT_RGB_888 = 3,
91 HYBRIS_PIXEL_FORMAT_RGB_565 = 4,
92 HYBRIS_PIXEL_FORMAT_BGRA_8888 = 5,
93 HYBRIS_PIXEL_FORMAT_RGBA_5551 = 6,
94 HYBRIS_PIXEL_FORMAT_RGBA_4444 = 7,
95
96 /* 0x8 - 0xFF range unavailable */
97
98 /*
99 * 0x100 - 0x1FF
100 *
101 * This range is reserved for pixel formats that are specific to the HAL
102 * implementation. Implementations can use any value in this range to
103 * communicate video pixel formats between their HAL modules. These formats
104 * must not have an alpha channel. Additionally, an EGLimage created from a
105 * gralloc buffer of one of these formats must be supported for use with the
106 * GL_OES_EGL_image_external OpenGL ES extension.
107 */
108
109 /*
110 * Android YUV format:
111 *
112 * This format is exposed outside of the HAL to software decoders and
113 * applications. EGLImageKHR must support it in conjunction with the
114 * OES_EGL_image_external extension.
115 *
116 * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed
117 * by (W/2) x (H/2) Cr and Cb planes.
118 *
119 * This format assumes
120 * - an even width
121 * - an even height
122 * - a horizontal stride multiple of 16 pixels
123 * - a vertical stride equal to the height
124 *
125 * y_size = stride * height
126 * c_stride = ALIGN(stride/2, 16)
127 * c_size = c_stride * height/2
128 * size = y_size + c_size * 2
129 * cr_offset = y_size
130 * cb_offset = y_size + c_size
131 *
132 */
133 HYBRIS_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar
134
135
136 /*
137 * Android Y8 format:
138 *
139 * This format is exposed outside of the HAL to the framework.
140 * The expected gralloc usage flags are SW_* and HW_CAMERA_*,
141 * and no other HW_ flags will be used.
142 *
143 * Y8 is a YUV planar format comprised of a WxH Y plane,
144 * with each pixel being represented by 8 bits.
145 *
146 * It is equivalent to just the Y plane from YV12.
147 *
148 * This format assumes
149 * - an even width
150 * - an even height
151 * - a horizontal stride multiple of 16 pixels
152 * - a vertical stride equal to the height
153 *
154 * size = stride * height
155 *
156 */
157 HYBRIS_PIXEL_FORMAT_Y8 = 0x20203859,
158
159 /*
160 * Android Y16 format:
161 *
162 * This format is exposed outside of the HAL to the framework.
163 * The expected gralloc usage flags are SW_* and HW_CAMERA_*,
164 * and no other HW_ flags will be used.
165 *
166 * Y16 is a YUV planar format comprised of a WxH Y plane,
167 * with each pixel being represented by 16 bits.
168 *
169 * It is just like Y8, but has double the bits per pixel (little endian).
170 *
171 * This format assumes
172 * - an even width
173 * - an even height
174 * - a horizontal stride multiple of 16 pixels
175 * - a vertical stride equal to the height
176 * - strides are specified in pixels, not in bytes
177 *
178 * size = stride * height * 2
179 *
180 */
181 HYBRIS_PIXEL_FORMAT_Y16 = 0x20363159,
182
183 /*
184 * Android RAW sensor format:
185 *
186 * This format is exposed outside of the HAL to applications.
187 *
188 * RAW_SENSOR is a single-channel 16-bit format, typically representing raw
189 * Bayer-pattern images from an image sensor, with minimal processing.
190 *
191 * The exact pixel layout of the data in the buffer is sensor-dependent, and
192 * needs to be queried from the camera device.
193 *
194 * Generally, not all 16 bits are used; more common values are 10 or 12
195 * bits. All parameters to interpret the raw data (black and white points,
196 * color space, etc) must be queried from the camera device.
197 *
198 * This format assumes
199 * - an even width
200 * - an even height
201 * - a horizontal stride multiple of 16 pixels (32 bytes).
202 */
203 HYBRIS_PIXEL_FORMAT_RAW_SENSOR = 0x20,
204
205 /*
206 * Android binary blob graphics buffer format:
207 *
208 * This format is used to carry task-specific data which does not have a
209 * standard image structure. The details of the format are left to the two
210 * endpoints.
211 *
212 * A typical use case is for transporting JPEG-compressed images from the
213 * Camera HAL to the framework or to applications.
214 *
215 * Buffers of this format must have a height of 1, and width equal to their
216 * size in bytes.
217 */
218 HYBRIS_PIXEL_FORMAT_BLOB = 0x21,
219
220 /*
221 * Android format indicating that the choice of format is entirely up to the
222 * device-specific Gralloc implementation.
223 *
224 * The Gralloc implementation should examine the usage bits passed in when
225 * allocating a buffer with this format, and it should derive the pixel
226 * format from those usage flags. This format will never be used with any
227 * of the GRALLOC_USAGE_SW_* usage flags.
228 *
229 * If a buffer of this format is to be used as an OpenGL ES texture, the
230 * framework will assume that sampling the texture will always return an
231 * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values).
232 *
233 */
234 HYBRIS_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22,
235
236 /*
237 * Android flexible YCbCr formats
238 *
239 * This format allows platforms to use an efficient YCbCr/YCrCb buffer
240 * layout, while still describing the buffer layout in a way accessible to
241 * the CPU in a device-independent manner. While called YCbCr, it can be
242 * used to describe formats with either chromatic ordering, as well as
243 * whole planar or semiplanar layouts.
244 *
245 * struct android_ycbcr (below) is the the struct used to describe it.
246 *
247 * This format must be accepted by the gralloc module when
248 * USAGE_HW_CAMERA_WRITE and USAGE_SW_READ_* are set.
249 *
250 * This format is locked for use by gralloc's (*lock_ycbcr) method, and
251 * locking with the (*lock) method will return an error.
252 */
253 HYBRIS_PIXEL_FORMAT_YCbCr_420_888 = 0x23,
254
255 /* Legacy formats (deprecated), used by ImageFormat.java */
256 HYBRIS_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16
257 HYBRIS_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21
258 HYBRIS_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2
259 };
260
261 #endif