Merge "Camera: HIDLized camera HALs, first set"

This commit is contained in:
TreeHugger Robot
2016-12-02 22:22:10 +00:00
committed by Android (Google) Code Review
26 changed files with 34677 additions and 0 deletions

8
camera/Android.bp Normal file
View File

@@ -0,0 +1,8 @@
// This is an autogenerated file, do not edit.
subdirs = [
"common/1.0",
"device/1.0",
"device/3.2",
"metadata/3.2",
"provider/2.4",
]

12
camera/README.md Normal file
View File

@@ -0,0 +1,12 @@
## Camera HALs ##
---
## Overview: ##
The camera.* HAL tree is used by the Android camera service to discover and
operate camera devices available on the device.
More details and versioning information can be found within each particular HAL.
More complete information about the Android camera HAL and subsystem can be found at
[source.android.com](http://source.android.com/devices/camera/index.html).

View File

@@ -0,0 +1,46 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
genrule {
name: "android.hardware.camera.common@1.0_genc++",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.common@1.0",
srcs: [
"types.hal",
],
out: [
"android/hardware/camera/common/1.0/types.cpp",
],
}
genrule {
name: "android.hardware.camera.common@1.0_genc++_headers",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.common@1.0",
srcs: [
"types.hal",
],
out: [
"android/hardware/camera/common/1.0/types.h",
],
}
cc_library_shared {
name: "android.hardware.camera.common@1.0",
generated_sources: ["android.hardware.camera.common@1.0_genc++"],
generated_headers: ["android.hardware.camera.common@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.camera.common@1.0_genc++_headers"],
shared_libs: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"liblog",
"libutils",
"libcutils",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
],
}

View File

@@ -0,0 +1,336 @@
# This file is autogenerated by hidl-gen. Do not edit manually.
LOCAL_PATH := $(call my-dir)
################################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.camera.common@1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(local-generated-sources-dir)
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
#
# Build types.hal (CameraDeviceStatus)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/CameraDeviceStatus.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.CameraDeviceStatus
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (CameraMetadataType)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/CameraMetadataType.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.CameraMetadataType
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (CameraResourceCost)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/CameraResourceCost.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.CameraResourceCost
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (Status)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/Status.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.Status
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (TagBoundaryId)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/TagBoundaryId.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.TagBoundaryId
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (TorchMode)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/TorchMode.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.TorchMode
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (TorchModeStatus)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/TorchModeStatus.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.TorchModeStatus
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (VendorTag)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/VendorTag.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.VendorTag
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (VendorTagSection)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/VendorTagSection.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.VendorTagSection
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
include $(BUILD_JAVA_LIBRARY)
################################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.camera.common@1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(local-generated-sources-dir)
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
#
# Build types.hal (CameraDeviceStatus)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/CameraDeviceStatus.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.CameraDeviceStatus
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (CameraMetadataType)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/CameraMetadataType.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.CameraMetadataType
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (CameraResourceCost)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/CameraResourceCost.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.CameraResourceCost
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (Status)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/Status.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.Status
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (TagBoundaryId)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/TagBoundaryId.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.TagBoundaryId
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (TorchMode)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/TorchMode.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.TorchMode
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (TorchModeStatus)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/TorchModeStatus.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.TorchModeStatus
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (VendorTag)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/VendorTag.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.VendorTag
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
#
# Build types.hal (VendorTagSection)
#
GEN := $(intermediates)/android/hardware/camera/common/1.0/VendorTagSection.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-Ljava -randroid.hardware:hardware/interfaces \
android.hardware.camera.common@1.0::types.VendorTagSection
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
include $(BUILD_STATIC_JAVA_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH))

413
camera/common/1.0/types.hal Normal file
View File

@@ -0,0 +1,413 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.common@1.0;
/**
* Common enumeration and structure definitions for all HALs under
* android.hardware.camera
*/
/**
* Status codes for camera HAL method calls.
*
*/
enum Status : uint32_t {
/**
* Method call succeeded
*/
OK = 0,
/**
* One of the arguments to the method call is invalid. For example,
* the camera ID is unknown.
*/
ILLEGAL_ARGUMENT = 1,
/**
* The specified camera device is already in use
*/
CAMERA_IN_USE = 2,
/**
* The HAL cannot support more simultaneous cameras in use.
*/
MAX_CAMERAS_IN_USE = 3,
/**
* This HAL does not support this method.
*/
METHOD_NOT_SUPPORTED = 4,
/**
* The specified camera device does not support this operation.
*/
OPERATION_NOT_SUPPORTED = 5,
/**
* This camera device is no longer connected or otherwise available for use
*/
CAMERA_DISCONNECTED = 6,
/**
* The HAL has encountered an internal error and cannot complete the
* request.
*/
INTERNAL_ERROR = 7
};
/**
* Possible states that the flash unit on a closed camera device can be set to
* via the ICameraProvider::setTorchMode() method.
*/
enum TorchMode : uint32_t {
OFF = 0, // Turn off the flash
ON = 1 // Turn on the flash to torch mode
};
/**
* Camera metadata type - duplicated from VNDK libcamera_metadata for vendor tag
* definitions.
*/
enum CameraMetadataType : uint32_t {
// Unsigned 8-bit integer (uint8_t)
BYTE = 0,
// Signed 32-bit integer (int32_t)
INT32 = 1,
// 32-bit float (float)
FLOAT = 2,
// Signed 64-bit integer (int64_t)
INT64 = 3,
// 64-bit float (double)
DOUBLE = 4,
// A 64-bit fraction (camera_metadata_rational_t)
RATIONAL = 5
};
/**
* A single vendor-unique metadata tag.
* The full name of the tag is <sectionName>.<tagName>
*/
struct VendorTag {
uint32_t tagId; // Tag identifier, must be >= TagBoundaryId::VENDOR
string tagName; // Name of tag, not including section name
CameraMetadataType tagType;
};
/**
* A set of related vendor tags.
*/
struct VendorTagSection {
string sectionName; // Section name; must be namespaced within vendor's name
vec<VendorTag> tags; // List of tags in this section
};
enum TagBoundaryId : uint32_t {
AOSP = 0x0, // First valid tag id for android-defined tags
VENDOR = 0x80000000u // First valid tag id for vendor extension tags
};
/**
* CameraDeviceStatus
*
* The current status of a camera device, as sent by a camera provider HAL
* through the ICameraProviderCallback::cameraDeviceStatusChange() call.
*
* At startup, the camera service must assume all internal camera devices listed
* by ICameraProvider::getCameraIdList() are in the PRESENT state. The provider
* must invoke ICameraProviderCallback::cameraDeviceStatusChange to inform the
* service of any initially NOT_PRESENT internal devices, and of any PRESENT
* external camera devices, as soon as the camera service has called
* ICameraProvider::setCallback().
*
* Allowed state transitions:
* PRESENT -> NOT_PRESENT
* NOT_PRESENT -> ENUMERATING
* NOT_PRESENT -> PRESENT
* ENUMERATING -> PRESENT
* ENUMERATING -> NOT_PRESENT
*/
enum CameraDeviceStatus : uint32_t {
/**
* The camera device is not currently connected, and trying to reference it
* in provider method calls must return status code ILLEGAL_ARGUMENT.
*
*/
NOT_PRESENT = 0,
/**
* The camera device is connected, and opening it is possible, as long as
* sufficient resources are available.
*
* By default, the framework must assume all devices returned by
* ICameraProvider::getCameraIdList() are in this state.
*/
PRESENT = 1,
/**
* The camera device is connected, but it is undergoing enumeration and
* startup, and so opening the device must return CAMERA_IN_USE.
*
* Attempting to call ICameraProvider::getCameraCharacteristics() must
* succeed, however.
*/
ENUMERATING = 2,
};
/**
* TorchModeStatus:
*
* The current status of the torch mode on a given camera device, sent by a
* camera provider HAL via the ICameraProviderCallback::TorchModeStatusChange()
* call.
*
* The torch mode status of a camera device is applicable only when the camera
* device is present. The camera service must not call
* ICameraProvider::setTorchMode() to turn on torch mode of a camera device if
* the camera device is not present. At camera service startup time, the
* framework must assume torch modes are in the AVAILABLE_OFF state if the
* camera device is present and the camera characteristics entry
* android.flash.info.available is reported as true via
* ICameraProvider::getCameraCharacteristics() call. The same is assumed for
* external camera devices when they are initially connected.
*
* The camera service requires the following behaviors from the camera provider
* HAL when a camera device's status changes:
*
* 1. A previously-disconnected camera device becomes connected. After
* ICameraProviderCallback::CameraDeviceStatusChange() is invoked to inform
* the camera service that the camera device is present, the framework must
* assume the camera device's torch mode is in AVAILABLE_OFF state if it
* has a flash unit. The camera provider HAL does not need to invoke
* ICameraProviderCallback::TorchModeStatusChange() unless the flash unit
* is unavailable to use by ICameraProvider::setTorchMode().
*
* 2. A previously-connected camera becomes disconnected. After
* ICameraProviderCallback::CameraDeviceStatusChange() is invoked to inform
* the camera service that the camera device is not present, the framework
* must not call ICameraProvider::setTorchMode() for the disconnected camera
* device until it is connected again. The camera provider HAL does not
* need to invoke ICameraProviderCallback::TorchModeStatusChange()
* separately to inform that the flash unit has become NOT_AVAILABLE.
*
* 3. openCameraDevice() or openCameraDeviceVersion() is called to open a
* camera device. The camera provider HAL must invoke
* ICameraProviderCallback::TorchModeStatusChange() for all flash units
* that have entered NOT_AVAILABLE state and can not be turned on by
* calling ICameraProvider::setTorchMode() due to this open() call.
* openCameraDevice() must not trigger AVAILABLE_OFF before NOT_AVAILABLE
* for all flash units that have become unavailable.
*
* 4. ICameraDevice.close() is called to close a camera device. The camera
* provider HAL must call ICameraProviderCallback::torchModeStatusChange()
* for all flash units that have now entered the AVAILABLE_OFF state and
* can be turned on by calling ICameraProvider::setTorchMode() again because
* of sufficient new camera resources being freed up by this close() call.
*
* Note that the camera service calling ICameraProvider::setTorchMode()
* successfully must trigger AVAILABLE_OFF or AVAILABLE_ON callback for the
* given camera device. Additionally it must trigger AVAILABLE_OFF callbacks
* for other previously-on torch modes if HAL cannot keep multiple devices'
* flashlights on simultaneously.
*/
enum TorchModeStatus : uint32_t {
/**
* The flash unit is no longer available and the torch mode can not be
* turned on by calling setTorchMode(). If the torch mode was AVAILABLE_ON,
* the flashlight must be turned off by the provider HAL before the provider
* HAL calls torchModeStatusChange().
*/
NOT_AVAILABLE = 0,
/**
* A torch mode has become off and is available to be turned on via
* ICameraProvider::setTorchMode(). This may happen in the following
* cases:
* 1. After the resources to turn on the torch mode have become available.
* 2. After ICameraProvider::setTorchMode() is called to turn off the torch
* mode.
* 3. After the camera service turned on the torch mode for some other
* camera device and the provider HAL had to turn off the torch modes
* of other camera device(s) that were previously on, due to lack of
* resources to keep them all on.
*/
AVAILABLE_OFF = 1,
/**
* A torch mode has become on and is available to be turned off via
* ICameraProvider::setTorchMode(). This can happen only after
* ICameraProvider::setTorchMode() has been called to turn on the torch mode.
*/
AVAILABLE_ON = 2,
};
/**
* CameraResourceCost:
*
* Structure defining the abstract resource cost of opening a camera device,
* and any usage conflicts between multiple camera devices.
*
* Obtainable via ICameraDevice::getResourceCost()
*/
struct CameraResourceCost {
/**
* 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
* must fail during the configure calls. If the total resource cost is <=
* 100, open and configure must 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 may 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 must 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 - resourceCost = 51
* conflicting_devices = empty
* Camera Device 1 - resourceCost = 51
* conflicting_devices = empty
*
* Result:
*
* Since the sum of the resource costs is > 100, if a higher-priority
* application has either device open, no lower-priority applications must
* 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 must 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 - resourceCost = 50
* conflicting_devices = { 2 }
* Camera Device 1 - resourceCost = 50
* conflicting_devices = { 2 }
* Camera Device 2 - resourceCost = 100
* conflicting_devices = { 0, 1 }
* Camera Device 3 - resourceCost = 50
* conflicting_devices = empty
*
* Result:
*
* Based on the conflicting_devices fields, the camera service guarantees
* that the following sets of open devices must never be allowed: { 1, 2
* }, { 0, 2 }.
*
* Based on the resourceCost 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 - resourceCost = 100
* conflicting_devices = empty
* Camera Device 1 - resourceCost = 100
* conflicting_devices = { 2 }
* Camera Device 2 - resourceCost = 0
* conflicting_devices = { 1 }
* Result:
*
* Based on the conflicting_devices fields, the camera service guarantees
* that the following sets of open devices must never be allowed:
* { 1, 2 }.
*
* Based on the resourceCost 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 must be forced to
* disconnect it if a higher-priority application subsequently opens
* device 1 or 2).
*/
uint32_t resourceCost;
/**
* An array of camera device IDs 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, an empty list may be returned to indicate this.
*
* The camera service must never simultaneously open any of the devices
* in this list while this camera device is open.
*
*/
vec<string> conflictingDevices;
};

