summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Venkatraman2017-04-05 18:45:44 -0500
committerVijay Venkatraman2017-04-06 12:28:50 -0500
commitb3ef9022e90a062ceae3d35a3655c558d96a17c0 (patch)
tree06e418c00d96f8000e91399dece7995ca9aec57c /include
parentb15882faab26af76f0bca30c2ce4ef4890eb4502 (diff)
downloadplatform-system-core-b3ef9022e90a062ceae3d35a3655c558d96a17c0.tar.gz
platform-system-core-b3ef9022e90a062ceae3d35a3655c558d96a17c0.tar.xz
platform-system-core-b3ef9022e90a062ceae3d35a3655c558d96a17c0.zip
Moved all files from include/system to libsystem/include/system
Bug: 33241851 Test: No changes for modules not using VNDK. For compiling with VNDK, add libsystem_headers as dependency for using these headers Change-Id: I1a8a44073424cc0db625e31d44cb16b78c5a9ca1 Merged-In: I2acce0ab771e10ac83461c2f931e2c19e922089e
Diffstat (limited to 'include')
l---------include/system1
-rw-r--r--include/system/camera.h298
-rw-r--r--include/system/graphics.h1420
-rw-r--r--include/system/qemu_pipe.h134
-rw-r--r--include/system/radio.h253
-rw-r--r--include/system/thread_defs.h77
-rw-r--r--include/system/window.h1013
7 files changed, 1 insertions, 3195 deletions
diff --git a/include/system b/include/system
new file mode 120000
index 000000000..91d45be34
--- /dev/null
+++ b/include/system
@@ -0,0 +1 @@
../libsystem/include/system/ \ No newline at end of file
diff --git a/include/system/camera.h b/include/system/camera.h
deleted file mode 100644
index 5d0873ac4..000000000
--- a/include/system/camera.h
+++ /dev/null
@@ -1,298 +0,0 @@
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H
18#define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H
19
20#include <stdint.h>
21#include <sys/cdefs.h>
22#include <sys/types.h>
23#include <cutils/native_handle.h>
24#include <hardware/hardware.h>
25#include <hardware/gralloc.h>
26
27__BEGIN_DECLS
28
29/**
30 * A set of bit masks for specifying how the received preview frames are
31 * handled before the previewCallback() call.
32 *
33 * The least significant 3 bits of an "int" value are used for this purpose:
34 *
35 * ..... 0 0 0
36 * ^ ^ ^
37 * | | |---------> determine whether the callback is enabled or not
38 * | |-----------> determine whether the callback is one-shot or not
39 * |-------------> determine whether the frame is copied out or not
40 *
41 * WARNING: When a frame is sent directly without copying, it is the frame
42 * receiver's responsiblity to make sure that the frame data won't get
43 * corrupted by subsequent preview frames filled by the camera. This flag is
44 * recommended only when copying out data brings significant performance price
45 * and the handling/processing of the received frame data is always faster than
46 * the preview frame rate so that data corruption won't occur.
47 *
48 * For instance,
49 * 1. 0x00 disables the callback. In this case, copy out and one shot bits
50 * are ignored.
51 * 2. 0x01 enables a callback without copying out the received frames. A
52 * typical use case is the Camcorder application to avoid making costly
53 * frame copies.
54 * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical
55 * use case is the Camera application.
56 * 4. 0x07 is enabling a callback with frame copied out only once. A typical
57 * use case is the Barcode scanner application.
58 */
59
60enum {
61 CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01,
62 CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02,
63 CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04,
64 /** Typical use cases */
65 CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00,
66 CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01,
67 CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05,
68 CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07
69};
70
71/** msgType in notifyCallback and dataCallback functions */
72enum {
73 CAMERA_MSG_ERROR = 0x0001, // notifyCallback
74 CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback
75 CAMERA_MSG_FOCUS = 0x0004, // notifyCallback
76 CAMERA_MSG_ZOOM = 0x0008, // notifyCallback
77 CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback
78 CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback
79 CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback
80 CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback
81 CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback
82 CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback
83 // Preview frame metadata. This can be combined with
84 // CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can
85 // request FRAME and METADATA. Or the apps can request only FRAME or only
86 // METADATA.
87 CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback
88 // Notify on autofocus start and stop. This is useful in continuous
89 // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE.
90 CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback
91 CAMERA_MSG_ALL_MSGS = 0xFFFF
92};
93
94/** cmdType in sendCommand functions */
95enum {
96 CAMERA_CMD_START_SMOOTH_ZOOM = 1,
97 CAMERA_CMD_STOP_SMOOTH_ZOOM = 2,
98
99 /**
100 * Set the clockwise rotation of preview display (setPreviewDisplay) in
101 * degrees. This affects the preview frames and the picture displayed after
102 * snapshot. This method is useful for portrait mode applications. Note
103 * that preview display of front-facing cameras is flipped horizontally
104 * before the rotation, that is, the image is reflected along the central
105 * vertical axis of the camera sensor. So the users can see themselves as
106 * looking into a mirror.
107 *
108 * This does not affect the order of byte array of
109 * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME,
110 * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or
111 * CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview
112 * since API level 14.
113 */
114 CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3,
115
116 /**
117 * cmdType to disable/enable shutter sound. In sendCommand passing arg1 =
118 * 0 will disable, while passing arg1 = 1 will enable the shutter sound.
119 */
120 CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4,
121
122 /* cmdType to play recording sound */
123 CAMERA_CMD_PLAY_RECORDING_SOUND = 5,
124
125 /**
126 * Start the face detection. This should be called after preview is started.
127 * The camera will notify the listener of CAMERA_MSG_FACE and the detected
128 * faces in the preview frame. The detected faces may be the same as the
129 * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop
130 * the face detection. This method is supported if CameraParameters
131 * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is
132 * bigger than 0. Hardware and software face detection should not be running
133 * at the same time. If the face detection has started, apps should not send
134 * this again.
135 *
136 * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE,
137 * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect.
138 *
139 * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or
140 * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not
141 * supported, the HAL must return BAD_VALUE.
142 */
143 CAMERA_CMD_START_FACE_DETECTION = 6,
144
145 /**
146 * Stop the face detection.
147 */
148 CAMERA_CMD_STOP_FACE_DETECTION = 7,
149
150 /**
151 * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing
152 * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback.
153 */
154 CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8,
155
156 /**
157 * Ping camera service to see if camera hardware is released.
158 *
159 * When any camera method returns error, the client can use ping command
160 * to see if the camera has been taken away by other clients. If the result
161 * is NO_ERROR, it means the camera hardware is not released. If the result
162 * is not NO_ERROR, the camera has been released and the existing client
163 * can silently finish itself or show a dialog.
164 */
165 CAMERA_CMD_PING = 9,
166
167 /**
168 * Configure the number of video buffers used for recording. The intended
169 * video buffer count for recording is passed as arg1, which must be
170 * greater than 0. This command must be sent before recording is started.
171 * This command returns INVALID_OPERATION error if it is sent after video
172 * recording is started, or the command is not supported at all. This
173 * command also returns a BAD_VALUE error if the intended video buffer
174 * count is non-positive or too big to be realized.
175 */
176 CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10,
177
178 /**
179 * Configure an explicit format to use for video recording metadata mode.
180 * This can be used to switch the format from the
181 * default IMPLEMENTATION_DEFINED gralloc format to some other
182 * device-supported format, and the default dataspace from the BT_709 color
183 * space to some other device-supported dataspace. arg1 is the HAL pixel
184 * format, and arg2 is the HAL dataSpace. This command returns
185 * INVALID_OPERATION error if it is sent after video recording is started,
186 * or the command is not supported at all.
187 *
188 * If the gralloc format is set to a format other than
189 * IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags
190 * of SW_READ_OFTEN.
191 */
192 CAMERA_CMD_SET_VIDEO_FORMAT = 11
193};
194
195/** camera fatal errors */
196enum {
197 CAMERA_ERROR_UNKNOWN = 1,
198 /**
199 * Camera was released because another client has connected to the camera.
200 * The original client should call Camera::disconnect immediately after
201 * getting this notification. Otherwise, the camera will be released by
202 * camera service in a short time. The client should not call any method
203 * (except disconnect and sending CAMERA_CMD_PING) after getting this.
204 */
205 CAMERA_ERROR_RELEASED = 2,
206 CAMERA_ERROR_SERVER_DIED = 100
207};
208
209enum {
210 /** The facing of the camera is opposite to that of the screen. */
211 CAMERA_FACING_BACK = 0,
212 /** The facing of the camera is the same as that of the screen. */
213 CAMERA_FACING_FRONT = 1,
214 /**
215 * The facing of the camera is not fixed relative to the screen.
216 * The cameras with this facing are external cameras, e.g. USB cameras.
217 */
218 CAMERA_FACING_EXTERNAL = 2
219};
220
221enum {
222 /** Hardware face detection. It does not use much CPU. */
223 CAMERA_FACE_DETECTION_HW = 0,
224 /**
225 * Software face detection. It uses some CPU. Applications must use
226 * Camera.setPreviewTexture for preview in this mode.
227 */
228 CAMERA_FACE_DETECTION_SW = 1
229};
230
231/**
232 * The information of a face from camera face detection.
233 */
234typedef struct camera_face {
235 /**
236 * Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents
237 * the top-left of the camera field of view, and (1000, 1000) represents the
238 * bottom-right of the field of view. The width and height cannot be 0 or
239 * negative. This is supported by both hardware and software face detection.
240 *
241 * The direction is relative to the sensor orientation, that is, what the
242 * sensor sees. The direction is not affected by the rotation or mirroring
243 * of CAMERA_CMD_SET_DISPLAY_ORIENTATION.
244 */
245 int32_t rect[4];
246
247 /**
248 * The confidence level of the face. The range is 1 to 100. 100 is the
249 * highest confidence. This is supported by both hardware and software
250 * face detection.
251 */
252 int32_t score;
253
254 /**
255 * An unique id per face while the face is visible to the tracker. If
256 * the face leaves the field-of-view and comes back, it will get a new
257 * id. If the value is 0, id is not supported.
258 */
259 int32_t id;
260
261 /**
262 * The coordinates of the center of the left eye. The range is -1000 to
263 * 1000. -2000, -2000 if this is not supported.
264 */
265 int32_t left_eye[2];
266
267 /**
268 * The coordinates of the center of the right eye. The range is -1000 to
269 * 1000. -2000, -2000 if this is not supported.
270 */
271 int32_t right_eye[2];
272
273 /**
274 * The coordinates of the center of the mouth. The range is -1000 to 1000.
275 * -2000, -2000 if this is not supported.
276 */
277 int32_t mouth[2];
278
279} camera_face_t;
280
281/**
282 * The metadata of the frame data.
283 */
284typedef struct camera_frame_metadata {
285 /**
286 * The number of detected faces in the frame.
287 */
288 int32_t number_of_faces;
289
290 /**
291 * An array of the detected faces. The length is number_of_faces.
292 */
293 camera_face_t *faces;
294} camera_frame_metadata_t;
295
296__END_DECLS
297
298#endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */
diff --git a/include/system/graphics.h b/include/system/graphics.h
deleted file mode 100644
index ae10fa095..000000000
--- a/include/system/graphics.h
+++ /dev/null
@@ -1,1420 +0,0 @@
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
18#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
19
20#include <stddef.h>
21#include <stdint.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/*
28 * If the HAL needs to create service threads to handle graphics related
29 * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority
30 * if they can block the main rendering thread in any way.
31 *
32 * the priority of the current thread can be set with:
33 *
34 * #include <sys/resource.h>
35 * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
36 *
37 */
38
39#define HAL_PRIORITY_URGENT_DISPLAY (-8)
40
41/**
42 * pixel format definitions
43 */
44
45typedef enum android_pixel_format {
46 /*
47 * "linear" color pixel formats:
48 *
49 * When used with ANativeWindow, the dataSpace field describes the color
50 * space of the buffer.
51 *
52 * The color space determines, for example, if the formats are linear or
53 * gamma-corrected; or whether any special operations are performed when
54 * reading or writing into a buffer in one of these formats.
55 */
56 HAL_PIXEL_FORMAT_RGBA_8888 = 1,
57 HAL_PIXEL_FORMAT_RGBX_8888 = 2,
58 HAL_PIXEL_FORMAT_RGB_888 = 3,
59 HAL_PIXEL_FORMAT_RGB_565 = 4,
60 HAL_PIXEL_FORMAT_BGRA_8888 = 5,
61
62 /*
63 * 0x100 - 0x1FF
64 *
65 * This range is reserved for pixel formats that are specific to the HAL
66 * implementation. Implementations can use any value in this range to
67 * communicate video pixel formats between their HAL modules. These formats
68 * must not have an alpha channel. Additionally, an EGLimage created from a
69 * gralloc buffer of one of these formats must be supported for use with the
70 * GL_OES_EGL_image_external OpenGL ES extension.
71 */
72
73 /*
74 * Android YUV format:
75 *
76 * This format is exposed outside of the HAL to software decoders and
77 * applications. EGLImageKHR must support it in conjunction with the
78 * OES_EGL_image_external extension.
79 *
80 * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed
81 * by (W/2) x (H/2) Cr and Cb planes.
82 *
83 * This format assumes
84 * - an even width
85 * - an even height
86 * - a horizontal stride multiple of 16 pixels
87 * - a vertical stride equal to the height
88 *
89 * y_size = stride * height
90 * c_stride = ALIGN(stride/2, 16)
91 * c_size = c_stride * height/2
92 * size = y_size + c_size * 2
93 * cr_offset = y_size
94 * cb_offset = y_size + c_size
95 *
96 * When used with ANativeWindow, the dataSpace field describes the color
97 * space of the buffer.
98 */
99 HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar
100
101
102 /*
103 * Android Y8 format:
104 *
105 * This format is exposed outside of the HAL to the framework.
106 * The expected gralloc usage flags are SW_* and HW_CAMERA_*,
107 * and no other HW_ flags will be used.
108 *
109 * Y8 is a YUV planar format comprised of a WxH Y plane,
110 * with each pixel being represented by 8 bits.
111 *
112 * It is equivalent to just the Y plane from YV12.
113 *
114 * This format assumes
115 * - an even width
116 * - an even height
117 * - a horizontal stride multiple of 16 pixels
118 * - a vertical stride equal to the height
119 *
120 * size = stride * height
121 *
122 * When used with ANativeWindow, the dataSpace field describes the color
123 * space of the buffer.
124 */
125 HAL_PIXEL_FORMAT_Y8 = 0x20203859,
126
127 /*
128 * Android Y16 format:
129 *
130 * This format is exposed outside of the HAL to the framework.
131 * The expected gralloc usage flags are SW_* and HW_CAMERA_*,
132 * and no other HW_ flags will be used.
133 *
134 * Y16 is a YUV planar format comprised of a WxH Y plane,
135 * with each pixel being represented by 16 bits.
136 *
137 * It is just like Y8, but has double the bits per pixel (little endian).
138 *
139 * This format assumes
140 * - an even width
141 * - an even height
142 * - a horizontal stride multiple of 16 pixels
143 * - a vertical stride equal to the height
144 * - strides are specified in pixels, not in bytes
145 *
146 * size = stride * height * 2
147 *
148 * When used with ANativeWindow, the dataSpace field describes the color
149 * space of the buffer, except that dataSpace field
150 * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth
151 * image where each sample is a distance value measured by a depth camera,
152 * plus an associated confidence value.
153 */
154 HAL_PIXEL_FORMAT_Y16 = 0x20363159,
155
156 /*
157 * Android RAW sensor format:
158 *
159 * This format is exposed outside of the camera HAL to applications.
160 *
161 * RAW16 is a single-channel, 16-bit, little endian format, typically
162 * representing raw Bayer-pattern images from an image sensor, with minimal
163 * processing.
164 *
165 * The exact pixel layout of the data in the buffer is sensor-dependent, and
166 * needs to be queried from the camera device.
167 *
168 * Generally, not all 16 bits are used; more common values are 10 or 12
169 * bits. If not all bits are used, the lower-order bits are filled first.
170 * All parameters to interpret the raw data (black and white points,
171 * color space, etc) must be queried from the camera device.
172 *
173 * This format assumes
174 * - an even width
175 * - an even height
176 * - a horizontal stride multiple of 16 pixels
177 * - a vertical stride equal to the height
178 * - strides are specified in pixels, not in bytes
179 *
180 * size = stride * height * 2
181 *
182 * This format must be accepted by the gralloc module when used with the
183 * following usage flags:
184 * - GRALLOC_USAGE_HW_CAMERA_*
185 * - GRALLOC_USAGE_SW_*
186 * - GRALLOC_USAGE_RENDERSCRIPT
187 *
188 * When used with ANativeWindow, the dataSpace should be
189 * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
190 * extra metadata to define.
191 */
192 HAL_PIXEL_FORMAT_RAW16 = 0x20,
193
194 /*
195 * Android RAW10 format:
196 *
197 * This format is exposed outside of the camera HAL to applications.
198 *
199 * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row,
200 * unprocessed format, usually representing raw Bayer-pattern images coming from
201 * an image sensor.
202 *
203 * In an image buffer with this format, starting from the first pixel of each
204 * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one
205 * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte
206 * contains the 2 least significant bits of the 4 pixels, the exact layout data
207 * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth
208 * bit of the ith pixel):
209 *
210 * bit 7 bit 0
211 * =====|=====|=====|=====|=====|=====|=====|=====|
212 * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]|
213 * |-----|-----|-----|-----|-----|-----|-----|-----|
214 * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]|
215 * |-----|-----|-----|-----|-----|-----|-----|-----|
216 * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]|
217 * |-----|-----|-----|-----|-----|-----|-----|-----|
218 * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]|
219 * |-----|-----|-----|-----|-----|-----|-----|-----|
220 * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]|
221 * ===============================================
222 *
223 * This format assumes
224 * - a width multiple of 4 pixels
225 * - an even height
226 * - a vertical stride equal to the height
227 * - strides are specified in bytes, not in pixels
228 *
229 * size = stride * height
230 *
231 * When stride is equal to width * (10 / 8), there will be no padding bytes at
232 * the end of each row, the entire image data is densely packed. When stride is
233 * larger than width * (10 / 8), padding bytes will be present at the end of each
234 * row (including the last row).
235 *
236 * This format must be accepted by the gralloc module when used with the
237 * following usage flags:
238 * - GRALLOC_USAGE_HW_CAMERA_*
239 * - GRALLOC_USAGE_SW_*
240 * - GRALLOC_USAGE_RENDERSCRIPT
241 *
242 * When used with ANativeWindow, the dataSpace field should be
243 * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
244 * extra metadata to define.
245 */
246 HAL_PIXEL_FORMAT_RAW10 = 0x25,
247
248 /*
249 * Android RAW12 format:
250 *
251 * This format is exposed outside of camera HAL to applications.
252 *
253 * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row,
254 * unprocessed format, usually representing raw Bayer-pattern images coming from
255 * an image sensor.
256 *
257 * In an image buffer with this format, starting from the first pixel of each
258 * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first
259 * and second byte contains the top 8 bits of first and second pixel. The third
260 * byte contains the 4 least significant bits of the two pixels, the exact layout
261 * data for each two consecutive pixels is illustrated below (Pi[j] stands for
262 * the jth bit of the ith pixel):
263 *
264 * bit 7 bit 0
265 * ======|======|======|======|======|======|======|======|
266 * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]|
267 * |------|------|------|------|------|------|------|------|
268 * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]|
269 * |------|------|------|------|------|------|------|------|
270 * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]|
271 * =======================================================
272 *
273 * This format assumes:
274 * - a width multiple of 4 pixels
275 * - an even height
276 * - a vertical stride equal to the height
277 * - strides are specified in bytes, not in pixels
278 *
279 * size = stride * height
280 *
281 * When stride is equal to width * (12 / 8), there will be no padding bytes at
282 * the end of each row, the entire image data is densely packed. When stride is
283 * larger than width * (12 / 8), padding bytes will be present at the end of
284 * each row (including the last row).
285 *
286 * This format must be accepted by the gralloc module when used with the
287 * following usage flags:
288 * - GRALLOC_USAGE_HW_CAMERA_*
289 * - GRALLOC_USAGE_SW_*
290 * - GRALLOC_USAGE_RENDERSCRIPT
291 *
292 * When used with ANativeWindow, the dataSpace field should be
293 * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
294 * extra metadata to define.
295 */
296 HAL_PIXEL_FORMAT_RAW12 = 0x26,
297
298 /*
299 * Android opaque RAW format:
300 *
301 * This format is exposed outside of the camera HAL to applications.
302 *
303 * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an
304 * image sensor. The actual structure of buffers of this format is
305 * implementation-dependent.
306 *
307 * This format must be accepted by the gralloc module when used with the
308 * following usage flags:
309 * - GRALLOC_USAGE_HW_CAMERA_*
310 * - GRALLOC_USAGE_SW_*
311 * - GRALLOC_USAGE_RENDERSCRIPT
312 *
313 * When used with ANativeWindow, the dataSpace field should be
314 * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
315 * extra metadata to define.
316 */
317 HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24,
318
319 /*
320 * Android binary blob graphics buffer format:
321 *
322 * This format is used to carry task-specific data which does not have a
323 * standard image structure. The details of the format are left to the two
324 * endpoints.
325 *
326 * A typical use case is for transporting JPEG-compressed images from the
327 * Camera HAL to the framework or to applications.
328 *
329 * Buffers of this format must have a height of 1, and width equal to their
330 * size in bytes.
331 *
332 * When used with ANativeWindow, the mapping of the dataSpace field to
333 * buffer contents for BLOB is as follows:
334 *
335 * dataSpace value | Buffer contents
336 * -------------------------------+-----------------------------------------
337 * HAL_DATASPACE_JFIF | An encoded JPEG image
338 * HAL_DATASPACE_DEPTH | An android_depth_points buffer
339 * Other | Unsupported
340 *
341 */
342 HAL_PIXEL_FORMAT_BLOB = 0x21,
343
344 /*
345 * Android format indicating that the choice of format is entirely up to the
346 * device-specific Gralloc implementation.
347 *
348 * The Gralloc implementation should examine the usage bits passed in when
349 * allocating a buffer with this format, and it should derive the pixel
350 * format from those usage flags. This format will never be used with any
351 * of the GRALLOC_USAGE_SW_* usage flags.
352 *
353 * If a buffer of this format is to be used as an OpenGL ES texture, the
354 * framework will assume that sampling the texture will always return an
355 * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values).
356 *
357 * When used with ANativeWindow, the dataSpace field describes the color
358 * space of the buffer.
359 */
360 HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22,
361
362 /*
363 * Android flexible YCbCr 4:2:0 formats
364 *
365 * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0
366 * buffer layout, while still describing the general format in a
367 * layout-independent manner. While called YCbCr, it can be
368 * used to describe formats with either chromatic ordering, as well as
369 * whole planar or semiplanar layouts.
370 *
371 * struct android_ycbcr (below) is the the struct used to describe it.
372 *
373 * This format must be accepted by the gralloc module when
374 * USAGE_SW_WRITE_* or USAGE_SW_READ_* are set.
375 *
376 * This format is locked for use by gralloc's (*lock_ycbcr) method, and
377 * locking with the (*lock) method will return an error.
378 *
379 * When used with ANativeWindow, the dataSpace field describes the color
380 * space of the buffer.
381 */
382 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23,
383
384 /*
385 * Android flexible YCbCr 4:2:2 formats
386 *
387 * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2
388 * buffer layout, while still describing the general format in a
389 * layout-independent manner. While called YCbCr, it can be
390 * used to describe formats with either chromatic ordering, as well as
391 * whole planar or semiplanar layouts.
392 *
393 * This format is currently only used by SW readable buffers
394 * produced by MediaCodecs, so the gralloc module can ignore this format.
395 */
396 HAL_PIXEL_FORMAT_YCbCr_422_888 = 0x27,
397
398 /*
399 * Android flexible YCbCr 4:4:4 formats
400 *
401 * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4
402 * buffer layout, while still describing the general format in a
403 * layout-independent manner. While called YCbCr, it can be
404 * used to describe formats with either chromatic ordering, as well as
405 * whole planar or semiplanar layouts.
406 *
407 * This format is currently only used by SW readable buffers
408 * produced by MediaCodecs, so the gralloc module can ignore this format.
409 */
410 HAL_PIXEL_FORMAT_YCbCr_444_888 = 0x28,
411
412 /*
413 * Android flexible RGB 888 formats
414 *
415 * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX
416 * buffer layout, while still describing the general format in a
417 * layout-independent manner. While called RGB, it can be
418 * used to describe formats with either color ordering and optional
419 * padding, as well as whole planar layout.
420 *
421 * This format is currently only used by SW readable buffers
422 * produced by MediaCodecs, so the gralloc module can ignore this format.
423 */
424 HAL_PIXEL_FORMAT_FLEX_RGB_888 = 0x29,
425
426 /*
427 * Android flexible RGBA 8888 formats
428 *
429 * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR
430 * buffer layout, while still describing the general format in a
431 * layout-independent manner. While called RGBA, it can be
432 * used to describe formats with any of the component orderings, as
433 * well as whole planar layout.
434 *
435 * This format is currently only used by SW readable buffers
436 * produced by MediaCodecs, so the gralloc module can ignore this format.
437 */
438 HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 0x2A,
439
440 /* Legacy formats (deprecated), used by ImageFormat.java */
441 HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16
442 HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21
443 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2
444} android_pixel_format_t;
445
446/*
447 * Structure for describing YCbCr formats for consumption by applications.
448 * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888.
449 *
450 * Buffer chroma subsampling is defined in the format.
451 * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0.
452 *
453 * Buffers must have a 8 bit depth.
454 *
455 * y, cb, and cr point to the first byte of their respective planes.
456 *
457 * Stride describes the distance in bytes from the first value of one row of
458 * the image to the first value of the next row. It includes the width of the
459 * image plus padding.
460 * ystride is the stride of the luma plane.
461 * cstride is the stride of the chroma planes.
462 *
463 * chroma_step is the distance in bytes from one chroma pixel value to the
464 * next. This is 2 bytes for semiplanar (because chroma values are interleaved
465 * and each chroma value is one byte) and 1 for planar.
466 */
467
468struct android_ycbcr {
469 void *y;
470 void *cb;
471 void *cr;
472 size_t ystride;
473 size_t cstride;
474 size_t chroma_step;
475
476 /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */
477 uint32_t reserved[8];
478};
479
480/*
481 * Structures for describing flexible YUVA/RGBA formats for consumption by
482 * applications. Such flexible formats contain a plane for each component (e.g.
483 * red, green, blue), where each plane is laid out in a grid-like pattern
484 * occupying unique byte addresses and with consistent byte offsets between
485 * neighboring pixels.
486 *
487 * The android_flex_layout structure is used with any pixel format that can be
488 * represented by it, such as:
489 * - HAL_PIXEL_FORMAT_YCbCr_*_888
490 * - HAL_PIXEL_FORMAT_FLEX_RGB*_888
491 * - HAL_PIXEL_FORMAT_RGB[AX]_888[8],BGRA_8888,RGB_888
492 * - HAL_PIXEL_FORMAT_YV12,Y8,Y16,YCbCr_422_SP/I,YCrCb_420_SP
493 * - even implementation defined formats that can be represented by
494 * the structures
495 *
496 * Vertical increment (aka. row increment or stride) describes the distance in
497 * bytes from the first pixel of one row to the first pixel of the next row
498 * (below) for the component plane. This can be negative.
499 *
500 * Horizontal increment (aka. column or pixel increment) describes the distance
501 * in bytes from one pixel to the next pixel (to the right) on the same row for
502 * the component plane. This can be negative.
503 *
504 * Each plane can be subsampled either vertically or horizontally by
505 * a power-of-two factor.
506 *
507 * The bit-depth of each component can be arbitrary, as long as the pixels are
508 * laid out on whole bytes, in native byte-order, using the most significant
509 * bits of each unit.
510 */
511
512typedef enum android_flex_component {
513 /* luma */
514 FLEX_COMPONENT_Y = 1 << 0,
515 /* chroma blue */
516 FLEX_COMPONENT_Cb = 1 << 1,
517 /* chroma red */
518 FLEX_COMPONENT_Cr = 1 << 2,
519
520 /* red */
521 FLEX_COMPONENT_R = 1 << 10,
522 /* green */
523 FLEX_COMPONENT_G = 1 << 11,
524 /* blue */
525 FLEX_COMPONENT_B = 1 << 12,
526
527 /* alpha */
528 FLEX_COMPONENT_A = 1 << 30,
529} android_flex_component_t;
530
531typedef struct android_flex_plane {
532 /* pointer to the first byte of the top-left pixel of the plane. */
533 uint8_t *top_left;
534
535 android_flex_component_t component;
536
537 /* bits allocated for the component in each pixel. Must be a positive
538 multiple of 8. */
539 int32_t bits_per_component;
540 /* number of the most significant bits used in the format for this
541 component. Must be between 1 and bits_per_component, inclusive. */
542 int32_t bits_used;
543
544 /* horizontal increment */
545 int32_t h_increment;
546 /* vertical increment */
547 int32_t v_increment;
548 /* horizontal subsampling. Must be a positive power of 2. */
549 int32_t h_subsampling;
550 /* vertical subsampling. Must be a positive power of 2. */
551 int32_t v_subsampling;
552} android_flex_plane_t;
553
554typedef enum android_flex_format {
555 /* not a flexible format */
556 FLEX_FORMAT_INVALID = 0x0,
557 FLEX_FORMAT_Y = FLEX_COMPONENT_Y,
558 FLEX_FORMAT_YCbCr = FLEX_COMPONENT_Y | FLEX_COMPONENT_Cb | FLEX_COMPONENT_Cr,
559 FLEX_FORMAT_YCbCrA = FLEX_FORMAT_YCbCr | FLEX_COMPONENT_A,
560 FLEX_FORMAT_RGB = FLEX_COMPONENT_R | FLEX_COMPONENT_G | FLEX_COMPONENT_B,
561 FLEX_FORMAT_RGBA = FLEX_FORMAT_RGB | FLEX_COMPONENT_A,
562} android_flex_format_t;
563
564typedef struct android_flex_layout {
565 /* the kind of flexible format */
566 android_flex_format_t format;
567
568 /* number of planes; 0 for FLEX_FORMAT_INVALID */
569 uint32_t num_planes;
570 /* a plane for each component; ordered in increasing component value order.
571 E.g. FLEX_FORMAT_RGBA maps 0 -> R, 1 -> G, etc.
572 Can be NULL for FLEX_FORMAT_INVALID */
573 android_flex_plane_t *planes;
574} android_flex_layout_t;
575
576/**
577 * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB
578 * with dataSpace value of HAL_DATASPACE_DEPTH.
579 * When locking a native buffer of the above format and dataSpace value,
580 * the vaddr pointer can be cast to this structure.
581 *
582 * A variable-length list of (x,y,z, confidence) 3D points, as floats. (x, y,
583 * z) represents a measured point's position, with the coordinate system defined
584 * by the data source. Confidence represents the estimated likelihood that this
585 * measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f ==
586 * 100% confidence.
587 *
588 * num_points is the number of points in the list
589 *
590 * xyz_points is the flexible array of floating-point values.
591 * It contains (num_points) * 4 floats.
592 *
593 * For example:
594 * android_depth_points d = get_depth_buffer();
595 * struct {
596 * float x; float y; float z; float confidence;
597 * } firstPoint, lastPoint;
598 *
599 * firstPoint.x = d.xyzc_points[0];
600 * firstPoint.y = d.xyzc_points[1];
601 * firstPoint.z = d.xyzc_points[2];
602 * firstPoint.confidence = d.xyzc_points[3];
603 * lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0];
604 * lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1];
605 * lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2];
606 * lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3];
607 */
608
609struct android_depth_points {
610 uint32_t num_points;
611
612 /** reserved for future use, set to 0 by gralloc's (*lock)() */
613 uint32_t reserved[8];
614
615#if defined(__clang__)
616#pragma clang diagnostic push
617#pragma clang diagnostic ignored "-Wc99-extensions"
618#endif
619 float xyzc_points[];
620#if defined(__clang__)
621#pragma clang diagnostic pop
622#endif
623};
624
625/**
626 * Transformation definitions
627 *
628 * IMPORTANT NOTE:
629 * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}.
630 *
631 */
632
633typedef enum android_transform {
634 /* flip source image horizontally (around the vertical axis) */
635 HAL_TRANSFORM_FLIP_H = 0x01,
636 /* flip source image vertically (around the horizontal axis)*/
637 HAL_TRANSFORM_FLIP_V = 0x02,
638 /* rotate source image 90 degrees clockwise */
639 HAL_TRANSFORM_ROT_90 = 0x04,
640 /* rotate source image 180 degrees */
641 HAL_TRANSFORM_ROT_180 = 0x03,
642 /* rotate source image 270 degrees clockwise */
643 HAL_TRANSFORM_ROT_270 = 0x07,
644 /* don't use. see system/window.h */
645 HAL_TRANSFORM_RESERVED = 0x08,
646} android_transform_t;
647
648/**
649 * Dataspace Definitions
650 * ======================
651 *
652 * Dataspace is the definition of how pixel values should be interpreted.
653 *
654 * For many formats, this is the colorspace of the image data, which includes
655 * primaries (including white point) and the transfer characteristic function,
656 * which describes both gamma curve and numeric range (within the bit depth).
657 *
658 * Other dataspaces include depth measurement data from a depth camera.
659 *
660 * A dataspace is comprised of a number of fields.
661 *
662 * Version
663 * --------
664 * The top 2 bits represent the revision of the field specification. This is
665 * currently always 0.
666 *
667 *
668 * bits 31-30 29 - 0
669 * +-----+----------------------------------------------------+
670 * fields | Rev | Revision specific fields |
671 * +-----+----------------------------------------------------+
672 *
673 * Field layout for version = 0:
674 * ----------------------------
675 *
676 * A dataspace is comprised of the following fields:
677 * Standard
678 * Transfer function
679 * Range
680 *
681 * bits 31-30 29-27 26 - 22 21 - 16 15 - 0
682 * +-----+-----+--------+--------+----------------------------+
683 * fields | 0 |Range|Transfer|Standard| Legacy and custom |
684 * +-----+-----+--------+--------+----------------------------+
685 * VV RRR TTTTT SSSSSS LLLLLLLL LLLLLLLL
686 *
687 * If range, transfer and standard fields are all 0 (e.g. top 16 bits are
688 * all zeroes), the bottom 16 bits contain either a legacy dataspace value,
689 * or a custom value.
690 */
691
692typedef enum android_dataspace {
693 /*
694 * Default-assumption data space, when not explicitly specified.
695 *
696 * It is safest to assume the buffer is an image with sRGB primaries and
697 * encoding ranges, but the consumer and/or the producer of the data may
698 * simply be using defaults. No automatic gamma transform should be
699 * expected, except for a possible display gamma transform when drawn to a
700 * screen.
701 */
702 HAL_DATASPACE_UNKNOWN = 0x0,
703
704 /*
705 * Arbitrary dataspace with manually defined characteristics. Definition
706 * for colorspaces or other meaning must be communicated separately.
707 *
708 * This is used when specifying primaries, transfer characteristics,
709 * etc. separately.
710 *
711 * A typical use case is in video encoding parameters (e.g. for H.264),
712 * where a colorspace can have separately defined primaries, transfer
713 * characteristics, etc.
714 */
715 HAL_DATASPACE_ARBITRARY = 0x1,
716
717 /*
718 * Color-description aspects
719 *
720 * The following aspects define various characteristics of the color
721 * specification. These represent bitfields, so that a data space value
722 * can specify each of them independently.
723 */
724
725 HAL_DATASPACE_STANDARD_SHIFT = 16,
726
727 /*
728 * Standard aspect
729 *
730 * Defines the chromaticity coordinates of the source primaries in terms of
731 * the CIE 1931 definition of x and y specified in ISO 11664-1.
732 */
733 HAL_DATASPACE_STANDARD_MASK = 63 << HAL_DATASPACE_STANDARD_SHIFT, // 0x3F
734
735 /*
736 * Chromacity coordinates are unknown or are determined by the application.
737 * Implementations shall use the following suggested standards:
738 *
739 * All YCbCr formats: BT709 if size is 720p or larger (since most video
740 * content is letterboxed this corresponds to width is
741 * 1280 or greater, or height is 720 or greater).
742 * BT601_625 if size is smaller than 720p or is JPEG.
743 * All RGB formats: BT709.
744 *
745 * For all other formats standard is undefined, and implementations should use
746 * an appropriate standard for the data represented.
747 */
748 HAL_DATASPACE_STANDARD_UNSPECIFIED = 0 << HAL_DATASPACE_STANDARD_SHIFT,
749
750 /*
751 * Primaries: x y
752 * green 0.300 0.600
753 * blue 0.150 0.060
754 * red 0.640 0.330
755 * white (D65) 0.3127 0.3290
756 *
757 * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation
758 * for RGB conversion.
759 */
760 HAL_DATASPACE_STANDARD_BT709 = 1 << HAL_DATASPACE_STANDARD_SHIFT,
761
762 /*
763 * Primaries: x y
764 * green 0.290 0.600
765 * blue 0.150 0.060
766 * red 0.640 0.330
767 * white (D65) 0.3127 0.3290
768 *
769 * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
770 * for RGB conversion from the one purely determined by the primaries
771 * to minimize the color shift into RGB space that uses BT.709
772 * primaries.
773 */
774 HAL_DATASPACE_STANDARD_BT601_625 = 2 << HAL_DATASPACE_STANDARD_SHIFT,
775
776 /*
777 * Primaries: x y
778 * green 0.290 0.600
779 * blue 0.150 0.060
780 * red 0.640 0.330
781 * white (D65) 0.3127 0.3290
782 *
783 * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation
784 * for RGB conversion.
785 */
786 HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED = 3 << HAL_DATASPACE_STANDARD_SHIFT,
787
788 /*
789 * Primaries: x y
790 * green 0.310 0.595
791 * blue 0.155 0.070
792 * red 0.630 0.340
793 * white (D65) 0.3127 0.3290
794 *
795 * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
796 * for RGB conversion from the one purely determined by the primaries
797 * to minimize the color shift into RGB space that uses BT.709
798 * primaries.
799 */
800 HAL_DATASPACE_STANDARD_BT601_525 = 4 << HAL_DATASPACE_STANDARD_SHIFT,
801
802 /*
803 * Primaries: x y
804 * green 0.310 0.595
805 * blue 0.155 0.070
806 * red 0.630 0.340
807 * white (D65) 0.3127 0.3290
808 *
809 * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation
810 * for RGB conversion (as in SMPTE 240M).
811 */
812 HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED = 5 << HAL_DATASPACE_STANDARD_SHIFT,
813
814 /*
815 * Primaries: x y
816 * green 0.170 0.797
817 * blue 0.131 0.046
818 * red 0.708 0.292
819 * white (D65) 0.3127 0.3290
820 *
821 * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation
822 * for RGB conversion.
823 */
824 HAL_DATASPACE_STANDARD_BT2020 = 6 << HAL_DATASPACE_STANDARD_SHIFT,
825
826 /*
827 * Primaries: x y
828 * green 0.170 0.797
829 * blue 0.131 0.046
830 * red 0.708 0.292
831 * white (D65) 0.3127 0.3290
832 *
833 * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation
834 * for RGB conversion using the linear domain.
835 */
836 HAL_DATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE = 7 << HAL_DATASPACE_STANDARD_SHIFT,
837
838 /*
839 * Primaries: x y
840 * green 0.21 0.71
841 * blue 0.14 0.08
842 * red 0.67 0.33
843 * white (C) 0.310 0.316
844 *
845 * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation
846 * for RGB conversion.
847 */
848 HAL_DATASPACE_STANDARD_BT470M = 8 << HAL_DATASPACE_STANDARD_SHIFT,
849
850 /*
851 * Primaries: x y
852 * green 0.243 0.692
853 * blue 0.145 0.049
854 * red 0.681 0.319
855 * white (C) 0.310 0.316
856 *
857 * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation
858 * for RGB conversion.
859 */
860 HAL_DATASPACE_STANDARD_FILM = 9 << HAL_DATASPACE_STANDARD_SHIFT,
861
862 HAL_DATASPACE_TRANSFER_SHIFT = 22,
863
864 /*
865 * Transfer aspect
866 *
867 * Transfer characteristics are the opto-electronic transfer characteristic
868 * at the source as a function of linear optical intensity (luminance).
869 *
870 * For digital signals, E corresponds to the recorded value. Normally, the
871 * transfer function is applied in RGB space to each of the R, G and B
872 * components independently. This may result in color shift that can be
873 * minized by applying the transfer function in Lab space only for the L
874 * component. Implementation may apply the transfer function in RGB space
875 * for all pixel formats if desired.
876 */
877
878 HAL_DATASPACE_TRANSFER_MASK = 31 << HAL_DATASPACE_TRANSFER_SHIFT, // 0x1F
879
880 /*
881 * Transfer characteristics are unknown or are determined by the
882 * application.
883 *
884 * Implementations should use the following transfer functions:
885 *
886 * For YCbCr formats: use HAL_DATASPACE_TRANSFER_SMPTE_170M
887 * For RGB formats: use HAL_DATASPACE_TRANSFER_SRGB
888 *
889 * For all other formats transfer function is undefined, and implementations
890 * should use an appropriate standard for the data represented.
891 */
892 HAL_DATASPACE_TRANSFER_UNSPECIFIED = 0 << HAL_DATASPACE_TRANSFER_SHIFT,
893
894 /*
895 * Transfer characteristic curve:
896 * E = L
897 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
898 * E - corresponding electrical signal
899 */
900 HAL_DATASPACE_TRANSFER_LINEAR = 1 << HAL_DATASPACE_TRANSFER_SHIFT,
901
902 /*
903 * Transfer characteristic curve:
904 *
905 * E = 1.055 * L^(1/2.4) - 0.055 for 0.0031308 <= L <= 1
906 * = 12.92 * L for 0 <= L < 0.0031308
907 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
908 * E - corresponding electrical signal
909 */
910 HAL_DATASPACE_TRANSFER_SRGB = 2 << HAL_DATASPACE_TRANSFER_SHIFT,
911
912 /*
913 * BT.601 525, BT.601 625, BT.709, BT.2020
914 *
915 * Transfer characteristic curve:
916 * E = 1.099 * L ^ 0.45 - 0.099 for 0.018 <= L <= 1
917 * = 4.500 * L for 0 <= L < 0.018
918 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
919 * E - corresponding electrical signal
920 */
921 HAL_DATASPACE_TRANSFER_SMPTE_170M = 3 << HAL_DATASPACE_TRANSFER_SHIFT,
922
923 /*
924 * Assumed display gamma 2.2.
925 *
926 * Transfer characteristic curve:
927 * E = L ^ (1/2.2)
928 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
929 * E - corresponding electrical signal
930 */
931 HAL_DATASPACE_TRANSFER_GAMMA2_2 = 4 << HAL_DATASPACE_TRANSFER_SHIFT,
932
933 /*
934 * display gamma 2.8.
935 *
936 * Transfer characteristic curve:
937 * E = L ^ (1/2.8)
938 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
939 * E - corresponding electrical signal
940 */
941 HAL_DATASPACE_TRANSFER_GAMMA2_8 = 5 << HAL_DATASPACE_TRANSFER_SHIFT,
942
943 /*
944 * SMPTE ST 2084
945 *
946 * Transfer characteristic curve:
947 * E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m
948 * c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375
949 * c2 = 32 * 2413 / 4096 = 18.8515625
950 * c3 = 32 * 2392 / 4096 = 18.6875
951 * m = 128 * 2523 / 4096 = 78.84375
952 * n = 0.25 * 2610 / 4096 = 0.1593017578125
953 * L - luminance of image 0 <= L <= 1 for HDR colorimetry.
954 * L = 1 corresponds to 10000 cd/m2
955 * E - corresponding electrical signal
956 */
957 HAL_DATASPACE_TRANSFER_ST2084 = 6 << HAL_DATASPACE_TRANSFER_SHIFT,
958
959 /*
960 * ARIB STD-B67 Hybrid Log Gamma
961 *
962 * Transfer characteristic curve:
963 * E = r * L^0.5 for 0 <= L <= 1
964 * = a * ln(L - b) + c for 1 < L
965 * a = 0.17883277
966 * b = 0.28466892
967 * c = 0.55991073
968 * r = 0.5
969 * L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds
970 * to reference white level of 100 cd/m2
971 * E - corresponding electrical signal
972 */
973 HAL_DATASPACE_TRANSFER_HLG = 7 << HAL_DATASPACE_TRANSFER_SHIFT,
974
975 HAL_DATASPACE_RANGE_SHIFT = 27,
976
977 /*
978 * Range aspect
979 *
980 * Defines the range of values corresponding to the unit range of 0-1.
981 * This is defined for YCbCr only, but can be expanded to RGB space.
982 */
983 HAL_DATASPACE_RANGE_MASK = 7 << HAL_DATASPACE_RANGE_SHIFT, // 0x7
984
985 /*
986 * Range is unknown or are determined by the application. Implementations
987 * shall use the following suggested ranges:
988 *
989 * All YCbCr formats: limited range.
990 * All RGB or RGBA formats (including RAW and Bayer): full range.
991 * All Y formats: full range
992 *
993 * For all other formats range is undefined, and implementations should use
994 * an appropriate range for the data represented.
995 */
996 HAL_DATASPACE_RANGE_UNSPECIFIED = 0 << HAL_DATASPACE_RANGE_SHIFT,
997
998 /*
999 * Full range uses all values for Y, Cb and Cr from
1000 * 0 to 2^b-1, where b is the bit depth of the color format.
1001 */
1002 HAL_DATASPACE_RANGE_FULL = 1 << HAL_DATASPACE_RANGE_SHIFT,
1003
1004 /*
1005 * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and
1006 * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of
1007 * the color format.
1008 *
1009 * E.g. For 8-bit-depth formats:
1010 * Luma (Y) samples should range from 16 to 235, inclusive
1011 * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
1012 *
1013 * For 10-bit-depth formats:
1014 * Luma (Y) samples should range from 64 to 940, inclusive
1015 * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
1016 */
1017 HAL_DATASPACE_RANGE_LIMITED = 2 << HAL_DATASPACE_RANGE_SHIFT,
1018
1019 /*
1020 * Legacy dataspaces
1021 */
1022
1023 /*
1024 * sRGB linear encoding:
1025 *
1026 * The red, green, and blue components are stored in sRGB space, but
1027 * are linear, not gamma-encoded.
1028 * The RGB primaries and the white point are the same as BT.709.
1029 *
1030 * The values are encoded using the full range ([0,255] for 8-bit) for all
1031 * components.
1032 */
1033 HAL_DATASPACE_SRGB_LINEAR = 0x200, // deprecated, use HAL_DATASPACE_V0_SRGB_LINEAR
1034
1035 HAL_DATASPACE_V0_SRGB_LINEAR = HAL_DATASPACE_STANDARD_BT709 |
1036 HAL_DATASPACE_TRANSFER_LINEAR | HAL_DATASPACE_RANGE_FULL,
1037
1038
1039 /*
1040 * sRGB gamma encoding:
1041 *
1042 * The red, green and blue components are stored in sRGB space, and
1043 * converted to linear space when read, using the SRGB transfer function
1044 * for each of the R, G and B components. When written, the inverse
1045 * transformation is performed.
1046 *
1047 * The alpha component, if present, is always stored in linear space and
1048 * is left unmodified when read or written.
1049 *
1050 * Use full range and BT.709 standard.
1051 */
1052 HAL_DATASPACE_SRGB = 0x201, // deprecated, use HAL_DATASPACE_V0_SRGB
1053
1054 HAL_DATASPACE_V0_SRGB = HAL_DATASPACE_STANDARD_BT709 |
1055 HAL_DATASPACE_TRANSFER_SRGB | HAL_DATASPACE_RANGE_FULL,
1056
1057
1058 /*
1059 * YCbCr Colorspaces
1060 * -----------------
1061 *
1062 * Primaries are given using (x,y) coordinates in the CIE 1931 definition
1063 * of x and y specified by ISO 11664-1.
1064 *
1065 * Transfer characteristics are the opto-electronic transfer characteristic
1066 * at the source as a function of linear optical intensity (luminance).
1067 */
1068
1069 /*
1070 * JPEG File Interchange Format (JFIF)
1071 *
1072 * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255
1073 *
1074 * Use full range, BT.601 transfer and BT.601_625 standard.
1075 */
1076 HAL_DATASPACE_JFIF = 0x101, // deprecated, use HAL_DATASPACE_V0_JFIF
1077
1078 HAL_DATASPACE_V0_JFIF = HAL_DATASPACE_STANDARD_BT601_625 |
1079 HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_FULL,
1080
1081 /*
1082 * ITU-R Recommendation 601 (BT.601) - 625-line
1083 *
1084 * Standard-definition television, 625 Lines (PAL)
1085 *
1086 * Use limited range, BT.601 transfer and BT.601_625 standard.
1087 */
1088 HAL_DATASPACE_BT601_625 = 0x102, // deprecated, use HAL_DATASPACE_V0_BT601_625
1089
1090 HAL_DATASPACE_V0_BT601_625 = HAL_DATASPACE_STANDARD_BT601_625 |
1091 HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_LIMITED,
1092
1093
1094 /*
1095 * ITU-R Recommendation 601 (BT.601) - 525-line
1096 *
1097 * Standard-definition television, 525 Lines (NTSC)
1098 *
1099 * Use limited range, BT.601 transfer and BT.601_525 standard.
1100 */
1101 HAL_DATASPACE_BT601_525 = 0x103, // deprecated, use HAL_DATASPACE_V0_BT601_525
1102
1103 HAL_DATASPACE_V0_BT601_525 = HAL_DATASPACE_STANDARD_BT601_525 |
1104 HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_LIMITED,
1105
1106 /*
1107 * ITU-R Recommendation 709 (BT.709)
1108 *
1109 * High-definition television
1110 *
1111 * Use limited range, BT.709 transfer and BT.709 standard.
1112 */
1113 HAL_DATASPACE_BT709 = 0x104, // deprecated, use HAL_DATASPACE_V0_BT709
1114
1115 HAL_DATASPACE_V0_BT709 = HAL_DATASPACE_STANDARD_BT709 |
1116 HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_LIMITED,
1117
1118 /*
1119 * Data spaces for non-color formats
1120 */
1121
1122 /*
1123 * The buffer contains depth ranging measurements from a depth camera.
1124 * This value is valid with formats:
1125 * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement
1126 * and an associated confidence value. The 3 MSBs of the sample make
1127 * up the confidence value, and the low 13 LSBs of the sample make up
1128 * the depth measurement.
1129 * For the confidence section, 0 means 100% confidence, 1 means 0%
1130 * confidence. The mapping to a linear float confidence value between
1131 * 0.f and 1.f can be obtained with
1132 * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f;
1133 * The depth measurement can be extracted simply with
1134 * uint16_t range = (depthSample & 0x1FFF);
1135 * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as
1136 * a variable-length float (x,y,z, confidence) coordinate point list.
1137 * The point cloud will be represented with the android_depth_points
1138 * structure.
1139 */
1140 HAL_DATASPACE_DEPTH = 0x1000
1141
1142} android_dataspace_t;
1143
1144/*
1145 * Color modes that may be supported by a display.
1146 *
1147 * Definitions:
1148 * Rendering intent generally defines the goal in mapping a source (input)
1149 * color to a destination device color for a given color mode.
1150 *
1151 * It is important to keep in mind three cases where mapping may be applied:
1152 * 1. The source gamut is much smaller than the destination (display) gamut
1153 * 2. The source gamut is much larger than the destination gamut (this will
1154 * ordinarily be handled using colorimetric rendering, below)
1155 * 3. The source and destination gamuts are roughly equal, although not
1156 * completely overlapping
1157 * Also, a common requirement for mappings is that skin tones should be
1158 * preserved, or at least remain natural in appearance.
1159 *
1160 * Colorimetric Rendering Intent (All cases):
1161 * Colorimetric indicates that colors should be preserved. In the case
1162 * that the source gamut lies wholly within the destination gamut or is
1163 * about the same (#1, #3), this will simply mean that no manipulations
1164 * (no saturation boost, for example) are applied. In the case where some
1165 * source colors lie outside the destination gamut (#2, #3), those will
1166 * need to be mapped to colors that are within the destination gamut,
1167 * while the already in-gamut colors remain unchanged.
1168 *
1169 * Non-colorimetric transforms can take many forms. There are no hard
1170 * rules and it's left to the implementation to define.
1171 * Two common intents are described below.
1172 *
1173 * Stretched-Gamut Enhancement Intent (Source < Destination):
1174 * When the destination gamut is much larger than the source gamut (#1), the
1175 * source primaries may be redefined to reflect the full extent of the
1176 * destination space, or to reflect an intermediate gamut.
1177 * Skin-tone preservation would likely be applied. An example might be sRGB
1178 * input displayed on a DCI-P3 capable device, with skin-tone preservation.
1179 *
1180 * Within-Gamut Enhancement Intent (Source >= Destination):
1181 * When the device (destination) gamut is not larger than the source gamut
1182 * (#2 or #3), but the appearance of a larger gamut is desired, techniques
1183 * such as saturation boost may be applied to the source colors. Skin-tone
1184 * preservation may be applied. There is no unique method for within-gamut
1185 * enhancement; it would be defined within a flexible color mode.
1186 *
1187 */
1188typedef enum android_color_mode {
1189
1190 /*
1191 * HAL_COLOR_MODE_DEFAULT is the "native" gamut of the display.
1192 * White Point: Vendor/OEM defined
1193 * Panel Gamma: Vendor/OEM defined (typically 2.2)
1194 * Rendering Intent: Vendor/OEM defined (typically 'enhanced')
1195 */
1196 HAL_COLOR_MODE_NATIVE = 0,
1197
1198 /*
1199 * HAL_COLOR_MODE_STANDARD_BT601_625 corresponds with display
1200 * settings that implement the ITU-R Recommendation BT.601
1201 * or Rec 601. Using 625 line version
1202 * Rendering Intent: Colorimetric
1203 * Primaries:
1204 * x y
1205 * green 0.290 0.600
1206 * blue 0.150 0.060
1207 * red 0.640 0.330
1208 * white (D65) 0.3127 0.3290
1209 *
1210 * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
1211 * for RGB conversion from the one purely determined by the primaries
1212 * to minimize the color shift into RGB space that uses BT.709
1213 * primaries.
1214 *
1215 * Gamma Correction (GC):
1216 *
1217 * if Vlinear < 0.018
1218 * Vnonlinear = 4.500 * Vlinear
1219 * else
1220 * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099
1221 */
1222 HAL_COLOR_MODE_STANDARD_BT601_625 = 1,
1223
1224 /*
1225 * Primaries:
1226 * x y
1227 * green 0.290 0.600
1228 * blue 0.150 0.060
1229 * red 0.640 0.330
1230 * white (D65) 0.3127 0.3290
1231 *
1232 * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation
1233 * for RGB conversion.
1234 *
1235 * Gamma Correction (GC):
1236 *
1237 * if Vlinear < 0.018
1238 * Vnonlinear = 4.500 * Vlinear
1239 * else
1240 * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099
1241 */
1242 HAL_COLOR_MODE_STANDARD_BT601_625_UNADJUSTED = 2,
1243
1244 /*
1245 * Primaries:
1246 * x y
1247 * green 0.310 0.595
1248 * blue 0.155 0.070
1249 * red 0.630 0.340
1250 * white (D65) 0.3127 0.3290
1251 *
1252 * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
1253 * for RGB conversion from the one purely determined by the primaries
1254 * to minimize the color shift into RGB space that uses BT.709
1255 * primaries.
1256 *
1257 * Gamma Correction (GC):
1258 *
1259 * if Vlinear < 0.018
1260 * Vnonlinear = 4.500 * Vlinear
1261 * else
1262 * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099
1263 */
1264 HAL_COLOR_MODE_STANDARD_BT601_525 = 3,
1265
1266 /*
1267 * Primaries:
1268 * x y
1269 * green 0.310 0.595
1270 * blue 0.155 0.070
1271 * red 0.630 0.340
1272 * white (D65) 0.3127 0.3290
1273 *
1274 * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation
1275 * for RGB conversion (as in SMPTE 240M).
1276 *
1277 * Gamma Correction (GC):
1278 *
1279 * if Vlinear < 0.018
1280 * Vnonlinear = 4.500 * Vlinear
1281 * else
1282 * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099
1283 */
1284 HAL_COLOR_MODE_STANDARD_BT601_525_UNADJUSTED = 4,
1285
1286 /*
1287 * HAL_COLOR_MODE_REC709 corresponds with display settings that implement
1288 * the ITU-R Recommendation BT.709 / Rec. 709 for high-definition television.
1289 * Rendering Intent: Colorimetric
1290 * Primaries:
1291 * x y
1292 * green 0.300 0.600
1293 * blue 0.150 0.060
1294 * red 0.640 0.330
1295 * white (D65) 0.3127 0.3290
1296 *
1297 * HDTV REC709 Inverse Gamma Correction (IGC): V represents normalized
1298 * (with [0 to 1] range) value of R, G, or B.
1299 *
1300 * if Vnonlinear < 0.081
1301 * Vlinear = Vnonlinear / 4.5
1302 * else
1303 * Vlinear = ((Vnonlinear + 0.099) / 1.099) ^ (1/0.45)
1304 *
1305 * HDTV REC709 Gamma Correction (GC):
1306 *
1307 * if Vlinear < 0.018
1308 * Vnonlinear = 4.5 * Vlinear
1309 * else
1310 * Vnonlinear = 1.099 * (Vlinear) ^ 0.45 – 0.099
1311 */
1312 HAL_COLOR_MODE_STANDARD_BT709 = 5,
1313
1314 /*
1315 * HAL_COLOR_MODE_DCI_P3 corresponds with display settings that implement
1316 * SMPTE EG 432-1 and SMPTE RP 431-2
1317 * Rendering Intent: Colorimetric
1318 * Primaries:
1319 * x y
1320 * green 0.265 0.690
1321 * blue 0.150 0.060
1322 * red 0.680 0.320
1323 * white (D65) 0.3127 0.3290
1324 *
1325 * Gamma: 2.2
1326 */
1327 HAL_COLOR_MODE_DCI_P3 = 6,
1328
1329 /*
1330 * HAL_COLOR_MODE_SRGB corresponds with display settings that implement
1331 * the sRGB color space. Uses the same primaries as ITU-R Recommendation
1332 * BT.709
1333 * Rendering Intent: Colorimetric
1334 * Primaries:
1335 * x y
1336 * green 0.300 0.600
1337 * blue 0.150 0.060
1338 * red 0.640 0.330
1339 * white (D65) 0.3127 0.3290
1340 *
1341 * PC/Internet (sRGB) Inverse Gamma Correction (IGC):
1342 *
1343 * if Vnonlinear ≤ 0.03928
1344 * Vlinear = Vnonlinear / 12.92
1345 * else
1346 * Vlinear = ((Vnonlinear + 0.055)/1.055) ^ 2.4
1347 *
1348 * PC/Internet (sRGB) Gamma Correction (GC):
1349 *
1350 * if Vlinear ≤ 0.0031308
1351 * Vnonlinear = 12.92 * Vlinear
1352 * else
1353 * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055
1354 */
1355 HAL_COLOR_MODE_SRGB = 7,
1356
1357 /*
1358 * HAL_COLOR_MODE_ADOBE_RGB corresponds with the RGB color space developed
1359 * by Adobe Systems, Inc. in 1998.
1360 * Rendering Intent: Colorimetric
1361 * Primaries:
1362 * x y
1363 * green 0.210 0.710
1364 * blue 0.150 0.060
1365 * red 0.640 0.330
1366 * white (D65) 0.3127 0.3290
1367 *
1368 * Gamma: 2.2
1369 */
1370 HAL_COLOR_MODE_ADOBE_RGB = 8
1371
1372} android_color_mode_t;
1373
1374/*
1375 * Color transforms that may be applied by hardware composer to the whole
1376 * display.
1377 */
1378typedef enum android_color_transform {
1379 /* Applies no transform to the output color */
1380 HAL_COLOR_TRANSFORM_IDENTITY = 0,
1381
1382 /* Applies an arbitrary transform defined by a 4x4 affine matrix */
1383 HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX = 1,
1384
1385 /* Applies a transform that inverts the value or luminance of the color, but
1386 * does not modify hue or saturation */
1387 HAL_COLOR_TRANSFORM_VALUE_INVERSE = 2,
1388
1389 /* Applies a transform that maps all colors to shades of gray */
1390 HAL_COLOR_TRANSFORM_GRAYSCALE = 3,
1391
1392 /* Applies a transform which corrects for protanopic color blindness */
1393 HAL_COLOR_TRANSFORM_CORRECT_PROTANOPIA = 4,
1394
1395 /* Applies a transform which corrects for deuteranopic color blindness */
1396 HAL_COLOR_TRANSFORM_CORRECT_DEUTERANOPIA = 5,
1397
1398 /* Applies a transform which corrects for tritanopic color blindness */
1399 HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA = 6
1400} android_color_transform_t;
1401
1402/*
1403 * Supported HDR formats. Must be kept in sync with equivalents in Display.java.
1404 */
1405typedef enum android_hdr {
1406 /* Device supports Dolby Vision HDR */
1407 HAL_HDR_DOLBY_VISION = 1,
1408
1409 /* Device supports HDR10 */
1410 HAL_HDR_HDR10 = 2,
1411
1412 /* Device supports hybrid log-gamma HDR */
1413 HAL_HDR_HLG = 3
1414} android_hdr_t;
1415
1416#ifdef __cplusplus
1417}
1418#endif
1419
1420#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */
diff --git a/include/system/qemu_pipe.h b/include/system/qemu_pipe.h
deleted file mode 100644
index af2507997..000000000
--- a/include/system/qemu_pipe.h
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef ANDROID_INCLUDE_SYSTEM_QEMU_PIPE_H
17#define ANDROID_INCLUDE_SYSTEM_QEMU_PIPE_H
18
19#include <unistd.h>
20#include <fcntl.h>
21#include <string.h>
22#include <errno.h>
23
24// Define QEMU_PIPE_DEBUG if you want to print error messages when an error
25// occurs during pipe operations. The macro should simply take a printf-style
26// formatting string followed by optional arguments.
27#ifndef QEMU_PIPE_DEBUG
28# define QEMU_PIPE_DEBUG(...) (void)0
29#endif
30
31// Try to open a new Qemu fast-pipe. This function returns a file descriptor
32// that can be used to communicate with a named service managed by the
33// emulator.
34//
35// This file descriptor can be used as a standard pipe/socket descriptor.
36//
37// 'pipeName' is the name of the emulator service you want to connect to,
38// and must begin with 'pipe:' (e.g. 'pipe:camera' or 'pipe:opengles').
39//
40// On success, return a valid file descriptor, or -1/errno on failure. E.g.:
41//
42// EINVAL -> unknown/unsupported pipeName
43// ENOSYS -> fast pipes not available in this system.
44//
45// ENOSYS should never happen, except if you're trying to run within a
46// misconfigured emulator.
47//
48// You should be able to open several pipes to the same pipe service,
49// except for a few special cases (e.g. GSM modem), where EBUSY will be
50// returned if more than one client tries to connect to it.
51static __inline__ int qemu_pipe_open(const char* pipeName) {
52 // Sanity check.
53 if (!pipeName || memcmp(pipeName, "pipe:", 5) != 0) {
54 errno = EINVAL;
55 return -1;
56 }
57
58 int fd = TEMP_FAILURE_RETRY(open("/dev/qemu_pipe", O_RDWR));
59 if (fd < 0) {
60 QEMU_PIPE_DEBUG("%s: Could not open /dev/qemu_pipe: %s", __FUNCTION__,
61 strerror(errno));
62 return -1;
63 }
64
65 // Write the pipe name, *including* the trailing zero which is necessary.
66 size_t pipeNameLen = strlen(pipeName);
67 ssize_t ret = TEMP_FAILURE_RETRY(write(fd, pipeName, pipeNameLen + 1U));
68 if (ret != (ssize_t)pipeNameLen + 1) {
69 QEMU_PIPE_DEBUG("%s: Could not connect to %s pipe service: %s",
70 __FUNCTION__, pipeName, strerror(errno));
71 if (ret == 0) {
72 errno = ECONNRESET;
73 } else if (ret > 0) {
74 errno = EINVAL;
75 }
76 return -1;
77 }
78 return fd;
79}
80
81// Send a framed message |buff| of |len| bytes through the |fd| descriptor.
82// This really adds a 4-hexchar prefix describing the payload size.
83// Returns 0 on success, and -1 on error.
84static int __inline__ qemu_pipe_frame_send(int fd,
85 const void* buff,
86 size_t len) {
87 char header[5];
88 snprintf(header, sizeof(header), "%04zx", len);
89 ssize_t ret = TEMP_FAILURE_RETRY(write(fd, header, 4));
90 if (ret != 4) {
91 QEMU_PIPE_DEBUG("Can't write qemud frame header: %s", strerror(errno));
92 return -1;
93 }
94 ret = TEMP_FAILURE_RETRY(write(fd, buff, len));
95 if (ret != (ssize_t)len) {
96 QEMU_PIPE_DEBUG("Can't write qemud frame payload: %s", strerror(errno));
97 return -1;
98 }
99 return 0;
100}
101
102// Read a frame message from |fd|, and store it into |buff| of |len| bytes.
103// If the framed message is larger than |len|, then this returns -1 and the
104// content is lost. Otherwise, this returns the size of the message. NOTE:
105// empty messages are possible in a framed wire protocol and do not mean
106// end-of-stream.
107static int __inline__ qemu_pipe_frame_recv(int fd, void* buff, size_t len) {
108 char header[5];
109 ssize_t ret = TEMP_FAILURE_RETRY(read(fd, header, 4));
110 if (ret != 4) {
111 QEMU_PIPE_DEBUG("Can't read qemud frame header: %s", strerror(errno));
112 return -1;
113 }
114 header[4] = '\0';
115 size_t size;
116 if (sscanf(header, "%04zx", &size) != 1) {
117 QEMU_PIPE_DEBUG("Malformed qemud frame header: [%.*s]", 4, header);
118 return -1;
119 }
120 if (size > len) {
121 QEMU_PIPE_DEBUG("Oversized qemud frame (% bytes, expected <= %)", size,
122 len);
123 return -1;
124 }
125 ret = TEMP_FAILURE_RETRY(read(fd, buff, size));
126 if (ret != (ssize_t)size) {
127 QEMU_PIPE_DEBUG("Could not read qemud frame payload: %s",
128 strerror(errno));
129 return -1;
130 }
131 return size;
132}
133
134#endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_PIPE_H */
diff --git a/include/system/radio.h b/include/system/radio.h
deleted file mode 100644
index 03b252e30..000000000
--- a/include/system/radio.h
+++ /dev/null
@@ -1,253 +0,0 @@
1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_RADIO_H
18#define ANDROID_RADIO_H
19
20#include <stdbool.h>
21#include <stdint.h>
22#include <stdio.h>
23#include <sys/cdefs.h>
24#include <sys/types.h>
25
26
27#define RADIO_NUM_BANDS_MAX 16
28#define RADIO_NUM_SPACINGS_MAX 16
29#define RADIO_STRING_LEN_MAX 128
30
31/*
32 * Radio hardware module class. A given radio hardware module HAL is of one class
33 * only. The platform can not have more than one hardware module of each class.
34 * Current version of the framework only supports RADIO_CLASS_AM_FM.
35 */
36typedef enum {
37 RADIO_CLASS_AM_FM = 0, /* FM (including HD radio) and AM */
38 RADIO_CLASS_SAT = 1, /* Satellite Radio */
39 RADIO_CLASS_DT = 2, /* Digital Radio (DAB) */
40} radio_class_t;
41
42/* value for field "type" of radio band described in struct radio_hal_band_config */
43typedef enum {
44 RADIO_BAND_AM = 0, /* Amplitude Modulation band: LW, MW, SW */
45 RADIO_BAND_FM = 1, /* Frequency Modulation band: FM */
46 RADIO_BAND_FM_HD = 2, /* FM HD Radio / DRM (IBOC) */
47 RADIO_BAND_AM_HD = 3, /* AM HD Radio / DRM (IBOC) */
48} radio_band_t;
49
50/* RDS variant implemented. A struct radio_hal_fm_band_config can list none or several. */
51enum {
52 RADIO_RDS_NONE = 0x0,
53 RADIO_RDS_WORLD = 0x01,
54 RADIO_RDS_US = 0x02,
55};
56typedef unsigned int radio_rds_t;
57
58/* FM deemphasis variant implemented. A struct radio_hal_fm_band_config can list one or more. */
59enum {
60 RADIO_DEEMPHASIS_50 = 0x1,
61 RADIO_DEEMPHASIS_75 = 0x2,
62};
63typedef unsigned int radio_deemphasis_t;
64
65/* Region a particular radio band configuration corresponds to. Not used at the HAL.
66 * Derived by the framework when converting the band descriptors retrieved from the HAL to
67 * individual band descriptors for each supported region. */
68typedef enum {
69 RADIO_REGION_NONE = -1,
70 RADIO_REGION_ITU_1 = 0,
71 RADIO_REGION_ITU_2 = 1,
72 RADIO_REGION_OIRT = 2,
73 RADIO_REGION_JAPAN = 3,
74 RADIO_REGION_KOREA = 4,
75} radio_region_t;
76
77/* scanning direction for scan() and step() tuner APIs */
78typedef enum {
79 RADIO_DIRECTION_UP,
80 RADIO_DIRECTION_DOWN
81} radio_direction_t;
82
83/* unique handle allocated to a radio module */
84typedef unsigned int radio_handle_t;
85
86/* Opaque meta data structure used by radio meta data API (see system/radio_metadata.h) */
87typedef struct radio_metadata radio_metadata_t;
88
89
90/* Additional attributes for an FM band configuration */
91typedef struct radio_hal_fm_band_config {
92 radio_deemphasis_t deemphasis; /* deemphasis variant */
93 bool stereo; /* stereo supported */
94 radio_rds_t rds; /* RDS variants supported */
95 bool ta; /* Traffic Announcement supported */
96 bool af; /* Alternate Frequency supported */
97 bool ea; /* Emergency announcements supported */
98} radio_hal_fm_band_config_t;
99
100/* Additional attributes for an AM band configuration */
101typedef struct radio_hal_am_band_config {
102 bool stereo; /* stereo supported */
103} radio_hal_am_band_config_t;
104
105/* Radio band configuration. Describes a given band supported by the radio module.
106 * The HAL can expose only one band per type with the the maximum range supported and all options.
107 * THe framework will derive the actual regions were this module can operate and expose separate
108 * band configurations for applications to chose from. */
109typedef struct radio_hal_band_config {
110 radio_band_t type;
111 bool antenna_connected;
112 unsigned int lower_limit;
113 unsigned int upper_limit;
114 unsigned int num_spacings;
115 unsigned int spacings[RADIO_NUM_SPACINGS_MAX];
116 union {
117 radio_hal_fm_band_config_t fm;
118 radio_hal_am_band_config_t am;
119 };
120} radio_hal_band_config_t;
121
122/* Used internally by the framework to represent a band for s specific region */
123typedef struct radio_band_config {
124 radio_region_t region;
125 radio_hal_band_config_t band;
126} radio_band_config_t;
127
128
129/* Exposes properties of a given hardware radio module.
130 * NOTE: current framework implementation supports only one audio source (num_audio_sources = 1).
131 * The source corresponds to AUDIO_DEVICE_IN_FM_TUNER.
132 * If more than one tuner is supported (num_tuners > 1), only one can be connected to the audio
133 * source. */
134typedef struct radio_hal_properties {
135 radio_class_t class_id; /* Class of this module. E.g RADIO_CLASS_AM_FM */
136 char implementor[RADIO_STRING_LEN_MAX]; /* implementor name */
137 char product[RADIO_STRING_LEN_MAX]; /* product name */
138 char version[RADIO_STRING_LEN_MAX]; /* product version */
139 char serial[RADIO_STRING_LEN_MAX]; /* serial number (for subscription services) */
140 unsigned int num_tuners; /* number of tuners controllable independently */
141 unsigned int num_audio_sources; /* number of audio sources driven simultaneously */
142 bool supports_capture; /* the hardware supports capture of audio source audio HAL */
143 unsigned int num_bands; /* number of band descriptors */
144 radio_hal_band_config_t bands[RADIO_NUM_BANDS_MAX]; /* band descriptors */
145} radio_hal_properties_t;
146
147/* Used internally by the framework. Same information as in struct radio_hal_properties plus a
148 * unique handle and one band configuration per region. */
149typedef struct radio_properties {
150 radio_handle_t handle;
151 radio_class_t class_id;
152 char implementor[RADIO_STRING_LEN_MAX];
153 char product[RADIO_STRING_LEN_MAX];
154 char version[RADIO_STRING_LEN_MAX];
155 char serial[RADIO_STRING_LEN_MAX];
156 unsigned int num_tuners;
157 unsigned int num_audio_sources;
158 bool supports_capture;
159 unsigned int num_bands;
160 radio_band_config_t bands[RADIO_NUM_BANDS_MAX];
161} radio_properties_t;
162
163/* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED.
164 * Contains information on currently tuned channel.
165 */
166typedef struct radio_program_info {
167 unsigned int channel; /* current channel. (e.g kHz for band type RADIO_BAND_FM) */
168 unsigned int sub_channel; /* current sub channel. (used for RADIO_BAND_FM_HD) */
169 bool tuned; /* tuned to a program or not */
170 bool stereo; /* program is stereo or not */
171 bool digital; /* digital program or not (e.g HD Radio program) */
172 unsigned int signal_strength; /* signal strength from 0 to 100 */
173 /* meta data (e.g PTY, song title ...), must not be NULL */
174 __attribute__((aligned(8))) radio_metadata_t *metadata;
175} radio_program_info_t;
176
177
178/* Events sent to the framework via the HAL callback. An event can notify the completion of an
179 * asynchronous command (configuration, tune, scan ...) or a spontaneous change (antenna connection,
180 * failure, AF switching, meta data reception... */
181enum {
182 RADIO_EVENT_HW_FAILURE = 0, /* hardware module failure. Requires reopening the tuner */
183 RADIO_EVENT_CONFIG = 1, /* configuration change completed */
184 RADIO_EVENT_ANTENNA = 2, /* Antenna connected, disconnected */
185 RADIO_EVENT_TUNED = 3, /* tune, step, scan completed */
186 RADIO_EVENT_METADATA = 4, /* New meta data received */
187 RADIO_EVENT_TA = 5, /* Traffic announcement start or stop */
188 RADIO_EVENT_AF_SWITCH = 6, /* Switch to Alternate Frequency */
189 RADIO_EVENT_EA = 7, /* Emergency announcement start or stop */
190 // begin framework only events
191 RADIO_EVENT_CONTROL = 100, /* loss/gain of tuner control */
192 RADIO_EVENT_SERVER_DIED = 101, /* radio service died */
193};
194typedef unsigned int radio_event_type_t;
195
196/* Event passed to the framework by the HAL callback */
197typedef struct radio_hal_event {
198 radio_event_type_t type; /* event type */
199 int status; /* used by RADIO_EVENT_CONFIG, RADIO_EVENT_TUNED */
200 union {
201 /* RADIO_EVENT_ANTENNA, RADIO_EVENT_TA, RADIO_EVENT_EA */
202 bool on;
203 radio_hal_band_config_t config; /* RADIO_EVENT_CONFIG */
204 radio_program_info_t info; /* RADIO_EVENT_TUNED, RADIO_EVENT_AF_SWITCH */
205 radio_metadata_t *metadata; /* RADIO_EVENT_METADATA */
206 };
207} radio_hal_event_t;
208
209/* Used internally by the framework. Same information as in struct radio_hal_event */
210typedef struct radio_event {
211 radio_event_type_t type;
212 int status;
213 union {
214 bool on;
215 radio_band_config_t config;
216 radio_program_info_t info;
217 radio_metadata_t *metadata; /* offset from start of struct when in shared memory */
218 };
219} radio_event_t;
220
221
222static inline
223radio_rds_t radio_rds_for_region(bool rds, radio_region_t region) {
224 if (!rds)
225 return RADIO_RDS_NONE;
226 switch(region) {
227 case RADIO_REGION_ITU_1:
228 case RADIO_REGION_OIRT:
229 case RADIO_REGION_JAPAN:
230 case RADIO_REGION_KOREA:
231 return RADIO_RDS_WORLD;
232 case RADIO_REGION_ITU_2:
233 return RADIO_RDS_US;
234 default:
235 return RADIO_REGION_NONE;
236 }
237}
238
239static inline
240radio_deemphasis_t radio_demephasis_for_region(radio_region_t region) {
241 switch(region) {
242 case RADIO_REGION_KOREA:
243 case RADIO_REGION_ITU_2:
244 return RADIO_DEEMPHASIS_75;
245 case RADIO_REGION_ITU_1:
246 case RADIO_REGION_OIRT:
247 case RADIO_REGION_JAPAN:
248 default:
249 return RADIO_DEEMPHASIS_50;
250 }
251}
252
253#endif // ANDROID_RADIO_H
diff --git a/include/system/thread_defs.h b/include/system/thread_defs.h
deleted file mode 100644
index 377a48ce9..000000000
--- a/include/system/thread_defs.h
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_THREAD_DEFS_H
18#define ANDROID_THREAD_DEFS_H
19
20#include "graphics.h"
21
22#if defined(__cplusplus)
23extern "C" {
24#endif
25
26enum {
27 /*
28 * ***********************************************
29 * ** Keep in sync with android.os.Process.java **
30 * ***********************************************
31 *
32 * This maps directly to the "nice" priorities we use in Android.
33 * A thread priority should be chosen inverse-proportionally to
34 * the amount of work the thread is expected to do. The more work
35 * a thread will do, the less favorable priority it should get so that
36 * it doesn't starve the system. Threads not behaving properly might
37 * be "punished" by the kernel.
38 * Use the levels below when appropriate. Intermediate values are
39 * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below.
40 */
41 ANDROID_PRIORITY_LOWEST = 19,
42
43 /* use for background tasks */
44 ANDROID_PRIORITY_BACKGROUND = 10,
45
46 /* most threads run at normal priority */
47 ANDROID_PRIORITY_NORMAL = 0,
48
49 /* threads currently running a UI that the user is interacting with */
50 ANDROID_PRIORITY_FOREGROUND = -2,
51
52 /* the main UI thread has a slightly more favorable priority */
53 ANDROID_PRIORITY_DISPLAY = -4,
54
55 /* ui service treads might want to run at a urgent display (uncommon) */
56 ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY,
57
58 /* all normal audio threads */
59 ANDROID_PRIORITY_AUDIO = -16,
60
61 /* service audio threads (uncommon) */
62 ANDROID_PRIORITY_URGENT_AUDIO = -19,
63
64 /* should never be used in practice. regular process might not
65 * be allowed to use this level */
66 ANDROID_PRIORITY_HIGHEST = -20,
67
68 ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL,
69 ANDROID_PRIORITY_MORE_FAVORABLE = -1,
70 ANDROID_PRIORITY_LESS_FAVORABLE = +1,
71};
72
73#if defined(__cplusplus)
74}
75#endif
76
77#endif /* ANDROID_THREAD_DEFS_H */
diff --git a/include/system/window.h b/include/system/window.h
deleted file mode 100644
index f43970549..000000000
--- a/include/system/window.h
+++ /dev/null
@@ -1,1013 +0,0 @@
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
18#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
19
20#include <cutils/native_handle.h>
21#include <errno.h>
22#include <limits.h>
23#include <stdint.h>
24#include <string.h>
25#include <sys/cdefs.h>
26#include <system/graphics.h>
27#include <unistd.h>
28#include <stdbool.h>
29
30#ifndef __UNUSED
31#define __UNUSED __attribute__((__unused__))
32#endif
33#ifndef __deprecated
34#define __deprecated __attribute__((__deprecated__))
35#endif
36
37__BEGIN_DECLS
38
39/*****************************************************************************/
40
41#ifdef __cplusplus
42#define ANDROID_NATIVE_UNSIGNED_CAST(x) static_cast<unsigned int>(x)
43#else
44#define ANDROID_NATIVE_UNSIGNED_CAST(x) ((unsigned int)(x))
45#endif
46
47#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
48 ((ANDROID_NATIVE_UNSIGNED_CAST(a) << 24) | \
49 (ANDROID_NATIVE_UNSIGNED_CAST(b) << 16) | \
50 (ANDROID_NATIVE_UNSIGNED_CAST(c) << 8) | \
51 (ANDROID_NATIVE_UNSIGNED_CAST(d)))
52
53#define ANDROID_NATIVE_WINDOW_MAGIC \
54 ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
55
56#define ANDROID_NATIVE_BUFFER_MAGIC \
57 ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
58
59// ---------------------------------------------------------------------------
60
61// This #define may be used to conditionally compile device-specific code to
62// support either the prior ANativeWindow interface, which did not pass libsync
63// fences around, or the new interface that does. This #define is only present
64// when the ANativeWindow interface does include libsync support.
65#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1
66
67// ---------------------------------------------------------------------------
68
69typedef const native_handle_t* buffer_handle_t;
70
71// ---------------------------------------------------------------------------
72
73typedef struct android_native_rect_t
74{
75 int32_t left;
76 int32_t top;
77 int32_t right;
78 int32_t bottom;
79} android_native_rect_t;
80
81// ---------------------------------------------------------------------------
82
83typedef struct android_native_base_t
84{
85 /* a magic value defined by the actual EGL native type */
86 int magic;
87
88 /* the sizeof() of the actual EGL native type */
89 int version;
90
91 void* reserved[4];
92
93 /* reference-counting interface */
94 void (*incRef)(struct android_native_base_t* base);
95 void (*decRef)(struct android_native_base_t* base);
96} android_native_base_t;
97
98typedef struct ANativeWindowBuffer
99{
100#ifdef __cplusplus
101 ANativeWindowBuffer() {
102 common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
103 common.version = sizeof(ANativeWindowBuffer);
104 memset(common.reserved, 0, sizeof(common.reserved));
105 }
106
107 // Implement the methods that sp<ANativeWindowBuffer> expects so that it
108 // can be used to automatically refcount ANativeWindowBuffer's.
109 void incStrong(const void* /*id*/) const {
110 common.incRef(const_cast<android_native_base_t*>(&common));
111 }
112 void decStrong(const void* /*id*/) const {
113 common.decRef(const_cast<android_native_base_t*>(&common));
114 }
115#endif
116
117 struct android_native_base_t common;
118
119 int width;
120 int height;
121 int stride;
122 int format;
123 int usage;
124
125 void* reserved[2];
126
127 buffer_handle_t handle;
128
129 void* reserved_proc[8];
130} ANativeWindowBuffer_t;
131
132// Old typedef for backwards compatibility.
133typedef ANativeWindowBuffer_t android_native_buffer_t;
134
135// ---------------------------------------------------------------------------
136
137/* attributes queriable with query() */
138enum {
139 NATIVE_WINDOW_WIDTH = 0,
140 NATIVE_WINDOW_HEIGHT = 1,
141 NATIVE_WINDOW_FORMAT = 2,
142
143 /* The minimum number of buffers that must remain un-dequeued after a buffer
144 * has been queued. This value applies only if set_buffer_count was used to
145 * override the number of buffers and if a buffer has since been queued.
146 * Users of the set_buffer_count ANativeWindow method should query this
147 * value before calling set_buffer_count. If it is necessary to have N
148 * buffers simultaneously dequeued as part of the steady-state operation,
149 * and this query returns M then N+M buffers should be requested via
150 * native_window_set_buffer_count.
151 *
152 * Note that this value does NOT apply until a single buffer has been
153 * queued. In particular this means that it is possible to:
154 *
155 * 1. Query M = min undequeued buffers
156 * 2. Set the buffer count to N + M
157 * 3. Dequeue all N + M buffers
158 * 4. Cancel M buffers
159 * 5. Queue, dequeue, queue, dequeue, ad infinitum
160 */
161 NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
162
163 /* Check whether queueBuffer operations on the ANativeWindow send the buffer
164 * to the window compositor. The query sets the returned 'value' argument
165 * to 1 if the ANativeWindow DOES send queued buffers directly to the window
166 * compositor and 0 if the buffers do not go directly to the window
167 * compositor.
168 *
169 * This can be used to determine whether protected buffer content should be
170 * sent to the ANativeWindow. Note, however, that a result of 1 does NOT
171 * indicate that queued buffers will be protected from applications or users
172 * capturing their contents. If that behavior is desired then some other
173 * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
174 * conjunction with this query.
175 */
176 NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
177
178 /* Get the concrete type of a ANativeWindow. See below for the list of
179 * possible return values.
180 *
181 * This query should not be used outside the Android framework and will
182 * likely be removed in the near future.
183 */
184 NATIVE_WINDOW_CONCRETE_TYPE = 5,
185
186
187 /*
188 * Default width and height of ANativeWindow buffers, these are the
189 * dimensions of the window buffers irrespective of the
190 * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window
191 * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.
192 */
193 NATIVE_WINDOW_DEFAULT_WIDTH = 6,
194 NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
195
196 /*
197 * transformation that will most-likely be applied to buffers. This is only
198 * a hint, the actual transformation applied might be different.
199 *
200 * INTENDED USE:
201 *
202 * The transform hint can be used by a producer, for instance the GLES
203 * driver, to pre-rotate the rendering such that the final transformation
204 * in the composer is identity. This can be very useful when used in
205 * conjunction with the h/w composer HAL, in situations where it
206 * cannot handle arbitrary rotations.
207 *
208 * 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
209 * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
210 *
211 * 2. The GL driver overrides the width and height of the ANW to
212 * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
213 * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
214 * according to NATIVE_WINDOW_TRANSFORM_HINT and calling
215 * native_window_set_buffers_dimensions().
216 *
217 * 3. The GL driver dequeues a buffer of the new pre-rotated size.
218 *
219 * 4. The GL driver renders to the buffer such that the image is
220 * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
221 * to the rendering.
222 *
223 * 5. The GL driver calls native_window_set_transform to apply
224 * inverse transformation to the buffer it just rendered.
225 * In order to do this, the GL driver needs
226 * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
227 * done easily:
228 *
229 * int hintTransform, inverseTransform;
230 * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
231 * inverseTransform = hintTransform;
232 * if (hintTransform & HAL_TRANSFORM_ROT_90)
233 * inverseTransform ^= HAL_TRANSFORM_ROT_180;
234 *
235 *
236 * 6. The GL driver queues the pre-transformed buffer.
237 *
238 * 7. The composer combines the buffer transform with the display
239 * transform. If the buffer transform happens to cancel out the
240 * display transform then no rotation is needed.
241 *
242 */
243 NATIVE_WINDOW_TRANSFORM_HINT = 8,
244
245 /*
246 * Boolean that indicates whether the consumer is running more than
247 * one buffer behind the producer.
248 */
249 NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,
250
251 /*
252 * The consumer gralloc usage bits currently set by the consumer.
253 * The values are defined in hardware/libhardware/include/gralloc.h.
254 */
255 NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10,
256
257 /**
258 * Transformation that will by applied to buffers by the hwcomposer.
259 * This must not be set or checked by producer endpoints, and will
260 * disable the transform hint set in SurfaceFlinger (see
261 * NATIVE_WINDOW_TRANSFORM_HINT).
262 *
263 * INTENDED USE:
264 * Temporary - Please do not use this. This is intended only to be used
265 * by the camera's LEGACY mode.
266 *
267 * In situations where a SurfaceFlinger client wishes to set a transform
268 * that is not visible to the producer, and will always be applied in the
269 * hardware composer, the client can set this flag with
270 * native_window_set_buffers_sticky_transform. This can be used to rotate
271 * and flip buffers consumed by hardware composer without actually changing
272 * the aspect ratio of the buffers produced.
273 */
274 NATIVE_WINDOW_STICKY_TRANSFORM = 11,
275
276 /**
277 * The default data space for the buffers as set by the consumer.
278 * The values are defined in graphics.h.
279 */
280 NATIVE_WINDOW_DEFAULT_DATASPACE = 12,
281
282 /*
283 * Returns the age of the contents of the most recently dequeued buffer as
284 * the number of frames that have elapsed since it was last queued. For
285 * example, if the window is double-buffered, the age of any given buffer in
286 * steady state will be 2. If the dequeued buffer has never been queued, its
287 * age will be 0.
288 */
289 NATIVE_WINDOW_BUFFER_AGE = 13,
290
291 /*
292 * Returns the duration of the last dequeueBuffer call in microseconds
293 */
294 NATIVE_WINDOW_LAST_DEQUEUE_DURATION = 14,
295
296 /*
297 * Returns the duration of the last queueBuffer call in microseconds
298 */
299 NATIVE_WINDOW_LAST_QUEUE_DURATION = 15,
300};
301
302/* Valid operations for the (*perform)() hook.
303 *
304 * Values marked as 'deprecated' are supported, but have been superceded by
305 * other functionality.
306 *
307 * Values marked as 'private' should be considered private to the framework.
308 * HAL implementation code with access to an ANativeWindow should not use these,
309 * as it may not interact properly with the framework's use of the
310 * ANativeWindow.
311 */
312enum {
313 NATIVE_WINDOW_SET_USAGE = 0,
314 NATIVE_WINDOW_CONNECT = 1, /* deprecated */
315 NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
316 NATIVE_WINDOW_SET_CROP = 3, /* private */
317 NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
318 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
319 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
320 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
321 NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
322 NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
323 NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */
324 NATIVE_WINDOW_LOCK = 11, /* private */
325 NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
326 NATIVE_WINDOW_API_CONNECT = 13, /* private */
327 NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
328 NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
329 NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */
330 NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
331 NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18,
332 NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19,
333 NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */
334 NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21,
335 NATIVE_WINDOW_SET_AUTO_REFRESH = 22,
336 NATIVE_WINDOW_GET_FRAME_TIMESTAMPS = 23,
337};
338
339/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
340enum {
341 /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
342 * OpenGL ES.
343 */
344 NATIVE_WINDOW_API_EGL = 1,
345
346 /* Buffers will be queued after being filled using the CPU
347 */
348 NATIVE_WINDOW_API_CPU = 2,
349
350 /* Buffers will be queued by Stagefright after being filled by a video
351 * decoder. The video decoder can either be a software or hardware decoder.
352 */
353 NATIVE_WINDOW_API_MEDIA = 3,
354
355 /* Buffers will be queued by the the camera HAL.
356 */
357 NATIVE_WINDOW_API_CAMERA = 4,
358};
359
360/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
361enum {
362 /* flip source image horizontally */
363 NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
364 /* flip source image vertically */
365 NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
366 /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
367 NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
368 /* rotate source image 180 degrees */
369 NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
370 /* rotate source image 270 degrees clock-wise */
371 NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
372 /* transforms source by the inverse transform of the screen it is displayed onto. This
373 * transform is applied last */
374 NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08
375};
376
377/* parameter for NATIVE_WINDOW_SET_SCALING_MODE
378 * keep in sync with Surface.java in frameworks/base */
379enum {
380 /* the window content is not updated (frozen) until a buffer of
381 * the window size is received (enqueued)
382 */
383 NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
384 /* the buffer is scaled in both dimensions to match the window size */
385 NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
386 /* the buffer is scaled uniformly such that the smaller dimension
387 * of the buffer matches the window size (cropping in the process)
388 */
389 NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,
390 /* the window is clipped to the size of the buffer's crop rectangle; pixels
391 * outside the crop rectangle are treated as if they are completely
392 * transparent.
393 */
394 NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3,
395};
396
397/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
398enum {
399 NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
400 NATIVE_WINDOW_SURFACE = 1, /* Surface */
401};
402
403/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
404 *
405 * Special timestamp value to indicate that timestamps should be auto-generated
406 * by the native window when queueBuffer is called. This is equal to INT64_MIN,
407 * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
408 */
409static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
410
411struct ANativeWindow
412{
413#ifdef __cplusplus
414 ANativeWindow()
415 : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
416 {
417 common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
418 common.version = sizeof(ANativeWindow);
419 memset(common.reserved, 0, sizeof(common.reserved));
420 }
421
422 /* Implement the methods that sp<ANativeWindow> expects so that it
423 can be used to automatically refcount ANativeWindow's. */
424 void incStrong(const void* /*id*/) const {
425 common.incRef(const_cast<android_native_base_t*>(&common));
426 }
427 void decStrong(const void* /*id*/) const {
428 common.decRef(const_cast<android_native_base_t*>(&common));
429 }
430#endif
431
432 struct android_native_base_t common;
433
434 /* flags describing some attributes of this surface or its updater */
435 const uint32_t flags;
436
437 /* min swap interval supported by this updated */
438 const int minSwapInterval;
439
440 /* max swap interval supported by this updated */
441 const int maxSwapInterval;
442
443 /* horizontal and vertical resolution in DPI */
444 const float xdpi;
445 const float ydpi;
446
447 /* Some storage reserved for the OEM's driver. */
448 intptr_t oem[4];
449
450 /*
451 * Set the swap interval for this surface.
452 *
453 * Returns 0 on success or -errno on error.
454 */
455 int (*setSwapInterval)(struct ANativeWindow* window,
456 int interval);
457
458 /*
459 * Hook called by EGL to acquire a buffer. After this call, the buffer
460 * is not locked, so its content cannot be modified. This call may block if
461 * no buffers are available.
462 *
463 * The window holds a reference to the buffer between dequeueBuffer and
464 * either queueBuffer or cancelBuffer, so clients only need their own
465 * reference if they might use the buffer after queueing or canceling it.
466 * Holding a reference to a buffer after queueing or canceling it is only
467 * allowed if a specific buffer count has been set.
468 *
469 * Returns 0 on success or -errno on error.
470 *
471 * XXX: This function is deprecated. It will continue to work for some
472 * time for binary compatibility, but the new dequeueBuffer function that
473 * outputs a fence file descriptor should be used in its place.
474 */
475 int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,
476 struct ANativeWindowBuffer** buffer);
477
478 /*
479 * hook called by EGL to lock a buffer. This MUST be called before modifying
480 * the content of a buffer. The buffer must have been acquired with
481 * dequeueBuffer first.
482 *
483 * Returns 0 on success or -errno on error.
484 *
485 * XXX: This function is deprecated. It will continue to work for some
486 * time for binary compatibility, but it is essentially a no-op, and calls
487 * to it should be removed.
488 */
489 int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,
490 struct ANativeWindowBuffer* buffer);
491
492 /*
493 * Hook called by EGL when modifications to the render buffer are done.
494 * This unlocks and post the buffer.
495 *
496 * The window holds a reference to the buffer between dequeueBuffer and
497 * either queueBuffer or cancelBuffer, so clients only need their own
498 * reference if they might use the buffer after queueing or canceling it.
499 * Holding a reference to a buffer after queueing or canceling it is only
500 * allowed if a specific buffer count has been set.
501 *
502 * Buffers MUST be queued in the same order than they were dequeued.
503 *
504 * Returns 0 on success or -errno on error.
505 *
506 * XXX: This function is deprecated. It will continue to work for some
507 * time for binary compatibility, but the new queueBuffer function that
508 * takes a fence file descriptor should be used in its place (pass a value
509 * of -1 for the fence file descriptor if there is no valid one to pass).
510 */
511 int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,
512 struct ANativeWindowBuffer* buffer);
513
514 /*
515 * hook used to retrieve information about the native window.
516 *
517 * Returns 0 on success or -errno on error.
518 */
519 int (*query)(const struct ANativeWindow* window,
520 int what, int* value);
521
522 /*
523 * hook used to perform various operations on the surface.
524 * (*perform)() is a generic mechanism to add functionality to
525 * ANativeWindow while keeping backward binary compatibility.
526 *
527 * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
528 * defined below.
529 *
530 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
531 * by the surface's implementation.
532 *
533 * See above for a list of valid operations, such as
534 * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
535 */
536 int (*perform)(struct ANativeWindow* window,
537 int operation, ... );
538
539 /*
540 * Hook used to cancel a buffer that has been dequeued.
541 * No synchronization is performed between dequeue() and cancel(), so
542 * either external synchronization is needed, or these functions must be
543 * called from the same thread.
544 *
545 * The window holds a reference to the buffer between dequeueBuffer and
546 * either queueBuffer or cancelBuffer, so clients only need their own
547 * reference if they might use the buffer after queueing or canceling it.
548 * Holding a reference to a buffer after queueing or canceling it is only
549 * allowed if a specific buffer count has been set.
550 *
551 * XXX: This function is deprecated. It will continue to work for some
552 * time for binary compatibility, but the new cancelBuffer function that
553 * takes a fence file descriptor should be used in its place (pass a value
554 * of -1 for the fence file descriptor if there is no valid one to pass).
555 */
556 int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,
557 struct ANativeWindowBuffer* buffer);
558
559 /*
560 * Hook called by EGL to acquire a buffer. This call may block if no
561 * buffers are available.
562 *
563 * The window holds a reference to the buffer between dequeueBuffer and
564 * either queueBuffer or cancelBuffer, so clients only need their own
565 * reference if they might use the buffer after queueing or canceling it.
566 * Holding a reference to a buffer after queueing or canceling it is only
567 * allowed if a specific buffer count has been set.
568 *
569 * The libsync fence file descriptor returned in the int pointed to by the
570 * fenceFd argument will refer to the fence that must signal before the
571 * dequeued buffer may be written to. A value of -1 indicates that the
572 * caller may access the buffer immediately without waiting on a fence. If
573 * a valid file descriptor is returned (i.e. any value except -1) then the
574 * caller is responsible for closing the file descriptor.
575 *
576 * Returns 0 on success or -errno on error.
577 */
578 int (*dequeueBuffer)(struct ANativeWindow* window,
579 struct ANativeWindowBuffer** buffer, int* fenceFd);
580
581 /*
582 * Hook called by EGL when modifications to the render buffer are done.
583 * This unlocks and post the buffer.
584 *
585 * The window holds a reference to the buffer between dequeueBuffer and
586 * either queueBuffer or cancelBuffer, so clients only need their own
587 * reference if they might use the buffer after queueing or canceling it.
588 * Holding a reference to a buffer after queueing or canceling it is only
589 * allowed if a specific buffer count has been set.
590 *
591 * The fenceFd argument specifies a libsync fence file descriptor for a
592 * fence that must signal before the buffer can be accessed. If the buffer
593 * can be accessed immediately then a value of -1 should be used. The
594 * caller must not use the file descriptor after it is passed to
595 * queueBuffer, and the ANativeWindow implementation is responsible for
596 * closing it.
597 *
598 * Returns 0 on success or -errno on error.
599 */
600 int (*queueBuffer)(struct ANativeWindow* window,
601 struct ANativeWindowBuffer* buffer, int fenceFd);
602
603 /*
604 * Hook used to cancel a buffer that has been dequeued.
605 * No synchronization is performed between dequeue() and cancel(), so
606 * either external synchronization is needed, or these functions must be
607 * called from the same thread.
608 *
609 * The window holds a reference to the buffer between dequeueBuffer and
610 * either queueBuffer or cancelBuffer, so clients only need their own
611 * reference if they might use the buffer after queueing or canceling it.
612 * Holding a reference to a buffer after queueing or canceling it is only
613 * allowed if a specific buffer count has been set.
614 *
615 * The fenceFd argument specifies a libsync fence file decsriptor for a
616 * fence that must signal before the buffer can be accessed. If the buffer
617 * can be accessed immediately then a value of -1 should be used.
618 *
619 * Note that if the client has not waited on the fence that was returned
620 * from dequeueBuffer, that same fence should be passed to cancelBuffer to
621 * ensure that future uses of the buffer are preceded by a wait on that
622 * fence. The caller must not use the file descriptor after it is passed
623 * to cancelBuffer, and the ANativeWindow implementation is responsible for
624 * closing it.
625 *
626 * Returns 0 on success or -errno on error.
627 */
628 int (*cancelBuffer)(struct ANativeWindow* window,
629 struct ANativeWindowBuffer* buffer, int fenceFd);
630};
631
632 /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
633 * android_native_window_t is deprecated.
634 */
635typedef struct ANativeWindow ANativeWindow;
636typedef struct ANativeWindow android_native_window_t __deprecated;
637
638/*
639 * native_window_set_usage(..., usage)
640 * Sets the intended usage flags for the next buffers
641 * acquired with (*lockBuffer)() and on.
642 * By default (if this function is never called), a usage of
643 * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
644 * is assumed.
645 * Calling this function will usually cause following buffers to be
646 * reallocated.
647 */
648
649static inline int native_window_set_usage(
650 struct ANativeWindow* window, int usage)
651{
652 return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
653}
654
655/* deprecated. Always returns 0. Don't call. */
656static inline int native_window_connect(
657 struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
658
659static inline int native_window_connect(
660 struct ANativeWindow* window __UNUSED, int api __UNUSED) {
661 return 0;
662}
663
664/* deprecated. Always returns 0. Don't call. */
665static inline int native_window_disconnect(
666 struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
667
668static inline int native_window_disconnect(
669 struct ANativeWindow* window __UNUSED, int api __UNUSED) {
670 return 0;
671}
672
673/*
674 * native_window_set_crop(..., crop)
675 * Sets which region of the next queued buffers needs to be considered.
676 * Depending on the scaling mode, a buffer's crop region is scaled and/or
677 * cropped to match the surface's size. This function sets the crop in
678 * pre-transformed buffer pixel coordinates.
679 *
680 * The specified crop region applies to all buffers queued after it is called.
681 *
682 * If 'crop' is NULL, subsequently queued buffers won't be cropped.
683 *
684 * An error is returned if for instance the crop region is invalid, out of the
685 * buffer's bound or if the window is invalid.
686 */
687static inline int native_window_set_crop(
688 struct ANativeWindow* window,
689 android_native_rect_t const * crop)
690{
691 return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
692}
693
694/*
695 * native_window_set_post_transform_crop(..., crop)
696 * Sets which region of the next queued buffers needs to be considered.
697 * Depending on the scaling mode, a buffer's crop region is scaled and/or
698 * cropped to match the surface's size. This function sets the crop in
699 * post-transformed pixel coordinates.
700 *
701 * The specified crop region applies to all buffers queued after it is called.
702 *
703 * If 'crop' is NULL, subsequently queued buffers won't be cropped.
704 *
705 * An error is returned if for instance the crop region is invalid, out of the
706 * buffer's bound or if the window is invalid.
707 */
708static inline int native_window_set_post_transform_crop(
709 struct ANativeWindow* window,
710 android_native_rect_t const * crop)
711{
712 return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);
713}
714
715/*
716 * native_window_set_active_rect(..., active_rect)
717 *
718 * This function is deprecated and will be removed soon. For now it simply
719 * sets the post-transform crop for compatibility while multi-project commits
720 * get checked.
721 */
722static inline int native_window_set_active_rect(
723 struct ANativeWindow* window,
724 android_native_rect_t const * active_rect) __deprecated;
725
726static inline int native_window_set_active_rect(
727 struct ANativeWindow* window,
728 android_native_rect_t const * active_rect)
729{
730 return native_window_set_post_transform_crop(window, active_rect);
731}
732
733/*
734 * native_window_set_buffer_count(..., count)
735 * Sets the number of buffers associated with this native window.
736 */
737static inline int native_window_set_buffer_count(
738 struct ANativeWindow* window,
739 size_t bufferCount)
740{
741 return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
742}
743
744/*
745 * native_window_set_buffers_geometry(..., int w, int h, int format)
746 * All buffers dequeued after this call will have the dimensions and format
747 * specified. A successful call to this function has the same effect as calling
748 * native_window_set_buffers_size and native_window_set_buffers_format.
749 *
750 * XXX: This function is deprecated. The native_window_set_buffers_dimensions
751 * and native_window_set_buffers_format functions should be used instead.
752 */
753static inline int native_window_set_buffers_geometry(
754 struct ANativeWindow* window,
755 int w, int h, int format) __deprecated;
756
757static inline int native_window_set_buffers_geometry(
758 struct ANativeWindow* window,
759 int w, int h, int format)
760{
761 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
762 w, h, format);
763}
764
765/*
766 * native_window_set_buffers_dimensions(..., int w, int h)
767 * All buffers dequeued after this call will have the dimensions specified.
768 * In particular, all buffers will have a fixed-size, independent from the
769 * native-window size. They will be scaled according to the scaling mode
770 * (see native_window_set_scaling_mode) upon window composition.
771 *
772 * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
773 * following this call will be sized to match the window's size.
774 *
775 * Calling this function will reset the window crop to a NULL value, which
776 * disables cropping of the buffers.
777 */
778static inline int native_window_set_buffers_dimensions(
779 struct ANativeWindow* window,
780 int w, int h)
781{
782 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
783 w, h);
784}
785
786/*
787 * native_window_set_buffers_user_dimensions(..., int w, int h)
788 *
789 * Sets the user buffer size for the window, which overrides the
790 * window's size. All buffers dequeued after this call will have the
791 * dimensions specified unless overridden by
792 * native_window_set_buffers_dimensions. All buffers will have a
793 * fixed-size, independent from the native-window size. They will be
794 * scaled according to the scaling mode (see
795 * native_window_set_scaling_mode) upon window composition.
796 *
797 * If w and h are 0, the normal behavior is restored. That is, the
798 * default buffer size will match the windows's size.
799 *
800 * Calling this function will reset the window crop to a NULL value, which
801 * disables cropping of the buffers.
802 */
803static inline int native_window_set_buffers_user_dimensions(
804 struct ANativeWindow* window,
805 int w, int h)
806{
807 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,
808 w, h);
809}
810
811/*
812 * native_window_set_buffers_format(..., int format)
813 * All buffers dequeued after this call will have the format specified.
814 *
815 * If the specified format is 0, the default buffer format will be used.
816 */
817static inline int native_window_set_buffers_format(
818 struct ANativeWindow* window,
819 int format)
820{
821 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
822}
823
824/*
825 * native_window_set_buffers_data_space(..., int dataSpace)
826 * All buffers queued after this call will be associated with the dataSpace
827 * parameter specified.
828 *
829 * dataSpace specifies additional information about the buffer that's dependent
830 * on the buffer format and the endpoints. For example, it can be used to convey
831 * the color space of the image data in the buffer, or it can be used to
832 * indicate that the buffers contain depth measurement data instead of color
833 * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
834 * overridden by the consumer.
835 */
836static inline int native_window_set_buffers_data_space(
837 struct ANativeWindow* window,
838 android_dataspace_t dataSpace)
839{
840 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,
841 dataSpace);
842}
843
844/*
845 * native_window_set_buffers_transform(..., int transform)
846 * All buffers queued after this call will be displayed transformed according
847 * to the transform parameter specified.
848 */
849static inline int native_window_set_buffers_transform(
850 struct ANativeWindow* window,
851 int transform)
852{
853 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
854 transform);
855}
856
857/*
858 * native_window_set_buffers_sticky_transform(..., int transform)
859 * All buffers queued after this call will be displayed transformed according
860 * to the transform parameter specified applied on top of the regular buffer
861 * transform. Setting this transform will disable the transform hint.
862 *
863 * Temporary - This is only intended to be used by the LEGACY camera mode, do
864 * not use this for anything else.
865 */
866static inline int native_window_set_buffers_sticky_transform(
867 struct ANativeWindow* window,
868 int transform)
869{
870 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,
871 transform);
872}
873
874/*
875 * native_window_set_buffers_timestamp(..., int64_t timestamp)
876 * All buffers queued after this call will be associated with the timestamp
877 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
878 * (the default), timestamps will be generated automatically when queueBuffer is
879 * called. The timestamp is measured in nanoseconds, and is normally monotonically
880 * increasing. The timestamp should be unaffected by time-of-day adjustments,
881 * and for a camera should be strictly monotonic but for a media player may be
882 * reset when the position is set.
883 */
884static inline int native_window_set_buffers_timestamp(
885 struct ANativeWindow* window,
886 int64_t timestamp)
887{
888 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
889 timestamp);
890}
891
892/*
893 * native_window_set_scaling_mode(..., int mode)
894 * All buffers queued after this call will be associated with the scaling mode
895 * specified.
896 */
897static inline int native_window_set_scaling_mode(
898 struct ANativeWindow* window,
899 int mode)
900{
901 return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
902 mode);
903}
904
905/*
906 * native_window_api_connect(..., int api)
907 * connects an API to this window. only one API can be connected at a time.
908 * Returns -EINVAL if for some reason the window cannot be connected, which
909 * can happen if it's connected to some other API.
910 */
911static inline int native_window_api_connect(
912 struct ANativeWindow* window, int api)
913{
914 return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
915}
916
917/*
918 * native_window_api_disconnect(..., int api)
919 * disconnect the API from this window.
920 * An error is returned if for instance the window wasn't connected in the
921 * first place.
922 */
923static inline int native_window_api_disconnect(
924 struct ANativeWindow* window, int api)
925{
926 return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
927}
928
929/*
930 * native_window_dequeue_buffer_and_wait(...)
931 * Dequeue a buffer and wait on the fence associated with that buffer. The
932 * buffer may safely be accessed immediately upon this function returning. An
933 * error is returned if either of the dequeue or the wait operations fail.
934 */
935static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,
936 struct ANativeWindowBuffer** anb) {
937 return anw->dequeueBuffer_DEPRECATED(anw, anb);
938}
939
940/*
941 * native_window_set_sideband_stream(..., native_handle_t*)
942 * Attach a sideband buffer stream to a native window.
943 */
944static inline int native_window_set_sideband_stream(
945 struct ANativeWindow* window,
946 native_handle_t* sidebandHandle)
947{
948 return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,
949 sidebandHandle);
950}
951
952/*
953 * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
954 * Set the surface damage (i.e., the region of the surface that has changed
955 * since the previous frame). The damage set by this call will be reset (to the
956 * default of full-surface damage) after calling queue, so this must be called
957 * prior to every frame with damage that does not cover the whole surface if the
958 * caller desires downstream consumers to use this optimization.
959 *
960 * The damage region is specified as an array of rectangles, with the important
961 * caveat that the origin of the surface is considered to be the bottom-left
962 * corner, as in OpenGL ES.
963 *
964 * If numRects is set to 0, rects may be NULL, and the surface damage will be
965 * set to the full surface (the same as if this function had not been called for
966 * this frame).
967 */
968static inline int native_window_set_surface_damage(
969 struct ANativeWindow* window,
970 const android_native_rect_t* rects, size_t numRects)
971{
972 return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,
973 rects, numRects);
974}
975
976/*
977 * native_window_set_shared_buffer_mode(..., bool sharedBufferMode)
978 * Enable/disable shared buffer mode
979 */
980static inline int native_window_set_shared_buffer_mode(
981 struct ANativeWindow* window,
982 bool sharedBufferMode)
983{
984 return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE,
985 sharedBufferMode);
986}
987
988/*
989 * native_window_set_auto_refresh(..., autoRefresh)
990 * Enable/disable auto refresh when in shared buffer mode
991 */
992static inline int native_window_set_auto_refresh(
993 struct ANativeWindow* window,
994 bool autoRefresh)
995{
996 return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh);
997}
998
999static inline int native_window_get_frame_timestamps(
1000 struct ANativeWindow* window, uint32_t framesAgo,
1001 int64_t* outPostedTime, int64_t* outAcquireTime,
1002 int64_t* outRefreshStartTime, int64_t* outGlCompositionDoneTime,
1003 int64_t* outDisplayRetireTime, int64_t* outReleaseTime)
1004{
1005 return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS,
1006 framesAgo, outPostedTime, outAcquireTime, outRefreshStartTime,
1007 outGlCompositionDoneTime, outDisplayRetireTime, outReleaseTime);
1008}
1009
1010
1011__END_DECLS
1012
1013#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */