summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJayant Chowdhary <jchowdhary@google.com>2022-04-12 17:38:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-04-12 17:38:16 +0000
commit63d69a6565bb661199895621ff7525c5f5e6cc49 (patch)
treed0d2e02d5054f6a1ea2d735953a89773ed5f5d86
parenta4bc16a912b209f9d91428df22ce081bf023adb7 (diff)
parentade8aad8424c9389058b01ba22e71f6e4feb093c (diff)
downloadcamera-63d69a6565bb661199895621ff7525c5f5e6cc49.tar.gz
Merge "GCH: Check stream use cases supported in IsStreamCombinationSupported and ConfigureStreams." into tm-dev
-rw-r--r--common/hal/google_camera_hal/camera_device.cc19
-rw-r--r--common/hal/google_camera_hal/camera_device.h2
-rw-r--r--common/hal/google_camera_hal/camera_device_session.cc16
-rw-r--r--common/hal/google_camera_hal/camera_device_session.h3
-rw-r--r--common/hal/utils/utils.cc34
-rw-r--r--common/hal/utils/utils.h8
6 files changed, 82 insertions, 0 deletions
diff --git a/common/hal/google_camera_hal/camera_device.cc b/common/hal/google_camera_hal/camera_device.cc
index 43e65f3..55c3a41 100644
--- a/common/hal/google_camera_hal/camera_device.cc
+++ b/common/hal/google_camera_hal/camera_device.cc
@@ -167,6 +167,21 @@ status_t CameraDevice::Initialize(
return res;
}
+ std::unique_ptr<HalCameraMetadata> static_metadata;
+ res = camera_device_hwl_->GetCameraCharacteristics(&static_metadata);
+ if (res != OK) {
+ ALOGE("%s: Getting camera characteristics failed: %s(%d)", __FUNCTION__,
+ strerror(-res), res);
+ return res;
+ }
+
+ res = utils::GetStreamUseCases(static_metadata.get(), &stream_use_cases_);
+ if (res != OK) {
+ ALOGE("%s: Getting stream use cases failed: %s(%d)", __FUNCTION__,
+ strerror(-res), res);
+ return res;
+ }
+
return OK;
}
@@ -264,6 +279,10 @@ status_t CameraDevice::CreateCameraDeviceSession(
bool CameraDevice::IsStreamCombinationSupported(
const StreamConfiguration& stream_config) {
+ if (!utils::IsStreamUseCaseSupported(stream_config, stream_use_cases_)) {
+ return false;
+ }
+
bool supported =
camera_device_hwl_->IsStreamCombinationSupported(stream_config);
if (!supported) {
diff --git a/common/hal/google_camera_hal/camera_device.h b/common/hal/google_camera_hal/camera_device.h
index 5309aff..80245f1 100644
--- a/common/hal/google_camera_hal/camera_device.h
+++ b/common/hal/google_camera_hal/camera_device.h
@@ -110,6 +110,8 @@ class CameraDevice {
std::vector<GetCaptureSessionFactoryFunc> external_session_factory_entries_;
// Opened library handles that should be closed on destruction
std::vector<void*> external_capture_session_lib_handles_;
+ // Stream use cases supported by this camera device
+ std::set<int64_t> stream_use_cases_;
const std::vector<std::string>* configure_streams_libs_ = nullptr;
};
diff --git a/common/hal/google_camera_hal/camera_device_session.cc b/common/hal/google_camera_hal/camera_device_session.cc
index 4c51e1c..f1821e6 100644
--- a/common/hal/google_camera_hal/camera_device_session.cc
+++ b/common/hal/google_camera_hal/camera_device_session.cc
@@ -431,6 +431,13 @@ status_t CameraDeviceSession::Initialize(
return res;
}
+ res = utils::GetStreamUseCases(characteristics.get(), &stream_use_cases_);
+ if (res != OK) {
+ ALOGE("%s: Initializing stream use case failed: %s(%d)", __FUNCTION__,
+ strerror(-res), res);
+ return res;
+ }
+
res = InitializeBufferManagement(characteristics.get());
if (res != OK) {
ALOGE("%s: Initialize buffer management failed: %s(%d)", __FUNCTION__,
@@ -689,6 +696,15 @@ status_t CameraDeviceSession::ConfigureStreams(
operation_mode_ = stream_config.operation_mode;
multi_res_reprocess_ = stream_config.multi_resolution_input_image;
+ // TODO: We would ideally want this to be a part of CreateCaptureSession,
+ // which internally calls IsStreamCombinationSupported. However this
+ // IsStreamCombinationSupported doesn't match the
+ // CameraDevice::IsStreamCombination. We should look at unifying the two for a
+ // potentially cleaner code-base.
+ if (!utils::IsStreamUseCaseSupported(stream_config, stream_use_cases_)) {
+ return BAD_VALUE;
+ }
+
capture_session_ = CreateCaptureSession(
stream_config, kWrapperCaptureSessionEntries,
external_capture_session_entries_, kCaptureSessionEntries,
diff --git a/common/hal/google_camera_hal/camera_device_session.h b/common/hal/google_camera_hal/camera_device_session.h
index b2b0fda..768cf26 100644
--- a/common/hal/google_camera_hal/camera_device_session.h
+++ b/common/hal/google_camera_hal/camera_device_session.h
@@ -423,6 +423,9 @@ class CameraDeviceSession {
// Protected by request_record_lock_;
std::set<uint32_t> ignore_shutters_;
+ // Stream use cases supported by this camera device
+ std::set<int64_t> stream_use_cases_;
+
static constexpr int32_t kInvalidStreamId = -1;
// Whether measure the time of buffer allocation
diff --git a/common/hal/utils/utils.cc b/common/hal/utils/utils.cc
index 7a41889..6e0ba2f 100644
--- a/common/hal/utils/utils.cc
+++ b/common/hal/utils/utils.cc
@@ -486,6 +486,40 @@ std::vector<std::string> FindLibraryPaths(const char* dir_path) {
return libs;
}
+bool IsStreamUseCaseSupported(const StreamConfiguration& stream_config,
+ const std::set<int64_t>& stream_use_cases,
+ bool log_if_not_supported) {
+ for (const auto& stream : stream_config.streams) {
+ if (stream_use_cases.find(stream.use_case) == stream_use_cases.end()) {
+ if (log_if_not_supported) {
+ ALOGE("Stream use case %d not in set of supported use cases",
+ stream.use_case);
+ }
+ return false;
+ }
+ }
+ return true;
+}
+
+status_t GetStreamUseCases(const HalCameraMetadata* static_metadata,
+ std::set<int64_t>* stream_use_cases) {
+ if (static_metadata == nullptr || stream_use_cases == nullptr) {
+ return BAD_VALUE;
+ }
+
+ camera_metadata_ro_entry entry;
+ status_t ret =
+ static_metadata->Get(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES, &entry);
+ if (ret != OK) {
+ ALOGV("%s: No available stream use cases!", __FUNCTION__);
+ stream_use_cases->insert(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT);
+ return OK;
+ }
+ stream_use_cases->insert(entry.data.i64, entry.data.i64 + entry.count);
+
+ return OK;
+}
+
} // namespace utils
} // namespace google_camera_hal
} // namespace android
diff --git a/common/hal/utils/utils.h b/common/hal/utils/utils.h
index a43e614..699be9d 100644
--- a/common/hal/utils/utils.h
+++ b/common/hal/utils/utils.h
@@ -19,6 +19,7 @@
#include <log/log.h>
+#include <set>
#include <utility>
#include "hal_types.h"
@@ -77,6 +78,13 @@ status_t SetRealtimeThread(pthread_t thread);
status_t UpdateThreadSched(pthread_t thread, int32_t policy,
struct sched_param* param);
+status_t GetStreamUseCases(const HalCameraMetadata* static_metadata,
+ std::set<int64_t>* stream_use_cases);
+
+bool IsStreamUseCaseSupported(const StreamConfiguration& stream_config,
+ const std::set<int64_t>& stream_use_cases,
+ bool log_if_not_supported = true);
+
// Map the rectangle to the coordination of HAL.
void ConvertZoomRatio(float zoom_ratio, const Dimension& active_array_dimension,
int32_t* left, int32_t* top, int32_t* width,