21
camera/common/README.md Normal file
View File

@@ -0,0 +1,21 @@
## Camera common HAL definitions ##
---
## Overview: ##
The camera.common namesapce is used by the Android camera HALs for common
enumeration and structure definitions.
This includes standard status codes returned by most camera HAL methods.
More complete information about the Android camera HAL and subsystem can be found at
[source.android.com](http://source.android.com/devices/camera/index.html).
## Version history: ##
## types.hal: ##
### @1.0:
Common enum and struct definitions for all camera HAL interfaces. Does not
define any interfaces of its own.

View File

@@ -0,0 +1,76 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
genrule {
name: "android.hardware.camera.device@1.0_genc++",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.device@1.0",
srcs: [
"types.hal",
"ICameraDevice.hal",
"ICameraDeviceCallback.hal",
"ICameraDevicePreviewCallback.hal",
],
out: [
"android/hardware/camera/device/1.0/types.cpp",
"android/hardware/camera/device/1.0/CameraDeviceAll.cpp",
"android/hardware/camera/device/1.0/CameraDeviceCallbackAll.cpp",
"android/hardware/camera/device/1.0/CameraDevicePreviewCallbackAll.cpp",
],
}
genrule {
name: "android.hardware.camera.device@1.0_genc++_headers",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.device@1.0",
srcs: [
"types.hal",
"ICameraDevice.hal",
"ICameraDeviceCallback.hal",
"ICameraDevicePreviewCallback.hal",
],
out: [
"android/hardware/camera/device/1.0/types.h",
"android/hardware/camera/device/1.0/ICameraDevice.h",
"android/hardware/camera/device/1.0/IHwCameraDevice.h",
"android/hardware/camera/device/1.0/BnCameraDevice.h",
"android/hardware/camera/device/1.0/BpCameraDevice.h",
"android/hardware/camera/device/1.0/BsCameraDevice.h",
"android/hardware/camera/device/1.0/ICameraDeviceCallback.h",
"android/hardware/camera/device/1.0/IHwCameraDeviceCallback.h",
"android/hardware/camera/device/1.0/BnCameraDeviceCallback.h",
"android/hardware/camera/device/1.0/BpCameraDeviceCallback.h",
"android/hardware/camera/device/1.0/BsCameraDeviceCallback.h",
"android/hardware/camera/device/1.0/ICameraDevicePreviewCallback.h",
"android/hardware/camera/device/1.0/IHwCameraDevicePreviewCallback.h",
"android/hardware/camera/device/1.0/BnCameraDevicePreviewCallback.h",
"android/hardware/camera/device/1.0/BpCameraDevicePreviewCallback.h",
"android/hardware/camera/device/1.0/BsCameraDevicePreviewCallback.h",
],
}
cc_library_shared {
name: "android.hardware.camera.device@1.0",
generated_sources: ["android.hardware.camera.device@1.0_genc++"],
generated_headers: ["android.hardware.camera.device@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.camera.device@1.0_genc++_headers"],
shared_libs: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"liblog",
"libutils",
"libcutils",
"android.hardware.camera.common@1.0",
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
"android.hardware.camera.common@1.0",
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
],
}

View File

@@ -0,0 +1,389 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.device@1.0;
import android.hardware.camera.common@1.0::types;
import ICameraDeviceCallback;
import ICameraDevicePreviewCallback;
/**
* Camera device HAL, legacy version
*
* DEPRECATED. New devices are strongly recommended to use Camera HAL v3.2 or
* newer.
*
* Supports the android.hardware.Camera API, and the android.hardware.camera2
* API in LEGACY mode only.
*
* Will be removed in the Android P release.
*/
interface ICameraDevice {
/**
* Get camera device resource cost information.
*
* This method may be called at any time, including before open()
*
* @return status Status code for the operation, one of:
* OK:
* On success.
* INTERNAL_ERROR:
* An unexpected internal camera HAL error occurred, and the
* resource cost is not available.
* CAMERA_DISCONNECTED:
* An external camera device has been disconnected, and is no longer
* available. This camera device interface is now stale, and a new
* instance must be acquired if the device is reconnected. All
* subsequent calls on this interface must return
* CAMERA_DISCONNECTED.
* @return resourceCost
* The resources required to open this camera device, or unspecified
* values if status is not OK.
*/
getResourceCost() generates (Status status, CameraResourceCost resourceCost);
/**
* Get basic camera information.
*
* This method may be called at any time, including before open()
*
* @return status Status code for the operation, one of:
* OK:
* On success.
* INTERNAL_ERROR:
* An unexpected internal camera HAL error occurred, and the
* camera information is not available.
* CAMERA_DISCONNECTED:
* An external camera device has been disconnected, and is no longer
* available. This camera device interface is now stale, and a new
* instance must be acquired if the device is reconnected. All
* subsequent calls on this interface must return
* CAMERA_DISCONNECTED.
* @return info Basic information about this camera device, or unspecified
* values if status is not OK.
*/
getCameraInfo() generates (Status status, CameraInfo info);
/**
* setTorchMode:
*
* 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
* ICameraProviderCallback::torchModeStatusChange() with the new state.
*
* The camera device has a higher priority accessing the flash unit. When
* there are any resource conflicts, such as when open() is called to fully
* activate a camera device, the provider must notify the framework through
* ICameraProviderCallback::torchModeStatusChange() 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, the provider must notify the framework through
* ICameraProviderCallback::torchModeStatusChange() that the torch mode
* state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to
* be called.
*
* When the framework calls setTorchMode() to turn on the torch mode of a
* flash unit, if HAL cannot keep multiple torch modes on simultaneously,
* HAL must turn off the torch mode that was turned on by
* a previous setTorchMode() call and notify the framework that the torch
* mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF.
*
* @param torchMode The new mode to set the device flash unit to.
*
* @return status Status code for the operation, one of:
* OK:
* On a successful change to the torch state.
* INTERNAL_ERROR:
* The flash unit cannot be operated due to an unexpected internal
* error.
* ILLEGAL_ARGUMENT:
* The camera ID is unknown.
* CAMERA_IN_USE:
* This camera device has been opened, so the torch cannot be
* controlled until it is closed.
* MAX_CAMERAS_IN_USE:
* Due to other camera devices being open, or due to other
* resource constraints, the torch cannot be controlled currently.
* METHOD_NOT_SUPPORTED:
* This provider does not support direct operation of flashlight
* torch mode. The framework must open the camera device and turn
* the torch on through the device interface.
* OPERATION_NOT_SUPPORTED:
* This camera device does not have a flash unit. This must
* be returned if and only if android.flash.info.available is
* false.
* CAMERA_DISCONNECTED:
* An external camera device has been disconnected, and is no longer
* available. This camera device interface is now stale, and a new
* instance must be acquired if the device is reconnected. All
* subsequent calls on this interface must return
* CAMERA_DISCONNECTED.
*
*/
setTorchMode(TorchMode mode) generates (Status status);
/**
* Dump state of the camera hardware.
*
* This must be callable at any time, whether the device is open or not.
*
* @param fd A native handle with one valid file descriptor. The descriptor
* must be able to be used with dprintf() or equivalent to dump the
* state of this camera device into the camera service dumpsys output.
*
* @return status The status code for this operation.
*/
dumpState(handle fd) generates (Status status);
/**
* Open the camera device for active use.
*
* All methods besides getResourceCost(), getCameraInfo(), setTorchMode(),
* and dump() must not be called unless open() has been called successfully,
* and close() has not yet been called.
*
* @param callback Interface to invoke by the HAL for device callbacks.
* @return status Status code for the operation, one of:
* OK:
* On a successful open of the camera device.
* INTERNAL_ERROR:
* The camera device cannot be opened due to an internal
* error.
* ILLEGAL_ARGUMENT:
* The callback handle is invalid (for example, it is null).
* CAMERA_IN_USE:
* This camera device is already open.
* MAX_CAMERAS_IN_USE:
* The maximal number of camera devices that can be
* opened concurrently were opened already.
* CAMERA_DISCONNECTED:
* This external camera device has been disconnected, and is no
* longer available. This interface is now stale, and a new instance
* must be acquired if the device is reconnected. All subsequent
* calls on this interface must return CAMERA_DISCONNECTED.
*/
open(ICameraDeviceCallback callback) generates (Status status);
/*****
* All methods below this point must only be called between a successful
* open() call and a close() call.
*/
/** Set the callback interface through which preview frames are sent */
setPreviewWindow(ICameraDevicePreviewCallback window)
generates (Status status);
/**
* Enable a message, or set of messages.
*
* @param msgType The bitfield of messages to enable.
*/
enableMsgType(FrameCallbackFlags msgType);
/**
* Disable a message, or a set of messages.
*
* Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera
* HAL must not rely on its client to call releaseRecordingFrame() to
* release video recording frames sent out by the cameral HAL before and
* after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL
* clients must not modify/access any video recording frame after calling
* disableMsgType(CAMERA_MSG_VIDEO_FRAME).
*
* @param msgType The bitfield of messages to disable.
*/
disableMsgType(FrameCallbackFlags msgType);
/**
* Query whether a message, or a set of messages, is enabled. Note that
* this is operates as an AND, if any of the messages queried are off, this
* must return false.
*
* @param msgType The bitfield of messages to query.
* @return enabled Whether all the specified flags are enabled.
*/
msgTypeEnabled(FrameCallbackFlags msgType) generates (bool enabled);
/**
* Start preview mode.
*
* @return status The status code for this operation.
*/
startPreview() generates (Status status);
/**
* Stop a previously started preview.
*/
stopPreview();
/**
* Returns true if preview is enabled.
*
* @return enabled Whether preview is currently enabled.
*/
previewEnabled() generates (bool enabled);
/**
* Request the camera HAL to store meta data or real YUV data in the video
* buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If
* it is not called, the default camera HAL behavior is to store real YUV
* data in the video buffers.
*
* This method must be called before startRecording() in order to be
* effective.
*
* If meta data is stored in the video buffers, it is up to the receiver of
* the video buffers to interpret the contents and to find the actual frame
* data with the help of the meta data in the buffer. How this is done is
* outside of the scope of this method.
*
* Some camera HALs may not support storing meta data in the video buffers,
* but all camera HALs must support storing real YUV data in the video
* buffers. If the camera HAL does not support storing the meta data in the
* video buffers when it is requested to do do, INVALID_OPERATION must be
* returned. It is very useful for the camera HAL to pass meta data rather
* than the actual frame data directly to the video encoder, since the
* amount of the uncompressed frame data can be very large if video size is
* large.
*
* @param enable Set to true to instruct the camera HAL to store meta data
* in the video buffers; false to instruct the camera HAL to store real
* YUV data in the video buffers.
*
* @return status OK on success.
*/
storeMetaDataInBuffers(bool enable) generates (Status status);
/**
* Start record mode.
*
* When a record image is available, a CAMERA_MSG_VIDEO_FRAME message is
* sent with the corresponding frame. Every record frame must be released by
* a camera HAL client via releaseRecordingFrame() before the client calls
* disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
* disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
* responsibility to manage the life-cycle of the video recording frames,
* and the client must not modify/access any video recording frames.
*
* @return status The status code for the operation.
*/
startRecording() generates (Status status);
/**
* Stop a previously started recording.
*/
stopRecording();
/**
* Returns true if recording is enabled.
*
* @return enabled True if recording is currently active.
*/
recordingEnabled() generates (bool enabled);
/**
* Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
*
* It is camera HAL client's responsibility to release video recording
* frames sent out by the camera HAL before the camera HAL receives a call
* to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
* disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
* responsibility to manage the life-cycle of the video recording frames.
*
* @param data The memory buffer to release a recording frame from.
* @param bufferIndex The specific buffer index to return to the HAL.
*/
releaseRecordingFrame(MemoryId data, uint32_t bufferIndex);
/**
* Start auto focus.
*
* The notification callback routine is called with
* CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() can be
* called again after that if another auto focus is needed.
*
* @return status The status code for this operation.
*/
autoFocus() generates (Status status);
/**
* Cancels auto-focus function.
*
* If the auto-focus is still in progress, this function must cancel
* it. Whether the auto-focus is in progress or not, this function must
* return the focus position to the default. If the camera does not support
* auto-focus, this is a no-op.
*
* @return status The status code for this operation.
*/
cancelAutoFocus() generates (Status status);
/**
* Take a picture.
*
* @return status The status code for this operation.
*/
takePicture() generates (Status status);
/**
* Cancel a picture that was started with takePicture. Calling this method
* when no picture is being taken is a no-op.
*
* @return status The status code for this operation.
*/
cancelPicture() generates (Status status);
/**
* Set the camera parameters.
*
* @param parms The parameter string, consisting of
* '<key1>=<value1>; ...;<keyN>=<valueN>'.
* @return status The status code for this operation:
* OK: Parameter update was successful
* ILLEGAL_ARGUMENT: At least one parameter was invalid or not supported
*
*/
setParameters(string parms) generates (Status status);
/**
* Retrieve the camera parameters.
*/
getParameters() generates (string parms);
/**
* Send command to camera driver.
* The meaning of the arguments is defined by the value of cmd, documented
* in the CommandType definition.
*
* @param cmd The command to invoke.
* @param arg1 The first argument for the command, if needed.
* @param arg2 The second argument for the command, if needed.
*
* @return status The status code for this operation.
*/
sendCommand(CommandType cmd, int32_t arg1, int32_t arg2)
generates (Status status);
/**
* Release the hardware resources owned by this object, shutting down the
* camera device.
*/
close();
};

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.device@1.0;
interface ICameraDeviceCallback {
/**
* Notify the camera service of a particular event occurring
* The meaning of each parameter is defined by the value of msgType, and
* documented in the definition of NotifyCallbackMsg.
*
* @param msgType The type of the event.
* @param ext1 The first parameter for the event, if needed.
* @param ext2 The second parameter for the event, if needed.
*/
notifyCallback(NotifyCallbackMsg msgType, int32_t ext1, int32_t ext2);
/**
* Define a memory buffer from the provided handle and size, and return a
* unique identifier for the HAL to use to reference it with.
*
* TODO(b/33269977): Ensure this aligns with design and performance goals.
*
* @param descriptor A native handle that must have exactly one file
* descriptor in it; the file descriptor must be memory mappable to
* bufferSize * bufferCount bytes.
* @param bufferSize The number of bytes a single buffer consists of.
* @param bufferCount The number of contiguous buffers that the descriptor
* contains.
*
* @return memId A integer identifier for this memory buffer, for use with
* data callbacks and unregistering memory.
*/
registerMemory(handle descriptor, uint32_t bufferSize, uint32_t bufferCount)
generates (MemoryId memId);
/**
* Unregister a previously registered memory buffer
*/
unregisterMemory(MemoryId memId);
/**
* Send a buffer of image data to the camera service
*
* @param msgType The kind of image buffer data this call represents.
* @param data A memory handle to the buffer containing the data.
* @param bufferIndex The offset into the memory handle where the buffer
* starts.
*
*/
dataCallback(DataCallbackMsg msgType, MemoryId data, uint32_t bufferIndex);
/**
* Send a buffer of image data to the camera service, with a timestamp
*
* @param msgType The kind of image buffer data this call represents.
* @param data A memory handle to the buffer containing the data.
* @param bufferIndex The offset into the memory handle where the buffer
* starts.
* @param timestamp The time this buffer was captured by the camera, in
* nanoseconds.
*
*/
dataCallbackTimestamp(DataCallbackMsg msgType, MemoryId data, uint32_t bufferIndex,
int64_t timestamp);
};

