upload android base code part4
This commit is contained in:
parent
b9e30e05b1
commit
78ea2404cd
23455 changed files with 5250148 additions and 0 deletions
77
android/hardware/interfaces/camera/provider/2.4/Android.bp
Normal file
77
android/hardware/interfaces/camera/provider/2.4/Android.bp
Normal file
|
@ -0,0 +1,77 @@
|
|||
// This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
filegroup {
|
||||
name: "android.hardware.camera.provider@2.4_hal",
|
||||
srcs: [
|
||||
"ICameraProvider.hal",
|
||||
"ICameraProviderCallback.hal",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.camera.provider@2.4_genc++",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.camera.provider@2.4",
|
||||
srcs: [
|
||||
":android.hardware.camera.provider@2.4_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++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.camera.provider@2.4",
|
||||
srcs: [
|
||||
":android.hardware.camera.provider@2.4_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/camera/provider/2.4/ICameraProvider.h",
|
||||
"android/hardware/camera/provider/2.4/IHwCameraProvider.h",
|
||||
"android/hardware/camera/provider/2.4/BnHwCameraProvider.h",
|
||||
"android/hardware/camera/provider/2.4/BpHwCameraProvider.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/BnHwCameraProviderCallback.h",
|
||||
"android/hardware/camera/provider/2.4/BpHwCameraProviderCallback.h",
|
||||
"android/hardware/camera/provider/2.4/BsCameraProviderCallback.h",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "android.hardware.camera.provider@2.4",
|
||||
defaults: ["hidl-module-defaults"],
|
||||
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"],
|
||||
vendor_available: true,
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
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",
|
||||
"android.hardware.graphics.common@1.0",
|
||||
],
|
||||
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",
|
||||
"android.hardware.graphics.common@1.0",
|
||||
],
|
||||
}
|
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* isSetTorchModeSupported:
|
||||
*
|
||||
* Returns if the camera devices known to this camera provider support
|
||||
* setTorchMode API or not. If the provider does not support setTorchMode
|
||||
* API, calling to setTorchMode will return METHOD_NOT_SUPPORTED.
|
||||
*
|
||||
* Note that not every camera device has a flash unit, so even this API
|
||||
* returns true, setTorchMode call might still fail due to the camera device
|
||||
* does not have a flash unit. In such case, the returned status will be
|
||||
* OPERATION_NOT_SUPPORTED.
|
||||
*
|
||||
* @return status Status code for the operation, one of:
|
||||
* OK:
|
||||
* On a succesful call
|
||||
* INTERNAL_ERROR:
|
||||
* Torch API support cannot be queried. This may be due to
|
||||
* a failure to initialize the camera subsystem, for example.
|
||||
* @return support Whether the camera devices known to this provider
|
||||
* supports setTorchMode API or not.
|
||||
*
|
||||
*/
|
||||
isSetTorchModeSupported() generates (Status status, bool support);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
};
|
|
@ -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);
|
||||
|
||||
};
|
|
@ -0,0 +1,52 @@
|
|||
cc_library_shared {
|
||||
name: "android.hardware.camera.provider@2.4-impl",
|
||||
defaults: ["hidl_defaults"],
|
||||
proprietary: true,
|
||||
relative_install_path: "hw",
|
||||
srcs: ["CameraProvider.cpp"],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
"android.hardware.camera.device@1.0",
|
||||
"android.hardware.camera.device@3.2",
|
||||
"android.hardware.camera.device@3.3",
|
||||
"camera.device@1.0-impl",
|
||||
"camera.device@3.2-impl",
|
||||
"camera.device@3.3-impl",
|
||||
"android.hardware.camera.provider@2.4",
|
||||
"android.hardware.camera.common@1.0",
|
||||
"android.hardware.graphics.mapper@2.0",
|
||||
"android.hidl.allocator@1.0",
|
||||
"android.hidl.memory@1.0",
|
||||
"liblog",
|
||||
"libhardware",
|
||||
"libcamera_metadata"
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.camera.common@1.0-helper"
|
||||
]
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.camera.provider@2.4-service",
|
||||
defaults: ["hidl_defaults"],
|
||||
proprietary: true,
|
||||
relative_install_path: "hw",
|
||||
srcs: ["service.cpp"],
|
||||
compile_multilib: "32",
|
||||
init_rc: ["android.hardware.camera.provider@2.4-service.rc"],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libbinder",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.camera.device@1.0",
|
||||
"android.hardware.camera.device@3.2",
|
||||
"android.hardware.camera.device@3.3",
|
||||
"android.hardware.camera.provider@2.4",
|
||||
"android.hardware.camera.common@1.0",
|
||||
],
|
||||
}
|
|
@ -0,0 +1,548 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "CamProvider@2.4-impl"
|
||||
//#define LOG_NDEBUG 0
|
||||
#include <android/log.h>
|
||||
|
||||
#include "CameraProvider.h"
|
||||
#include "CameraDevice_1_0.h"
|
||||
#include "CameraDevice_3_3.h"
|
||||
#include <cutils/properties.h>
|
||||
#include <string.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace camera {
|
||||
namespace provider {
|
||||
namespace V2_4 {
|
||||
namespace implementation {
|
||||
|
||||
namespace {
|
||||
const char *kLegacyProviderName = "legacy/0";
|
||||
// "device@<version>/legacy/<id>"
|
||||
const std::regex kDeviceNameRE("device@([0-9]+\\.[0-9]+)/legacy/(.+)");
|
||||
const char *kHAL3_2 = "3.2";
|
||||
const char *kHAL3_3 = "3.3";
|
||||
const char *kHAL1_0 = "1.0";
|
||||
const int kMaxCameraDeviceNameLen = 128;
|
||||
const int kMaxCameraIdLen = 16;
|
||||
|
||||
bool matchDeviceName(const hidl_string& deviceName, std::string* deviceVersion,
|
||||
std::string* cameraId) {
|
||||
std::string deviceNameStd(deviceName.c_str());
|
||||
std::smatch sm;
|
||||
if (std::regex_match(deviceNameStd, sm, kDeviceNameRE)) {
|
||||
if (deviceVersion != nullptr) {
|
||||
*deviceVersion = sm[1];
|
||||
}
|
||||
if (cameraId != nullptr) {
|
||||
*cameraId = sm[2];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
using ::android::hardware::camera::common::V1_0::CameraMetadataType;
|
||||
using ::android::hardware::camera::common::V1_0::Status;
|
||||
|
||||
/**
|
||||
* static callback forwarding methods from HAL to instance
|
||||
*/
|
||||
void CameraProvider::sCameraDeviceStatusChange(
|
||||
const struct camera_module_callbacks* callbacks,
|
||||
int camera_id,
|
||||
int new_status) {
|
||||
CameraProvider* cp = const_cast<CameraProvider*>(
|
||||
static_cast<const CameraProvider*>(callbacks));
|
||||
|
||||
if (cp == nullptr) {
|
||||
ALOGE("%s: callback ops is null", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
Mutex::Autolock _l(cp->mCbLock);
|
||||
char cameraId[kMaxCameraIdLen];
|
||||
snprintf(cameraId, sizeof(cameraId), "%d", camera_id);
|
||||
std::string cameraIdStr(cameraId);
|
||||
cp->mCameraStatusMap[cameraIdStr] = (camera_device_status_t) new_status;
|
||||
if (cp->mCallbacks != nullptr) {
|
||||
CameraDeviceStatus status = (CameraDeviceStatus) new_status;
|
||||
for (auto const& deviceNamePair : cp->mCameraDeviceNames) {
|
||||
if (cameraIdStr.compare(deviceNamePair.first) == 0) {
|
||||
cp->mCallbacks->cameraDeviceStatusChange(
|
||||
deviceNamePair.second, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CameraProvider::sTorchModeStatusChange(
|
||||
const struct camera_module_callbacks* callbacks,
|
||||
const char* camera_id,
|
||||
int new_status) {
|
||||
CameraProvider* cp = const_cast<CameraProvider*>(
|
||||
static_cast<const CameraProvider*>(callbacks));
|
||||
|
||||
if (cp == nullptr) {
|
||||
ALOGE("%s: callback ops is null", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
Mutex::Autolock _l(cp->mCbLock);
|
||||
if (cp->mCallbacks != nullptr) {
|
||||
std::string cameraIdStr(camera_id);
|
||||
TorchModeStatus status = (TorchModeStatus) new_status;
|
||||
for (auto const& deviceNamePair : cp->mCameraDeviceNames) {
|
||||
if (cameraIdStr.compare(deviceNamePair.first) == 0) {
|
||||
cp->mCallbacks->torchModeStatusChange(
|
||||
deviceNamePair.second, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status CameraProvider::getHidlStatus(int status) {
|
||||
switch (status) {
|
||||
case 0: return Status::OK;
|
||||
case -ENODEV: return Status::INTERNAL_ERROR;
|
||||
case -EINVAL: return Status::ILLEGAL_ARGUMENT;
|
||||
default:
|
||||
ALOGE("%s: unknown HAL status code %d", __FUNCTION__, status);
|
||||
return Status::INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
std::string CameraProvider::getLegacyCameraId(const hidl_string& deviceName) {
|
||||
std::string cameraId;
|
||||
matchDeviceName(deviceName, nullptr, &cameraId);
|
||||
return cameraId;
|
||||
}
|
||||
|
||||
int CameraProvider::getCameraDeviceVersion(const hidl_string& deviceName) {
|
||||
std::string deviceVersion;
|
||||
bool match = matchDeviceName(deviceName, &deviceVersion, nullptr);
|
||||
if (!match) {
|
||||
return -1;
|
||||
}
|
||||
if (deviceVersion == kHAL3_3) {
|
||||
return CAMERA_DEVICE_API_VERSION_3_3;
|
||||
} else if (deviceVersion == kHAL3_2) {
|
||||
return CAMERA_DEVICE_API_VERSION_3_2;
|
||||
} else if (deviceVersion == kHAL1_0) {
|
||||
return CAMERA_DEVICE_API_VERSION_1_0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string CameraProvider::getHidlDeviceName(
|
||||
std::string cameraId, int deviceVersion) {
|
||||
// Maybe consider create a version check method and SortedVec to speed up?
|
||||
if (deviceVersion != CAMERA_DEVICE_API_VERSION_1_0 &&
|
||||
deviceVersion != CAMERA_DEVICE_API_VERSION_3_2 &&
|
||||
deviceVersion != CAMERA_DEVICE_API_VERSION_3_3 &&
|
||||
deviceVersion != CAMERA_DEVICE_API_VERSION_3_4 ) {
|
||||
return hidl_string("");
|
||||
}
|
||||
bool isV1 = deviceVersion == CAMERA_DEVICE_API_VERSION_1_0;
|
||||
int versionMajor = isV1 ? 1 : 3;
|
||||
int versionMinor = isV1 ? 0 : mPreferredHal3MinorVersion;
|
||||
char deviceName[kMaxCameraDeviceNameLen];
|
||||
snprintf(deviceName, sizeof(deviceName), "device@%d.%d/legacy/%s",
|
||||
versionMajor, versionMinor, cameraId.c_str());
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
CameraProvider::CameraProvider() :
|
||||
camera_module_callbacks_t({sCameraDeviceStatusChange,
|
||||
sTorchModeStatusChange}) {
|
||||
mInitFailed = initialize();
|
||||
}
|
||||
|
||||
CameraProvider::~CameraProvider() {}
|
||||
|
||||
bool CameraProvider::initialize() {
|
||||
camera_module_t *rawModule;
|
||||
int err = hw_get_module(CAMERA_HARDWARE_MODULE_ID,
|
||||
(const hw_module_t **)&rawModule);
|
||||
if (err < 0) {
|
||||
ALOGE("Could not load camera HAL module: %d (%s)", err, strerror(-err));
|
||||
return true;
|
||||
}
|
||||
|
||||
mModule = new CameraModule(rawModule);
|
||||
err = mModule->init();
|
||||
if (err != OK) {
|
||||
ALOGE("Could not initialize camera HAL module: %d (%s)", err, strerror(-err));
|
||||
mModule.clear();
|
||||
return true;
|
||||
}
|
||||
ALOGI("Loaded \"%s\" camera module", mModule->getModuleName());
|
||||
|
||||
// Setup vendor tags here so HAL can setup vendor keys in camera characteristics
|
||||
VendorTagDescriptor::clearGlobalVendorTagDescriptor();
|
||||
if (!setUpVendorTags()) {
|
||||
ALOGE("%s: Vendor tag setup failed, will not be available.", __FUNCTION__);
|
||||
}
|
||||
|
||||
// Setup callback now because we are going to try openLegacy next
|
||||
err = mModule->setCallbacks(this);
|
||||
if (err != OK) {
|
||||
ALOGE("Could not set camera module callback: %d (%s)", err, strerror(-err));
|
||||
mModule.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
mPreferredHal3MinorVersion = property_get_int32("ro.camera.wrapper.hal3TrebleMinorVersion", 3);
|
||||
ALOGV("Preferred HAL 3 minor version is %d", mPreferredHal3MinorVersion);
|
||||
switch(mPreferredHal3MinorVersion) {
|
||||
case 2:
|
||||
case 3:
|
||||
// OK
|
||||
break;
|
||||
default:
|
||||
ALOGW("Unknown minor camera device HAL version %d in property "
|
||||
"'camera.wrapper.hal3TrebleMinorVersion', defaulting to 3", mPreferredHal3MinorVersion);
|
||||
mPreferredHal3MinorVersion = 3;
|
||||
}
|
||||
|
||||
mNumberOfLegacyCameras = mModule->getNumberOfCameras();
|
||||
for (int i = 0; i < mNumberOfLegacyCameras; i++) {
|
||||
struct camera_info info;
|
||||
auto rc = mModule->getCameraInfo(i, &info);
|
||||
if (rc != NO_ERROR) {
|
||||
ALOGE("%s: Camera info query failed!", __func__);
|
||||
mModule.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkCameraVersion(i, info) != OK) {
|
||||
ALOGE("%s: Camera version check failed!", __func__);
|
||||
mModule.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
char cameraId[kMaxCameraIdLen];
|
||||
snprintf(cameraId, sizeof(cameraId), "%d", i);
|
||||
std::string cameraIdStr(cameraId);
|
||||
mCameraStatusMap[cameraIdStr] = CAMERA_DEVICE_STATUS_PRESENT;
|
||||
mCameraIds.add(cameraIdStr);
|
||||
|
||||
// initialize mCameraDeviceNames and mOpenLegacySupported
|
||||
mOpenLegacySupported[cameraIdStr] = false;
|
||||
int deviceVersion = mModule->getDeviceVersion(i);
|
||||
mCameraDeviceNames.add(
|
||||
std::make_pair(cameraIdStr,
|
||||
getHidlDeviceName(cameraIdStr, deviceVersion)));
|
||||
if (deviceVersion >= CAMERA_DEVICE_API_VERSION_3_2 &&
|
||||
mModule->isOpenLegacyDefined()) {
|
||||
// try open_legacy to see if it actually works
|
||||
struct hw_device_t* halDev = nullptr;
|
||||
int ret = mModule->openLegacy(cameraId, CAMERA_DEVICE_API_VERSION_1_0, &halDev);
|
||||
if (ret == 0) {
|
||||
mOpenLegacySupported[cameraIdStr] = true;
|
||||
halDev->close(halDev);
|
||||
mCameraDeviceNames.add(
|
||||
std::make_pair(cameraIdStr,
|
||||
getHidlDeviceName(cameraIdStr, CAMERA_DEVICE_API_VERSION_1_0)));
|
||||
} else if (ret == -EBUSY || ret == -EUSERS) {
|
||||
// Looks like this provider instance is not initialized during
|
||||
// system startup and there are other camera users already.
|
||||
// Not a good sign but not fatal.
|
||||
ALOGW("%s: open_legacy try failed!", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false; // mInitFailed
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the device HAL version is still in supported.
|
||||
*/
|
||||
int CameraProvider::checkCameraVersion(int id, camera_info info) {
|
||||
if (mModule == nullptr) {
|
||||
return NO_INIT;
|
||||
}
|
||||
|
||||
// device_version undefined in CAMERA_MODULE_API_VERSION_1_0,
|
||||
// All CAMERA_MODULE_API_VERSION_1_0 devices are backward-compatible
|
||||
if (mModule->getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_0) {
|
||||
// Verify the device version is in the supported range
|
||||
switch (info.device_version) {
|
||||
case CAMERA_DEVICE_API_VERSION_1_0:
|
||||
case CAMERA_DEVICE_API_VERSION_3_2:
|
||||
case CAMERA_DEVICE_API_VERSION_3_3:
|
||||
case CAMERA_DEVICE_API_VERSION_3_4:
|
||||
// in support
|
||||
break;
|
||||
case CAMERA_DEVICE_API_VERSION_2_0:
|
||||
case CAMERA_DEVICE_API_VERSION_2_1:
|
||||
case CAMERA_DEVICE_API_VERSION_3_0:
|
||||
case CAMERA_DEVICE_API_VERSION_3_1:
|
||||
// no longer supported
|
||||
default:
|
||||
ALOGE("%s: Device %d has HAL version %x, which is not supported",
|
||||
__FUNCTION__, id, info.device_version);
|
||||
return NO_INIT;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool CameraProvider::setUpVendorTags() {
|
||||
ATRACE_CALL();
|
||||
vendor_tag_ops_t vOps = vendor_tag_ops_t();
|
||||
|
||||
// Check if vendor operations have been implemented
|
||||
if (!mModule->isVendorTagDefined()) {
|
||||
ALOGI("%s: No vendor tags defined for this device.", __FUNCTION__);
|
||||
return true;
|
||||
}
|
||||
|
||||
mModule->getVendorTagOps(&vOps);
|
||||
|
||||
// Ensure all vendor operations are present
|
||||
if (vOps.get_tag_count == nullptr || vOps.get_all_tags == nullptr ||
|
||||
vOps.get_section_name == nullptr || vOps.get_tag_name == nullptr ||
|
||||
vOps.get_tag_type == nullptr) {
|
||||
ALOGE("%s: Vendor tag operations not fully defined. Ignoring definitions."
|
||||
, __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read all vendor tag definitions into a descriptor
|
||||
sp<VendorTagDescriptor> desc;
|
||||
status_t res;
|
||||
if ((res = VendorTagDescriptor::createDescriptorFromOps(&vOps, /*out*/desc))
|
||||
!= OK) {
|
||||
ALOGE("%s: Could not generate descriptor from vendor tag operations,"
|
||||
"received error %s (%d). Camera clients will not be able to use"
|
||||
"vendor tags", __FUNCTION__, strerror(res), res);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the global descriptor to use with camera metadata
|
||||
VendorTagDescriptor::setAsGlobalVendorTagDescriptor(desc);
|
||||
const SortedVector<String8>* sectionNames = desc->getAllSectionNames();
|
||||
size_t numSections = sectionNames->size();
|
||||
std::vector<std::vector<VendorTag>> tagsBySection(numSections);
|
||||
int tagCount = desc->getTagCount();
|
||||
std::vector<uint32_t> tags(tagCount);
|
||||
desc->getTagArray(tags.data());
|
||||
for (int i = 0; i < tagCount; i++) {
|
||||
VendorTag vt;
|
||||
vt.tagId = tags[i];
|
||||
vt.tagName = desc->getTagName(tags[i]);
|
||||
vt.tagType = (CameraMetadataType) desc->getTagType(tags[i]);
|
||||
ssize_t sectionIdx = desc->getSectionIndex(tags[i]);
|
||||
tagsBySection[sectionIdx].push_back(vt);
|
||||
}
|
||||
mVendorTagSections.resize(numSections);
|
||||
for (size_t s = 0; s < numSections; s++) {
|
||||
mVendorTagSections[s].sectionName = (*sectionNames)[s].string();
|
||||
mVendorTagSections[s].tags = tagsBySection[s];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::camera::provider::V2_4::ICameraProvider follow.
|
||||
Return<Status> CameraProvider::setCallback(const sp<ICameraProviderCallback>& callback) {
|
||||
Mutex::Autolock _l(mCbLock);
|
||||
mCallbacks = callback;
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
Return<void> CameraProvider::getVendorTags(getVendorTags_cb _hidl_cb) {
|
||||
_hidl_cb(Status::OK, mVendorTagSections);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> CameraProvider::getCameraIdList(getCameraIdList_cb _hidl_cb) {
|
||||
std::vector<hidl_string> deviceNameList;
|
||||
for (auto const& deviceNamePair : mCameraDeviceNames) {
|
||||
if (mCameraStatusMap[deviceNamePair.first] == CAMERA_DEVICE_STATUS_PRESENT) {
|
||||
deviceNameList.push_back(deviceNamePair.second);
|
||||
}
|
||||
}
|
||||
hidl_vec<hidl_string> hidlDeviceNameList(deviceNameList);
|
||||
_hidl_cb(Status::OK, hidlDeviceNameList);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> CameraProvider::isSetTorchModeSupported(isSetTorchModeSupported_cb _hidl_cb) {
|
||||
bool support = mModule->isSetTorchModeSupported();
|
||||
_hidl_cb (Status::OK, support);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> CameraProvider::getCameraDeviceInterface_V1_x(
|
||||
const hidl_string& cameraDeviceName, getCameraDeviceInterface_V1_x_cb _hidl_cb) {
|
||||
std::string cameraId, deviceVersion;
|
||||
bool match = matchDeviceName(cameraDeviceName, &deviceVersion, &cameraId);
|
||||
if (!match) {
|
||||
_hidl_cb(Status::ILLEGAL_ARGUMENT, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
std::string deviceName(cameraDeviceName.c_str());
|
||||
ssize_t index = mCameraDeviceNames.indexOf(std::make_pair(cameraId, deviceName));
|
||||
if (index == NAME_NOT_FOUND) { // Either an illegal name or a device version mismatch
|
||||
Status status = Status::OK;
|
||||
ssize_t idx = mCameraIds.indexOf(cameraId);
|
||||
if (idx == NAME_NOT_FOUND) {
|
||||
ALOGE("%s: cannot find camera %s!", __FUNCTION__, cameraId.c_str());
|
||||
status = Status::ILLEGAL_ARGUMENT;
|
||||
} else { // invalid version
|
||||
ALOGE("%s: camera device %s does not support version %s!",
|
||||
__FUNCTION__, cameraId.c_str(), deviceVersion.c_str());
|
||||
status = Status::OPERATION_NOT_SUPPORTED;
|
||||
}
|
||||
_hidl_cb(status, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (mCameraStatusMap.count(cameraId) == 0 ||
|
||||
mCameraStatusMap[cameraId] != CAMERA_DEVICE_STATUS_PRESENT) {
|
||||
_hidl_cb(Status::ILLEGAL_ARGUMENT, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
sp<android::hardware::camera::device::V1_0::implementation::CameraDevice> device =
|
||||
new android::hardware::camera::device::V1_0::implementation::CameraDevice(
|
||||
mModule, cameraId, mCameraDeviceNames);
|
||||
|
||||
if (device == nullptr) {
|
||||
ALOGE("%s: cannot allocate camera device for id %s", __FUNCTION__, cameraId.c_str());
|
||||
_hidl_cb(Status::INTERNAL_ERROR, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (device->isInitFailed()) {
|
||||
ALOGE("%s: camera device %s init failed!", __FUNCTION__, cameraId.c_str());
|
||||
device = nullptr;
|
||||
_hidl_cb(Status::INTERNAL_ERROR, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
_hidl_cb (Status::OK, device);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> CameraProvider::getCameraDeviceInterface_V3_x(
|
||||
const hidl_string& cameraDeviceName, getCameraDeviceInterface_V3_x_cb _hidl_cb) {
|
||||
std::string cameraId, deviceVersion;
|
||||
bool match = matchDeviceName(cameraDeviceName, &deviceVersion, &cameraId);
|
||||
if (!match) {
|
||||
_hidl_cb(Status::ILLEGAL_ARGUMENT, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
std::string deviceName(cameraDeviceName.c_str());
|
||||
ssize_t index = mCameraDeviceNames.indexOf(std::make_pair(cameraId, deviceName));
|
||||
if (index == NAME_NOT_FOUND) { // Either an illegal name or a device version mismatch
|
||||
Status status = Status::OK;
|
||||
ssize_t idx = mCameraIds.indexOf(cameraId);
|
||||
if (idx == NAME_NOT_FOUND) {
|
||||
ALOGE("%s: cannot find camera %s!", __FUNCTION__, cameraId.c_str());
|
||||
status = Status::ILLEGAL_ARGUMENT;
|
||||
} else { // invalid version
|
||||
ALOGE("%s: camera device %s does not support version %s!",
|
||||
__FUNCTION__, cameraId.c_str(), deviceVersion.c_str());
|
||||
status = Status::OPERATION_NOT_SUPPORTED;
|
||||
}
|
||||
_hidl_cb(status, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (mCameraStatusMap.count(cameraId) == 0 ||
|
||||
mCameraStatusMap[cameraId] != CAMERA_DEVICE_STATUS_PRESENT) {
|
||||
_hidl_cb(Status::ILLEGAL_ARGUMENT, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Since some Treble HAL revisions can map to the same legacy HAL version(s), we default
|
||||
// to the newest possible Treble HAL revision, but allow for override if needed via
|
||||
// system property.
|
||||
sp<android::hardware::camera::device::V3_2::ICameraDevice> device;
|
||||
switch (mPreferredHal3MinorVersion) {
|
||||
case 2: { // Map legacy camera device v3 HAL to Treble camera device HAL v3.2
|
||||
ALOGV("Constructing v3.2 camera device");
|
||||
sp<android::hardware::camera::device::V3_2::implementation::CameraDevice> deviceImpl =
|
||||
new android::hardware::camera::device::V3_2::implementation::CameraDevice(
|
||||
mModule, cameraId, mCameraDeviceNames);
|
||||
if (deviceImpl == nullptr || deviceImpl->isInitFailed()) {
|
||||
ALOGE("%s: camera device %s init failed!", __FUNCTION__, cameraId.c_str());
|
||||
device = nullptr;
|
||||
_hidl_cb(Status::INTERNAL_ERROR, nullptr);
|
||||
return Void();
|
||||
}
|
||||
device = deviceImpl;
|
||||
break;
|
||||
}
|
||||
case 3: { // Map legacy camera device v3 HAL to Treble camera device HAL v3.3
|
||||
ALOGV("Constructing v3.3 camera device");
|
||||
sp<android::hardware::camera::device::V3_2::implementation::CameraDevice> deviceImpl =
|
||||
new android::hardware::camera::device::V3_3::implementation::CameraDevice(
|
||||
mModule, cameraId, mCameraDeviceNames);
|
||||
if (deviceImpl == nullptr || deviceImpl->isInitFailed()) {
|
||||
ALOGE("%s: camera device %s init failed!", __FUNCTION__, cameraId.c_str());
|
||||
device = nullptr;
|
||||
_hidl_cb(Status::INTERNAL_ERROR, nullptr);
|
||||
return Void();
|
||||
}
|
||||
device = deviceImpl;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ALOGE("%s: Unknown HAL minor version %d!", __FUNCTION__, mPreferredHal3MinorVersion);
|
||||
device = nullptr;
|
||||
_hidl_cb(Status::INTERNAL_ERROR, nullptr);
|
||||
return Void();
|
||||
}
|
||||
_hidl_cb (Status::OK, device);
|
||||
return Void();
|
||||
}
|
||||
|
||||
ICameraProvider* HIDL_FETCH_ICameraProvider(const char* name) {
|
||||
if (strcmp(name, kLegacyProviderName) != 0) {
|
||||
return nullptr;
|
||||
}
|
||||
CameraProvider* provider = new CameraProvider();
|
||||
if (provider == nullptr) {
|
||||
ALOGE("%s: cannot allocate camera provider!", __FUNCTION__);
|
||||
return nullptr;
|
||||
}
|
||||
if (provider->isInitFailed()) {
|
||||
ALOGE("%s: camera provider init failed!", __FUNCTION__);
|
||||
delete provider;
|
||||
return nullptr;
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_4
|
||||
} // namespace provider
|
||||
} // namespace camera
|
||||
} // namespace hardware
|
||||
} // namespace android
|
|
@ -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.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_CAMERA_PROVIDER_V2_4_CAMERAPROVIDER_H
|
||||
#define ANDROID_HARDWARE_CAMERA_PROVIDER_V2_4_CAMERAPROVIDER_H
|
||||
|
||||
#include <regex>
|
||||
#include "hardware/camera_common.h"
|
||||
#include "utils/Mutex.h"
|
||||
#include "utils/SortedVector.h"
|
||||
#include <android/hardware/camera/provider/2.4/ICameraProvider.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include "CameraModule.h"
|
||||
#include "VendorTagDescriptor.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace camera {
|
||||
namespace provider {
|
||||
namespace V2_4 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::camera::common::V1_0::CameraDeviceStatus;
|
||||
using ::android::hardware::camera::common::V1_0::Status;
|
||||
using ::android::hardware::camera::common::V1_0::TorchModeStatus;
|
||||
using ::android::hardware::camera::common::V1_0::VendorTag;
|
||||
using ::android::hardware::camera::common::V1_0::VendorTagSection;
|
||||
using ::android::hardware::camera::common::V1_0::helper::CameraModule;
|
||||
using ::android::hardware::camera::common::V1_0::helper::VendorTagDescriptor;
|
||||
using ::android::hardware::camera::provider::V2_4::ICameraProvider;
|
||||
using ::android::hardware::camera::provider::V2_4::ICameraProviderCallback;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
using ::android::Mutex;
|
||||
|
||||
struct CameraProvider : public ICameraProvider, public camera_module_callbacks_t {
|
||||
CameraProvider();
|
||||
~CameraProvider();
|
||||
|
||||
// Caller must use this method to check if CameraProvider ctor failed
|
||||
bool isInitFailed() { return mInitFailed; }
|
||||
|
||||
// Methods from ::android::hardware::camera::provider::V2_4::ICameraProvider follow.
|
||||
Return<Status> setCallback(const sp<ICameraProviderCallback>& callback) override;
|
||||
Return<void> getVendorTags(getVendorTags_cb _hidl_cb) override;
|
||||
Return<void> getCameraIdList(getCameraIdList_cb _hidl_cb) override;
|
||||
Return<void> isSetTorchModeSupported(isSetTorchModeSupported_cb _hidl_cb) override;
|
||||
Return<void> getCameraDeviceInterface_V1_x(
|
||||
const hidl_string& cameraDeviceName,
|
||||
getCameraDeviceInterface_V1_x_cb _hidl_cb) override;
|
||||
Return<void> getCameraDeviceInterface_V3_x(
|
||||
const hidl_string& cameraDeviceName,
|
||||
getCameraDeviceInterface_V3_x_cb _hidl_cb) override;
|
||||
|
||||
private:
|
||||
Mutex mCbLock;
|
||||
sp<ICameraProviderCallback> mCallbacks = nullptr;
|
||||
|
||||
sp<CameraModule> mModule;
|
||||
|
||||
int mNumberOfLegacyCameras;
|
||||
std::map<std::string, camera_device_status_t> mCameraStatusMap; // camera id -> status
|
||||
std::map<std::string, bool> mOpenLegacySupported; // camera id -> open_legacy HAL1.0 supported
|
||||
SortedVector<std::string> mCameraIds; // the "0"/"1" legacy camera Ids
|
||||
// (cameraId string, hidl device name) pairs
|
||||
SortedVector<std::pair<std::string, std::string>> mCameraDeviceNames;
|
||||
|
||||
int mPreferredHal3MinorVersion;
|
||||
|
||||
// Must be queried before using any APIs.
|
||||
// APIs will only work when this returns true
|
||||
bool mInitFailed;
|
||||
bool initialize();
|
||||
|
||||
hidl_vec<VendorTagSection> mVendorTagSections;
|
||||
bool setUpVendorTags();
|
||||
int checkCameraVersion(int id, camera_info info);
|
||||
|
||||
// create HIDL device name from camera ID and legacy device version
|
||||
std::string getHidlDeviceName(std::string cameraId, int deviceVersion);
|
||||
|
||||
// extract legacy camera ID/device version from a HIDL device name
|
||||
static std::string getLegacyCameraId(const hidl_string& deviceName);
|
||||
static int getCameraDeviceVersion(const hidl_string& deviceName);
|
||||
|
||||
// convert conventional HAL status to HIDL Status
|
||||
static Status getHidlStatus(int);
|
||||
|
||||
// static callback forwarding methods
|
||||
static void sCameraDeviceStatusChange(
|
||||
const struct camera_module_callbacks* callbacks,
|
||||
int camera_id,
|
||||
int new_status);
|
||||
static void sTorchModeStatusChange(
|
||||
const struct camera_module_callbacks* callbacks,
|
||||
const char* camera_id,
|
||||
int new_status);
|
||||
};
|
||||
|
||||
extern "C" ICameraProvider* HIDL_FETCH_ICameraProvider(const char* name);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_4
|
||||
} // namespace provider
|
||||
} // namespace camera
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_CAMERA_PROVIDER_V2_4_CAMERAPROVIDER_H
|
|
@ -0,0 +1,6 @@
|
|||
cychen@google.com
|
||||
epeev@google.com
|
||||
etalvala@google.com
|
||||
shuzhenwang@google.com
|
||||
yinchiayeh@google.com
|
||||
zhijunhe@google.com
|
|
@ -0,0 +1,7 @@
|
|||
service camera-provider-2-4 /vendor/bin/hw/android.hardware.camera.provider@2.4-service
|
||||
class hal
|
||||
user cameraserver
|
||||
group audio camera input drmrpc
|
||||
ioprio rt 4
|
||||
capabilities SYS_NICE
|
||||
writepid /dev/cpuset/camera-daemon/tasks /dev/stune/top-app/tasks
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.camera.provider@2.4-service"
|
||||
|
||||
#include <android/hardware/camera/provider/2.4/ICameraProvider.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
#include <binder/ProcessState.h>
|
||||
|
||||
using android::hardware::camera::provider::V2_4::ICameraProvider;
|
||||
using android::hardware::defaultPassthroughServiceImplementation;
|
||||
|
||||
int main()
|
||||
{
|
||||
ALOGI("Camera provider Service is starting.");
|
||||
// The camera HAL may communicate to other vendor components via
|
||||
// /dev/vndbinder
|
||||
android::ProcessState::initWithDriver("/dev/vndbinder");
|
||||
return defaultPassthroughServiceImplementation<ICameraProvider>("legacy/0", /*maxThreads*/ 6);
|
||||
}
|
11
android/hardware/interfaces/camera/provider/2.4/vts/OWNERS
Normal file
11
android/hardware/interfaces/camera/provider/2.4/vts/OWNERS
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Camera team
|
||||
cychen@google.com
|
||||
epeev@google.com
|
||||
etalvala@google.com
|
||||
shuzhenwang@google.com
|
||||
yinchiayeh@google.com
|
||||
zhijunhe@google.com
|
||||
|
||||
# VTS team
|
||||
yim@google.com
|
||||
zhuoyao@google.com
|
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalCameraProviderV2_4TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["VtsHalCameraProviderV2_4TargetTest.cpp"],
|
||||
|
||||
// TODO(b/64437680): Assume these are always available on the device.
|
||||
shared_libs: [
|
||||
"libbinder",
|
||||
"libcamera_metadata",
|
||||
"libfmq",
|
||||
"libgui",
|
||||
"libui",
|
||||
],
|
||||
|
||||
// Statically link to libs not guaranteed to be present on the device.
|
||||
static_libs: [
|
||||
"android.hardware.camera.common@1.0",
|
||||
"android.hardware.camera.common@1.0-helper",
|
||||
"android.hardware.camera.device@1.0",
|
||||
"android.hardware.camera.device@3.2",
|
||||
"android.hardware.camera.device@3.3",
|
||||
"android.hardware.camera.provider@2.4",
|
||||
"android.hardware.graphics.common@1.0",
|
||||
"android.hardware.graphics.mapper@2.0",
|
||||
"libgrallocusage",
|
||||
],
|
||||
}
|
File diff suppressed because it is too large
Load diff
37
android/hardware/interfaces/camera/provider/README.md
Normal file
37
android/hardware/interfaces/camera/provider/README.md
Normal 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.
|
Loading…
Add table
Add a link
Reference in a new issue