Merge "camera_common: add TORCH_MODE_STATUS_OFF"
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 8d5b2f0..2389c09 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -128,6 +128,7 @@
#define AUDIO_PARAMETER_STREAM_INPUT_SOURCE "input_source" /* audio_source_t */
#define AUDIO_PARAMETER_STREAM_SAMPLING_RATE "sampling_rate" /* uint32_t */
+#define AUDIO_PARAMETER_DEVICE_CONNECT "connect" /* audio_devices_t */
#define AUDIO_PARAMETER_DEVICE_DISCONNECT "disconnect" /* audio_devices_t */
/* Query supported formats. The response is a '|' separated list of strings from
diff --git a/include/hardware/camera3.h b/include/hardware/camera3.h
index b705103..5fcbf0f 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,9 @@
* - 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.
*/
/**
@@ -1073,34 +1082,7 @@
*
* This includes some typical use case examples the camera HAL may support.
*
- * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_INPUT stream.
- *
- * When Zero Shutter Lag (ZSL) is supported by the camera device, the INPUT stream
- * can be used for application/framework implemented ZSL use case. This kind of stream
- * will be used by the framework as follows:
- *
- * 1. Framework configures an opaque raw format output stream that is used to
- * produce the ZSL output buffers. The stream pixel format will be
- * HAL_PIXEL_FORMAT_RAW_OPAQUE.
- *
- * 2. Framework configures an opaque raw format input stream that is used to
- * send the reprocess ZSL buffers to the HAL. The stream pixel format will
- * also be HAL_PIXEL_FORMAT_RAW_OPAQUE.
- *
- * 3. 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. Framework picks a ZSL buffer from the 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 JPEG result to framework.
- *
- * The HAL can select the actual raw buffer format and configure the ISP pipeline
- * appropriately based on the HAL_PIXEL_FORMAT_RAW_OPAQUE format. See this format
- * definition for more details.
- *
- * S8.2 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream.
+ * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream.
*
* For this use case, the bidirectional stream will be used by the framework as follows:
*
@@ -1136,6 +1118,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.
+ *
*/
/**
@@ -1164,6 +1196,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;
@@ -1211,8 +1337,9 @@
* quality images (that otherwise would cause a frame rate performance
* loss), or to do off-line reprocessing.
*
- * A typical use case is Zero Shutter Lag (ZSL), see S8.1 for more details.
- *
+ * 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,
@@ -1223,7 +1350,7 @@
*
* This kind of stream is meant generally for Zero Shutter Lag (ZSL)
* features, where copying the captured image from the output buffer to the
- * reprocessing input buffer would be expensive. See S8.2 for more details.
+ * reprocessing input buffer would be expensive. See S8.1 for more details.
*
* Note that the HAL will always be reprocessing data it produced.
*
diff --git a/include/hardware/camera_common.h b/include/hardware/camera_common.h
index b00372d..7d5dce5 100644
--- a/include/hardware/camera_common.h
+++ b/include/hardware/camera_common.h
@@ -90,15 +90,29 @@
*******************************************************************************
* Version: 2.4 [CAMERA_MODULE_API_VERSION_2_4]
*
- * This camera module version adds 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.
+ * 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.
*/
/**
@@ -128,10 +142,11 @@
#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
@@ -140,11 +155,19 @@
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:
- * 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:
+ *
+ * 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;
@@ -160,8 +183,16 @@
* 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;
@@ -183,9 +214,9 @@
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().
*
@@ -203,6 +234,80 @@
*
*/
const camera_metadata_t *static_camera_characteristics;
+
+ /**
+ * The total resource "cost" of using this 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.
+ *
+ * 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.
+ *
+ * Note: 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 should fail during the configure calls. If the
+ * total resource cost is <= 100, configuration should never fail due to
+ * resource constraints.
+ *
+ * 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.
+ *
+ * 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;
/**
@@ -226,23 +331,51 @@
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,
@@ -434,8 +567,21 @@
* 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);
@@ -454,6 +600,14 @@
*
* -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);
diff --git a/include/hardware/keyguard.h b/include/hardware/keyguard.h
new file mode 100644
index 0000000..2d65d4b
--- /dev/null
+++ b/include/hardware/keyguard.h
@@ -0,0 +1,92 @@
+/*
+ * 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_KEYGUARD_H
+#define ANDROID_HARDWARE_KEYGUARD_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <hardware/hardware.h>
+
+__BEGIN_DECLS
+
+#define KEYGUARD_HARDWARE_MODULE_ID "keyguard"
+
+#define KEYGUARD_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
+
+#define HARDWARE_KEYGUARD "keyguard"
+
+struct keyguard_module {
+ /**
+ * Comon methods of the keyguard module. This *must* be the first member of
+ * keyguard_module as users of this structure will cast a hw_module_t to
+ * a keyguard_module pointer in the appropriate context.
+ */
+ hw_module_t common;
+};
+
+struct keyguard_device {
+ /**
+ * Common methods of the keyguard device. As above, this must be the first
+ * member of keymaster_device.
+ */
+ hw_device_t common;
+
+ /**
+ * Enrolls password_payload, which should be derived from a user selected pin or password,
+ * with the authentication factor private key used only for enrolling authentication
+ * factor data.
+ *
+ * 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 keyguard_device *dev, const uint8_t *password_payload,
+ const uint8_t password_payload_length, uint8_t **enrolled_password_handle,
+ uint8_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 verification_token,
+ * usable to attest password verification to other trusted services. Clients
+ * may pass NULL for this value.
+ *
+ * Returns: 0 on success or an error code less than 0 on error
+ * On error, verification token will not be allocated
+ */
+ int (*verify)(const struct keyguard_device *dev, const uint8_t *enrolled_password_handle,
+ const uint8_t enrolled_password_handle_length, const uint8_t *provided_password,
+ const uint8_t provided_password_length, uint8_t **verification_token);
+
+};
+typedef struct keyguard_device keyguard_device_t;
+
+static inline int keyguard_open(const struct hw_module_t *module,
+ keyguard_device_t **device) {
+ return module->methods->open(module, HARDWARE_KEYGUARD,
+ (struct hw_device_t **) device);
+}
+
+static inline int keyguard_close(keyguard_device_t *device) {
+ return device->common.close(&device->common);
+}
+
+__END_DECLS
+
+#endif // ANDROID_HARDWARE_KEYGUARD_H
diff --git a/include/hardware/keymaster.h b/include/hardware/keymaster.h
index a6200a5..40380ad 100644
--- a/include/hardware/keymaster.h
+++ b/include/hardware/keymaster.h
@@ -278,7 +278,7 @@
*
* \param[in] data_length Length of \p data.
*/
- keymaster_error_t (*add_rng_entropy)(const struct keymaster_device* dev, uint8_t* data,
+ keymaster_error_t (*add_rng_entropy)(const struct keymaster_device* dev, const uint8_t* data,
size_t data_length);
/**
@@ -401,7 +401,7 @@
const keymaster_key_blob_t* key_blob,
const keymaster_blob_t* client_id,
const keymaster_blob_t* app_data,
- const keymaster_key_blob_t* rescoped_key_blob,
+ keymaster_key_blob_t* rescoped_key_blob,
keymaster_key_characteristics_t** characteristics);
/**
@@ -556,18 +556,6 @@
keymaster_operation_handle_t* operation_handle);
/**
- * Get an estimate of the output that will be generated by calling update() with the specified
- * number of input bytes, followed by finish(). The estimate may not be exact, but is
- * guaranteed not to be smaller than sum of the output lengths from update() and finish(). The
- * estimate takes into account input data already provided.
- *
- * \param[in] input_length The number of additional input bytes to be processed.
- *
- * \param[out] output_estimate The length of the output that will be produced.
- */
- keymaster_error_t (*get_output_size)(size_t input_length, size_t* output_estimate);
-
- /**
* Provides data to, and possibly receives output from, an ongoing cryptographic operation begun
* with begin().
*
diff --git a/include/hardware/keymaster_defs.h b/include/hardware/keymaster_defs.h
index 3a0aecc..95ffe8e 100644
--- a/include/hardware/keymaster_defs.h
+++ b/include/hardware/keymaster_defs.h
@@ -102,15 +102,15 @@
*/
/* Crypto parameters */
- KM_TAG_PURPOSE = KM_ENUM_REP | 1, /* keymaster_purpose_t. */
- KM_TAG_ALGORITHM = KM_ENUM | 2, /* keymaster_algorithm_t. */
- KM_TAG_KEY_SIZE = KM_INT | 3, /* Key size in bits. */
- KM_TAG_BLOCK_MODE = KM_ENUM | 4, /* keymaster_block_mode_t. */
- KM_TAG_DIGEST = KM_ENUM | 5, /* keymaster_digest_t. */
- KM_TAG_MAC_LENGTH = KM_INT | 6, /* MAC length in bits. */
- KM_TAG_PADDING = KM_ENUM | 7, /* keymaster_padding_t. */
- KM_TAG_CHUNK_LENGTH = KM_INT | 8, /* AEAD mode minimum decryption chunk size, in bytes. */
- KM_TAG_NONCE = KM_BYTES | 9, /* Nonce or Initialization Vector */
+ KM_TAG_PURPOSE = KM_ENUM_REP | 1, /* keymaster_purpose_t. */
+ KM_TAG_ALGORITHM = KM_ENUM | 2, /* keymaster_algorithm_t. */
+ KM_TAG_KEY_SIZE = KM_INT | 3, /* Key size in bits. */
+ KM_TAG_BLOCK_MODE = KM_ENUM | 4, /* keymaster_block_mode_t. */
+ KM_TAG_DIGEST = KM_ENUM | 5, /* keymaster_digest_t. */
+ KM_TAG_MAC_LENGTH = KM_INT | 6, /* MAC length in bits. */
+ KM_TAG_PADDING = KM_ENUM | 7, /* keymaster_padding_t. */
+ KM_TAG_CHUNK_LENGTH = KM_INT | 8, /* AEAD mode minimum decryption chunk size, in bytes. */
+ KM_TAG_CALLER_NONCE = KM_BOOL | 9, /* Allow caller to specify nonce or IV. */
/* Other hardware-enforced. */
KM_TAG_RESCOPING_ADD = KM_ENUM_REP | 101, /* Tags authorized for addition via rescoping. */
@@ -138,28 +138,24 @@
longer be trusted. */
KM_TAG_MIN_SECONDS_BETWEEN_OPS = KM_INT | 403, /* Minimum elapsed time between
cryptographic operations with the key. */
- KM_TAG_SINGLE_USE_PER_BOOT = KM_BOOL | 404, /* If true, the key can only be used once
- per boot. */
+ KM_TAG_MAX_USES_PER_BOOT = KM_INT | 404, /* Number of times the key can be used per
+ boot. */
/* User authentication */
- KM_TAG_ALL_USERS = KM_BOOL | 500, /* If key is usable by all users. */
- KM_TAG_USER_ID = KM_INT | 501, /* ID of authorized user. Disallowed if KM_TAG_ALL_USERS is
- present. */
- KM_TAG_NO_AUTH_REQUIRED = KM_BOOL | 502, /* If key is usable without authentication. */
- KM_TAG_USER_AUTH_ID = KM_INT_REP | 503, /* ID of the authenticator to use (e.g. password,
- fingerprint, etc.). Repeatable to support
- multi-factor auth. Disallowed if
- KM_TAG_NO_AUTH_REQUIRED is present. */
- KM_TAG_AUTH_TIMEOUT = KM_INT | 504, /* Required freshness of user authentication for
- private/secret key operations, in seconds.
- Public key operations require no authentication.
- If absent, authentication is required for every
- use. Authentication state is lost when the
- device is powered off. */
- KM_TAG_RESCOPE_AUTH_TIMEOUT = KM_INT | 505, /* Required freshness of user authentication for key
- rescoping operations, in seconds. Public key
- operations require no authentication. If absent,
- authentication required for every rescoping. */
+ KM_TAG_ALL_USERS = KM_BOOL | 500, /* If key is usable by all users. */
+ KM_TAG_USER_ID = KM_INT | 501, /* ID of authorized user. Disallowed if
+ KM_TAG_ALL_USERS is present. */
+ KM_TAG_NO_AUTH_REQUIRED = KM_BOOL | 502, /* If key is usable without authentication. */
+ KM_TAG_USER_AUTH_ID = KM_INT_REP | 503, /* ID of the authenticator to use (e.g. password,
+ fingerprint, etc.). Repeatable to support
+ multi-factor auth. Disallowed if
+ KM_TAG_NO_AUTH_REQUIRED is present. */
+ KM_TAG_AUTH_TIMEOUT = KM_INT | 504, /* Required freshness of user authentication for
+ private/secret key operations, in seconds.
+ Public key operations require no authentication.
+ If absent, authentication is required for every
+ use. Authentication state is lost when the
+ device is powered off. */
/* Application access control */
KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600, /* If key is usable by all applications. */
@@ -179,6 +175,7 @@
/* Tags used only to provide data to operations */
KM_TAG_ADDITIONAL_DATA = KM_BYTES | 1000, /* Used to provide additional data for AEAD modes. */
+ KM_TAG_NONCE = KM_BYTES | 1001, /* Nonce or Initialization Vector */
} keymaster_tag_t;
/**
@@ -382,7 +379,7 @@
KM_ERROR_UNSUPPORTED_KEY_SIZE = -6,
KM_ERROR_UNSUPPORTED_BLOCK_MODE = -7,
KM_ERROR_INCOMPATIBLE_BLOCK_MODE = -8,
- KM_ERROR_UNSUPPORTED_TAG_LENGTH = -9,
+ KM_ERROR_UNSUPPORTED_MAC_LENGTH = -9,
KM_ERROR_UNSUPPORTED_PADDING_MODE = -10,
KM_ERROR_INCOMPATIBLE_PADDING_MODE = -11,
KM_ERROR_UNSUPPORTED_DIGEST = -12,
diff --git a/include/hardware/qemu_pipe.h b/include/hardware/qemu_pipe.h
index 814b20b..53aec97 100644
--- a/include/hardware/qemu_pipe.h
+++ b/include/hardware/qemu_pipe.h
@@ -23,6 +23,7 @@
#include <pthread.h> /* for pthread_once() */
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <errno.h>
#ifndef D
diff --git a/modules/audio/audio_hw.c b/modules/audio/audio_hw.c
index 18c0e59..637e3f4 100644
--- a/modules/audio/audio_hw.c
+++ b/modules/audio/audio_hw.c
@@ -18,6 +18,7 @@
//#define LOG_NDEBUG 0
#include <errno.h>
+#include <malloc.h>
#include <pthread.h>
#include <stdint.h>
#include <sys/time.h>
diff --git a/modules/consumerir/consumerir.c b/modules/consumerir/consumerir.c
index 87039cc..f3eac0b 100644
--- a/modules/consumerir/consumerir.c
+++ b/modules/consumerir/consumerir.c
@@ -16,6 +16,7 @@
#define LOG_TAG "ConsumerIrHal"
#include <errno.h>
+#include <malloc.h>
#include <string.h>
#include <cutils/log.h>
#include <hardware/hardware.h>
diff --git a/modules/fingerprint/fingerprint.c b/modules/fingerprint/fingerprint.c
index 14dac12..0346518 100644
--- a/modules/fingerprint/fingerprint.c
+++ b/modules/fingerprint/fingerprint.c
@@ -16,6 +16,7 @@
#define LOG_TAG "FingerprintHal"
#include <errno.h>
+#include <malloc.h>
#include <string.h>
#include <cutils/log.h>
#include <hardware/hardware.h>
diff --git a/modules/hwcomposer/hwcomposer.cpp b/modules/hwcomposer/hwcomposer.cpp
index f0a5512..9d1aa34 100644
--- a/modules/hwcomposer/hwcomposer.cpp
+++ b/modules/hwcomposer/hwcomposer.cpp
@@ -16,8 +16,9 @@
#include <hardware/hardware.h>
-#include <fcntl.h>
#include <errno.h>
+#include <fcntl.h>
+#include <malloc.h>
#include <cutils/log.h>
#include <cutils/atomic.h>
diff --git a/modules/local_time/local_time_hw.c b/modules/local_time/local_time_hw.c
index 308f7d9..ac597f4 100644
--- a/modules/local_time/local_time_hw.c
+++ b/modules/local_time/local_time_hw.c
@@ -18,9 +18,10 @@
//#define LOG_NDEBUG 0
#include <errno.h>
+#include <malloc.h>
#include <stdint.h>
+#include <string.h>
#include <sys/time.h>
-#include <linux/time.h>
#include <cutils/log.h>
diff --git a/modules/nfc-nci/nfc_nci_example.c b/modules/nfc-nci/nfc_nci_example.c
index 2514225..758c2b7 100644
--- a/modules/nfc-nci/nfc_nci_example.c
+++ b/modules/nfc-nci/nfc_nci_example.c
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include <errno.h>
+#include <malloc.h>
#include <string.h>
#include <cutils/log.h>
diff --git a/modules/nfc/nfc_pn544_example.c b/modules/nfc/nfc_pn544_example.c
index 54c9c56..71bfd6b 100644
--- a/modules/nfc/nfc_pn544_example.c
+++ b/modules/nfc/nfc_pn544_example.c
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include <errno.h>
+#include <malloc.h>
#include <string.h>
#include <hardware/hardware.h>
diff --git a/modules/tv_input/tv_input.cpp b/modules/tv_input/tv_input.cpp
index bc02786..114e80e 100644
--- a/modules/tv_input/tv_input.cpp
+++ b/modules/tv_input/tv_input.cpp
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-#include <fcntl.h>
#include <errno.h>
+#include <fcntl.h>
+#include <malloc.h>
#include <cutils/log.h>
#include <cutils/native_handle.h>
diff --git a/modules/vibrator/vibrator.c b/modules/vibrator/vibrator.c
index ce4c03c..6b3ce57 100644
--- a/modules/vibrator/vibrator.c
+++ b/modules/vibrator/vibrator.c
@@ -19,6 +19,7 @@
#include <cutils/log.h>
+#include <malloc.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
diff --git a/tests/keymaster/Android.mk b/tests/keymaster/Android.mk
index c420db9..0c11795 100644
--- a/tests/keymaster/Android.mk
+++ b/tests/keymaster/Android.mk
@@ -6,9 +6,6 @@
LOCAL_SRC_FILES:= \
keymaster_test.cpp
-LOCAL_C_INCLUDES := \
- external/openssl/include \
-
LOCAL_SHARED_LIBRARIES := \
liblog \
libutils \