View File

@@ -0,0 +1,118 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.device@1.0;
import android.hardware.camera.common@1.0::types;
import android.hardware.graphics.allocator@2.0::types;
import android.hardware.graphics.common@1.0::types;
/**
* Camera device HAL@1.0 preview stream operation interface.
*/
interface ICameraDevicePreviewCallback {
/**
* Acquire a buffer to write a preview buffer into.
*
* @return status The status code for this operation. If not OK, then
* buffer and stride must not be used.
* @return buffer A handle to the buffer to write into.
* @return stride The stride between two rows of pixels in this buffer.
*/
dequeueBuffer() generates (Status status, handle buffer, uint32_t stride);
/**
* Send a filled preview buffer to its consumer.
*
* @param buffer The handle to the preview buffer that's been filled.
* @return status The status code for this operation.
*/
enqueueBuffer(handle buffer) generates (Status status);
/**
* Return a preview buffer unfilled. This buffer must not be sent on to the
* preview consumer as a valid buffer, but may be reused as if it were
* empty.
*
* @param buffer The handle to the preview buffer to return.
* @return status The status code for this operation.
*/
cancelBuffer(handle buffer) generates (Status status);
/**
* Set the number of preview buffers needed by the HAL.
*
* @param count The maximum number of preview buffers to allocate.
* @return status The status code for this operation.
*/
setBufferCount(uint32_t count) generates (Status status);
/**
* Set the dimensions and format of future preview buffers.
*
* The next buffer that is dequeued must match the requested size and
* format.
*
* @return Status The status code for this operation.
*/
setBuffersGeometry(uint32_t w, uint32_t h,
android.hardware.graphics.common@1.0::PixelFormat format)
generates (Status status);
/**
* Set the valid region of image data for the next buffer(s) to be enqueued.
*
* @return Status The status code for this operation.
*/
setCrop(int32_t left, int32_t top, int32_t right, int32_t bottom)
generates (Status status);
/**
* Set the producer usage flags for the next buffer(s) to be enqueued.
*
* @return Status The status code for this operation.
*/
setUsage(ProducerUsage usage) generates (Status status);
/**
* Set the expected buffering mode for the preview output.
*/
setSwapInterval(int32_t interval) generates (Status status);
/**
* Get the minimum number of buffers the preview consumer endpoint needs
* to hold for correct operation.
*
* @return Status The status code for this operation.
* @return count The number of buffers the consumer has requested.
*/
getMinUndequeuedBufferCount() generates (Status status, uint32_t count);
/**
* Set the timestamp for the next buffer to enqueue
*
* Timestamps are measured in nanoseconds, and must be comparable
* and monotonically increasing between two frames in the same
* preview stream. They do not need to be comparable between
* consecutive or parallel preview streams, cameras, or app runs.
*
* @param timestamp The timestamp to set for future buffers.
* @return Status The status code for this operation.
*/
setTimestamp(int64_t timestamp) generates (Status status);
};

194
camera/device/1.0/types.hal Normal file
View File

@@ -0,0 +1,194 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.device@1.0;
enum CameraFacing : uint32_t {
/** The facing of the camera is opposite to that of the screen. */
BACK = 0,
/** The facing of the camera is the same as that of the screen. */
FRONT = 1,
/**
* The facing of the camera is not fixed relative to the screen.
* The cameras with this facing are external cameras, e.g. USB cameras.
*/
EXTERNAL = 2
};
/**
* Basic information about a camera device, always accessible via
* ICameraDevice::getCameraInfo().
*/
struct CameraInfo {
/**
* The direction that this device faces.
*/
CameraFacing facing;
/**
* The orientation of the camera image. The value is the angle that the
* camera image needs to be rotated clockwise so it shows correctly on the
* display in its natural orientation. It must be 0, 90, 180, or 270.
*
* For example, suppose a device has a naturally tall screen. The
* back-facing camera sensor is mounted in landscape. You are looking at the
* screen. If the top side of the camera sensor is aligned with the right
* edge of the screen in natural orientation, the value must be 90. If the
* top side of a front-facing camera sensor is aligned with the right of the
* screen, the value must be 270.
*
* An external camera device must leave this set to 0.
*
*/
uint32_t orientation;
};
/**
* Message types for ICameraDevice@1.0::enableMsgType()/disableMsgType()
*
* A set of bit masks for specifying how the received preview frames are
* handled before the previewCallback() call.
*
* The least significant 3 bits of an "int" value are used for this purpose:
*
* ..... 0 0 0
* ^ ^ ^
* | | |---------> determine whether the callback is enabled or not
* | |-----------> determine whether the callback is one-shot or not
* |-------------> determine whether the frame is copied out or not
*
* WARNING: When a frame is sent directly without copying, it is the frame
* receiver's responsiblity to make sure that the frame data won't get
* corrupted by subsequent preview frames filled by the camera. This flag is
* recommended only when copying out data brings significant performance price
* and the handling/processing of the received frame data is always faster than
* the preview frame rate so that data corruption won't occur.
*
* For instance,
* 1. 0x00 disables the callback. In this case, copy out and one shot bits
* are ignored.
* 2. 0x01 enables a callback without copying out the received frames. A
* typical use case is the Camcorder application to avoid making costly
* frame copies.
* 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical
* use case is the Camera application.
* 4. 0x07 is enabling a callback with frame copied out only once. A typical
* use case is the Barcode scanner application.
*/
enum FrameCallbackFlags : uint32_t {
ENABLE_MASK = 0x01,
ONE_SHOT_MASK = 0x02,
COPY_OUT_MASK = 0x04,
/** Typical use cases */
NOOP = 0x00,
CAMCORDER = 0x01,
CAMERA = 0x05,
BARCODE_SCANNER = 0x07
};
/**
* Subset of commands in /system/core/include/system/camera.h relevant for
* ICameraDevice@1.0::sendCommand()
*/
enum CommandType : uint32_t {
START_SMOOTH_ZOOM = 1,
STOP_SMOOTH_ZOOM = 2,
/**
* Start the face detection. This must be called only after preview is
* started. The camera must notify the listener of CAMERA_MSG_FACE and the
* detected faces in the preview frame. The detected faces may be the same
* as the previous ones. Apps must call CAMERA_CMD_STOP_FACE_DETECTION to
* stop the face detection. This method is supported if CameraParameters
* KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is bigger
* than 0. Hardware and software face detection must not be running at the
* same time. If the face detection has started, apps must not send this
* again.
*
* In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE,
* KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect.
*
* arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or
* CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not
* supported, the HAL must return BAD_VALUE.
*/
START_FACE_DETECTION = 6,
/**
* Stop the face detection.
*/
STOP_FACE_DETECTION = 7,
/**
* Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing
* arg1 = 0 must disable, while passing arg1 = 1 must enable the callback.
*/
ENABLE_FOCUS_MOVE_MSG = 8,
/**
* Configure an explicit format to use for video recording metadata mode.
* This can be used to switch the format from the
* default IMPLEMENTATION_DEFINED gralloc format to some other
* device-supported format, and the default dataspace from the BT_709 color
* space to some other device-supported dataspace. arg1 is the HAL pixel
* format, and arg2 is the HAL dataSpace. This command returns
* INVALID_OPERATION error if it is sent after video recording is started,
* or the command is not supported at all.
*
* If the gralloc format is set to a format other than
* IMPLEMENTATION_DEFINED, then HALv3 devices must use gralloc usage flags
* of SW_READ_OFTEN.
*/
SET_VIDEO_FORMAT = 11
};
/**
* Message types for ICameraDevice1Callback::notifyCallback()
*/
enum NotifyCallbackMsg : uint32_t {
ERROR = 0x0001,
SHUTTER = 0x0002,
FOCUS = 0x0004,
ZOOM = 0x0008,
// Notify on autofocus start and stop. This is useful in continuous
// autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE.
FOCUS_MOVE = 0x0800
};
/**
* Message types for ICameraDevice1Callback::dataCallback() and
* ICameraDevice1Callback::dataCallbackTimestamp()
*/
enum DataCallbackMsg : uint32_t {
PREVIEW_FRAME = 0x0010,
VIDEO_FRAME = 0x0020,
POSTVIEW_FRAME = 0x0040,
RAW_IMAGE = 0x0080,
COMPRESSED_IMAGE = 0x0100,
RAW_IMAGE_NOTIFY = 0x0200,
// Preview frame metadata. This can be combined with
// CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can
// request FRAME and METADATA. Or the apps can request only FRAME or only
// METADATA.
PREVIEW_METADATA = 0x0400
};
/*
* A simple integer handle to use to reference a particular memory buffer
* between the HAL and the framework.
*/
typedef uint32_t MemoryId;

View File

