Camera: Add support for physical camera characteristics query
- Add version 3.5 for ICameraDevice for physical camera characteristics query. - Add version 3.5 for ICameraDeviceSession to work around HIDL versioning bug. Test: Camera CTS Bug: 79523700 Change-Id: I8df6cdd4ee6ac5755758510c0dc1ea1cec31aa73
This commit is contained in:
parent
51a04b2fe2
commit
d3feb3d62c
13 changed files with 484 additions and 29 deletions
|
@ -319,6 +319,41 @@ int CameraModule::getCameraInfo(int cameraId, struct camera_info *info) {
|
|||
return OK;
|
||||
}
|
||||
|
||||
int CameraModule::getPhysicalCameraInfo(int physicalCameraId, camera_metadata_t **physicalInfo) {
|
||||
ATRACE_CALL();
|
||||
Mutex::Autolock lock(mCameraInfoLock);
|
||||
if (physicalCameraId < 0) {
|
||||
ALOGE("%s: Invalid physical camera ID %d", __FUNCTION__, physicalCameraId);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// Only query physical camera info for 2.5 version for newer
|
||||
int apiVersion = mModule->common.module_api_version;
|
||||
if (apiVersion < CAMERA_MODULE_API_VERSION_2_5) {
|
||||
ALOGE("%s: Module version must be at least 2.5 to handle getPhysicalCameraInfo",
|
||||
__FUNCTION__);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ssize_t index = mPhysicalCameraInfoMap.indexOfKey(physicalCameraId);
|
||||
if (index == NAME_NOT_FOUND) {
|
||||
// Get physical camera characteristics, and cache it
|
||||
camera_metadata_t *info = nullptr;
|
||||
ATRACE_BEGIN("camera_module->get_physical_camera_info");
|
||||
int ret = mModule->get_physical_camera_info(physicalCameraId, &info);
|
||||
ATRACE_END();
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
index = mPhysicalCameraInfoMap.add(physicalCameraId, info);
|
||||
}
|
||||
|
||||
assert(index != NAME_NOT_FOUND);
|
||||
*physicalInfo = mPhysicalCameraInfoMap[index];
|
||||
return OK;
|
||||
}
|
||||
|
||||
int CameraModule::getDeviceVersion(int cameraId) {
|
||||
ssize_t index = mDeviceVersionMap.indexOfKey(cameraId);
|
||||
if (index == NAME_NOT_FOUND) {
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
void *getDso();
|
||||
// Only used by CameraProvider
|
||||
void removeCamera(int cameraId);
|
||||
int getPhysicalCameraInfo(int physicalCameraId, camera_metadata_t **physicalInfo);
|
||||
|
||||
private:
|
||||
// Derive camera characteristics keys defined after HAL device version
|
||||
|
@ -76,6 +77,7 @@ private:
|
|||
camera_module_t *mModule;
|
||||
KeyedVector<int, camera_info> mCameraInfoMap;
|
||||
KeyedVector<int, int> mDeviceVersionMap;
|
||||
KeyedVector<int, camera_metadata_t*> mPhysicalCameraInfoMap;
|
||||
Mutex mCameraInfoLock;
|
||||
};
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ Status CameraDevice::getHidlStatus(int status) {
|
|||
}
|
||||
|
||||
// Methods from ::android::hardware::camera::device::V3_2::ICameraDevice follow.
|
||||
Return<void> CameraDevice::getResourceCost(getResourceCost_cb _hidl_cb) {
|
||||
Return<void> CameraDevice::getResourceCost(ICameraDevice::getResourceCost_cb _hidl_cb) {
|
||||
Status status = initStatus();
|
||||
CameraResourceCost resCost;
|
||||
if (status == Status::OK) {
|
||||
|
@ -141,7 +141,8 @@ Return<void> CameraDevice::getResourceCost(getResourceCost_cb _hidl_cb) {
|
|||
return Void();
|
||||
}
|
||||
|
||||
Return<void> CameraDevice::getCameraCharacteristics(getCameraCharacteristics_cb _hidl_cb) {
|
||||
Return<void> CameraDevice::getCameraCharacteristics(
|
||||
ICameraDevice::getCameraCharacteristics_cb _hidl_cb) {
|
||||
Status status = initStatus();
|
||||
CameraMetadata cameraCharacteristics;
|
||||
if (status == Status::OK) {
|
||||
|
@ -172,7 +173,8 @@ Return<Status> CameraDevice::setTorchMode(TorchMode mode) {
|
|||
return status;
|
||||
}
|
||||
|
||||
Return<void> CameraDevice::open(const sp<ICameraDeviceCallback>& callback, open_cb _hidl_cb) {
|
||||
Return<void> CameraDevice::open(const sp<ICameraDeviceCallback>& callback,
|
||||
ICameraDevice::open_cb _hidl_cb) {
|
||||
Status status = initStatus();
|
||||
sp<CameraDeviceSession> session = nullptr;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ using ::android::Mutex;
|
|||
/*
|
||||
* The camera device HAL implementation is opened lazily (via the open call)
|
||||
*/
|
||||
struct CameraDevice : public ICameraDevice {
|
||||
struct CameraDevice : public virtual RefBase {
|
||||
// Called by provider HAL. Provider HAL must ensure the uniqueness of
|
||||
// CameraDevice object per cameraId, or there could be multiple CameraDevice
|
||||
// trying to access the same physical camera.
|
||||
|
@ -60,7 +60,14 @@ struct CameraDevice : public ICameraDevice {
|
|||
CameraDevice(sp<CameraModule> module,
|
||||
const std::string& cameraId,
|
||||
const SortedVector<std::pair<std::string, std::string>>& cameraDeviceNames);
|
||||
~CameraDevice();
|
||||
virtual ~CameraDevice();
|
||||
|
||||
// Retrieve the HIDL interface, split into its own class to avoid inheritance issues when
|
||||
// dealing with minor version revs and simultaneous implementation and interface inheritance
|
||||
virtual sp<ICameraDevice> getInterface() {
|
||||
return new TrampolineDeviceInterface_3_2(this);
|
||||
}
|
||||
|
||||
// Caller must use this method to check if CameraDevice ctor failed
|
||||
bool isInitFailed() { return mInitFail; }
|
||||
// Used by provider HAL to signal external camera disconnected
|
||||
|
@ -68,16 +75,16 @@ struct CameraDevice : public ICameraDevice {
|
|||
|
||||
/* Methods from ::android::hardware::camera::device::V3_2::ICameraDevice follow. */
|
||||
// The following method can be called without opening the actual camera device
|
||||
Return<void> getResourceCost(getResourceCost_cb _hidl_cb) override;
|
||||
Return<void> getCameraCharacteristics(getCameraCharacteristics_cb _hidl_cb) override;
|
||||
Return<Status> setTorchMode(TorchMode mode) override;
|
||||
Return<void> getResourceCost(ICameraDevice::getResourceCost_cb _hidl_cb);
|
||||
Return<void> getCameraCharacteristics(ICameraDevice::getCameraCharacteristics_cb _hidl_cb);
|
||||
Return<Status> setTorchMode(TorchMode mode);
|
||||
|
||||
// Open the device HAL and also return a default capture session
|
||||
Return<void> open(const sp<ICameraDeviceCallback>& callback, open_cb _hidl_cb) override;
|
||||
Return<void> open(const sp<ICameraDeviceCallback>& callback, ICameraDevice::open_cb _hidl_cb);
|
||||
|
||||
|
||||
// Forward the dump call to the opened session, or do nothing
|
||||
Return<void> dumpState(const ::android::hardware::hidl_handle& fd) override;
|
||||
Return<void> dumpState(const ::android::hardware::hidl_handle& fd);
|
||||
/* End of Methods from ::android::hardware::camera::device::V3_2::ICameraDevice */
|
||||
|
||||
protected:
|
||||
|
@ -106,6 +113,39 @@ protected:
|
|||
static Status getHidlStatus(int);
|
||||
|
||||
Status initStatus() const;
|
||||
|
||||
private:
|
||||
struct TrampolineDeviceInterface_3_2 : public ICameraDevice {
|
||||
TrampolineDeviceInterface_3_2(sp<CameraDevice> parent) :
|
||||
mParent(parent) {}
|
||||
|
||||
virtual Return<void> getResourceCost(V3_2::ICameraDevice::getResourceCost_cb _hidl_cb)
|
||||
override {
|
||||
return mParent->getResourceCost(_hidl_cb);
|
||||
}
|
||||
|
||||
virtual Return<void> getCameraCharacteristics(
|
||||
V3_2::ICameraDevice::getCameraCharacteristics_cb _hidl_cb) override {
|
||||
return mParent->getCameraCharacteristics(_hidl_cb);
|
||||
}
|
||||
|
||||
virtual Return<Status> setTorchMode(TorchMode mode) override {
|
||||
return mParent->setTorchMode(mode);
|
||||
}
|
||||
|
||||
virtual Return<void> open(const sp<V3_2::ICameraDeviceCallback>& callback,
|
||||
V3_2::ICameraDevice::open_cb _hidl_cb) override {
|
||||
return mParent->open(callback, _hidl_cb);
|
||||
}
|
||||
|
||||
virtual Return<void> dumpState(const hidl_handle& fd) override {
|
||||
return mParent->dumpState(fd);
|
||||
}
|
||||
|
||||
private:
|
||||
sp<CameraDevice> mParent;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
|
23
camera/device/3.5/Android.bp
Normal file
23
camera/device/3.5/Android.bp
Normal file
|
@ -0,0 +1,23 @@
|
|||
// This file is autogenerated by hidl-gen -Landroidbp.
|
||||
|
||||
hidl_interface {
|
||||
name: "android.hardware.camera.device@3.5",
|
||||
root: "android.hardware",
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
srcs: [
|
||||
"ICameraDevice.hal",
|
||||
"ICameraDeviceSession.hal",
|
||||
],
|
||||
interfaces: [
|
||||
"android.hardware.camera.common@1.0",
|
||||
"android.hardware.camera.device@3.2",
|
||||
"android.hardware.camera.device@3.3",
|
||||
"android.hardware.camera.device@3.4",
|
||||
"android.hardware.graphics.common@1.0",
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
gen_java: false,
|
||||
}
|
||||
|
62
camera/device/3.5/ICameraDevice.hal
Normal file
62
camera/device/3.5/ICameraDevice.hal
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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.5;
|
||||
|
||||
import android.hardware.camera.common@1.0::Status;
|
||||
import @3.2::CameraMetadata;
|
||||
import @3.2::ICameraDevice;
|
||||
|
||||
/**
|
||||
* Camera device interface
|
||||
*
|
||||
* Supports the android.hardware.Camera API, and the android.hardware.camera2
|
||||
* API at LIMITED or better hardware level.
|
||||
*
|
||||
*/
|
||||
interface ICameraDevice extends @3.2::ICameraDevice {
|
||||
|
||||
/**
|
||||
* getPhysicalCameraCharacteristics:
|
||||
*
|
||||
* Return the static camera information for a physical camera ID backing
|
||||
* this logical camera device. This information may not change between consecutive calls.
|
||||
*
|
||||
* Note that HAL must support this function for physical camera IDs that are
|
||||
* not exposed via ICameraProvider::getCameraIdList().
|
||||
*
|
||||
* @return status Status code for the operation, one of:
|
||||
* OK:
|
||||
* On a successful query of the camera device characteristics
|
||||
* 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 logical camera device's physical device, or an empty
|
||||
* metadata structure if status is not OK.
|
||||
*
|
||||
*/
|
||||
getPhysicalCameraCharacteristics(string physicalCameraId)
|
||||
generates (Status status, CameraMetadata cameraCharacteristics);
|
||||
|
||||
};
|
29
camera/device/3.5/ICameraDeviceSession.hal
Normal file
29
camera/device/3.5/ICameraDeviceSession.hal
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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.5;
|
||||
|
||||
import android.hardware.camera.common@1.0::Status;
|
||||
import @3.4::ICameraDeviceSession;
|
||||
|
||||
/**
|
||||
* 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 extends @3.4::ICameraDeviceSession {
|
||||
};
|
53
camera/device/3.5/default/Android.bp
Normal file
53
camera/device/3.5/default/Android.bp
Normal file
|
@ -0,0 +1,53 @@
|
|||
//
|
||||
// Copyright (C) 2018 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_library_headers {
|
||||
name: "camera.device@3.5-impl_headers",
|
||||
vendor: true,
|
||||
export_include_dirs: ["include/device_v3_5_impl"]
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
name: "camera.device@3.5-impl",
|
||||
defaults: ["hidl_defaults"],
|
||||
proprietary: true,
|
||||
vendor: true,
|
||||
srcs: [
|
||||
"CameraDevice.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
"camera.device@3.2-impl",
|
||||
"camera.device@3.3-impl",
|
||||
"camera.device@3.4-impl",
|
||||
"android.hardware.camera.device@3.2",
|
||||
"android.hardware.camera.device@3.3",
|
||||
"android.hardware.camera.device@3.4",
|
||||
"android.hardware.camera.device@3.5",
|
||||
"android.hardware.camera.provider@2.4",
|
||||
"android.hardware.graphics.mapper@2.0",
|
||||
"liblog",
|
||||
"libhardware",
|
||||
"libcamera_metadata",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.camera.common@1.0-helper",
|
||||
],
|
||||
local_include_dirs: ["include/device_v3_5_impl"],
|
||||
}
|
86
camera/device/3.5/default/CameraDevice.cpp
Normal file
86
camera/device/3.5/default/CameraDevice.cpp
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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 "CamDev@3.5-impl"
|
||||
#include <log/log.h>
|
||||
|
||||
#include "CameraModule.h"
|
||||
#include "CameraDevice_3_5.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace camera {
|
||||
namespace device {
|
||||
namespace V3_5 {
|
||||
namespace implementation {
|
||||
|
||||
using namespace ::android::hardware::camera::device;
|
||||
using ::android::hardware::camera::common::V1_0::Status;
|
||||
using ::android::hardware::camera::device::V3_2::CameraMetadata;
|
||||
|
||||
CameraDevice::CameraDevice(sp<CameraModule> module, const std::string& cameraId,
|
||||
const SortedVector<std::pair<std::string, std::string>>& cameraDeviceNames) :
|
||||
V3_4::implementation::CameraDevice(module, cameraId, cameraDeviceNames) {
|
||||
}
|
||||
|
||||
CameraDevice::~CameraDevice() {
|
||||
}
|
||||
|
||||
Return<void> CameraDevice::getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId,
|
||||
V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) {
|
||||
Status status = initStatus();
|
||||
CameraMetadata cameraCharacteristics;
|
||||
if (status == Status::OK) {
|
||||
// Require module 2.5+ version.
|
||||
if (mModule->getModuleApiVersion() < CAMERA_MODULE_API_VERSION_2_5) {
|
||||
ALOGE("%s: get_physical_camera_info must be called on camera module 2.5 or newer",
|
||||
__FUNCTION__);
|
||||
status = Status::INTERNAL_ERROR;
|
||||
} else {
|
||||
char *end;
|
||||
errno = 0;
|
||||
long id = strtol(physicalCameraId.c_str(), &end, 0);
|
||||
if (id > INT_MAX || (errno == ERANGE && id == LONG_MAX) ||
|
||||
id < INT_MIN || (errno == ERANGE && id == LONG_MIN) ||
|
||||
*end != '\0') {
|
||||
ALOGE("%s: Invalid physicalCameraId %s", __FUNCTION__, physicalCameraId.c_str());
|
||||
status = Status::ILLEGAL_ARGUMENT;
|
||||
} else {
|
||||
camera_metadata_t *physicalInfo = nullptr;
|
||||
int ret = mModule->getPhysicalCameraInfo((int)id, &physicalInfo);
|
||||
if (ret == OK) {
|
||||
V3_2::implementation::convertToHidl(physicalInfo, &cameraCharacteristics);
|
||||
} else {
|
||||
ALOGE("%s: Failed to get physical camera %s info: %s (%d)!", __FUNCTION__,
|
||||
physicalCameraId.c_str(), strerror(-ret), ret);
|
||||
status = Status::INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_hidl_cb(status, cameraCharacteristics);
|
||||
return Void();
|
||||
}
|
||||
|
||||
// End of methods from ::android::hardware::camera::device::V3_2::ICameraDevice.
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V3_5
|
||||
} // namespace device
|
||||
} // namespace camera
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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_DEVICE_V3_5_CAMERADEVICE_H
|
||||
#define ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_CAMERADEVICE_H
|
||||
|
||||
#include "CameraModule.h"
|
||||
#include <../../../../3.4/default/include/device_v3_4_impl/CameraDevice_3_4.h>
|
||||
|
||||
#include <android/hardware/camera/device/3.5/ICameraDevice.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace camera {
|
||||
namespace device {
|
||||
namespace V3_5 {
|
||||
namespace implementation {
|
||||
|
||||
using namespace ::android::hardware::camera::device;
|
||||
|
||||
using ::android::hardware::camera::common::V1_0::helper::CameraModule;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::camera::common::V1_0::TorchMode;
|
||||
using ::android::hardware::camera::common::V1_0::helper::CameraModule;
|
||||
using ::android::hardware::camera::common::V1_0::Status;
|
||||
using ::android::sp;
|
||||
|
||||
struct CameraDevice : public V3_4::implementation::CameraDevice {
|
||||
// Called by provider HAL.
|
||||
// Provider HAL must ensure the uniqueness of CameraDevice object per cameraId, or there could
|
||||
// be multiple CameraDevice trying to access the same physical camera. Also, provider will have
|
||||
// to keep track of all CameraDevice objects in order to notify CameraDevice when the underlying
|
||||
// camera is detached.
|
||||
// Delegates nearly all work to CameraDevice_3_4
|
||||
CameraDevice(sp<CameraModule> module,
|
||||
const std::string& cameraId,
|
||||
const SortedVector<std::pair<std::string, std::string>>& cameraDeviceNames);
|
||||
virtual ~CameraDevice();
|
||||
|
||||
virtual sp<V3_2::ICameraDevice> getInterface() override {
|
||||
return new TrampolineDeviceInterface_3_5(this);
|
||||
}
|
||||
|
||||
protected:
|
||||
Return<void> getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId,
|
||||
V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb);
|
||||
|
||||
private:
|
||||
struct TrampolineDeviceInterface_3_5 : public ICameraDevice {
|
||||
TrampolineDeviceInterface_3_5(sp<CameraDevice> parent) :
|
||||
mParent(parent) {}
|
||||
|
||||
virtual Return<void> getResourceCost(V3_2::ICameraDevice::getResourceCost_cb _hidl_cb)
|
||||
override {
|
||||
return mParent->getResourceCost(_hidl_cb);
|
||||
}
|
||||
|
||||
virtual Return<void> getCameraCharacteristics(
|
||||
V3_2::ICameraDevice::getCameraCharacteristics_cb _hidl_cb) override {
|
||||
return mParent->getCameraCharacteristics(_hidl_cb);
|
||||
}
|
||||
|
||||
virtual Return<Status> setTorchMode(TorchMode mode) override {
|
||||
return mParent->setTorchMode(mode);
|
||||
}
|
||||
|
||||
virtual Return<void> open(const sp<V3_2::ICameraDeviceCallback>& callback,
|
||||
V3_2::ICameraDevice::open_cb _hidl_cb) override {
|
||||
return mParent->open(callback, _hidl_cb);
|
||||
}
|
||||
|
||||
virtual Return<void> dumpState(const hidl_handle& fd) override {
|
||||
return mParent->dumpState(fd);
|
||||
}
|
||||
|
||||
virtual Return<void> getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId,
|
||||
V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) override {
|
||||
return mParent->getPhysicalCameraCharacteristics(physicalCameraId, _hidl_cb);
|
||||
}
|
||||
private:
|
||||
sp<CameraDevice> mParent;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V3_5
|
||||
} // namespace device
|
||||
} // namespace camera
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_CAMERA_DEVICE_V3_5_CAMERADEVICE_H
|
|
@ -14,6 +14,7 @@ hidl_interface {
|
|||
"android.hardware.camera.common@1.0",
|
||||
"android.hardware.camera.device@1.0",
|
||||
"android.hardware.camera.device@3.2",
|
||||
"android.hardware.camera.device@3.5",
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
gen_java: false,
|
||||
|
|
|
@ -14,10 +14,12 @@ cc_library_shared {
|
|||
"android.hardware.camera.device@3.2",
|
||||
"android.hardware.camera.device@3.3",
|
||||
"android.hardware.camera.device@3.4",
|
||||
"android.hardware.camera.device@3.5",
|
||||
"camera.device@1.0-impl",
|
||||
"camera.device@3.2-impl",
|
||||
"camera.device@3.3-impl",
|
||||
"camera.device@3.4-impl",
|
||||
"camera.device@3.5-impl",
|
||||
"camera.device@3.4-external-impl",
|
||||
"android.hardware.camera.provider@2.4",
|
||||
"android.hardware.camera.common@1.0",
|
||||
|
@ -31,6 +33,7 @@ cc_library_shared {
|
|||
],
|
||||
header_libs: [
|
||||
"camera.device@3.4-impl_headers",
|
||||
"camera.device@3.5-impl_headers",
|
||||
"camera.device@3.4-external-impl_headers"
|
||||
],
|
||||
static_libs: [
|
||||
|
@ -56,6 +59,7 @@ cc_binary {
|
|||
"android.hardware.camera.device@3.2",
|
||||
"android.hardware.camera.device@3.3",
|
||||
"android.hardware.camera.device@3.4",
|
||||
"android.hardware.camera.device@3.5",
|
||||
"android.hardware.camera.provider@2.4",
|
||||
"android.hardware.camera.common@1.0",
|
||||
],
|
||||
|
@ -80,6 +84,7 @@ cc_binary {
|
|||
"android.hardware.camera.device@3.2",
|
||||
"android.hardware.camera.device@3.3",
|
||||
"android.hardware.camera.device@3.4",
|
||||
"android.hardware.camera.device@3.5",
|
||||
"android.hardware.camera.provider@2.4",
|
||||
"android.hardware.camera.common@1.0",
|
||||
],
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "CameraDevice_1_0.h"
|
||||
#include "CameraDevice_3_3.h"
|
||||
#include "CameraDevice_3_4.h"
|
||||
#include "CameraDevice_3_5.h"
|
||||
#include <cutils/properties.h>
|
||||
#include <string.h>
|
||||
#include <utils/Trace.h>
|
||||
|
@ -43,6 +44,7 @@ const std::regex kDeviceNameRE("device@([0-9]+\\.[0-9]+)/legacy/(.+)");
|
|||
const char *kHAL3_2 = "3.2";
|
||||
const char *kHAL3_3 = "3.3";
|
||||
const char *kHAL3_4 = "3.4";
|
||||
const char *kHAL3_5 = "3.5";
|
||||
const char *kHAL1_0 = "1.0";
|
||||
const int kMaxCameraDeviceNameLen = 128;
|
||||
const int kMaxCameraIdLen = 16;
|
||||
|
@ -250,7 +252,11 @@ std::string CameraProvider::getHidlDeviceName(
|
|||
int versionMajor = isV1 ? 1 : 3;
|
||||
int versionMinor = isV1 ? 0 : mPreferredHal3MinorVersion;
|
||||
if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_5) {
|
||||
versionMinor = 4;
|
||||
if (mModule->getModuleApiVersion() == CAMERA_MODULE_API_VERSION_2_5) {
|
||||
versionMinor = 5;
|
||||
} else {
|
||||
versionMinor = 4;
|
||||
}
|
||||
}
|
||||
char deviceName[kMaxCameraDeviceNameLen];
|
||||
snprintf(deviceName, sizeof(deviceName), "device@%d.%d/legacy/%s",
|
||||
|
@ -546,21 +552,31 @@ Return<void> CameraProvider::getCameraDeviceInterface_V3_x(
|
|||
return Void();
|
||||
}
|
||||
|
||||
sp<android::hardware::camera::device::V3_2::ICameraDevice> device;
|
||||
if (deviceVersion == kHAL3_4) {
|
||||
sp<android::hardware::camera::device::V3_2::implementation::CameraDevice> deviceImpl;
|
||||
if (deviceVersion >= kHAL3_4) {
|
||||
ALOGV("Constructing v3.4 camera device");
|
||||
sp<android::hardware::camera::device::V3_2::implementation::CameraDevice> deviceImpl =
|
||||
new android::hardware::camera::device::V3_4::implementation::CameraDevice(
|
||||
if (deviceVersion == kHAL3_4) {
|
||||
deviceImpl = new android::hardware::camera::device::V3_4::implementation::CameraDevice(
|
||||
mModule, cameraId, mCameraDeviceNames);
|
||||
} else if (deviceVersion == kHAL3_5) {
|
||||
deviceImpl = new android::hardware::camera::device::V3_5::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;
|
||||
_hidl_cb (Status::OK, device);
|
||||
IF_ALOGV() {
|
||||
deviceImpl->getInterface()->interfaceChain([](
|
||||
::android::hardware::hidl_vec<::android::hardware::hidl_string> interfaceChain) {
|
||||
ALOGV("Device interface chain:");
|
||||
for (auto iface : interfaceChain) {
|
||||
ALOGV(" %s", iface.c_str());
|
||||
}
|
||||
});
|
||||
}
|
||||
_hidl_cb (Status::OK, deviceImpl->getInterface());
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
@ -570,39 +586,33 @@ Return<void> CameraProvider::getCameraDeviceInterface_V3_x(
|
|||
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(
|
||||
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(
|
||||
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);
|
||||
|
||||
_hidl_cb (Status::OK, deviceImpl->getInterface());
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue