summaryrefslogtreecommitdiff
path: root/devices
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-03-23 19:31:01 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-23 19:31:01 +0000
commit58f4d831f68d68130ffc4bf4c12b51f9d24ad812 (patch)
tree64b768ef56fe820ac3c33b59fe02e4856d9f8843 /devices
parent008b18d6b5bee75663f0ced062369be5c6a35a83 (diff)
parent28ff7255969b52348207f2ce544a675c9f284d4d (diff)
downloadcamera-58f4d831f68d68130ffc4bf4c12b51f9d24ad812.tar.gz
Merge "EmulatedCamera: Ignore unavailable physical devices" into rvc-dev
Diffstat (limited to 'devices')
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedCameraDeviceHWLImpl.cpp2
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedCameraDeviceSessionHWLImpl.cpp4
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.cpp48
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.h3
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedLogicalRequestState.cpp9
-rw-r--r--devices/EmulatedCamera/hwl/utils/HWLUtils.cpp3
-rw-r--r--devices/EmulatedCamera/hwl/utils/HWLUtils.h11
7 files changed, 48 insertions, 32 deletions
diff --git a/devices/EmulatedCamera/hwl/EmulatedCameraDeviceHWLImpl.cpp b/devices/EmulatedCamera/hwl/EmulatedCameraDeviceHWLImpl.cpp
index 759dc5b..6974b6a 100644
--- a/devices/EmulatedCamera/hwl/EmulatedCameraDeviceHWLImpl.cpp
+++ b/devices/EmulatedCamera/hwl/EmulatedCameraDeviceHWLImpl.cpp
@@ -119,7 +119,7 @@ status_t EmulatedCameraDeviceHwlImpl::GetPhysicalCameraCharacteristics(
}
*characteristics = HalCameraMetadata::Clone(
- physical_device_map_->at(physical_camera_id).get());
+ physical_device_map_->at(physical_camera_id).second.get());
return OK;
}
diff --git a/devices/EmulatedCamera/hwl/EmulatedCameraDeviceSessionHWLImpl.cpp b/devices/EmulatedCamera/hwl/EmulatedCameraDeviceSessionHWLImpl.cpp
index 6268707..67f64ef 100644
--- a/devices/EmulatedCamera/hwl/EmulatedCameraDeviceSessionHWLImpl.cpp
+++ b/devices/EmulatedCamera/hwl/EmulatedCameraDeviceSessionHWLImpl.cpp
@@ -84,7 +84,7 @@ status_t EmulatedCameraDeviceSessionHwlImpl::Initialize(
logical_chars->emplace(camera_id_, sensor_chars_);
for (const auto& it : *physical_device_map_) {
SensorCharacteristics physical_chars;
- auto stat = GetSensorCharacteristics(it.second.get(), &physical_chars);
+ auto stat = GetSensorCharacteristics(it.second.second.get(), &physical_chars);
if (stat == OK) {
logical_chars->emplace(it.first, physical_chars);
} else {
@@ -353,7 +353,7 @@ status_t EmulatedCameraDeviceSessionHwlImpl::GetPhysicalCameraCharacteristics(
}
(*characteristics) = HalCameraMetadata::Clone(
- physical_device_map_->at(physical_camera_id).get());
+ physical_device_map_->at(physical_camera_id).second.get());
return OK;
}
diff --git a/devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.cpp b/devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.cpp
index 8c72ea4..f40c8af 100644
--- a/devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.cpp
+++ b/devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.cpp
@@ -630,25 +630,29 @@ status_t EmulatedCameraProviderHwlImpl::Initialize() {
// The first device entry is always the logical camera followed by the
// physical devices. They must be at least 2.
- camera_id_map_.emplace(logical_id, std::vector<uint32_t>());
+ camera_id_map_.emplace(logical_id, std::vector<std::pair<CameraDeviceStatus, uint32_t>>());
if (root.size() >= 3) {
camera_id_map_[logical_id].reserve(root.size() - 1);
+ size_t current_physical_device = 0;
while (device_iter != root.end()) {
auto physical_id = ParseCharacteristics(*device_iter, /*id*/ -1);
if (physical_id < 0) {
return physical_id;
}
- camera_id_map_[logical_id].push_back(physical_id);
-
- device_iter++;
+ // Only notify unavailable physical camera if there are more than 2
+ // physical cameras backing the logical camera
+ auto device_status = (current_physical_device < 2) ? CameraDeviceStatus::kPresent :
+ CameraDeviceStatus::kNotPresent;
+ camera_id_map_[logical_id].push_back(std::make_pair(device_status, physical_id));
+ device_iter++; current_physical_device++;
}
auto physical_devices = std::make_unique<PhysicalDeviceMap>();
- for (const auto& physical_device_id : camera_id_map_[logical_id]) {
+ for (const auto& physical_device : camera_id_map_[logical_id]) {
physical_devices->emplace(
- physical_device_id,
+ physical_device.second, std::make_pair(physical_device.first,
HalCameraMetadata::Clone(
- static_metadata_[physical_device_id].get()));
+ static_metadata_[physical_device.second].get())));
}
auto updated_logical_chars =
EmulatedLogicalRequestState::AdaptLogicalCharacteristics(
@@ -667,7 +671,7 @@ status_t EmulatedCameraProviderHwlImpl::Initialize() {
if (result_id != logical_id) {
return result_id;
}
- camera_id_map_.emplace(logical_id, std::vector<uint32_t>());
+ camera_id_map_.emplace(logical_id, std::vector<std::pair<CameraDeviceStatus, uint32_t>>());
}
logical_id++;
@@ -708,16 +712,18 @@ void EmulatedCameraProviderHwlImpl::WaitForStatusCallbackFuture() {
}
void EmulatedCameraProviderHwlImpl::NotifyPhysicalCameraUnavailable() {
- for (auto one_map : camera_id_map_) {
- if (one_map.second.size() <= 2) continue;
+ for (const auto& one_map : camera_id_map_) {
+ for (const auto& physical_device : one_map.second) {
+ if (physical_device.first != CameraDeviceStatus::kNotPresent) {
+ continue;
+ }
- // Only notify one unavailable physical camera if there are more than 2
- // physical cameras backing the logical camera
- uint32_t logicalCameraId = one_map.first;
- uint32_t physicalCameraId = one_map.second[one_map.second.size() - 1];
- physical_camera_status_cb_(
- logicalCameraId, physicalCameraId,
- google_camera_hal::CameraDeviceStatus::kNotPresent);
+ uint32_t logical_camera_id = one_map.first;
+ uint32_t physical_camera_id = physical_device.second;
+ physical_camera_status_cb_(
+ logical_camera_id, physical_camera_id,
+ CameraDeviceStatus::kNotPresent);
+ }
}
}
@@ -776,10 +782,10 @@ status_t EmulatedCameraProviderHwlImpl::CreateCameraDeviceHwl(
}
auto physical_devices = std::make_unique<PhysicalDeviceMap>();
- for (const auto& physical_device_id : camera_id_map_[camera_id]) {
- physical_devices->emplace(
- physical_device_id,
- HalCameraMetadata::Clone(static_metadata_[physical_device_id].get()));
+ for (const auto& physical_device : camera_id_map_[camera_id]) {
+ physical_devices->emplace(
+ physical_device.second, std::make_pair(physical_device.first,
+ HalCameraMetadata::Clone(static_metadata_[physical_device.second].get())));
}
*camera_device_hwl = EmulatedCameraDeviceHwlImpl::Create(
camera_id, std::move(meta), std::move(physical_devices), torch_state);
diff --git a/devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.h b/devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.h
index c4e5186..f9b0e66 100644
--- a/devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.h
+++ b/devices/EmulatedCamera/hwl/EmulatedCameraProviderHWLImpl.h
@@ -27,6 +27,7 @@ namespace android {
using google_camera_hal::CameraBufferAllocatorHwl;
using google_camera_hal::CameraDeviceHwl;
+using google_camera_hal::CameraDeviceStatus;
using google_camera_hal::CameraIdAndStreamConfiguration;
using google_camera_hal::CameraProviderHwl;
using google_camera_hal::HalCameraMetadata;
@@ -84,7 +85,7 @@ class EmulatedCameraProviderHwlImpl : public CameraProviderHwl {
std::vector<std::unique_ptr<HalCameraMetadata>> static_metadata_;
// Logical to physical camera Id mapping. Empty value vector in case
// of regular non-logical device.
- std::unordered_map<uint32_t, std::vector<uint32_t>> camera_id_map_;
+ std::unordered_map<uint32_t, std::vector<std::pair<CameraDeviceStatus, uint32_t>>> camera_id_map_;
HwlTorchModeStatusChangeFunc torch_cb_;
HwlPhysicalCameraDeviceStatusChangeFunc physical_camera_status_cb_;
diff --git a/devices/EmulatedCamera/hwl/EmulatedLogicalRequestState.cpp b/devices/EmulatedCamera/hwl/EmulatedLogicalRequestState.cpp
index ec7d0fb..4b9b5d3 100644
--- a/devices/EmulatedCamera/hwl/EmulatedLogicalRequestState.cpp
+++ b/devices/EmulatedCamera/hwl/EmulatedLogicalRequestState.cpp
@@ -45,7 +45,10 @@ status_t EmulatedLogicalRequestState::Initialize(
if ((ret == OK) && (logical_entry.count > 1)) {
for (size_t i = 0; i < logical_entry.count; i++) {
for (const auto& it : *physical_device_map_) {
- ret = it.second->Get(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS,
+ if (it.second.first != CameraDeviceStatus::kPresent) {
+ continue;
+ }
+ ret = it.second.second->Get(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS,
&physical_entry);
if ((ret == OK) && (physical_entry.count > 0)) {
if (logical_entry.data.f[i] == physical_entry.data.f[0]) {
@@ -64,7 +67,7 @@ status_t EmulatedLogicalRequestState::Initialize(
std::unique_ptr<EmulatedRequestState> physical_request_state =
std::make_unique<EmulatedRequestState>(it.first);
auto ret = physical_request_state->Initialize(
- HalCameraMetadata::Clone(it.second.get()));
+ HalCameraMetadata::Clone(it.second.second.get()));
if (ret != OK) {
ALOGE("%s: Physical device: %u request state initialization failed!",
__FUNCTION__, it.first);
@@ -217,7 +220,7 @@ EmulatedLogicalRequestState::AdaptLogicalCharacteristics(
physical_ids.insert(physical_ids.end(), physical_id.begin(),
physical_id.end());
physical_ids.push_back('\0');
- auto ret = physical_device.second->Get(
+ auto ret = physical_device.second.second->Get(
ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, &entry);
if ((ret == OK) && (entry.count > 0)) {
focal_lengths.insert(entry.data.f, entry.data.f + entry.count);
diff --git a/devices/EmulatedCamera/hwl/utils/HWLUtils.cpp b/devices/EmulatedCamera/hwl/utils/HWLUtils.cpp
index e68ea56..fa773a8 100644
--- a/devices/EmulatedCamera/hwl/utils/HWLUtils.cpp
+++ b/devices/EmulatedCamera/hwl/utils/HWLUtils.cpp
@@ -208,7 +208,8 @@ status_t GetSensorCharacteristics(const HalCameraMetadata* metadata,
PhysicalDeviceMapPtr ClonePhysicalDeviceMap(const PhysicalDeviceMapPtr& src) {
auto ret = std::make_unique<PhysicalDeviceMap>();
for (const auto& it : *src) {
- ret->emplace(it.first, HalCameraMetadata::Clone(it.second.get()));
+ ret->emplace(it.first, std::make_pair(it.second.first,
+ HalCameraMetadata::Clone(it.second.second.get())));
}
return ret;
}
diff --git a/devices/EmulatedCamera/hwl/utils/HWLUtils.h b/devices/EmulatedCamera/hwl/utils/HWLUtils.h
index d9ec11d..cd023c9 100644
--- a/devices/EmulatedCamera/hwl/utils/HWLUtils.h
+++ b/devices/EmulatedCamera/hwl/utils/HWLUtils.h
@@ -18,6 +18,7 @@
#define EMULATOR_CAMERA_HAL_HWL_HWL_UTILS_H_
#include "EmulatedSensor.h"
+#include "hal_types.h"
#include "hwl_types.h"
#include "system/camera_metadata.h"
@@ -31,12 +32,16 @@
namespace android {
-typedef std::unordered_map<uint32_t, std::unique_ptr<HalCameraMetadata>>
+using google_camera_hal::CameraDeviceStatus;
+using google_camera_hal::HalCameraMetadata;
+using std::pair;
+using std::unique_ptr;
+using std::unordered_map;
+
+typedef unordered_map<uint32_t, pair<CameraDeviceStatus, unique_ptr<HalCameraMetadata>>>
PhysicalDeviceMap;
typedef std::unique_ptr<PhysicalDeviceMap> PhysicalDeviceMapPtr;
-using google_camera_hal::HalCameraMetadata;
-
// Metadata utility functions start
bool HasCapability(const HalCameraMetadata* metadata, uint8_t capability);
status_t GetSensorCharacteristics(const HalCameraMetadata* metadata,