@@ -0,0 +1,76 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
genrule {
name: "android.hardware.camera.device@3.2_genc++",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.device@3.2",
srcs: [
"types.hal",
"ICameraDevice.hal",
"ICameraDeviceCallback.hal",
"ICameraDeviceSession.hal",
],
out: [
"android/hardware/camera/device/3.2/types.cpp",
"android/hardware/camera/device/3.2/CameraDeviceAll.cpp",
"android/hardware/camera/device/3.2/CameraDeviceCallbackAll.cpp",
"android/hardware/camera/device/3.2/CameraDeviceSessionAll.cpp",
],
}
genrule {
name: "android.hardware.camera.device@3.2_genc++_headers",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.device@3.2",
srcs: [
"types.hal",
"ICameraDevice.hal",
"ICameraDeviceCallback.hal",
"ICameraDeviceSession.hal",
],
out: [
"android/hardware/camera/device/3.2/types.h",
"android/hardware/camera/device/3.2/ICameraDevice.h",
"android/hardware/camera/device/3.2/IHwCameraDevice.h",
"android/hardware/camera/device/3.2/BnCameraDevice.h",
"android/hardware/camera/device/3.2/BpCameraDevice.h",
"android/hardware/camera/device/3.2/BsCameraDevice.h",
"android/hardware/camera/device/3.2/ICameraDeviceCallback.h",
"android/hardware/camera/device/3.2/IHwCameraDeviceCallback.h",
"android/hardware/camera/device/3.2/BnCameraDeviceCallback.h",
"android/hardware/camera/device/3.2/BpCameraDeviceCallback.h",
"android/hardware/camera/device/3.2/BsCameraDeviceCallback.h",
"android/hardware/camera/device/3.2/ICameraDeviceSession.h",
"android/hardware/camera/device/3.2/IHwCameraDeviceSession.h",
"android/hardware/camera/device/3.2/BnCameraDeviceSession.h",
"android/hardware/camera/device/3.2/BpCameraDeviceSession.h",
"android/hardware/camera/device/3.2/BsCameraDeviceSession.h",
],
}
cc_library_shared {
name: "android.hardware.camera.device@3.2",
generated_sources: ["android.hardware.camera.device@3.2_genc++"],
generated_headers: ["android.hardware.camera.device@3.2_genc++_headers"],
export_generated_headers: ["android.hardware.camera.device@3.2_genc++_headers"],
shared_libs: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"liblog",
"libutils",
"libcutils",
"android.hardware.camera.common@1.0",
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
"android.hardware.camera.common@1.0",
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
],
}

View File

@@ -0,0 +1,199 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.device@3.2;
import android.hardware.camera.common@1.0::types;
import ICameraDeviceSession;
import ICameraDeviceCallback;
/**
* Camera device HAL, first modern version
*
* Supports the android.hardware.Camera API, and the android.hardware.camera2
* API at LIMITED or better hardware level.
*
*/
interface ICameraDevice {
/**
* Get camera device resource cost information.
*
* @return status Status code for the operation, one of:
* OK:
* On success
* INTERNAL_ERROR:
* An unexpected internal camera HAL error occurred, and the
* resource cost is not available.
* CAMERA_DISCONNECTED:
* An external camera device has been disconnected, and is no longer
* available. This camera device interface is now stale, and a new
* instance must be acquired if the device is reconnected. All
* subsequent calls on this interface must return
* CAMERA_DISCONNECTED.
* @return resourceCost
* The resources required to open this camera device, or unspecified
* values if status is not OK.
*/
getResourceCost() generates (Status status, CameraResourceCost resourceCost);
/**
* getCameraCharacteristics:
*
* Return the static camera information for this camera device. This
* information may not change between consecutive calls.
*
* When an external camera is disconnected, its camera id becomes
* invalid. Calling this method with this invalid camera id must result in
* ILLEGAL_ARGUMENT; this may happen even before the device status callback
* is invoked by the HAL.
*
* @return status Status code for the operation, one of:
* OK:
* On a successful open of the camera device.
* INTERNAL_ERROR:
* The camera device cannot be opened due to an internal
* error.
* CAMERA_DISCONNECTED:
* An external camera device has been disconnected, and is no longer
* available. This camera device interface is now stale, and a new
* instance must be acquired if the device is reconnected. All
* subsequent calls on this interface must return
* CAMERA_DISCONNECTED.
*
* @return cameraCharacteristics
* The static metadata for this camera device, or an empty metadata
* structure if status is not OK.
*
*/
getCameraCharacteristics() generates
(Status status, CameraMetadata cameraCharacteristics);
/**
* setTorchMode:
*
* Turn on or off the torch mode of the flash unit associated with this
* camera device. If the operation is successful, HAL must notify the
* framework torch state by invoking
* ICameraProviderCallback::torchModeStatusChange() with the new state.
*
* An active camera session has a higher priority accessing the flash
* unit. When there are any resource conflicts, such as when open() is
* called to fully activate a camera device, the provider must notify the
* framework through ICameraProviderCallback::torchModeStatusChange() 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, the provider must notify the framework through
* ICameraProviderCallback::torchModeStatusChange() that the torch mode
* state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to
* be called.
*
* When the client calls setTorchMode() to turn on the torch mode of a flash
* unit, if the HAL cannot keep multiple torch modes on simultaneously, the
* HAL must turn off the torch mode(s) that were turned on by previous
* setTorchMode() calls and notify the framework that the torch mode state
* of those flash unit(s) has become TORCH_MODE_STATUS_AVAILABLE_OFF.
*
* @param torchMode The new mode to set the device flash unit to.
*
* @return status Status code for the operation, one of:
* OK:
* On a successful change to the torch state
* INTERNAL_ERROR:
* The flash unit cannot be operated due to an unexpected internal
* error.
* ILLEGAL_ARGUMENT:
* The camera ID is unknown.
* CAMERA_IN_USE:
* This camera device has been opened, so the torch cannot be
* controlled until it is closed.
* MAX_CAMERAS_IN_USE:
* Due to other camera devices being open, or due to other
* resource constraints, the torch cannot be controlled currently.
* METHOD_NOT_SUPPORTED:
* This provider does not support direct operation of flashlight
* torch mode. The framework must open the camera device and turn
* the torch on through the device interface.
* OPERATION_NOT_SUPPORTED:
* This camera device does not have a flash unit. This can
* be returned if and only if android.flash.info.available is
* false.
* CAMERA_DISCONNECTED:
* An external camera device has been disconnected, and is no longer
* available. This camera device interface is now stale, and a new
* instance must be acquired if the device is reconnected. All
* subsequent calls on this interface must return
* CAMERA_DISCONNECTED.
*
*/
setTorchMode(TorchMode mode) generates (Status status);
/**
* open:
*
* Power on and initialize this camera device for active use, returning a
* session handle for active operations.
*
* @param callback Interface to invoke by the HAL for device asynchronous
* events.
* @return status Status code for the operation, one of:
* OK:
* On a successful open of the camera device.
* INTERNAL_ERROR:
* The camera device cannot be opened due to an internal
* error.
* ILLEGAL_ARGUMENT:
* The callbacks handle is invalid (for example, it is null).
* CAMERA_IN_USE:
* This camera device is already open.
* MAX_CAMERAS_IN_USE:
* The maximal number of camera devices that can be
* opened concurrently were opened already.
* CAMERA_DISCONNECTED:
* This external camera device has been disconnected, and is no
* longer available. This interface is now stale, and a new instance
* must be acquired if the device is reconnected. All subsequent
* calls on this interface must return CAMERA_DISCONNECTED.
* @return cameraDevice The interface to the newly-opened camera session,
* or null if status is not OK.
*/
open(ICameraDeviceCallback callback) generates
(Status status, ICameraDeviceSession session);
/**
* dumpState:
*
* Print out debugging state for the camera device. This may be called by
* the framework when the camera service is asked for a debug dump, which
* happens when using the dumpsys tool, or when capturing a bugreport.
*
* The passed-in file descriptor can be used to write debugging text using
* dprintf() or write(). The text must be in ASCII encoding only.
*
* In case this camera device has been disconnected, the dump must not fail,
* but may simply print out 'Device disconnected' or equivalent.
*
* Performance requirements:
*
* This must be a non-blocking call. The HAL should return from this call
* in 1ms, must return from this call in 10ms. This call must avoid
* deadlocks, as it may be called at any point during camera operation.
* Any synchronization primitives used (such as mutex locks or semaphores)
* must be acquired with a timeout.
*/
dumpState(handle fd);
};

View File

@@ -0,0 +1,126 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.device@3.2;
import android.hardware.camera.common@1.0::types;
/**
*
* Callback methods for the HAL to call into the framework.
*
* These methods are used to return metadata and image buffers for a completed
* or failed captures, and to notify the framework of asynchronous events such
* as errors.
*
* The framework must not call back into the HAL from within these callbacks,
* and these calls must not block for extended periods.
*
*/
interface ICameraDeviceCallback {
/**
* processCaptureResult:
*
* Send results from a completed capture to the framework.
* processCaptureResult() may be invoked multiple times by the HAL in
* response to a single capture request. This allows, for example, the
* metadata and low-resolution buffers to be returned in one call, and
* post-processed JPEG buffers in a later call, once it is available. Each
* call must include the frame number of the request it is returning
* metadata or buffers for.
*
* A component (buffer or metadata) of the complete result may only be
* included in one process_capture_result call. A buffer for each stream,
* and the result metadata, must be returned by the HAL for each request in
* one of the processCaptureResult calls, even in case of errors producing
* some of the output. A call to processCaptureResult() with neither
* output buffers or result metadata is not allowed.
*
* The order of returning metadata and buffers for a single result does not
* matter, but buffers for a given stream must be returned in FIFO order. So
* the buffer for request 5 for stream A must always be returned before the
* buffer for request 6 for stream A. This also applies to the result
* metadata; the metadata for request 5 must be returned before the metadata
* for request 6.
*
* However, different streams are independent of each other, so it is
* acceptable and expected that the buffer for request 5 for stream A may be
* returned after the buffer for request 6 for stream B is. And it is
* acceptable that the result metadata for request 6 for stream B is
* returned before the buffer for request 5 for stream A is.
*
* The HAL retains ownership of result structure, which only needs to be
* valid to access during this call. The framework must copy whatever it
* needs before this call returns.
*
* The output buffers do not need to be filled yet; the framework must wait
* on the stream buffer release sync fence before reading the buffer
* data. Therefore, this method should be called by the HAL as soon as
* possible, even if some or all of the output buffers are still in
* being filled. The HAL must include valid release sync fences into each
* output_buffers stream buffer entry, or -1 if that stream buffer is
* already filled.
*
* If the result buffer cannot be constructed for a request, the HAL must
* return an empty metadata buffer, but still provide the output buffers and
* their sync fences. In addition, notify() must be called with an
* ERROR_RESULT message.
*
* If an output buffer cannot be filled, its status field must be set to
* STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER
* message.
*
* If the entire capture has failed, then this method still needs to be
* called to return the output buffers to the framework. All the buffer
* statuses must be STATUS_ERROR, and the result metadata must be an
* empty buffer. In addition, notify() must be called with a ERROR_REQUEST
* message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages
* must not be sent.
*
* Performance requirements:
*
* This is a non-blocking call. The framework must return this call in 5ms.
*
* The pipeline latency (see S7 for definition) should be less than or equal to
* 4 frame intervals, and must be less than or equal to 8 frame intervals.
*
*/
processCaptureResult(CaptureResult result);
/**
* notify:
*
* Asynchronous notification callback from the HAL, fired for various
* reasons. Only for information independent of frame capture, or that
* require specific timing.
*
* Multiple threads may call notify() simultaneously.
*
* Buffers delivered to the framework must not be dispatched to the
* application layer until a start of exposure timestamp (or input image's
* start of exposure timestamp for a reprocess request) has been received
* via a SHUTTER notify() call. It is highly recommended to dispatch this
* call as early as possible.
*
* ------------------------------------------------------------------------
* Performance requirements:
*
* This is a non-blocking call. The framework must return this call in 5ms.
*/
notify(NotifyMsg msg);
};

View File

