summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/hardware/audio_effect.h18
-rw-r--r--include/hardware/bluetooth.h5
-rw-r--r--include/hardware/bt_common_types.h44
-rw-r--r--include/hardware/bt_gatt_client.h26
-rw-r--r--include/hardware/camera3.h244
-rw-r--r--include/hardware/camera_common.h495
-rw-r--r--include/hardware/fingerprint.h137
-rw-r--r--include/hardware/fused_location.h17
-rw-r--r--include/hardware/gatekeeper.h149
-rw-r--r--include/hardware/hw_auth_token.h4
-rw-r--r--include/hardware/input.h507
-rw-r--r--include/hardware/radio.h298
12 files changed, 1861 insertions, 83 deletions
diff --git a/include/hardware/audio_effect.h b/include/hardware/audio_effect.h
index ee48e4c..41cd2e6 100644
--- a/include/hardware/audio_effect.h
+++ b/include/hardware/audio_effect.h
@@ -344,9 +344,10 @@ struct effect_interface_s {
// Output:
// returned value: 0 successful operation
// -EINVAL invalid interface handle or
- // invalid command/reply size or format according to command code
- // The return code should be restricted to indicate problems related to the this
- // API specification. Status related to the execution of a particular command should be
+ // invalid command/reply size or format according to
+ // command code
+ // The return code should be restricted to indicate problems related to this API
+ // specification. Status related to the execution of a particular command should be
// indicated as part of the reply field.
//
// *pReplyData updated with command response
@@ -937,11 +938,12 @@ typedef struct audio_effect_library_s {
//
// Input:
// uuid: pointer to the effect uuid.
- // sessionId: audio session to which this effect instance will be attached. All effects
- // created with the same session ID are connected in series and process the same signal
- // stream. Knowing that two effects are part of the same effect chain can help the
- // library implement some kind of optimizations.
- // ioId: identifies the output or input stream this effect is directed to at audio HAL.
+ // sessionId: audio session to which this effect instance will be attached.
+ // All effects created with the same session ID are connected in series and process
+ // the same signal stream. Knowing that two effects are part of the same effect
+ // chain can help the library implement some kind of optimizations.
+ // ioId: identifies the output or input stream this effect is directed to in
+ // audio HAL.
// For future use especially with tunneled HW accelerated effects
//
// Input/Output:
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index 74cd1fc..75c9e9c 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -143,14 +143,15 @@ typedef struct
typedef struct
{
+ uint16_t version_supported;
uint8_t local_privacy_enabled;
uint8_t max_adv_instance;
uint8_t rpa_offload_supported;
uint8_t max_irk_list_size;
uint8_t max_adv_filter_supported;
- uint8_t scan_result_storage_size_lobyte;
- uint8_t scan_result_storage_size_hibyte;
uint8_t activity_energy_info_supported;
+ uint16_t scan_result_storage_size;
+ uint16_t total_trackable_advertisers;
}bt_local_le_features_t;
/* Bluetooth Adapter and Remote Device property types */
diff --git a/include/hardware/bt_common_types.h b/include/hardware/bt_common_types.h
new file mode 100644
index 0000000..e30ac24
--- /dev/null
+++ b/include/hardware/bt_common_types.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+/******************************************************************************
+ *
+ * This file contains constants and definitions that can be used commonly between JNI and stack layer
+ *
+ ******************************************************************************/
+#ifndef ANDROID_INCLUDE_BT_COMMON_TYPES_H
+#define ANDROID_INCLUDE_BT_COMMON_TYPES_H
+
+#include "bluetooth.h"
+
+typedef struct
+{
+ uint8_t client_if;
+ uint8_t filt_index;
+ uint8_t advertiser_state;
+ uint8_t advertiser_info_present;
+ uint8_t addr_type;
+ uint8_t tx_power;
+ int8_t rssi_value;
+ uint16_t time_stamp;
+ bt_bdaddr_t bd_addr;
+ uint8_t adv_pkt_len;
+ uint8_t *p_adv_pkt_data;
+ uint8_t scan_rsp_len;
+ uint8_t *p_scan_rsp_data;
+} btgatt_track_adv_info_t;
+
+#endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */
diff --git a/include/hardware/bt_gatt_client.h b/include/hardware/bt_gatt_client.h
index 8073dd1..7881dc8 100644
--- a/include/hardware/bt_gatt_client.h
+++ b/include/hardware/bt_gatt_client.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include "bt_gatt_types.h"
+#include "bt_common_types.h"
__BEGIN_DECLS
@@ -69,6 +70,23 @@ typedef struct
typedef struct
{
+ uint8_t client_if;
+ uint8_t action;
+ uint8_t filt_index;
+ uint16_t feat_seln;
+ uint16_t list_logic_type;
+ uint8_t filt_logic_type;
+ uint8_t rssi_high_thres;
+ uint8_t rssi_low_thres;
+ uint8_t dely_mode;
+ uint16_t found_timeout;
+ uint16_t lost_timeout;
+ uint8_t found_timeout_cnt;
+ uint16_t num_of_tracking_entries;
+} btgatt_filt_param_setup_t;
+
+typedef struct
+{
bt_bdaddr_t *bda1;
bt_uuid_t *uuid1;
uint16_t u1;
@@ -202,8 +220,7 @@ typedef void (*batchscan_reports_callback)(int client_if, int status, int report
typedef void (*batchscan_threshold_callback)(int client_if);
/** Track ADV VSE callback invoked when tracked device is found or lost */
-typedef void (*track_adv_event_callback)(int client_if, int filt_index, int addr_type,
- bt_bdaddr_t* bda, int adv_state);
+typedef void (*track_adv_event_callback)(btgatt_track_adv_info_t *p_track_adv_info);
typedef struct {
register_client_callback register_client_cb;
@@ -336,10 +353,7 @@ typedef struct {
bt_status_t (*read_remote_rssi)( int client_if, const bt_bdaddr_t *bd_addr);
/** Setup scan filter params */
- bt_status_t (*scan_filter_param_setup)(int client_if, int action, int filt_index, int feat_seln,
- int list_logic_type, int filt_logic_type, int rssi_high_thres,
- int rssi_low_thres, int dely_mode, int found_timeout,
- int lost_timeout, int found_timeout_cnt);
+ bt_status_t (*scan_filter_param_setup)(btgatt_filt_param_setup_t filt_param);
/** Configure a scan filter condition */
diff --git a/include/hardware/camera3.h b/include/hardware/camera3.h
index 2bb3ba1..fd3a45d 100644
--- a/include/hardware/camera3.h
+++ b/include/hardware/camera3.h
@@ -21,7 +21,7 @@
#include "camera_common.h"
/**
- * Camera device HAL 3.2 [ CAMERA_DEVICE_API_VERSION_3_2 ]
+ * Camera device HAL 3.3 [ CAMERA_DEVICE_API_VERSION_3_3 ]
*
* This is the current recommended version of the camera device HAL.
*
@@ -29,9 +29,14 @@
* android.hardware.camera2 API in LIMITED or FULL modes.
*
* Camera devices that support this version of the HAL must return
- * CAMERA_DEVICE_API_VERSION_3_2 in camera_device_t.common.version and in
+ * CAMERA_DEVICE_API_VERSION_3_3 in camera_device_t.common.version and in
* camera_info_t.device_version (from camera_module_t.get_camera_info).
*
+ * CAMERA_DEVICE_API_VERSION_3_3:
+ * Camera modules that may contain version 3.3 devices must implement at
+ * least version 2.2 of the camera module interface (as defined by
+ * camera_module_t.common.module_api_version).
+ *
* CAMERA_DEVICE_API_VERSION_3_2:
* Camera modules that may contain version 3.2 devices must implement at
* least version 2.2 of the camera module interface (as defined by
@@ -54,6 +59,7 @@
* S7. Key Performance Indicator (KPI) glossary
* S8. Sample Use Cases
* S9. Notes on Controls and Metadata
+ * S10. Reprocessing flow and controls
*/
/**
@@ -119,6 +125,16 @@
* - change the input buffer return path. The buffer is returned in
* process_capture_result instead of process_capture_request.
*
+ * 3.3: Minor revision of expanded-capability HAL:
+ *
+ * - OPAQUE and YUV reprocessing API updates.
+ *
+ * - Basic support for depth output buffers.
+ *
+ * - Addition of data_space field to camera3_stream_t.
+ *
+ * - Addition of rotation field to camera3_stream_t.
+ *
*/
/**
@@ -1109,6 +1125,56 @@
* as input.
* - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream.
*
+ * S8.2 ZSL (OPAQUE) reprocessing with CAMERA3_STREAM_INPUT stream.
+ *
+ * CAMERA_DEVICE_API_VERSION_3_3:
+ * When OPAQUE_REPROCESSING capability is supported by the camera device, the INPUT stream
+ * can be used for application/framework implemented use case like Zero Shutter Lag (ZSL).
+ * This kind of stream will be used by the framework as follows:
+ *
+ * 1. Application/framework configures an opaque (RAW or YUV based) format output stream that is
+ * used to produce the ZSL output buffers. The stream pixel format will be
+ * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
+ *
+ * 2. Application/framework configures an opaque format input stream that is used to
+ * send the reprocessing ZSL buffers to the HAL. The stream pixel format will
+ * also be HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
+ *
+ * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the
+ * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB.
+ *
+ * 4. Application/framework picks a ZSL buffer from the ZSL output stream when a ZSL capture is
+ * issued by the application, and sends the data back as an input buffer in a
+ * reprocessing request, then sends to the HAL for reprocessing.
+ *
+ * 5. The HAL sends back the output YUV/JPEG result to framework.
+ *
+ * The HAL can select the actual opaque buffer format and configure the ISP pipeline
+ * appropriately based on the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format and
+ * the gralloc usage flag GRALLOC_USAGE_HW_CAMERA_ZSL.
+
+ * S8.3 YUV reprocessing with CAMERA3_STREAM_INPUT stream.
+ *
+ * When YUV reprocessing is supported by the HAL, the INPUT stream
+ * can be used for the YUV reprocessing use cases like lucky-shot and image fusion.
+ * This kind of stream will be used by the framework as follows:
+ *
+ * 1. Application/framework configures an YCbCr_420 format output stream that is
+ * used to produce the output buffers.
+ *
+ * 2. Application/framework configures an YCbCr_420 format input stream that is used to
+ * send the reprocessing YUV buffers to the HAL.
+ *
+ * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the
+ * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB.
+ *
+ * 4. Application/framework processes the output buffers (could be as simple as picking
+ * an output buffer directly) from the output stream when a capture is issued, and sends
+ * the data back as an input buffer in a reprocessing request, then sends to the HAL
+ * for reprocessing.
+ *
+ * 5. The HAL sends back the output YUV/JPEG result to framework.
+ *
*/
/**
@@ -1137,6 +1203,100 @@
* be included in the 'available modes' tag to represent this operating
* mode.
*/
+
+/**
+ * S10. Reprocessing flow and controls
+ *
+ * This section describes the OPAQUE and YUV reprocessing flow and controls. OPAQUE reprocessing
+ * uses an opaque format that is not directly application-visible, and the application can
+ * only select some of the output buffers and send back to HAL for reprocessing, while YUV
+ * reprocessing gives the application opportunity to process the buffers before reprocessing.
+ *
+ * S8 gives the stream configurations for the typical reprocessing uses cases,
+ * this section specifies the buffer flow and controls in more details.
+ *
+ * S10.1 OPAQUE (typically for ZSL use case) reprocessing flow and controls
+ *
+ * For OPAQUE reprocessing (e.g. ZSL) use case, after the application creates the specific
+ * output and input streams, runtime buffer flow and controls are specified as below:
+ *
+ * 1. Application starts output streaming by sending repeating requests for output
+ * opaque buffers and preview. The buffers are held by an application
+ * maintained circular buffer. The requests are based on CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG
+ * capture template, which should have all necessary settings that guarantee output
+ * frame rate is not slowed down relative to sensor output frame rate.
+ *
+ * 2. When a capture is issued, the application selects one output buffer based
+ * on application buffer selection logic, e.g. good AE and AF statistics etc.
+ * Application then creates an reprocess request based on the capture result associated
+ * with this selected buffer. The selected output buffer is now added to this reprocess
+ * request as an input buffer, the output buffer of this reprocess request should be
+ * either JPEG output buffer or YUV output buffer, or both, depending on the application
+ * choice.
+ *
+ * 3. Application then alters the reprocess settings to get best image quality. The HAL must
+ * support and only support below controls if the HAL support OPAQUE_REPROCESSING capability:
+ * - android.jpeg.* (if JPEG buffer is included as one of the output)
+ * - android.noiseReduction.mode (change to HIGH_QUALITY if it is supported)
+ * - android.edge.mode (change to HIGH_QUALITY if it is supported)
+ * All other controls must be ignored by the HAL.
+ * 4. HAL processed the input buffer and return the output buffers in the capture results
+ * as normal.
+ *
+ * S10.2 YUV reprocessing flow and controls
+ *
+ * The YUV reprocessing buffer flow is similar as OPAQUE reprocessing, with below difference:
+ *
+ * 1. Application may want to have finer granularity control of the intermediate YUV images
+ * (before reprocessing). For example, application may choose
+ * - android.noiseReduction.mode == MINIMAL
+ * to make sure the no YUV domain noise reduction has applied to the output YUV buffers,
+ * then it can do its own advanced noise reduction on them. For OPAQUE reprocessing case, this
+ * doesn't matter, as long as the final reprocessed image has the best quality.
+ * 2. Application may modify the YUV output buffer data. For example, for image fusion use
+ * case, where multiple output images are merged together to improve the signal-to-noise
+ * ratio (SNR). The input buffer may be generated from multiple buffers by the application.
+ * To avoid excessive amount of noise reduction and insufficient amount of edge enhancement
+ * being applied to the input buffer, the application can hint the HAL how much effective
+ * exposure time improvement has been done by the application, then the HAL can adjust the
+ * noise reduction and edge enhancement paramters to get best reprocessed image quality.
+ * Below tag can be used for this purpose:
+ * - android.reprocess.effectiveExposureFactor
+ * The value would be exposure time increase factor applied to the original output image,
+ * for example, if there are N image merged, the exposure time increase factor would be up
+ * to sqrt(N). See this tag spec for more details.
+ *
+ * S10.3 Reprocessing pipeline characteristics
+ *
+ * Reprocessing pipeline has below different characteristics comparing with normal output
+ * pipeline:
+ *
+ * 1. The reprocessing result can be returned ahead of the pending normal output results. But
+ * the FIFO ordering must be maintained for all reprocessing results. For example, there are
+ * below requests (A stands for output requests, B stands for reprocessing requests)
+ * being processed by the HAL:
+ * A1, A2, A3, A4, B1, A5, B2, A6...
+ * result of B1 can be returned before A1-A4, but result of B2 must be returned after B1.
+ * 2. Single input rule: For a given reprocessing request, all output buffers must be from the
+ * input buffer, rather than sensor output. For example, if a reprocess request include both
+ * JPEG and preview buffers, all output buffers must be produced from the input buffer
+ * included by the reprocessing request, rather than sensor. The HAL must not output preview
+ * buffers from sensor, while output JPEG buffer from the input buffer.
+ * 3. Input buffer will be from camera output directly (ZSL case) or indirectly(image fusion
+ * case). For the case where buffer is modified, the size will remain same. The HAL can
+ * notify CAMERA3_MSG_ERROR_REQUEST if buffer from unknown source is sent.
+ * 4. Result as reprocessing request: The HAL can expect that a reprocessing request is a copy
+ * of one of the output results with minor allowed setting changes. The HAL can notify
+ * CAMERA3_MSG_ERROR_REQUEST if a request from unknown source is issued.
+ * 5. Output buffers may not be used as inputs across the configure stream boundary, This is
+ * because an opaque stream like the ZSL output stream may have different actual image size
+ * inside of the ZSL buffer to save power and bandwidth for smaller resolution JPEG capture.
+ * The HAL may notify CAMERA3_MSG_ERROR_REQUEST if this case occurs.
+ * 6. HAL Reprocess requests error reporting during flush should follow the same rule specified
+ * by flush() method.
+ *
+ */
+
__BEGIN_DECLS
struct camera3_device;
@@ -1184,6 +1344,9 @@ typedef enum camera3_stream_type {
* quality images (that otherwise would cause a frame rate performance
* loss), or to do off-line reprocessing.
*
+ * CAMERA_DEVICE_API_VERSION_3_3:
+ * The typical use cases are OPAQUE (typically ZSL) and YUV reprocessing,
+ * see S8.2, S8.3 and S10 for more details.
*/
CAMERA3_STREAM_INPUT = 1,
@@ -1209,6 +1372,25 @@ typedef enum camera3_stream_type {
} camera3_stream_type_t;
/**
+ * camera3_stream_rotation_t:
+ *
+ * The required counterclockwise rotation of camera stream.
+ */
+typedef enum camera3_stream_rotation {
+ /* No rotation */
+ CAMERA3_STREAM_ROTATION_0 = 0,
+
+ /* Rotate by 90 degree counterclockwise */
+ CAMERA3_STREAM_ROTATION_90 = 1,
+
+ /* Rotate by 180 degree counterclockwise */
+ CAMERA3_STREAM_ROTATION_180 = 2,
+
+ /* Rotate by 270 degree counterclockwise */
+ CAMERA3_STREAM_ROTATION_270 = 3
+} camera3_stream_rotation_t;
+
+/**
* camera3_stream_t:
*
* A handle to a single camera input or output stream. A stream is defined by
@@ -1326,6 +1508,61 @@ typedef struct camera3_stream {
*/
void *priv;
+ /**
+ * A field that describes the contents of the buffer. The format and buffer
+ * dimensions define the memory layout and structure of the stream buffers,
+ * while dataSpace defines the meaning of the data within the buffer.
+ *
+ * For most formats, dataSpace defines the color space of the image data.
+ * In addition, for some formats, dataSpace indicates whether image- or
+ * depth-based data is requested. See system/core/include/system/graphics.h
+ * for details of formats and valid dataSpace values for each format.
+ *
+ * Version information:
+ *
+ * < CAMERA_DEVICE_API_VERSION_3_3:
+ *
+ * Not defined and should not be accessed. dataSpace should be assumed to
+ * be HAL_DATASPACE_UNKNOWN, and the appropriate color space, etc, should
+ * be determined from the usage flags and the format.
+ *
+ * >= CAMERA_DEVICE_API_VERSION_3_3:
+ *
+ * Always set by the camera service. HAL must use this dataSpace to
+ * configure the stream to the correct colorspace, or to select between
+ * color and depth outputs if supported.
+ */
+ android_dataspace_t data_space;
+
+ /**
+ * The required output rotation of the stream, one of
+ * the camera3_stream_rotation_t values. This must be inspected by HAL along
+ * with stream width and height. For example, if the rotation is 90 degree
+ * and the stream width and height is 720 and 1280 respectively, camera service
+ * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image
+ * and rotate the image by 90 degree counterclockwise. The rotation field is
+ * no-op when the stream type is input. Camera HAL must ignore the rotation
+ * field for an input stream.
+ *
+ * <= CAMERA_DEVICE_API_VERSION_3_2:
+ *
+ * Not defined and must not be accessed. HAL must not apply any rotation
+ * on output images.
+ *
+ * >= CAMERA_DEVICE_API_VERSION_3_3:
+ *
+ * Always set by camera service. HAL must inspect this field during stream
+ * configuration and returns -EINVAL if HAL cannot perform such rotation.
+ * HAL must always support CAMERA3_STREAM_ROTATION_0, so a
+ * configure_streams() call must not fail for unsupported rotation if
+ * rotation field of all streams is CAMERA3_STREAM_ROTATION_0.
+ *
+ */
+ int rotation;
+
+ /* reserved for future use */
+ void *reserved[7];
+
} camera3_stream_t;
/**
@@ -2380,6 +2617,9 @@ typedef struct camera3_device_ops {
*
* - Including too many output streams of a certain format.
*
+ * - Unsupported rotation configuration (only applies to
+ * devices with version >= CAMERA_DEVICE_API_VERSION_3_3)
+ *
* Note that the framework submitting an invalid stream
* configuration is not normal operation, since stream
* configurations are checked before configure. An invalid
diff --git a/include/hardware/camera_common.h b/include/hardware/camera_common.h
index dadbc8f..c2d4536 100644
--- a/include/hardware/camera_common.h
+++ b/include/hardware/camera_common.h
@@ -20,6 +20,7 @@
#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>
@@ -85,6 +86,33 @@ __BEGIN_DECLS
* 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.
*/
/**
@@ -100,8 +128,9 @@ __BEGIN_DECLS
#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_3
+#define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_4
/**
* All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
@@ -113,10 +142,11 @@ __BEGIN_DECLS
#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.2 is current, older HAL camera device versions are not
+// 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_2
+#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_3
/**
* Defined in /system/media/camera/include/system/camera_metadata.h
@@ -125,11 +155,19 @@ typedef struct camera_metadata camera_metadata_t;
typedef struct camera_info {
/**
- * The direction that the camera faces to. It should be CAMERA_FACING_BACK
- * or CAMERA_FACING_FRONT.
+ * 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):
*
- * Version information:
- * Valid in all camera_module versions
+ * 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;
@@ -145,8 +183,16 @@ typedef struct camera_info {
* top side of a front-facing camera sensor is aligned with the right of the
* screen, the value should be 270.
*
- * Version information:
- * Valid in all camera_module versions
+ * 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;
@@ -168,9 +214,9 @@ typedef struct camera_info {
uint32_t device_version;
/**
- * The camera's fixed characteristics, which include all camera metadata in
- * the android.*.info.* sections. This should be a sorted metadata buffer,
- * and may not be modified or freed by the caller. The pointer should remain
+ * 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().
*
@@ -188,6 +234,185 @@ typedef struct camera_info {
*
*/
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;
/**
@@ -211,33 +436,152 @@ typedef struct camera_info {
typedef enum camera_device_status {
/**
* The camera device is not currently connected, and opening it will return
- * failure. Calls to get_camera_info must still succeed, and provide the
- * same information it would if the camera were connected
+ * 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. 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.
+ * 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. Calls to get_camera_info
- * must still succeed, as if the camera was in the PRESENT status.
+ * 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_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_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.
+ *
+ * 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_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_OFF or TORCH_MODE_STATUS_ON callback for the given camera
+ * device. Additionally it must trigger TORCH_MODE_STATUS_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. These are called only by HAL modules
- * implementing version CAMERA_MODULE_API_VERSION_2_1 or higher of the HAL
- * module API interface.
+ * 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 {
@@ -250,6 +594,8 @@ typedef struct camera_module_callbacks {
* 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.
*
@@ -263,6 +609,30 @@ typedef 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 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 {
@@ -304,8 +674,21 @@ typedef struct camera_module {
* simply the number converted to a string. That is, "0" for camera ID 0,
* "1" for camera ID 1.
*
- * The value here must be static, and cannot change after the first call to
- * this method
+ * 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);
@@ -324,6 +707,14 @@ typedef struct camera_module {
*
* -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);
@@ -425,8 +816,60 @@ typedef struct camera_module {
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_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_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);
+
/* reserved for future use */
- void* reserved[7];
+ void* reserved[6];
} camera_module_t;
__END_DECLS
diff --git a/include/hardware/fingerprint.h b/include/hardware/fingerprint.h
index 458ca2d..1d190a6 100644
--- a/include/hardware/fingerprint.h
+++ b/include/hardware/fingerprint.h
@@ -18,6 +18,7 @@
#define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H
#define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
+#define FINGERPRINT_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
#define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint"
typedef enum fingerprint_msg_type {
@@ -25,50 +26,71 @@ typedef enum fingerprint_msg_type {
FINGERPRINT_ACQUIRED = 1,
FINGERPRINT_PROCESSED = 2,
FINGERPRINT_TEMPLATE_ENROLLING = 3,
- FINGERPRINT_TEMPLATE_REMOVED = 4
+ FINGERPRINT_TEMPLATE_REMOVED = 4,
+ FINGERPRINT_AUTHENTICATED = 5
} fingerprint_msg_type_t;
typedef enum fingerprint_error {
FINGERPRINT_ERROR_HW_UNAVAILABLE = 1,
FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2,
FINGERPRINT_ERROR_TIMEOUT = 3,
- FINGERPRINT_ERROR_NO_SPACE = 4 /* No space available to store a template */
+ FINGERPRINT_ERROR_NO_SPACE = 4, /* No space available to store a template */
+ FINGERPRINT_ERROR_CANCELED = 5,
+ FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6, /* fingerprint id can't be removed */
+ FINGERPRINT_ERROR_VENDOR_BASE = 1000 /* vendor-specific error messages start here */
} fingerprint_error_t;
typedef enum fingerprint_acquired_info {
FINGERPRINT_ACQUIRED_GOOD = 0,
FINGERPRINT_ACQUIRED_PARTIAL = 1,
FINGERPRINT_ACQUIRED_INSUFFICIENT = 2,
- FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 4,
- FINGERPRINT_ACQUIRED_TOO_SLOW = 8,
- FINGERPRINT_ACQUIRED_TOO_FAST = 16
+ FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3,
+ FINGERPRINT_ACQUIRED_TOO_SLOW = 4,
+ FINGERPRINT_ACQUIRED_TOO_FAST = 5,
+ FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000 /* vendor-specific acquisition messages start here */
} fingerprint_acquired_info_t;
+typedef struct fingerprint_finger_id {
+ uint32_t gid;
+ uint32_t fid;
+} fingerprint_finger_id_t;
+
+/* The progress indication may be augmented by a bitmap encoded indication
+* of what finger area is considered as collected.
+* Bit numbers mapped to physical location:
+*
+* distal
+* +--+--+--+--+--+
+* | 4| 3| 2| 1| 0|
+* | 9| 8| 7| 6| 5|
+* medial |14|13|12|11|10| lateral
+* |19|18|17|16|15|
+* |24|23|22|21|20|
+* +--+--+--+--+--+
+* proximal
+*
+*/
+typedef uint32_t finger_map_bmp;
+
+typedef enum fingerprint_enroll_msg_type {
+ FINGERPRINT_ENROLL_MSG_NONE = 0,
+ FINGERPRINT_ENROLL_MSG_PREDEFINED = 1, /* TODO: define standard enroll cues */
+ FINGERPRINT_ENROLL_MSG_BITMAP = 2, /* typeof(fingerprint_enroll.msg) == *finger_map_bmp */
+ FINGERPRINT_ENROLL_MSG_VENDOR = 3
+} fingerprint_enroll_msg_type_t;
+
typedef struct fingerprint_enroll {
- uint32_t id;
+ fingerprint_finger_id_t finger;
/* samples_remaining goes from N (no data collected, but N scans needed)
- * to 0 (no more data is needed to build a template).
- * The progress indication may be augmented by a bitmap encoded indication
- * of finger area that needs to be presented by the user.
- * Bit numbers mapped to physical location:
- *
- * distal
- * +-+-+-+
- * |2|1|0|
- * |5|4|3|
- * medial |8|7|6| lateral
- * |b|a|9|
- * |e|d|c|
- * +-+-+-+
- * proximal
- *
- */
- uint16_t data_collected_bmp;
- uint16_t samples_remaining;
+ * to 0 (no more data is needed to build a template). */
+ uint32_t samples_remaining;
+ fingerprint_enroll_msg_type_t msg_type;
+ size_t msg_size;
+ void *msg;
} fingerprint_enroll_t;
typedef struct fingerprint_removed {
- uint32_t id;
+ fingerprint_finger_id_t finger;
} fingerprint_removed_t;
typedef struct fingerprint_acquired {
@@ -76,18 +98,29 @@ typedef struct fingerprint_acquired {
} fingerprint_acquired_t;
typedef struct fingerprint_processed {
- uint32_t id; /* 0 is a special id and means no match */
+ fingerprint_finger_id_t finger; /* all 0s is a special case and means no match */
} fingerprint_processed_t;
+typedef struct fingerprint_authenticated {
+ uint32_t user_id;
+ uint32_t auth_id;
+ uint32_t timestamp;
+ uint32_t app_id;
+ uint64_t crypto_op_id;
+ uint8_t hmac[16]; /* 128-bit */
+ uint32_t auth_token_size;
+ uint8_t *auth_token;
+} fingerprint_authenticated_t;
+
typedef struct fingerprint_msg {
fingerprint_msg_type_t type;
union {
- uint64_t raw;
fingerprint_error_t error;
fingerprint_enroll_t enroll;
fingerprint_removed_t removed;
fingerprint_acquired_t acquired;
fingerprint_processed_t processed;
+ fingerprint_authenticated_t authenticated;
} data;
} fingerprint_msg_t;
@@ -111,29 +144,43 @@ typedef struct fingerprint_device {
* (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING &&
* fingerprint_msg.data.enroll.samples_remaining == 0)
* or after timeout_sec seconds.
+ * The fingerprint template will be assigned to the group gid. User has a choice
+ * to supply the gid or set it to 0 in which case a unique group id will be generated.
*
* Function return: 0 if enrollment process can be successfully started
* -1 otherwise. A notify() function may be called
* indicating the error condition.
*/
- int (*enroll)(struct fingerprint_device *dev, uint32_t timeout_sec);
+ int (*enroll)(struct fingerprint_device *dev, uint32_t gid, uint32_t timeout_sec);
/*
- * Cancel fingerprint enroll request:
- * Switches the HAL state machine back to accept a fingerprint scan mode.
- * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING &&
- * fingerprint_msg.data.enroll.samples_remaining == 0)
+ * Fingerprint pre-enroll enroll request:
+ * Generates a unique token to upper layers to indicate the start of an enrollment transaction.
+ * This token will be wrapped by security for verification and passed to enroll() for
+ * verification before enrollment will be allowed. This is to ensure adding a new fingerprint
+ * template was preceded by some kind of credential confirmation (e.g. device password).
+ *
+ * Function return: 0 if function failed
+ * otherwise, a uint64_t of token
+ */
+ uint64_t (*pre_enroll)(struct fingerprint_device *dev);
+
+ /*
+ * Cancel pending enroll or authenticate, sending FINGERPRINT_ERROR_CANCELED
+ * to all running clients. Switches the HAL state machine back to the idle state.
* will indicate switch back to the scan mode.
*
* Function return: 0 if cancel request is accepted
* -1 otherwise.
*/
- int (*enroll_cancel)(struct fingerprint_device *dev);
+ int (*cancel)(struct fingerprint_device *dev);
/*
* Fingerprint remove request:
* deletes a fingerprint template.
- * If the fingerprint id is 0 the entire template database will be removed.
+ * If the fingerprint id is 0 and the group is 0 then the entire template
+ * database will be removed. A combinaiton of fingerprint id 0 and a valid
+ * group id deletes all fingreprints in that group.
* notify() will be called for each template deleted with
* fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and
* fingerprint_msg.data.removed.id indicating each template id removed.
@@ -141,7 +188,24 @@ typedef struct fingerprint_device {
* Function return: 0 if fingerprint template(s) can be successfully deleted
* -1 otherwise.
*/
- int (*remove)(struct fingerprint_device *dev, uint32_t fingerprint_id);
+ int (*remove)(struct fingerprint_device *dev, fingerprint_finger_id_t finger);
+
+ /*
+ * Restricts the HAL operation to a set of fingerprints belonging to a
+ * group provided. Gid of 0 signals global operation.
+ *
+ * Function return: 0 on success
+ * -1 if the group does not exist.
+ */
+ int (*set_active_group)(struct fingerprint_device *dev, uint32_t gid);
+
+ /*
+ * Authenticates an operation identifed by operation_id
+ *
+ * Function return: 0 on success
+ * -1 if the operation cannot be completed
+ */
+ int (*authenticate)(struct fingerprint_device *dev, uint64_t operation_id, uint32_t gid);
/*
* Set notification callback:
@@ -152,8 +216,7 @@ typedef struct fingerprint_device {
* Function return: 0 if callback function is successfuly registered
* -1 otherwise.
*/
- int (*set_notify)(struct fingerprint_device *dev,
- fingerprint_notify_t notify);
+ int (*set_notify)(struct fingerprint_device *dev, fingerprint_notify_t notify);
/*
* Client provided callback function to receive notifications.
diff --git a/include/hardware/fused_location.h b/include/hardware/fused_location.h
index 5c7821c..ff64aef 100644
--- a/include/hardware/fused_location.h
+++ b/include/hardware/fused_location.h
@@ -228,6 +228,23 @@ typedef struct {
* seconds.
*/
int64_t period_ns;
+
+ /**
+ * The smallest displacement between reported locations in meters.
+ *
+ * If set to 0, then you should report locations at the requested
+ * interval even if the device is stationary. If positive, you
+ * can use this parameter as a hint to save power (e.g. throttling
+ * location period if the user hasn't traveled close to the displacement
+ * threshold). Even small positive values can be interpreted to mean
+ * that you don't have to compute location when the device is stationary.
+ *
+ * There is no need to filter location delivery based on this parameter.
+ * Locations can be delivered even if they have a displacement smaller than
+ * requested. This parameter can safely be ignored at the cost of potential
+ * power savings.
+ */
+ float smallest_displacement_meters;
} FlpBatchOptions;
#define FLP_RESULT_SUCCESS 0
diff --git a/include/hardware/gatekeeper.h b/include/hardware/gatekeeper.h
new file mode 100644
index 0000000..89d96b1
--- /dev/null
+++ b/include/hardware/gatekeeper.h
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2015 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_HARDWARE_GATEKEEPER_H
+#define ANDROID_HARDWARE_GATEKEEPER_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <hardware/hardware.h>
+
+__BEGIN_DECLS
+
+#define GATEKEEPER_HARDWARE_MODULE_ID "gatekeeper"
+
+#define GATEKEEPER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
+
+#define HARDWARE_GATEKEEPER "gatekeeper"
+
+struct gatekeeper_module {
+ /**
+ * Comon methods of the gatekeeper module. This *must* be the first member of
+ * gatekeeper_module as users of this structure will cast a hw_module_t to
+ * a gatekeeper_module pointer in the appropriate context.
+ */
+ hw_module_t common;
+};
+
+struct gatekeeper_device {
+ /**
+ * Common methods of the gatekeeper device. As above, this must be the first
+ * member of keymaster_device.
+ */
+ hw_device_t common;
+
+ /**
+ * Enrolls desired_password, which should be derived from a user selected pin or password,
+ * with the authentication factor private key used only for enrolling authentication
+ * factor data.
+ *
+ * If there was already a password enrolled, it should be provided in
+ * current_password_handle, along with the current password in current_password
+ * that should validate against current_password_handle.
+ *
+ * Parameters:
+ * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open
+ * - uid: the Android user identifier
+ *
+ * - current_password_handle: the currently enrolled password handle the user
+ * wants to replace. May be null if there's no currently enrolled password.
+ * - current_password_handle_length: the length in bytes of the buffer pointed
+ * at by current_password_handle. Must be 0 if current_password_handle is NULL.
+ *
+ * - current_password: the user's current password in plain text. If presented,
+ * it MUST verify against current_password_handle.
+ * - current_password_length: the size in bytes of the buffer pointed at by
+ * current_password. Must be 0 if the current_password is NULL.
+ *
+ * - desired_password: the new password the user wishes to enroll in plain-text.
+ * Cannot be NULL.
+ * - desired_password_length: the length in bytes of the buffer pointed at by
+ * desired_password.
+ *
+ * - enrolled_password_handle: on success, a buffer will be allocated with the
+ * new password handle referencing the password provided in desired_password.
+ * This buffer can be used on subsequent calls to enroll or verify.
+ * The caller is responsible for deallocating this buffer via a call to free()
+ * - enrolled_password_handle_length: pointer to the length in bytes of the buffer allocated
+ * by this function and pointed to by *enrolled_password_handle_length.
+ *
+ * Returns: 0 on success or an error code less than 0 on error.
+ * On error, enrolled_password_handle will not be allocated.
+ */
+ int (*enroll)(const struct gatekeeper_device *dev, uint32_t uid,
+ const uint8_t *current_password_handle, uint32_t current_password_handle_length,
+ const uint8_t *current_password, uint32_t current_password_length,
+ const uint8_t *desired_password, uint32_t desired_password_length,
+ uint8_t **enrolled_password_handle, uint32_t *enrolled_password_handle_length);
+
+ /**
+ * Verifies provided_password matches enrolled_password_handle.
+ *
+ * Implementations of this module may retain the result of this call
+ * to attest to the recency of authentication.
+ *
+ * On success, writes the address of a verification token to auth_token,
+ * usable to attest password verification to other trusted services. Clients
+ * may pass NULL for this value.
+ *
+ * Parameters:
+ * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open
+ * - uid: the Android user identifier
+ *
+ * - challenge: An optional challenge to authenticate against, or 0. Used when a separate
+ * authenticator requests password verification, or for transactional
+ * password authentication.
+ *
+ * - enrolled_password_handle: the currently enrolled password handle that the
+ * user wishes to verify against.
+ * - enrolled_password_handle_length: the length in bytes of the buffer pointed
+ * to by enrolled_password_handle
+ *
+ * - provided_password: the plaintext password to be verified against the
+ * enrolled_password_handle
+ * - provided_password_length: the length in bytes of the buffer pointed to by
+ * provided_password
+ *
+ * - auth_token: on success, a buffer containing the authentication token
+ * resulting from this verification is assigned to *auth_token. The caller
+ * is responsible for deallocating this memory via a call to free()
+ * - auth_token_length: on success, the length in bytes of the authentication
+ * token assigned to *auth_token will be assigned to *auth_token_length
+ *
+ * Returns: 0 on success or an error code less than 0 on error
+ * On error, auth token will not be allocated
+ */
+ int (*verify)(const struct gatekeeper_device *dev, uint32_t uid, uint64_t challenge,
+ const uint8_t *enrolled_password_handle, uint32_t enrolled_password_handle_length,
+ const uint8_t *provided_password, uint32_t provided_password_length,
+ uint8_t **auth_token, uint32_t *auth_token_length);
+
+};
+typedef struct gatekeeper_device gatekeeper_device_t;
+
+static inline int gatekeeper_open(const struct hw_module_t *module,
+ gatekeeper_device_t **device) {
+ return module->methods->open(module, HARDWARE_GATEKEEPER,
+ (struct hw_device_t **) device);
+}
+
+static inline int gatekeeper_close(gatekeeper_device_t *device) {
+ return device->common.close(&device->common);
+}
+
+__END_DECLS
+
+#endif // ANDROID_HARDWARE_GATEKEEPER_H
diff --git a/include/hardware/hw_auth_token.h b/include/hardware/hw_auth_token.h
index 40283cb..f471d1a 100644
--- a/include/hardware/hw_auth_token.h
+++ b/include/hardware/hw_auth_token.h
@@ -19,7 +19,7 @@
#ifndef ANDROID_HARDWARE_HW_AUTH_TOKEN_H
#define ANDROID_HARDWARE_HW_AUTH_TOKEN_H
-#ifndef __cplusplus
+#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
@@ -46,7 +46,7 @@ typedef struct __attribute__((__packed__)) {
uint8_t hmac[32];
} hw_auth_token_t;
-#ifndef __cplusplus
+#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
diff --git a/include/hardware/input.h b/include/hardware/input.h
new file mode 100644
index 0000000..5aa3e51
--- /dev/null
+++ b/include/hardware/input.h
@@ -0,0 +1,507 @@
+/*
+ * Copyright (C) 2015 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_INPUT_H
+#define ANDROID_INCLUDE_HARDWARE_INPUT_H
+
+#include <hardware/hardware.h>
+#include <stdint.h>
+
+__BEGIN_DECLS
+
+#define INPUT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
+#define INPUT_HARDWARE_MODULE_ID "input"
+
+#define INPUT_INSTANCE_EVDEV "evdev"
+
+typedef enum input_bus {
+ INPUT_BUS_BT,
+ INPUT_BUS_USB,
+ INPUT_BUS_SERIAL,
+ INPUT_BUS_BUILTIN
+} input_bus_t;
+
+typedef struct input_host input_host_t;
+
+typedef struct input_device_handle input_device_handle_t;
+
+typedef struct input_device_identifier input_device_identifier_t;
+
+typedef struct input_device_definition input_device_definition_t;
+
+typedef struct input_report_definition input_report_definition_t;
+
+typedef struct input_report input_report_t;
+
+typedef struct input_collection input_collection_t;
+
+typedef enum {
+ // keycodes
+ INPUT_USAGE_KEYCODE_UNKNOWN,
+ INPUT_USAGE_KEYCODE_SOFT_LEFT,
+ INPUT_USAGE_KEYCODE_SOFT_RIGHT,
+ INPUT_USAGE_KEYCODE_HOME,
+ INPUT_USAGE_KEYCODE_BACK,
+ INPUT_USAGE_KEYCODE_CALL,
+ INPUT_USAGE_KEYCODE_ENDCALL,
+ INPUT_USAGE_KEYCODE_0,
+ INPUT_USAGE_KEYCODE_1,
+ INPUT_USAGE_KEYCODE_2,
+ INPUT_USAGE_KEYCODE_3,
+ INPUT_USAGE_KEYCODE_4,
+ INPUT_USAGE_KEYCODE_5,
+ INPUT_USAGE_KEYCODE_6,
+ INPUT_USAGE_KEYCODE_7,
+ INPUT_USAGE_KEYCODE_8,
+ INPUT_USAGE_KEYCODE_9,
+ INPUT_USAGE_KEYCODE_STAR,
+ INPUT_USAGE_KEYCODE_POUND,
+ INPUT_USAGE_KEYCODE_DPAD_UP,
+ INPUT_USAGE_KEYCODE_DPAD_DOWN,
+ INPUT_USAGE_KEYCODE_DPAD_LEFT,
+ INPUT_USAGE_KEYCODE_DPAD_RIGHT,
+ INPUT_USAGE_KEYCODE_DPAD_CENTER,
+ INPUT_USAGE_KEYCODE_VOLUME_UP,
+ INPUT_USAGE_KEYCODE_VOLUME_DOWN,
+ INPUT_USAGE_KEYCODE_POWER,
+ INPUT_USAGE_KEYCODE_CAMERA,
+ INPUT_USAGE_KEYCODE_CLEAR,
+ INPUT_USAGE_KEYCODE_A,
+ INPUT_USAGE_KEYCODE_B,
+ INPUT_USAGE_KEYCODE_C,
+ INPUT_USAGE_KEYCODE_D,
+ INPUT_USAGE_KEYCODE_E,
+ INPUT_USAGE_KEYCODE_F,
+ INPUT_USAGE_KEYCODE_G,
+ INPUT_USAGE_KEYCODE_H,
+ INPUT_USAGE_KEYCODE_I,
+ INPUT_USAGE_KEYCODE_J,
+ INPUT_USAGE_KEYCODE_K,
+ INPUT_USAGE_KEYCODE_L,
+ INPUT_USAGE_KEYCODE_M,
+ INPUT_USAGE_KEYCODE_N,
+ INPUT_USAGE_KEYCODE_O,
+ INPUT_USAGE_KEYCODE_P,
+ INPUT_USAGE_KEYCODE_Q,
+ INPUT_USAGE_KEYCODE_R,
+ INPUT_USAGE_KEYCODE_S,
+ INPUT_USAGE_KEYCODE_T,
+ INPUT_USAGE_KEYCODE_U,
+ INPUT_USAGE_KEYCODE_V,
+ INPUT_USAGE_KEYCODE_W,
+ INPUT_USAGE_KEYCODE_X,
+ INPUT_USAGE_KEYCODE_Y,
+ INPUT_USAGE_KEYCODE_Z,
+ INPUT_USAGE_KEYCODE_COMMA,
+ INPUT_USAGE_KEYCODE_PERIOD,
+ INPUT_USAGE_KEYCODE_ALT_LEFT,
+ INPUT_USAGE_KEYCODE_ALT_RIGHT,
+ INPUT_USAGE_KEYCODE_SHIFT_LEFT,
+ INPUT_USAGE_KEYCODE_SHIFT_RIGHT,
+ INPUT_USAGE_KEYCODE_TAB,
+ INPUT_USAGE_KEYCODE_SPACE,
+ INPUT_USAGE_KEYCODE_SYM,
+ INPUT_USAGE_KEYCODE_EXPLORER,
+ INPUT_USAGE_KEYCODE_ENVELOPE,
+ INPUT_USAGE_KEYCODE_ENTER,
+ INPUT_USAGE_KEYCODE_DEL,
+ INPUT_USAGE_KEYCODE_GRAVE,
+ INPUT_USAGE_KEYCODE_MINUS,
+ INPUT_USAGE_KEYCODE_EQUALS,
+ INPUT_USAGE_KEYCODE_LEFT_BRACKET,
+ INPUT_USAGE_KEYCODE_RIGHT_BRACKET,
+ INPUT_USAGE_KEYCODE_BACKSLASH,
+ INPUT_USAGE_KEYCODE_SEMICOLON,
+ INPUT_USAGE_KEYCODE_APOSTROPHE,
+ INPUT_USAGE_KEYCODE_SLASH,
+ INPUT_USAGE_KEYCODE_AT,
+ INPUT_USAGE_KEYCODE_NUM,
+ INPUT_USAGE_KEYCODE_HEADSETHOOK,
+ INPUT_USAGE_KEYCODE_FOCUS, // *Camera* focus
+ INPUT_USAGE_KEYCODE_PLUS,
+ INPUT_USAGE_KEYCODE_MENU,
+ INPUT_USAGE_KEYCODE_NOTIFICATION,
+ INPUT_USAGE_KEYCODE_SEARCH,
+ INPUT_USAGE_KEYCODE_MEDIA_PLAY_PAUSE,
+ INPUT_USAGE_KEYCODE_MEDIA_STOP,
+ INPUT_USAGE_KEYCODE_MEDIA_NEXT,
+ INPUT_USAGE_KEYCODE_MEDIA_PREVIOUS,
+ INPUT_USAGE_KEYCODE_MEDIA_REWIND,
+ INPUT_USAGE_KEYCODE_MEDIA_FAST_FORWARD,
+ INPUT_USAGE_KEYCODE_MUTE,
+ INPUT_USAGE_KEYCODE_PAGE_UP,
+ INPUT_USAGE_KEYCODE_PAGE_DOWN,
+ INPUT_USAGE_KEYCODE_PICTSYMBOLS,
+ INPUT_USAGE_KEYCODE_SWITCH_CHARSET,
+ INPUT_USAGE_KEYCODE_BUTTON_A,
+ INPUT_USAGE_KEYCODE_BUTTON_B,
+ INPUT_USAGE_KEYCODE_BUTTON_C,
+ INPUT_USAGE_KEYCODE_BUTTON_X,
+ INPUT_USAGE_KEYCODE_BUTTON_Y,
+ INPUT_USAGE_KEYCODE_BUTTON_Z,
+ INPUT_USAGE_KEYCODE_BUTTON_L1,
+ INPUT_USAGE_KEYCODE_BUTTON_R1,
+ INPUT_USAGE_KEYCODE_BUTTON_L2,
+ INPUT_USAGE_KEYCODE_BUTTON_R2,
+ INPUT_USAGE_KEYCODE_BUTTON_THUMBL,
+ INPUT_USAGE_KEYCODE_BUTTON_THUMBR,
+ INPUT_USAGE_KEYCODE_BUTTON_START,
+ INPUT_USAGE_KEYCODE_BUTTON_SELECT,
+ INPUT_USAGE_KEYCODE_BUTTON_MODE,
+ INPUT_USAGE_KEYCODE_ESCAPE,
+ INPUT_USAGE_KEYCODE_FORWARD_DEL,
+ INPUT_USAGE_KEYCODE_CTRL_LEFT,
+ INPUT_USAGE_KEYCODE_CTRL_RIGHT,
+ INPUT_USAGE_KEYCODE_CAPS_LOCK,
+ INPUT_USAGE_KEYCODE_SCROLL_LOCK,
+ INPUT_USAGE_KEYCODE_META_LEFT,
+ INPUT_USAGE_KEYCODE_META_RIGHT,
+ INPUT_USAGE_KEYCODE_FUNCTION,
+ INPUT_USAGE_KEYCODE_SYSRQ,
+ INPUT_USAGE_KEYCODE_BREAK,
+ INPUT_USAGE_KEYCODE_MOVE_HOME,
+ INPUT_USAGE_KEYCODE_MOVE_END,
+ INPUT_USAGE_KEYCODE_INSERT,
+ INPUT_USAGE_KEYCODE_FORWARD,
+ INPUT_USAGE_KEYCODE_MEDIA_PLAY,
+ INPUT_USAGE_KEYCODE_MEDIA_PAUSE,
+ INPUT_USAGE_KEYCODE_MEDIA_CLOSE,
+ INPUT_USAGE_KEYCODE_MEDIA_EJECT,
+ INPUT_USAGE_KEYCODE_MEDIA_RECORD,
+ INPUT_USAGE_KEYCODE_F1,
+ INPUT_USAGE_KEYCODE_F2,
+ INPUT_USAGE_KEYCODE_F3,
+ INPUT_USAGE_KEYCODE_F4,
+ INPUT_USAGE_KEYCODE_F5,
+ INPUT_USAGE_KEYCODE_F6,
+ INPUT_USAGE_KEYCODE_F7,
+ INPUT_USAGE_KEYCODE_F8,
+ INPUT_USAGE_KEYCODE_F9,
+ INPUT_USAGE_KEYCODE_F10,
+ INPUT_USAGE_KEYCODE_F11,
+ INPUT_USAGE_KEYCODE_F12,
+ INPUT_USAGE_KEYCODE_NUM_LOCK,
+ INPUT_USAGE_KEYCODE_NUMPAD_0,
+ INPUT_USAGE_KEYCODE_NUMPAD_1,
+ INPUT_USAGE_KEYCODE_NUMPAD_2,
+ INPUT_USAGE_KEYCODE_NUMPAD_3,
+ INPUT_USAGE_KEYCODE_NUMPAD_4,
+ INPUT_USAGE_KEYCODE_NUMPAD_5,
+ INPUT_USAGE_KEYCODE_NUMPAD_6,
+ INPUT_USAGE_KEYCODE_NUMPAD_7,
+ INPUT_USAGE_KEYCODE_NUMPAD_8,
+ INPUT_USAGE_KEYCODE_NUMPAD_9,
+ INPUT_USAGE_KEYCODE_NUMPAD_DIVIDE,
+ INPUT_USAGE_KEYCODE_NUMPAD_MULTIPLY,
+ INPUT_USAGE_KEYCODE_NUMPAD_SUBTRACT,
+ INPUT_USAGE_KEYCODE_NUMPAD_ADD,
+ INPUT_USAGE_KEYCODE_NUMPAD_DOT,
+ INPUT_USAGE_KEYCODE_NUMPAD_COMMA,
+ INPUT_USAGE_KEYCODE_NUMPAD_ENTER,
+ INPUT_USAGE_KEYCODE_NUMPAD_EQUALS,
+ INPUT_USAGE_KEYCODE_NUMPAD_LEFT_PAREN,
+ INPUT_USAGE_KEYCODE_NUMPAD_RIGHT_PAREN,
+ INPUT_USAGE_KEYCODE_VOLUME_MUTE,
+ INPUT_USAGE_KEYCODE_INFO,
+ INPUT_USAGE_KEYCODE_CHANNEL_UP,
+ INPUT_USAGE_KEYCODE_CHANNEL_DOWN,
+ INPUT_USAGE_KEYCODE_ZOOM_IN,
+ INPUT_USAGE_KEYCODE_ZOOM_OUT,
+ INPUT_USAGE_KEYCODE_TV,
+ INPUT_USAGE_KEYCODE_WINDOW,
+ INPUT_USAGE_KEYCODE_GUIDE,
+ INPUT_USAGE_KEYCODE_DVR,
+ INPUT_USAGE_KEYCODE_BOOKMARK,
+ INPUT_USAGE_KEYCODE_CAPTIONS,
+ INPUT_USAGE_KEYCODE_SETTINGS,
+ INPUT_USAGE_KEYCODE_TV_POWER,
+ INPUT_USAGE_KEYCODE_TV_INPUT,
+ INPUT_USAGE_KEYCODE_STB_POWER,
+ INPUT_USAGE_KEYCODE_STB_INPUT,
+ INPUT_USAGE_KEYCODE_AVR_POWER,
+ INPUT_USAGE_KEYCODE_AVR_INPUT,
+ INPUT_USAGE_KEYCODE_PROG_RED,
+ INPUT_USAGE_KEYCODE_PROG_GREEN,
+ INPUT_USAGE_KEYCODE_PROG_YELLOW,
+ INPUT_USAGE_KEYCODE_PROG_BLUE,
+ INPUT_USAGE_KEYCODE_APP_SWITCH,
+ INPUT_USAGE_KEYCODE_BUTTON_1,
+ INPUT_USAGE_KEYCODE_BUTTON_2,
+ INPUT_USAGE_KEYCODE_BUTTON_3,
+ INPUT_USAGE_KEYCODE_BUTTON_4,
+ INPUT_USAGE_KEYCODE_BUTTON_5,
+ INPUT_USAGE_KEYCODE_BUTTON_6,
+ INPUT_USAGE_KEYCODE_BUTTON_7,
+ INPUT_USAGE_KEYCODE_BUTTON_8,
+ INPUT_USAGE_KEYCODE_BUTTON_9,
+ INPUT_USAGE_KEYCODE_BUTTON_10,
+ INPUT_USAGE_KEYCODE_BUTTON_11,
+ INPUT_USAGE_KEYCODE_BUTTON_12,
+ INPUT_USAGE_KEYCODE_BUTTON_13,
+ INPUT_USAGE_KEYCODE_BUTTON_14,
+ INPUT_USAGE_KEYCODE_BUTTON_15,
+ INPUT_USAGE_KEYCODE_BUTTON_16,
+ INPUT_USAGE_KEYCODE_LANGUAGE_SWITCH,
+ INPUT_USAGE_KEYCODE_MANNER_MODE,
+ INPUT_USAGE_KEYCODE_3D_MODE,
+ INPUT_USAGE_KEYCODE_CONTACTS,
+ INPUT_USAGE_KEYCODE_CALENDAR,
+ INPUT_USAGE_KEYCODE_MUSIC,
+ INPUT_USAGE_KEYCODE_CALCULATOR,
+ INPUT_USAGE_KEYCODE_ZENKAKU_HANKAKU,
+ INPUT_USAGE_KEYCODE_EISU,
+ INPUT_USAGE_KEYCODE_MUHENKAN,
+ INPUT_USAGE_KEYCODE_HENKAN,
+ INPUT_USAGE_KEYCODE_KATAKANA_HIRAGANA,
+ INPUT_USAGE_KEYCODE_YEN,
+ INPUT_USAGE_KEYCODE_RO,
+ INPUT_USAGE_KEYCODE_KANA,
+ INPUT_USAGE_KEYCODE_ASSIST,
+ INPUT_USAGE_KEYCODE_BRIGHTNESS_DOWN,
+ INPUT_USAGE_KEYCODE_BRIGHTNESS_UP,
+ INPUT_USAGE_KEYCODE_MEDIA_AUDIO_TRACK,
+ INPUT_USAGE_KEYCODE_SLEEP,
+ INPUT_USAGE_KEYCODE_WAKEUP,
+ INPUT_USAGE_KEYCODE_PAIRING,
+ INPUT_USAGE_KEYCODE_MEDIA_TOP_MENU,
+ INPUT_USAGE_KEYCODE_11,
+ INPUT_USAGE_KEYCODE_12,
+ INPUT_USAGE_KEYCODE_LAST_CHANNEL,
+ INPUT_USAGE_KEYCODE_TV_DATA_SERVICE,
+ INPUT_USAGE_KEYCODE_VOICE_ASSIST,
+ INPUT_USAGE_KEYCODE_TV_RADIO_SERVICE,
+ INPUT_USAGE_KEYCODE_TV_TELETEXT,
+ INPUT_USAGE_KEYCODE_TV_NUMBER_ENTRY,
+ INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_ANALOG,
+ INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_DIGITAL,
+ INPUT_USAGE_KEYCODE_TV_SATELLITE,
+ INPUT_USAGE_KEYCODE_TV_SATELLITE_BS,
+ INPUT_USAGE_KEYCODE_TV_SATELLITE_CS,
+ INPUT_USAGE_KEYCODE_TV_SATELLITE_SERVICE,
+ INPUT_USAGE_KEYCODE_TV_NETWORK,
+ INPUT_USAGE_KEYCODE_TV_ANTENNA_CABLE,
+ INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_1,
+ INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_2,
+ INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_3,
+ INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_4,
+ INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_1,
+ INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_2,
+ INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_1,
+ INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_2,
+ INPUT_USAGE_KEYCODE_TV_INPUT_VGA_1,
+ INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION,
+ INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP,
+ INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN,
+ INPUT_USAGE_KEYCODE_TV_ZOOM_MODE,
+ INPUT_USAGE_KEYCODE_TV_CONTENTS_MENU,
+ INPUT_USAGE_KEYCODE_TV_MEDIA_CONTEXT_MENU,
+ INPUT_USAGE_KEYCODE_TV_TIMER_PROGRAMMING,
+ INPUT_USAGE_KEYCODE_HELP,
+
+ // axes
+ INPUT_USAGE_AXIS_X,
+ INPUT_USAGE_AXIS_Y,
+ INPUT_USAGE_AXIS_PRESSURE,
+ INPUT_USAGE_AXIS_SIZE,
+ INPUT_USAGE_AXIS_TOUCH_MAJOR,
+ INPUT_USAGE_AXIS_TOUCH_MINOR,
+ INPUT_USAGE_AXIS_TOOL_MAJOR,
+ INPUT_USAGE_AXIS_TOOL_MINOR,
+ INPUT_USAGE_AXIS_ORIENTATION,
+ INPUT_USAGE_AXIS_VSCROLL,
+ INPUT_USAGE_AXIS_HSCROLL,
+ INPUT_USAGE_AXIS_Z,
+ INPUT_USAGE_AXIS_RX,
+ INPUT_USAGE_AXIS_RY,
+ INPUT_USAGE_AXIS_RZ,
+ INPUT_USAGE_AXIS_HAT_X,
+ INPUT_USAGE_AXIS_HAT_Y,
+ INPUT_USAGE_AXIS_LTRIGGER,
+ INPUT_USAGE_AXIS_RTRIGGER,
+ INPUT_USAGE_AXIS_THROTTLE,
+ INPUT_USAGE_AXIS_RUDDER,
+ INPUT_USAGE_AXIS_WHEEL,
+ INPUT_USAGE_AXIS_GAS,
+ INPUT_USAGE_AXIS_BRAKE,
+ INPUT_USAGE_AXIS_DISTANCE,
+ INPUT_USAGE_AXIS_TILT,
+ INPUT_USAGE_AXIS_GENERIC_1,
+ INPUT_USAGE_AXIS_GENERIC_2,
+ INPUT_USAGE_AXIS_GENERIC_3,
+ INPUT_USAGE_AXIS_GENERIC_4,
+ INPUT_USAGE_AXIS_GENERIC_5,
+ INPUT_USAGE_AXIS_GENERIC_6,
+ INPUT_USAGE_AXIS_GENERIC_7,
+ INPUT_USAGE_AXIS_GENERIC_8,
+ INPUT_USAGE_AXIS_GENERIC_9,
+ INPUT_USAGE_AXIS_GENERIC_10,
+ INPUT_USAGE_AXIS_GENERIC_11,
+ INPUT_USAGE_AXIS_GENERIC_12,
+ INPUT_USAGE_AXIS_GENERIC_13,
+ INPUT_USAGE_AXIS_GENERIC_14,
+ INPUT_USAGE_AXIS_GENERIC_15,
+ INPUT_USAGE_AXIS_GENERIC_16,
+
+ // leds
+ INPUT_USAGE_LED_NUM_LOCK,
+ INPUT_USAGE_LED_CAPS_LOCK,
+ INPUT_USAGE_LED_SCROLL_LOCK,
+ INPUT_USAGE_LED_COMPOSE,
+ INPUT_USAGE_LED_KANA,
+ INPUT_USAGE_LED_SLEEP,
+ INPUT_USAGE_LED_SUSPEND,
+ INPUT_USAGE_LED_MUTE,
+ INPUT_USAGE_LED_MISC,
+ INPUT_USAGE_LED_MAIL,
+ INPUT_USAGE_LED_CHARGING,
+ INPUT_USAGE_LED_CONTROLLER_1,
+ INPUT_USAGE_LED_CONTROLLER_2,
+ INPUT_USAGE_LED_CONTROLLER_3,
+ INPUT_USAGE_LED_CONTROLLER_4,
+} input_usage_t;
+
+typedef enum {
+ INPUT_COLLECTION_ID_TOUCH,
+ INPUT_COLLECTION_ID_KEYBOARD,
+ INPUT_COLLECTION_ID_MOUSE,
+ INPUT_COLLECTION_ID_TOUCHPAD,
+ // etc
+} input_collection_id_t;
+
+typedef struct input_message input_message_t;
+
+typedef struct input_host_callbacks {
+
+ /**
+ * Creates a device identifier with the given properties.
+ * The unique ID should be a string that precisely identifies a given piece of hardware. For
+ * example, an input device connected via Bluetooth could use its MAC address as its unique ID.
+ */
+ input_device_identifier_t* (*create_device_identifier)(input_host_t* host,
+ const char* name, int32_t product_id, int32_t vendor_id,
+ input_bus_t bus, const char* unique_id);
+
+ /**
+ * Allocates the device definition which will describe the input capabilities of a device. A
+ * device definition may be used to register as many devices as desired.
+ */
+ input_device_definition_t* (*create_device_definition)(input_host_t* host);
+
+ /**
+ * Allocate either an input report, which the HAL will use to tell the host of incoming input
+ * events, or an output report, which the host will use to tell the HAL of desired state
+ * changes (e.g. setting an LED).
+ */
+ input_report_definition_t* (*create_input_report_definition)(input_host_t* host);
+ input_report_definition_t* (*create_output_report_definition)(input_host_t* host);
+
+ /**
+ * Append the report to the given input device.
+ */
+ void (*input_device_definition_add_report)(input_host_t* host,
+ input_device_definition_t* d, input_report_definition_t* r);
+
+ /**
+ * Add a collection with the given arity and ID. A collection describes a set
+ * of logically grouped properties such as the X and Y coordinates of a single finger touch or
+ * the set of keys on a keyboard. The arity declares how many repeated instances of this
+ * collection will appear in whatever report it is attached to. The ID describes the type of
+ * grouping being represented by the collection. For example, a touchscreen capable of
+ * reporting up to 2 fingers simultaneously might have a collection with the X and Y
+ * coordinates, an arity of 2, and an ID of INPUT_COLLECTION_USAGE_TOUCHSCREEN. Any given ID
+ * may only be present once for a given report.
+ */
+ void (*input_report_definition_add_collection)(input_host_t* host,
+ input_report_definition_t* report, input_collection_id_t id, int32_t arity);
+
+ /**
+ * Declare an int usage with the given properties. The report and collection defines where the
+ * usage is being declared.
+ */
+ void (*input_report_definition_declare_usage_int)(input_host_t* host,
+ input_report_definition_t* report, input_collection_id_t id,
+ input_usage_t usage, int32_t min, int32_t max, float resolution);
+
+ /**
+ * Declare a set of boolean usages with the given properties. The report and collection
+ * defines where the usages are being declared.
+ */
+ void (*input_report_definition_declare_usages_bool)(input_host_t* host,
+ input_report_definition_t* report, input_collection_id_t id,
+ input_usage_t* usage, size_t usage_count);
+
+
+ /**
+ * Register a given input device definition. This notifies the host that an input device has
+ * been connected and gives a description of all its capabilities.
+ */
+ input_device_handle_t* (*register_device)(input_host_t* host,
+ input_device_identifier_t* id, input_device_definition_t* d);
+
+ /** Unregister the given device */
+ void (*unregister_device)(input_host_t* host, input_device_handle_t* handle);
+
+ /**
+ * Allocate a report that will contain all of the state as described by the given report.
+ */
+ input_report_t* (*input_allocate_report)(input_host_t* host, input_report_definition_t* r);
+
+ /**
+ * Add an int usage value to a report.
+ */
+ void (*input_report_set_usage_int)(input_host_t* host, input_report_t* r,
+ input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index);
+
+ /**
+ * Add a boolean usage value to a report.
+ */
+ void (*input_report_set_usage_bool)(input_host_t* host, input_report_t* r,
+ input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index);
+
+ void (*report_event)(input_host_t* host, input_device_handle_t* d, input_report_t* report);
+} input_host_callbacks_t;
+
+typedef struct input_module input_module_t;
+
+struct input_module {
+ /**
+ * Common methods of the input module. This *must* be the first member
+ * of input_module as users of this structure will cast a hw_module_t
+ * to input_module pointer in contexts where it's known
+ * the hw_module_t references a input_module.
+ */
+ struct hw_module_t common;
+
+ /**
+ * Initialize the module with host callbacks. At this point the HAL should start up whatever
+ * infrastructure it needs to in order to process input events.
+ */
+ void (*init)(const input_module_t* module, input_host_t* host, input_host_callbacks_t cb);
+
+ /**
+ * Sends an output report with a new set of state the host would like the given device to
+ * assume.
+ */
+ void (*notify_report)(const input_module_t* module, input_report_t* report);
+};
+
+static inline int input_open(const struct hw_module_t** module, const char* type) {
+ return hw_get_module_by_class(INPUT_HARDWARE_MODULE_ID, type, module);
+}
+
+__END_DECLS
+
+#endif /* ANDROID_INCLUDE_HARDWARE_INPUT_H */
diff --git a/include/hardware/radio.h b/include/hardware/radio.h
new file mode 100644
index 0000000..145deb5
--- /dev/null
+++ b/include/hardware/radio.h
@@ -0,0 +1,298 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+#include <system/radio.h>
+#include <hardware/hardware.h>
+
+#ifndef ANDROID_RADIO_HAL_H
+#define ANDROID_RADIO_HAL_H
+
+
+__BEGIN_DECLS
+
+/**
+ * The id of this module
+ */
+#define RADIO_HARDWARE_MODULE_ID "radio"
+
+/**
+ * Name of the audio devices to open
+ */
+#define RADIO_HARDWARE_DEVICE "radio_hw_device"
+
+#define RADIO_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
+#define RADIO_MODULE_API_VERSION_CURRENT RADIO_MODULE_API_VERSION_1_0
+
+
+#define RADIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
+#define RADIO_DEVICE_API_VERSION_CURRENT RADIO_DEVICE_API_VERSION_1_0
+
+/**
+ * List of known radio HAL modules. This is the base name of the radio HAL
+ * library composed of the "radio." prefix, one of the base names below and
+ * a suffix specific to the device.
+ * E.g: radio.fm.default.so
+ */
+
+#define RADIO_HARDWARE_MODULE_ID_FM "fm" /* corresponds to RADIO_CLASS_AM_FM */
+#define RADIO_HARDWARE_MODULE_ID_SAT "sat" /* corresponds to RADIO_CLASS_SAT */
+#define RADIO_HARDWARE_MODULE_ID_DT "dt" /* corresponds to RADIO_CLASS_DT */
+
+
+/**
+ * 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.
+ */
+struct radio_module {
+ struct hw_module_t common;
+};
+
+/*
+ * Callback function called by the HAL when one of the following occurs:
+ * - event RADIO_EVENT_HW_FAILURE: radio chip of driver failure requiring
+ * closing and reopening of the tuner interface.
+ * - event RADIO_EVENT_CONFIG: new configuration applied in response to open_tuner(),
+ * or set_configuration(). The event status is 0 (no error) if the configuration has been applied,
+ * -EINVAL is not or -ETIMEDOUT in case of time out.
+ * - event RADIO_EVENT_TUNED: tune locked on new station/frequency following scan(),
+ * step(), tune() or auto AF switching. The event status is 0 (no error) if in tune,
+ * -EINVAL is not tuned and data in radio_program_info is not valid or -ETIMEDOUT if scan()
+ * timed out.
+ * - event RADIO_EVENT_TA: at the beginning and end of traffic announcement if current
+ * configuration enables TA.
+ * - event RADIO_EVENT_AF: after automatic switching to alternate frequency if current
+ * configuration enables AF switching.
+ * - event RADIO_EVENT_ANTENNA: when the antenna is connected or disconnected.
+ * - event RADIO_EVENT_METADATA: when new meta data are received from the tuned station.
+ * The callback MUST NOT be called synchronously while executing a HAL function but from
+ * a separate thread.
+ */
+typedef void (*radio_callback_t)(radio_hal_event_t *event, void *cookie);
+
+/* control interface for a radio tuner */
+struct radio_tuner {
+ /*
+ * Apply current radio band configuration (band, range, channel spacing ...).
+ *
+ * arguments:
+ * - config: the band configuration to apply
+ *
+ * returns:
+ * 0 if configuration could be applied
+ * -EINVAL if configuration requested is invalid
+ *
+ * Automatically cancels pending scan, step or tune.
+ *
+ * Callback function with event RADIO_EVENT_CONFIG MUST be called once the
+ * configuration is applied or a failure occurs or after a time out.
+ */
+ int (*set_configuration)(const struct radio_tuner *tuner,
+ const radio_hal_band_config_t *config);
+
+ /*
+ * Retrieve current radio band configuration.
+ *
+ * arguments:
+ * - config: where to return the band configuration
+ *
+ * returns:
+ * 0 if valid configuration is returned
+ * -EINVAL if invalid arguments are passed
+ */
+ int (*get_configuration)(const struct radio_tuner *tuner,
+ radio_hal_band_config_t *config);
+
+ /*
+ * Start scanning up to next valid station.
+ * Must be called when a valid configuration has been applied.
+ *
+ * arguments:
+ * - direction: RADIO_DIRECTION_UP or RADIO_DIRECTION_DOWN
+ * - skip_sub_channel: valid for HD radio or digital radios only: ignore sub channels
+ * (e.g SPS for HD radio).
+ *
+ * returns:
+ * 0 if scan successfully started
+ * -ENOSYS if called out of sequence
+ * -ENODEV if another error occurs
+ *
+ * Automatically cancels pending scan, step or tune.
+ *
+ * Callback function with event RADIO_EVENT_TUNED MUST be called once
+ * locked on a station or after a time out or full frequency scan if
+ * no station found. The event status should indicate if a valid station
+ * is tuned or not.
+ */
+ int (*scan)(const struct radio_tuner *tuner,
+ radio_direction_t direction, bool skip_sub_channel);
+
+ /*
+ * Move one channel spacing up or down.
+ * Must be called when a valid configuration has been applied.
+ *
+ * arguments:
+ * - direction: RADIO_DIRECTION_UP or RADIO_DIRECTION_DOWN
+ * - skip_sub_channel: valid for HD radio or digital radios only: ignore sub channels
+ * (e.g SPS for HD radio).
+ *
+ * returns:
+ * 0 if step successfully started
+ * -ENOSYS if called out of sequence
+ * -ENODEV if another error occurs
+ *
+ * Automatically cancels pending scan, step or tune.
+ *
+ * Callback function with event RADIO_EVENT_TUNED MUST be called once
+ * step completed or after a time out. The event status should indicate
+ * if a valid station is tuned or not.
+ */
+ int (*step)(const struct radio_tuner *tuner,
+ radio_direction_t direction, bool skip_sub_channel);
+
+ /*
+ * Tune to specified frequency.
+ * Must be called when a valid configuration has been applied.
+ *
+ * arguments:
+ * - channel: channel to tune to. A frequency in kHz for AM/FM/HD Radio bands.
+ * - sub_channel: valid for HD radio or digital radios only: (e.g SPS number for HD radio).
+ *
+ * returns:
+ * 0 if tune successfully started
+ * -ENOSYS if called out of sequence
+ * -EINVAL if invalid arguments are passed
+ * -ENODEV if another error occurs
+ *
+ * Automatically cancels pending scan, step or tune.
+ *
+ * Callback function with event RADIO_EVENT_TUNED MUST be called once
+ * tuned or after a time out. The event status should indicate
+ * if a valid station is tuned or not.
+ */
+ int (*tune)(const struct radio_tuner *tuner,
+ unsigned int channel, unsigned int sub_channel);
+
+ /*
+ * Cancel a scan, step or tune operation.
+ * Must be called while a scan, step or tune operation is pending
+ * (callback not yet sent).
+ *
+ * returns:
+ * 0 if successful
+ * -ENOSYS if called out of sequence
+ * -ENODEV if another error occurs
+ *
+ * The callback is not sent.
+ */
+ int (*cancel)(const struct radio_tuner *tuner);
+
+ /*
+ * Retrieve current station information.
+ *
+ * arguments:
+ * - info: where to return the program info.
+ * If info->metadata is NULL. no meta data should be returned.
+ * If meta data must be returned, they should be added to or cloned to
+ * info->metadata, not passed from a newly created meta data buffer.
+ *
+ * returns:
+ * 0 if tuned and information available
+ * -EINVAL if invalid arguments are passed
+ * -ENODEV if another error occurs
+ */
+ int (*get_program_information)(const struct radio_tuner *tuner,
+ radio_program_info_t *info);
+};
+
+struct radio_hw_device {
+ struct hw_device_t common;
+
+ /*
+ * Retrieve implementation properties.
+ *
+ * arguments:
+ * - properties: where to return the module properties
+ *
+ * returns:
+ * 0 if no error
+ * -EINVAL if invalid arguments are passed
+ */
+ int (*get_properties)(const struct radio_hw_device *dev,
+ radio_hal_properties_t *properties);
+
+ /*
+ * Open a tuner interface for the requested configuration.
+ * If no other tuner is opened, this will activate the radio module.
+ *
+ * arguments:
+ * - config: the band configuration to apply
+ * - audio: this tuner will be used for live radio listening and should be connected to
+ * the radio audio source.
+ * - callback: the event callback
+ * - cookie: the cookie to pass when calling the callback
+ * - tuner: where to return the tuner interface
+ *
+ * returns:
+ * 0 if HW was powered up and configuration could be applied
+ * -EINVAL if configuration requested is invalid
+ * -ENOSYS if called out of sequence
+ *
+ * Callback function with event RADIO_EVENT_CONFIG MUST be called once the
+ * configuration is applied or a failure occurs or after a time out.
+ */
+ int (*open_tuner)(const struct radio_hw_device *dev,
+ const radio_hal_band_config_t *config,
+ bool audio,
+ radio_callback_t callback,
+ void *cookie,
+ const struct radio_tuner **tuner);
+
+ /*
+ * Close a tuner interface.
+ * If the last tuner is closed, the radio module is deactivated.
+ *
+ * arguments:
+ * - tuner: the tuner interface to close
+ *
+ * returns:
+ * 0 if powered down successfully.
+ * -EINVAL if an invalid argument is passed
+ * -ENOSYS if called out of sequence
+ */
+ int (*close_tuner)(const struct radio_hw_device *dev, const struct radio_tuner *tuner);
+
+};
+
+typedef struct radio_hw_device radio_hw_device_t;
+
+/** convenience API for opening and closing a supported device */
+
+static inline int radio_hw_device_open(const struct hw_module_t* module,
+ struct radio_hw_device** device)
+{
+ return module->methods->open(module, RADIO_HARDWARE_DEVICE,
+ (struct hw_device_t**)device);
+}
+
+static inline int radio_hw_device_close(const struct radio_hw_device* device)
+{
+ return device->common.close((struct hw_device_t *)&device->common);
+}
+
+__END_DECLS
+
+#endif // ANDROID_RADIO_HAL_H