summaryrefslogtreecommitdiff
path: root/camera/common
diff options
context:
space:
mode:
Diffstat (limited to 'camera/common')
-rw-r--r--camera/common/1.0/default/Android.bp1
-rw-r--r--camera/common/1.0/default/CameraMetadata.cpp31
-rw-r--r--camera/common/1.0/default/CameraModule.cpp137
-rw-r--r--camera/common/1.0/default/HandleImporter.cpp244
-rw-r--r--camera/common/1.0/default/OWNERS7
-rw-r--r--camera/common/1.0/default/VendorTagDescriptor.cpp171
-rw-r--r--camera/common/1.0/default/include/CameraModule.h12
-rw-r--r--camera/common/1.0/default/include/HandleImporter.h13
-rw-r--r--camera/common/1.0/default/include/VendorTagDescriptor.h75
9 files changed, 575 insertions, 116 deletions
diff --git a/camera/common/1.0/default/Android.bp b/camera/common/1.0/default/Android.bp
index 21f81f5acc..3e5c6d7812 100644
--- a/camera/common/1.0/default/Android.bp
+++ b/camera/common/1.0/default/Android.bp
@@ -20,6 +20,7 @@ cc_library_static {
"libhardware",
"libcamera_metadata",
"android.hardware.graphics.mapper@2.0",
+ "android.hardware.graphics.mapper@3.0",
"libexif",
],
include_dirs: ["system/media/private/camera/include"],
diff --git a/camera/common/1.0/default/CameraMetadata.cpp b/camera/common/1.0/default/CameraMetadata.cpp
index 4c54931a11..eb1bd1c149 100644
--- a/camera/common/1.0/default/CameraMetadata.cpp
+++ b/camera/common/1.0/default/CameraMetadata.cpp
@@ -171,17 +171,16 @@ status_t CameraMetadata::sort() {
}
status_t CameraMetadata::checkType(uint32_t tag, uint8_t expectedType) {
- int tagType = get_camera_metadata_tag_type(tag);
+ int tagType = get_local_camera_metadata_tag_type(tag, mBuffer);
if ( CC_UNLIKELY(tagType == -1)) {
ALOGE("Update metadata entry: Unknown tag %d", tag);
return INVALID_OPERATION;
}
if ( CC_UNLIKELY(tagType != expectedType) ) {
ALOGE("Mismatched tag type when updating entry %s (%d) of type %s; "
- "got type %s data instead ",
- get_camera_metadata_tag_name(tag), tag,
- camera_metadata_type_names[tagType],
- camera_metadata_type_names[expectedType]);
+ "got type %s data instead ",
+ get_local_camera_metadata_tag_name(tag, mBuffer), tag,
+ camera_metadata_type_names[tagType], camera_metadata_type_names[expectedType]);
return INVALID_OPERATION;
}
return OK;
@@ -298,7 +297,7 @@ status_t CameraMetadata::updateImpl(uint32_t tag, const void *data,
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return INVALID_OPERATION;
}
- int type = get_camera_metadata_tag_type(tag);
+ int type = get_local_camera_metadata_tag_type(tag, mBuffer);
if (type == -1) {
ALOGE("%s: Tag %d not found", __FUNCTION__, tag);
return BAD_VALUE;
@@ -332,9 +331,9 @@ status_t CameraMetadata::updateImpl(uint32_t tag, const void *data,
}
if (res != OK) {
- ALOGE("%s: Unable to update metadata entry %s.%s (%x): %s (%d)",
- __FUNCTION__, get_camera_metadata_section_name(tag),
- get_camera_metadata_tag_name(tag), tag, strerror(-res), res);
+ ALOGE("%s: Unable to update metadata entry %s.%s (%x): %s (%d)", __FUNCTION__,
+ get_local_camera_metadata_section_name(tag, mBuffer),
+ get_local_camera_metadata_tag_name(tag, mBuffer), tag, strerror(-res), res);
}
IF_ALOGV() {
@@ -391,18 +390,16 @@ status_t CameraMetadata::erase(uint32_t tag) {
if (res == NAME_NOT_FOUND) {
return OK;
} else if (res != OK) {
- ALOGE("%s: Error looking for entry %s.%s (%x): %s %d",
- __FUNCTION__,
- get_camera_metadata_section_name(tag),
- get_camera_metadata_tag_name(tag), tag, strerror(-res), res);
+ ALOGE("%s: Error looking for entry %s.%s (%x): %s %d", __FUNCTION__,
+ get_local_camera_metadata_section_name(tag, mBuffer),
+ get_local_camera_metadata_tag_name(tag, mBuffer), tag, strerror(-res), res);
return res;
}
res = delete_camera_metadata_entry(mBuffer, entry.index);
if (res != OK) {
- ALOGE("%s: Error deleting entry %s.%s (%x): %s %d",
- __FUNCTION__,
- get_camera_metadata_section_name(tag),
- get_camera_metadata_tag_name(tag), tag, strerror(-res), res);
+ ALOGE("%s: Error deleting entry %s.%s (%x): %s %d", __FUNCTION__,
+ get_local_camera_metadata_section_name(tag, mBuffer),
+ get_local_camera_metadata_tag_name(tag, mBuffer), tag, strerror(-res), res);
}
return res;
}
diff --git a/camera/common/1.0/default/CameraModule.cpp b/camera/common/1.0/default/CameraModule.cpp
index dc4e0f01ff..467c121a94 100644
--- a/camera/common/1.0/default/CameraModule.cpp
+++ b/camera/common/1.0/default/CameraModule.cpp
@@ -235,7 +235,7 @@ void CameraModule::appendAvailableKeys(CameraMetadata &chars,
chars.update(keyTag, availableKeys);
}
-CameraModule::CameraModule(camera_module_t *module) {
+CameraModule::CameraModule(camera_module_t *module) : mNumberOfCameras(0) {
if (module == NULL) {
ALOGE("%s: camera hardware module must not be null", __FUNCTION__);
assert(0);
@@ -253,6 +253,14 @@ CameraModule::~CameraModule()
}
mCameraInfoMap.removeItemsAt(0);
}
+
+ while (mPhysicalCameraInfoMap.size() > 0) {
+ camera_metadata_t* metadata = mPhysicalCameraInfoMap.editValueAt(0);
+ if (metadata != NULL) {
+ free_camera_metadata(metadata);
+ }
+ mPhysicalCameraInfoMap.removeItemsAt(0);
+ }
}
int CameraModule::init() {
@@ -264,7 +272,8 @@ int CameraModule::init() {
res = mModule->init();
ATRACE_END();
}
- mCameraInfoMap.setCapacity(getNumberOfCameras());
+ mNumberOfCameras = getNumberOfCameras();
+ mCameraInfoMap.setCapacity(mNumberOfCameras);
return res;
}
@@ -319,6 +328,52 @@ 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 < mNumberOfCameras) {
+ 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;
+ }
+ if (mModule->get_physical_camera_info == nullptr) {
+ ALOGE("%s: get_physical_camera is NULL for module version 2.5", __FUNCTION__);
+ return -EINVAL;
+ }
+
+ 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;
+ }
+
+ // The camera_metadata_t returned by get_physical_camera_info could be using
+ // more memory than necessary due to unused reserved space. Reduce the
+ // size by appending it to a new CameraMetadata object, which internally
+ // calls resizeIfNeeded.
+ CameraMetadata m;
+ m.append(info);
+ camera_metadata_t* derivedMetadata = m.release();
+ index = mPhysicalCameraInfoMap.add(physicalCameraId, derivedMetadata);
+ }
+
+ 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) {
@@ -412,6 +467,64 @@ int CameraModule::setTorchMode(const char* camera_id, bool enable) {
return res;
}
+int CameraModule::isStreamCombinationSupported(int cameraId, camera_stream_combination_t *streams) {
+ int res = INVALID_OPERATION;
+ if (mModule->is_stream_combination_supported != NULL) {
+ ATRACE_BEGIN("camera_module->is_stream_combination_supported");
+ res = mModule->is_stream_combination_supported(cameraId, streams);
+ ATRACE_END();
+ }
+ return res;
+}
+
+void CameraModule::notifyDeviceStateChange(uint64_t deviceState) {
+ if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_5 &&
+ mModule->notify_device_state_change != NULL) {
+ ATRACE_BEGIN("camera_module->notify_device_state_change");
+ ALOGI("%s: calling notify_device_state_change with state %" PRId64, __FUNCTION__,
+ deviceState);
+ mModule->notify_device_state_change(deviceState);
+ ATRACE_END();
+ }
+}
+
+bool CameraModule::isLogicalMultiCamera(
+ const common::V1_0::helper::CameraMetadata& metadata,
+ std::unordered_set<std::string>* physicalCameraIds) {
+ if (physicalCameraIds == nullptr) {
+ ALOGE("%s: physicalCameraIds must not be null", __FUNCTION__);
+ return false;
+ }
+
+ bool isLogicalMultiCamera = false;
+ camera_metadata_ro_entry_t capabilities =
+ metadata.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
+ for (size_t i = 0; i < capabilities.count; i++) {
+ if (capabilities.data.u8[i] ==
+ ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA) {
+ isLogicalMultiCamera = true;
+ break;
+ }
+ }
+
+ if (isLogicalMultiCamera) {
+ camera_metadata_ro_entry_t entry =
+ metadata.find(ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS);
+ const uint8_t* ids = entry.data.u8;
+ size_t start = 0;
+ for (size_t i = 0; i < entry.count; ++i) {
+ if (ids[i] == '\0') {
+ if (start != i) {
+ const char* physicalId = reinterpret_cast<const char*>(ids+start);
+ physicalCameraIds->emplace(physicalId);
+ }
+ start = i + 1;
+ }
+ }
+ }
+ return isLogicalMultiCamera;
+}
+
status_t CameraModule::filterOpenErrorCode(status_t err) {
switch(err) {
case NO_ERROR:
@@ -426,8 +539,24 @@ status_t CameraModule::filterOpenErrorCode(status_t err) {
}
void CameraModule::removeCamera(int cameraId) {
- free_camera_metadata(
- const_cast<camera_metadata_t*>(mCameraInfoMap[cameraId].static_camera_characteristics));
+ std::unordered_set<std::string> physicalIds;
+ camera_metadata_t *metadata = const_cast<camera_metadata_t*>(
+ mCameraInfoMap.valueFor(cameraId).static_camera_characteristics);
+ common::V1_0::helper::CameraMetadata hidlMetadata(metadata);
+
+ if (isLogicalMultiCamera(hidlMetadata, &physicalIds)) {
+ for (const auto& id : physicalIds) {
+ int idInt = std::stoi(id);
+ if (mPhysicalCameraInfoMap.indexOfKey(idInt) >= 0) {
+ free_camera_metadata(mPhysicalCameraInfoMap[idInt]);
+ mPhysicalCameraInfoMap.removeItem(idInt);
+ } else {
+ ALOGE("%s: Cannot find corresponding static metadata for physical id %s",
+ __FUNCTION__, id.c_str());
+ }
+ }
+ }
+ free_camera_metadata(metadata);
mCameraInfoMap.removeItem(cameraId);
mDeviceVersionMap.removeItem(cameraId);
}
diff --git a/camera/common/1.0/default/HandleImporter.cpp b/camera/common/1.0/default/HandleImporter.cpp
index 21706a84a3..b8c40e95b8 100644
--- a/camera/common/1.0/default/HandleImporter.cpp
+++ b/camera/common/1.0/default/HandleImporter.cpp
@@ -25,7 +25,9 @@ namespace common {
namespace V1_0 {
namespace helper {
-using MapperError = android::hardware::graphics::mapper::V2_0::Error;
+using MapperErrorV2 = android::hardware::graphics::mapper::V2_0::Error;
+using MapperErrorV3 = android::hardware::graphics::mapper::V3_0::Error;
+using IMapperV3 = android::hardware::graphics::mapper::V3_0::IMapper;
HandleImporter::HandleImporter() : mInitialized(false) {}
@@ -34,8 +36,14 @@ void HandleImporter::initializeLocked() {
return;
}
- mMapper = IMapper::getService();
- if (mMapper == nullptr) {
+ mMapperV3 = IMapperV3::getService();
+ if (mMapperV3 != nullptr) {
+ mInitialized = true;
+ return;
+ }
+
+ mMapperV2 = IMapper::getService();
+ if (mMapperV2 == nullptr) {
ALOGE("%s: cannnot acccess graphics mapper HAL!", __FUNCTION__);
return;
}
@@ -45,32 +53,16 @@ void HandleImporter::initializeLocked() {
}
void HandleImporter::cleanup() {
- mMapper.clear();
+ mMapperV3.clear();
+ mMapperV2.clear();
mInitialized = false;
}
-// In IComposer, any buffer_handle_t is owned by the caller and we need to
-// make a clone for hwcomposer2. We also need to translate empty handle
-// to nullptr. This function does that, in-place.
-bool HandleImporter::importBuffer(buffer_handle_t& handle) {
- if (!handle->numFds && !handle->numInts) {
- handle = nullptr;
- return true;
- }
-
- Mutex::Autolock lock(mLock);
- if (!mInitialized) {
- initializeLocked();
- }
-
- if (mMapper == nullptr) {
- ALOGE("%s: mMapper is null!", __FUNCTION__);
- return false;
- }
-
- MapperError error;
+template<class M, class E>
+bool HandleImporter::importBufferInternal(const sp<M> mapper, buffer_handle_t& handle) {
+ E error;
buffer_handle_t importedHandle;
- auto ret = mMapper->importBuffer(
+ auto ret = mapper->importBuffer(
hidl_handle(handle),
[&](const auto& tmpError, const auto& tmpBufferHandle) {
error = tmpError;
@@ -83,30 +75,117 @@ bool HandleImporter::importBuffer(buffer_handle_t& handle) {
return false;
}
- if (error != MapperError::NONE) {
+ if (error != E::NONE) {
return false;
}
handle = importedHandle;
-
return true;
}
+template<class M, class E>
+YCbCrLayout HandleImporter::lockYCbCrInternal(const sp<M> mapper, buffer_handle_t& buf,
+ uint64_t cpuUsage, const IMapper::Rect& accessRegion) {
+ hidl_handle acquireFenceHandle;
+ auto buffer = const_cast<native_handle_t*>(buf);
+ YCbCrLayout layout = {};
+
+ typename M::Rect accessRegionCopy = {accessRegion.left, accessRegion.top,
+ accessRegion.width, accessRegion.height};
+ mapper->lockYCbCr(buffer, cpuUsage, accessRegionCopy, acquireFenceHandle,
+ [&](const auto& tmpError, const auto& tmpLayout) {
+ if (tmpError == E::NONE) {
+ // Member by member copy from different versions of YCbCrLayout.
+ layout.y = tmpLayout.y;
+ layout.cb = tmpLayout.cb;
+ layout.cr = tmpLayout.cr;
+ layout.yStride = tmpLayout.yStride;
+ layout.cStride = tmpLayout.cStride;
+ layout.chromaStep = tmpLayout.chromaStep;
+ } else {
+ ALOGE("%s: failed to lockYCbCr error %d!", __FUNCTION__, tmpError);
+ }
+ });
+ return layout;
+}
+
+template<class M, class E>
+int HandleImporter::unlockInternal(const sp<M> mapper, buffer_handle_t& buf) {
+ int releaseFence = -1;
+ auto buffer = const_cast<native_handle_t*>(buf);
+
+ mapper->unlock(
+ buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) {
+ if (tmpError == E::NONE) {
+ auto fenceHandle = tmpReleaseFence.getNativeHandle();
+ if (fenceHandle) {
+ if (fenceHandle->numInts != 0 || fenceHandle->numFds != 1) {
+ ALOGE("%s: bad release fence numInts %d numFds %d",
+ __FUNCTION__, fenceHandle->numInts, fenceHandle->numFds);
+ return;
+ }
+ releaseFence = dup(fenceHandle->data[0]);
+ if (releaseFence < 0) {
+ ALOGE("%s: bad release fence FD %d",
+ __FUNCTION__, releaseFence);
+ }
+ }
+ } else {
+ ALOGE("%s: failed to unlock error %d!", __FUNCTION__, tmpError);
+ }
+ });
+ return releaseFence;
+}
+
+// In IComposer, any buffer_handle_t is owned by the caller and we need to
+// make a clone for hwcomposer2. We also need to translate empty handle
+// to nullptr. This function does that, in-place.
+bool HandleImporter::importBuffer(buffer_handle_t& handle) {
+ if (!handle->numFds && !handle->numInts) {
+ handle = nullptr;
+ return true;
+ }
+
+ Mutex::Autolock lock(mLock);
+ if (!mInitialized) {
+ initializeLocked();
+ }
+
+ if (mMapperV3 != nullptr) {
+ return importBufferInternal<IMapperV3, MapperErrorV3>(mMapperV3, handle);
+ }
+
+ if (mMapperV2 != nullptr) {
+ return importBufferInternal<IMapper, MapperErrorV2>(mMapperV2, handle);
+ }
+
+ ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__);
+ return false;
+}
+
void HandleImporter::freeBuffer(buffer_handle_t handle) {
if (!handle) {
return;
}
Mutex::Autolock lock(mLock);
- if (mMapper == nullptr) {
- ALOGE("%s: mMapper is null!", __FUNCTION__);
+ if (mMapperV3 == nullptr && mMapperV2 == nullptr) {
+ ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__);
return;
}
- auto ret = mMapper->freeBuffer(const_cast<native_handle_t*>(handle));
- if (!ret.isOk()) {
- ALOGE("%s: mapper freeBuffer failed: %s",
- __FUNCTION__, ret.description().c_str());
+ if (mMapperV3 != nullptr) {
+ auto ret = mMapperV3->freeBuffer(const_cast<native_handle_t*>(handle));
+ if (!ret.isOk()) {
+ ALOGE("%s: mapper freeBuffer failed: %s",
+ __FUNCTION__, ret.description().c_str());
+ }
+ } else {
+ auto ret = mMapperV2->freeBuffer(const_cast<native_handle_t*>(handle));
+ if (!ret.isOk()) {
+ ALOGE("%s: mapper freeBuffer failed: %s",
+ __FUNCTION__, ret.description().c_str());
+ }
}
}
@@ -138,91 +217,82 @@ void* HandleImporter::lock(
buffer_handle_t& buf, uint64_t cpuUsage, size_t size) {
Mutex::Autolock lock(mLock);
void *ret = 0;
- IMapper::Rect accessRegion { 0, 0, static_cast<int>(size), 1 };
if (!mInitialized) {
initializeLocked();
}
- if (mMapper == nullptr) {
- ALOGE("%s: mMapper is null!", __FUNCTION__);
+ if (mMapperV3 == nullptr && mMapperV2 == nullptr) {
+ ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__);
return ret;
}
hidl_handle acquireFenceHandle;
auto buffer = const_cast<native_handle_t*>(buf);
- mMapper->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
- [&](const auto& tmpError, const auto& tmpPtr) {
- if (tmpError == MapperError::NONE) {
- ret = tmpPtr;
- } else {
- ALOGE("%s: failed to lock error %d!",
- __FUNCTION__, tmpError);
- }
- });
+ if (mMapperV3 != nullptr) {
+ IMapperV3::Rect accessRegion { 0, 0, static_cast<int>(size), 1 };
+ // No need to use bytesPerPixel and bytesPerStride because we are using
+ // an 1-D buffer and accressRegion.
+ mMapperV3->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
+ [&](const auto& tmpError, const auto& tmpPtr, const auto& /*bytesPerPixel*/,
+ const auto& /*bytesPerStride*/) {
+ if (tmpError == MapperErrorV3::NONE) {
+ ret = tmpPtr;
+ } else {
+ ALOGE("%s: failed to lock error %d!",
+ __FUNCTION__, tmpError);
+ }
+ });
+ } else {
+ IMapper::Rect accessRegion { 0, 0, static_cast<int>(size), 1 };
+ mMapperV2->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
+ [&](const auto& tmpError, const auto& tmpPtr) {
+ if (tmpError == MapperErrorV2::NONE) {
+ ret = tmpPtr;
+ } else {
+ ALOGE("%s: failed to lock error %d!",
+ __FUNCTION__, tmpError);
+ }
+ });
+ }
ALOGV("%s: ptr %p size: %zu", __FUNCTION__, ret, size);
return ret;
}
-
YCbCrLayout HandleImporter::lockYCbCr(
buffer_handle_t& buf, uint64_t cpuUsage,
const IMapper::Rect& accessRegion) {
Mutex::Autolock lock(mLock);
- YCbCrLayout layout = {};
if (!mInitialized) {
initializeLocked();
}
- if (mMapper == nullptr) {
- ALOGE("%s: mMapper is null!", __FUNCTION__);
- return layout;
+ if (mMapperV3 != nullptr) {
+ return lockYCbCrInternal<IMapperV3, MapperErrorV3>(
+ mMapperV3, buf, cpuUsage, accessRegion);
}
- hidl_handle acquireFenceHandle;
- auto buffer = const_cast<native_handle_t*>(buf);
- mMapper->lockYCbCr(buffer, cpuUsage, accessRegion, acquireFenceHandle,
- [&](const auto& tmpError, const auto& tmpLayout) {
- if (tmpError == MapperError::NONE) {
- layout = tmpLayout;
- } else {
- ALOGE("%s: failed to lockYCbCr error %d!", __FUNCTION__, tmpError);
- }
- });
+ if (mMapperV2 != nullptr) {
+ return lockYCbCrInternal<IMapper, MapperErrorV2>(
+ mMapperV2, buf, cpuUsage, accessRegion);
+ }
- ALOGV("%s: layout y %p cb %p cr %p y_str %d c_str %d c_step %d",
- __FUNCTION__, layout.y, layout.cb, layout.cr,
- layout.yStride, layout.cStride, layout.chromaStep);
- return layout;
+ ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__);
+ return {};
}
int HandleImporter::unlock(buffer_handle_t& buf) {
- int releaseFence = -1;
- auto buffer = const_cast<native_handle_t*>(buf);
- mMapper->unlock(
- buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) {
- if (tmpError == MapperError::NONE) {
- auto fenceHandle = tmpReleaseFence.getNativeHandle();
- if (fenceHandle) {
- if (fenceHandle->numInts != 0 || fenceHandle->numFds != 1) {
- ALOGE("%s: bad release fence numInts %d numFds %d",
- __FUNCTION__, fenceHandle->numInts, fenceHandle->numFds);
- return;
- }
- releaseFence = dup(fenceHandle->data[0]);
- if (releaseFence <= 0) {
- ALOGE("%s: bad release fence FD %d",
- __FUNCTION__, releaseFence);
- }
- }
- } else {
- ALOGE("%s: failed to unlock error %d!", __FUNCTION__, tmpError);
- }
- });
+ if (mMapperV3 != nullptr) {
+ return unlockInternal<IMapperV3, MapperErrorV3>(mMapperV3, buf);
+ }
+ if (mMapperV2 != nullptr) {
+ return unlockInternal<IMapper, MapperErrorV2>(mMapperV2, buf);
+ }
- return releaseFence;
+ ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__);
+ return -1;
}
} // namespace helper
diff --git a/camera/common/1.0/default/OWNERS b/camera/common/1.0/default/OWNERS
index 18acfee145..f48a95c5b3 100644
--- a/camera/common/1.0/default/OWNERS
+++ b/camera/common/1.0/default/OWNERS
@@ -1,6 +1 @@
-cychen@google.com
-epeev@google.com
-etalvala@google.com
-shuzhenwang@google.com
-yinchiayeh@google.com
-zhijunhe@google.com
+include platform/frameworks/av:/camera/OWNERS
diff --git a/camera/common/1.0/default/VendorTagDescriptor.cpp b/camera/common/1.0/default/VendorTagDescriptor.cpp
index 052bf5be60..d2bee85daf 100644
--- a/camera/common/1.0/default/VendorTagDescriptor.cpp
+++ b/camera/common/1.0/default/VendorTagDescriptor.cpp
@@ -176,6 +176,93 @@ void VendorTagDescriptor::dump(int fd, int verbosity, int indentation) const {
}
+int VendorTagDescriptorCache::getTagCount(metadata_vendor_id_t id) const {
+ int ret = 0;
+ auto desc = mVendorMap.find(id);
+ if (desc != mVendorMap.end()) {
+ ret = desc->second->getTagCount();
+ } else {
+ ALOGE("%s: Vendor descriptor id is missing!", __func__);
+ }
+
+ return ret;
+}
+
+void VendorTagDescriptorCache::getTagArray(uint32_t* tagArray, metadata_vendor_id_t id) const {
+ auto desc = mVendorMap.find(id);
+ if (desc != mVendorMap.end()) {
+ desc->second->getTagArray(tagArray);
+ } else {
+ ALOGE("%s: Vendor descriptor id is missing!", __func__);
+ }
+}
+
+const char* VendorTagDescriptorCache::getSectionName(uint32_t tag, metadata_vendor_id_t id) const {
+ const char* ret = nullptr;
+ auto desc = mVendorMap.find(id);
+ if (desc != mVendorMap.end()) {
+ ret = desc->second->getSectionName(tag);
+ } else {
+ ALOGE("%s: Vendor descriptor id is missing!", __func__);
+ }
+
+ return ret;
+}
+
+const char* VendorTagDescriptorCache::getTagName(uint32_t tag, metadata_vendor_id_t id) const {
+ const char* ret = nullptr;
+ auto desc = mVendorMap.find(id);
+ if (desc != mVendorMap.end()) {
+ ret = desc->second->getTagName(tag);
+ } else {
+ ALOGE("%s: Vendor descriptor id is missing!", __func__);
+ }
+
+ return ret;
+}
+
+int VendorTagDescriptorCache::getTagType(uint32_t tag, metadata_vendor_id_t id) const {
+ int ret = 0;
+ auto desc = mVendorMap.find(id);
+ if (desc != mVendorMap.end()) {
+ ret = desc->second->getTagType(tag);
+ } else {
+ ALOGE("%s: Vendor descriptor id is missing!", __func__);
+ }
+
+ return ret;
+}
+
+void VendorTagDescriptorCache::dump(int fd, int verbosity, int indentation) const {
+ for (const auto& desc : mVendorMap) {
+ desc.second->dump(fd, verbosity, indentation);
+ }
+}
+
+int32_t VendorTagDescriptorCache::addVendorDescriptor(
+ metadata_vendor_id_t id, sp<hardware::camera::common::V1_0::helper::VendorTagDescriptor> desc) {
+ auto entry = mVendorMap.find(id);
+ if (entry != mVendorMap.end()) {
+ ALOGE("%s: Vendor descriptor with same id already present!", __func__);
+ return BAD_VALUE;
+ }
+
+ mVendorMap.emplace(id, desc);
+ return NO_ERROR;
+}
+
+int32_t VendorTagDescriptorCache::getVendorTagDescriptor(
+ metadata_vendor_id_t id,
+ sp<hardware::camera::common::V1_0::helper::VendorTagDescriptor>* desc /*out*/) {
+ auto entry = mVendorMap.find(id);
+ if (entry == mVendorMap.end()) {
+ return NAME_NOT_FOUND;
+ }
+
+ *desc = entry->second;
+
+ return NO_ERROR;
+}
} // namespace params
} // namespace camera2
@@ -192,10 +279,17 @@ static const char* vendor_tag_descriptor_get_section_name(const vendor_tag_ops_t
static const char* vendor_tag_descriptor_get_tag_name(const vendor_tag_ops_t* v, uint32_t tag);
static int vendor_tag_descriptor_get_tag_type(const vendor_tag_ops_t* v, uint32_t tag);
+static int vendor_tag_descriptor_cache_get_tag_count(metadata_vendor_id_t id);
+static void vendor_tag_descriptor_cache_get_all_tags(uint32_t* tagArray, metadata_vendor_id_t id);
+static const char* vendor_tag_descriptor_cache_get_section_name(uint32_t tag,
+ metadata_vendor_id_t id);
+static const char* vendor_tag_descriptor_cache_get_tag_name(uint32_t tag, metadata_vendor_id_t id);
+static int vendor_tag_descriptor_cache_get_tag_type(uint32_t tag, metadata_vendor_id_t id);
} /* extern "C" */
static Mutex sLock;
static sp<VendorTagDescriptor> sGlobalVendorTagDescriptor;
+static sp<VendorTagDescriptorCache> sGlobalVendorTagDescriptorCache;
status_t VendorTagDescriptor::createDescriptorFromOps(const vendor_tag_ops_t* vOps,
/*out*/
@@ -310,6 +404,39 @@ sp<VendorTagDescriptor> VendorTagDescriptor::getGlobalVendorTagDescriptor() {
return sGlobalVendorTagDescriptor;
}
+status_t VendorTagDescriptorCache::setAsGlobalVendorTagCache(
+ const sp<VendorTagDescriptorCache>& cache) {
+ status_t res = OK;
+ Mutex::Autolock al(sLock);
+ sGlobalVendorTagDescriptorCache = cache;
+
+ struct vendor_tag_cache_ops* opsPtr = NULL;
+ if (cache != NULL) {
+ opsPtr = &(cache->mVendorCacheOps);
+ opsPtr->get_tag_count = vendor_tag_descriptor_cache_get_tag_count;
+ opsPtr->get_all_tags = vendor_tag_descriptor_cache_get_all_tags;
+ opsPtr->get_section_name = vendor_tag_descriptor_cache_get_section_name;
+ opsPtr->get_tag_name = vendor_tag_descriptor_cache_get_tag_name;
+ opsPtr->get_tag_type = vendor_tag_descriptor_cache_get_tag_type;
+ }
+ if ((res = set_camera_metadata_vendor_cache_ops(opsPtr)) != OK) {
+ ALOGE("%s: Could not set vendor tag cache, received error %s (%d).", __FUNCTION__,
+ strerror(-res), res);
+ }
+ return res;
+}
+
+void VendorTagDescriptorCache::clearGlobalVendorTagCache() {
+ Mutex::Autolock al(sLock);
+ set_camera_metadata_vendor_cache_ops(NULL);
+ sGlobalVendorTagDescriptorCache.clear();
+}
+
+sp<VendorTagDescriptorCache> VendorTagDescriptorCache::getGlobalVendorTagCache() {
+ Mutex::Autolock al(sLock);
+ return sGlobalVendorTagDescriptorCache;
+}
+
extern "C" {
int vendor_tag_descriptor_get_tag_count(const vendor_tag_ops_t* /*v*/) {
@@ -357,6 +484,50 @@ int vendor_tag_descriptor_get_tag_type(const vendor_tag_ops_t* /*v*/, uint32_t t
return sGlobalVendorTagDescriptor->getTagType(tag);
}
+int vendor_tag_descriptor_cache_get_tag_count(metadata_vendor_id_t id) {
+ Mutex::Autolock al(sLock);
+ if (sGlobalVendorTagDescriptorCache == NULL) {
+ ALOGE("%s: Vendor tag descriptor cache not initialized.", __FUNCTION__);
+ return VENDOR_TAG_COUNT_ERR;
+ }
+ return sGlobalVendorTagDescriptorCache->getTagCount(id);
+}
+
+void vendor_tag_descriptor_cache_get_all_tags(uint32_t* tagArray, metadata_vendor_id_t id) {
+ Mutex::Autolock al(sLock);
+ if (sGlobalVendorTagDescriptorCache == NULL) {
+ ALOGE("%s: Vendor tag descriptor cache not initialized.", __FUNCTION__);
+ }
+ sGlobalVendorTagDescriptorCache->getTagArray(tagArray, id);
+}
+
+const char* vendor_tag_descriptor_cache_get_section_name(uint32_t tag, metadata_vendor_id_t id) {
+ Mutex::Autolock al(sLock);
+ if (sGlobalVendorTagDescriptorCache == NULL) {
+ ALOGE("%s: Vendor tag descriptor cache not initialized.", __FUNCTION__);
+ return VENDOR_SECTION_NAME_ERR;
+ }
+ return sGlobalVendorTagDescriptorCache->getSectionName(tag, id);
+}
+
+const char* vendor_tag_descriptor_cache_get_tag_name(uint32_t tag, metadata_vendor_id_t id) {
+ Mutex::Autolock al(sLock);
+ if (sGlobalVendorTagDescriptorCache == NULL) {
+ ALOGE("%s: Vendor tag descriptor cache not initialized.", __FUNCTION__);
+ return VENDOR_TAG_NAME_ERR;
+ }
+ return sGlobalVendorTagDescriptorCache->getTagName(tag, id);
+}
+
+int vendor_tag_descriptor_cache_get_tag_type(uint32_t tag, metadata_vendor_id_t id) {
+ Mutex::Autolock al(sLock);
+ if (sGlobalVendorTagDescriptorCache == NULL) {
+ ALOGE("%s: Vendor tag descriptor cache not initialized.", __FUNCTION__);
+ return VENDOR_TAG_NAME_ERR;
+ }
+ return sGlobalVendorTagDescriptorCache->getTagType(tag, id);
+}
+
} /* extern "C" */
} // namespace helper
diff --git a/camera/common/1.0/default/include/CameraModule.h b/camera/common/1.0/default/include/CameraModule.h
index deebd09480..c89e934655 100644
--- a/camera/common/1.0/default/include/CameraModule.h
+++ b/camera/common/1.0/default/include/CameraModule.h
@@ -17,6 +17,9 @@
#ifndef CAMERA_COMMON_1_0_CAMERAMODULE_H
#define CAMERA_COMMON_1_0_CAMERAMODULE_H
+#include <string>
+#include <unordered_set>
+
#include <hardware/camera.h>
#include <utils/Mutex.h>
#include <utils/KeyedVector.h>
@@ -65,6 +68,13 @@ public:
void *getDso();
// Only used by CameraProvider
void removeCamera(int cameraId);
+ int getPhysicalCameraInfo(int physicalCameraId, camera_metadata_t **physicalInfo);
+ int isStreamCombinationSupported(int cameraId, camera_stream_combination_t *streams);
+ void notifyDeviceStateChange(uint64_t deviceState);
+
+ static bool isLogicalMultiCamera(
+ const common::V1_0::helper::CameraMetadata& metadata,
+ std::unordered_set<std::string>* physicalCameraIds);
private:
// Derive camera characteristics keys defined after HAL device version
@@ -74,8 +84,10 @@ private:
int32_t keyTag, const Vector<int32_t>& appendKeys);
status_t filterOpenErrorCode(status_t err);
camera_module_t *mModule;
+ int mNumberOfCameras;
KeyedVector<int, camera_info> mCameraInfoMap;
KeyedVector<int, int> mDeviceVersionMap;
+ KeyedVector<int, camera_metadata_t*> mPhysicalCameraInfoMap;
Mutex mCameraInfoLock;
};
diff --git a/camera/common/1.0/default/include/HandleImporter.h b/camera/common/1.0/default/include/HandleImporter.h
index f9cd9fb604..a93d4554ad 100644
--- a/camera/common/1.0/default/include/HandleImporter.h
+++ b/camera/common/1.0/default/include/HandleImporter.h
@@ -19,6 +19,7 @@
#include <utils/Mutex.h>
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <android/hardware/graphics/mapper/3.0/IMapper.h>
#include <cutils/native_handle.h>
using android::hardware::graphics::mapper::V2_0::IMapper;
@@ -57,10 +58,18 @@ private:
void initializeLocked();
void cleanup();
+ template<class M, class E>
+ bool importBufferInternal(const sp<M> mapper, buffer_handle_t& handle);
+ template<class M, class E>
+ YCbCrLayout lockYCbCrInternal(const sp<M> mapper, buffer_handle_t& buf, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion);
+ template<class M, class E>
+ int unlockInternal(const sp<M> mapper, buffer_handle_t& buf);
+
Mutex mLock;
bool mInitialized;
- sp<IMapper> mMapper;
-
+ sp<IMapper> mMapperV2;
+ sp<graphics::mapper::V3_0::IMapper> mMapperV3;
};
} // namespace helper
diff --git a/camera/common/1.0/default/include/VendorTagDescriptor.h b/camera/common/1.0/default/include/VendorTagDescriptor.h
index a040540edb..0f54db52d1 100644
--- a/camera/common/1.0/default/include/VendorTagDescriptor.h
+++ b/camera/common/1.0/default/include/VendorTagDescriptor.h
@@ -157,6 +157,81 @@ class VendorTagDescriptor :
};
+} /* namespace helper */
+} /* namespace V1_0 */
+} /* namespace common */
+} /* namespace camera */
+
+namespace camera2 {
+namespace params {
+
+class VendorTagDescriptorCache {
+ public:
+ typedef android::hardware::camera::common::V1_0::helper::VendorTagDescriptor
+ VendorTagDescriptor;
+ VendorTagDescriptorCache(){};
+ int32_t addVendorDescriptor(metadata_vendor_id_t id, sp<VendorTagDescriptor> desc);
+
+ int32_t getVendorTagDescriptor(metadata_vendor_id_t id, sp<VendorTagDescriptor>* desc /*out*/);
+
+ // Returns the number of vendor tags defined.
+ int getTagCount(metadata_vendor_id_t id) const;
+
+ // Returns an array containing the id's of vendor tags defined.
+ void getTagArray(uint32_t* tagArray, metadata_vendor_id_t id) const;
+
+ // Returns the section name string for a given vendor tag id.
+ const char* getSectionName(uint32_t tag, metadata_vendor_id_t id) const;
+
+ // Returns the tag name string for a given vendor tag id.
+ const char* getTagName(uint32_t tag, metadata_vendor_id_t id) const;
+
+ // Returns the tag type for a given vendor tag id.
+ int getTagType(uint32_t tag, metadata_vendor_id_t id) const;
+
+ /**
+ * Dump the currently configured vendor tags to a file descriptor.
+ */
+ void dump(int fd, int verbosity, int indentation) const;
+
+ protected:
+ std::unordered_map<metadata_vendor_id_t, sp<VendorTagDescriptor>> mVendorMap;
+ struct vendor_tag_cache_ops mVendorCacheOps;
+};
+
+} /* namespace params */
+} /* namespace camera2 */
+
+namespace camera {
+namespace common {
+namespace V1_0 {
+namespace helper {
+
+class VendorTagDescriptorCache
+ : public ::android::hardware::camera2::params::VendorTagDescriptorCache,
+ public LightRefBase<VendorTagDescriptorCache> {
+ public:
+ /**
+ * Sets the global vendor tag descriptor cache to use for this process.
+ * Camera metadata operations that access vendor tags will use the
+ * vendor tag definitions set this way.
+ *
+ * Returns OK on success, or a negative error code.
+ */
+ static status_t setAsGlobalVendorTagCache(const sp<VendorTagDescriptorCache>& cache);
+
+ /**
+ * Returns the global vendor tag cache used by this process.
+ * This will contain NULL if no vendor tags are defined.
+ */
+ static sp<VendorTagDescriptorCache> getGlobalVendorTagCache();
+
+ /**
+ * Clears the global vendor tag cache used by this process.
+ */
+ static void clearGlobalVendorTagCache();
+};
+
} // namespace helper
} // namespace V1_0
} // namespace common