@@ -0,0 +1,360 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.device@3.2;
import android.hardware.camera.common@1.0::types;
/**
* Camera device active session interface.
*
* Obtained via ICameraDevice::open(), this interface contains the methods to
* configure and request captures from an active camera device.
*
*/
interface ICameraDeviceSession {
/**
* constructDefaultRequestSettings:
*
* Create capture settings for standard camera use cases.
*
* The device must return a settings buffer that is configured to meet the
* requested use case, which must be one of the CAMERA3_TEMPLATE_*
* enums. All request control fields must be included.
*
* Performance requirements:
*
* This must be a non-blocking call. The HAL should return from this call
* in 1ms, and must return from this call in 5ms.
*
* Return values:
* @return status Status code for the operation, one of:
* OK:
* On a successful construction of default settings.
* INTERNAL_ERROR:
* An unexpected internal error occurred, and the default settings
* are not available.
* CAMERA_DISCONNECTED:
* An external camera device has been disconnected, and is no longer
* available. This camera device interface is now stale, and a new
* instance must be acquired if the device is reconnected. All
* subsequent calls on this interface must return
* CAMERA_DISCONNECTED.
* @return template The default capture request settings for the requested
* use case, or an empty metadata structure if status is not OK.
*
*/
constructDefaultRequestSettings(RequestTemplate type) generates
(Status status, CameraMetadata requestTemplate);
/**
* configureStreams:
*
* Reset the HAL camera device processing pipeline and set up new input and
* output streams. This call replaces any existing stream configuration with
* the streams defined in the streamList. This method must be called at
* least once before a request is submitted with processCaptureRequest().
*
* The streamList must contain at least one output-capable stream, and may
* not contain more than one input-capable stream.
*
* The streamList may contain streams that are also in the currently-active
* set of streams (from the previous call to configureStreams()). These
* streams must already have valid values for usage, maxBuffers, and the
* private pointer.
*
* If the HAL needs to change the stream configuration for an existing
* stream due to the new configuration, it may rewrite the values of usage
* and/or maxBuffers during the configure call.
*
* The framework must detect such a change, and may then reallocate the
* stream buffers before using buffers from that stream in a request.
*
* If a currently-active stream is not included in streamList, the HAL may
* safely remove any references to that stream. It must not be reused in a
* later configureStreams() call by the framework, and all the gralloc
* buffers for it must be freed after the configureStreams() call returns.
*
* If the stream is new, the maxBuffer field of the stream structure must be
* set to 0. The usage must be set to the consumer usage flags. The HAL
* device must set these fields in the configureStreams() return values.
* These fields are then used by the framework and the platform gralloc
* module to allocate the gralloc buffers for each stream.
*
* Newly allocated buffers may be included in a capture request at any time
* by the framework. Once a gralloc buffer is returned to the framework
* with processCaptureResult (and its respective releaseFence has been
* signaled) the framework may free or reuse it at any time.
*
* ------------------------------------------------------------------------
*
* Preconditions:
*
* The framework must only call this method when no captures are being
* processed. That is, all results have been returned to the framework, and
* all in-flight input and output buffers have been returned and their
* release sync fences have been signaled by the HAL. The framework must not
* submit new requests for capture while the configureStreams() call is
* underway.
*
* Postconditions:
*
* The HAL device must configure itself to provide maximum possible output
* frame rate given the sizes and formats of the output streams, as
* documented in the camera device's static metadata.
*
* Performance requirements:
*
* This call is expected to be heavyweight and possibly take several hundred
* milliseconds to complete, since it may require resetting and
* reconfiguring the image sensor and the camera processing pipeline.
* Nevertheless, the HAL device should attempt to minimize the
* reconfiguration delay to minimize the user-visible pauses during
* application operational mode changes (such as switching from still
* capture to video recording).
*
* The HAL should return from this call in 500ms, and must return from this
* call in 1000ms.
*
* @return Status Status code for the operation, one of:
* OK:
* On successful stream configuration.
* INTERNAL_ERROR:
* If there has been a fatal error and the device is no longer
* operational. Only close() can be called successfully by the
* framework after this error is returned.
* ILLEGAL_ARGUMENT:
* If the requested stream configuration is invalid. Some examples
* of invalid stream configurations include:
* - Including more than 1 INPUT stream
* - Not including any OUTPUT streams
* - Including streams with unsupported formats, or an unsupported
* size for that format.
* - Including too many output streams of a certain format.
* - Unsupported rotation configuration
* - Stream sizes/formats don't satisfy the
* camera3_stream_configuration_t->operation_mode requirements
* for non-NORMAL mode, or the requested operation_mode is not
* supported by the HAL.
* The camera service cannot filter out all possible illegal stream
* configurations, since some devices may support more simultaneous
* streams or larger stream resolutions than the minimum required
* for a given camera device hardware level. The HAL must return an
* ILLEGAL_ARGUMENT for any unsupported stream set, and then be
* ready to accept a future valid stream configuration in a later
* configureStreams call.
* @return finalConfiguration The stream parameters desired by the HAL for
* each stream, including maximum buffers, the usage flags, and the
* override format.
*
*/
configureStreams(StreamConfiguration requestedConfiguration)
generates (Status status,
HalStreamConfiguration halConfiguration);
/**
* processCaptureRequest:
*
* Send a new capture request to the HAL. The HAL must not return from
* this call until it is ready to accept the next request to process. Only
* one call to processCaptureRequest() must be made at a time by the
* framework, and the calls must all be from the same thread. The next call
* to processCaptureRequest() must be made as soon as a new request and
* its associated buffers are available. In a normal preview scenario, this
* means the function is generally called again by the framework almost
* instantly.
*
* The actual request processing is asynchronous, with the results of
* capture being returned by the HAL through the processCaptureResult()
* call. This call requires the result metadata to be available, but output
* buffers may simply provide sync fences to wait on. Multiple requests are
* expected to be in flight at once, to maintain full output frame rate.
*
* The framework retains ownership of the request structure. It is only
* guaranteed to be valid during this call. The HAL device must make copies
* of the information it needs to retain for the capture processing. The HAL
* is responsible for waiting on and closing the buffers' fences and
* returning the buffer handles to the framework.
*
* The HAL must write the file descriptor for the input buffer's release
* sync fence into input_buffer->release_fence, if input_buffer is not
* valid. If the HAL returns -1 for the input buffer release sync fence, the
* framework is free to immediately reuse the input buffer. Otherwise, the
* framework must wait on the sync fence before refilling and reusing the
* input buffer.
*
* The input/output buffers provided by the framework in each request
* may be brand new (having never before seen by the HAL).
*
* ------------------------------------------------------------------------
* Performance considerations:
*
* Handling a new buffer should be extremely lightweight and there must be
* no frame rate degradation or frame jitter introduced.
*
* This call must return fast enough to ensure that the requested frame
* rate can be sustained, especially for streaming cases (post-processing
* quality settings set to FAST). The HAL should return this call in 1
* frame interval, and must return from this call in 4 frame intervals.
*
* @return status Status code for the operation, one of:
* OK:
* On a successful start to processing the capture request
* ILLEGAL_ARGUMENT:
* If the input is malformed (the settings are empty when not
* allowed, there are 0 output buffers, etc) and capture processing
* cannot start. Failures during request processing must be
* handled by calling ICameraDeviceCallback::notify(). In case of
* this error, the framework retains responsibility for the
* stream buffers' fences and the buffer handles; the HAL must not
* close the fences or return these buffers with
* ICameraDeviceCallback::processCaptureResult().
* INTERNAL_ERROR:
* If the camera device has encountered a serious error. After this
* error is returned, only the close() method can be successfully
* called by the framework.
*
*/
processCaptureRequest(CaptureRequest request)
generates (Status status);
/**
* flush:
*
* Flush all currently in-process captures and all buffers in the pipeline
* on the given device. Generally, this method is used to dump all state as
* quickly as possible in order to prepare for a configure_streams() call.
*
* No buffers are required to be successfully returned, so every buffer
* held at the time of flush() (whether successfully filled or not) may be
* returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed
* to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call,
* provided they are successfully filled.
*
* All requests currently in the HAL are expected to be returned as soon as
* possible. Not-in-process requests must return errors immediately. Any
* interruptible hardware blocks must be stopped, and any uninterruptible
* blocks must be waited on.
*
* flush() may be called concurrently to processCaptureRequest(), with the
* expectation that processCaptureRequest returns quickly and the
* request submitted in that processCaptureRequest call is treated like
* all other in-flight requests. Due to concurrency issues, it is possible
* that from the HAL's point of view, a processCaptureRequest() call may
* be started after flush has been invoked but has not returned yet. If such
* a call happens before flush() returns, the HAL must treat the new
* capture request like other in-flight pending requests (see #4 below).
*
* More specifically, the HAL must follow below requirements for various
* cases:
*
* 1. For captures that are too late for the HAL to cancel/stop, and must be
* completed normally by the HAL; i.e. the HAL can send shutter/notify
* and processCaptureResult and buffers as normal.
*
* 2. For pending requests that have not done any processing, the HAL must
* call notify CAMERA3_MSG_ERROR_REQUEST, and return all the output
* buffers with processCaptureResult in the error state
* (CAMERA3_BUFFER_STATUS_ERROR). The HAL must not place the release
* fence into an error state, instead, the release fences must be set to
* the acquire fences passed by the framework, or -1 if they have been
* waited on by the HAL already. This is also the path to follow for any
* captures for which the HAL already called notify() with
* CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers
* for. After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only
* processCaptureResults with buffers in CAMERA3_BUFFER_STATUS_ERROR
* are allowed. No further notifys or processCaptureResult with
* non-empty metadata is allowed.
*
* 3. For partially completed pending requests that do not have all the
* output buffers or perhaps missing metadata, the HAL must follow
* below:
*
* 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected
* result metadata (i.e. one or more partial metadata) won't be
* available for the capture.
*
* 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that
* won't be produced for the capture.
*
* 3.3. Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp
* before any buffers/metadata are returned with
* processCaptureResult.
*
* 3.4. For captures that will produce some results, the HAL must not
* call CAMERA3_MSG_ERROR_REQUEST, since that indicates complete
* failure.
*
* 3.5. Valid buffers/metadata must be passed to the framework as
* normal.
*
* 3.6. Failed buffers must be returned to the framework as described
* for case 2. But failed buffers do not have to follow the strict
* ordering valid buffers do, and may be out-of-order with respect
* to valid buffers. For example, if buffers A, B, C, D, E are sent,
* D and E are failed, then A, E, B, D, C is an acceptable return
* order.
*
* 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is
* sufficient, no need to call processCaptureResult with empty
* metadata or equivalent.
*
* 4. If a flush() is invoked while a processCaptureRequest() invocation
* is active, that process call must return as soon as possible. In
* addition, if a processCaptureRequest() call is made after flush()
* has been invoked but before flush() has returned, the capture request
* provided by the late processCaptureRequest call must be treated
* like a pending request in case #2 above.
*
* flush() must only return when there are no more outstanding buffers or
* requests left in the HAL. The framework may call configure_streams (as
* the HAL state is now quiesced) or may issue new requests.
*
* Note that it's sufficient to only support fully-succeeded and
* fully-failed result cases. However, it is highly desirable to support
* the partial failure cases as well, as it could help improve the flush
* call overall performance.
*
* Performance requirements:
*
* The HAL should return from this call in 100ms, and must return from this
* call in 1000ms. And this call must not be blocked longer than pipeline
* latency (see S7 for definition).
*
* @return status Status code for the operation, one of:
* OK:
* On a successful flush of the camera HAL.
* INTERNAL_ERROR:
* If the camera device has encountered a serious error. After this
* error is returned, only the close() method can be successfully
* called by the framework.
*/
flush() generates (Status status);
/**
* close:
*
* Shut down the camera device.
*
* After this call, all calls to this session instance must return
* INTERNAL_ERROR.
*
* This method must always succeed, even if the device has encountered a
* serious error.
*/
close();
};

920
camera/device/3.2/types.hal Normal file
View File

