include: android: Add Android headers from Cros
Copy the Android Camera3 HAL headers from the ChromiumOS build system and define a new inclusion directive in the meson build system for them. The header files have been copied from: https://chromium.googlesource.com/chromiumos/platform2 at revision 9e65ddd2c496e712f005ada9715decd2ff8e4a03 and provide: 1) Android CameraHAL3 HAL headers in include/android/hardware/ 2) The Android system headers in include/android/system/ 3) The Android camera metadata headers in include/android/metadata/ The original path in the Cros platform2/ repository is, respectively: camera/android/header_files/include/hardware camera/android/header_files/include/system camera/android/libcamera_metadata/include/ Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
3c658acf82
commit
206a22a6e9
17 changed files with 8925 additions and 0 deletions
3093
include/android/hardware/libhardware/include/hardware/camera3.h
Normal file
3093
include/android/hardware/libhardware/include/hardware/camera3.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,916 @@
|
|||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// FIXME: add well-defined names for cameras
|
||||
|
||||
#ifndef ANDROID_INCLUDE_CAMERA_COMMON_H
|
||||
#define ANDROID_INCLUDE_CAMERA_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <cutils/native_handle.h>
|
||||
#include <system/camera.h>
|
||||
#include <system/camera_vendor_tags.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/gralloc.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* The id of this module
|
||||
*/
|
||||
#define CAMERA_HARDWARE_MODULE_ID "camera"
|
||||
|
||||
/**
|
||||
* Module versioning information for the Camera hardware module, based on
|
||||
* camera_module_t.common.module_api_version. The two most significant hex
|
||||
* digits represent the major version, and the two least significant represent
|
||||
* the minor version.
|
||||
*
|
||||
*******************************************************************************
|
||||
* Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0]
|
||||
*
|
||||
* Camera modules that report these version numbers implement the initial
|
||||
* camera module HAL interface. All camera devices openable through this
|
||||
* module support only version 1 of the camera device HAL. The device_version
|
||||
* and static_camera_characteristics fields of camera_info are not valid. Only
|
||||
* the android.hardware.Camera API can be supported by this module and its
|
||||
* devices.
|
||||
*
|
||||
*******************************************************************************
|
||||
* Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0]
|
||||
*
|
||||
* Camera modules that report this version number implement the second version
|
||||
* of the camera module HAL interface. Camera devices openable through this
|
||||
* module may support either version 1.0 or version 2.0 of the camera device
|
||||
* HAL interface. The device_version field of camera_info is always valid; the
|
||||
* static_camera_characteristics field of camera_info is valid if the
|
||||
* device_version field is 2.0 or higher.
|
||||
*
|
||||
*******************************************************************************
|
||||
* Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1]
|
||||
*
|
||||
* This camera module version adds support for asynchronous callbacks to the
|
||||
* framework from the camera HAL module, which is used to notify the framework
|
||||
* about changes to the camera module state. Modules that provide a valid
|
||||
* set_callbacks() method must report at least this version number.
|
||||
*
|
||||
*******************************************************************************
|
||||
* Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2]
|
||||
*
|
||||
* This camera module version adds vendor tag support from the module, and
|
||||
* deprecates the old vendor_tag_query_ops that were previously only
|
||||
* accessible with a device open.
|
||||
*
|
||||
*******************************************************************************
|
||||
* Version: 2.3 [CAMERA_MODULE_API_VERSION_2_3]
|
||||
*
|
||||
* This camera module version adds open legacy camera HAL device support.
|
||||
* Framework can use it to open the camera device as lower device HAL version
|
||||
* HAL device if the same device can support multiple device API versions.
|
||||
* The standard hardware module open call (common.methods->open) continues
|
||||
* to open the camera device with the latest supported version, which is
|
||||
* also the version listed in camera_info_t.device_version.
|
||||
*
|
||||
*******************************************************************************
|
||||
* Version: 2.4 [CAMERA_MODULE_API_VERSION_2_4]
|
||||
*
|
||||
* This camera module version adds below API changes:
|
||||
*
|
||||
* 1. Torch mode support. The framework can use it to turn on torch mode for
|
||||
* any camera device that has a flash unit, without opening a camera device. The
|
||||
* camera device has a higher priority accessing the flash unit than the camera
|
||||
* module; opening a camera device will turn off the torch if it had been enabled
|
||||
* through the module interface. When there are any resource conflicts, such as
|
||||
* open() is called to open a camera device, the camera HAL module must notify the
|
||||
* framework through the torch mode status callback that the torch mode has been
|
||||
* turned off.
|
||||
*
|
||||
* 2. External camera (e.g. USB hot-plug camera) support. The API updates specify that
|
||||
* the camera static info is only available when camera is connected and ready to
|
||||
* use for external hot-plug cameras. Calls to get static info will be invalid
|
||||
* calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The frameworks
|
||||
* will only count on device status change callbacks to manage the available external
|
||||
* camera list.
|
||||
*
|
||||
* 3. Camera arbitration hints. This module version adds support for explicitly
|
||||
* indicating the number of camera devices that can be simultaneously opened and used.
|
||||
* To specify valid combinations of devices, the resource_cost and conflicting_devices
|
||||
* fields should always be set in the camera_info structure returned by the
|
||||
* get_camera_info call.
|
||||
*
|
||||
* 4. Module initialization method. This will be called by the camera service
|
||||
* right after the HAL module is loaded, to allow for one-time initialization
|
||||
* of the HAL. It is called before any other module methods are invoked.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Predefined macros for currently-defined version numbers
|
||||
*/
|
||||
|
||||
/**
|
||||
* All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated
|
||||
* as CAMERA_MODULE_API_VERSION_1_0
|
||||
*/
|
||||
#define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
|
||||
#define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
|
||||
#define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1)
|
||||
#define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2)
|
||||
#define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3)
|
||||
#define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4)
|
||||
|
||||
#define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_4
|
||||
|
||||
/**
|
||||
* All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
|
||||
* as CAMERA_DEVICE_API_VERSION_1_0
|
||||
*/
|
||||
#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
|
||||
#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
|
||||
#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1)
|
||||
#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0)
|
||||
#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1)
|
||||
#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2)
|
||||
#define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3)
|
||||
|
||||
// Device version 3.3 is current, older HAL camera device versions are not
|
||||
// recommended for new devices.
|
||||
#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_3
|
||||
|
||||
/**
|
||||
* Defined in /system/media/camera/include/system/camera_metadata.h
|
||||
*/
|
||||
typedef struct camera_metadata camera_metadata_t;
|
||||
|
||||
typedef struct camera_info {
|
||||
/**
|
||||
* The direction that the camera faces to. See system/core/include/system/camera.h
|
||||
* for camera facing definitions.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3 or lower:
|
||||
*
|
||||
* It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4 or higher:
|
||||
*
|
||||
* It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or
|
||||
* CAMERA_FACING_EXTERNAL.
|
||||
*/
|
||||
int facing;
|
||||
|
||||
/**
|
||||
* The orientation of the camera image. The value is the angle that the
|
||||
* camera image needs to be rotated clockwise so it shows correctly on the
|
||||
* display in its natural orientation. It should be 0, 90, 180, or 270.
|
||||
*
|
||||
* For example, suppose a device has a naturally tall screen. The
|
||||
* back-facing camera sensor is mounted in landscape. You are looking at the
|
||||
* screen. If the top side of the camera sensor is aligned with the right
|
||||
* edge of the screen in natural orientation, the value should be 90. If the
|
||||
* top side of a front-facing camera sensor is aligned with the right of the
|
||||
* screen, the value should be 270.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3 or lower:
|
||||
*
|
||||
* Valid in all camera_module versions.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4 or higher:
|
||||
*
|
||||
* Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT,
|
||||
* not valid if camera facing is CAMERA_FACING_EXTERNAL.
|
||||
*/
|
||||
int orientation;
|
||||
|
||||
/**
|
||||
* The value of camera_device_t.common.version.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_1_0:
|
||||
*
|
||||
* Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do
|
||||
* not read this field.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_0 or higher:
|
||||
*
|
||||
* Always valid
|
||||
*
|
||||
*/
|
||||
uint32_t device_version;
|
||||
|
||||
/**
|
||||
* The camera's fixed characteristics, which include all static camera metadata
|
||||
* specified in system/media/camera/docs/docs.html. This should be a sorted metadata
|
||||
* buffer, and may not be modified or freed by the caller. The pointer should remain
|
||||
* valid for the lifetime of the camera module, and values in it may not
|
||||
* change after it is returned by get_camera_info().
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_1_0:
|
||||
*
|
||||
* Not valid. Extra characteristics are not available. Do not read this
|
||||
* field.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_0 or higher:
|
||||
*
|
||||
* Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read
|
||||
* otherwise.
|
||||
*
|
||||
*/
|
||||
const camera_metadata_t *static_camera_characteristics;
|
||||
|
||||
/**
|
||||
* The total resource "cost" of using this camera, represented as an integer
|
||||
* value in the range [0, 100] where 100 represents total usage of the shared
|
||||
* resource that is the limiting bottleneck of the camera subsystem. This may
|
||||
* be a very rough estimate, and is used as a hint to the camera service to
|
||||
* determine when to disallow multiple applications from simultaneously
|
||||
* opening different cameras advertised by the camera service.
|
||||
*
|
||||
* The camera service must be able to simultaneously open and use any
|
||||
* combination of camera devices exposed by the HAL where the sum of
|
||||
* the resource costs of these cameras is <= 100. For determining cost,
|
||||
* each camera device must be assumed to be configured and operating at
|
||||
* the maximally resource-consuming framerate and stream size settings
|
||||
* available in the configuration settings exposed for that device through
|
||||
* the camera metadata.
|
||||
*
|
||||
* The camera service may still attempt to simultaneously open combinations
|
||||
* of camera devices with a total resource cost > 100. This may succeed or
|
||||
* fail. If this succeeds, combinations of configurations that are not
|
||||
* supported due to resource constraints from having multiple open devices
|
||||
* should fail during the configure calls. If the total resource cost is
|
||||
* <= 100, open and configure should never fail for any stream configuration
|
||||
* settings or other device capabilities that would normally succeed for a
|
||||
* device when it is the only open camera device.
|
||||
*
|
||||
* This field will be used to determine whether background applications are
|
||||
* allowed to use this camera device while other applications are using other
|
||||
* camera devices. Note: multiple applications will never be allowed by the
|
||||
* camera service to simultaneously open the same camera device.
|
||||
*
|
||||
* Example use cases:
|
||||
*
|
||||
* Ex. 1: Camera Device 0 = Back Camera
|
||||
* Camera Device 1 = Front Camera
|
||||
* - Using both camera devices causes a large framerate slowdown due to
|
||||
* limited ISP bandwidth.
|
||||
*
|
||||
* Configuration:
|
||||
*
|
||||
* Camera Device 0 - resource_cost = 51
|
||||
* conflicting_devices = null
|
||||
* Camera Device 1 - resource_cost = 51
|
||||
* conflicting_devices = null
|
||||
*
|
||||
* Result:
|
||||
*
|
||||
* Since the sum of the resource costs is > 100, if a higher-priority
|
||||
* application has either device open, no lower-priority applications will be
|
||||
* allowed by the camera service to open either device. If a lower-priority
|
||||
* application is using a device that a higher-priority subsequently attempts
|
||||
* to open, the lower-priority application will be forced to disconnect the
|
||||
* the device.
|
||||
*
|
||||
* If the highest-priority application chooses, it may still attempt to open
|
||||
* both devices (since these devices are not listed as conflicting in the
|
||||
* conflicting_devices fields), but usage of these devices may fail in the
|
||||
* open or configure calls.
|
||||
*
|
||||
* Ex. 2: Camera Device 0 = Left Back Camera
|
||||
* Camera Device 1 = Right Back Camera
|
||||
* Camera Device 2 = Combined stereo camera using both right and left
|
||||
* back camera sensors used by devices 0, and 1
|
||||
* Camera Device 3 = Front Camera
|
||||
* - Due to do hardware constraints, up to two cameras may be open at once. The
|
||||
* combined stereo camera may never be used at the same time as either of the
|
||||
* two back camera devices (device 0, 1), and typically requires too much
|
||||
* bandwidth to use at the same time as the front camera (device 3).
|
||||
*
|
||||
* Configuration:
|
||||
*
|
||||
* Camera Device 0 - resource_cost = 50
|
||||
* conflicting_devices = { 2 }
|
||||
* Camera Device 1 - resource_cost = 50
|
||||
* conflicting_devices = { 2 }
|
||||
* Camera Device 2 - resource_cost = 100
|
||||
* conflicting_devices = { 0, 1 }
|
||||
* Camera Device 3 - resource_cost = 50
|
||||
* conflicting_devices = null
|
||||
*
|
||||
* Result:
|
||||
*
|
||||
* Based on the conflicting_devices fields, the camera service guarantees that
|
||||
* the following sets of open devices will never be allowed: { 1, 2 }, { 0, 2 }.
|
||||
*
|
||||
* Based on the resource_cost fields, if a high-priority foreground application
|
||||
* is using camera device 0, a background application would be allowed to open
|
||||
* camera device 1 or 3 (but would be forced to disconnect it again if the
|
||||
* foreground application opened another device).
|
||||
*
|
||||
* The highest priority application may still attempt to simultaneously open
|
||||
* devices 0, 2, and 3, but the HAL may fail in open or configure calls for
|
||||
* this combination.
|
||||
*
|
||||
* Ex. 3: Camera Device 0 = Back Camera
|
||||
* Camera Device 1 = Front Camera
|
||||
* Camera Device 2 = Low-power Front Camera that uses the same
|
||||
* sensor as device 1, but only exposes image stream
|
||||
* resolutions that can be used in low-power mode
|
||||
* - Using both front cameras (device 1, 2) at the same time is impossible due
|
||||
* a shared physical sensor. Using the back and "high-power" front camera
|
||||
* (device 1) may be impossible for some stream configurations due to hardware
|
||||
* limitations, but the "low-power" front camera option may always be used as
|
||||
* it has special dedicated hardware.
|
||||
*
|
||||
* Configuration:
|
||||
*
|
||||
* Camera Device 0 - resource_cost = 100
|
||||
* conflicting_devices = null
|
||||
* Camera Device 1 - resource_cost = 100
|
||||
* conflicting_devices = { 2 }
|
||||
* Camera Device 2 - resource_cost = 0
|
||||
* conflicting_devices = { 1 }
|
||||
* Result:
|
||||
*
|
||||
* Based on the conflicting_devices fields, the camera service guarantees that
|
||||
* the following sets of open devices will never be allowed: { 1, 2 }.
|
||||
*
|
||||
* Based on the resource_cost fields, only the highest priority application
|
||||
* may attempt to open both device 0 and 1 at the same time. If a higher-priority
|
||||
* application is not using device 1 or 2, a low-priority background application
|
||||
* may open device 2 (but will be forced to disconnect it if a higher-priority
|
||||
* application subsequently opens device 1 or 2).
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3 or lower:
|
||||
*
|
||||
* Not valid. Can be assumed to be 100. Do not read this field.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4 or higher:
|
||||
*
|
||||
* Always valid.
|
||||
*/
|
||||
int resource_cost;
|
||||
|
||||
/**
|
||||
* An array of camera device IDs represented as NULL-terminated strings
|
||||
* indicating other devices that cannot be simultaneously opened while this
|
||||
* camera device is in use.
|
||||
*
|
||||
* This field is intended to be used to indicate that this camera device
|
||||
* is a composite of several other camera devices, or otherwise has
|
||||
* hardware dependencies that prohibit simultaneous usage. If there are no
|
||||
* dependencies, a NULL may be returned in this field to indicate this.
|
||||
*
|
||||
* The camera service will never simultaneously open any of the devices
|
||||
* in this list while this camera device is open.
|
||||
*
|
||||
* The strings pointed to in this field will not be cleaned up by the camera
|
||||
* service, and must remain while this device is plugged in.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3 or lower:
|
||||
*
|
||||
* Not valid. Can be assumed to be NULL. Do not read this field.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4 or higher:
|
||||
*
|
||||
* Always valid.
|
||||
*/
|
||||
char** conflicting_devices;
|
||||
|
||||
/**
|
||||
* The length of the array given in the conflicting_devices field.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3 or lower:
|
||||
*
|
||||
* Not valid. Can be assumed to be 0. Do not read this field.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4 or higher:
|
||||
*
|
||||
* Always valid.
|
||||
*/
|
||||
size_t conflicting_devices_length;
|
||||
|
||||
} camera_info_t;
|
||||
|
||||
/**
|
||||
* camera_device_status_t:
|
||||
*
|
||||
* The current status of the camera device, as provided by the HAL through the
|
||||
* camera_module_callbacks.camera_device_status_change() call.
|
||||
*
|
||||
* At module load time, the framework will assume all camera devices are in the
|
||||
* CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke
|
||||
* camera_module_callbacks::camera_device_status_change to inform the framework
|
||||
* of any initially NOT_PRESENT devices.
|
||||
*
|
||||
* Allowed transitions:
|
||||
* PRESENT -> NOT_PRESENT
|
||||
* NOT_PRESENT -> ENUMERATING
|
||||
* NOT_PRESENT -> PRESENT
|
||||
* ENUMERATING -> PRESENT
|
||||
* ENUMERATING -> NOT_PRESENT
|
||||
*/
|
||||
typedef enum camera_device_status {
|
||||
/**
|
||||
* The camera device is not currently connected, and opening it will return
|
||||
* failure.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3 or lower:
|
||||
*
|
||||
* Calls to get_camera_info must still succeed, and provide the same information
|
||||
* it would if the camera were connected.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4:
|
||||
*
|
||||
* The camera device at this status must return -EINVAL for get_camera_info call,
|
||||
* as the device is not connected.
|
||||
*/
|
||||
CAMERA_DEVICE_STATUS_NOT_PRESENT = 0,
|
||||
|
||||
/**
|
||||
* The camera device is connected, and opening it will succeed.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3 or lower:
|
||||
*
|
||||
* The information returned by get_camera_info cannot change due to this status
|
||||
* change. By default, the framework will assume all devices are in this state.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4:
|
||||
*
|
||||
* The information returned by get_camera_info will become valid after a device's
|
||||
* status changes to this. By default, the framework will assume all devices are in
|
||||
* this state.
|
||||
*/
|
||||
CAMERA_DEVICE_STATUS_PRESENT = 1,
|
||||
|
||||
/**
|
||||
* The camera device is connected, but it is undergoing an enumeration and
|
||||
* so opening the device will return -EBUSY.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3 or lower:
|
||||
*
|
||||
* Calls to get_camera_info must still succeed, as if the camera was in the
|
||||
* PRESENT status.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4:
|
||||
*
|
||||
* The camera device at this status must return -EINVAL for get_camera_info for call,
|
||||
* as the device is not ready.
|
||||
*/
|
||||
CAMERA_DEVICE_STATUS_ENUMERATING = 2,
|
||||
|
||||
} camera_device_status_t;
|
||||
|
||||
/**
|
||||
* torch_mode_status_t:
|
||||
*
|
||||
* The current status of the torch mode, as provided by the HAL through the
|
||||
* camera_module_callbacks.torch_mode_status_change() call.
|
||||
*
|
||||
* The torch mode status of a camera device is applicable only when the camera
|
||||
* device is present. The framework will not call set_torch_mode() to turn on
|
||||
* torch mode of a camera device if the camera device is not present. At module
|
||||
* load time, the framework will assume torch modes are in the
|
||||
* TORCH_MODE_STATUS_AVAILABLE_OFF state if the camera device is present and
|
||||
* android.flash.info.available is reported as true via get_camera_info() call.
|
||||
*
|
||||
* The behaviors of the camera HAL module that the framework expects in the
|
||||
* following situations when a camera device's status changes:
|
||||
* 1. A previously-disconnected camera device becomes connected.
|
||||
* After camera_module_callbacks::camera_device_status_change() is invoked
|
||||
* to inform the framework that the camera device is present, the framework
|
||||
* will assume the camera device's torch mode is in
|
||||
* TORCH_MODE_STATUS_AVAILABLE_OFF state. The camera HAL module does not need
|
||||
* to invoke camera_module_callbacks::torch_mode_status_change() unless the
|
||||
* flash unit is unavailable to use by set_torch_mode().
|
||||
*
|
||||
* 2. A previously-connected camera becomes disconnected.
|
||||
* After camera_module_callbacks::camera_device_status_change() is invoked
|
||||
* to inform the framework that the camera device is not present, the
|
||||
* framework will not call set_torch_mode() for the disconnected camera
|
||||
* device until its flash unit becomes available again. The camera HAL
|
||||
* module does not need to invoke
|
||||
* camera_module_callbacks::torch_mode_status_change() separately to inform
|
||||
* that the flash unit has become unavailable.
|
||||
*
|
||||
* 3. open() is called to open a camera device.
|
||||
* The camera HAL module must invoke
|
||||
* camera_module_callbacks::torch_mode_status_change() for all flash units
|
||||
* that have entered TORCH_MODE_STATUS_NOT_AVAILABLE state and can not be
|
||||
* turned on by calling set_torch_mode() anymore due to this open() call.
|
||||
* open() must not trigger TORCH_MODE_STATUS_AVAILABLE_OFF before
|
||||
* TORCH_MODE_STATUS_NOT_AVAILABLE for all flash units that have become
|
||||
* unavailable.
|
||||
*
|
||||
* 4. close() is called to close a camera device.
|
||||
* The camera HAL module must invoke
|
||||
* camera_module_callbacks::torch_mode_status_change() for all flash units
|
||||
* that have entered TORCH_MODE_STATUS_AVAILABLE_OFF state and can be turned
|
||||
* on by calling set_torch_mode() again because of enough resources freed
|
||||
* up by this close() call.
|
||||
*
|
||||
* Note that the framework calling set_torch_mode() successfully must trigger
|
||||
* TORCH_MODE_STATUS_AVAILABLE_OFF or TORCH_MODE_STATUS_AVAILABLE_ON callback
|
||||
* for the given camera device. Additionally it must trigger
|
||||
* TORCH_MODE_STATUS_AVAILABLE_OFF callbacks for other previously-on torch
|
||||
* modes if HAL cannot keep multiple torch modes on simultaneously.
|
||||
*/
|
||||
typedef enum torch_mode_status {
|
||||
|
||||
/**
|
||||
* The flash unit is no longer available and the torch mode can not be
|
||||
* turned on by calling set_torch_mode(). If the torch mode is on, it
|
||||
* will be turned off by HAL before HAL calls torch_mode_status_change().
|
||||
*/
|
||||
TORCH_MODE_STATUS_NOT_AVAILABLE = 0,
|
||||
|
||||
/**
|
||||
* A torch mode has become off and available to be turned on via
|
||||
* set_torch_mode(). This may happen in the following
|
||||
* cases:
|
||||
* 1. After the resources to turn on the torch mode have become available.
|
||||
* 2. After set_torch_mode() is called to turn off the torch mode.
|
||||
* 3. After the framework turned on the torch mode of some other camera
|
||||
* device and HAL had to turn off the torch modes of any camera devices
|
||||
* that were previously on.
|
||||
*/
|
||||
TORCH_MODE_STATUS_AVAILABLE_OFF = 1,
|
||||
|
||||
/**
|
||||
* A torch mode has become on and available to be turned off via
|
||||
* set_torch_mode(). This can happen only after set_torch_mode() is called
|
||||
* to turn on the torch mode.
|
||||
*/
|
||||
TORCH_MODE_STATUS_AVAILABLE_ON = 2,
|
||||
|
||||
} torch_mode_status_t;
|
||||
|
||||
/**
|
||||
* Callback functions for the camera HAL module to use to inform the framework
|
||||
* of changes to the camera subsystem.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* Each callback is called only by HAL modules implementing the indicated
|
||||
* version or higher of the HAL module API interface.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_1:
|
||||
* camera_device_status_change()
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4:
|
||||
* torch_mode_status_change()
|
||||
|
||||
*/
|
||||
typedef struct camera_module_callbacks {
|
||||
|
||||
/**
|
||||
* camera_device_status_change:
|
||||
*
|
||||
* Callback to the framework to indicate that the state of a specific camera
|
||||
* device has changed. At module load time, the framework will assume all
|
||||
* camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL
|
||||
* must call this method to inform the framework of any initially
|
||||
* NOT_PRESENT devices.
|
||||
*
|
||||
* This callback is added for CAMERA_MODULE_API_VERSION_2_1.
|
||||
*
|
||||
* camera_module_callbacks: The instance of camera_module_callbacks_t passed
|
||||
* to the module with set_callbacks.
|
||||
*
|
||||
* camera_id: The ID of the camera device that has a new status.
|
||||
*
|
||||
* new_status: The new status code, one of the camera_device_status_t enums,
|
||||
* or a platform-specific status.
|
||||
*
|
||||
*/
|
||||
void (*camera_device_status_change)(const struct camera_module_callbacks*,
|
||||
int camera_id,
|
||||
int new_status);
|
||||
|
||||
/**
|
||||
* torch_mode_status_change:
|
||||
*
|
||||
* Callback to the framework to indicate that the state of the torch mode
|
||||
* of the flash unit associated with a specific camera device has changed.
|
||||
* At module load time, the framework will assume the torch modes are in
|
||||
* the TORCH_MODE_STATUS_AVAILABLE_OFF state if android.flash.info.available
|
||||
* is reported as true via get_camera_info() call.
|
||||
*
|
||||
* This callback is added for CAMERA_MODULE_API_VERSION_2_4.
|
||||
*
|
||||
* camera_module_callbacks: The instance of camera_module_callbacks_t
|
||||
* passed to the module with set_callbacks.
|
||||
*
|
||||
* camera_id: The ID of camera device whose flash unit has a new torch mode
|
||||
* status.
|
||||
*
|
||||
* new_status: The new status code, one of the torch_mode_status_t enums.
|
||||
*/
|
||||
void (*torch_mode_status_change)(const struct camera_module_callbacks*,
|
||||
const char* camera_id,
|
||||
int new_status);
|
||||
|
||||
|
||||
} camera_module_callbacks_t;
|
||||
|
||||
typedef struct camera_module {
|
||||
/**
|
||||
* Common methods of the camera module. This *must* be the first member of
|
||||
* camera_module as users of this structure will cast a hw_module_t to
|
||||
* camera_module pointer in contexts where it's known the hw_module_t
|
||||
* references a camera_module.
|
||||
*
|
||||
* The return values for common.methods->open for camera_module are:
|
||||
*
|
||||
* 0: On a successful open of the camera device.
|
||||
*
|
||||
* -ENODEV: The camera device cannot be opened due to an internal
|
||||
* error.
|
||||
*
|
||||
* -EINVAL: The input arguments are invalid, i.e. the id is invalid,
|
||||
* and/or the module is invalid.
|
||||
*
|
||||
* -EBUSY: The camera device was already opened for this camera id
|
||||
* (by using this method or open_legacy),
|
||||
* regardless of the device HAL version it was opened as.
|
||||
*
|
||||
* -EUSERS: The maximal number of camera devices that can be
|
||||
* opened concurrently were opened already, either by
|
||||
* this method or the open_legacy method.
|
||||
*
|
||||
* All other return values from common.methods->open will be treated as
|
||||
* -ENODEV.
|
||||
*/
|
||||
hw_module_t common;
|
||||
|
||||
/**
|
||||
* get_number_of_cameras:
|
||||
*
|
||||
* Returns the number of camera devices accessible through the camera
|
||||
* module. The camera devices are numbered 0 through N-1, where N is the
|
||||
* value returned by this call. The name of the camera device for open() is
|
||||
* simply the number converted to a string. That is, "0" for camera ID 0,
|
||||
* "1" for camera ID 1.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3 or lower:
|
||||
*
|
||||
* The value here must be static, and cannot change after the first call
|
||||
* to this method.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4 or higher:
|
||||
*
|
||||
* The value here must be static, and must count only built-in cameras,
|
||||
* which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values
|
||||
* (camera_info.facing). The HAL must not include the external cameras
|
||||
* (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value
|
||||
* of this call. Frameworks will use camera_device_status_change callback
|
||||
* to manage number of external cameras.
|
||||
*/
|
||||
int (*get_number_of_cameras)(void);
|
||||
|
||||
/**
|
||||
* get_camera_info:
|
||||
*
|
||||
* Return the static camera information for a given camera device. This
|
||||
* information may not change for a camera device.
|
||||
*
|
||||
* Return values:
|
||||
*
|
||||
* 0: On a successful operation
|
||||
*
|
||||
* -ENODEV: The information cannot be provided due to an internal
|
||||
* error.
|
||||
*
|
||||
* -EINVAL: The input arguments are invalid, i.e. the id is invalid,
|
||||
* and/or the module is invalid.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4 or higher:
|
||||
*
|
||||
* When a camera is disconnected, its camera id becomes invalid. Calling this
|
||||
* this method with this invalid camera id will get -EINVAL and NULL camera
|
||||
* static metadata (camera_info.static_camera_characteristics).
|
||||
*/
|
||||
int (*get_camera_info)(int camera_id, struct camera_info *info);
|
||||
|
||||
/**
|
||||
* set_callbacks:
|
||||
*
|
||||
* Provide callback function pointers to the HAL module to inform framework
|
||||
* of asynchronous camera module events. The framework will call this
|
||||
* function once after initial camera HAL module load, after the
|
||||
* get_number_of_cameras() method is called for the first time, and before
|
||||
* any other calls to the module.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0:
|
||||
*
|
||||
* Not provided by HAL module. Framework may not call this function.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_1:
|
||||
*
|
||||
* Valid to be called by the framework.
|
||||
*
|
||||
* Return values:
|
||||
*
|
||||
* 0: On a successful operation
|
||||
*
|
||||
* -ENODEV: The operation cannot be completed due to an internal
|
||||
* error.
|
||||
*
|
||||
* -EINVAL: The input arguments are invalid, i.e. the callbacks are
|
||||
* null
|
||||
*/
|
||||
int (*set_callbacks)(const camera_module_callbacks_t *callbacks);
|
||||
|
||||
/**
|
||||
* get_vendor_tag_ops:
|
||||
*
|
||||
* Get methods to query for vendor extension metadata tag information. The
|
||||
* HAL should fill in all the vendor tag operation methods, or leave ops
|
||||
* unchanged if no vendor tags are defined.
|
||||
*
|
||||
* The vendor_tag_ops structure used here is defined in:
|
||||
* system/media/camera/include/system/vendor_tags.h
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_1_x/2_0/2_1:
|
||||
* Not provided by HAL module. Framework may not call this function.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_2:
|
||||
* Valid to be called by the framework.
|
||||
*/
|
||||
void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops);
|
||||
|
||||
/**
|
||||
* open_legacy:
|
||||
*
|
||||
* Open a specific legacy camera HAL device if multiple device HAL API
|
||||
* versions are supported by this camera HAL module. For example, if the
|
||||
* camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and
|
||||
* CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id,
|
||||
* framework can call this function to open the camera device as
|
||||
* CAMERA_DEVICE_API_VERSION_1_0 device.
|
||||
*
|
||||
* This is an optional method. A Camera HAL module does not need to support
|
||||
* more than one device HAL version per device, and such modules may return
|
||||
* -ENOSYS for all calls to this method. For all older HAL device API
|
||||
* versions that are not supported, it may return -EOPNOTSUPP. When above
|
||||
* cases occur, The normal open() method (common.methods->open) will be
|
||||
* used by the framework instead.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2:
|
||||
* Not provided by HAL module. Framework will not call this function.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_3:
|
||||
* Valid to be called by the framework.
|
||||
*
|
||||
* Return values:
|
||||
*
|
||||
* 0: On a successful open of the camera device.
|
||||
*
|
||||
* -ENOSYS This method is not supported.
|
||||
*
|
||||
* -EOPNOTSUPP: The requested HAL version is not supported by this method.
|
||||
*
|
||||
* -EINVAL: The input arguments are invalid, i.e. the id is invalid,
|
||||
* and/or the module is invalid.
|
||||
*
|
||||
* -EBUSY: The camera device was already opened for this camera id
|
||||
* (by using this method or common.methods->open method),
|
||||
* regardless of the device HAL version it was opened as.
|
||||
*
|
||||
* -EUSERS: The maximal number of camera devices that can be
|
||||
* opened concurrently were opened already, either by
|
||||
* this method or common.methods->open method.
|
||||
*/
|
||||
int (*open_legacy)(const struct hw_module_t* module, const char* id,
|
||||
uint32_t halVersion, struct hw_device_t** device);
|
||||
|
||||
/**
|
||||
* set_torch_mode:
|
||||
*
|
||||
* Turn on or off the torch mode of the flash unit associated with a given
|
||||
* camera ID. If the operation is successful, HAL must notify the framework
|
||||
* torch state by invoking
|
||||
* camera_module_callbacks.torch_mode_status_change() with the new state.
|
||||
*
|
||||
* The camera device has a higher priority accessing the flash unit. When
|
||||
* there are any resource conflicts, such as open() is called to open a
|
||||
* camera device, HAL module must notify the framework through
|
||||
* camera_module_callbacks.torch_mode_status_change() that the
|
||||
* torch mode has been turned off and the torch mode state has become
|
||||
* TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode
|
||||
* become available again, HAL module must notify the framework through
|
||||
* camera_module_callbacks.torch_mode_status_change() that the torch mode
|
||||
* state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to
|
||||
* be called.
|
||||
*
|
||||
* When the framework calls set_torch_mode() to turn on the torch mode of a
|
||||
* flash unit, if HAL cannot keep multiple torch modes on simultaneously,
|
||||
* HAL should turn off the torch mode that was turned on by
|
||||
* a previous set_torch_mode() call and notify the framework that the torch
|
||||
* mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
|
||||
* Not provided by HAL module. Framework will not call this function.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4:
|
||||
* Valid to be called by the framework.
|
||||
*
|
||||
* Return values:
|
||||
*
|
||||
* 0: On a successful operation.
|
||||
*
|
||||
* -ENOSYS: The camera device does not support this operation. It is
|
||||
* returned if and only if android.flash.info.available is
|
||||
* false.
|
||||
*
|
||||
* -EBUSY: The camera device is already in use.
|
||||
*
|
||||
* -EUSERS: The resources needed to turn on the torch mode are not
|
||||
* available, typically because other camera devices are
|
||||
* holding the resources to make using the flash unit not
|
||||
* possible.
|
||||
*
|
||||
* -EINVAL: camera_id is invalid.
|
||||
*
|
||||
*/
|
||||
int (*set_torch_mode)(const char* camera_id, bool enabled);
|
||||
|
||||
/**
|
||||
* init:
|
||||
*
|
||||
* This method is called by the camera service before any other methods
|
||||
* are invoked, right after the camera HAL library has been successfully
|
||||
* loaded. It may be left as NULL by the HAL module, if no initialization
|
||||
* in needed.
|
||||
*
|
||||
* It can be used by HAL implementations to perform initialization and
|
||||
* other one-time operations.
|
||||
*
|
||||
* Version information (based on camera_module_t.common.module_api_version):
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
|
||||
* Not provided by HAL module. Framework will not call this function.
|
||||
*
|
||||
* CAMERA_MODULE_API_VERSION_2_4:
|
||||
* If not NULL, will always be called by the framework once after the HAL
|
||||
* module is loaded, before any other HAL module method is called.
|
||||
*
|
||||
* Return values:
|
||||
*
|
||||
* 0: On a successful operation.
|
||||
*
|
||||
* -ENODEV: Initialization cannot be completed due to an internal
|
||||
* error. The HAL must be assumed to be in a nonfunctional
|
||||
* state.
|
||||
*
|
||||
*/
|
||||
int (*init)();
|
||||
|
||||
/* reserved for future use */
|
||||
void* reserved[5];
|
||||
} camera_module_t;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */
|
173
include/android/hardware/libhardware/include/hardware/fb.h
Normal file
173
include/android/hardware/libhardware/include/hardware/fb.h
Normal file
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ANDROID_FB_INTERFACE_H
|
||||
#define ANDROID_FB_INTERFACE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GRALLOC_HARDWARE_FB0 "fb0"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct framebuffer_device_t {
|
||||
/**
|
||||
* Common methods of the framebuffer device. This *must* be the first member of
|
||||
* framebuffer_device_t as users of this structure will cast a hw_device_t to
|
||||
* framebuffer_device_t pointer in contexts where it's known the hw_device_t references a
|
||||
* framebuffer_device_t.
|
||||
*/
|
||||
struct hw_device_t common;
|
||||
|
||||
/* flags describing some attributes of the framebuffer */
|
||||
const uint32_t flags;
|
||||
|
||||
/* dimensions of the framebuffer in pixels */
|
||||
const uint32_t width;
|
||||
const uint32_t height;
|
||||
|
||||
/* frambuffer stride in pixels */
|
||||
const int stride;
|
||||
|
||||
/* framebuffer pixel format */
|
||||
const int format;
|
||||
|
||||
/* resolution of the framebuffer's display panel in pixel per inch*/
|
||||
const float xdpi;
|
||||
const float ydpi;
|
||||
|
||||
/* framebuffer's display panel refresh rate in frames per second */
|
||||
const float fps;
|
||||
|
||||
/* min swap interval supported by this framebuffer */
|
||||
const int minSwapInterval;
|
||||
|
||||
/* max swap interval supported by this framebuffer */
|
||||
const int maxSwapInterval;
|
||||
|
||||
/* Number of framebuffers supported*/
|
||||
const int numFramebuffers;
|
||||
|
||||
int reserved[7];
|
||||
|
||||
/*
|
||||
* requests a specific swap-interval (same definition than EGL)
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*setSwapInterval)(struct framebuffer_device_t* window,
|
||||
int interval);
|
||||
|
||||
/*
|
||||
* This hook is OPTIONAL.
|
||||
*
|
||||
* It is non NULL If the framebuffer driver supports "update-on-demand"
|
||||
* and the given rectangle is the area of the screen that gets
|
||||
* updated during (*post)().
|
||||
*
|
||||
* This is useful on devices that are able to DMA only a portion of
|
||||
* the screen to the display panel, upon demand -- as opposed to
|
||||
* constantly refreshing the panel 60 times per second, for instance.
|
||||
*
|
||||
* Only the area defined by this rectangle is guaranteed to be valid, that
|
||||
* is, the driver is not allowed to post anything outside of this
|
||||
* rectangle.
|
||||
*
|
||||
* The rectangle evaluated during (*post)() and specifies which area
|
||||
* of the buffer passed in (*post)() shall to be posted.
|
||||
*
|
||||
* return -EINVAL if width or height <=0, or if left or top < 0
|
||||
*/
|
||||
int (*setUpdateRect)(struct framebuffer_device_t* window,
|
||||
int left, int top, int width, int height);
|
||||
|
||||
/*
|
||||
* Post <buffer> to the display (display it on the screen)
|
||||
* The buffer must have been allocated with the
|
||||
* GRALLOC_USAGE_HW_FB usage flag.
|
||||
* buffer must be the same width and height as the display and must NOT
|
||||
* be locked.
|
||||
*
|
||||
* The buffer is shown during the next VSYNC.
|
||||
*
|
||||
* If the same buffer is posted again (possibly after some other buffer),
|
||||
* post() will block until the the first post is completed.
|
||||
*
|
||||
* Internally, post() is expected to lock the buffer so that a
|
||||
* subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or
|
||||
* USAGE_*_WRITE will block until it is safe; that is typically once this
|
||||
* buffer is shown and another buffer has been posted.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer);
|
||||
|
||||
|
||||
/*
|
||||
* The (*compositionComplete)() method must be called after the
|
||||
* compositor has finished issuing GL commands for client buffers.
|
||||
*/
|
||||
|
||||
int (*compositionComplete)(struct framebuffer_device_t* dev);
|
||||
|
||||
/*
|
||||
* This hook is OPTIONAL.
|
||||
*
|
||||
* If non NULL it will be caused by SurfaceFlinger on dumpsys
|
||||
*/
|
||||
void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len);
|
||||
|
||||
/*
|
||||
* (*enableScreen)() is used to either blank (enable=0) or
|
||||
* unblank (enable=1) the screen this framebuffer is attached to.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*enableScreen)(struct framebuffer_device_t* dev, int enable);
|
||||
|
||||
void* reserved_proc[6];
|
||||
|
||||
} framebuffer_device_t;
|
||||
|
||||
|
||||
/** convenience API for opening and closing a supported device */
|
||||
|
||||
static inline int framebuffer_open(const struct hw_module_t* module,
|
||||
struct framebuffer_device_t** device) {
|
||||
return module->methods->open(module,
|
||||
GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device);
|
||||
}
|
||||
|
||||
static inline int framebuffer_close(struct framebuffer_device_t* device) {
|
||||
return device->common.close(&device->common);
|
||||
}
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // ANDROID_FB_INTERFACE_H
|
384
include/android/hardware/libhardware/include/hardware/gralloc.h
Normal file
384
include/android/hardware/libhardware/include/hardware/gralloc.h
Normal file
|
@ -0,0 +1,384 @@
|
|||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ANDROID_GRALLOC_INTERFACE_H
|
||||
#define ANDROID_GRALLOC_INTERFACE_H
|
||||
|
||||
#include <system/window.h>
|
||||
#include <system/graphics.h>
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/fb.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* Module versioning information for the Gralloc hardware module, based on
|
||||
* gralloc_module_t.common.module_api_version.
|
||||
*
|
||||
* Version History:
|
||||
*
|
||||
* GRALLOC_MODULE_API_VERSION_0_1:
|
||||
* Initial Gralloc hardware module API.
|
||||
*
|
||||
* GRALLOC_MODULE_API_VERSION_0_2:
|
||||
* Add support for flexible YCbCr format with (*lock_ycbcr)() method.
|
||||
*
|
||||
* GRALLOC_MODULE_API_VERSION_0_3:
|
||||
* Add support for fence passing to/from lock/unlock.
|
||||
*/
|
||||
|
||||
#define GRALLOC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
|
||||
#define GRALLOC_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2)
|
||||
#define GRALLOC_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3)
|
||||
|
||||
#define GRALLOC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1)
|
||||
|
||||
/**
|
||||
* The id of this module
|
||||
*/
|
||||
#define GRALLOC_HARDWARE_MODULE_ID "gralloc"
|
||||
|
||||
/**
|
||||
* Name of the graphics device to open
|
||||
*/
|
||||
|
||||
#define GRALLOC_HARDWARE_GPU0 "gpu0"
|
||||
|
||||
enum {
|
||||
/* buffer is never read in software */
|
||||
GRALLOC_USAGE_SW_READ_NEVER = 0x00000000,
|
||||
/* buffer is rarely read in software */
|
||||
GRALLOC_USAGE_SW_READ_RARELY = 0x00000002,
|
||||
/* buffer is often read in software */
|
||||
GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003,
|
||||
/* mask for the software read values */
|
||||
GRALLOC_USAGE_SW_READ_MASK = 0x0000000F,
|
||||
|
||||
/* buffer is never written in software */
|
||||
GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000,
|
||||
/* buffer is rarely written in software */
|
||||
GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020,
|
||||
/* buffer is often written in software */
|
||||
GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030,
|
||||
/* mask for the software write values */
|
||||
GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0,
|
||||
|
||||
/* buffer will be used as an OpenGL ES texture */
|
||||
GRALLOC_USAGE_HW_TEXTURE = 0x00000100,
|
||||
/* buffer will be used as an OpenGL ES render target */
|
||||
GRALLOC_USAGE_HW_RENDER = 0x00000200,
|
||||
/* buffer will be used by the 2D hardware blitter */
|
||||
GRALLOC_USAGE_HW_2D = 0x00000400,
|
||||
/* buffer will be used by the HWComposer HAL module */
|
||||
GRALLOC_USAGE_HW_COMPOSER = 0x00000800,
|
||||
/* buffer will be used with the framebuffer device */
|
||||
GRALLOC_USAGE_HW_FB = 0x00001000,
|
||||
|
||||
/* buffer should be displayed full-screen on an external display when
|
||||
* possible */
|
||||
GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000,
|
||||
|
||||
/* Must have a hardware-protected path to external display sink for
|
||||
* this buffer. If a hardware-protected path is not available, then
|
||||
* either don't composite only this buffer (preferred) to the
|
||||
* external sink, or (less desirable) do not route the entire
|
||||
* composition to the external sink. */
|
||||
GRALLOC_USAGE_PROTECTED = 0x00004000,
|
||||
|
||||
/* buffer may be used as a cursor */
|
||||
GRALLOC_USAGE_CURSOR = 0x00008000,
|
||||
|
||||
/* buffer will be used with the HW video encoder */
|
||||
GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000,
|
||||
/* buffer will be written by the HW camera pipeline */
|
||||
GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000,
|
||||
/* buffer will be read by the HW camera pipeline */
|
||||
GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000,
|
||||
/* buffer will be used as part of zero-shutter-lag queue */
|
||||
GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000,
|
||||
/* mask for the camera access values */
|
||||
GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000,
|
||||
/* mask for the software usage bit-mask */
|
||||
GRALLOC_USAGE_HW_MASK = 0x00071F00,
|
||||
|
||||
/* buffer will be used as a RenderScript Allocation */
|
||||
GRALLOC_USAGE_RENDERSCRIPT = 0x00100000,
|
||||
|
||||
/* Set by the consumer to indicate to the producer that they may attach a
|
||||
* buffer that they did not detach from the BufferQueue. Will be filtered
|
||||
* out by GRALLOC_USAGE_ALLOC_MASK, so gralloc modules will not need to
|
||||
* handle this flag. */
|
||||
GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000,
|
||||
|
||||
/* Mask of all flags which could be passed to a gralloc module for buffer
|
||||
* allocation. Any flags not in this mask do not need to be handled by
|
||||
* gralloc modules. */
|
||||
GRALLOC_USAGE_ALLOC_MASK = ~(GRALLOC_USAGE_FOREIGN_BUFFERS),
|
||||
|
||||
/* implementation-specific private usage flags */
|
||||
GRALLOC_USAGE_PRIVATE_0 = 0x10000000,
|
||||
GRALLOC_USAGE_PRIVATE_1 = 0x20000000,
|
||||
GRALLOC_USAGE_PRIVATE_2 = 0x40000000,
|
||||
GRALLOC_USAGE_PRIVATE_3 = 0x80000000,
|
||||
GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000,
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
|
||||
* and the fields of this data structure must begin with hw_module_t
|
||||
* followed by module specific information.
|
||||
*/
|
||||
typedef struct gralloc_module_t {
|
||||
struct hw_module_t common;
|
||||
|
||||
/*
|
||||
* (*registerBuffer)() must be called before a buffer_handle_t that has not
|
||||
* been created with (*alloc_device_t::alloc)() can be used.
|
||||
*
|
||||
* This is intended to be used with buffer_handle_t's that have been
|
||||
* received in this process through IPC.
|
||||
*
|
||||
* This function checks that the handle is indeed a valid one and prepares
|
||||
* it for use with (*lock)() and (*unlock)().
|
||||
*
|
||||
* It is not necessary to call (*registerBuffer)() on a handle created
|
||||
* with (*alloc_device_t::alloc)().
|
||||
*
|
||||
* returns an error if this buffer_handle_t is not valid.
|
||||
*/
|
||||
int (*registerBuffer)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle);
|
||||
|
||||
/*
|
||||
* (*unregisterBuffer)() is called once this handle is no longer needed in
|
||||
* this process. After this call, it is an error to call (*lock)(),
|
||||
* (*unlock)(), or (*registerBuffer)().
|
||||
*
|
||||
* This function doesn't close or free the handle itself; this is done
|
||||
* by other means, usually through libcutils's native_handle_close() and
|
||||
* native_handle_free().
|
||||
*
|
||||
* It is an error to call (*unregisterBuffer)() on a buffer that wasn't
|
||||
* explicitly registered first.
|
||||
*/
|
||||
int (*unregisterBuffer)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle);
|
||||
|
||||
/*
|
||||
* The (*lock)() method is called before a buffer is accessed for the
|
||||
* specified usage. This call may block, for instance if the h/w needs
|
||||
* to finish rendering or if CPU caches need to be synchronized.
|
||||
*
|
||||
* The caller promises to modify only pixels in the area specified
|
||||
* by (l,t,w,h).
|
||||
*
|
||||
* The content of the buffer outside of the specified area is NOT modified
|
||||
* by this call.
|
||||
*
|
||||
* If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address
|
||||
* of the buffer in virtual memory.
|
||||
*
|
||||
* Note calling (*lock)() on HAL_PIXEL_FORMAT_YCbCr_*_888 buffers will fail
|
||||
* and return -EINVAL. These buffers must be locked with (*lock_ycbcr)()
|
||||
* instead.
|
||||
*
|
||||
* THREADING CONSIDERATIONS:
|
||||
*
|
||||
* It is legal for several different threads to lock a buffer from
|
||||
* read access, none of the threads are blocked.
|
||||
*
|
||||
* However, locking a buffer simultaneously for write or read/write is
|
||||
* undefined, but:
|
||||
* - shall not result in termination of the process
|
||||
* - shall not block the caller
|
||||
* It is acceptable to return an error or to leave the buffer's content
|
||||
* into an indeterminate state.
|
||||
*
|
||||
* If the buffer was created with a usage mask incompatible with the
|
||||
* requested usage flags here, -EINVAL is returned.
|
||||
*
|
||||
*/
|
||||
|
||||
int (*lock)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle, int usage,
|
||||
int l, int t, int w, int h,
|
||||
void** vaddr);
|
||||
|
||||
|
||||
/*
|
||||
* The (*unlock)() method must be called after all changes to the buffer
|
||||
* are completed.
|
||||
*/
|
||||
|
||||
int (*unlock)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle);
|
||||
|
||||
|
||||
/* reserved for future use */
|
||||
int (*perform)(struct gralloc_module_t const* module,
|
||||
int operation, ... );
|
||||
|
||||
/*
|
||||
* The (*lock_ycbcr)() method is like the (*lock)() method, with the
|
||||
* difference that it fills a struct ycbcr with a description of the buffer
|
||||
* layout, and zeroes out the reserved fields.
|
||||
*
|
||||
* If the buffer format is not compatible with a flexible YUV format (e.g.
|
||||
* the buffer layout cannot be represented with the ycbcr struct), it
|
||||
* will return -EINVAL.
|
||||
*
|
||||
* This method must work on buffers with HAL_PIXEL_FORMAT_YCbCr_*_888
|
||||
* if supported by the device, as well as with any other format that is
|
||||
* requested by the multimedia codecs when they are configured with a
|
||||
* flexible-YUV-compatible color-format with android native buffers.
|
||||
*
|
||||
* Note that this method may also be called on buffers of other formats,
|
||||
* including non-YUV formats.
|
||||
*
|
||||
* Added in GRALLOC_MODULE_API_VERSION_0_2.
|
||||
*/
|
||||
|
||||
int (*lock_ycbcr)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle, int usage,
|
||||
int l, int t, int w, int h,
|
||||
struct android_ycbcr *ycbcr);
|
||||
|
||||
/*
|
||||
* The (*lockAsync)() method is like the (*lock)() method except
|
||||
* that the buffer's sync fence object is passed into the lock
|
||||
* call instead of requiring the caller to wait for completion.
|
||||
*
|
||||
* The gralloc implementation takes ownership of the fenceFd and
|
||||
* is responsible for closing it when no longer needed.
|
||||
*
|
||||
* Added in GRALLOC_MODULE_API_VERSION_0_3.
|
||||
*/
|
||||
int (*lockAsync)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle, int usage,
|
||||
int l, int t, int w, int h,
|
||||
void** vaddr, int fenceFd);
|
||||
|
||||
/*
|
||||
* The (*unlockAsync)() method is like the (*unlock)() method
|
||||
* except that a buffer sync fence object is returned from the
|
||||
* lock call, representing the completion of any pending work
|
||||
* performed by the gralloc implementation.
|
||||
*
|
||||
* The caller takes ownership of the fenceFd and is responsible
|
||||
* for closing it when no longer needed.
|
||||
*
|
||||
* Added in GRALLOC_MODULE_API_VERSION_0_3.
|
||||
*/
|
||||
int (*unlockAsync)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle, int* fenceFd);
|
||||
|
||||
/*
|
||||
* The (*lockAsync_ycbcr)() method is like the (*lock_ycbcr)()
|
||||
* method except that the buffer's sync fence object is passed
|
||||
* into the lock call instead of requiring the caller to wait for
|
||||
* completion.
|
||||
*
|
||||
* The gralloc implementation takes ownership of the fenceFd and
|
||||
* is responsible for closing it when no longer needed.
|
||||
*
|
||||
* Added in GRALLOC_MODULE_API_VERSION_0_3.
|
||||
*/
|
||||
int (*lockAsync_ycbcr)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle, int usage,
|
||||
int l, int t, int w, int h,
|
||||
struct android_ycbcr *ycbcr, int fenceFd);
|
||||
|
||||
/* reserved for future use */
|
||||
void* reserved_proc[3];
|
||||
} gralloc_module_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* Every device data structure must begin with hw_device_t
|
||||
* followed by module specific public methods and attributes.
|
||||
*/
|
||||
|
||||
typedef struct alloc_device_t {
|
||||
struct hw_device_t common;
|
||||
|
||||
/*
|
||||
* (*alloc)() Allocates a buffer in graphic memory with the requested
|
||||
* parameters and returns a buffer_handle_t and the stride in pixels to
|
||||
* allow the implementation to satisfy hardware constraints on the width
|
||||
* of a pixmap (eg: it may have to be multiple of 8 pixels).
|
||||
* The CALLER TAKES OWNERSHIP of the buffer_handle_t.
|
||||
*
|
||||
* If format is HAL_PIXEL_FORMAT_YCbCr_420_888, the returned stride must be
|
||||
* 0, since the actual strides are available from the android_ycbcr
|
||||
* structure.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
|
||||
int (*alloc)(struct alloc_device_t* dev,
|
||||
int w, int h, int format, int usage,
|
||||
buffer_handle_t* handle, int* stride);
|
||||
|
||||
/*
|
||||
* (*free)() Frees a previously allocated buffer.
|
||||
* Behavior is undefined if the buffer is still mapped in any process,
|
||||
* but shall not result in termination of the program or security breaches
|
||||
* (allowing a process to get access to another process' buffers).
|
||||
* THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes
|
||||
* invalid after the call.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*free)(struct alloc_device_t* dev,
|
||||
buffer_handle_t handle);
|
||||
|
||||
/* This hook is OPTIONAL.
|
||||
*
|
||||
* If non NULL it will be caused by SurfaceFlinger on dumpsys
|
||||
*/
|
||||
void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len);
|
||||
|
||||
void* reserved_proc[7];
|
||||
} alloc_device_t;
|
||||
|
||||
|
||||
/** convenience API for opening and closing a supported device */
|
||||
|
||||
static inline int gralloc_open(const struct hw_module_t* module,
|
||||
struct alloc_device_t** device) {
|
||||
return module->methods->open(module,
|
||||
GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device);
|
||||
}
|
||||
|
||||
static inline int gralloc_close(struct alloc_device_t* device) {
|
||||
return device->common.close(&device->common);
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // ANDROID_GRALLOC_INTERFACE_H
|
238
include/android/hardware/libhardware/include/hardware/hardware.h
Normal file
238
include/android/hardware/libhardware/include/hardware/hardware.h
Normal file
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H
|
||||
#define ANDROID_INCLUDE_HARDWARE_HARDWARE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
#include <system/graphics.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Value for the hw_module_t.tag field
|
||||
*/
|
||||
|
||||
#define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
|
||||
|
||||
#define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T')
|
||||
#define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T')
|
||||
|
||||
#define HARDWARE_MAKE_API_VERSION(maj,min) \
|
||||
((((maj) & 0xff) << 8) | ((min) & 0xff))
|
||||
|
||||
#define HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) \
|
||||
((((maj) & 0xff) << 24) | (((min) & 0xff) << 16) | ((hdr) & 0xffff))
|
||||
#define HARDWARE_API_VERSION_2_MAJ_MIN_MASK 0xffff0000
|
||||
#define HARDWARE_API_VERSION_2_HEADER_MASK 0x0000ffff
|
||||
|
||||
|
||||
/*
|
||||
* The current HAL API version.
|
||||
*
|
||||
* All module implementations must set the hw_module_t.hal_api_version field
|
||||
* to this value when declaring the module with HAL_MODULE_INFO_SYM.
|
||||
*
|
||||
* Note that previous implementations have always set this field to 0.
|
||||
* Therefore, libhardware HAL API will always consider versions 0.0 and 1.0
|
||||
* to be 100% binary compatible.
|
||||
*
|
||||
*/
|
||||
#define HARDWARE_HAL_API_VERSION HARDWARE_MAKE_API_VERSION(1, 0)
|
||||
|
||||
/*
|
||||
* Helper macros for module implementors.
|
||||
*
|
||||
* The derived modules should provide convenience macros for supported
|
||||
* versions so that implementations can explicitly specify module/device
|
||||
* versions at definition time.
|
||||
*
|
||||
* Use this macro to set the hw_module_t.module_api_version field.
|
||||
*/
|
||||
#define HARDWARE_MODULE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min)
|
||||
#define HARDWARE_MODULE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr)
|
||||
|
||||
/*
|
||||
* Use this macro to set the hw_device_t.version field
|
||||
*/
|
||||
#define HARDWARE_DEVICE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min)
|
||||
#define HARDWARE_DEVICE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr)
|
||||
|
||||
struct hw_module_t;
|
||||
struct hw_module_methods_t;
|
||||
struct hw_device_t;
|
||||
|
||||
/**
|
||||
* Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
|
||||
* and the fields of this data structure must begin with hw_module_t
|
||||
* followed by module specific information.
|
||||
*/
|
||||
typedef struct hw_module_t {
|
||||
/** tag must be initialized to HARDWARE_MODULE_TAG */
|
||||
uint32_t tag;
|
||||
|
||||
/**
|
||||
* The API version of the implemented module. The module owner is
|
||||
* responsible for updating the version when a module interface has
|
||||
* changed.
|
||||
*
|
||||
* The derived modules such as gralloc and audio own and manage this field.
|
||||
* The module user must interpret the version field to decide whether or
|
||||
* not to inter-operate with the supplied module implementation.
|
||||
* For example, SurfaceFlinger is responsible for making sure that
|
||||
* it knows how to manage different versions of the gralloc-module API,
|
||||
* and AudioFlinger must know how to do the same for audio-module API.
|
||||
*
|
||||
* The module API version should include a major and a minor component.
|
||||
* For example, version 1.0 could be represented as 0x0100. This format
|
||||
* implies that versions 0x0100-0x01ff are all API-compatible.
|
||||
*
|
||||
* In the future, libhardware will expose a hw_get_module_version()
|
||||
* (or equivalent) function that will take minimum/maximum supported
|
||||
* versions as arguments and would be able to reject modules with
|
||||
* versions outside of the supplied range.
|
||||
*/
|
||||
uint16_t module_api_version;
|
||||
#define version_major module_api_version
|
||||
/**
|
||||
* version_major/version_minor defines are supplied here for temporary
|
||||
* source code compatibility. They will be removed in the next version.
|
||||
* ALL clients must convert to the new version format.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The API version of the HAL module interface. This is meant to
|
||||
* version the hw_module_t, hw_module_methods_t, and hw_device_t
|
||||
* structures and definitions.
|
||||
*
|
||||
* The HAL interface owns this field. Module users/implementations
|
||||
* must NOT rely on this value for version information.
|
||||
*
|
||||
* Presently, 0 is the only valid value.
|
||||
*/
|
||||
uint16_t hal_api_version;
|
||||
#define version_minor hal_api_version
|
||||
|
||||
/** Identifier of module */
|
||||
const char *id;
|
||||
|
||||
/** Name of this module */
|
||||
const char *name;
|
||||
|
||||
/** Author/owner/implementor of the module */
|
||||
const char *author;
|
||||
|
||||
/** Modules methods */
|
||||
struct hw_module_methods_t* methods;
|
||||
|
||||
/** module's dso */
|
||||
void* dso;
|
||||
|
||||
#ifdef __LP64__
|
||||
uint64_t reserved[32-7];
|
||||
#else
|
||||
/** padding to 128 bytes, reserved for future use */
|
||||
uint32_t reserved[32-7];
|
||||
#endif
|
||||
|
||||
} hw_module_t;
|
||||
|
||||
typedef struct hw_module_methods_t {
|
||||
/** Open a specific device */
|
||||
int (*open)(const struct hw_module_t* module, const char* id,
|
||||
struct hw_device_t** device);
|
||||
|
||||
} hw_module_methods_t;
|
||||
|
||||
/**
|
||||
* Every device data structure must begin with hw_device_t
|
||||
* followed by module specific public methods and attributes.
|
||||
*/
|
||||
typedef struct hw_device_t {
|
||||
/** tag must be initialized to HARDWARE_DEVICE_TAG */
|
||||
uint32_t tag;
|
||||
|
||||
/**
|
||||
* Version of the module-specific device API. This value is used by
|
||||
* the derived-module user to manage different device implementations.
|
||||
*
|
||||
* The module user is responsible for checking the module_api_version
|
||||
* and device version fields to ensure that the user is capable of
|
||||
* communicating with the specific module implementation.
|
||||
*
|
||||
* One module can support multiple devices with different versions. This
|
||||
* can be useful when a device interface changes in an incompatible way
|
||||
* but it is still necessary to support older implementations at the same
|
||||
* time. One such example is the Camera 2.0 API.
|
||||
*
|
||||
* This field is interpreted by the module user and is ignored by the
|
||||
* HAL interface itself.
|
||||
*/
|
||||
uint32_t version;
|
||||
|
||||
/** reference to the module this device belongs to */
|
||||
struct hw_module_t* module;
|
||||
|
||||
/** padding reserved for future use */
|
||||
#ifdef __LP64__
|
||||
uint64_t reserved[12];
|
||||
#else
|
||||
uint32_t reserved[12];
|
||||
#endif
|
||||
|
||||
/** Close this device */
|
||||
int (*close)(struct hw_device_t* device);
|
||||
|
||||
} hw_device_t;
|
||||
|
||||
/**
|
||||
* Name of the hal_module_info
|
||||
*/
|
||||
#define HAL_MODULE_INFO_SYM HMI
|
||||
|
||||
/**
|
||||
* Name of the hal_module_info as a string
|
||||
*/
|
||||
#define HAL_MODULE_INFO_SYM_AS_STR "HMI"
|
||||
|
||||
/**
|
||||
* Get the module info associated with a module by id.
|
||||
*
|
||||
* @return: 0 == success, <0 == error and *module == NULL
|
||||
*/
|
||||
int hw_get_module(const char *id, const struct hw_module_t **module);
|
||||
|
||||
/**
|
||||
* Get the module info associated with a module instance by class 'class_id'
|
||||
* and instance 'inst'.
|
||||
*
|
||||
* Some modules types necessitate multiple instances. For example audio supports
|
||||
* multiple concurrent interfaces and thus 'audio' is the module class
|
||||
* and 'primary' or 'a2dp' are module interfaces. This implies that the files
|
||||
* providing these modules would be named audio.primary.<variant>.so and
|
||||
* audio.a2dp.<variant>.so
|
||||
*
|
||||
* @return: 0 == success, <0 == error and *module == NULL
|
||||
*/
|
||||
int hw_get_module_by_class(const char *class_id, const char *inst,
|
||||
const struct hw_module_t **module);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */
|
5
include/android/meson.build
Normal file
5
include/android/meson.build
Normal file
|
@ -0,0 +1,5 @@
|
|||
android_includes = ([
|
||||
include_directories('hardware/libhardware/include/'),
|
||||
include_directories('metadata/'),
|
||||
include_directories('system/core/include'),
|
||||
])
|
100
include/android/metadata/camera_metadata_hidden.h
Normal file
100
include/android/metadata/camera_metadata_hidden.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SYSTEM_MEDIA_PRIVATE_INCLUDE_CAMERA_METADATA_HIDDEN_H
|
||||
#define SYSTEM_MEDIA_PRIVATE_INCLUDE_CAMERA_METADATA_HIDDEN_H
|
||||
|
||||
#include <system/camera_vendor_tags.h>
|
||||
|
||||
/**
|
||||
* Error codes returned by vendor tags ops operations. These are intended
|
||||
* to be used by all framework code that uses the return values from the
|
||||
* vendor operations object.
|
||||
*/
|
||||
#define VENDOR_SECTION_NAME_ERR NULL
|
||||
#define VENDOR_TAG_NAME_ERR NULL
|
||||
#define VENDOR_TAG_COUNT_ERR (-1)
|
||||
#define VENDOR_TAG_TYPE_ERR (-1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/** **These are private functions for use only by the camera framework.** **/
|
||||
|
||||
/**
|
||||
* Set the global vendor tag operations object used to define vendor tag
|
||||
* structure when parsing camera metadata with functions defined in
|
||||
* system/media/camera/include/camera_metadata.h.
|
||||
*/
|
||||
ANDROID_API
|
||||
int set_camera_metadata_vendor_ops(const vendor_tag_ops_t *query_ops);
|
||||
|
||||
/**
|
||||
* Set the global vendor tag cache operations object used to define vendor tag
|
||||
* structure when parsing camera metadata with functions defined in
|
||||
* system/media/camera/include/camera_metadata.h.
|
||||
*/
|
||||
ANDROID_API
|
||||
int set_camera_metadata_vendor_cache_ops(
|
||||
const struct vendor_tag_cache_ops *query_cache_ops);
|
||||
|
||||
/**
|
||||
* Set the vendor id for a particular metadata buffer.
|
||||
*/
|
||||
ANDROID_API
|
||||
void set_camera_metadata_vendor_id(camera_metadata_t *meta,
|
||||
metadata_vendor_id_t id);
|
||||
|
||||
/**
|
||||
* Retrieve the vendor id for a particular metadata buffer.
|
||||
*/
|
||||
ANDROID_API
|
||||
metadata_vendor_id_t get_camera_metadata_vendor_id(
|
||||
const camera_metadata_t *meta);
|
||||
|
||||
/**
|
||||
* Retrieve the type of a tag. Returns -1 if no such tag is defined.
|
||||
*/
|
||||
ANDROID_API
|
||||
int get_local_camera_metadata_tag_type_vendor_id(uint32_t tag,
|
||||
metadata_vendor_id_t id);
|
||||
|
||||
/**
|
||||
* Retrieve the name of a tag. Returns NULL if no such tag is defined.
|
||||
*/
|
||||
ANDROID_API
|
||||
const char *get_local_camera_metadata_tag_name_vendor_id(uint32_t tag,
|
||||
metadata_vendor_id_t id);
|
||||
|
||||
/**
|
||||
* Retrieve the name of a tag section. Returns NULL if no such tag is defined.
|
||||
*/
|
||||
ANDROID_API
|
||||
const char *get_local_camera_metadata_section_name_vendor_id(uint32_t tag,
|
||||
metadata_vendor_id_t id);
|
||||
|
||||
/**
|
||||
* Retrieve the type of a tag. Returns -1 if no such tag is defined.
|
||||
*/
|
||||
ANDROID_API
|
||||
int get_local_camera_metadata_tag_type_vendor_id(uint32_t tag,
|
||||
metadata_vendor_id_t id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM_MEDIA_PRIVATE_INCLUDE_CAMERA_METADATA_HIDDEN_H */
|
580
include/android/metadata/system/camera_metadata.h
Normal file
580
include/android/metadata/system/camera_metadata.h
Normal file
|
@ -0,0 +1,580 @@
|
|||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_METADATA_H
|
||||
#define SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_METADATA_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <cutils/compiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Tag hierarchy and enum definitions for camera_metadata_entry
|
||||
* =============================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Main enum definitions are in a separate file to make it easy to
|
||||
* maintain
|
||||
*/
|
||||
#include "camera_metadata_tags.h"
|
||||
|
||||
/**
|
||||
* Enum range for each top-level category
|
||||
*/
|
||||
ANDROID_API
|
||||
extern unsigned int camera_metadata_section_bounds[ANDROID_SECTION_COUNT][2];
|
||||
ANDROID_API
|
||||
extern const char *camera_metadata_section_names[ANDROID_SECTION_COUNT];
|
||||
|
||||
/**
|
||||
* Type definitions for camera_metadata_entry
|
||||
* =============================================================================
|
||||
*/
|
||||
enum {
|
||||
// Unsigned 8-bit integer (uint8_t)
|
||||
TYPE_BYTE = 0,
|
||||
// Signed 32-bit integer (int32_t)
|
||||
TYPE_INT32 = 1,
|
||||
// 32-bit float (float)
|
||||
TYPE_FLOAT = 2,
|
||||
// Signed 64-bit integer (int64_t)
|
||||
TYPE_INT64 = 3,
|
||||
// 64-bit float (double)
|
||||
TYPE_DOUBLE = 4,
|
||||
// A 64-bit fraction (camera_metadata_rational_t)
|
||||
TYPE_RATIONAL = 5,
|
||||
// Number of type fields
|
||||
NUM_TYPES
|
||||
};
|
||||
|
||||
typedef struct camera_metadata_rational {
|
||||
int32_t numerator;
|
||||
int32_t denominator;
|
||||
} camera_metadata_rational_t;
|
||||
|
||||
/**
|
||||
* A reference to a metadata entry in a buffer.
|
||||
*
|
||||
* The data union pointers point to the real data in the buffer, and can be
|
||||
* modified in-place if the count does not need to change. The count is the
|
||||
* number of entries in data of the entry's type, not a count of bytes.
|
||||
*/
|
||||
typedef struct camera_metadata_entry {
|
||||
size_t index;
|
||||
uint32_t tag;
|
||||
uint8_t type;
|
||||
size_t count;
|
||||
union {
|
||||
uint8_t *u8;
|
||||
int32_t *i32;
|
||||
float *f;
|
||||
int64_t *i64;
|
||||
double *d;
|
||||
camera_metadata_rational_t *r;
|
||||
} data;
|
||||
} camera_metadata_entry_t;
|
||||
|
||||
/**
|
||||
* A read-only reference to a metadata entry in a buffer. Identical to
|
||||
* camera_metadata_entry in layout
|
||||
*/
|
||||
typedef struct camera_metadata_ro_entry {
|
||||
size_t index;
|
||||
uint32_t tag;
|
||||
uint8_t type;
|
||||
size_t count;
|
||||
union {
|
||||
const uint8_t *u8;
|
||||
const int32_t *i32;
|
||||
const float *f;
|
||||
const int64_t *i64;
|
||||
const double *d;
|
||||
const camera_metadata_rational_t *r;
|
||||
} data;
|
||||
} camera_metadata_ro_entry_t;
|
||||
|
||||
/**
|
||||
* Size in bytes of each entry type
|
||||
*/
|
||||
ANDROID_API
|
||||
extern const size_t camera_metadata_type_size[NUM_TYPES];
|
||||
|
||||
/**
|
||||
* Human-readable name of each entry type
|
||||
*/
|
||||
ANDROID_API
|
||||
extern const char* camera_metadata_type_names[NUM_TYPES];
|
||||
|
||||
/**
|
||||
* Main definitions for the metadata entry and array structures
|
||||
* =============================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* A packet of metadata. This is a list of metadata entries, each of which has
|
||||
* an integer tag to identify its meaning, 'type' and 'count' field, and the
|
||||
* data, which contains a 'count' number of entries of type 'type'. The packet
|
||||
* has a fixed capacity for entries and for extra data. A new entry uses up one
|
||||
* entry slot, and possibly some amount of data capacity; the function
|
||||
* calculate_camera_metadata_entry_data_size() provides the amount of data
|
||||
* capacity that would be used up by an entry.
|
||||
*
|
||||
* Entries are not sorted by default, and are not forced to be unique - multiple
|
||||
* entries with the same tag are allowed. The packet will not dynamically resize
|
||||
* when full.
|
||||
*
|
||||
* The packet is contiguous in memory, with size in bytes given by
|
||||
* get_camera_metadata_size(). Therefore, it can be copied safely with memcpy()
|
||||
* to a buffer of sufficient size. The copy_camera_metadata() function is
|
||||
* intended for eliminating unused capacity in the destination packet.
|
||||
*/
|
||||
struct camera_metadata;
|
||||
typedef struct camera_metadata camera_metadata_t;
|
||||
|
||||
/**
|
||||
* Functions for manipulating camera metadata
|
||||
* =============================================================================
|
||||
*
|
||||
* NOTE: Unless otherwise specified, functions that return type "int"
|
||||
* return 0 on success, and non-0 value on error.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allocate a new camera_metadata structure, with some initial space for entries
|
||||
* and extra data. The entry_capacity is measured in entry counts, and
|
||||
* data_capacity in bytes. The resulting structure is all contiguous in memory,
|
||||
* and can be freed with free_camera_metadata().
|
||||
*/
|
||||
ANDROID_API
|
||||
camera_metadata_t *allocate_camera_metadata(size_t entry_capacity,
|
||||
size_t data_capacity);
|
||||
|
||||
/**
|
||||
* Get the required alignment of a packet of camera metadata, which is the
|
||||
* maximal alignment of the embedded camera_metadata, camera_metadata_buffer_entry,
|
||||
* and camera_metadata_data.
|
||||
*/
|
||||
ANDROID_API
|
||||
size_t get_camera_metadata_alignment();
|
||||
|
||||
/**
|
||||
* Allocate a new camera_metadata structure of size src_size. Copy the data,
|
||||
* ignoring alignment, and then attempt validation. If validation
|
||||
* fails, free the memory and return NULL. Otherwise return the pointer.
|
||||
*
|
||||
* The resulting pointer can be freed with free_camera_metadata().
|
||||
*/
|
||||
ANDROID_API
|
||||
camera_metadata_t *allocate_copy_camera_metadata_checked(
|
||||
const camera_metadata_t *src,
|
||||
size_t src_size);
|
||||
|
||||
/**
|
||||
* Place a camera metadata structure into an existing buffer. Returns NULL if
|
||||
* the buffer is too small for the requested number of reserved entries and
|
||||
* bytes of data. The entry_capacity is measured in entry counts, and
|
||||
* data_capacity in bytes. If the buffer is larger than the required space,
|
||||
* unused space will be left at the end. If successful, returns a pointer to the
|
||||
* metadata header placed at the start of the buffer. It is the caller's
|
||||
* responsibility to free the original buffer; do not call
|
||||
* free_camera_metadata() with the returned pointer.
|
||||
*/
|
||||
ANDROID_API
|
||||
camera_metadata_t *place_camera_metadata(void *dst, size_t dst_size,
|
||||
size_t entry_capacity,
|
||||
size_t data_capacity);
|
||||
|
||||
/**
|
||||
* Free a camera_metadata structure. Should only be used with structures
|
||||
* allocated with allocate_camera_metadata().
|
||||
*/
|
||||
ANDROID_API
|
||||
void free_camera_metadata(camera_metadata_t *metadata);
|
||||
|
||||
/**
|
||||
* Calculate the buffer size needed for a metadata structure of entry_count
|
||||
* metadata entries, needing a total of data_count bytes of extra data storage.
|
||||
*/
|
||||
ANDROID_API
|
||||
size_t calculate_camera_metadata_size(size_t entry_count,
|
||||
size_t data_count);
|
||||
|
||||
/**
|
||||
* Get current size of entire metadata structure in bytes, including reserved
|
||||
* but unused space.
|
||||
*/
|
||||
ANDROID_API
|
||||
size_t get_camera_metadata_size(const camera_metadata_t *metadata);
|
||||
|
||||
/**
|
||||
* Get size of entire metadata buffer in bytes, not including reserved but
|
||||
* unused space. This is the amount of space needed by copy_camera_metadata for
|
||||
* its dst buffer.
|
||||
*/
|
||||
ANDROID_API
|
||||
size_t get_camera_metadata_compact_size(const camera_metadata_t *metadata);
|
||||
|
||||
/**
|
||||
* Get the current number of entries in the metadata packet.
|
||||
*
|
||||
* metadata packet must be valid, which can be checked before the call with
|
||||
* validate_camera_metadata_structure().
|
||||
*/
|
||||
ANDROID_API
|
||||
size_t get_camera_metadata_entry_count(const camera_metadata_t *metadata);
|
||||
|
||||
/**
|
||||
* Get the maximum number of entries that could fit in the metadata packet.
|
||||
*/
|
||||
ANDROID_API
|
||||
size_t get_camera_metadata_entry_capacity(const camera_metadata_t *metadata);
|
||||
|
||||
/**
|
||||
* Get the current count of bytes used for value storage in the metadata packet.
|
||||
*/
|
||||
ANDROID_API
|
||||
size_t get_camera_metadata_data_count(const camera_metadata_t *metadata);
|
||||
|
||||
/**
|
||||
* Get the maximum count of bytes that could be used for value storage in the
|
||||
* metadata packet.
|
||||
*/
|
||||
ANDROID_API
|
||||
size_t get_camera_metadata_data_capacity(const camera_metadata_t *metadata);
|
||||
|
||||
/**
|
||||
* Copy a metadata structure to a memory buffer, compacting it along the
|
||||
* way. That is, in the copied structure, entry_count == entry_capacity, and
|
||||
* data_count == data_capacity.
|
||||
*
|
||||
* If dst_size > get_camera_metadata_compact_size(), the unused bytes are at the
|
||||
* end of the buffer. If dst_size < get_camera_metadata_compact_size(), returns
|
||||
* NULL. Otherwise returns a pointer to the metadata structure header placed at
|
||||
* the start of dst.
|
||||
*
|
||||
* Since the buffer was not allocated by allocate_camera_metadata, the caller is
|
||||
* responsible for freeing the underlying buffer when needed; do not call
|
||||
* free_camera_metadata.
|
||||
*/
|
||||
ANDROID_API
|
||||
camera_metadata_t *copy_camera_metadata(void *dst, size_t dst_size,
|
||||
const camera_metadata_t *src);
|
||||
|
||||
|
||||
// Non-zero return values for validate_camera_metadata_structure
|
||||
enum {
|
||||
CAMERA_METADATA_VALIDATION_ERROR = 1,
|
||||
CAMERA_METADATA_VALIDATION_SHIFTED = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Validate that a metadata is structurally sane. That is, its internal
|
||||
* state is such that we won't get buffer overflows or run into other
|
||||
* 'impossible' issues when calling the other API functions.
|
||||
*
|
||||
* This is useful in particular after copying the binary metadata blob
|
||||
* from an untrusted source, since passing this check means the data is at least
|
||||
* consistent.
|
||||
*
|
||||
* The expected_size argument is optional.
|
||||
*
|
||||
* Returns 0: on success
|
||||
* CAMERA_METADATA_VALIDATION_ERROR: on error
|
||||
* CAMERA_METADATA_VALIDATION_SHIFTED: when the data is not properly aligned, but can be
|
||||
* used as input of clone_camera_metadata and the returned metadata will be valid.
|
||||
*
|
||||
*/
|
||||
ANDROID_API
|
||||
int validate_camera_metadata_structure(const camera_metadata_t *metadata,
|
||||
const size_t *expected_size);
|
||||
|
||||
/**
|
||||
* Append camera metadata in src to an existing metadata structure in dst. This
|
||||
* does not resize the destination structure, so if it is too small, a non-zero
|
||||
* value is returned. On success, 0 is returned. Appending onto a sorted
|
||||
* structure results in a non-sorted combined structure.
|
||||
*/
|
||||
ANDROID_API
|
||||
int append_camera_metadata(camera_metadata_t *dst, const camera_metadata_t *src);
|
||||
|
||||
/**
|
||||
* Clone an existing metadata buffer, compacting along the way. This is
|
||||
* equivalent to allocating a new buffer of the minimum needed size, then
|
||||
* appending the buffer to be cloned into the new buffer. The resulting buffer
|
||||
* can be freed with free_camera_metadata(). Returns NULL if cloning failed.
|
||||
*/
|
||||
ANDROID_API
|
||||
camera_metadata_t *clone_camera_metadata(const camera_metadata_t *src);
|
||||
|
||||
/**
|
||||
* Calculate the number of bytes of extra data a given metadata entry will take
|
||||
* up. That is, if entry of 'type' with a payload of 'data_count' values is
|
||||
* added, how much will the value returned by get_camera_metadata_data_count()
|
||||
* be increased? This value may be zero, if no extra data storage is needed.
|
||||
*/
|
||||
ANDROID_API
|
||||
size_t calculate_camera_metadata_entry_data_size(uint8_t type,
|
||||
size_t data_count);
|
||||
|
||||
/**
|
||||
* Add a metadata entry to a metadata structure. Returns 0 if the addition
|
||||
* succeeded. Returns a non-zero value if there is insufficient reserved space
|
||||
* left to add the entry, or if the tag is unknown. data_count is the number of
|
||||
* entries in the data array of the tag's type, not a count of
|
||||
* bytes. Vendor-defined tags can not be added using this method, unless
|
||||
* set_vendor_tag_query_ops() has been called first. Entries are always added to
|
||||
* the end of the structure (highest index), so after addition, a
|
||||
* previously-sorted array will be marked as unsorted.
|
||||
*
|
||||
* Returns 0 on success. A non-0 value is returned on error.
|
||||
*/
|
||||
ANDROID_API
|
||||
int add_camera_metadata_entry(camera_metadata_t *dst,
|
||||
uint32_t tag,
|
||||
const void *data,
|
||||
size_t data_count);
|
||||
|
||||
/**
|
||||
* Sort the metadata buffer for fast searching. If already marked as sorted,
|
||||
* does nothing. Adding or appending entries to the buffer will place the buffer
|
||||
* back into an unsorted state.
|
||||
*
|
||||
* Returns 0 on success. A non-0 value is returned on error.
|
||||
*/
|
||||
ANDROID_API
|
||||
int sort_camera_metadata(camera_metadata_t *dst);
|
||||
|
||||
/**
|
||||
* Get metadata entry at position index in the metadata buffer.
|
||||
* Index must be less than entry count, which is returned by
|
||||
* get_camera_metadata_entry_count().
|
||||
*
|
||||
* src and index are inputs; the passed-in entry is updated with the details of
|
||||
* the entry. The data pointer points to the real data in the buffer, and can be
|
||||
* updated as long as the data count does not change.
|
||||
*
|
||||
* Returns 0 on success. A non-0 value is returned on error.
|
||||
*/
|
||||
ANDROID_API
|
||||
int get_camera_metadata_entry(camera_metadata_t *src,
|
||||
size_t index,
|
||||
camera_metadata_entry_t *entry);
|
||||
|
||||
/**
|
||||
* Get metadata entry at position index, but disallow editing the data.
|
||||
*/
|
||||
ANDROID_API
|
||||
int get_camera_metadata_ro_entry(const camera_metadata_t *src,
|
||||
size_t index,
|
||||
camera_metadata_ro_entry_t *entry);
|
||||
|
||||
/**
|
||||
* Find an entry with given tag value. If not found, returns -ENOENT. Otherwise,
|
||||
* returns entry contents like get_camera_metadata_entry.
|
||||
*
|
||||
* If multiple entries with the same tag exist, does not have any guarantees on
|
||||
* which is returned. To speed up searching for tags, sort the metadata
|
||||
* structure first by calling sort_camera_metadata().
|
||||
*/
|
||||
ANDROID_API
|
||||
int find_camera_metadata_entry(camera_metadata_t *src,
|
||||
uint32_t tag,
|
||||
camera_metadata_entry_t *entry);
|
||||
|
||||
/**
|
||||
* Find an entry with given tag value, but disallow editing the data
|
||||
*/
|
||||
ANDROID_API
|
||||
int find_camera_metadata_ro_entry(const camera_metadata_t *src,
|
||||
uint32_t tag,
|
||||
camera_metadata_ro_entry_t *entry);
|
||||
|
||||
/**
|
||||
* Delete an entry at given index. This is an expensive operation, since it
|
||||
* requires repacking entries and possibly entry data. This also invalidates any
|
||||
* existing camera_metadata_entry.data pointers to this buffer. Sorting is
|
||||
* maintained.
|
||||
*/
|
||||
ANDROID_API
|
||||
int delete_camera_metadata_entry(camera_metadata_t *dst,
|
||||
size_t index);
|
||||
|
||||
/**
|
||||
* Updates a metadata entry with new data. If the data size is changing, may
|
||||
* need to adjust the data array, making this an O(N) operation. If the data
|
||||
* size is the same or still fits in the entry space, this is O(1). Maintains
|
||||
* sorting, but invalidates camera_metadata_entry instances that point to the
|
||||
* updated entry. If a non-NULL value is passed in to entry, the entry structure
|
||||
* is updated to match the new buffer state. Returns a non-zero value if there
|
||||
* is no room for the new data in the buffer.
|
||||
*/
|
||||
ANDROID_API
|
||||
int update_camera_metadata_entry(camera_metadata_t *dst,
|
||||
size_t index,
|
||||
const void *data,
|
||||
size_t data_count,
|
||||
camera_metadata_entry_t *updated_entry);
|
||||
|
||||
/**
|
||||
* Retrieve human-readable name of section the tag is in. Returns NULL if
|
||||
* no such tag is defined. Returns NULL for tags in the vendor section, unless
|
||||
* set_vendor_tag_query_ops() has been used.
|
||||
*/
|
||||
ANDROID_API
|
||||
const char *get_camera_metadata_section_name(uint32_t tag);
|
||||
|
||||
/**
|
||||
* Retrieve human-readable name of tag (not including section). Returns NULL if
|
||||
* no such tag is defined. Returns NULL for tags in the vendor section, unless
|
||||
* set_vendor_tag_query_ops() has been used.
|
||||
*/
|
||||
ANDROID_API
|
||||
const char *get_camera_metadata_tag_name(uint32_t tag);
|
||||
|
||||
/**
|
||||
* Retrieve the type of a tag. Returns -1 if no such tag is defined. Returns -1
|
||||
* for tags in the vendor section, unless set_vendor_tag_query_ops() has been
|
||||
* used.
|
||||
*/
|
||||
ANDROID_API
|
||||
int get_camera_metadata_tag_type(uint32_t tag);
|
||||
|
||||
/**
|
||||
* Retrieve human-readable name of section the tag is in. Returns NULL if
|
||||
* no such tag is defined.
|
||||
*/
|
||||
ANDROID_API
|
||||
const char *get_local_camera_metadata_section_name(uint32_t tag,
|
||||
const camera_metadata_t *meta);
|
||||
|
||||
/**
|
||||
* Retrieve human-readable name of tag (not including section). Returns NULL if
|
||||
* no such tag is defined.
|
||||
*/
|
||||
ANDROID_API
|
||||
const char *get_local_camera_metadata_tag_name(uint32_t tag,
|
||||
const camera_metadata_t *meta);
|
||||
|
||||
/**
|
||||
* Retrieve the type of a tag. Returns -1 if no such tag is defined.
|
||||
*/
|
||||
ANDROID_API
|
||||
int get_local_camera_metadata_tag_type(uint32_t tag,
|
||||
const camera_metadata_t *meta);
|
||||
|
||||
/**
|
||||
* Set up vendor-specific tag query methods. These are needed to properly add
|
||||
* entries with vendor-specified tags and to use the
|
||||
* get_camera_metadata_section_name, _tag_name, and _tag_type methods with
|
||||
* vendor tags. Returns 0 on success.
|
||||
*
|
||||
* **DEPRECATED** - Please use vendor_tag_ops defined in camera_vendor_tags.h
|
||||
* instead.
|
||||
*/
|
||||
typedef struct vendor_tag_query_ops vendor_tag_query_ops_t;
|
||||
struct vendor_tag_query_ops {
|
||||
/**
|
||||
* Get vendor section name for a vendor-specified entry tag. Only called for
|
||||
* tags >= 0x80000000. The section name must start with the name of the
|
||||
* vendor in the Java package style. For example, CameraZoom inc must prefix
|
||||
* their sections with "com.camerazoom." Must return NULL if the tag is
|
||||
* outside the bounds of vendor-defined sections.
|
||||
*/
|
||||
const char *(*get_camera_vendor_section_name)(
|
||||
const vendor_tag_query_ops_t *v,
|
||||
uint32_t tag);
|
||||
/**
|
||||
* Get tag name for a vendor-specified entry tag. Only called for tags >=
|
||||
* 0x80000000. Must return NULL if the tag is outside the bounds of
|
||||
* vendor-defined sections.
|
||||
*/
|
||||
const char *(*get_camera_vendor_tag_name)(
|
||||
const vendor_tag_query_ops_t *v,
|
||||
uint32_t tag);
|
||||
/**
|
||||
* Get tag type for a vendor-specified entry tag. Only called for tags >=
|
||||
* 0x80000000. Must return -1 if the tag is outside the bounds of
|
||||
* vendor-defined sections.
|
||||
*/
|
||||
int (*get_camera_vendor_tag_type)(
|
||||
const vendor_tag_query_ops_t *v,
|
||||
uint32_t tag);
|
||||
/**
|
||||
* Get the number of vendor tags supported on this platform. Used to
|
||||
* calculate the size of buffer needed for holding the array of all tags
|
||||
* returned by get_camera_vendor_tags().
|
||||
*/
|
||||
int (*get_camera_vendor_tag_count)(
|
||||
const vendor_tag_query_ops_t *v);
|
||||
/**
|
||||
* Fill an array with all the supported vendor tags on this platform.
|
||||
* get_camera_vendor_tag_count() returns the number of tags supported, and
|
||||
* tag_array should be allocated with enough space to hold all of the tags.
|
||||
*/
|
||||
void (*get_camera_vendor_tags)(
|
||||
const vendor_tag_query_ops_t *v,
|
||||
uint32_t *tag_array);
|
||||
};
|
||||
|
||||
/**
|
||||
* **DEPRECATED** - This should only be used by the camera framework. Camera
|
||||
* metadata will transition to using vendor_tag_ops defined in
|
||||
* camera_vendor_tags.h instead.
|
||||
*/
|
||||
ANDROID_API
|
||||
int set_camera_metadata_vendor_tag_ops(const vendor_tag_query_ops_t *query_ops);
|
||||
|
||||
/**
|
||||
* Print fields in the metadata to the log.
|
||||
* verbosity = 0: Only tag entry information
|
||||
* verbosity = 1: Tag entry information plus at most 16 data values
|
||||
* verbosity = 2: All information
|
||||
*/
|
||||
ANDROID_API
|
||||
void dump_camera_metadata(const camera_metadata_t *metadata,
|
||||
int fd,
|
||||
int verbosity);
|
||||
|
||||
/**
|
||||
* Print fields in the metadata to the log; adds indentation parameter, which
|
||||
* specifies the number of spaces to insert before each line of the dump
|
||||
*/
|
||||
ANDROID_API
|
||||
void dump_indented_camera_metadata(const camera_metadata_t *metadata,
|
||||
int fd,
|
||||
int verbosity,
|
||||
int indentation);
|
||||
|
||||
/**
|
||||
* Prints the specified tag value as a string. Only works for enum tags.
|
||||
* Returns 0 on success, -1 on failure.
|
||||
*/
|
||||
ANDROID_API
|
||||
int camera_metadata_enum_snprint(uint32_t tag,
|
||||
uint32_t value,
|
||||
char *dst,
|
||||
size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
1005
include/android/metadata/system/camera_metadata_tags.h
Normal file
1005
include/android/metadata/system/camera_metadata_tags.h
Normal file
File diff suppressed because it is too large
Load diff
158
include/android/metadata/system/camera_vendor_tags.h
Normal file
158
include/android/metadata/system/camera_vendor_tags.h
Normal file
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* Copyright 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_VENDOR_TAGS_H
|
||||
#define SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_VENDOR_TAGS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CAMERA_METADATA_VENDOR_TAG_BOUNDARY 0x80000000u
|
||||
#define CAMERA_METADATA_INVALID_VENDOR_ID UINT64_MAX
|
||||
|
||||
typedef uint64_t metadata_vendor_id_t;
|
||||
|
||||
/**
|
||||
* Vendor tags:
|
||||
*
|
||||
* This structure contains basic functions for enumerating an immutable set of
|
||||
* vendor-defined camera metadata tags, and querying static information about
|
||||
* their structure/type. The intended use of this information is to validate
|
||||
* the structure of metadata returned by the camera HAL, and to allow vendor-
|
||||
* defined metadata tags to be visible in application facing camera API.
|
||||
*/
|
||||
typedef struct vendor_tag_ops vendor_tag_ops_t;
|
||||
struct vendor_tag_ops {
|
||||
/**
|
||||
* Get the number of vendor tags supported on this platform. Used to
|
||||
* calculate the size of buffer needed for holding the array of all tags
|
||||
* returned by get_all_tags(). This must return -1 on error.
|
||||
*/
|
||||
int (*get_tag_count)(const vendor_tag_ops_t *v);
|
||||
|
||||
/**
|
||||
* Fill an array with all of the supported vendor tags on this platform.
|
||||
* get_tag_count() must return the number of tags supported, and
|
||||
* tag_array will be allocated with enough space to hold the number of tags
|
||||
* returned by get_tag_count().
|
||||
*/
|
||||
void (*get_all_tags)(const vendor_tag_ops_t *v, uint32_t *tag_array);
|
||||
|
||||
/**
|
||||
* Get the vendor section name for a vendor-specified entry tag. This will
|
||||
* only be called for vendor-defined tags.
|
||||
*
|
||||
* The naming convention for the vendor-specific section names should
|
||||
* follow a style similar to the Java package style. For example,
|
||||
* CameraZoom Inc. must prefix their sections with "com.camerazoom."
|
||||
* This must return NULL if the tag is outside the bounds of
|
||||
* vendor-defined sections.
|
||||
*
|
||||
* There may be different vendor-defined tag sections, for example the
|
||||
* phone maker, the chipset maker, and the camera module maker may each
|
||||
* have their own "com.vendor."-prefixed section.
|
||||
*
|
||||
* The memory pointed to by the return value must remain valid for the
|
||||
* lifetime of the module, and is owned by the module.
|
||||
*/
|
||||
const char *(*get_section_name)(const vendor_tag_ops_t *v, uint32_t tag);
|
||||
|
||||
/**
|
||||
* Get the tag name for a vendor-specified entry tag. This is only called
|
||||
* for vendor-defined tags, and must return NULL if it is not a
|
||||
* vendor-defined tag.
|
||||
*
|
||||
* The memory pointed to by the return value must remain valid for the
|
||||
* lifetime of the module, and is owned by the module.
|
||||
*/
|
||||
const char *(*get_tag_name)(const vendor_tag_ops_t *v, uint32_t tag);
|
||||
|
||||
/**
|
||||
* Get tag type for a vendor-specified entry tag. The type returned must be
|
||||
* a valid type defined in camera_metadata.h. This method is only called
|
||||
* for tags >= CAMERA_METADATA_VENDOR_TAG_BOUNDARY, and must return
|
||||
* -1 if the tag is outside the bounds of the vendor-defined sections.
|
||||
*/
|
||||
int (*get_tag_type)(const vendor_tag_ops_t *v, uint32_t tag);
|
||||
|
||||
/* Reserved for future use. These must be initialized to NULL. */
|
||||
void* reserved[8];
|
||||
};
|
||||
|
||||
struct vendor_tag_cache_ops {
|
||||
/**
|
||||
* Get the number of vendor tags supported on this platform. Used to
|
||||
* calculate the size of buffer needed for holding the array of all tags
|
||||
* returned by get_all_tags(). This must return -1 on error.
|
||||
*/
|
||||
int (*get_tag_count)(metadata_vendor_id_t id);
|
||||
|
||||
/**
|
||||
* Fill an array with all of the supported vendor tags on this platform.
|
||||
* get_tag_count() must return the number of tags supported, and
|
||||
* tag_array will be allocated with enough space to hold the number of tags
|
||||
* returned by get_tag_count().
|
||||
*/
|
||||
void (*get_all_tags)(uint32_t *tag_array, metadata_vendor_id_t id);
|
||||
|
||||
/**
|
||||
* Get the vendor section name for a vendor-specified entry tag. This will
|
||||
* only be called for vendor-defined tags.
|
||||
*
|
||||
* The naming convention for the vendor-specific section names should
|
||||
* follow a style similar to the Java package style. For example,
|
||||
* CameraZoom Inc. must prefix their sections with "com.camerazoom."
|
||||
* This must return NULL if the tag is outside the bounds of
|
||||
* vendor-defined sections.
|
||||
*
|
||||
* There may be different vendor-defined tag sections, for example the
|
||||
* phone maker, the chipset maker, and the camera module maker may each
|
||||
* have their own "com.vendor."-prefixed section.
|
||||
*
|
||||
* The memory pointed to by the return value must remain valid for the
|
||||
* lifetime of the module, and is owned by the module.
|
||||
*/
|
||||
const char *(*get_section_name)(uint32_t tag, metadata_vendor_id_t id);
|
||||
|
||||
/**
|
||||
* Get the tag name for a vendor-specified entry tag. This is only called
|
||||
* for vendor-defined tags, and must return NULL if it is not a
|
||||
* vendor-defined tag.
|
||||
*
|
||||
* The memory pointed to by the return value must remain valid for the
|
||||
* lifetime of the module, and is owned by the module.
|
||||
*/
|
||||
const char *(*get_tag_name)(uint32_t tag, metadata_vendor_id_t id);
|
||||
|
||||
/**
|
||||
* Get tag type for a vendor-specified entry tag. The type returned must be
|
||||
* a valid type defined in camera_metadata.h. This method is only called
|
||||
* for tags >= CAMERA_METADATA_VENDOR_TAG_BOUNDARY, and must return
|
||||
* -1 if the tag is outside the bounds of the vendor-defined sections.
|
||||
*/
|
||||
int (*get_tag_type)(uint32_t tag, metadata_vendor_id_t id);
|
||||
|
||||
/* Reserved for future use. These must be initialized to NULL. */
|
||||
void* reserved[8];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_VENDOR_TAGS_H */
|
||||
|
144
include/android/system/core/include/android/log.h
Normal file
144
include/android/system/core/include/android/log.h
Normal file
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ANDROID_LOG_H
|
||||
#define _ANDROID_LOG_H
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
* IMPORTANT NOTICE:
|
||||
*
|
||||
* This file is part of Android's set of stable system headers
|
||||
* exposed by the Android NDK (Native Development Kit) since
|
||||
* platform release 1.5
|
||||
*
|
||||
* Third-party source AND binary code relies on the definitions
|
||||
* here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
|
||||
*
|
||||
* - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
|
||||
* - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
|
||||
* - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
|
||||
* - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
|
||||
*/
|
||||
|
||||
/*
|
||||
* Support routines to send messages to the Android in-kernel log buffer,
|
||||
* which can later be accessed through the 'logcat' utility.
|
||||
*
|
||||
* Each log message must have
|
||||
* - a priority
|
||||
* - a log tag
|
||||
* - some text
|
||||
*
|
||||
* The tag normally corresponds to the component that emits the log message,
|
||||
* and should be reasonably small.
|
||||
*
|
||||
* Log message text may be truncated to less than an implementation-specific
|
||||
* limit (e.g. 1023 characters max).
|
||||
*
|
||||
* Note that a newline character ("\n") will be appended automatically to your
|
||||
* log message, if not already there. It is not possible to send several messages
|
||||
* and have them appear on a single line in logcat.
|
||||
*
|
||||
* PLEASE USE LOGS WITH MODERATION:
|
||||
*
|
||||
* - Sending log messages eats CPU and slow down your application and the
|
||||
* system.
|
||||
*
|
||||
* - The circular log buffer is pretty small (<64KB), sending many messages
|
||||
* might push off other important log messages from the rest of the system.
|
||||
*
|
||||
* - In release builds, only send log messages to account for exceptional
|
||||
* conditions.
|
||||
*
|
||||
* NOTE: These functions MUST be implemented by /system/lib/liblog.so
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Android log priority values, in ascending priority order.
|
||||
*/
|
||||
typedef enum android_LogPriority {
|
||||
ANDROID_LOG_UNKNOWN = 0,
|
||||
ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
|
||||
ANDROID_LOG_VERBOSE,
|
||||
ANDROID_LOG_DEBUG,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_WARN,
|
||||
ANDROID_LOG_ERROR,
|
||||
ANDROID_LOG_FATAL,
|
||||
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
|
||||
} android_LogPriority;
|
||||
|
||||
/*
|
||||
* Send a simple string to the log.
|
||||
*/
|
||||
int __android_log_write(int prio, const char *tag, const char *text);
|
||||
|
||||
/*
|
||||
* Send a formatted string to the log, used like printf(fmt,...)
|
||||
*/
|
||||
int __android_log_print(int prio, const char *tag, const char *fmt, ...)
|
||||
#if defined(__GNUC__)
|
||||
#ifdef __USE_MINGW_ANSI_STDIO
|
||||
#if __USE_MINGW_ANSI_STDIO
|
||||
__attribute__ ((format(gnu_printf, 3, 4)))
|
||||
#else
|
||||
__attribute__ ((format(printf, 3, 4)))
|
||||
#endif
|
||||
#else
|
||||
__attribute__ ((format(printf, 3, 4)))
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
|
||||
/*
|
||||
* A variant of __android_log_print() that takes a va_list to list
|
||||
* additional parameters.
|
||||
*/
|
||||
int __android_log_vprint(int prio, const char *tag,
|
||||
const char *fmt, va_list ap);
|
||||
|
||||
/*
|
||||
* Log an assertion failure and abort the process to have a chance
|
||||
* to inspect it if a debugger is attached. This uses the FATAL priority.
|
||||
*/
|
||||
void __android_log_assert(const char *cond, const char *tag,
|
||||
const char *fmt, ...)
|
||||
#if defined(__GNUC__)
|
||||
__attribute__ ((noreturn))
|
||||
#ifdef __USE_MINGW_ANSI_STDIO
|
||||
#if __USE_MINGW_ANSI_STDIO
|
||||
__attribute__ ((format(gnu_printf, 3, 4)))
|
||||
#else
|
||||
__attribute__ ((format(printf, 3, 4)))
|
||||
#endif
|
||||
#else
|
||||
__attribute__ ((format(printf, 3, 4)))
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ANDROID_LOG_H */
|
44
include/android/system/core/include/cutils/compiler.h
Normal file
44
include/android/system/core/include/cutils/compiler.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_CUTILS_COMPILER_H
|
||||
#define ANDROID_CUTILS_COMPILER_H
|
||||
|
||||
/*
|
||||
* helps the compiler's optimizer predicting branches
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true ))
|
||||
# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false ))
|
||||
#else
|
||||
# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 ))
|
||||
# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 ))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* exports marked symbols
|
||||
*
|
||||
* if used on a C++ class declaration, this macro must be inserted
|
||||
* after the "class" keyword. For instance:
|
||||
*
|
||||
* template <typename TYPE>
|
||||
* class ANDROID_API Singleton { }
|
||||
*/
|
||||
|
||||
#define ANDROID_API __attribute__((visibility("default")))
|
||||
|
||||
#endif // ANDROID_CUTILS_COMPILER_H
|
69
include/android/system/core/include/cutils/native_handle.h
Normal file
69
include/android/system/core/include/cutils/native_handle.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef NATIVE_HANDLE_H_
|
||||
#define NATIVE_HANDLE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct native_handle
|
||||
{
|
||||
int version; /* sizeof(native_handle_t) */
|
||||
int numFds; /* number of file-descriptors at &data[0] */
|
||||
int numInts; /* number of ints at &data[numFds] */
|
||||
int data[0]; /* numFds + numInts ints */
|
||||
} native_handle_t;
|
||||
|
||||
/*
|
||||
* native_handle_close
|
||||
*
|
||||
* closes the file descriptors contained in this native_handle_t
|
||||
*
|
||||
* return 0 on success, or a negative error code on failure
|
||||
*
|
||||
*/
|
||||
int native_handle_close(const native_handle_t* h);
|
||||
|
||||
|
||||
/*
|
||||
* native_handle_create
|
||||
*
|
||||
* creates a native_handle_t and initializes it. must be destroyed with
|
||||
* native_handle_delete().
|
||||
*
|
||||
*/
|
||||
native_handle_t* native_handle_create(int numFds, int numInts);
|
||||
|
||||
/*
|
||||
* native_handle_delete
|
||||
*
|
||||
* frees a native_handle_t allocated with native_handle_create().
|
||||
* This ONLY frees the memory allocated for the native_handle_t, but doesn't
|
||||
* close the file descriptors; which can be achieved with native_handle_close().
|
||||
*
|
||||
* return 0 on success, or a negative error code on failure
|
||||
*
|
||||
*/
|
||||
int native_handle_delete(native_handle_t* h);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NATIVE_HANDLE_H_ */
|
298
include/android/system/core/include/system/camera.h
Normal file
298
include/android/system/core/include/system/camera.h
Normal file
|
@ -0,0 +1,298 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H
|
||||
#define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <cutils/native_handle.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/gralloc.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* A set of bit masks for specifying how the received preview frames are
|
||||
* handled before the previewCallback() call.
|
||||
*
|
||||
* The least significant 3 bits of an "int" value are used for this purpose:
|
||||
*
|
||||
* ..... 0 0 0
|
||||
* ^ ^ ^
|
||||
* | | |---------> determine whether the callback is enabled or not
|
||||
* | |-----------> determine whether the callback is one-shot or not
|
||||
* |-------------> determine whether the frame is copied out or not
|
||||
*
|
||||
* WARNING: When a frame is sent directly without copying, it is the frame
|
||||
* receiver's responsiblity to make sure that the frame data won't get
|
||||
* corrupted by subsequent preview frames filled by the camera. This flag is
|
||||
* recommended only when copying out data brings significant performance price
|
||||
* and the handling/processing of the received frame data is always faster than
|
||||
* the preview frame rate so that data corruption won't occur.
|
||||
*
|
||||
* For instance,
|
||||
* 1. 0x00 disables the callback. In this case, copy out and one shot bits
|
||||
* are ignored.
|
||||
* 2. 0x01 enables a callback without copying out the received frames. A
|
||||
* typical use case is the Camcorder application to avoid making costly
|
||||
* frame copies.
|
||||
* 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical
|
||||
* use case is the Camera application.
|
||||
* 4. 0x07 is enabling a callback with frame copied out only once. A typical
|
||||
* use case is the Barcode scanner application.
|
||||
*/
|
||||
|
||||
enum {
|
||||
CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01,
|
||||
CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02,
|
||||
CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04,
|
||||
/** Typical use cases */
|
||||
CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00,
|
||||
CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01,
|
||||
CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05,
|
||||
CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07
|
||||
};
|
||||
|
||||
/** msgType in notifyCallback and dataCallback functions */
|
||||
enum {
|
||||
CAMERA_MSG_ERROR = 0x0001, // notifyCallback
|
||||
CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback
|
||||
CAMERA_MSG_FOCUS = 0x0004, // notifyCallback
|
||||
CAMERA_MSG_ZOOM = 0x0008, // notifyCallback
|
||||
CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback
|
||||
CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback
|
||||
CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback
|
||||
CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback
|
||||
CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback
|
||||
CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback
|
||||
// Preview frame metadata. This can be combined with
|
||||
// CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can
|
||||
// request FRAME and METADATA. Or the apps can request only FRAME or only
|
||||
// METADATA.
|
||||
CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback
|
||||
// Notify on autofocus start and stop. This is useful in continuous
|
||||
// autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE.
|
||||
CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback
|
||||
CAMERA_MSG_ALL_MSGS = 0xFFFF
|
||||
};
|
||||
|
||||
/** cmdType in sendCommand functions */
|
||||
enum {
|
||||
CAMERA_CMD_START_SMOOTH_ZOOM = 1,
|
||||
CAMERA_CMD_STOP_SMOOTH_ZOOM = 2,
|
||||
|
||||
/**
|
||||
* Set the clockwise rotation of preview display (setPreviewDisplay) in
|
||||
* degrees. This affects the preview frames and the picture displayed after
|
||||
* snapshot. This method is useful for portrait mode applications. Note
|
||||
* that preview display of front-facing cameras is flipped horizontally
|
||||
* before the rotation, that is, the image is reflected along the central
|
||||
* vertical axis of the camera sensor. So the users can see themselves as
|
||||
* looking into a mirror.
|
||||
*
|
||||
* This does not affect the order of byte array of
|
||||
* CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME,
|
||||
* CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or
|
||||
* CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview
|
||||
* since API level 14.
|
||||
*/
|
||||
CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3,
|
||||
|
||||
/**
|
||||
* cmdType to disable/enable shutter sound. In sendCommand passing arg1 =
|
||||
* 0 will disable, while passing arg1 = 1 will enable the shutter sound.
|
||||
*/
|
||||
CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4,
|
||||
|
||||
/* cmdType to play recording sound */
|
||||
CAMERA_CMD_PLAY_RECORDING_SOUND = 5,
|
||||
|
||||
/**
|
||||
* Start the face detection. This should be called after preview is started.
|
||||
* The camera will notify the listener of CAMERA_MSG_FACE and the detected
|
||||
* faces in the preview frame. The detected faces may be the same as the
|
||||
* previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop
|
||||
* the face detection. This method is supported if CameraParameters
|
||||
* KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is
|
||||
* bigger than 0. Hardware and software face detection should not be running
|
||||
* at the same time. If the face detection has started, apps should not send
|
||||
* this again.
|
||||
*
|
||||
* In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE,
|
||||
* KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect.
|
||||
*
|
||||
* arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or
|
||||
* CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not
|
||||
* supported, the HAL must return BAD_VALUE.
|
||||
*/
|
||||
CAMERA_CMD_START_FACE_DETECTION = 6,
|
||||
|
||||
/**
|
||||
* Stop the face detection.
|
||||
*/
|
||||
CAMERA_CMD_STOP_FACE_DETECTION = 7,
|
||||
|
||||
/**
|
||||
* Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing
|
||||
* arg1 = 0 will disable, while passing arg1 = 1 will enable the callback.
|
||||
*/
|
||||
CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8,
|
||||
|
||||
/**
|
||||
* Ping camera service to see if camera hardware is released.
|
||||
*
|
||||
* When any camera method returns error, the client can use ping command
|
||||
* to see if the camera has been taken away by other clients. If the result
|
||||
* is NO_ERROR, it means the camera hardware is not released. If the result
|
||||
* is not NO_ERROR, the camera has been released and the existing client
|
||||
* can silently finish itself or show a dialog.
|
||||
*/
|
||||
CAMERA_CMD_PING = 9,
|
||||
|
||||
/**
|
||||
* Configure the number of video buffers used for recording. The intended
|
||||
* video buffer count for recording is passed as arg1, which must be
|
||||
* greater than 0. This command must be sent before recording is started.
|
||||
* This command returns INVALID_OPERATION error if it is sent after video
|
||||
* recording is started, or the command is not supported at all. This
|
||||
* command also returns a BAD_VALUE error if the intended video buffer
|
||||
* count is non-positive or too big to be realized.
|
||||
*/
|
||||
CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10,
|
||||
|
||||
/**
|
||||
* Configure an explicit format to use for video recording metadata mode.
|
||||
* This can be used to switch the format from the
|
||||
* default IMPLEMENTATION_DEFINED gralloc format to some other
|
||||
* device-supported format, and the default dataspace from the BT_709 color
|
||||
* space to some other device-supported dataspace. arg1 is the HAL pixel
|
||||
* format, and arg2 is the HAL dataSpace. This command returns
|
||||
* INVALID_OPERATION error if it is sent after video recording is started,
|
||||
* or the command is not supported at all.
|
||||
*
|
||||
* If the gralloc format is set to a format other than
|
||||
* IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags
|
||||
* of SW_READ_OFTEN.
|
||||
*/
|
||||
CAMERA_CMD_SET_VIDEO_FORMAT = 11
|
||||
};
|
||||
|
||||
/** camera fatal errors */
|
||||
enum {
|
||||
CAMERA_ERROR_UNKNOWN = 1,
|
||||
/**
|
||||
* Camera was released because another client has connected to the camera.
|
||||
* The original client should call Camera::disconnect immediately after
|
||||
* getting this notification. Otherwise, the camera will be released by
|
||||
* camera service in a short time. The client should not call any method
|
||||
* (except disconnect and sending CAMERA_CMD_PING) after getting this.
|
||||
*/
|
||||
CAMERA_ERROR_RELEASED = 2,
|
||||
CAMERA_ERROR_SERVER_DIED = 100
|
||||
};
|
||||
|
||||
enum {
|
||||
/** The facing of the camera is opposite to that of the screen. */
|
||||
CAMERA_FACING_BACK = 0,
|
||||
/** The facing of the camera is the same as that of the screen. */
|
||||
CAMERA_FACING_FRONT = 1,
|
||||
/**
|
||||
* The facing of the camera is not fixed relative to the screen.
|
||||
* The cameras with this facing are external cameras, e.g. USB cameras.
|
||||
*/
|
||||
CAMERA_FACING_EXTERNAL = 2
|
||||
};
|
||||
|
||||
enum {
|
||||
/** Hardware face detection. It does not use much CPU. */
|
||||
CAMERA_FACE_DETECTION_HW = 0,
|
||||
/**
|
||||
* Software face detection. It uses some CPU. Applications must use
|
||||
* Camera.setPreviewTexture for preview in this mode.
|
||||
*/
|
||||
CAMERA_FACE_DETECTION_SW = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* The information of a face from camera face detection.
|
||||
*/
|
||||
typedef struct camera_face {
|
||||
/**
|
||||
* Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents
|
||||
* the top-left of the camera field of view, and (1000, 1000) represents the
|
||||
* bottom-right of the field of view. The width and height cannot be 0 or
|
||||
* negative. This is supported by both hardware and software face detection.
|
||||
*
|
||||
* The direction is relative to the sensor orientation, that is, what the
|
||||
* sensor sees. The direction is not affected by the rotation or mirroring
|
||||
* of CAMERA_CMD_SET_DISPLAY_ORIENTATION.
|
||||
*/
|
||||
int32_t rect[4];
|
||||
|
||||
/**
|
||||
* The confidence level of the face. The range is 1 to 100. 100 is the
|
||||
* highest confidence. This is supported by both hardware and software
|
||||
* face detection.
|
||||
*/
|
||||
int32_t score;
|
||||
|
||||
/**
|
||||
* An unique id per face while the face is visible to the tracker. If
|
||||
* the face leaves the field-of-view and comes back, it will get a new
|
||||
* id. If the value is 0, id is not supported.
|
||||
*/
|
||||
int32_t id;
|
||||
|
||||
/**
|
||||
* The coordinates of the center of the left eye. The range is -1000 to
|
||||
* 1000. -2000, -2000 if this is not supported.
|
||||
*/
|
||||
int32_t left_eye[2];
|
||||
|
||||
/**
|
||||
* The coordinates of the center of the right eye. The range is -1000 to
|
||||
* 1000. -2000, -2000 if this is not supported.
|
||||
*/
|
||||
int32_t right_eye[2];
|
||||
|
||||
/**
|
||||
* The coordinates of the center of the mouth. The range is -1000 to 1000.
|
||||
* -2000, -2000 if this is not supported.
|
||||
*/
|
||||
int32_t mouth[2];
|
||||
|
||||
} camera_face_t;
|
||||
|
||||
/**
|
||||
* The metadata of the frame data.
|
||||
*/
|
||||
typedef struct camera_frame_metadata {
|
||||
/**
|
||||
* The number of detected faces in the frame.
|
||||
*/
|
||||
int32_t number_of_faces;
|
||||
|
||||
/**
|
||||
* An array of the detected faces. The length is number_of_faces.
|
||||
*/
|
||||
camera_face_t *faces;
|
||||
} camera_frame_metadata_t;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */
|
763
include/android/system/core/include/system/graphics.h
Normal file
763
include/android/system/core/include/system/graphics.h
Normal file
|
@ -0,0 +1,763 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
|
||||
#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the HAL needs to create service threads to handle graphics related
|
||||
* tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority
|
||||
* if they can block the main rendering thread in any way.
|
||||
*
|
||||
* the priority of the current thread can be set with:
|
||||
*
|
||||
* #include <sys/resource.h>
|
||||
* setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
|
||||
*
|
||||
*/
|
||||
|
||||
#define HAL_PRIORITY_URGENT_DISPLAY (-8)
|
||||
|
||||
/**
|
||||
* pixel format definitions
|
||||
*/
|
||||
|
||||
enum {
|
||||
/*
|
||||
* "linear" color pixel formats:
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace field describes the color
|
||||
* space of the buffer.
|
||||
*
|
||||
* The color space determines, for example, if the formats are linear or
|
||||
* gamma-corrected; or whether any special operations are performed when
|
||||
* reading or writing into a buffer in one of these formats.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_RGBA_8888 = 1,
|
||||
HAL_PIXEL_FORMAT_RGBX_8888 = 2,
|
||||
HAL_PIXEL_FORMAT_RGB_888 = 3,
|
||||
HAL_PIXEL_FORMAT_RGB_565 = 4,
|
||||
HAL_PIXEL_FORMAT_BGRA_8888 = 5,
|
||||
|
||||
/*
|
||||
* 0x100 - 0x1FF
|
||||
*
|
||||
* This range is reserved for pixel formats that are specific to the HAL
|
||||
* implementation. Implementations can use any value in this range to
|
||||
* communicate video pixel formats between their HAL modules. These formats
|
||||
* must not have an alpha channel. Additionally, an EGLimage created from a
|
||||
* gralloc buffer of one of these formats must be supported for use with the
|
||||
* GL_OES_EGL_image_external OpenGL ES extension.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Android YUV format:
|
||||
*
|
||||
* This format is exposed outside of the HAL to software decoders and
|
||||
* applications. EGLImageKHR must support it in conjunction with the
|
||||
* OES_EGL_image_external extension.
|
||||
*
|
||||
* YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed
|
||||
* by (W/2) x (H/2) Cr and Cb planes.
|
||||
*
|
||||
* This format assumes
|
||||
* - an even width
|
||||
* - an even height
|
||||
* - a horizontal stride multiple of 16 pixels
|
||||
* - a vertical stride equal to the height
|
||||
*
|
||||
* y_size = stride * height
|
||||
* c_stride = ALIGN(stride/2, 16)
|
||||
* c_size = c_stride * height/2
|
||||
* size = y_size + c_size * 2
|
||||
* cr_offset = y_size
|
||||
* cb_offset = y_size + c_size
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace field describes the color
|
||||
* space of the buffer.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar
|
||||
|
||||
|
||||
/*
|
||||
* Android Y8 format:
|
||||
*
|
||||
* This format is exposed outside of the HAL to the framework.
|
||||
* The expected gralloc usage flags are SW_* and HW_CAMERA_*,
|
||||
* and no other HW_ flags will be used.
|
||||
*
|
||||
* Y8 is a YUV planar format comprised of a WxH Y plane,
|
||||
* with each pixel being represented by 8 bits.
|
||||
*
|
||||
* It is equivalent to just the Y plane from YV12.
|
||||
*
|
||||
* This format assumes
|
||||
* - an even width
|
||||
* - an even height
|
||||
* - a horizontal stride multiple of 16 pixels
|
||||
* - a vertical stride equal to the height
|
||||
*
|
||||
* size = stride * height
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace field describes the color
|
||||
* space of the buffer.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_Y8 = 0x20203859,
|
||||
|
||||
/*
|
||||
* Android Y16 format:
|
||||
*
|
||||
* This format is exposed outside of the HAL to the framework.
|
||||
* The expected gralloc usage flags are SW_* and HW_CAMERA_*,
|
||||
* and no other HW_ flags will be used.
|
||||
*
|
||||
* Y16 is a YUV planar format comprised of a WxH Y plane,
|
||||
* with each pixel being represented by 16 bits.
|
||||
*
|
||||
* It is just like Y8, but has double the bits per pixel (little endian).
|
||||
*
|
||||
* This format assumes
|
||||
* - an even width
|
||||
* - an even height
|
||||
* - a horizontal stride multiple of 16 pixels
|
||||
* - a vertical stride equal to the height
|
||||
* - strides are specified in pixels, not in bytes
|
||||
*
|
||||
* size = stride * height * 2
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace field describes the color
|
||||
* space of the buffer, except that dataSpace field
|
||||
* HAL_DATASPACE_DEPTH indicates that this buffer contains a depth
|
||||
* image where each sample is a distance value measured by a depth camera,
|
||||
* plus an associated confidence value.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_Y16 = 0x20363159,
|
||||
|
||||
/*
|
||||
* Android RAW sensor format:
|
||||
*
|
||||
* This format is exposed outside of the camera HAL to applications.
|
||||
*
|
||||
* RAW16 is a single-channel, 16-bit, little endian format, typically
|
||||
* representing raw Bayer-pattern images from an image sensor, with minimal
|
||||
* processing.
|
||||
*
|
||||
* The exact pixel layout of the data in the buffer is sensor-dependent, and
|
||||
* needs to be queried from the camera device.
|
||||
*
|
||||
* Generally, not all 16 bits are used; more common values are 10 or 12
|
||||
* bits. If not all bits are used, the lower-order bits are filled first.
|
||||
* All parameters to interpret the raw data (black and white points,
|
||||
* color space, etc) must be queried from the camera device.
|
||||
*
|
||||
* This format assumes
|
||||
* - an even width
|
||||
* - an even height
|
||||
* - a horizontal stride multiple of 16 pixels
|
||||
* - a vertical stride equal to the height
|
||||
* - strides are specified in pixels, not in bytes
|
||||
*
|
||||
* size = stride * height * 2
|
||||
*
|
||||
* This format must be accepted by the gralloc module when used with the
|
||||
* following usage flags:
|
||||
* - GRALLOC_USAGE_HW_CAMERA_*
|
||||
* - GRALLOC_USAGE_SW_*
|
||||
* - GRALLOC_USAGE_RENDERSCRIPT
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace should be
|
||||
* HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
|
||||
* extra metadata to define.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_RAW16 = 0x20,
|
||||
|
||||
/*
|
||||
* Android RAW10 format:
|
||||
*
|
||||
* This format is exposed outside of the camera HAL to applications.
|
||||
*
|
||||
* RAW10 is a single-channel, 10-bit per pixel, densely packed in each row,
|
||||
* unprocessed format, usually representing raw Bayer-pattern images coming from
|
||||
* an image sensor.
|
||||
*
|
||||
* In an image buffer with this format, starting from the first pixel of each
|
||||
* row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one
|
||||
* of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte
|
||||
* contains the 2 least significant bits of the 4 pixels, the exact layout data
|
||||
* for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth
|
||||
* bit of the ith pixel):
|
||||
*
|
||||
* bit 7 bit 0
|
||||
* =====|=====|=====|=====|=====|=====|=====|=====|
|
||||
* Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]|
|
||||
* |-----|-----|-----|-----|-----|-----|-----|-----|
|
||||
* Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]|
|
||||
* |-----|-----|-----|-----|-----|-----|-----|-----|
|
||||
* Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]|
|
||||
* |-----|-----|-----|-----|-----|-----|-----|-----|
|
||||
* Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]|
|
||||
* |-----|-----|-----|-----|-----|-----|-----|-----|
|
||||
* Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]|
|
||||
* ===============================================
|
||||
*
|
||||
* This format assumes
|
||||
* - a width multiple of 4 pixels
|
||||
* - an even height
|
||||
* - a vertical stride equal to the height
|
||||
* - strides are specified in bytes, not in pixels
|
||||
*
|
||||
* size = stride * height
|
||||
*
|
||||
* When stride is equal to width * (10 / 8), there will be no padding bytes at
|
||||
* the end of each row, the entire image data is densely packed. When stride is
|
||||
* larger than width * (10 / 8), padding bytes will be present at the end of each
|
||||
* row (including the last row).
|
||||
*
|
||||
* This format must be accepted by the gralloc module when used with the
|
||||
* following usage flags:
|
||||
* - GRALLOC_USAGE_HW_CAMERA_*
|
||||
* - GRALLOC_USAGE_SW_*
|
||||
* - GRALLOC_USAGE_RENDERSCRIPT
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace field should be
|
||||
* HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
|
||||
* extra metadata to define.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_RAW10 = 0x25,
|
||||
|
||||
/*
|
||||
* Android RAW12 format:
|
||||
*
|
||||
* This format is exposed outside of camera HAL to applications.
|
||||
*
|
||||
* RAW12 is a single-channel, 12-bit per pixel, densely packed in each row,
|
||||
* unprocessed format, usually representing raw Bayer-pattern images coming from
|
||||
* an image sensor.
|
||||
*
|
||||
* In an image buffer with this format, starting from the first pixel of each
|
||||
* row, each two consecutive pixels are packed into 3 bytes (24 bits). The first
|
||||
* and second byte contains the top 8 bits of first and second pixel. The third
|
||||
* byte contains the 4 least significant bits of the two pixels, the exact layout
|
||||
* data for each two consecutive pixels is illustrated below (Pi[j] stands for
|
||||
* the jth bit of the ith pixel):
|
||||
*
|
||||
* bit 7 bit 0
|
||||
* ======|======|======|======|======|======|======|======|
|
||||
* Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]|
|
||||
* |------|------|------|------|------|------|------|------|
|
||||
* Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]|
|
||||
* |------|------|------|------|------|------|------|------|
|
||||
* Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]|
|
||||
* =======================================================
|
||||
*
|
||||
* This format assumes:
|
||||
* - a width multiple of 4 pixels
|
||||
* - an even height
|
||||
* - a vertical stride equal to the height
|
||||
* - strides are specified in bytes, not in pixels
|
||||
*
|
||||
* size = stride * height
|
||||
*
|
||||
* When stride is equal to width * (12 / 8), there will be no padding bytes at
|
||||
* the end of each row, the entire image data is densely packed. When stride is
|
||||
* larger than width * (12 / 8), padding bytes will be present at the end of
|
||||
* each row (including the last row).
|
||||
*
|
||||
* This format must be accepted by the gralloc module when used with the
|
||||
* following usage flags:
|
||||
* - GRALLOC_USAGE_HW_CAMERA_*
|
||||
* - GRALLOC_USAGE_SW_*
|
||||
* - GRALLOC_USAGE_RENDERSCRIPT
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace field should be
|
||||
* HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
|
||||
* extra metadata to define.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_RAW12 = 0x26,
|
||||
|
||||
/*
|
||||
* Android opaque RAW format:
|
||||
*
|
||||
* This format is exposed outside of the camera HAL to applications.
|
||||
*
|
||||
* RAW_OPAQUE is a format for unprocessed raw image buffers coming from an
|
||||
* image sensor. The actual structure of buffers of this format is
|
||||
* implementation-dependent.
|
||||
*
|
||||
* This format must be accepted by the gralloc module when used with the
|
||||
* following usage flags:
|
||||
* - GRALLOC_USAGE_HW_CAMERA_*
|
||||
* - GRALLOC_USAGE_SW_*
|
||||
* - GRALLOC_USAGE_RENDERSCRIPT
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace field should be
|
||||
* HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
|
||||
* extra metadata to define.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24,
|
||||
|
||||
/*
|
||||
* Android binary blob graphics buffer format:
|
||||
*
|
||||
* This format is used to carry task-specific data which does not have a
|
||||
* standard image structure. The details of the format are left to the two
|
||||
* endpoints.
|
||||
*
|
||||
* A typical use case is for transporting JPEG-compressed images from the
|
||||
* Camera HAL to the framework or to applications.
|
||||
*
|
||||
* Buffers of this format must have a height of 1, and width equal to their
|
||||
* size in bytes.
|
||||
*
|
||||
* When used with ANativeWindow, the mapping of the dataSpace field to
|
||||
* buffer contents for BLOB is as follows:
|
||||
*
|
||||
* dataSpace value | Buffer contents
|
||||
* -------------------------------+-----------------------------------------
|
||||
* HAL_DATASPACE_JFIF | An encoded JPEG image
|
||||
* HAL_DATASPACE_DEPTH | An android_depth_points buffer
|
||||
* Other | Unsupported
|
||||
*
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_BLOB = 0x21,
|
||||
|
||||
/*
|
||||
* Android format indicating that the choice of format is entirely up to the
|
||||
* device-specific Gralloc implementation.
|
||||
*
|
||||
* The Gralloc implementation should examine the usage bits passed in when
|
||||
* allocating a buffer with this format, and it should derive the pixel
|
||||
* format from those usage flags. This format will never be used with any
|
||||
* of the GRALLOC_USAGE_SW_* usage flags.
|
||||
*
|
||||
* If a buffer of this format is to be used as an OpenGL ES texture, the
|
||||
* framework will assume that sampling the texture will always return an
|
||||
* alpha value of 1.0 (i.e. the buffer contains only opaque pixel values).
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace field describes the color
|
||||
* space of the buffer.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22,
|
||||
|
||||
/*
|
||||
* Android flexible YCbCr 4:2:0 formats
|
||||
*
|
||||
* This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0
|
||||
* buffer layout, while still describing the general format in a
|
||||
* layout-independent manner. While called YCbCr, it can be
|
||||
* used to describe formats with either chromatic ordering, as well as
|
||||
* whole planar or semiplanar layouts.
|
||||
*
|
||||
* struct android_ycbcr (below) is the the struct used to describe it.
|
||||
*
|
||||
* This format must be accepted by the gralloc module when
|
||||
* USAGE_SW_WRITE_* or USAGE_SW_READ_* are set.
|
||||
*
|
||||
* This format is locked for use by gralloc's (*lock_ycbcr) method, and
|
||||
* locking with the (*lock) method will return an error.
|
||||
*
|
||||
* When used with ANativeWindow, the dataSpace field describes the color
|
||||
* space of the buffer.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23,
|
||||
|
||||
/*
|
||||
* Android flexible YCbCr 4:2:2 formats
|
||||
*
|
||||
* This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2
|
||||
* buffer layout, while still describing the general format in a
|
||||
* layout-independent manner. While called YCbCr, it can be
|
||||
* used to describe formats with either chromatic ordering, as well as
|
||||
* whole planar or semiplanar layouts.
|
||||
*
|
||||
* This format is currently only used by SW readable buffers
|
||||
* produced by MediaCodecs, so the gralloc module can ignore this format.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_YCbCr_422_888 = 0x27,
|
||||
|
||||
/*
|
||||
* Android flexible YCbCr 4:4:4 formats
|
||||
*
|
||||
* This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4
|
||||
* buffer layout, while still describing the general format in a
|
||||
* layout-independent manner. While called YCbCr, it can be
|
||||
* used to describe formats with either chromatic ordering, as well as
|
||||
* whole planar or semiplanar layouts.
|
||||
*
|
||||
* This format is currently only used by SW readable buffers
|
||||
* produced by MediaCodecs, so the gralloc module can ignore this format.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_YCbCr_444_888 = 0x28,
|
||||
|
||||
/*
|
||||
* Android flexible RGB 888 formats
|
||||
*
|
||||
* This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX
|
||||
* buffer layout, while still describing the general format in a
|
||||
* layout-independent manner. While called RGB, it can be
|
||||
* used to describe formats with either color ordering and optional
|
||||
* padding, as well as whole planar layout.
|
||||
*
|
||||
* This format is currently only used by SW readable buffers
|
||||
* produced by MediaCodecs, so the gralloc module can ignore this format.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_FLEX_RGB_888 = 0x29,
|
||||
|
||||
/*
|
||||
* Android flexible RGBA 8888 formats
|
||||
*
|
||||
* This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR
|
||||
* buffer layout, while still describing the general format in a
|
||||
* layout-independent manner. While called RGBA, it can be
|
||||
* used to describe formats with any of the component orderings, as
|
||||
* well as whole planar layout.
|
||||
*
|
||||
* This format is currently only used by SW readable buffers
|
||||
* produced by MediaCodecs, so the gralloc module can ignore this format.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 0x2A,
|
||||
|
||||
/* Legacy formats (deprecated), used by ImageFormat.java */
|
||||
HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16
|
||||
HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21
|
||||
HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure for describing YCbCr formats for consumption by applications.
|
||||
* This is used with HAL_PIXEL_FORMAT_YCbCr_*_888.
|
||||
*
|
||||
* Buffer chroma subsampling is defined in the format.
|
||||
* e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0.
|
||||
*
|
||||
* Buffers must have a 8 bit depth.
|
||||
*
|
||||
* @y, @cb, and @cr point to the first byte of their respective planes.
|
||||
*
|
||||
* Stride describes the distance in bytes from the first value of one row of
|
||||
* the image to the first value of the next row. It includes the width of the
|
||||
* image plus padding.
|
||||
* @ystride is the stride of the luma plane.
|
||||
* @cstride is the stride of the chroma planes.
|
||||
*
|
||||
* @chroma_step is the distance in bytes from one chroma pixel value to the
|
||||
* next. This is 2 bytes for semiplanar (because chroma values are interleaved
|
||||
* and each chroma value is one byte) and 1 for planar.
|
||||
*/
|
||||
|
||||
struct android_ycbcr {
|
||||
void *y;
|
||||
void *cb;
|
||||
void *cr;
|
||||
size_t ystride;
|
||||
size_t cstride;
|
||||
size_t chroma_step;
|
||||
|
||||
/** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */
|
||||
uint32_t reserved[8];
|
||||
};
|
||||
|
||||
/**
|
||||
* Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB
|
||||
* with dataSpace value of HAL_DATASPACE_DEPTH.
|
||||
* When locking a native buffer of the above format and dataSpace value,
|
||||
* the vaddr pointer can be cast to this structure.
|
||||
*
|
||||
* A variable-length list of (x,y,z, confidence) 3D points, as floats. (x, y,
|
||||
* z) represents a measured point's position, with the coordinate system defined
|
||||
* by the data source. Confidence represents the estimated likelihood that this
|
||||
* measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f ==
|
||||
* 100% confidence.
|
||||
*
|
||||
* @num_points is the number of points in the list
|
||||
*
|
||||
* @xyz_points is the flexible array of floating-point values.
|
||||
* It contains (num_points) * 4 floats.
|
||||
*
|
||||
* For example:
|
||||
* android_depth_points d = get_depth_buffer();
|
||||
* struct {
|
||||
* float x; float y; float z; float confidence;
|
||||
* } firstPoint, lastPoint;
|
||||
*
|
||||
* firstPoint.x = d.xyzc_points[0];
|
||||
* firstPoint.y = d.xyzc_points[1];
|
||||
* firstPoint.z = d.xyzc_points[2];
|
||||
* firstPoint.confidence = d.xyzc_points[3];
|
||||
* lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0];
|
||||
* lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1];
|
||||
* lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2];
|
||||
* lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3];
|
||||
*/
|
||||
|
||||
struct android_depth_points {
|
||||
uint32_t num_points;
|
||||
|
||||
/** reserved for future use, set to 0 by gralloc's (*lock)() */
|
||||
uint32_t reserved[8];
|
||||
|
||||
float xyzc_points[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Transformation definitions
|
||||
*
|
||||
* IMPORTANT NOTE:
|
||||
* HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}.
|
||||
*
|
||||
*/
|
||||
|
||||
enum {
|
||||
/* flip source image horizontally (around the vertical axis) */
|
||||
HAL_TRANSFORM_FLIP_H = 0x01,
|
||||
/* flip source image vertically (around the horizontal axis)*/
|
||||
HAL_TRANSFORM_FLIP_V = 0x02,
|
||||
/* rotate source image 90 degrees clockwise */
|
||||
HAL_TRANSFORM_ROT_90 = 0x04,
|
||||
/* rotate source image 180 degrees */
|
||||
HAL_TRANSFORM_ROT_180 = 0x03,
|
||||
/* rotate source image 270 degrees clockwise */
|
||||
HAL_TRANSFORM_ROT_270 = 0x07,
|
||||
/* don't use. see system/window.h */
|
||||
HAL_TRANSFORM_RESERVED = 0x08,
|
||||
};
|
||||
|
||||
/**
|
||||
* Dataspace Definitions
|
||||
* ======================
|
||||
*
|
||||
* Dataspace is the definition of how pixel values should be interpreted.
|
||||
*
|
||||
* For many formats, this is the colorspace of the image data, which includes
|
||||
* primaries (including white point) and the transfer characteristic function,
|
||||
* which describes both gamma curve and numeric range (within the bit depth).
|
||||
*
|
||||
* Other dataspaces include depth measurement data from a depth camera.
|
||||
*/
|
||||
|
||||
typedef enum android_dataspace {
|
||||
/*
|
||||
* Default-assumption data space, when not explicitly specified.
|
||||
*
|
||||
* It is safest to assume the buffer is an image with sRGB primaries and
|
||||
* encoding ranges, but the consumer and/or the producer of the data may
|
||||
* simply be using defaults. No automatic gamma transform should be
|
||||
* expected, except for a possible display gamma transform when drawn to a
|
||||
* screen.
|
||||
*/
|
||||
HAL_DATASPACE_UNKNOWN = 0x0,
|
||||
|
||||
/*
|
||||
* Arbitrary dataspace with manually defined characteristics. Definition
|
||||
* for colorspaces or other meaning must be communicated separately.
|
||||
*
|
||||
* This is used when specifying primaries, transfer characteristics,
|
||||
* etc. separately.
|
||||
*
|
||||
* A typical use case is in video encoding parameters (e.g. for H.264),
|
||||
* where a colorspace can have separately defined primaries, transfer
|
||||
* characteristics, etc.
|
||||
*/
|
||||
HAL_DATASPACE_ARBITRARY = 0x1,
|
||||
|
||||
/*
|
||||
* RGB Colorspaces
|
||||
* -----------------
|
||||
*
|
||||
* Primaries are given using (x,y) coordinates in the CIE 1931 definition
|
||||
* of x and y specified by ISO 11664-1.
|
||||
*
|
||||
* Transfer characteristics are the opto-electronic transfer characteristic
|
||||
* at the source as a function of linear optical intensity (luminance).
|
||||
*/
|
||||
|
||||
/*
|
||||
* sRGB linear encoding:
|
||||
*
|
||||
* The red, green, and blue components are stored in sRGB space, but
|
||||
* are linear, not gamma-encoded.
|
||||
* The RGB primaries and the white point are the same as BT.709.
|
||||
*
|
||||
* The values are encoded using the full range ([0,255] for 8-bit) for all
|
||||
* components.
|
||||
*/
|
||||
HAL_DATASPACE_SRGB_LINEAR = 0x200,
|
||||
|
||||
/*
|
||||
* sRGB gamma encoding:
|
||||
*
|
||||
* The red, green and blue components are stored in sRGB space, and
|
||||
* converted to linear space when read, using the standard sRGB to linear
|
||||
* equation:
|
||||
*
|
||||
* Clinear = Csrgb / 12.92 for Csrgb <= 0.04045
|
||||
* = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045
|
||||
*
|
||||
* When written the inverse transformation is performed:
|
||||
*
|
||||
* Csrgb = 12.92 * Clinear for Clinear <= 0.0031308
|
||||
* = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308
|
||||
*
|
||||
*
|
||||
* The alpha component, if present, is always stored in linear space and
|
||||
* is left unmodified when read or written.
|
||||
*
|
||||
* The RGB primaries and the white point are the same as BT.709.
|
||||
*
|
||||
* The values are encoded using the full range ([0,255] for 8-bit) for all
|
||||
* components.
|
||||
*
|
||||
*/
|
||||
HAL_DATASPACE_SRGB = 0x201,
|
||||
|
||||
/*
|
||||
* YCbCr Colorspaces
|
||||
* -----------------
|
||||
*
|
||||
* Primaries are given using (x,y) coordinates in the CIE 1931 definition
|
||||
* of x and y specified by ISO 11664-1.
|
||||
*
|
||||
* Transfer characteristics are the opto-electronic transfer characteristic
|
||||
* at the source as a function of linear optical intensity (luminance).
|
||||
*/
|
||||
|
||||
/*
|
||||
* JPEG File Interchange Format (JFIF)
|
||||
*
|
||||
* Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255
|
||||
*
|
||||
* Transfer characteristic curve:
|
||||
* E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018
|
||||
* E = 4.500 L, 0.018 > L >= 0
|
||||
* L - luminance of image 0 <= L <= 1 for conventional colorimetry
|
||||
* E - corresponding electrical signal
|
||||
*
|
||||
* Primaries: x y
|
||||
* green 0.290 0.600
|
||||
* blue 0.150 0.060
|
||||
* red 0.640 0.330
|
||||
* white (D65) 0.3127 0.3290
|
||||
*/
|
||||
HAL_DATASPACE_JFIF = 0x101,
|
||||
|
||||
/*
|
||||
* ITU-R Recommendation 601 (BT.601) - 625-line
|
||||
*
|
||||
* Standard-definition television, 625 Lines (PAL)
|
||||
*
|
||||
* For 8-bit-depth formats:
|
||||
* Luma (Y) samples should range from 16 to 235, inclusive
|
||||
* Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
|
||||
*
|
||||
* For 10-bit-depth formats:
|
||||
* Luma (Y) samples should range from 64 to 940, inclusive
|
||||
* Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
|
||||
*
|
||||
* Transfer characteristic curve:
|
||||
* E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018
|
||||
* E = 4.500 L, 0.018 > L >= 0
|
||||
* L - luminance of image 0 <= L <= 1 for conventional colorimetry
|
||||
* E - corresponding electrical signal
|
||||
*
|
||||
* Primaries: x y
|
||||
* green 0.290 0.600
|
||||
* blue 0.150 0.060
|
||||
* red 0.640 0.330
|
||||
* white (D65) 0.3127 0.3290
|
||||
*/
|
||||
HAL_DATASPACE_BT601_625 = 0x102,
|
||||
|
||||
/*
|
||||
* ITU-R Recommendation 601 (BT.601) - 525-line
|
||||
*
|
||||
* Standard-definition television, 525 Lines (NTSC)
|
||||
*
|
||||
* For 8-bit-depth formats:
|
||||
* Luma (Y) samples should range from 16 to 235, inclusive
|
||||
* Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
|
||||
*
|
||||
* For 10-bit-depth formats:
|
||||
* Luma (Y) samples should range from 64 to 940, inclusive
|
||||
* Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
|
||||
*
|
||||
* Transfer characteristic curve:
|
||||
* E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018
|
||||
* E = 4.500 L, 0.018 > L >= 0
|
||||
* L - luminance of image 0 <= L <= 1 for conventional colorimetry
|
||||
* E - corresponding electrical signal
|
||||
*
|
||||
* Primaries: x y
|
||||
* green 0.310 0.595
|
||||
* blue 0.155 0.070
|
||||
* red 0.630 0.340
|
||||
* white (D65) 0.3127 0.3290
|
||||
*/
|
||||
HAL_DATASPACE_BT601_525 = 0x103,
|
||||
|
||||
/*
|
||||
* ITU-R Recommendation 709 (BT.709)
|
||||
*
|
||||
* High-definition television
|
||||
*
|
||||
* For 8-bit-depth formats:
|
||||
* Luma (Y) samples should range from 16 to 235, inclusive
|
||||
* Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
|
||||
*
|
||||
* For 10-bit-depth formats:
|
||||
* Luma (Y) samples should range from 64 to 940, inclusive
|
||||
* Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
|
||||
*
|
||||
* Primaries: x y
|
||||
* green 0.300 0.600
|
||||
* blue 0.150 0.060
|
||||
* red 0.640 0.330
|
||||
* white (D65) 0.3127 0.3290
|
||||
*/
|
||||
HAL_DATASPACE_BT709 = 0x104,
|
||||
|
||||
/*
|
||||
* The buffer contains depth ranging measurements from a depth camera.
|
||||
* This value is valid with formats:
|
||||
* HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement
|
||||
* and an associated confidence value. The 3 MSBs of the sample make
|
||||
* up the confidence value, and the low 13 LSBs of the sample make up
|
||||
* the depth measurement.
|
||||
* For the confidence section, 0 means 100% confidence, 1 means 0%
|
||||
* confidence. The mapping to a linear float confidence value between
|
||||
* 0.f and 1.f can be obtained with
|
||||
* float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f;
|
||||
* The depth measurement can be extracted simply with
|
||||
* uint16_t range = (depthSample & 0x1FFF);
|
||||
* HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as
|
||||
* a variable-length float (x,y,z, confidence) coordinate point list.
|
||||
* The point cloud will be represented with the android_depth_points
|
||||
* structure.
|
||||
*/
|
||||
HAL_DATASPACE_DEPTH = 0x1000
|
||||
|
||||
} android_dataspace_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */
|
954
include/android/system/core/include/system/window.h
Normal file
954
include/android/system/core/include/system/window.h
Normal file
|
@ -0,0 +1,954 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
|
||||
#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <system/graphics.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef __UNUSED
|
||||
#define __UNUSED __attribute__((__unused__))
|
||||
#endif
|
||||
#ifndef __deprecated
|
||||
#define __deprecated __attribute__((__deprecated__))
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
|
||||
(((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))
|
||||
|
||||
#define ANDROID_NATIVE_WINDOW_MAGIC \
|
||||
ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
|
||||
|
||||
#define ANDROID_NATIVE_BUFFER_MAGIC \
|
||||
ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// This #define may be used to conditionally compile device-specific code to
|
||||
// support either the prior ANativeWindow interface, which did not pass libsync
|
||||
// fences around, or the new interface that does. This #define is only present
|
||||
// when the ANativeWindow interface does include libsync support.
|
||||
#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
typedef const native_handle_t* buffer_handle_t;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
typedef struct android_native_rect_t
|
||||
{
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
} android_native_rect_t;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
typedef struct android_native_base_t
|
||||
{
|
||||
/* a magic value defined by the actual EGL native type */
|
||||
int magic;
|
||||
|
||||
/* the sizeof() of the actual EGL native type */
|
||||
int version;
|
||||
|
||||
void* reserved[4];
|
||||
|
||||
/* reference-counting interface */
|
||||
void (*incRef)(struct android_native_base_t* base);
|
||||
void (*decRef)(struct android_native_base_t* base);
|
||||
} android_native_base_t;
|
||||
|
||||
typedef struct ANativeWindowBuffer
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
ANativeWindowBuffer() {
|
||||
common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
|
||||
common.version = sizeof(ANativeWindowBuffer);
|
||||
memset(common.reserved, 0, sizeof(common.reserved));
|
||||
}
|
||||
|
||||
// Implement the methods that sp<ANativeWindowBuffer> expects so that it
|
||||
// can be used to automatically refcount ANativeWindowBuffer's.
|
||||
void incStrong(const void* /*id*/) const {
|
||||
common.incRef(const_cast<android_native_base_t*>(&common));
|
||||
}
|
||||
void decStrong(const void* /*id*/) const {
|
||||
common.decRef(const_cast<android_native_base_t*>(&common));
|
||||
}
|
||||
#endif
|
||||
|
||||
struct android_native_base_t common;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int stride;
|
||||
int format;
|
||||
int usage;
|
||||
|
||||
void* reserved[2];
|
||||
|
||||
buffer_handle_t handle;
|
||||
|
||||
void* reserved_proc[8];
|
||||
} ANativeWindowBuffer_t;
|
||||
|
||||
// Old typedef for backwards compatibility.
|
||||
typedef ANativeWindowBuffer_t android_native_buffer_t;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/* attributes queriable with query() */
|
||||
enum {
|
||||
NATIVE_WINDOW_WIDTH = 0,
|
||||
NATIVE_WINDOW_HEIGHT = 1,
|
||||
NATIVE_WINDOW_FORMAT = 2,
|
||||
|
||||
/* The minimum number of buffers that must remain un-dequeued after a buffer
|
||||
* has been queued. This value applies only if set_buffer_count was used to
|
||||
* override the number of buffers and if a buffer has since been queued.
|
||||
* Users of the set_buffer_count ANativeWindow method should query this
|
||||
* value before calling set_buffer_count. If it is necessary to have N
|
||||
* buffers simultaneously dequeued as part of the steady-state operation,
|
||||
* and this query returns M then N+M buffers should be requested via
|
||||
* native_window_set_buffer_count.
|
||||
*
|
||||
* Note that this value does NOT apply until a single buffer has been
|
||||
* queued. In particular this means that it is possible to:
|
||||
*
|
||||
* 1. Query M = min undequeued buffers
|
||||
* 2. Set the buffer count to N + M
|
||||
* 3. Dequeue all N + M buffers
|
||||
* 4. Cancel M buffers
|
||||
* 5. Queue, dequeue, queue, dequeue, ad infinitum
|
||||
*/
|
||||
NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
|
||||
|
||||
/* Check whether queueBuffer operations on the ANativeWindow send the buffer
|
||||
* to the window compositor. The query sets the returned 'value' argument
|
||||
* to 1 if the ANativeWindow DOES send queued buffers directly to the window
|
||||
* compositor and 0 if the buffers do not go directly to the window
|
||||
* compositor.
|
||||
*
|
||||
* This can be used to determine whether protected buffer content should be
|
||||
* sent to the ANativeWindow. Note, however, that a result of 1 does NOT
|
||||
* indicate that queued buffers will be protected from applications or users
|
||||
* capturing their contents. If that behavior is desired then some other
|
||||
* mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
|
||||
* conjunction with this query.
|
||||
*/
|
||||
NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
|
||||
|
||||
/* Get the concrete type of a ANativeWindow. See below for the list of
|
||||
* possible return values.
|
||||
*
|
||||
* This query should not be used outside the Android framework and will
|
||||
* likely be removed in the near future.
|
||||
*/
|
||||
NATIVE_WINDOW_CONCRETE_TYPE = 5,
|
||||
|
||||
|
||||
/*
|
||||
* Default width and height of ANativeWindow buffers, these are the
|
||||
* dimensions of the window buffers irrespective of the
|
||||
* NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window
|
||||
* size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.
|
||||
*/
|
||||
NATIVE_WINDOW_DEFAULT_WIDTH = 6,
|
||||
NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
|
||||
|
||||
/*
|
||||
* transformation that will most-likely be applied to buffers. This is only
|
||||
* a hint, the actual transformation applied might be different.
|
||||
*
|
||||
* INTENDED USE:
|
||||
*
|
||||
* The transform hint can be used by a producer, for instance the GLES
|
||||
* driver, to pre-rotate the rendering such that the final transformation
|
||||
* in the composer is identity. This can be very useful when used in
|
||||
* conjunction with the h/w composer HAL, in situations where it
|
||||
* cannot handle arbitrary rotations.
|
||||
*
|
||||
* 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
|
||||
* queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
|
||||
*
|
||||
* 2. The GL driver overrides the width and height of the ANW to
|
||||
* account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
|
||||
* NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
|
||||
* according to NATIVE_WINDOW_TRANSFORM_HINT and calling
|
||||
* native_window_set_buffers_dimensions().
|
||||
*
|
||||
* 3. The GL driver dequeues a buffer of the new pre-rotated size.
|
||||
*
|
||||
* 4. The GL driver renders to the buffer such that the image is
|
||||
* already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
|
||||
* to the rendering.
|
||||
*
|
||||
* 5. The GL driver calls native_window_set_transform to apply
|
||||
* inverse transformation to the buffer it just rendered.
|
||||
* In order to do this, the GL driver needs
|
||||
* to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
|
||||
* done easily:
|
||||
*
|
||||
* int hintTransform, inverseTransform;
|
||||
* query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
|
||||
* inverseTransform = hintTransform;
|
||||
* if (hintTransform & HAL_TRANSFORM_ROT_90)
|
||||
* inverseTransform ^= HAL_TRANSFORM_ROT_180;
|
||||
*
|
||||
*
|
||||
* 6. The GL driver queues the pre-transformed buffer.
|
||||
*
|
||||
* 7. The composer combines the buffer transform with the display
|
||||
* transform. If the buffer transform happens to cancel out the
|
||||
* display transform then no rotation is needed.
|
||||
*
|
||||
*/
|
||||
NATIVE_WINDOW_TRANSFORM_HINT = 8,
|
||||
|
||||
/*
|
||||
* Boolean that indicates whether the consumer is running more than
|
||||
* one buffer behind the producer.
|
||||
*/
|
||||
NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,
|
||||
|
||||
/*
|
||||
* The consumer gralloc usage bits currently set by the consumer.
|
||||
* The values are defined in hardware/libhardware/include/gralloc.h.
|
||||
*/
|
||||
NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10,
|
||||
|
||||
/**
|
||||
* Transformation that will by applied to buffers by the hwcomposer.
|
||||
* This must not be set or checked by producer endpoints, and will
|
||||
* disable the transform hint set in SurfaceFlinger (see
|
||||
* NATIVE_WINDOW_TRANSFORM_HINT).
|
||||
*
|
||||
* INTENDED USE:
|
||||
* Temporary - Please do not use this. This is intended only to be used
|
||||
* by the camera's LEGACY mode.
|
||||
*
|
||||
* In situations where a SurfaceFlinger client wishes to set a transform
|
||||
* that is not visible to the producer, and will always be applied in the
|
||||
* hardware composer, the client can set this flag with
|
||||
* native_window_set_buffers_sticky_transform. This can be used to rotate
|
||||
* and flip buffers consumed by hardware composer without actually changing
|
||||
* the aspect ratio of the buffers produced.
|
||||
*/
|
||||
NATIVE_WINDOW_STICKY_TRANSFORM = 11,
|
||||
|
||||
/**
|
||||
* The default data space for the buffers as set by the consumer.
|
||||
* The values are defined in graphics.h.
|
||||
*/
|
||||
NATIVE_WINDOW_DEFAULT_DATASPACE = 12,
|
||||
|
||||
/*
|
||||
* Returns the age of the contents of the most recently dequeued buffer as
|
||||
* the number of frames that have elapsed since it was last queued. For
|
||||
* example, if the window is double-buffered, the age of any given buffer in
|
||||
* steady state will be 2. If the dequeued buffer has never been queued, its
|
||||
* age will be 0.
|
||||
*/
|
||||
NATIVE_WINDOW_BUFFER_AGE = 13,
|
||||
};
|
||||
|
||||
/* Valid operations for the (*perform)() hook.
|
||||
*
|
||||
* Values marked as 'deprecated' are supported, but have been superceded by
|
||||
* other functionality.
|
||||
*
|
||||
* Values marked as 'private' should be considered private to the framework.
|
||||
* HAL implementation code with access to an ANativeWindow should not use these,
|
||||
* as it may not interact properly with the framework's use of the
|
||||
* ANativeWindow.
|
||||
*/
|
||||
enum {
|
||||
NATIVE_WINDOW_SET_USAGE = 0,
|
||||
NATIVE_WINDOW_CONNECT = 1, /* deprecated */
|
||||
NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
|
||||
NATIVE_WINDOW_SET_CROP = 3, /* private */
|
||||
NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
|
||||
NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
|
||||
NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
|
||||
NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
|
||||
NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
|
||||
NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
|
||||
NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */
|
||||
NATIVE_WINDOW_LOCK = 11, /* private */
|
||||
NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
|
||||
NATIVE_WINDOW_API_CONNECT = 13, /* private */
|
||||
NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
|
||||
NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
|
||||
NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */
|
||||
NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
|
||||
NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18,
|
||||
NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19,
|
||||
NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */
|
||||
};
|
||||
|
||||
/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
|
||||
enum {
|
||||
/* Buffers will be queued by EGL via eglSwapBuffers after being filled using
|
||||
* OpenGL ES.
|
||||
*/
|
||||
NATIVE_WINDOW_API_EGL = 1,
|
||||
|
||||
/* Buffers will be queued after being filled using the CPU
|
||||
*/
|
||||
NATIVE_WINDOW_API_CPU = 2,
|
||||
|
||||
/* Buffers will be queued by Stagefright after being filled by a video
|
||||
* decoder. The video decoder can either be a software or hardware decoder.
|
||||
*/
|
||||
NATIVE_WINDOW_API_MEDIA = 3,
|
||||
|
||||
/* Buffers will be queued by the the camera HAL.
|
||||
*/
|
||||
NATIVE_WINDOW_API_CAMERA = 4,
|
||||
};
|
||||
|
||||
/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
|
||||
enum {
|
||||
/* flip source image horizontally */
|
||||
NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
|
||||
/* flip source image vertically */
|
||||
NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
|
||||
/* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
|
||||
NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
|
||||
/* rotate source image 180 degrees */
|
||||
NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
|
||||
/* rotate source image 270 degrees clock-wise */
|
||||
NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
|
||||
/* transforms source by the inverse transform of the screen it is displayed onto. This
|
||||
* transform is applied last */
|
||||
NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08
|
||||
};
|
||||
|
||||
/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */
|
||||
enum {
|
||||
/* the window content is not updated (frozen) until a buffer of
|
||||
* the window size is received (enqueued)
|
||||
*/
|
||||
NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
|
||||
/* the buffer is scaled in both dimensions to match the window size */
|
||||
NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
|
||||
/* the buffer is scaled uniformly such that the smaller dimension
|
||||
* of the buffer matches the window size (cropping in the process)
|
||||
*/
|
||||
NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,
|
||||
/* the window is clipped to the size of the buffer's crop rectangle; pixels
|
||||
* outside the crop rectangle are treated as if they are completely
|
||||
* transparent.
|
||||
*/
|
||||
NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3,
|
||||
};
|
||||
|
||||
/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
|
||||
enum {
|
||||
NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
|
||||
NATIVE_WINDOW_SURFACE = 1, /* Surface */
|
||||
};
|
||||
|
||||
/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
|
||||
*
|
||||
* Special timestamp value to indicate that timestamps should be auto-generated
|
||||
* by the native window when queueBuffer is called. This is equal to INT64_MIN,
|
||||
* defined directly to avoid problems with C99/C++ inclusion of stdint.h.
|
||||
*/
|
||||
static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
|
||||
|
||||
struct ANativeWindow
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
ANativeWindow()
|
||||
: flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
|
||||
{
|
||||
common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
|
||||
common.version = sizeof(ANativeWindow);
|
||||
memset(common.reserved, 0, sizeof(common.reserved));
|
||||
}
|
||||
|
||||
/* Implement the methods that sp<ANativeWindow> expects so that it
|
||||
can be used to automatically refcount ANativeWindow's. */
|
||||
void incStrong(const void* /*id*/) const {
|
||||
common.incRef(const_cast<android_native_base_t*>(&common));
|
||||
}
|
||||
void decStrong(const void* /*id*/) const {
|
||||
common.decRef(const_cast<android_native_base_t*>(&common));
|
||||
}
|
||||
#endif
|
||||
|
||||
struct android_native_base_t common;
|
||||
|
||||
/* flags describing some attributes of this surface or its updater */
|
||||
const uint32_t flags;
|
||||
|
||||
/* min swap interval supported by this updated */
|
||||
const int minSwapInterval;
|
||||
|
||||
/* max swap interval supported by this updated */
|
||||
const int maxSwapInterval;
|
||||
|
||||
/* horizontal and vertical resolution in DPI */
|
||||
const float xdpi;
|
||||
const float ydpi;
|
||||
|
||||
/* Some storage reserved for the OEM's driver. */
|
||||
intptr_t oem[4];
|
||||
|
||||
/*
|
||||
* Set the swap interval for this surface.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*setSwapInterval)(struct ANativeWindow* window,
|
||||
int interval);
|
||||
|
||||
/*
|
||||
* Hook called by EGL to acquire a buffer. After this call, the buffer
|
||||
* is not locked, so its content cannot be modified. This call may block if
|
||||
* no buffers are available.
|
||||
*
|
||||
* The window holds a reference to the buffer between dequeueBuffer and
|
||||
* either queueBuffer or cancelBuffer, so clients only need their own
|
||||
* reference if they might use the buffer after queueing or canceling it.
|
||||
* Holding a reference to a buffer after queueing or canceling it is only
|
||||
* allowed if a specific buffer count has been set.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*
|
||||
* XXX: This function is deprecated. It will continue to work for some
|
||||
* time for binary compatibility, but the new dequeueBuffer function that
|
||||
* outputs a fence file descriptor should be used in its place.
|
||||
*/
|
||||
int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer** buffer);
|
||||
|
||||
/*
|
||||
* hook called by EGL to lock a buffer. This MUST be called before modifying
|
||||
* the content of a buffer. The buffer must have been acquired with
|
||||
* dequeueBuffer first.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*
|
||||
* XXX: This function is deprecated. It will continue to work for some
|
||||
* time for binary compatibility, but it is essentially a no-op, and calls
|
||||
* to it should be removed.
|
||||
*/
|
||||
int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer* buffer);
|
||||
|
||||
/*
|
||||
* Hook called by EGL when modifications to the render buffer are done.
|
||||
* This unlocks and post the buffer.
|
||||
*
|
||||
* The window holds a reference to the buffer between dequeueBuffer and
|
||||
* either queueBuffer or cancelBuffer, so clients only need their own
|
||||
* reference if they might use the buffer after queueing or canceling it.
|
||||
* Holding a reference to a buffer after queueing or canceling it is only
|
||||
* allowed if a specific buffer count has been set.
|
||||
*
|
||||
* Buffers MUST be queued in the same order than they were dequeued.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*
|
||||
* XXX: This function is deprecated. It will continue to work for some
|
||||
* time for binary compatibility, but the new queueBuffer function that
|
||||
* takes a fence file descriptor should be used in its place (pass a value
|
||||
* of -1 for the fence file descriptor if there is no valid one to pass).
|
||||
*/
|
||||
int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer* buffer);
|
||||
|
||||
/*
|
||||
* hook used to retrieve information about the native window.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*query)(const struct ANativeWindow* window,
|
||||
int what, int* value);
|
||||
|
||||
/*
|
||||
* hook used to perform various operations on the surface.
|
||||
* (*perform)() is a generic mechanism to add functionality to
|
||||
* ANativeWindow while keeping backward binary compatibility.
|
||||
*
|
||||
* DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
|
||||
* defined below.
|
||||
*
|
||||
* (*perform)() returns -ENOENT if the 'what' parameter is not supported
|
||||
* by the surface's implementation.
|
||||
*
|
||||
* See above for a list of valid operations, such as
|
||||
* NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
|
||||
*/
|
||||
int (*perform)(struct ANativeWindow* window,
|
||||
int operation, ... );
|
||||
|
||||
/*
|
||||
* Hook used to cancel a buffer that has been dequeued.
|
||||
* No synchronization is performed between dequeue() and cancel(), so
|
||||
* either external synchronization is needed, or these functions must be
|
||||
* called from the same thread.
|
||||
*
|
||||
* The window holds a reference to the buffer between dequeueBuffer and
|
||||
* either queueBuffer or cancelBuffer, so clients only need their own
|
||||
* reference if they might use the buffer after queueing or canceling it.
|
||||
* Holding a reference to a buffer after queueing or canceling it is only
|
||||
* allowed if a specific buffer count has been set.
|
||||
*
|
||||
* XXX: This function is deprecated. It will continue to work for some
|
||||
* time for binary compatibility, but the new cancelBuffer function that
|
||||
* takes a fence file descriptor should be used in its place (pass a value
|
||||
* of -1 for the fence file descriptor if there is no valid one to pass).
|
||||
*/
|
||||
int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer* buffer);
|
||||
|
||||
/*
|
||||
* Hook called by EGL to acquire a buffer. This call may block if no
|
||||
* buffers are available.
|
||||
*
|
||||
* The window holds a reference to the buffer between dequeueBuffer and
|
||||
* either queueBuffer or cancelBuffer, so clients only need their own
|
||||
* reference if they might use the buffer after queueing or canceling it.
|
||||
* Holding a reference to a buffer after queueing or canceling it is only
|
||||
* allowed if a specific buffer count has been set.
|
||||
*
|
||||
* The libsync fence file descriptor returned in the int pointed to by the
|
||||
* fenceFd argument will refer to the fence that must signal before the
|
||||
* dequeued buffer may be written to. A value of -1 indicates that the
|
||||
* caller may access the buffer immediately without waiting on a fence. If
|
||||
* a valid file descriptor is returned (i.e. any value except -1) then the
|
||||
* caller is responsible for closing the file descriptor.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*dequeueBuffer)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer** buffer, int* fenceFd);
|
||||
|
||||
/*
|
||||
* Hook called by EGL when modifications to the render buffer are done.
|
||||
* This unlocks and post the buffer.
|
||||
*
|
||||
* The window holds a reference to the buffer between dequeueBuffer and
|
||||
* either queueBuffer or cancelBuffer, so clients only need their own
|
||||
* reference if they might use the buffer after queueing or canceling it.
|
||||
* Holding a reference to a buffer after queueing or canceling it is only
|
||||
* allowed if a specific buffer count has been set.
|
||||
*
|
||||
* The fenceFd argument specifies a libsync fence file descriptor for a
|
||||
* fence that must signal before the buffer can be accessed. If the buffer
|
||||
* can be accessed immediately then a value of -1 should be used. The
|
||||
* caller must not use the file descriptor after it is passed to
|
||||
* queueBuffer, and the ANativeWindow implementation is responsible for
|
||||
* closing it.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*queueBuffer)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer* buffer, int fenceFd);
|
||||
|
||||
/*
|
||||
* Hook used to cancel a buffer that has been dequeued.
|
||||
* No synchronization is performed between dequeue() and cancel(), so
|
||||
* either external synchronization is needed, or these functions must be
|
||||
* called from the same thread.
|
||||
*
|
||||
* The window holds a reference to the buffer between dequeueBuffer and
|
||||
* either queueBuffer or cancelBuffer, so clients only need their own
|
||||
* reference if they might use the buffer after queueing or canceling it.
|
||||
* Holding a reference to a buffer after queueing or canceling it is only
|
||||
* allowed if a specific buffer count has been set.
|
||||
*
|
||||
* The fenceFd argument specifies a libsync fence file decsriptor for a
|
||||
* fence that must signal before the buffer can be accessed. If the buffer
|
||||
* can be accessed immediately then a value of -1 should be used.
|
||||
*
|
||||
* Note that if the client has not waited on the fence that was returned
|
||||
* from dequeueBuffer, that same fence should be passed to cancelBuffer to
|
||||
* ensure that future uses of the buffer are preceded by a wait on that
|
||||
* fence. The caller must not use the file descriptor after it is passed
|
||||
* to cancelBuffer, and the ANativeWindow implementation is responsible for
|
||||
* closing it.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*cancelBuffer)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer* buffer, int fenceFd);
|
||||
};
|
||||
|
||||
/* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
|
||||
* android_native_window_t is deprecated.
|
||||
*/
|
||||
typedef struct ANativeWindow ANativeWindow;
|
||||
typedef struct ANativeWindow android_native_window_t __deprecated;
|
||||
|
||||
/*
|
||||
* native_window_set_usage(..., usage)
|
||||
* Sets the intended usage flags for the next buffers
|
||||
* acquired with (*lockBuffer)() and on.
|
||||
* By default (if this function is never called), a usage of
|
||||
* GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
|
||||
* is assumed.
|
||||
* Calling this function will usually cause following buffers to be
|
||||
* reallocated.
|
||||
*/
|
||||
|
||||
static inline int native_window_set_usage(
|
||||
struct ANativeWindow* window, int usage)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
|
||||
}
|
||||
|
||||
/* deprecated. Always returns 0. Don't call. */
|
||||
static inline int native_window_connect(
|
||||
struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
|
||||
|
||||
static inline int native_window_connect(
|
||||
struct ANativeWindow* window __UNUSED, int api __UNUSED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* deprecated. Always returns 0. Don't call. */
|
||||
static inline int native_window_disconnect(
|
||||
struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
|
||||
|
||||
static inline int native_window_disconnect(
|
||||
struct ANativeWindow* window __UNUSED, int api __UNUSED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_crop(..., crop)
|
||||
* Sets which region of the next queued buffers needs to be considered.
|
||||
* Depending on the scaling mode, a buffer's crop region is scaled and/or
|
||||
* cropped to match the surface's size. This function sets the crop in
|
||||
* pre-transformed buffer pixel coordinates.
|
||||
*
|
||||
* The specified crop region applies to all buffers queued after it is called.
|
||||
*
|
||||
* If 'crop' is NULL, subsequently queued buffers won't be cropped.
|
||||
*
|
||||
* An error is returned if for instance the crop region is invalid, out of the
|
||||
* buffer's bound or if the window is invalid.
|
||||
*/
|
||||
static inline int native_window_set_crop(
|
||||
struct ANativeWindow* window,
|
||||
android_native_rect_t const * crop)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_post_transform_crop(..., crop)
|
||||
* Sets which region of the next queued buffers needs to be considered.
|
||||
* Depending on the scaling mode, a buffer's crop region is scaled and/or
|
||||
* cropped to match the surface's size. This function sets the crop in
|
||||
* post-transformed pixel coordinates.
|
||||
*
|
||||
* The specified crop region applies to all buffers queued after it is called.
|
||||
*
|
||||
* If 'crop' is NULL, subsequently queued buffers won't be cropped.
|
||||
*
|
||||
* An error is returned if for instance the crop region is invalid, out of the
|
||||
* buffer's bound or if the window is invalid.
|
||||
*/
|
||||
static inline int native_window_set_post_transform_crop(
|
||||
struct ANativeWindow* window,
|
||||
android_native_rect_t const * crop)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_active_rect(..., active_rect)
|
||||
*
|
||||
* This function is deprecated and will be removed soon. For now it simply
|
||||
* sets the post-transform crop for compatibility while multi-project commits
|
||||
* get checked.
|
||||
*/
|
||||
static inline int native_window_set_active_rect(
|
||||
struct ANativeWindow* window,
|
||||
android_native_rect_t const * active_rect) __deprecated;
|
||||
|
||||
static inline int native_window_set_active_rect(
|
||||
struct ANativeWindow* window,
|
||||
android_native_rect_t const * active_rect)
|
||||
{
|
||||
return native_window_set_post_transform_crop(window, active_rect);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffer_count(..., count)
|
||||
* Sets the number of buffers associated with this native window.
|
||||
*/
|
||||
static inline int native_window_set_buffer_count(
|
||||
struct ANativeWindow* window,
|
||||
size_t bufferCount)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_geometry(..., int w, int h, int format)
|
||||
* All buffers dequeued after this call will have the dimensions and format
|
||||
* specified. A successful call to this function has the same effect as calling
|
||||
* native_window_set_buffers_size and native_window_set_buffers_format.
|
||||
*
|
||||
* XXX: This function is deprecated. The native_window_set_buffers_dimensions
|
||||
* and native_window_set_buffers_format functions should be used instead.
|
||||
*/
|
||||
static inline int native_window_set_buffers_geometry(
|
||||
struct ANativeWindow* window,
|
||||
int w, int h, int format) __deprecated;
|
||||
|
||||
static inline int native_window_set_buffers_geometry(
|
||||
struct ANativeWindow* window,
|
||||
int w, int h, int format)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
|
||||
w, h, format);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_dimensions(..., int w, int h)
|
||||
* All buffers dequeued after this call will have the dimensions specified.
|
||||
* In particular, all buffers will have a fixed-size, independent from the
|
||||
* native-window size. They will be scaled according to the scaling mode
|
||||
* (see native_window_set_scaling_mode) upon window composition.
|
||||
*
|
||||
* If w and h are 0, the normal behavior is restored. That is, dequeued buffers
|
||||
* following this call will be sized to match the window's size.
|
||||
*
|
||||
* Calling this function will reset the window crop to a NULL value, which
|
||||
* disables cropping of the buffers.
|
||||
*/
|
||||
static inline int native_window_set_buffers_dimensions(
|
||||
struct ANativeWindow* window,
|
||||
int w, int h)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
|
||||
w, h);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_user_dimensions(..., int w, int h)
|
||||
*
|
||||
* Sets the user buffer size for the window, which overrides the
|
||||
* window's size. All buffers dequeued after this call will have the
|
||||
* dimensions specified unless overridden by
|
||||
* native_window_set_buffers_dimensions. All buffers will have a
|
||||
* fixed-size, independent from the native-window size. They will be
|
||||
* scaled according to the scaling mode (see
|
||||
* native_window_set_scaling_mode) upon window composition.
|
||||
*
|
||||
* If w and h are 0, the normal behavior is restored. That is, the
|
||||
* default buffer size will match the windows's size.
|
||||
*
|
||||
* Calling this function will reset the window crop to a NULL value, which
|
||||
* disables cropping of the buffers.
|
||||
*/
|
||||
static inline int native_window_set_buffers_user_dimensions(
|
||||
struct ANativeWindow* window,
|
||||
int w, int h)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,
|
||||
w, h);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_format(..., int format)
|
||||
* All buffers dequeued after this call will have the format specified.
|
||||
*
|
||||
* If the specified format is 0, the default buffer format will be used.
|
||||
*/
|
||||
static inline int native_window_set_buffers_format(
|
||||
struct ANativeWindow* window,
|
||||
int format)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_data_space(..., int dataSpace)
|
||||
* All buffers queued after this call will be associated with the dataSpace
|
||||
* parameter specified.
|
||||
*
|
||||
* dataSpace specifies additional information about the buffer that's dependent
|
||||
* on the buffer format and the endpoints. For example, it can be used to convey
|
||||
* the color space of the image data in the buffer, or it can be used to
|
||||
* indicate that the buffers contain depth measurement data instead of color
|
||||
* images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
|
||||
* overridden by the consumer.
|
||||
*/
|
||||
static inline int native_window_set_buffers_data_space(
|
||||
struct ANativeWindow* window,
|
||||
android_dataspace_t dataSpace)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,
|
||||
dataSpace);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_transform(..., int transform)
|
||||
* All buffers queued after this call will be displayed transformed according
|
||||
* to the transform parameter specified.
|
||||
*/
|
||||
static inline int native_window_set_buffers_transform(
|
||||
struct ANativeWindow* window,
|
||||
int transform)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
|
||||
transform);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_sticky_transform(..., int transform)
|
||||
* All buffers queued after this call will be displayed transformed according
|
||||
* to the transform parameter specified applied on top of the regular buffer
|
||||
* transform. Setting this transform will disable the transform hint.
|
||||
*
|
||||
* Temporary - This is only intended to be used by the LEGACY camera mode, do
|
||||
* not use this for anything else.
|
||||
*/
|
||||
static inline int native_window_set_buffers_sticky_transform(
|
||||
struct ANativeWindow* window,
|
||||
int transform)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,
|
||||
transform);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_timestamp(..., int64_t timestamp)
|
||||
* All buffers queued after this call will be associated with the timestamp
|
||||
* parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
|
||||
* (the default), timestamps will be generated automatically when queueBuffer is
|
||||
* called. The timestamp is measured in nanoseconds, and is normally monotonically
|
||||
* increasing. The timestamp should be unaffected by time-of-day adjustments,
|
||||
* and for a camera should be strictly monotonic but for a media player may be
|
||||
* reset when the position is set.
|
||||
*/
|
||||
static inline int native_window_set_buffers_timestamp(
|
||||
struct ANativeWindow* window,
|
||||
int64_t timestamp)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_scaling_mode(..., int mode)
|
||||
* All buffers queued after this call will be associated with the scaling mode
|
||||
* specified.
|
||||
*/
|
||||
static inline int native_window_set_scaling_mode(
|
||||
struct ANativeWindow* window,
|
||||
int mode)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
|
||||
mode);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_api_connect(..., int api)
|
||||
* connects an API to this window. only one API can be connected at a time.
|
||||
* Returns -EINVAL if for some reason the window cannot be connected, which
|
||||
* can happen if it's connected to some other API.
|
||||
*/
|
||||
static inline int native_window_api_connect(
|
||||
struct ANativeWindow* window, int api)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_api_disconnect(..., int api)
|
||||
* disconnect the API from this window.
|
||||
* An error is returned if for instance the window wasn't connected in the
|
||||
* first place.
|
||||
*/
|
||||
static inline int native_window_api_disconnect(
|
||||
struct ANativeWindow* window, int api)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_dequeue_buffer_and_wait(...)
|
||||
* Dequeue a buffer and wait on the fence associated with that buffer. The
|
||||
* buffer may safely be accessed immediately upon this function returning. An
|
||||
* error is returned if either of the dequeue or the wait operations fail.
|
||||
*/
|
||||
static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,
|
||||
struct ANativeWindowBuffer** anb) {
|
||||
return anw->dequeueBuffer_DEPRECATED(anw, anb);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_sideband_stream(..., native_handle_t*)
|
||||
* Attach a sideband buffer stream to a native window.
|
||||
*/
|
||||
static inline int native_window_set_sideband_stream(
|
||||
struct ANativeWindow* window,
|
||||
native_handle_t* sidebandHandle)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,
|
||||
sidebandHandle);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
|
||||
* Set the surface damage (i.e., the region of the surface that has changed
|
||||
* since the previous frame). The damage set by this call will be reset (to the
|
||||
* default of full-surface damage) after calling queue, so this must be called
|
||||
* prior to every frame with damage that does not cover the whole surface if the
|
||||
* caller desires downstream consumers to use this optimization.
|
||||
*
|
||||
* The damage region is specified as an array of rectangles, with the important
|
||||
* caveat that the origin of the surface is considered to be the bottom-left
|
||||
* corner, as in OpenGL ES.
|
||||
*
|
||||
* If numRects is set to 0, rects may be NULL, and the surface damage will be
|
||||
* set to the full surface (the same as if this function had not been called for
|
||||
* this frame).
|
||||
*/
|
||||
static inline int native_window_set_surface_damage(
|
||||
struct ANativeWindow* window,
|
||||
const android_native_rect_t* rects, size_t numRects)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,
|
||||
rects, numRects);
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */
|
Loading…
Add table
Add a link
Reference in a new issue