<div dir="ltr"><div dir="ltr">Hi Laurent, thank you for the patch.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 27, 2021 at 10:02 AM Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com">laurent.pinchart@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Import the latest version of the Android headers from Chrome OS (commit<br>
a30340e77ec8 ("camera: Uprev Android camera headers")). This brings in<br>
the Camera HAL v3.5 support.<br>
<br>
The headers are imported verbatim, except for the addition of the SPDX<br>
headers.<br>
<br>
Signed-off-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>><br>
---<br>
.../libhardware/include/hardware/camera3.h | 215 +++-<br>
.../include/hardware/camera_common.h | 16 +-<br>
.../libhardware/include/hardware/fb.h | 2 +-<br>
.../libhardware/include/hardware/gralloc.h | 97 +-<br>
.../libhardware/include/hardware/hardware.h | 6 +<br>
.../core/include/cutils/native_handle.h | 36 +<br>
.../system/core/include/system/camera.h | 9 +<br>
.../system/core/include/system/graphics.h | 793 +++------------<br>
.../system/core/include/system/window.h | 955 ------------------<br>
9 files changed, 469 insertions(+), 1660 deletions(-)<br>
delete mode 100644 include/android/system/core/include/system/window.h<br></blockquote><div><br></div><div>I confirmed no difference in headers between libcamera and ChromeOS after this patch.</div><div>I would wait for Jacopo's review.</div><div><br></div><div>Reviewed-by: Hirokazu Honda <<a href="mailto:hiroh@chromium.org">hiroh@chromium.org</a>></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
Compile-tested only for now.<br>
<br>
diff --git a/include/android/hardware/libhardware/include/hardware/camera3.h b/include/android/hardware/libhardware/include/hardware/camera3.h<br>
index d89bc9304b00..fd1e2072ad20 100644<br>
--- a/include/android/hardware/libhardware/include/hardware/camera3.h<br>
+++ b/include/android/hardware/libhardware/include/hardware/camera3.h<br>
@@ -1,6 +1,6 @@<br>
/* SPDX-License-Identifier: Apache-2.0 */<br>
/*<br>
- * Copyright (C) 2013 The Android Open Source Project<br>
+ * Copyright (C) 2013-2018 The Android Open Source Project<br>
*<br>
* Licensed under the Apache License, Version 2.0 (the "License");<br>
* you may not use this file except in compliance with the License.<br>
@@ -22,21 +22,21 @@<br>
#include "camera_common.h"<br>
<br>
/**<br>
- * Camera device HAL 3.3 [ CAMERA_DEVICE_API_VERSION_3_3 ]<br>
+ * Camera device HAL 3.5[ CAMERA_DEVICE_API_VERSION_3_5 ]<br>
*<br>
* This is the current recommended version of the camera device HAL.<br>
*<br>
* Supports the android.hardware.Camera API, and as of v3.2, the<br>
- * android.hardware.camera2 API in LIMITED or FULL modes.<br>
+ * android.hardware.camera2 API as LIMITED or above hardware level.<br>
*<br>
* Camera devices that support this version of the HAL must return<br>
- * CAMERA_DEVICE_API_VERSION_3_3 in camera_device_t.common.version and in<br>
+ * CAMERA_DEVICE_API_VERSION_3_5 in camera_device_t.common.version and in<br>
* camera_info_t.device_version (from camera_module_t.get_camera_info).<br>
*<br>
- * CAMERA_DEVICE_API_VERSION_3_3:<br>
- * Camera modules that may contain version 3.3 devices must implement at<br>
- * least version 2.2 of the camera module interface (as defined by<br>
- * camera_module_t.common.module_api_version).<br>
+ * CAMERA_DEVICE_API_VERSION_3_3 and above:<br>
+ * Camera modules that may contain version 3.3 or above devices must<br>
+ * implement at least version 2.2 of the camera module interface (as defined<br>
+ * by camera_module_t.common.module_api_version).<br>
*<br>
* CAMERA_DEVICE_API_VERSION_3_2:<br>
* Camera modules that may contain version 3.2 devices must implement at<br>
@@ -138,6 +138,52 @@<br>
*<br>
* - Addition of camera3 stream configuration operation mode to camera3_stream_configuration_t<br>
*<br>
+ * 3.4: Minor additions to supported metadata and changes to data_space support<br>
+ *<br>
+ * - Add ANDROID_SENSOR_OPAQUE_RAW_SIZE static metadata as mandatory if<br>
+ * RAW_OPAQUE format is supported.<br>
+ *<br>
+ * - Add ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE static metadata as<br>
+ * mandatory if any RAW format is supported<br>
+ *<br>
+ * - Switch camera3_stream_t data_space field to a more flexible definition,<br>
+ * using the version 0 definition of dataspace encoding.<br>
+ *<br>
+ * - General metadata additions which are available to use for HALv3.2 or<br>
+ * newer:<br>
+ * - ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3<br>
+ * - ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST<br>
+ * - ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE<br>
+ * - ANDROID_SENSOR_DYNAMIC_BLACK_LEVEL<br>
+ * - ANDROID_SENSOR_DYNAMIC_WHITE_LEVEL<br>
+ * - ANDROID_SENSOR_OPAQUE_RAW_SIZE<br>
+ * - ANDROID_SENSOR_OPTICAL_BLACK_REGIONS<br>
+ *<br>
+ * 3.5: Minor revisions to support session parameters and logical multi camera:<br>
+ *<br>
+ * - Add ANDROID_REQUEST_AVAILABLE_SESSION_KEYS static metadata, which is<br>
+ * optional for implementations that want to support session parameters. If support is<br>
+ * needed, then Hal should populate the list with all available capture request keys<br>
+ * that can cause severe processing delays when modified by client. Typical examples<br>
+ * include parameters that require time-consuming HW re-configuration or internal camera<br>
+ * pipeline update.<br>
+ *<br>
+ * - Add a session parameter field to camera3_stream_configuration which can be populated<br>
+ * by clients with initial values for the keys found in ANDROID_REQUEST_AVAILABLE_SESSION_KEYS.<br>
+ *<br>
+ * - Metadata additions for logical multi camera capability:<br>
+ * - ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA<br>
+ * - ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS<br>
+ * - ANDROID_LOGICAL_MULTI_CAMERA_SYNC_TYPE<br>
+ *<br>
+ * - Add physical camera id field in camera3_stream, so that for a logical<br>
+ * multi camera, the application has the option to specify which physical camera<br>
+ * a particular stream is configured on.<br>
+ *<br>
+ * - Add physical camera id and settings field in camera3_capture_request, so that<br>
+ * for a logical multi camera, the application has the option to specify individual<br>
+ * settings for a particular physical device.<br>
+ *<br>
*/<br>
<br>
/**<br>
@@ -1460,6 +1506,13 @@ typedef enum camera3_stream_configuration_mode {<br>
* android.lens.opticalStabilizationMode (if it is supported)<br>
* android.scaler.cropRegion<br>
* android.statistics.faceDetectMode (if it is supported)<br>
+ * 6. To reduce the amount of data passed across process boundaries at<br>
+ * high frame rate, within one batch, camera framework only propagates<br>
+ * the last shutter notify and the last capture results (including partial<br>
+ * results and final result) to the app. The shutter notifies and capture<br>
+ * results for the other requests in the batch are derived by<br>
+ * the camera framework. As a result, the HAL can return empty metadata<br>
+ * except for the last result in the batch.<br>
*<br>
* For more details about high speed stream requirements, see<br>
* android.control.availableHighSpeedVideoConfigurations and CONSTRAINED_HIGH_SPEED_VIDEO<br>
@@ -1578,6 +1631,13 @@ typedef struct camera3_stream {<br>
* value of this is 0.<br>
* For all streams passed via configure_streams(), the HAL must write<br>
* over this field with its usage flags.<br>
+ *<br>
+ * From Android O, the usage flag for an output stream may be bitwise<br>
+ * combination of usage flags for multiple consumers, for the purpose of<br>
+ * sharing one camera stream between those consumers. The HAL must fail<br>
+ * configure_streams call with -EINVAL if the combined flags cannot be<br>
+ * supported due to imcompatible buffer format, dataSpace, or other hardware<br>
+ * limitations.<br>
*/<br>
uint32_t usage;<br>
<br>
@@ -1612,11 +1672,19 @@ typedef struct camera3_stream {<br>
* be HAL_DATASPACE_UNKNOWN, and the appropriate color space, etc, should<br>
* be determined from the usage flags and the format.<br>
*<br>
- * >= CAMERA_DEVICE_API_VERSION_3_3:<br>
+ * = CAMERA_DEVICE_API_VERSION_3_3:<br>
*<br>
* Always set by the camera service. HAL must use this dataSpace to<br>
* configure the stream to the correct colorspace, or to select between<br>
- * color and depth outputs if supported.<br>
+ * color and depth outputs if supported. The dataspace values are the<br>
+ * legacy definitions in graphics.h<br>
+ *<br>
+ * >= CAMERA_DEVICE_API_VERSION_3_4:<br>
+ *<br>
+ * Always set by the camera service. HAL must use this dataSpace to<br>
+ * configure the stream to the correct colorspace, or to select between<br>
+ * color and depth outputs if supported. The dataspace values are set<br>
+ * using the V0 dataspace definitions in graphics.h<br>
*/<br>
android_dataspace_t data_space;<br>
<br>
@@ -1646,6 +1714,29 @@ typedef struct camera3_stream {<br>
*/<br>
int rotation;<br>
<br>
+ /**<br>
+ * The physical camera id this stream belongs to.<br>
+ *<br>
+ * <= CAMERA_DEVICE_API_VERISON_3_4:<br>
+ *<br>
+ * Not defined and must not be accessed.<br>
+ *<br>
+ * >= CAMERA_DEVICE_API_VERISON_3_5:<br>
+ *<br>
+ * Always set by camera service. If the camera device is not a logical<br>
+ * multi camera, or if the camera is a logical multi camera but the stream<br>
+ * is not a physical output stream, this field will point to a 0-length<br>
+ * string.<br>
+ *<br>
+ * A logical multi camera is a camera device backed by multiple physical<br>
+ * cameras that are also exposed to the application. And for a logical<br>
+ * multi camera, a physical output stream is an output stream specifically<br>
+ * requested on an underlying physical camera.<br>
+ *<br>
+ * For an input stream, this field is guaranteed to be a 0-length string.<br>
+ */<br>
+ const char* physical_camera_id;<br>
+<br>
/**<br>
* This should be one of the camera3_stream_rotation_t values except for<br>
* CAMERA3_STREAM_ROTATION_180.<br>
@@ -1663,7 +1754,7 @@ typedef struct camera3_stream {<br>
int crop_rotate_scale_degrees;<br>
<br>
/* reserved for future use */<br>
- void *reserved[6];<br>
+ void *reserved[5];<br>
<br>
} camera3_stream_t;<br>
<br>
@@ -1697,16 +1788,30 @@ typedef struct camera3_stream_configuration {<br>
/**<br>
* >= CAMERA_DEVICE_API_VERSION_3_3:<br>
*<br>
- * The operation mode of streams in this configuration, one of the value defined in<br>
- * camera3_stream_configuration_mode_t.<br>
- * The HAL can use this mode as an indicator to set the stream property (e.g.,<br>
- * camera3_stream->max_buffers) appropriately. For example, if the configuration is<br>
- * CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE, the HAL may want to set aside more<br>
- * buffers for batch mode operation (see android.control.availableHighSpeedVideoConfigurations<br>
- * for batch mode definition).<br>
+ * The operation mode of streams in this configuration, one of the value<br>
+ * defined in camera3_stream_configuration_mode_t. The HAL can use this<br>
+ * mode as an indicator to set the stream property (e.g.,<br>
+ * camera3_stream->max_buffers) appropriately. For example, if the<br>
+ * configuration is<br>
+ * CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE, the HAL may<br>
+ * want to set aside more buffers for batch mode operation (see<br>
+ * android.control.availableHighSpeedVideoConfigurations for batch mode<br>
+ * definition).<br>
*<br>
*/<br>
uint32_t operation_mode;<br>
+<br>
+ /**<br>
+ * >= CAMERA_DEVICE_API_VERSION_3_5:<br>
+ *<br>
+ * The session metadata buffer contains the initial values of<br>
+ * ANDROID_REQUEST_AVAILABLE_SESSION_KEYS. This field is optional<br>
+ * and camera clients can choose to ignore it, in which case it will<br>
+ * be set to NULL. If parameters are present, then Hal should examine<br>
+ * the parameter values and configure its internal camera pipeline<br>
+ * accordingly.<br>
+ */<br>
+ const camera_metadata_t *session_parameters;<br>
} camera3_stream_configuration_t;<br>
<br>
/**<br>
@@ -1950,7 +2055,7 @@ typedef enum camera3_error_msg_code {<br>
* available. Subsequent requests are unaffected, and the device remains<br>
* operational. The frame_number field specifies the request for which the<br>
* buffer was dropped, and error_stream contains a pointer to the stream<br>
- * that dropped the frame.u<br>
+ * that dropped the frame.<br>
*/<br>
CAMERA3_MSG_ERROR_BUFFER = 4,<br>
<br>
@@ -2190,6 +2295,44 @@ typedef struct camera3_capture_request {<br>
*/<br>
const camera3_stream_buffer_t *output_buffers;<br>
<br>
+ /**<br>
+ * <= CAMERA_DEVICE_API_VERISON_3_4:<br>
+ *<br>
+ * Not defined and must not be accessed.<br>
+ *<br>
+ * >= CAMERA_DEVICE_API_VERSION_3_5:<br>
+ * The number of physical camera settings to be applied. If 'num_physcam_settings'<br>
+ * equals 0 or a physical device is not included, then Hal must decide the<br>
+ * specific physical device settings based on the default 'settings'.<br>
+ */<br>
+ uint32_t num_physcam_settings;<br>
+<br>
+ /**<br>
+ * <= CAMERA_DEVICE_API_VERISON_3_4:<br>
+ *<br>
+ * Not defined and must not be accessed.<br>
+ *<br>
+ * >= CAMERA_DEVICE_API_VERSION_3_5:<br>
+ * The physical camera ids. The array will contain 'num_physcam_settings'<br>
+ * camera id strings for all physical devices that have specific settings.<br>
+ * In case some id is invalid, the process capture request must fail and return<br>
+ * -EINVAL.<br>
+ */<br>
+ const char **physcam_id;<br>
+<br>
+ /**<br>
+ * <= CAMERA_DEVICE_API_VERISON_3_4:<br>
+ *<br>
+ * Not defined and must not be accessed.<br>
+ *<br>
+ * >= CAMERA_DEVICE_API_VERSION_3_5:<br>
+ * The capture settings for the physical cameras. The array will contain<br>
+ * 'num_physcam_settings' settings for invididual physical devices. In<br>
+ * case the settings at some particular index are empty, the process capture<br>
+ * request must fail and return -EINVAL.<br>
+ */<br>
+ const camera_metadata_t **physcam_settings;<br>
+<br>
} camera3_capture_request_t;<br>
<br>
/**<br>
@@ -2367,6 +2510,37 @@ typedef struct camera3_capture_result {<br>
*/<br>
uint32_t partial_result;<br>
<br>
+ /**<br>
+ * >= CAMERA_DEVICE_API_VERSION_3_5:<br>
+ *<br>
+ * Specifies the number of physical camera metadata this capture result<br>
+ * contains. It must be equal to the number of physical cameras being<br>
+ * requested from.<br>
+ *<br>
+ * If the current camera device is not a logical multi-camera, or the<br>
+ * corresponding capture_request doesn't request on any physical camera,<br>
+ * this field must be 0.<br>
+ */<br>
+ uint32_t num_physcam_metadata;<br>
+<br>
+ /**<br>
+ * >= CAMERA_DEVICE_API_VERSION_3_5:<br>
+ *<br>
+ * An array of strings containing the physical camera ids for the returned<br>
+ * physical camera metadata. The length of the array is<br>
+ * num_physcam_metadata.<br>
+ */<br>
+ const char **physcam_ids;<br>
+<br>
+ /**<br>
+ * >= CAMERA_DEVICE_API_VERSION_3_5:<br>
+ *<br>
+ * The array of physical camera metadata for the physical cameras being<br>
+ * requested upon. This array should have a 1-to-1 mapping with the<br>
+ * physcam_ids. The length of the array is num_physcam_metadata.<br>
+ */<br>
+ const camera_metadata_t **physcam_metadata;<br>
+<br>
} camera3_capture_result_t;<br>
<br>
/**********************************************************************<br>
@@ -2899,7 +3073,8 @@ typedef struct camera3_device_ops {<br>
* 0: On a successful start to processing the capture request<br>
*<br>
* -EINVAL: If the input is malformed (the settings are NULL when not<br>
- * allowed, there are 0 output buffers, etc) and capture processing<br>
+ * allowed, invalid physical camera settings,<br>
+ * there are 0 output buffers, etc) and capture processing<br>
* cannot start. Failures during request processing should be<br>
* handled by calling camera3_callback_ops_t.notify(). In case of<br>
* this error, the framework will retain responsibility for the<br>
diff --git a/include/android/hardware/libhardware/include/hardware/camera_common.h b/include/android/hardware/libhardware/include/hardware/camera_common.h<br>
index 26df06987030..5c9bc06fe0b7 100644<br>
--- a/include/android/hardware/libhardware/include/hardware/camera_common.h<br>
+++ b/include/android/hardware/libhardware/include/hardware/camera_common.h<br>
@@ -141,17 +141,19 @@ __BEGIN_DECLS<br>
* All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated<br>
* as CAMERA_DEVICE_API_VERSION_1_0<br>
*/<br>
-#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)<br>
-#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)<br>
-#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1)<br>
-#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0)<br>
-#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1)<br>
+#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) // DEPRECATED<br>
+#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) // NO LONGER SUPPORTED<br>
+#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) // NO LONGER SUPPORTED<br>
+#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) // NO LONGER SUPPORTED<br>
+#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) // NO LONGER SUPPORTED<br>
#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2)<br>
#define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3)<br>
+#define CAMERA_DEVICE_API_VERSION_3_4 HARDWARE_DEVICE_API_VERSION(3, 4)<br>
+#define CAMERA_DEVICE_API_VERSION_3_5 HARDWARE_DEVICE_API_VERSION(3, 5)<br>
<br>
-// Device version 3.3 is current, older HAL camera device versions are not<br>
+// Device version 3.5 is current, older HAL camera device versions are not<br>
// recommended for new devices.<br>
-#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_3<br>
+#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_5<br>
<br>
/**<br>
* Defined in /system/media/camera/include/system/camera_metadata.h<br>
diff --git a/include/android/hardware/libhardware/include/hardware/fb.h b/include/android/hardware/libhardware/include/hardware/fb.h<br>
index 9ea9a6e60f05..2d9153aed00b 100644<br>
--- a/include/android/hardware/libhardware/include/hardware/fb.h<br>
+++ b/include/android/hardware/libhardware/include/hardware/fb.h<br>
@@ -161,7 +161,7 @@ typedef struct framebuffer_device_t {<br>
static inline int framebuffer_open(const struct hw_module_t* module,<br>
struct framebuffer_device_t** device) {<br>
return module->methods->open(module,<br>
- GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device);<br>
+ GRALLOC_HARDWARE_FB0, TO_HW_DEVICE_T_OPEN(device));<br>
}<br>
<br>
static inline int framebuffer_close(struct framebuffer_device_t* device) {<br>
diff --git a/include/android/hardware/libhardware/include/hardware/gralloc.h b/include/android/hardware/libhardware/include/hardware/gralloc.h<br>
index 80da4cb8e16b..01a7672747a4 100644<br>
--- a/include/android/hardware/libhardware/include/hardware/gralloc.h<br>
+++ b/include/android/hardware/libhardware/include/hardware/gralloc.h<br>
@@ -19,9 +19,8 @@<br>
#ifndef ANDROID_GRALLOC_INTERFACE_H<br>
#define ANDROID_GRALLOC_INTERFACE_H<br>
<br>
-#include <system/window.h><br>
+#include <hardware/hardware.h><br>
#include <system/graphics.h><br>
-#include <hardware/hardware.h><br>
<br>
#include <stdint.h><br>
#include <sys/cdefs.h><br>
@@ -29,8 +28,8 @@<br>
<br>
#include <cutils/native_handle.h><br>
<br>
-#include <hardware/hardware.h><br>
#include <hardware/fb.h><br>
+#include <hardware/hardware.h><br>
<br>
__BEGIN_DECLS<br>
<br>
@@ -69,69 +68,69 @@ __BEGIN_DECLS<br>
<br>
enum {<br>
/* buffer is never read in software */<br>
- GRALLOC_USAGE_SW_READ_NEVER = 0x00000000,<br>
+ GRALLOC_USAGE_SW_READ_NEVER = 0x00000000U,<br>
/* buffer is rarely read in software */<br>
- GRALLOC_USAGE_SW_READ_RARELY = 0x00000002,<br>
+ GRALLOC_USAGE_SW_READ_RARELY = 0x00000002U,<br>
/* buffer is often read in software */<br>
- GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003,<br>
+ GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003U,<br>
/* mask for the software read values */<br>
- GRALLOC_USAGE_SW_READ_MASK = 0x0000000F,<br>
+ GRALLOC_USAGE_SW_READ_MASK = 0x0000000FU,<br>
<br>
/* buffer is never written in software */<br>
- GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000,<br>
+ GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000U,<br>
/* buffer is rarely written in software */<br>
- GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020,<br>
+ GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020U,<br>
/* buffer is often written in software */<br>
- GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030,<br>
+ GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030U,<br>
/* mask for the software write values */<br>
- GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0,<br>
+ GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0U,<br>
<br>
/* buffer will be used as an OpenGL ES texture */<br>
- GRALLOC_USAGE_HW_TEXTURE = 0x00000100,<br>
+ GRALLOC_USAGE_HW_TEXTURE = 0x00000100U,<br>
/* buffer will be used as an OpenGL ES render target */<br>
- GRALLOC_USAGE_HW_RENDER = 0x00000200,<br>
+ GRALLOC_USAGE_HW_RENDER = 0x00000200U,<br>
/* buffer will be used by the 2D hardware blitter */<br>
- GRALLOC_USAGE_HW_2D = 0x00000400,<br>
+ GRALLOC_USAGE_HW_2D = 0x00000400U,<br>
/* buffer will be used by the HWComposer HAL module */<br>
- GRALLOC_USAGE_HW_COMPOSER = 0x00000800,<br>
+ GRALLOC_USAGE_HW_COMPOSER = 0x00000800U,<br>
/* buffer will be used with the framebuffer device */<br>
- GRALLOC_USAGE_HW_FB = 0x00001000,<br>
+ GRALLOC_USAGE_HW_FB = 0x00001000U,<br>
<br>
/* buffer should be displayed full-screen on an external display when<br>
* possible */<br>
- GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000,<br>
+ GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000U,<br>
<br>
/* Must have a hardware-protected path to external display sink for<br>
* this buffer. If a hardware-protected path is not available, then<br>
* either don't composite only this buffer (preferred) to the<br>
* external sink, or (less desirable) do not route the entire<br>
* composition to the external sink. */<br>
- GRALLOC_USAGE_PROTECTED = 0x00004000,<br>
+ GRALLOC_USAGE_PROTECTED = 0x00004000U,<br>
<br>
/* buffer may be used as a cursor */<br>
- GRALLOC_USAGE_CURSOR = 0x00008000,<br>
+ GRALLOC_USAGE_CURSOR = 0x00008000U,<br>
<br>
/* buffer will be used with the HW video encoder */<br>
- GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000,<br>
+ GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000U,<br>
/* buffer will be written by the HW camera pipeline */<br>
- GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000,<br>
+ GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000U,<br>
/* buffer will be read by the HW camera pipeline */<br>
- GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000,<br>
+ GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000U,<br>
/* buffer will be used as part of zero-shutter-lag queue */<br>
- GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000,<br>
+ GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000U,<br>
/* mask for the camera access values */<br>
- GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000,<br>
+ GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000U,<br>
/* mask for the software usage bit-mask */<br>
- GRALLOC_USAGE_HW_MASK = 0x00071F00,<br>
+ GRALLOC_USAGE_HW_MASK = 0x00071F00U,<br>
<br>
/* buffer will be used as a RenderScript Allocation */<br>
- GRALLOC_USAGE_RENDERSCRIPT = 0x00100000,<br>
+ GRALLOC_USAGE_RENDERSCRIPT = 0x00100000U,<br>
<br>
/* Set by the consumer to indicate to the producer that they may attach a<br>
* buffer that they did not detach from the BufferQueue. Will be filtered<br>
* out by GRALLOC_USAGE_ALLOC_MASK, so gralloc modules will not need to<br>
* handle this flag. */<br>
- GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000,<br>
+ GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000U,<br>
<br>
/* Mask of all flags which could be passed to a gralloc module for buffer<br>
* allocation. Any flags not in this mask do not need to be handled by<br>
@@ -139,11 +138,11 @@ enum {<br>
GRALLOC_USAGE_ALLOC_MASK = ~(GRALLOC_USAGE_FOREIGN_BUFFERS),<br>
<br>
/* implementation-specific private usage flags */<br>
- GRALLOC_USAGE_PRIVATE_0 = 0x10000000,<br>
- GRALLOC_USAGE_PRIVATE_1 = 0x20000000,<br>
- GRALLOC_USAGE_PRIVATE_2 = 0x40000000,<br>
- GRALLOC_USAGE_PRIVATE_3 = 0x80000000,<br>
- GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000,<br>
+ GRALLOC_USAGE_PRIVATE_0 = 0x10000000U,<br>
+ GRALLOC_USAGE_PRIVATE_1 = 0x20000000U,<br>
+ GRALLOC_USAGE_PRIVATE_2 = 0x40000000U,<br>
+ GRALLOC_USAGE_PRIVATE_3 = 0x80000000U,<br>
+ GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000U,<br>
};<br>
<br>
/*****************************************************************************/<br>
@@ -373,13 +372,45 @@ typedef struct alloc_device_t {<br>
static inline int gralloc_open(const struct hw_module_t* module, <br>
struct alloc_device_t** device) {<br>
return module->methods->open(module, <br>
- GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device);<br>
+ GRALLOC_HARDWARE_GPU0, TO_HW_DEVICE_T_OPEN(device));<br>
}<br>
<br>
static inline int gralloc_close(struct alloc_device_t* device) {<br>
return device->common.close(&device->common);<br>
}<br>
<br>
+/**<br>
+ * map_usage_to_memtrack should be called after allocating a gralloc buffer.<br>
+ *<br>
+ * @param usage - it is the flag used when alloc function is called.<br>
+ *<br>
+ * This function maps the gralloc usage flags to appropriate memtrack bucket.<br>
+ * GrallocHAL implementers and users should make an additional ION_IOCTL_TAG<br>
+ * call using the memtrack tag returned by this function. This will help the<br>
+ * in-kernel memtack to categorize the memory allocated by different processes<br>
+ * according to their usage.<br>
+ *<br>
+ */<br>
+static inline const char* map_usage_to_memtrack(uint32_t usage) {<br>
+ usage &= GRALLOC_USAGE_ALLOC_MASK;<br>
+<br>
+ if ((usage & GRALLOC_USAGE_HW_CAMERA_WRITE) != 0) {<br>
+ return "camera";<br>
+ } else if ((usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) != 0 ||<br>
+ (usage & GRALLOC_USAGE_EXTERNAL_DISP) != 0) {<br>
+ return "video";<br>
+ } else if ((usage & GRALLOC_USAGE_HW_RENDER) != 0 ||<br>
+ (usage & GRALLOC_USAGE_HW_TEXTURE) != 0) {<br>
+ return "gl";<br>
+ } else if ((usage & GRALLOC_USAGE_HW_CAMERA_READ) != 0) {<br>
+ return "camera";<br>
+ } else if ((usage & GRALLOC_USAGE_SW_READ_MASK) != 0 ||<br>
+ (usage & GRALLOC_USAGE_SW_WRITE_MASK) != 0) {<br>
+ return "cpu";<br>
+ }<br>
+ return "graphics";<br>
+}<br>
+<br>
__END_DECLS<br>
<br>
#endif // ANDROID_GRALLOC_INTERFACE_H<br>
diff --git a/include/android/hardware/libhardware/include/hardware/hardware.h b/include/android/hardware/libhardware/include/hardware/hardware.h<br>
index 10b73df7150a..8919f1204cde 100644<br>
--- a/include/android/hardware/libhardware/include/hardware/hardware.h<br>
+++ b/include/android/hardware/libhardware/include/hardware/hardware.h<br>
@@ -202,6 +202,12 @@ typedef struct hw_device_t {<br>
<br>
} hw_device_t;<br>
<br>
+#ifdef __cplusplus<br>
+#define TO_HW_DEVICE_T_OPEN(x) reinterpret_cast<struct hw_device_t**>(x)<br>
+#else<br>
+#define TO_HW_DEVICE_T_OPEN(x) (struct hw_device_t**)(x)<br>
+#endif<br>
+<br>
/**<br>
* Name of the hal_module_info<br>
*/<br>
diff --git a/include/android/system/core/include/cutils/native_handle.h b/include/android/system/core/include/cutils/native_handle.h<br>
index edd7888fe284..dbd37672f040 100644<br>
--- a/include/android/system/core/include/cutils/native_handle.h<br>
+++ b/include/android/system/core/include/cutils/native_handle.h<br>
@@ -18,18 +18,37 @@<br>
#ifndef NATIVE_HANDLE_H_<br>
#define NATIVE_HANDLE_H_<br>
<br>
+#include <stdalign.h><br>
+<br>
#ifdef __cplusplus<br>
extern "C" {<br>
#endif<br>
<br>
+#define NATIVE_HANDLE_MAX_FDS 1024<br>
+#define NATIVE_HANDLE_MAX_INTS 1024<br>
+<br>
+/* Declare a char array for use with native_handle_init */<br>
+#define NATIVE_HANDLE_DECLARE_STORAGE(name, maxFds, maxInts) \<br>
+ alignas(native_handle_t) char (name)[ \<br>
+ sizeof(native_handle_t) + sizeof(int) * ((maxFds) + (maxInts))]<br>
+<br>
typedef struct native_handle<br>
{<br>
int version; /* sizeof(native_handle_t) */<br>
int numFds; /* number of file-descriptors at &data[0] */<br>
int numInts; /* number of ints at &data[numFds] */<br>
+#if defined(__clang__)<br>
+#pragma clang diagnostic push<br>
+#pragma clang diagnostic ignored "-Wzero-length-array"<br>
+#endif<br>
int data[0]; /* numFds + numInts ints */<br>
+#if defined(__clang__)<br>
+#pragma clang diagnostic pop<br>
+#endif<br>
} native_handle_t;<br>
<br>
+typedef const native_handle_t* buffer_handle_t;<br>
+<br>
/*<br>
* native_handle_close<br>
* <br>
@@ -40,6 +59,14 @@ typedef struct native_handle<br>
*/<br>
int native_handle_close(const native_handle_t* h);<br>
<br>
+/*<br>
+ * native_handle_init<br>
+ *<br>
+ * Initializes a native_handle_t from storage. storage must be declared with<br>
+ * NATIVE_HANDLE_DECLARE_STORAGE. numFds and numInts must not respectively<br>
+ * exceed maxFds and maxInts used to declare the storage.<br>
+ */<br>
+native_handle_t* native_handle_init(char* storage, int numFds, int numInts);<br>
<br>
/*<br>
* native_handle_create<br>
@@ -50,6 +77,15 @@ int native_handle_close(const native_handle_t* h);<br>
*/<br>
native_handle_t* native_handle_create(int numFds, int numInts);<br>
<br>
+/*<br>
+ * native_handle_clone<br>
+ *<br>
+ * creates a native_handle_t and initializes it from another native_handle_t.<br>
+ * Must be destroyed with native_handle_delete().<br>
+ *<br>
+ */<br>
+native_handle_t* native_handle_clone(const native_handle_t* handle);<br>
+<br>
/*<br>
* native_handle_delete<br>
* <br>
diff --git a/include/android/system/core/include/system/camera.h b/include/android/system/core/include/system/camera.h<br>
index a1b68d054d93..9d69588f9829 100644<br>
--- a/include/android/system/core/include/system/camera.h<br>
+++ b/include/android/system/core/include/system/camera.h<br>
@@ -204,6 +204,15 @@ enum {<br>
* (except disconnect and sending CAMERA_CMD_PING) after getting this.<br>
*/<br>
CAMERA_ERROR_RELEASED = 2,<br>
+<br>
+ /**<br>
+ * Camera was released because device policy change or the client application<br>
+ * is going to background. The client should call Camera::disconnect<br>
+ * immediately after getting this notification. Otherwise, the camera will be<br>
+ * released by camera service in a short time. The client should not call any<br>
+ * method (except disconnect and sending CAMERA_CMD_PING) after getting this.<br>
+ */<br>
+ CAMERA_ERROR_DISABLED = 3,<br>
CAMERA_ERROR_SERVER_DIED = 100<br>
};<br>
<br>
diff --git a/include/android/system/core/include/system/graphics.h b/include/android/system/core/include/system/graphics.h<br>
index 909ffe68e78b..6341e642d57c 100644<br>
--- a/include/android/system/core/include/system/graphics.h<br>
+++ b/include/android/system/core/include/system/graphics.h<br>
@@ -18,12 +18,32 @@<br>
#ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H<br>
#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H<br>
<br>
+#include <stddef.h><br>
#include <stdint.h><br>
<br>
+/*<br>
+ * Some of the enums are now defined in HIDL in hardware/interfaces and are<br>
+ * generated.<br>
+ */<br>
+#include "graphics-base.h"<br>
+#include "graphics-sw.h"<br>
+<br>
#ifdef __cplusplus<br>
extern "C" {<br>
#endif<br>
<br>
+/* for compatibility */<br>
+#define HAL_PIXEL_FORMAT_YCbCr_420_888 HAL_PIXEL_FORMAT_YCBCR_420_888<br>
+#define HAL_PIXEL_FORMAT_YCbCr_422_SP HAL_PIXEL_FORMAT_YCBCR_422_SP<br>
+#define HAL_PIXEL_FORMAT_YCrCb_420_SP HAL_PIXEL_FORMAT_YCRCB_420_SP<br>
+#define HAL_PIXEL_FORMAT_YCbCr_422_I HAL_PIXEL_FORMAT_YCBCR_422_I<br>
+typedef android_pixel_format_t android_pixel_format;<br>
+typedef android_transform_t android_transform;<br>
+typedef android_dataspace_t android_dataspace;<br>
+typedef android_color_mode_t android_color_mode;<br>
+typedef android_color_transform_t android_color_transform;<br>
+typedef android_hdr_t android_hdr;<br>
+<br>
/*<br>
* If the HAL needs to create service threads to handle graphics related<br>
* tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority<br>
@@ -38,411 +58,6 @@ extern "C" {<br>
<br>
#define HAL_PRIORITY_URGENT_DISPLAY (-8)<br>
<br>
-/**<br>
- * pixel format definitions<br>
- */<br>
-<br>
-enum {<br>
- /*<br>
- * "linear" color pixel formats:<br>
- *<br>
- * When used with ANativeWindow, the dataSpace field describes the color<br>
- * space of the buffer.<br>
- *<br>
- * The color space determines, for example, if the formats are linear or<br>
- * gamma-corrected; or whether any special operations are performed when<br>
- * reading or writing into a buffer in one of these formats.<br>
- */<br>
- HAL_PIXEL_FORMAT_RGBA_8888 = 1,<br>
- HAL_PIXEL_FORMAT_RGBX_8888 = 2,<br>
- HAL_PIXEL_FORMAT_RGB_888 = 3,<br>
- HAL_PIXEL_FORMAT_RGB_565 = 4,<br>
- HAL_PIXEL_FORMAT_BGRA_8888 = 5,<br>
-<br>
- /*<br>
- * 0x100 - 0x1FF<br>
- *<br>
- * This range is reserved for pixel formats that are specific to the HAL<br>
- * implementation. Implementations can use any value in this range to<br>
- * communicate video pixel formats between their HAL modules. These formats<br>
- * must not have an alpha channel. Additionally, an EGLimage created from a<br>
- * gralloc buffer of one of these formats must be supported for use with the<br>
- * GL_OES_EGL_image_external OpenGL ES extension.<br>
- */<br>
-<br>
- /*<br>
- * Android YUV format:<br>
- *<br>
- * This format is exposed outside of the HAL to software decoders and<br>
- * applications. EGLImageKHR must support it in conjunction with the<br>
- * OES_EGL_image_external extension.<br>
- *<br>
- * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed<br>
- * by (W/2) x (H/2) Cr and Cb planes.<br>
- *<br>
- * This format assumes<br>
- * - an even width<br>
- * - an even height<br>
- * - a horizontal stride multiple of 16 pixels<br>
- * - a vertical stride equal to the height<br>
- *<br>
- * y_size = stride * height<br>
- * c_stride = ALIGN(stride/2, 16)<br>
- * c_size = c_stride * height/2<br>
- * size = y_size + c_size * 2<br>
- * cr_offset = y_size<br>
- * cb_offset = y_size + c_size<br>
- *<br>
- * When used with ANativeWindow, the dataSpace field describes the color<br>
- * space of the buffer.<br>
- */<br>
- HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar<br>
-<br>
-<br>
- /*<br>
- * Android Y8 format:<br>
- *<br>
- * This format is exposed outside of the HAL to the framework.<br>
- * The expected gralloc usage flags are SW_* and HW_CAMERA_*,<br>
- * and no other HW_ flags will be used.<br>
- *<br>
- * Y8 is a YUV planar format comprised of a WxH Y plane,<br>
- * with each pixel being represented by 8 bits.<br>
- *<br>
- * It is equivalent to just the Y plane from YV12.<br>
- *<br>
- * This format assumes<br>
- * - an even width<br>
- * - an even height<br>
- * - a horizontal stride multiple of 16 pixels<br>
- * - a vertical stride equal to the height<br>
- *<br>
- * size = stride * height<br>
- *<br>
- * When used with ANativeWindow, the dataSpace field describes the color<br>
- * space of the buffer.<br>
- */<br>
- HAL_PIXEL_FORMAT_Y8 = 0x20203859,<br>
-<br>
- /*<br>
- * Android Y16 format:<br>
- *<br>
- * This format is exposed outside of the HAL to the framework.<br>
- * The expected gralloc usage flags are SW_* and HW_CAMERA_*,<br>
- * and no other HW_ flags will be used.<br>
- *<br>
- * Y16 is a YUV planar format comprised of a WxH Y plane,<br>
- * with each pixel being represented by 16 bits.<br>
- *<br>
- * It is just like Y8, but has double the bits per pixel (little endian).<br>
- *<br>
- * This format assumes<br>
- * - an even width<br>
- * - an even height<br>
- * - a horizontal stride multiple of 16 pixels<br>
- * - a vertical stride equal to the height<br>
- * - strides are specified in pixels, not in bytes<br>
- *<br>
- * size = stride * height * 2<br>
- *<br>
- * When used with ANativeWindow, the dataSpace field describes the color<br>
- * space of the buffer, except that dataSpace field<br>
- * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth<br>
- * image where each sample is a distance value measured by a depth camera,<br>
- * plus an associated confidence value.<br>
- */<br>
- HAL_PIXEL_FORMAT_Y16 = 0x20363159,<br>
-<br>
- /*<br>
- * Android RAW sensor format:<br>
- *<br>
- * This format is exposed outside of the camera HAL to applications.<br>
- *<br>
- * RAW16 is a single-channel, 16-bit, little endian format, typically<br>
- * representing raw Bayer-pattern images from an image sensor, with minimal<br>
- * processing.<br>
- *<br>
- * The exact pixel layout of the data in the buffer is sensor-dependent, and<br>
- * needs to be queried from the camera device.<br>
- *<br>
- * Generally, not all 16 bits are used; more common values are 10 or 12<br>
- * bits. If not all bits are used, the lower-order bits are filled first.<br>
- * All parameters to interpret the raw data (black and white points,<br>
- * color space, etc) must be queried from the camera device.<br>
- *<br>
- * This format assumes<br>
- * - an even width<br>
- * - an even height<br>
- * - a horizontal stride multiple of 16 pixels<br>
- * - a vertical stride equal to the height<br>
- * - strides are specified in pixels, not in bytes<br>
- *<br>
- * size = stride * height * 2<br>
- *<br>
- * This format must be accepted by the gralloc module when used with the<br>
- * following usage flags:<br>
- * - GRALLOC_USAGE_HW_CAMERA_*<br>
- * - GRALLOC_USAGE_SW_*<br>
- * - GRALLOC_USAGE_RENDERSCRIPT<br>
- *<br>
- * When used with ANativeWindow, the dataSpace should be<br>
- * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial<br>
- * extra metadata to define.<br>
- */<br>
- HAL_PIXEL_FORMAT_RAW16 = 0x20,<br>
-<br>
- /*<br>
- * Android RAW10 format:<br>
- *<br>
- * This format is exposed outside of the camera HAL to applications.<br>
- *<br>
- * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row,<br>
- * unprocessed format, usually representing raw Bayer-pattern images coming from<br>
- * an image sensor.<br>
- *<br>
- * In an image buffer with this format, starting from the first pixel of each<br>
- * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one<br>
- * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte<br>
- * contains the 2 least significant bits of the 4 pixels, the exact layout data<br>
- * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth<br>
- * bit of the ith pixel):<br>
- *<br>
- * bit 7 bit 0<br>
- * =====|=====|=====|=====|=====|=====|=====|=====|<br>
- * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]|<br>
- * |-----|-----|-----|-----|-----|-----|-----|-----|<br>
- * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]|<br>
- * |-----|-----|-----|-----|-----|-----|-----|-----|<br>
- * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]|<br>
- * |-----|-----|-----|-----|-----|-----|-----|-----|<br>
- * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]|<br>
- * |-----|-----|-----|-----|-----|-----|-----|-----|<br>
- * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]|<br>
- * ===============================================<br>
- *<br>
- * This format assumes<br>
- * - a width multiple of 4 pixels<br>
- * - an even height<br>
- * - a vertical stride equal to the height<br>
- * - strides are specified in bytes, not in pixels<br>
- *<br>
- * size = stride * height<br>
- *<br>
- * When stride is equal to width * (10 / 8), there will be no padding bytes at<br>
- * the end of each row, the entire image data is densely packed. When stride is<br>
- * larger than width * (10 / 8), padding bytes will be present at the end of each<br>
- * row (including the last row).<br>
- *<br>
- * This format must be accepted by the gralloc module when used with the<br>
- * following usage flags:<br>
- * - GRALLOC_USAGE_HW_CAMERA_*<br>
- * - GRALLOC_USAGE_SW_*<br>
- * - GRALLOC_USAGE_RENDERSCRIPT<br>
- *<br>
- * When used with ANativeWindow, the dataSpace field should be<br>
- * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial<br>
- * extra metadata to define.<br>
- */<br>
- HAL_PIXEL_FORMAT_RAW10 = 0x25,<br>
-<br>
- /*<br>
- * Android RAW12 format:<br>
- *<br>
- * This format is exposed outside of camera HAL to applications.<br>
- *<br>
- * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row,<br>
- * unprocessed format, usually representing raw Bayer-pattern images coming from<br>
- * an image sensor.<br>
- *<br>
- * In an image buffer with this format, starting from the first pixel of each<br>
- * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first<br>
- * and second byte contains the top 8 bits of first and second pixel. The third<br>
- * byte contains the 4 least significant bits of the two pixels, the exact layout<br>
- * data for each two consecutive pixels is illustrated below (Pi[j] stands for<br>
- * the jth bit of the ith pixel):<br>
- *<br>
- * bit 7 bit 0<br>
- * ======|======|======|======|======|======|======|======|<br>
- * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]|<br>
- * |------|------|------|------|------|------|------|------|<br>
- * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]|<br>
- * |------|------|------|------|------|------|------|------|<br>
- * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]|<br>
- * =======================================================<br>
- *<br>
- * This format assumes:<br>
- * - a width multiple of 4 pixels<br>
- * - an even height<br>
- * - a vertical stride equal to the height<br>
- * - strides are specified in bytes, not in pixels<br>
- *<br>
- * size = stride * height<br>
- *<br>
- * When stride is equal to width * (12 / 8), there will be no padding bytes at<br>
- * the end of each row, the entire image data is densely packed. When stride is<br>
- * larger than width * (12 / 8), padding bytes will be present at the end of<br>
- * each row (including the last row).<br>
- *<br>
- * This format must be accepted by the gralloc module when used with the<br>
- * following usage flags:<br>
- * - GRALLOC_USAGE_HW_CAMERA_*<br>
- * - GRALLOC_USAGE_SW_*<br>
- * - GRALLOC_USAGE_RENDERSCRIPT<br>
- *<br>
- * When used with ANativeWindow, the dataSpace field should be<br>
- * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial<br>
- * extra metadata to define.<br>
- */<br>
- HAL_PIXEL_FORMAT_RAW12 = 0x26,<br>
-<br>
- /*<br>
- * Android opaque RAW format:<br>
- *<br>
- * This format is exposed outside of the camera HAL to applications.<br>
- *<br>
- * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an<br>
- * image sensor. The actual structure of buffers of this format is<br>
- * implementation-dependent.<br>
- *<br>
- * This format must be accepted by the gralloc module when used with the<br>
- * following usage flags:<br>
- * - GRALLOC_USAGE_HW_CAMERA_*<br>
- * - GRALLOC_USAGE_SW_*<br>
- * - GRALLOC_USAGE_RENDERSCRIPT<br>
- *<br>
- * When used with ANativeWindow, the dataSpace field should be<br>
- * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial<br>
- * extra metadata to define.<br>
- */<br>
- HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24,<br>
-<br>
- /*<br>
- * Android binary blob graphics buffer format:<br>
- *<br>
- * This format is used to carry task-specific data which does not have a<br>
- * standard image structure. The details of the format are left to the two<br>
- * endpoints.<br>
- *<br>
- * A typical use case is for transporting JPEG-compressed images from the<br>
- * Camera HAL to the framework or to applications.<br>
- *<br>
- * Buffers of this format must have a height of 1, and width equal to their<br>
- * size in bytes.<br>
- *<br>
- * When used with ANativeWindow, the mapping of the dataSpace field to<br>
- * buffer contents for BLOB is as follows:<br>
- *<br>
- * dataSpace value | Buffer contents<br>
- * -------------------------------+-----------------------------------------<br>
- * HAL_DATASPACE_JFIF | An encoded JPEG image<br>
- * HAL_DATASPACE_DEPTH | An android_depth_points buffer<br>
- * Other | Unsupported<br>
- *<br>
- */<br>
- HAL_PIXEL_FORMAT_BLOB = 0x21,<br>
-<br>
- /*<br>
- * Android format indicating that the choice of format is entirely up to the<br>
- * device-specific Gralloc implementation.<br>
- *<br>
- * The Gralloc implementation should examine the usage bits passed in when<br>
- * allocating a buffer with this format, and it should derive the pixel<br>
- * format from those usage flags. This format will never be used with any<br>
- * of the GRALLOC_USAGE_SW_* usage flags.<br>
- *<br>
- * If a buffer of this format is to be used as an OpenGL ES texture, the<br>
- * framework will assume that sampling the texture will always return an<br>
- * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values).<br>
- *<br>
- * When used with ANativeWindow, the dataSpace field describes the color<br>
- * space of the buffer.<br>
- */<br>
- HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22,<br>
-<br>
- /*<br>
- * Android flexible YCbCr 4:2:0 formats<br>
- *<br>
- * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0<br>
- * buffer layout, while still describing the general format in a<br>
- * layout-independent manner. While called YCbCr, it can be<br>
- * used to describe formats with either chromatic ordering, as well as<br>
- * whole planar or semiplanar layouts.<br>
- *<br>
- * struct android_ycbcr (below) is the the struct used to describe it.<br>
- *<br>
- * This format must be accepted by the gralloc module when<br>
- * USAGE_SW_WRITE_* or USAGE_SW_READ_* are set.<br>
- *<br>
- * This format is locked for use by gralloc's (*lock_ycbcr) method, and<br>
- * locking with the (*lock) method will return an error.<br>
- *<br>
- * When used with ANativeWindow, the dataSpace field describes the color<br>
- * space of the buffer.<br>
- */<br>
- HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23,<br>
-<br>
- /*<br>
- * Android flexible YCbCr 4:2:2 formats<br>
- *<br>
- * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2<br>
- * buffer layout, while still describing the general format in a<br>
- * layout-independent manner. While called YCbCr, it can be<br>
- * used to describe formats with either chromatic ordering, as well as<br>
- * whole planar or semiplanar layouts.<br>
- *<br>
- * This format is currently only used by SW readable buffers<br>
- * produced by MediaCodecs, so the gralloc module can ignore this format.<br>
- */<br>
- HAL_PIXEL_FORMAT_YCbCr_422_888 = 0x27,<br>
-<br>
- /*<br>
- * Android flexible YCbCr 4:4:4 formats<br>
- *<br>
- * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4<br>
- * buffer layout, while still describing the general format in a<br>
- * layout-independent manner. While called YCbCr, it can be<br>
- * used to describe formats with either chromatic ordering, as well as<br>
- * whole planar or semiplanar layouts.<br>
- *<br>
- * This format is currently only used by SW readable buffers<br>
- * produced by MediaCodecs, so the gralloc module can ignore this format.<br>
- */<br>
- HAL_PIXEL_FORMAT_YCbCr_444_888 = 0x28,<br>
-<br>
- /*<br>
- * Android flexible RGB 888 formats<br>
- *<br>
- * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX<br>
- * buffer layout, while still describing the general format in a<br>
- * layout-independent manner. While called RGB, it can be<br>
- * used to describe formats with either color ordering and optional<br>
- * padding, as well as whole planar layout.<br>
- *<br>
- * This format is currently only used by SW readable buffers<br>
- * produced by MediaCodecs, so the gralloc module can ignore this format.<br>
- */<br>
- HAL_PIXEL_FORMAT_FLEX_RGB_888 = 0x29,<br>
-<br>
- /*<br>
- * Android flexible RGBA 8888 formats<br>
- *<br>
- * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR<br>
- * buffer layout, while still describing the general format in a<br>
- * layout-independent manner. While called RGBA, it can be<br>
- * used to describe formats with any of the component orderings, as<br>
- * well as whole planar layout.<br>
- *<br>
- * This format is currently only used by SW readable buffers<br>
- * produced by MediaCodecs, so the gralloc module can ignore this format.<br>
- */<br>
- HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 0x2A,<br>
-<br>
- /* Legacy formats (deprecated), used by ImageFormat.java */<br>
- HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16<br>
- HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21<br>
- HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2<br>
-};<br>
-<br>
/*<br>
* Structure for describing YCbCr formats for consumption by applications.<br>
* This is used with HAL_PIXEL_FORMAT_YCbCr_*_888.<br>
@@ -452,15 +67,15 @@ enum {<br>
*<br>
* Buffers must have a 8 bit depth.<br>
*<br>
- * @y, @cb, and @cr point to the first byte of their respective planes.<br>
+ * y, cb, and cr point to the first byte of their respective planes.<br>
*<br>
* Stride describes the distance in bytes from the first value of one row of<br>
* the image to the first value of the next row. It includes the width of the<br>
* image plus padding.<br>
- * @ystride is the stride of the luma plane.<br>
- * @cstride is the stride of the chroma planes.<br>
+ * ystride is the stride of the luma plane.<br>
+ * cstride is the stride of the chroma planes.<br>
*<br>
- * @chroma_step is the distance in bytes from one chroma pixel value to the<br>
+ * chroma_step is the distance in bytes from one chroma pixel value to the<br>
* next. This is 2 bytes for semiplanar (because chroma values are interleaved<br>
* and each chroma value is one byte) and 1 for planar.<br>
*/<br>
@@ -477,6 +92,102 @@ struct android_ycbcr {<br>
uint32_t reserved[8];<br>
};<br>
<br>
+/*<br>
+ * Structures for describing flexible YUVA/RGBA formats for consumption by<br>
+ * applications. Such flexible formats contain a plane for each component (e.g.<br>
+ * red, green, blue), where each plane is laid out in a grid-like pattern<br>
+ * occupying unique byte addresses and with consistent byte offsets between<br>
+ * neighboring pixels.<br>
+ *<br>
+ * The android_flex_layout structure is used with any pixel format that can be<br>
+ * represented by it, such as:<br>
+ * - HAL_PIXEL_FORMAT_YCbCr_*_888<br>
+ * - HAL_PIXEL_FORMAT_FLEX_RGB*_888<br>
+ * - HAL_PIXEL_FORMAT_RGB[AX]_888[8],BGRA_8888,RGB_888<br>
+ * - HAL_PIXEL_FORMAT_YV12,Y8,Y16,YCbCr_422_SP/I,YCrCb_420_SP<br>
+ * - even implementation defined formats that can be represented by<br>
+ * the structures<br>
+ *<br>
+ * Vertical increment (aka. row increment or stride) describes the distance in<br>
+ * bytes from the first pixel of one row to the first pixel of the next row<br>
+ * (below) for the component plane. This can be negative.<br>
+ *<br>
+ * Horizontal increment (aka. column or pixel increment) describes the distance<br>
+ * in bytes from one pixel to the next pixel (to the right) on the same row for<br>
+ * the component plane. This can be negative.<br>
+ *<br>
+ * Each plane can be subsampled either vertically or horizontally by<br>
+ * a power-of-two factor.<br>
+ *<br>
+ * The bit-depth of each component can be arbitrary, as long as the pixels are<br>
+ * laid out on whole bytes, in native byte-order, using the most significant<br>
+ * bits of each unit.<br>
+ */<br>
+<br>
+typedef enum android_flex_component {<br>
+ /* luma */<br>
+ FLEX_COMPONENT_Y = 1 << 0,<br>
+ /* chroma blue */<br>
+ FLEX_COMPONENT_Cb = 1 << 1,<br>
+ /* chroma red */<br>
+ FLEX_COMPONENT_Cr = 1 << 2,<br>
+<br>
+ /* red */<br>
+ FLEX_COMPONENT_R = 1 << 10,<br>
+ /* green */<br>
+ FLEX_COMPONENT_G = 1 << 11,<br>
+ /* blue */<br>
+ FLEX_COMPONENT_B = 1 << 12,<br>
+<br>
+ /* alpha */<br>
+ FLEX_COMPONENT_A = 1 << 30,<br>
+} android_flex_component_t;<br>
+<br>
+typedef struct android_flex_plane {<br>
+ /* pointer to the first byte of the top-left pixel of the plane. */<br>
+ uint8_t *top_left;<br>
+<br>
+ android_flex_component_t component;<br>
+<br>
+ /* bits allocated for the component in each pixel. Must be a positive<br>
+ multiple of 8. */<br>
+ int32_t bits_per_component;<br>
+ /* number of the most significant bits used in the format for this<br>
+ component. Must be between 1 and bits_per_component, inclusive. */<br>
+ int32_t bits_used;<br>
+<br>
+ /* horizontal increment */<br>
+ int32_t h_increment;<br>
+ /* vertical increment */<br>
+ int32_t v_increment;<br>
+ /* horizontal subsampling. Must be a positive power of 2. */<br>
+ int32_t h_subsampling;<br>
+ /* vertical subsampling. Must be a positive power of 2. */<br>
+ int32_t v_subsampling;<br>
+} android_flex_plane_t;<br>
+<br>
+typedef enum android_flex_format {<br>
+ /* not a flexible format */<br>
+ FLEX_FORMAT_INVALID = 0x0,<br>
+ FLEX_FORMAT_Y = FLEX_COMPONENT_Y,<br>
+ FLEX_FORMAT_YCbCr = FLEX_COMPONENT_Y | FLEX_COMPONENT_Cb | FLEX_COMPONENT_Cr,<br>
+ FLEX_FORMAT_YCbCrA = FLEX_FORMAT_YCbCr | FLEX_COMPONENT_A,<br>
+ FLEX_FORMAT_RGB = FLEX_COMPONENT_R | FLEX_COMPONENT_G | FLEX_COMPONENT_B,<br>
+ FLEX_FORMAT_RGBA = FLEX_FORMAT_RGB | FLEX_COMPONENT_A,<br>
+} android_flex_format_t;<br>
+<br>
+typedef struct android_flex_layout {<br>
+ /* the kind of flexible format */<br>
+ android_flex_format_t format;<br>
+<br>
+ /* number of planes; 0 for FLEX_FORMAT_INVALID */<br>
+ uint32_t num_planes;<br>
+ /* a plane for each component; ordered in increasing component value order.<br>
+ E.g. FLEX_FORMAT_RGBA maps 0 -> R, 1 -> G, etc.<br>
+ Can be NULL for FLEX_FORMAT_INVALID */<br>
+ android_flex_plane_t *planes;<br>
+} android_flex_layout_t;<br>
+<br>
/**<br>
* Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB<br>
* with dataSpace value of HAL_DATASPACE_DEPTH.<br>
@@ -489,9 +200,9 @@ struct android_ycbcr {<br>
* measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f ==<br>
* 100% confidence.<br>
*<br>
- * @num_points is the number of points in the list<br>
+ * num_points is the number of points in the list<br>
*<br>
- * @xyz_points is the flexible array of floating-point values.<br>
+ * xyz_points is the flexible array of floating-point values.<br>
* It contains (num_points) * 4 floats.<br>
*<br>
* For example:<br>
@@ -516,246 +227,40 @@ struct android_depth_points {<br>
/** reserved for future use, set to 0 by gralloc's (*lock)() */<br>
uint32_t reserved[8];<br>
<br>
+#if defined(__clang__)<br>
+#pragma clang diagnostic push<br>
+#pragma clang diagnostic ignored "-Wc99-extensions"<br>
+#endif<br>
float xyzc_points[];<br>
+#if defined(__clang__)<br>
+#pragma clang diagnostic pop<br>
+#endif<br>
};<br>
<br>
/**<br>
- * Transformation definitions<br>
- *<br>
- * IMPORTANT NOTE:<br>
- * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}.<br>
- *<br>
- */<br>
-<br>
-enum {<br>
- /* flip source image horizontally (around the vertical axis) */<br>
- HAL_TRANSFORM_FLIP_H = 0x01,<br>
- /* flip source image vertically (around the horizontal axis)*/<br>
- HAL_TRANSFORM_FLIP_V = 0x02,<br>
- /* rotate source image 90 degrees clockwise */<br>
- HAL_TRANSFORM_ROT_90 = 0x04,<br>
- /* rotate source image 180 degrees */<br>
- HAL_TRANSFORM_ROT_180 = 0x03,<br>
- /* rotate source image 270 degrees clockwise */<br>
- HAL_TRANSFORM_ROT_270 = 0x07,<br>
- /* don't use. see system/window.h */<br>
- HAL_TRANSFORM_RESERVED = 0x08,<br>
+ * These structures are used to define the reference display's<br>
+ * capabilities for HDR content. Display engine can use this<br>
+ * to better tone map content to user's display.<br>
+ * Color is defined in CIE XYZ coordinates<br>
+ */<br>
+struct android_xy_color {<br>
+ float x;<br>
+ float y;<br>
};<br>
<br>
-/**<br>
- * Dataspace Definitions<br>
- * ======================<br>
- *<br>
- * Dataspace is the definition of how pixel values should be interpreted.<br>
- *<br>
- * For many formats, this is the colorspace of the image data, which includes<br>
- * primaries (including white point) and the transfer characteristic function,<br>
- * which describes both gamma curve and numeric range (within the bit depth).<br>
- *<br>
- * Other dataspaces include depth measurement data from a depth camera.<br>
- */<br>
-<br>
-typedef enum android_dataspace {<br>
- /*<br>
- * Default-assumption data space, when not explicitly specified.<br>
- *<br>
- * It is safest to assume the buffer is an image with sRGB primaries and<br>
- * encoding ranges, but the consumer and/or the producer of the data may<br>
- * simply be using defaults. No automatic gamma transform should be<br>
- * expected, except for a possible display gamma transform when drawn to a<br>
- * screen.<br>
- */<br>
- HAL_DATASPACE_UNKNOWN = 0x0,<br>
-<br>
- /*<br>
- * Arbitrary dataspace with manually defined characteristics. Definition<br>
- * for colorspaces or other meaning must be communicated separately.<br>
- *<br>
- * This is used when specifying primaries, transfer characteristics,<br>
- * etc. separately.<br>
- *<br>
- * A typical use case is in video encoding parameters (e.g. for H.264),<br>
- * where a colorspace can have separately defined primaries, transfer<br>
- * characteristics, etc.<br>
- */<br>
- HAL_DATASPACE_ARBITRARY = 0x1,<br>
-<br>
- /*<br>
- * RGB Colorspaces<br>
- * -----------------<br>
- *<br>
- * Primaries are given using (x,y) coordinates in the CIE 1931 definition<br>
- * of x and y specified by ISO 11664-1.<br>
- *<br>
- * Transfer characteristics are the opto-electronic transfer characteristic<br>
- * at the source as a function of linear optical intensity (luminance).<br>
- */<br>
-<br>
- /*<br>
- * sRGB linear encoding:<br>
- *<br>
- * The red, green, and blue components are stored in sRGB space, but<br>
- * are linear, not gamma-encoded.<br>
- * The RGB primaries and the white point are the same as BT.709.<br>
- *<br>
- * The values are encoded using the full range ([0,255] for 8-bit) for all<br>
- * components.<br>
- */<br>
- HAL_DATASPACE_SRGB_LINEAR = 0x200,<br>
-<br>
- /*<br>
- * sRGB gamma encoding:<br>
- *<br>
- * The red, green and blue components are stored in sRGB space, and<br>
- * converted to linear space when read, using the standard sRGB to linear<br>
- * equation:<br>
- *<br>
- * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045<br>
- * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045<br>
- *<br>
- * When written the inverse transformation is performed:<br>
- *<br>
- * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308<br>
- * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308<br>
- *<br>
- *<br>
- * The alpha component, if present, is always stored in linear space and<br>
- * is left unmodified when read or written.<br>
- *<br>
- * The RGB primaries and the white point are the same as BT.709.<br>
- *<br>
- * The values are encoded using the full range ([0,255] for 8-bit) for all<br>
- * components.<br>
- *<br>
- */<br>
- HAL_DATASPACE_SRGB = 0x201,<br>
-<br>
- /*<br>
- * YCbCr Colorspaces<br>
- * -----------------<br>
- *<br>
- * Primaries are given using (x,y) coordinates in the CIE 1931 definition<br>
- * of x and y specified by ISO 11664-1.<br>
- *<br>
- * Transfer characteristics are the opto-electronic transfer characteristic<br>
- * at the source as a function of linear optical intensity (luminance).<br>
- */<br>
-<br>
- /*<br>
- * JPEG File Interchange Format (JFIF)<br>
- *<br>
- * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255<br>
- *<br>
- * Transfer characteristic curve:<br>
- * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018<br>
- * E = 4.500 L, 0.018 > L >= 0<br>
- * L - luminance of image 0 <= L <= 1 for conventional colorimetry<br>
- * E - corresponding electrical signal<br>
- *<br>
- * Primaries: x y<br>
- * green 0.290 0.600<br>
- * blue 0.150 0.060<br>
- * red 0.640 0.330<br>
- * white (D65) 0.3127 0.3290<br>
- */<br>
- HAL_DATASPACE_JFIF = 0x101,<br>
-<br>
- /*<br>
- * ITU-R Recommendation 601 (BT.601) - 625-line<br>
- *<br>
- * Standard-definition television, 625 Lines (PAL)<br>
- *<br>
- * For 8-bit-depth formats:<br>
- * Luma (Y) samples should range from 16 to 235, inclusive<br>
- * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive<br>
- *<br>
- * For 10-bit-depth formats:<br>
- * Luma (Y) samples should range from 64 to 940, inclusive<br>
- * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive<br>
- *<br>
- * Transfer characteristic curve:<br>
- * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018<br>
- * E = 4.500 L, 0.018 > L >= 0<br>
- * L - luminance of image 0 <= L <= 1 for conventional colorimetry<br>
- * E - corresponding electrical signal<br>
- *<br>
- * Primaries: x y<br>
- * green 0.290 0.600<br>
- * blue 0.150 0.060<br>
- * red 0.640 0.330<br>
- * white (D65) 0.3127 0.3290<br>
- */<br>
- HAL_DATASPACE_BT601_625 = 0x102,<br>
-<br>
- /*<br>
- * ITU-R Recommendation 601 (BT.601) - 525-line<br>
- *<br>
- * Standard-definition television, 525 Lines (NTSC)<br>
- *<br>
- * For 8-bit-depth formats:<br>
- * Luma (Y) samples should range from 16 to 235, inclusive<br>
- * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive<br>
- *<br>
- * For 10-bit-depth formats:<br>
- * Luma (Y) samples should range from 64 to 940, inclusive<br>
- * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive<br>
- *<br>
- * Transfer characteristic curve:<br>
- * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018<br>
- * E = 4.500 L, 0.018 > L >= 0<br>
- * L - luminance of image 0 <= L <= 1 for conventional colorimetry<br>
- * E - corresponding electrical signal<br>
- *<br>
- * Primaries: x y<br>
- * green 0.310 0.595<br>
- * blue 0.155 0.070<br>
- * red 0.630 0.340<br>
- * white (D65) 0.3127 0.3290<br>
- */<br>
- HAL_DATASPACE_BT601_525 = 0x103,<br>
-<br>
- /*<br>
- * ITU-R Recommendation 709 (BT.709)<br>
- *<br>
- * High-definition television<br>
- *<br>
- * For 8-bit-depth formats:<br>
- * Luma (Y) samples should range from 16 to 235, inclusive<br>
- * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive<br>
- *<br>
- * For 10-bit-depth formats:<br>
- * Luma (Y) samples should range from 64 to 940, inclusive<br>
- * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive<br>
- *<br>
- * Primaries: x y<br>
- * green 0.300 0.600<br>
- * blue 0.150 0.060<br>
- * red 0.640 0.330<br>
- * white (D65) 0.3127 0.3290<br>
- */<br>
- HAL_DATASPACE_BT709 = 0x104,<br>
-<br>
- /*<br>
- * The buffer contains depth ranging measurements from a depth camera.<br>
- * This value is valid with formats:<br>
- * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement<br>
- * and an associated confidence value. The 3 MSBs of the sample make<br>
- * up the confidence value, and the low 13 LSBs of the sample make up<br>
- * the depth measurement.<br>
- * For the confidence section, 0 means 100% confidence, 1 means 0%<br>
- * confidence. The mapping to a linear float confidence value between<br>
- * 0.f and 1.f can be obtained with<br>
- * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f;<br>
- * The depth measurement can be extracted simply with<br>
- * uint16_t range = (depthSample & 0x1FFF);<br>
- * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as<br>
- * a variable-length float (x,y,z, confidence) coordinate point list.<br>
- * The point cloud will be represented with the android_depth_points<br>
- * structure.<br>
- */<br>
- HAL_DATASPACE_DEPTH = 0x1000<br>
+struct android_smpte2086_metadata {<br>
+ struct android_xy_color displayPrimaryRed;<br>
+ struct android_xy_color displayPrimaryGreen;<br>
+ struct android_xy_color displayPrimaryBlue;<br>
+ struct android_xy_color whitePoint;<br>
+ float maxLuminance;<br>
+ float minLuminance;<br>
+};<br>
<br>
-} android_dataspace_t;<br>
+struct android_cta861_3_metadata {<br>
+ float maxContentLightLevel;<br>
+ float maxFrameAverageLightLevel;<br>
+};<br>
<br>
#ifdef __cplusplus<br>
}<br>
diff --git a/include/android/system/core/include/system/window.h b/include/android/system/core/include/system/window.h<br>
deleted file mode 100644<br>
index 2c9d6063fdb5..000000000000<br>
--- a/include/android/system/core/include/system/window.h<br>
+++ /dev/null<br>
@@ -1,955 +0,0 @@<br>
-/* SPDX-License-Identifier: Apache-2.0 */<br>
-/*<br>
- * Copyright (C) 2011 The Android Open Source Project<br>
- *<br>
- * Licensed under the Apache License, Version 2.0 (the "License");<br>
- * you may not use this file except in compliance with the License.<br>
- * You may obtain a copy of the License at<br>
- *<br>
- * <a href="http://www.apache.org/licenses/LICENSE-2.0" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0</a><br>
- *<br>
- * Unless required by applicable law or agreed to in writing, software<br>
- * distributed under the License is distributed on an "AS IS" BASIS,<br>
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>
- * See the License for the specific language governing permissions and<br>
- * limitations under the License.<br>
- */<br>
-<br>
-#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H<br>
-#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H<br>
-<br>
-#include <cutils/native_handle.h><br>
-#include <errno.h><br>
-#include <limits.h><br>
-#include <stdint.h><br>
-#include <string.h><br>
-#include <sys/cdefs.h><br>
-#include <system/graphics.h><br>
-#include <unistd.h><br>
-<br>
-#ifndef __UNUSED<br>
-#define __UNUSED __attribute__((__unused__))<br>
-#endif<br>
-#ifndef __deprecated<br>
-#define __deprecated __attribute__((__deprecated__))<br>
-#endif<br>
-<br>
-__BEGIN_DECLS<br>
-<br>
-/*****************************************************************************/<br>
-<br>
-#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \<br>
- (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))<br>
-<br>
-#define ANDROID_NATIVE_WINDOW_MAGIC \<br>
- ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')<br>
-<br>
-#define ANDROID_NATIVE_BUFFER_MAGIC \<br>
- ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')<br>
-<br>
-// ---------------------------------------------------------------------------<br>
-<br>
-// This #define may be used to conditionally compile device-specific code to<br>
-// support either the prior ANativeWindow interface, which did not pass libsync<br>
-// fences around, or the new interface that does. This #define is only present<br>
-// when the ANativeWindow interface does include libsync support.<br>
-#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1<br>
-<br>
-// ---------------------------------------------------------------------------<br>
-<br>
-typedef const native_handle_t* buffer_handle_t;<br>
-<br>
-// ---------------------------------------------------------------------------<br>
-<br>
-typedef struct android_native_rect_t<br>
-{<br>
- int32_t left;<br>
- int32_t top;<br>
- int32_t right;<br>
- int32_t bottom;<br>
-} android_native_rect_t;<br>
-<br>
-// ---------------------------------------------------------------------------<br>
-<br>
-typedef struct android_native_base_t<br>
-{<br>
- /* a magic value defined by the actual EGL native type */<br>
- int magic;<br>
-<br>
- /* the sizeof() of the actual EGL native type */<br>
- int version;<br>
-<br>
- void* reserved[4];<br>
-<br>
- /* reference-counting interface */<br>
- void (*incRef)(struct android_native_base_t* base);<br>
- void (*decRef)(struct android_native_base_t* base);<br>
-} android_native_base_t;<br>
-<br>
-typedef struct ANativeWindowBuffer<br>
-{<br>
-#ifdef __cplusplus<br>
- ANativeWindowBuffer() {<br>
- common.magic = ANDROID_NATIVE_BUFFER_MAGIC;<br>
- common.version = sizeof(ANativeWindowBuffer);<br>
- memset(common.reserved, 0, sizeof(common.reserved));<br>
- }<br>
-<br>
- // Implement the methods that sp<ANativeWindowBuffer> expects so that it<br>
- // can be used to automatically refcount ANativeWindowBuffer's.<br>
- void incStrong(const void* /*id*/) const {<br>
- common.incRef(const_cast<android_native_base_t*>(&common));<br>
- }<br>
- void decStrong(const void* /*id*/) const {<br>
- common.decRef(const_cast<android_native_base_t*>(&common));<br>
- }<br>
-#endif<br>
-<br>
- struct android_native_base_t common;<br>
-<br>
- int width;<br>
- int height;<br>
- int stride;<br>
- int format;<br>
- int usage;<br>
-<br>
- void* reserved[2];<br>
-<br>
- buffer_handle_t handle;<br>
-<br>
- void* reserved_proc[8];<br>
-} ANativeWindowBuffer_t;<br>
-<br>
-// Old typedef for backwards compatibility.<br>
-typedef ANativeWindowBuffer_t android_native_buffer_t;<br>
-<br>
-// ---------------------------------------------------------------------------<br>
-<br>
-/* attributes queriable with query() */<br>
-enum {<br>
- NATIVE_WINDOW_WIDTH = 0,<br>
- NATIVE_WINDOW_HEIGHT = 1,<br>
- NATIVE_WINDOW_FORMAT = 2,<br>
-<br>
- /* The minimum number of buffers that must remain un-dequeued after a buffer<br>
- * has been queued. This value applies only if set_buffer_count was used to<br>
- * override the number of buffers and if a buffer has since been queued.<br>
- * Users of the set_buffer_count ANativeWindow method should query this<br>
- * value before calling set_buffer_count. If it is necessary to have N<br>
- * buffers simultaneously dequeued as part of the steady-state operation,<br>
- * and this query returns M then N+M buffers should be requested via<br>
- * native_window_set_buffer_count.<br>
- *<br>
- * Note that this value does NOT apply until a single buffer has been<br>
- * queued. In particular this means that it is possible to:<br>
- *<br>
- * 1. Query M = min undequeued buffers<br>
- * 2. Set the buffer count to N + M<br>
- * 3. Dequeue all N + M buffers<br>
- * 4. Cancel M buffers<br>
- * 5. Queue, dequeue, queue, dequeue, ad infinitum<br>
- */<br>
- NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,<br>
-<br>
- /* Check whether queueBuffer operations on the ANativeWindow send the buffer<br>
- * to the window compositor. The query sets the returned 'value' argument<br>
- * to 1 if the ANativeWindow DOES send queued buffers directly to the window<br>
- * compositor and 0 if the buffers do not go directly to the window<br>
- * compositor.<br>
- *<br>
- * This can be used to determine whether protected buffer content should be<br>
- * sent to the ANativeWindow. Note, however, that a result of 1 does NOT<br>
- * indicate that queued buffers will be protected from applications or users<br>
- * capturing their contents. If that behavior is desired then some other<br>
- * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in<br>
- * conjunction with this query.<br>
- */<br>
- NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,<br>
-<br>
- /* Get the concrete type of a ANativeWindow. See below for the list of<br>
- * possible return values.<br>
- *<br>
- * This query should not be used outside the Android framework and will<br>
- * likely be removed in the near future.<br>
- */<br>
- NATIVE_WINDOW_CONCRETE_TYPE = 5,<br>
-<br>
-<br>
- /*<br>
- * Default width and height of ANativeWindow buffers, these are the<br>
- * dimensions of the window buffers irrespective of the<br>
- * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window<br>
- * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.<br>
- */<br>
- NATIVE_WINDOW_DEFAULT_WIDTH = 6,<br>
- NATIVE_WINDOW_DEFAULT_HEIGHT = 7,<br>
-<br>
- /*<br>
- * transformation that will most-likely be applied to buffers. This is only<br>
- * a hint, the actual transformation applied might be different.<br>
- *<br>
- * INTENDED USE:<br>
- *<br>
- * The transform hint can be used by a producer, for instance the GLES<br>
- * driver, to pre-rotate the rendering such that the final transformation<br>
- * in the composer is identity. This can be very useful when used in<br>
- * conjunction with the h/w composer HAL, in situations where it<br>
- * cannot handle arbitrary rotations.<br>
- *<br>
- * 1. Before dequeuing a buffer, the GL driver (or any other ANW client)<br>
- * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.<br>
- *<br>
- * 2. The GL driver overrides the width and height of the ANW to<br>
- * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying<br>
- * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions<br>
- * according to NATIVE_WINDOW_TRANSFORM_HINT and calling<br>
- * native_window_set_buffers_dimensions().<br>
- *<br>
- * 3. The GL driver dequeues a buffer of the new pre-rotated size.<br>
- *<br>
- * 4. The GL driver renders to the buffer such that the image is<br>
- * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT<br>
- * to the rendering.<br>
- *<br>
- * 5. The GL driver calls native_window_set_transform to apply<br>
- * inverse transformation to the buffer it just rendered.<br>
- * In order to do this, the GL driver needs<br>
- * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is<br>
- * done easily:<br>
- *<br>
- * int hintTransform, inverseTransform;<br>
- * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);<br>
- * inverseTransform = hintTransform;<br>
- * if (hintTransform & HAL_TRANSFORM_ROT_90)<br>
- * inverseTransform ^= HAL_TRANSFORM_ROT_180;<br>
- *<br>
- *<br>
- * 6. The GL driver queues the pre-transformed buffer.<br>
- *<br>
- * 7. The composer combines the buffer transform with the display<br>
- * transform. If the buffer transform happens to cancel out the<br>
- * display transform then no rotation is needed.<br>
- *<br>
- */<br>
- NATIVE_WINDOW_TRANSFORM_HINT = 8,<br>
-<br>
- /*<br>
- * Boolean that indicates whether the consumer is running more than<br>
- * one buffer behind the producer.<br>
- */<br>
- NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,<br>
-<br>
- /*<br>
- * The consumer gralloc usage bits currently set by the consumer.<br>
- * The values are defined in hardware/libhardware/include/gralloc.h.<br>
- */<br>
- NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10,<br>
-<br>
- /**<br>
- * Transformation that will by applied to buffers by the hwcomposer.<br>
- * This must not be set or checked by producer endpoints, and will<br>
- * disable the transform hint set in SurfaceFlinger (see<br>
- * NATIVE_WINDOW_TRANSFORM_HINT).<br>
- *<br>
- * INTENDED USE:<br>
- * Temporary - Please do not use this. This is intended only to be used<br>
- * by the camera's LEGACY mode.<br>
- *<br>
- * In situations where a SurfaceFlinger client wishes to set a transform<br>
- * that is not visible to the producer, and will always be applied in the<br>
- * hardware composer, the client can set this flag with<br>
- * native_window_set_buffers_sticky_transform. This can be used to rotate<br>
- * and flip buffers consumed by hardware composer without actually changing<br>
- * the aspect ratio of the buffers produced.<br>
- */<br>
- NATIVE_WINDOW_STICKY_TRANSFORM = 11,<br>
-<br>
- /**<br>
- * The default data space for the buffers as set by the consumer.<br>
- * The values are defined in graphics.h.<br>
- */<br>
- NATIVE_WINDOW_DEFAULT_DATASPACE = 12,<br>
-<br>
- /*<br>
- * Returns the age of the contents of the most recently dequeued buffer as<br>
- * the number of frames that have elapsed since it was last queued. For<br>
- * example, if the window is double-buffered, the age of any given buffer in<br>
- * steady state will be 2. If the dequeued buffer has never been queued, its<br>
- * age will be 0.<br>
- */<br>
- NATIVE_WINDOW_BUFFER_AGE = 13,<br>
-};<br>
-<br>
-/* Valid operations for the (*perform)() hook.<br>
- *<br>
- * Values marked as 'deprecated' are supported, but have been superceded by<br>
- * other functionality.<br>
- *<br>
- * Values marked as 'private' should be considered private to the framework.<br>
- * HAL implementation code with access to an ANativeWindow should not use these,<br>
- * as it may not interact properly with the framework's use of the<br>
- * ANativeWindow.<br>
- */<br>
-enum {<br>
- NATIVE_WINDOW_SET_USAGE = 0,<br>
- NATIVE_WINDOW_CONNECT = 1, /* deprecated */<br>
- NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */<br>
- NATIVE_WINDOW_SET_CROP = 3, /* private */<br>
- NATIVE_WINDOW_SET_BUFFER_COUNT = 4,<br>
- NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */<br>
- NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,<br>
- NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,<br>
- NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,<br>
- NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,<br>
- NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */<br>
- NATIVE_WINDOW_LOCK = 11, /* private */<br>
- NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */<br>
- NATIVE_WINDOW_API_CONNECT = 13, /* private */<br>
- NATIVE_WINDOW_API_DISCONNECT = 14, /* private */<br>
- NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */<br>
- NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */<br>
- NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */<br>
- NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18,<br>
- NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19,<br>
- NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */<br>
-};<br>
-<br>
-/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */<br>
-enum {<br>
- /* Buffers will be queued by EGL via eglSwapBuffers after being filled using<br>
- * OpenGL ES.<br>
- */<br>
- NATIVE_WINDOW_API_EGL = 1,<br>
-<br>
- /* Buffers will be queued after being filled using the CPU<br>
- */<br>
- NATIVE_WINDOW_API_CPU = 2,<br>
-<br>
- /* Buffers will be queued by Stagefright after being filled by a video<br>
- * decoder. The video decoder can either be a software or hardware decoder.<br>
- */<br>
- NATIVE_WINDOW_API_MEDIA = 3,<br>
-<br>
- /* Buffers will be queued by the the camera HAL.<br>
- */<br>
- NATIVE_WINDOW_API_CAMERA = 4,<br>
-};<br>
-<br>
-/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */<br>
-enum {<br>
- /* flip source image horizontally */<br>
- NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,<br>
- /* flip source image vertically */<br>
- NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,<br>
- /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */<br>
- NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,<br>
- /* rotate source image 180 degrees */<br>
- NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,<br>
- /* rotate source image 270 degrees clock-wise */<br>
- NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,<br>
- /* transforms source by the inverse transform of the screen it is displayed onto. This<br>
- * transform is applied last */<br>
- NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08<br>
-};<br>
-<br>
-/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */<br>
-enum {<br>
- /* the window content is not updated (frozen) until a buffer of<br>
- * the window size is received (enqueued)<br>
- */<br>
- NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,<br>
- /* the buffer is scaled in both dimensions to match the window size */<br>
- NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,<br>
- /* the buffer is scaled uniformly such that the smaller dimension<br>
- * of the buffer matches the window size (cropping in the process)<br>
- */<br>
- NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,<br>
- /* the window is clipped to the size of the buffer's crop rectangle; pixels<br>
- * outside the crop rectangle are treated as if they are completely<br>
- * transparent.<br>
- */<br>
- NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3,<br>
-};<br>
-<br>
-/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */<br>
-enum {<br>
- NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */<br>
- NATIVE_WINDOW_SURFACE = 1, /* Surface */<br>
-};<br>
-<br>
-/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP<br>
- *<br>
- * Special timestamp value to indicate that timestamps should be auto-generated<br>
- * by the native window when queueBuffer is called. This is equal to INT64_MIN,<br>
- * defined directly to avoid problems with C99/C++ inclusion of stdint.h.<br>
- */<br>
-static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);<br>
-<br>
-struct ANativeWindow<br>
-{<br>
-#ifdef __cplusplus<br>
- ANativeWindow()<br>
- : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)<br>
- {<br>
- common.magic = ANDROID_NATIVE_WINDOW_MAGIC;<br>
- common.version = sizeof(ANativeWindow);<br>
- memset(common.reserved, 0, sizeof(common.reserved));<br>
- }<br>
-<br>
- /* Implement the methods that sp<ANativeWindow> expects so that it<br>
- can be used to automatically refcount ANativeWindow's. */<br>
- void incStrong(const void* /*id*/) const {<br>
- common.incRef(const_cast<android_native_base_t*>(&common));<br>
- }<br>
- void decStrong(const void* /*id*/) const {<br>
- common.decRef(const_cast<android_native_base_t*>(&common));<br>
- }<br>
-#endif<br>
-<br>
- struct android_native_base_t common;<br>
-<br>
- /* flags describing some attributes of this surface or its updater */<br>
- const uint32_t flags;<br>
-<br>
- /* min swap interval supported by this updated */<br>
- const int minSwapInterval;<br>
-<br>
- /* max swap interval supported by this updated */<br>
- const int maxSwapInterval;<br>
-<br>
- /* horizontal and vertical resolution in DPI */<br>
- const float xdpi;<br>
- const float ydpi;<br>
-<br>
- /* Some storage reserved for the OEM's driver. */<br>
- intptr_t oem[4];<br>
-<br>
- /*<br>
- * Set the swap interval for this surface.<br>
- *<br>
- * Returns 0 on success or -errno on error.<br>
- */<br>
- int (*setSwapInterval)(struct ANativeWindow* window,<br>
- int interval);<br>
-<br>
- /*<br>
- * Hook called by EGL to acquire a buffer. After this call, the buffer<br>
- * is not locked, so its content cannot be modified. This call may block if<br>
- * no buffers are available.<br>
- *<br>
- * The window holds a reference to the buffer between dequeueBuffer and<br>
- * either queueBuffer or cancelBuffer, so clients only need their own<br>
- * reference if they might use the buffer after queueing or canceling it.<br>
- * Holding a reference to a buffer after queueing or canceling it is only<br>
- * allowed if a specific buffer count has been set.<br>
- *<br>
- * Returns 0 on success or -errno on error.<br>
- *<br>
- * XXX: This function is deprecated. It will continue to work for some<br>
- * time for binary compatibility, but the new dequeueBuffer function that<br>
- * outputs a fence file descriptor should be used in its place.<br>
- */<br>
- int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,<br>
- struct ANativeWindowBuffer** buffer);<br>
-<br>
- /*<br>
- * hook called by EGL to lock a buffer. This MUST be called before modifying<br>
- * the content of a buffer. The buffer must have been acquired with<br>
- * dequeueBuffer first.<br>
- *<br>
- * Returns 0 on success or -errno on error.<br>
- *<br>
- * XXX: This function is deprecated. It will continue to work for some<br>
- * time for binary compatibility, but it is essentially a no-op, and calls<br>
- * to it should be removed.<br>
- */<br>
- int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,<br>
- struct ANativeWindowBuffer* buffer);<br>
-<br>
- /*<br>
- * Hook called by EGL when modifications to the render buffer are done.<br>
- * This unlocks and post the buffer.<br>
- *<br>
- * The window holds a reference to the buffer between dequeueBuffer and<br>
- * either queueBuffer or cancelBuffer, so clients only need their own<br>
- * reference if they might use the buffer after queueing or canceling it.<br>
- * Holding a reference to a buffer after queueing or canceling it is only<br>
- * allowed if a specific buffer count has been set.<br>
- *<br>
- * Buffers MUST be queued in the same order than they were dequeued.<br>
- *<br>
- * Returns 0 on success or -errno on error.<br>
- *<br>
- * XXX: This function is deprecated. It will continue to work for some<br>
- * time for binary compatibility, but the new queueBuffer function that<br>
- * takes a fence file descriptor should be used in its place (pass a value<br>
- * of -1 for the fence file descriptor if there is no valid one to pass).<br>
- */<br>
- int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,<br>
- struct ANativeWindowBuffer* buffer);<br>
-<br>
- /*<br>
- * hook used to retrieve information about the native window.<br>
- *<br>
- * Returns 0 on success or -errno on error.<br>
- */<br>
- int (*query)(const struct ANativeWindow* window,<br>
- int what, int* value);<br>
-<br>
- /*<br>
- * hook used to perform various operations on the surface.<br>
- * (*perform)() is a generic mechanism to add functionality to<br>
- * ANativeWindow while keeping backward binary compatibility.<br>
- *<br>
- * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions<br>
- * defined below.<br>
- *<br>
- * (*perform)() returns -ENOENT if the 'what' parameter is not supported<br>
- * by the surface's implementation.<br>
- *<br>
- * See above for a list of valid operations, such as<br>
- * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT<br>
- */<br>
- int (*perform)(struct ANativeWindow* window,<br>
- int operation, ... );<br>
-<br>
- /*<br>
- * Hook used to cancel a buffer that has been dequeued.<br>
- * No synchronization is performed between dequeue() and cancel(), so<br>
- * either external synchronization is needed, or these functions must be<br>
- * called from the same thread.<br>
- *<br>
- * The window holds a reference to the buffer between dequeueBuffer and<br>
- * either queueBuffer or cancelBuffer, so clients only need their own<br>
- * reference if they might use the buffer after queueing or canceling it.<br>
- * Holding a reference to a buffer after queueing or canceling it is only<br>
- * allowed if a specific buffer count has been set.<br>
- *<br>
- * XXX: This function is deprecated. It will continue to work for some<br>
- * time for binary compatibility, but the new cancelBuffer function that<br>
- * takes a fence file descriptor should be used in its place (pass a value<br>
- * of -1 for the fence file descriptor if there is no valid one to pass).<br>
- */<br>
- int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,<br>
- struct ANativeWindowBuffer* buffer);<br>
-<br>
- /*<br>
- * Hook called by EGL to acquire a buffer. This call may block if no<br>
- * buffers are available.<br>
- *<br>
- * The window holds a reference to the buffer between dequeueBuffer and<br>
- * either queueBuffer or cancelBuffer, so clients only need their own<br>
- * reference if they might use the buffer after queueing or canceling it.<br>
- * Holding a reference to a buffer after queueing or canceling it is only<br>
- * allowed if a specific buffer count has been set.<br>
- *<br>
- * The libsync fence file descriptor returned in the int pointed to by the<br>
- * fenceFd argument will refer to the fence that must signal before the<br>
- * dequeued buffer may be written to. A value of -1 indicates that the<br>
- * caller may access the buffer immediately without waiting on a fence. If<br>
- * a valid file descriptor is returned (i.e. any value except -1) then the<br>
- * caller is responsible for closing the file descriptor.<br>
- *<br>
- * Returns 0 on success or -errno on error.<br>
- */<br>
- int (*dequeueBuffer)(struct ANativeWindow* window,<br>
- struct ANativeWindowBuffer** buffer, int* fenceFd);<br>
-<br>
- /*<br>
- * Hook called by EGL when modifications to the render buffer are done.<br>
- * This unlocks and post the buffer.<br>
- *<br>
- * The window holds a reference to the buffer between dequeueBuffer and<br>
- * either queueBuffer or cancelBuffer, so clients only need their own<br>
- * reference if they might use the buffer after queueing or canceling it.<br>
- * Holding a reference to a buffer after queueing or canceling it is only<br>
- * allowed if a specific buffer count has been set.<br>
- *<br>
- * The fenceFd argument specifies a libsync fence file descriptor for a<br>
- * fence that must signal before the buffer can be accessed. If the buffer<br>
- * can be accessed immediately then a value of -1 should be used. The<br>
- * caller must not use the file descriptor after it is passed to<br>
- * queueBuffer, and the ANativeWindow implementation is responsible for<br>
- * closing it.<br>
- *<br>
- * Returns 0 on success or -errno on error.<br>
- */<br>
- int (*queueBuffer)(struct ANativeWindow* window,<br>
- struct ANativeWindowBuffer* buffer, int fenceFd);<br>
-<br>
- /*<br>
- * Hook used to cancel a buffer that has been dequeued.<br>
- * No synchronization is performed between dequeue() and cancel(), so<br>
- * either external synchronization is needed, or these functions must be<br>
- * called from the same thread.<br>
- *<br>
- * The window holds a reference to the buffer between dequeueBuffer and<br>
- * either queueBuffer or cancelBuffer, so clients only need their own<br>
- * reference if they might use the buffer after queueing or canceling it.<br>
- * Holding a reference to a buffer after queueing or canceling it is only<br>
- * allowed if a specific buffer count has been set.<br>
- *<br>
- * The fenceFd argument specifies a libsync fence file decsriptor for a<br>
- * fence that must signal before the buffer can be accessed. If the buffer<br>
- * can be accessed immediately then a value of -1 should be used.<br>
- *<br>
- * Note that if the client has not waited on the fence that was returned<br>
- * from dequeueBuffer, that same fence should be passed to cancelBuffer to<br>
- * ensure that future uses of the buffer are preceded by a wait on that<br>
- * fence. The caller must not use the file descriptor after it is passed<br>
- * to cancelBuffer, and the ANativeWindow implementation is responsible for<br>
- * closing it.<br>
- *<br>
- * Returns 0 on success or -errno on error.<br>
- */<br>
- int (*cancelBuffer)(struct ANativeWindow* window,<br>
- struct ANativeWindowBuffer* buffer, int fenceFd);<br>
-};<br>
-<br>
- /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).<br>
- * android_native_window_t is deprecated.<br>
- */<br>
-typedef struct ANativeWindow ANativeWindow;<br>
-typedef struct ANativeWindow android_native_window_t __deprecated;<br>
-<br>
-/*<br>
- * native_window_set_usage(..., usage)<br>
- * Sets the intended usage flags for the next buffers<br>
- * acquired with (*lockBuffer)() and on.<br>
- * By default (if this function is never called), a usage of<br>
- * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE<br>
- * is assumed.<br>
- * Calling this function will usually cause following buffers to be<br>
- * reallocated.<br>
- */<br>
-<br>
-static inline int native_window_set_usage(<br>
- struct ANativeWindow* window, int usage)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);<br>
-}<br>
-<br>
-/* deprecated. Always returns 0. Don't call. */<br>
-static inline int native_window_connect(<br>
- struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;<br>
-<br>
-static inline int native_window_connect(<br>
- struct ANativeWindow* window __UNUSED, int api __UNUSED) {<br>
- return 0;<br>
-}<br>
-<br>
-/* deprecated. Always returns 0. Don't call. */<br>
-static inline int native_window_disconnect(<br>
- struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;<br>
-<br>
-static inline int native_window_disconnect(<br>
- struct ANativeWindow* window __UNUSED, int api __UNUSED) {<br>
- return 0;<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_crop(..., crop)<br>
- * Sets which region of the next queued buffers needs to be considered.<br>
- * Depending on the scaling mode, a buffer's crop region is scaled and/or<br>
- * cropped to match the surface's size. This function sets the crop in<br>
- * pre-transformed buffer pixel coordinates.<br>
- *<br>
- * The specified crop region applies to all buffers queued after it is called.<br>
- *<br>
- * If 'crop' is NULL, subsequently queued buffers won't be cropped.<br>
- *<br>
- * An error is returned if for instance the crop region is invalid, out of the<br>
- * buffer's bound or if the window is invalid.<br>
- */<br>
-static inline int native_window_set_crop(<br>
- struct ANativeWindow* window,<br>
- android_native_rect_t const * crop)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_post_transform_crop(..., crop)<br>
- * Sets which region of the next queued buffers needs to be considered.<br>
- * Depending on the scaling mode, a buffer's crop region is scaled and/or<br>
- * cropped to match the surface's size. This function sets the crop in<br>
- * post-transformed pixel coordinates.<br>
- *<br>
- * The specified crop region applies to all buffers queued after it is called.<br>
- *<br>
- * If 'crop' is NULL, subsequently queued buffers won't be cropped.<br>
- *<br>
- * An error is returned if for instance the crop region is invalid, out of the<br>
- * buffer's bound or if the window is invalid.<br>
- */<br>
-static inline int native_window_set_post_transform_crop(<br>
- struct ANativeWindow* window,<br>
- android_native_rect_t const * crop)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_active_rect(..., active_rect)<br>
- *<br>
- * This function is deprecated and will be removed soon. For now it simply<br>
- * sets the post-transform crop for compatibility while multi-project commits<br>
- * get checked.<br>
- */<br>
-static inline int native_window_set_active_rect(<br>
- struct ANativeWindow* window,<br>
- android_native_rect_t const * active_rect) __deprecated;<br>
-<br>
-static inline int native_window_set_active_rect(<br>
- struct ANativeWindow* window,<br>
- android_native_rect_t const * active_rect)<br>
-{<br>
- return native_window_set_post_transform_crop(window, active_rect);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_buffer_count(..., count)<br>
- * Sets the number of buffers associated with this native window.<br>
- */<br>
-static inline int native_window_set_buffer_count(<br>
- struct ANativeWindow* window,<br>
- size_t bufferCount)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_buffers_geometry(..., int w, int h, int format)<br>
- * All buffers dequeued after this call will have the dimensions and format<br>
- * specified. A successful call to this function has the same effect as calling<br>
- * native_window_set_buffers_size and native_window_set_buffers_format.<br>
- *<br>
- * XXX: This function is deprecated. The native_window_set_buffers_dimensions<br>
- * and native_window_set_buffers_format functions should be used instead.<br>
- */<br>
-static inline int native_window_set_buffers_geometry(<br>
- struct ANativeWindow* window,<br>
- int w, int h, int format) __deprecated;<br>
-<br>
-static inline int native_window_set_buffers_geometry(<br>
- struct ANativeWindow* window,<br>
- int w, int h, int format)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,<br>
- w, h, format);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_buffers_dimensions(..., int w, int h)<br>
- * All buffers dequeued after this call will have the dimensions specified.<br>
- * In particular, all buffers will have a fixed-size, independent from the<br>
- * native-window size. They will be scaled according to the scaling mode<br>
- * (see native_window_set_scaling_mode) upon window composition.<br>
- *<br>
- * If w and h are 0, the normal behavior is restored. That is, dequeued buffers<br>
- * following this call will be sized to match the window's size.<br>
- *<br>
- * Calling this function will reset the window crop to a NULL value, which<br>
- * disables cropping of the buffers.<br>
- */<br>
-static inline int native_window_set_buffers_dimensions(<br>
- struct ANativeWindow* window,<br>
- int w, int h)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,<br>
- w, h);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_buffers_user_dimensions(..., int w, int h)<br>
- *<br>
- * Sets the user buffer size for the window, which overrides the<br>
- * window's size. All buffers dequeued after this call will have the<br>
- * dimensions specified unless overridden by<br>
- * native_window_set_buffers_dimensions. All buffers will have a<br>
- * fixed-size, independent from the native-window size. They will be<br>
- * scaled according to the scaling mode (see<br>
- * native_window_set_scaling_mode) upon window composition.<br>
- *<br>
- * If w and h are 0, the normal behavior is restored. That is, the<br>
- * default buffer size will match the windows's size.<br>
- *<br>
- * Calling this function will reset the window crop to a NULL value, which<br>
- * disables cropping of the buffers.<br>
- */<br>
-static inline int native_window_set_buffers_user_dimensions(<br>
- struct ANativeWindow* window,<br>
- int w, int h)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,<br>
- w, h);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_buffers_format(..., int format)<br>
- * All buffers dequeued after this call will have the format specified.<br>
- *<br>
- * If the specified format is 0, the default buffer format will be used.<br>
- */<br>
-static inline int native_window_set_buffers_format(<br>
- struct ANativeWindow* window,<br>
- int format)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_buffers_data_space(..., int dataSpace)<br>
- * All buffers queued after this call will be associated with the dataSpace<br>
- * parameter specified.<br>
- *<br>
- * dataSpace specifies additional information about the buffer that's dependent<br>
- * on the buffer format and the endpoints. For example, it can be used to convey<br>
- * the color space of the image data in the buffer, or it can be used to<br>
- * indicate that the buffers contain depth measurement data instead of color<br>
- * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been<br>
- * overridden by the consumer.<br>
- */<br>
-static inline int native_window_set_buffers_data_space(<br>
- struct ANativeWindow* window,<br>
- android_dataspace_t dataSpace)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,<br>
- dataSpace);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_buffers_transform(..., int transform)<br>
- * All buffers queued after this call will be displayed transformed according<br>
- * to the transform parameter specified.<br>
- */<br>
-static inline int native_window_set_buffers_transform(<br>
- struct ANativeWindow* window,<br>
- int transform)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,<br>
- transform);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_buffers_sticky_transform(..., int transform)<br>
- * All buffers queued after this call will be displayed transformed according<br>
- * to the transform parameter specified applied on top of the regular buffer<br>
- * transform. Setting this transform will disable the transform hint.<br>
- *<br>
- * Temporary - This is only intended to be used by the LEGACY camera mode, do<br>
- * not use this for anything else.<br>
- */<br>
-static inline int native_window_set_buffers_sticky_transform(<br>
- struct ANativeWindow* window,<br>
- int transform)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,<br>
- transform);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_buffers_timestamp(..., int64_t timestamp)<br>
- * All buffers queued after this call will be associated with the timestamp<br>
- * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO<br>
- * (the default), timestamps will be generated automatically when queueBuffer is<br>
- * called. The timestamp is measured in nanoseconds, and is normally monotonically<br>
- * increasing. The timestamp should be unaffected by time-of-day adjustments,<br>
- * and for a camera should be strictly monotonic but for a media player may be<br>
- * reset when the position is set.<br>
- */<br>
-static inline int native_window_set_buffers_timestamp(<br>
- struct ANativeWindow* window,<br>
- int64_t timestamp)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,<br>
- timestamp);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_scaling_mode(..., int mode)<br>
- * All buffers queued after this call will be associated with the scaling mode<br>
- * specified.<br>
- */<br>
-static inline int native_window_set_scaling_mode(<br>
- struct ANativeWindow* window,<br>
- int mode)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,<br>
- mode);<br>
-}<br>
-<br>
-/*<br>
- * native_window_api_connect(..., int api)<br>
- * connects an API to this window. only one API can be connected at a time.<br>
- * Returns -EINVAL if for some reason the window cannot be connected, which<br>
- * can happen if it's connected to some other API.<br>
- */<br>
-static inline int native_window_api_connect(<br>
- struct ANativeWindow* window, int api)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);<br>
-}<br>
-<br>
-/*<br>
- * native_window_api_disconnect(..., int api)<br>
- * disconnect the API from this window.<br>
- * An error is returned if for instance the window wasn't connected in the<br>
- * first place.<br>
- */<br>
-static inline int native_window_api_disconnect(<br>
- struct ANativeWindow* window, int api)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);<br>
-}<br>
-<br>
-/*<br>
- * native_window_dequeue_buffer_and_wait(...)<br>
- * Dequeue a buffer and wait on the fence associated with that buffer. The<br>
- * buffer may safely be accessed immediately upon this function returning. An<br>
- * error is returned if either of the dequeue or the wait operations fail.<br>
- */<br>
-static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,<br>
- struct ANativeWindowBuffer** anb) {<br>
- return anw->dequeueBuffer_DEPRECATED(anw, anb);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_sideband_stream(..., native_handle_t*)<br>
- * Attach a sideband buffer stream to a native window.<br>
- */<br>
-static inline int native_window_set_sideband_stream(<br>
- struct ANativeWindow* window,<br>
- native_handle_t* sidebandHandle)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,<br>
- sidebandHandle);<br>
-}<br>
-<br>
-/*<br>
- * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)<br>
- * Set the surface damage (i.e., the region of the surface that has changed<br>
- * since the previous frame). The damage set by this call will be reset (to the<br>
- * default of full-surface damage) after calling queue, so this must be called<br>
- * prior to every frame with damage that does not cover the whole surface if the<br>
- * caller desires downstream consumers to use this optimization.<br>
- *<br>
- * The damage region is specified as an array of rectangles, with the important<br>
- * caveat that the origin of the surface is considered to be the bottom-left<br>
- * corner, as in OpenGL ES.<br>
- *<br>
- * If numRects is set to 0, rects may be NULL, and the surface damage will be<br>
- * set to the full surface (the same as if this function had not been called for<br>
- * this frame).<br>
- */<br>
-static inline int native_window_set_surface_damage(<br>
- struct ANativeWindow* window,<br>
- const android_native_rect_t* rects, size_t numRects)<br>
-{<br>
- return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,<br>
- rects, numRects);<br>
-}<br>
-<br>
-__END_DECLS<br>
-<br>
-#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
<br>
</blockquote></div></div>