@@ -0,0 +1,920 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.device@3.2;
import android.hardware.graphics.allocator@2.0::types;
import android.hardware.graphics.common@1.0::types;
typedef vec<uint8_t> CameraMetadata;
/**
* StreamType:
*
* The type of the camera stream, which defines whether the camera HAL device is
* the producer or the consumer for that stream, and how the buffers of the
* stream relate to the other streams.
*/
enum StreamType : uint32_t {
/**
* This stream is an output stream; the camera HAL device must fill buffers
* from this stream with newly captured or reprocessed image data.
*/
OUTPUT = 0,
/**
* This stream is an input stream; the camera HAL device must read buffers
* from this stream and send them through the camera processing pipeline,
* as if the buffer was a newly captured image from the imager.
*
* The pixel format for input stream can be any format reported by
* android.scaler.availableInputOutputFormatsMap. The pixel format of the
* output stream that is used to produce the reprocessing data may be any
* format reported by android.scaler.availableStreamConfigurations. The
* supported input/output stream combinations depends the camera device
* capabilities, see android.scaler.availableInputOutputFormatsMap for
* stream map details.
*
* This kind of stream is generally used to reprocess data into higher
* quality images (that otherwise would cause a frame rate performance
* loss), or to do off-line reprocessing.
*
* The typical use cases are OPAQUE (typically ZSL) and YUV reprocessing,
* see S8.2, S8.3 and S10 for more details.
*/
INPUT = 1
};
/**
* StreamRotation:
*
* The required counterclockwise rotation of camera stream.
*/
enum StreamRotation : uint32_t {
/* No rotation */
ROTATION_0 = 0,
/* Rotate by 90 degree counterclockwise */
ROTATION_90 = 1,
/* Rotate by 180 degree counterclockwise */
ROTATION_180 = 2,
/* Rotate by 270 degree counterclockwise */
ROTATION_270 = 3
};
/**
* StreamConfigurationMode:
*
* This defines the general operation mode for the HAL (for a given stream
* configuration) where modes besides NORMAL have different semantics, and
* usually limit the generality of the API in exchange for higher performance in
* some particular area.
*/
enum StreamConfigurationMode : uint32_t {
/**
* Normal stream configuration operation mode. This is the default camera
* operation mode, where all semantics of HAL APIs and metadata controls
* apply.
*/
NORMAL_MODE = 0,
/**
* Special constrained high speed operation mode for devices that can not
* support high speed output in NORMAL mode. All streams in this
* configuration are operating at high speed mode and have different
* characteristics and limitations to achieve high speed output. The NORMAL
* mode can still be used for high speed output if the HAL can support high
* speed output while satisfying all the semantics of HAL APIs and metadata
* controls. It is recommended for the HAL to support high speed output in
* NORMAL mode (by advertising the high speed FPS ranges in
* android.control.aeAvailableTargetFpsRanges) if possible.
*
* This mode has below limitations/requirements:
*
* 1. The HAL must support up to 2 streams with sizes reported by
* android.control.availableHighSpeedVideoConfigurations.
* 2. In this mode, the HAL is expected to output up to 120fps or
* higher. This mode must support the targeted FPS range and size
* configurations reported by
* android.control.availableHighSpeedVideoConfigurations.
* 3. The HAL must support IMPLEMENTATION_DEFINED output
* stream format.
* 4. To achieve efficient high speed streaming, the HAL may have to
* aggregate multiple frames together and send to camera device for
* processing where the request controls are same for all the frames in
* this batch (batch mode). The HAL must support max batch size and the
* max batch size requirements defined by
* android.control.availableHighSpeedVideoConfigurations.
* 5. In this mode, the HAL must override aeMode, awbMode, and afMode to
* ON, ON, and CONTINUOUS_VIDEO, respectively. All post-processing
* block mode controls must be overridden to be FAST. Therefore, no
* manual control of capture and post-processing parameters is
* possible. All other controls operate the same as when
* android.control.mode == AUTO. This means that all other
* android.control.* fields must continue to work, such as
*
* android.control.aeTargetFpsRange
* android.control.aeExposureCompensation
* android.control.aeLock
* android.control.awbLock
* android.control.effectMode
* android.control.aeRegions
* android.control.afRegions
* android.control.awbRegions
* android.control.afTrigger
* android.control.aePrecaptureTrigger
*
* Outside of android.control.*, the following controls must work:
*
* android.flash.mode (TORCH mode only, automatic flash for still
* capture must not work since aeMode is ON)
* android.lens.opticalStabilizationMode (if it is supported)
* android.scaler.cropRegion
* android.statistics.faceDetectMode (if it is supported)
*
* For more details about high speed stream requirements, see
* android.control.availableHighSpeedVideoConfigurations and
* CONSTRAINED_HIGH_SPEED_VIDEO capability defined in
* android.request.availableCapabilities.
*
* This mode only needs to be supported by HALs that include
* CONSTRAINED_HIGH_SPEED_VIDEO in the android.request.availableCapabilities
* static metadata.
*/
CONSTRAINED_HIGH_SPEED_MODE = 1
};
/**
* Stream:
*
* A descriptor for a single camera input or output stream. A stream is defined
* by the framework by its buffer resolution and format, and additionally by the
* HAL with the gralloc usage flags and the maximum in-flight buffer count.
*
* If a configureStreams() call returns a non-fatal error, all active streams
* remain valid as if configureStreams() had not been called.
*
*/
struct Stream {
/**
* Stream ID - a nonnegative integer identifier for a stream.
*
* The identical stream ID must reference the same stream, with the same
* width/height/format, across consecutive calls to configureStreams.
*
* If previously-used stream ID is not used in a new call to
* configureStreams, then that stream is no longer active. Such a stream ID
* may be reused in a future configureStreams with a new
* width/height/format.
*
*/
int32_t id;
/**
* The type of the stream (input vs output, etc).
*/
StreamType streamType;
/**
* The width in pixels of the buffers in this stream
*/
uint32_t width;
/**
* The height in pixels of the buffers in this stream
*/
uint32_t height;
/**
* The pixel format for the buffers in this stream.
*
* If IMPLEMENTATION_DEFINED is used, then the platform
* gralloc module must select a format based on the usage flags provided by
* the camera device and the other endpoint of the stream.
*
*/
android.hardware.graphics.common@1.0::PixelFormat format;
/**
* The gralloc usage flags for this stream, as needed by the consumer of
* the stream.
*
* The usage flags from the producer and the consumer must be combined
* together and then passed to the platform gralloc HAL module for
* allocating the gralloc buffers for each stream.
*
* For streamType OUTPUT, when passed via
* configureStreams(), the initial value of this is the consumer's usage
* flags. The HAL may use these consumer flags to decide stream
* configuration. For streamType INPUT, when passed via
* configureStreams(), the initial value of this is 0. For all streams
* passed via configureStreams(), the HAL must set its desired producer
* usage flags in the final stream configuration.
*/
ConsumerUsage usage;
/**
* The maximum number of buffers the HAL device may need to have dequeued at
* the same time. The HAL device may not have more buffers in-flight from
* this stream than this value. For all streams passed via
* configureStreams(), the HAL must set its desired max buffer count in the
* final stream configuration.
*/
uint32_t maxBuffers;
/**
* 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
* android.hardware.graphics.common@1.0::types for details of formats and
* valid dataSpace values for each format.
*
* The HAL must use this dataSpace to configure the stream to the correct
* colorspace, or to select between color and depth outputs if
* supported. The dataspace values are set using the V0 dataspace
* definitions.
*/
Dataspace dataSpace;
/**
* The required output rotation of the stream.
*
* 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 must supply buffers of size
* 720x1280, and HAL must capture a 1280x720 image and rotate the image by
* 90 degree counterclockwise. The rotation field must be ignored when the
* stream type is input.
*
* The HAL must inspect this field during stream configuration and return
* IllegalArgument if HAL cannot perform such rotation. HAL must always
* support ROTATION_0, so a configureStreams() call must not fail for
* unsupported rotation if rotation field of all streams is ROTATION_0.
*
*/
StreamRotation rotation;
};
/**
* StreamConfiguration:
*
* A structure of stream definitions, used by configureStreams(). This
* structure defines all the output streams and the reprocessing input
* stream for the current camera use case.
*/
struct StreamConfiguration {
/**
* An array of camera stream pointers, defining the input/output
* configuration for the camera HAL device.
*
* At most one input-capable stream may be defined.
* At least one output-capable stream must be defined.
*/
vec<Stream> streams;
/**
* The operation mode of streams in this configuration. The HAL can use this
* mode as an indicator to set the stream property (e.g.,
* HalStream::maxBuffers) appropriately. For example, if the
* configuration is
* CONSTRAINED_HIGH_SPEED_MODE, the HAL may
* want to set aside more buffers for batch mode operation (see
* android.control.availableHighSpeedVideoConfigurations for batch mode
* definition).
*
*/
StreamConfigurationMode operationMode;
};
/**
* HalStream:
*
* The camera HAL's response to each requested stream configuration.
*
* The HAL may specify the desired format, maximum buffers, and
* usage flags for each stream.
*
*/
struct HalStream {
/**
* Stream ID - a nonnegative integer identifier for a stream.
*
* The ID must be one of the stream IDs passed into configureStreams.
*/
int32_t id;
/**
* The pixel format for the buffers in this stream.
*
* If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
* gralloc module must select a format based on the usage flags provided by
* the camera device and the other endpoint of the stream.
*
* The HAL must respect the requested format in Stream unless it is
* IMPLEMENTATION_DEFINED, in which case the override format here must be
* used instead. This allows cross-platform HALs to use a standard format
* since IMPLEMENTATION_DEFINED formats often require device-specific
* information. In all other cases, the overrideFormat must match the
* requested format.
*/
android.hardware.graphics.common@1.0::PixelFormat overrideFormat;
/**
* The gralloc usage flags for this stream, as needed by the HAL.
*
* For output streams, these are the HAL's producer usage flags. For input
* streams, these are the HAL's consumer usage flags. The usage flags from
* the producer and the consumer must be combined together and then passed
* to the platform graphics allocator HAL for allocating the gralloc buffers
* for each stream.
*
* If the stream's type is INPUT, then producerUsage must be 0, and
* consumerUsage must be set. For other types, producerUsage must be set,
* and consumerUsage must be 0.
*/
ProducerUsage producerUsage;
ConsumerUsage consumerUsage;
/**
* The maximum number of buffers the HAL device may need to have dequeued at
* the same time. The HAL device may not have more buffers in-flight from
* this stream than this value.
*/
uint32_t maxBuffers;
};
/**
* HalStreamConfiguration:
*
* A structure of stream definitions, returned by configureStreams(). This
* structure defines the HAL's desired parameters for each stream.
*
* All streams that were defined in the input to configureStreams() must have a
* corresponding entry in this structure when returned by configureStreams().
*/
struct HalStreamConfiguration {
vec<HalStream> streams;
};
/**
* BufferStatus:
*
* The current status of a single stream buffer.
*/
enum BufferStatus : uint32_t {
/**
* The buffer is in a normal state, and can be used after waiting on its
* sync fence.
*/
OK = 0,
/**
* The buffer does not contain valid data, and the data in it must not be
* used. The sync fence must still be waited on before reusing the buffer.
*/
ERROR = 1
};
/**
* StreamBuffer:
*
* A single buffer from a camera3 stream. It includes a handle to its parent
* stream, the handle to the gralloc buffer itself, and sync fences
*
* The buffer does not specify whether it is to be used for input or output;
* that is determined by its parent stream type and how the buffer is passed to
* the HAL device.
*/
struct StreamBuffer {
/**
* The ID of the stream this buffer is associated with
*/
int32_t streamId;
/**
* The graphics buffer handle to the buffer
*/
handle buffer;
/**
* Current state of the buffer. The framework must not pass buffers to the
* HAL that are in an error state. In case a buffer could not be filled by
* the HAL, it must have its status set to ERROR when returned to the
* framework with processCaptureResult().
*/
BufferStatus status;
/**
* The acquire sync fence for this buffer. The HAL must wait on this fence
* fd before attempting to read from or write to this buffer.
*
* The framework may be set to -1 to indicate that no waiting is necessary
* for this buffer.
*
* When the HAL returns an output buffer to the framework with
* processCaptureResult(), the acquireFence must be set to -1. If the HAL
* never waits on the acquireFence due to an error in filling a buffer,
* when calling processCaptureResult() the HAL must set the releaseFence
* of the buffer to be the acquireFence passed to it by the framework. This
* allows the framework to wait on the fence before reusing the buffer.
*
* For input buffers, the HAL must not change the acquireFence field during
* the processCaptureRequest() call.
*
* When the HAL returns an input buffer to the framework with
* processCaptureResult(), the acquireFence must be set to -1. If the HAL
* never waits on input buffer acquire fence due to an error, the sync
* fences must be handled similarly to the way they are handled for output
* buffers.
*/
handle acquireFence;
/**
* The release sync fence for this buffer. The HAL must set this fence when
* returning buffers to the framework, or write -1 to indicate that no
* waiting is required for this buffer.
*
* For the output buffers, the fences must be set in the outputBuffers
* array passed to processCaptureResult().
*
* For the input buffer, the fences must be set in the inputBuffer
* passed to processCaptureResult().
*
* After signaling the releaseFence for this buffer, the HAL
* must not make any further attempts to access this buffer as the
* ownership has been fully transferred back to the framework.
*
* If a fence of -1 was specified then the ownership of this buffer
* is transferred back immediately upon the call of processCaptureResult.
*/
handle releaseFence;
};
/**
* CameraBlob:
*
* Transport header for camera blob types; generally compressed JPEG buffers in
* output streams.
*
* To capture JPEG images, a stream is created using the pixel format
* HAL_PIXEL_FORMAT_BLOB and dataspace HAL_DATASPACE_V0_JFIF. The buffer size
* for the stream is calculated by the framework, based on the static metadata
* field android.jpeg.maxSize. Since compressed JPEG images are of variable
* size, the HAL needs to include the final size of the compressed image using
* this structure inside the output stream buffer. The camera blob ID field must
* be set to CameraBlobId::JPEG.
*
* The transport header must be at the end of the JPEG output stream
* buffer. That means the jpegBlobId must start at byte[buffer_size -
* sizeof(CameraBlob)], where the buffer_size is the size of gralloc
* buffer. Any HAL using this transport header must account for it in
* android.jpeg.maxSize. The JPEG data itself starts at the beginning of the
* buffer and must be blobSize bytes long.
*/
enum CameraBlobId : uint16_t {
JPEG = 0x00FF,
};
struct CameraBlob {
CameraBlobId blobId;
uint32_t blobSize;
};
/**
* MsgType:
*
* Indicates the type of message sent, which specifies which member of the
* message union is valid.
*
*/
enum MsgType : uint32_t {
/**
* An error has occurred. NotifyMsg::Message::Error contains the
* error information.
*/
ERROR = 1,
/**
* The exposure of a given request or processing a reprocess request has
* begun. NotifyMsg::Message::Shutter contains the information
* the capture.
*/
SHUTTER = 2
};
/**
* Defined error codes for MsgType::ERROR
*/
enum ErrorCode : uint32_t {
/**
* A serious failure occured. No further frames or buffer streams must
* be produced by the device. Device must be treated as closed. The
* client must reopen the device to use it again. The frameNumber field
* is unused.
*/
ERROR_DEVICE = 1,
/**
* An error has occurred in processing a request. No output (metadata or
* buffers) must be produced for this request. The frameNumber field
* specifies which request has been dropped. Subsequent requests are
* unaffected, and the device remains operational.
*/
ERROR_REQUEST = 2,
/**
* An error has occurred in producing an output result metadata buffer
* for a request, but output stream buffers for it must still be
* available. Subsequent requests are unaffected, and the device remains
* operational. The frameNumber field specifies the request for which
* result metadata won't be available.
*/
ERROR_RESULT = 3,
/**
* An error has occurred in placing an output buffer into a stream for a
* request. The frame metadata and other buffers may still be
* available. Subsequent requests are unaffected, and the device remains
* operational. The frameNumber field specifies the request for which the
* buffer was dropped, and errorStreamId indicates the stream
* that dropped the frame.
*/
ERROR_BUFFER = 4,
};
/**
* ErrorMsg:
*
* Message contents for MsgType::ERROR
*/
struct ErrorMsg {
/**
* Frame number of the request the error applies to. 0 if the frame number
* isn't applicable to the error.
*/
uint32_t frameNumber;
/**
* Pointer to the stream that had a failure. -1 if the stream isn't
* applicable to the error.
*/
int32_t errorStreamId;
/**
* The code for this error.
*/
ErrorCode errorCode;
};
/**
* ShutterMsg:
*
* Message contents for MsgType::SHUTTER
*/
struct ShutterMsg {
/**
* Frame number of the request that has begun exposure or reprocessing.
*/
uint32_t frameNumber;
/**
* Timestamp for the start of capture. For a reprocess request, this must
* be input image's start of capture. This must match the capture result
* metadata's sensor exposure start timestamp.
*/
uint64_t timestamp;
};
/**
* MotifyMsg:
*
* The message structure sent to ICameraDevice3Callback::notify()
*/
struct NotifyMsg {
/**
* The message type.
*/
MsgType type;
union Message {
/**
* Error message contents. Valid if type is MsgType::ERROR
*/
ErrorMsg error;
/**
* Shutter message contents. Valid if type is MsgType::SHUTTER
*/
ShutterMsg shutter;
};
};
/**
* RequestTemplate:
*
* Available template types for
* ICameraDevice::constructDefaultRequestSettings()
*/
enum RequestTemplate : uint32_t {
/**
* Standard camera preview operation with 3A on auto.
*/
PREVIEW = 1,
/**
* Standard camera high-quality still capture with 3A and flash on auto.
*/
STILL_CAPTURE = 2,
/**
* Standard video recording plus preview with 3A on auto, torch off.
*/
VIDEO_RECORD = 3,
/**
* High-quality still capture while recording video. Applications typically
* include preview, video record, and full-resolution YUV or JPEG streams in
* request. Must not cause stuttering on video stream. 3A on auto.
*/
VIDEO_SNAPSHOT = 4,
/**
* Zero-shutter-lag mode. Application typically request preview and
* full-resolution data for each frame, and reprocess it to JPEG when a
* still image is requested by user. Settings must provide highest-quality
* full-resolution images without compromising preview frame rate. 3A on
* auto.
*/
ZERO_SHUTTER_LAG = 5,
/**
* A basic template for direct application control of capture
* parameters. All automatic control is disabled (auto-exposure, auto-white
* balance, auto-focus), and post-processing parameters are set to preview
* quality. The manual capture parameters (exposure, sensitivity, etc.)
* are set to reasonable defaults, but may be overridden by the
* application depending on the intended use case.
*/
MANUAL = 6,
/**
* First value for vendor-defined request templates
*/
VENDOR_TEMPLATE_START = 0x40000000,
};
/**
* CaptureRequest:
*
* A single request for image capture/buffer reprocessing, sent to the Camera
* HAL device by the framework in processCaptureRequest().
*
* The request contains the settings to be used for this capture, and the set of
* output buffers to write the resulting image data in. It may optionally
* contain an input buffer, in which case the request is for reprocessing that
* input buffer instead of capturing a new image with the camera sensor. The
* capture is identified by the frameNumber.
*
* In response, the camera HAL device must send a CaptureResult
* structure asynchronously to the framework, using the processCaptureResult()
* callback.
*/
struct CaptureRequest {
/**
* The frame number is an incrementing integer set by the framework to
* uniquely identify this capture. It needs to be returned in the result
* call, and is also used to identify the request in asynchronous
* notifications sent to ICameraDevice3Callback::notify().
*/
uint32_t frameNumber;
/**
* The settings buffer contains the capture and processing parameters for
* the request. As a special case, an empty settings buffer indicates that
* the settings are identical to the most-recently submitted capture
* request. A empty buffer cannot be used as the first submitted request
* after a configureStreams() call.
*/
CameraMetadata settings;
/**
* The input stream buffer to use for this request, if any.
*
* If inputBuffer is invalid, then the request is for a new capture from the
* imager. If inputBuffer is valid, the request is for reprocessing the
* image contained in inputBuffer.
*
* In the latter case, the HAL must set the releaseFence of the
* inputBuffer to a valid sync fence, or to -1 if the HAL does not support
* sync, before processCaptureRequest() returns.
*
* The HAL is required to wait on the acquire sync fence of the input buffer
* before accessing it.
*
*/
StreamBuffer inputBuffer;
/**
* An array of at least 1 stream buffers, to be filled with image
* data from this capture/reprocess. The HAL must wait on the acquire fences
* of each stream buffer before writing to them.
*
* The HAL takes ownership of the actual buffer_handle_t entries in
* outputBuffers; the framework must not access them until they are
* returned in a CaptureResult.
*
* Any or all of the buffers included here may be brand new in this
* request (having never before seen by the HAL).
*/
vec<StreamBuffer> outputBuffers;
};
/**
* CaptureResult:
*
* The result of a single capture/reprocess by the camera HAL device. This is
* sent to the framework asynchronously with processCaptureResult(), in
* response to a single capture request sent to the HAL with
* processCaptureRequest(). Multiple processCaptureResult() calls may be
* performed by the HAL for each request.
*
* Each call, all with the same frame
* number, may contain some subset of the output buffers, and/or the result
* metadata.
*
* The result structure contains the output metadata from this capture, and the
* set of output buffers that have been/will be filled for this capture. Each
* output buffer may come with a release sync fence that the framework must wait
* on before reading, in case the buffer has not yet been filled by the HAL.
*
* The metadata may be provided multiple times for a single frame number. The
* framework must accumulate together the final result set by combining each
* partial result together into the total result set.
*
* If an input buffer is given in a request, the HAL must return it in one of
* the processCaptureResult calls, and the call may be to just return the
* input buffer, without metadata and output buffers; the sync fences must be
* handled the same way they are done for output buffers.
*
* Performance considerations:
*
* Applications receive these partial results immediately, so sending partial
* results is a highly recommended performance optimization to avoid the total
* pipeline latency before sending the results for what is known very early on
* in the pipeline.
*
* A typical use case might be calculating the AF state halfway through the
* pipeline; by sending the state back to the framework immediately, we get a
* 50% performance increase and perceived responsiveness of the auto-focus.
*
*/
struct CaptureResult {
/**
* The frame number is an incrementing integer set by the framework in the
* submitted request to uniquely identify this capture. It is also used to
* identify the request in asynchronous notifications sent to
* ICameraDevice3Callback::notify().
*/
uint32_t frameNumber;
/**
* The result metadata for this capture. This contains information about the
* final capture parameters, the state of the capture and post-processing
* hardware, the state of the 3A algorithms, if enabled, and the output of
* any enabled statistics units.
*
* If there was an error producing the result metadata, result must be an
* empty metadata buffer, and notify() must be called with
* ErrorCode::ERROR_RESULT.
*
* Multiple calls to processCaptureResult() with a given frameNumber
* may include (partial) result metadata.
*
* Partial metadata submitted must not include any metadata key returned
* in a previous partial result for a given frame. Each new partial result
* for that frame must also set a distinct partialResult value.
*
* If notify has been called with ErrorCode::ERROR_RESULT, all further
* partial results for that frame are ignored by the framework.
*/
CameraMetadata result;
/**
* The handles for the output stream buffers for this capture. They may not
* yet be filled at the time the HAL calls processCaptureResult(); the
* framework must wait on the release sync fences provided by the HAL before
* reading the buffers.
*
* The number of output buffers returned must be less than or equal to the
* matching capture request's count. If this is less than the buffer count
* in the capture request, at least one more call to processCaptureResult
* with the same frameNumber must be made, to return the remaining output
* buffers to the framework. This may only be zero if the structure includes
* valid result metadata or an input buffer is returned in this result.
*
* The HAL must set the stream buffer's release sync fence to a valid sync
* fd, or to -1 if the buffer has already been filled.
*
* If the HAL encounters an error while processing the buffer, and the
* buffer is not filled, the buffer's status field must be set to ERROR. If
* the HAL did not wait on the acquire fence before encountering the error,
* the acquire fence must be copied into the release fence, to allow the
* framework to wait on the fence before reusing the buffer.
*
* The acquire fence must be set to -1 for all output buffers.
*
* This vector may be empty; if so, at least one other processCaptureResult
* call must be made (or have been made) by the HAL to provide the filled
* output buffers.
*
* When processCaptureResult is called with a new buffer for a frame,
* all previous frames' buffers for that corresponding stream must have been
* already delivered (the fences need not have yet been signaled).
*
* Gralloc buffers for a frame may be sent to framework before the
* corresponding SHUTTER-notify.
*
* Performance considerations:
*
* Buffers delivered to the framework are not dispatched to the
* application layer until a start of exposure timestamp has been received
* via a SHUTTER notify() call. It is highly recommended to
* dispatch that call as early as possible.
*/
vec<StreamBuffer> outputBuffers;
/**
* The handle for the input stream buffer for this capture. It may not
* yet be consumed at the time the HAL calls processCaptureResult(); the
* framework must wait on the release sync fence provided by the HAL before
* reusing the buffer.
*
* The HAL must handle the sync fences the same way they are done for
* outputBuffers.
*
* Only one input buffer is allowed to be sent per request. Similarly to
* output buffers, the ordering of returned input buffers must be
* maintained by the HAL.
*
* Performance considerations:
*
* The input buffer should be returned as early as possible. If the HAL
* supports sync fences, it can call processCaptureResult to hand it back
* with sync fences being set appropriately. If the sync fences are not
* supported, the buffer can only be returned when it is consumed, which
* may take long time; the HAL may choose to copy this input buffer to make
* the buffer return sooner.
*/
StreamBuffer inputBuffer;
/**
* In order to take advantage of partial results, the HAL must set the
* static metadata android.request.partialResultCount to the number of
* partial results it sends for each frame.
*
* Each new capture result with a partial result must set
* this field to a distinct inclusive value between
* 1 and android.request.partialResultCount.
*
* HALs not wishing to take advantage of this feature must not
* set an android.request.partialResultCount or partial_result to a value
* other than 1.
*
* This value must be set to 0 when a capture result contains buffers only
* and no metadata.
*/
uint32_t partialResult;
};

