mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-24 17:15:07 +03:00
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 */
|
Loading…
Add table
Add a link
Reference in a new issue