76
camera/device/README.md Normal file
View File

@@ -0,0 +1,76 @@
## Camera Device HAL ##
---
## Overview: ##
The camera.device HAL interface is used by the Android camera service to operate
individual camera devices. Instances of camera.device HAL interface can be obtained
via one of the ICameraProvider::getCameraDeviceInterface_V<N>_x() methods, where N
is the major version of the camera device interface.
Obtaining the device interface does not turn on the respective camera device;
each camera device interface has an actual open() method to begin an active
camera session. Without invoking open(), the interface can be used for querying
camera static information.
More complete information about the Android camera HAL and subsystem can be found at
[source.android.com](http://source.android.com/devices/camera/index.html).
## Version history: ##
### ICameraDevice.hal@1.0:
HIDL version of the legacy camera device HAL. Intended as a shim for devices
needing to use the deprecated pre-HIDL camera device HAL v1.0.
May be used in HIDL passthrough mode for devices upgrading to the Android O
release; must be used in binderized mode for devices launching in the O release.
It is strongly recommended to not use this interface for new devices, as new
devices may not use this interface starting with the Android P release, and all
support for ICameraDevice@1.0 will be removed with the Android R release.
This HAL interface version only allows support at the LEGACY level for the
android.hardware.camera2 API.
Subsidiary HALs:
#### ICameraDevice1PreviewCallback.hal@1.0:
Callback interface for obtaining, filling, and returning graphics buffers for
preview operation with the ICameraDevice@1.0 inteface.
#### ICameraDevice1Callback.hal@1.0:
Callback interface for sending events and data buffers from the HAL to the
camera service.
### ICameraDevice.hal@3.2:
HIDL version of the baseline camera device HAL, required for LIMITED or FULL
operation through the android.hardware.camera2 API.
The main HAL contains methods for static queries about the device, similar to
the HALv3-specific sections of the legacy camera module HAL. Simply obtaining an
instance of the camera device interface does not turn on the camera device.
May be used in passthrough mode for devices upgrading to the Android O release;
must be used in binderized mode for all new devices launching with Android O or
later.
The open() method actually opens the camera device for use, returning a Session
interface for operating the active camera. It takes a Callback interface as an
argument.
Subsidiary HALs:
#### ICameraDevice3Session.hal@3.2:
Closely matches the features and operation of the pre-HIDL camera device HAL
v3.2, containing methods for configuring an active camera device and submitting
capture requests to it.
#### ICameraDevice3Callback.hal@3.2:
Callback interface for sending completed captures and other asynchronous events
from tehe HAL to the client.

View File

@@ -0,0 +1,46 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
genrule {
name: "android.hardware.camera.metadata@3.2_genc++",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.metadata@3.2",
srcs: [
"types.hal",
],
out: [
"android/hardware/camera/metadata/3.2/types.cpp",
],
}
genrule {
name: "android.hardware.camera.metadata@3.2_genc++_headers",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.metadata@3.2",
srcs: [
"types.hal",
],
out: [
"android/hardware/camera/metadata/3.2/types.h",
],
}
cc_library_shared {
name: "android.hardware.camera.metadata@3.2",
generated_sources: ["android.hardware.camera.metadata@3.2_genc++"],
generated_headers: ["android.hardware.camera.metadata@3.2_genc++_headers"],
export_generated_headers: ["android.hardware.camera.metadata@3.2_genc++_headers"],
shared_libs: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"liblog",
"libutils",
"libcutils",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
],
}

File diff suppressed because it is too large Load Diff

27340
camera/metadata/3.2/docs.html Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

19
camera/metadata/README.md Normal file
View File

@@ -0,0 +1,19 @@
## Camera Metadata Interface ##
---
## Overview: ##
The camera.metadata interface is used by the Android camera service,
camera provider and camera devices to retrieve static camera information and issue
camera capture controls.
See the docs.html for each version for the detailed description of each metadata
specification.
## Version history: ##
### @3.2:
HIDL version of the baseline camera metadata interface, required by
camera.provider@2.4 and camera.device@3.2 onwards.

View File

@@ -0,0 +1,64 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
genrule {
name: "android.hardware.camera.provider@2.4_genc++",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.provider@2.4",
srcs: [
"ICameraProvider.hal",
"ICameraProviderCallback.hal",
],
out: [
"android/hardware/camera/provider/2.4/CameraProviderAll.cpp",
"android/hardware/camera/provider/2.4/CameraProviderCallbackAll.cpp",
],
}
genrule {
name: "android.hardware.camera.provider@2.4_genc++_headers",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.provider@2.4",
srcs: [
"ICameraProvider.hal",
"ICameraProviderCallback.hal",
],
out: [
"android/hardware/camera/provider/2.4/ICameraProvider.h",
"android/hardware/camera/provider/2.4/IHwCameraProvider.h",
"android/hardware/camera/provider/2.4/BnCameraProvider.h",
"android/hardware/camera/provider/2.4/BpCameraProvider.h",
"android/hardware/camera/provider/2.4/BsCameraProvider.h",
"android/hardware/camera/provider/2.4/ICameraProviderCallback.h",
"android/hardware/camera/provider/2.4/IHwCameraProviderCallback.h",
"android/hardware/camera/provider/2.4/BnCameraProviderCallback.h",
"android/hardware/camera/provider/2.4/BpCameraProviderCallback.h",
"android/hardware/camera/provider/2.4/BsCameraProviderCallback.h",
],
}
cc_library_shared {
name: "android.hardware.camera.provider@2.4",
generated_sources: ["android.hardware.camera.provider@2.4_genc++"],
generated_headers: ["android.hardware.camera.provider@2.4_genc++_headers"],
export_generated_headers: ["android.hardware.camera.provider@2.4_genc++_headers"],
shared_libs: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"liblog",
"libutils",
"libcutils",
"android.hardware.camera.common@1.0",
"android.hardware.camera.device@1.0",
"android.hardware.camera.device@3.2",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
"android.hardware.camera.common@1.0",
"android.hardware.camera.device@1.0",
"android.hardware.camera.device@3.2",
],
}

View File

@@ -0,0 +1,164 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.provider@2.4;
import ICameraProviderCallback;
import android.hardware.camera.common@1.0::types;
import android.hardware.camera.device@1.0::ICameraDevice;
import android.hardware.camera.device@3.2::ICameraDevice;
/**
* Camera provider HAL, which enumerates the available individual camera devices
* known to the provider, and provides updates about changes to device status,
* such as connection, disconnection, or torch mode enable/disable.
*
* The provider is responsible for generating a list of camera device service
* names that can then be opened via the hardware service manager.
*
* Multiple camera provider HALs may be present in a single system.
* For discovery, the service names, and process names, must be of the form
* "android.hardware.camera.provider@<major>.<minor>/<type>/<instance>"
* where
* - <major>/<minor> is the provider HAL HIDL version,
* - <type> is the type of devices this provider knows about, such as
* "internal", "legacy", "usb", or "remote"
* - <instance> is a non-negative integer starting from 0 to disambiguate
* between multiple HALs of the same type.
*
* The "legacy" type is only used for passthrough legacy HAL mode, and must
* not be used by a standalone binderized HAL.
*
* The device instance names enumerated by the provider must be of the form
* "device@<major>.<minor>/<type>/<id>" where
* <major>/<minor> is the HIDL version of the interface. <id> is either a small
* incrementing integer for "internal" device types, with 0 being the main
* back-facing camera and 1 being the main front-facing camera, if they exist.
* Or, for external devices such as type "usb", a unique serial number that can
* be used to identify the device reliably when it is disconnected and
* reconnected. Multiple providers may not enumerate the same device ID.
*
*/
interface ICameraProvider {
/**
* setCallback:
*
* Provide a callback interface to the HAL provider to inform framework of
* asynchronous camera events. The framework must call this function once
* during camera service startup, before any other calls to the provider
* (note that in case the camera service restarts, this method must be
* invoked again during its startup).
*
* @param callback
* A non-null callback interface to invoke when camera events occur.
* @return status
* Status code for the operation, one of:
* OK:
* On success
* INTERNAL_ERROR:
* An unexpected internal error occurred while setting the callbacks
* ILLEGAL_ARGUMENT:
* The callback argument is invalid (for example, null).
*
*/
setCallback(ICameraProviderCallback callback) generates (Status status);
/**
* getVendorTags:
*
* Retrieve all vendor tags supported by devices discoverable through this
* provider. The tags are grouped into sections.
*
* @return status
* Status code for the operation, one of:
* OK:
* On success
* INTERNAL_ERROR:
* An unexpected internal error occurred while setting the callbacks
* @return sections
* The supported vendor tag sections; empty if there are no supported
* vendor tags, or status is not OK.
*
*/
getVendorTags() generates (Status status, vec<VendorTagSection> sections);
/**
* getCameraDeviceList:
*
* Returns the list of internal camera device interfaces known to this
* camera provider. These devices can then be accessed via the hardware
* service manager.
*
* External camera devices (camera facing EXTERNAL) must be reported through
* the device status change callback, not in this list. Only devices with
* facing BACK or FRONT must be listed here.
*
* @return status Status code for the operation, one of:
* OK:
* On a succesful generation of camera ID list
* INTERNAL_ERROR:
* A camera ID list cannot be created. This may be due to
* a failure to initialize the camera subsystem, for example.
* @return cameraDeviceServiceNames The vector of internal camera device
* names known to this provider.
*/
getCameraIdList()
generates (Status status, vec<string> cameraDeviceNames);
/**
* getCameraDeviceInterface_VN_x:
*
* Return a android.hardware.camera.device@N.x/ICameraDevice interface for
* the requested device name. This does not power on the camera device, but
* simply acquires the interface for querying the device static information,
* or to additionally open the device for active use.
*
* A separate method is required for each major revision of the camera device
* HAL interface, since they are not compatible with each other.
*
* Valid device names for this provider can be obtained via either
* getCameraIdList(), or via availability callbacks from
* ICameraProviderCallback::cameraDeviceStatusChange().
*
* The returned interface must be of the highest defined minor version for
* the major version; it's the responsibility of the HAL client to ensure
* they do not use methods/etc that are not valid for the actual minor
* version of the device.
*
* @param cameraDeviceName the name of the device to get an interface to.
* @return status Status code for the operation, one of:
* OK:
* On a succesful generation of camera ID list
* ILLEGAL_ARGUMENT:
* This device name is unknown, or has been disconnected
* OPERATION_NOT_SUPPORTED:
* The specified device does not support this major version of the
* HAL interface.
* INTERNAL_ERROR:
* A camera interface cannot be returned due to an unexpected
* internal error.
* @return device The inteface to this camera device, or null in case of
* error.
*/
getCameraDeviceInterface_V1_x(string cameraDeviceName) generates
(Status status,
android.hardware.camera.device@1.0::ICameraDevice device);
getCameraDeviceInterface_V3_x(string cameraDeviceName) generates
(Status status,
android.hardware.camera.device@3.2::ICameraDevice device);
};

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2016 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.
*/
package android.hardware.camera.provider@2.4;
import android.hardware.camera.common@1.0::types;
/**
* Callback functions for a camera provider HAL to use to inform the camera
* service of changes to the camera subsystem.
*/
interface ICameraProviderCallback {
/**
* cameraDeviceStatusChange:
*
* Callback to the camera service to indicate that the state of a specific
* camera device has changed.
*
* On camera service startup, when ICameraProvider::setCallback is invoked,
* the camera service must assume that all internal camera devices are in
* the CAMERA_DEVICE_STATUS_PRESENT state.
*
* The provider must call this method to inform the camera service of any
* initially NOT_PRESENT devices, and of any external camera devices that
* are already present, as soon as the callbacks are available through
* setCallback.
*
* @param cameraDeviceServiceName The name of the camera device that has a
* new status.
* @param newStatus The new status that device is in.
*
*/
cameraDeviceStatusChange(string cameraDeviceName,
CameraDeviceStatus newStatus);
/**
* torchModeStatusChange:
*
* Callback to the camera service to indicate that the state of the torch
* mode of the flash unit associated with a specific camera device has
* changed. At provider registration time, the camera service must assume
* the torch modes are in the TORCH_MODE_STATUS_AVAILABLE_OFF state if
* android.flash.info.available is reported as true via the
* ICameraDevice::getCameraCharacteristics call.
*
* @param cameraDeviceServiceName The name of the camera device that has a
* new status.
* @param newStatus The new status that device is in.
*
*/
torchModeStatusChange(string cameraDeviceName,
TorchModeStatus newStatus);
};

37
camera/provider/README.md Normal file
View File

@@ -0,0 +1,37 @@
## Camera Provider HAL ##
---
## Overview: ##
The camera.provider HAL is used by the Android camera service to discover,
query, and open individual camera devices.
It also allows for direct control of the flash unit of camera devices that have
one, for turning on/off torch mode.
More complete information about the Android camera HAL and subsystem can be found at
[source.android.com](http://source.android.com/devices/camera/index.html).
## Version history: ##
## types.hal: ##
### @0.0:
Common enum and struct definitions for all camera HAL interfaces. Does not
define any interfaces of its own.
## ICameraProvider.hal: ##
### @2.4:
First HIDL version of the camera provider HAL, closely matching the feature set
and operation of the pre-HIDL camera HAL module v2.4.
## ICameraProviderCallback.hal: ##
### @2.4:
First HIDL version of the camara provider HAL callback interface, closely
matching the feature set and operation of the pre-HIDL camera HAL module
callbacks v2.4.