summaryrefslogtreecommitdiff
path: root/camera/device/3.2/default/CameraDeviceSession.cpp
diff options
context:
space:
mode:
authorEmilian Peev <epeev@google.com>2017-11-13 16:03:44 +0000
committerEmilian Peev <epeev@google.com>2017-12-20 10:44:11 +0000
commite18057b42f1698f33f34d14e86a53934bd337bb8 (patch)
treea5c56e72bd99d5eded5d585460f6bc07b5b1a508 /camera/device/3.2/default/CameraDeviceSession.cpp
parent220d98c193513c9f0a13e73379a6665b65ce4ee2 (diff)
Camera: Bump device version to 3.4
Camera devices supporting version 3.4 will be able to receive session parameters during the stream configuration phase. Bug: 64450664 Test: Camera CTS run commandAndExit vts --skip-all-system-status-check --skip-preconditions --primary-abi-only --module VtsHalCameraProviderV2_4Target -l INFO Change-Id: Ifd83bfe0e512fe75b63602b4aba98f4cc1cdeb53
Diffstat (limited to 'camera/device/3.2/default/CameraDeviceSession.cpp')
-rw-r--r--camera/device/3.2/default/CameraDeviceSession.cpp156
1 files changed, 88 insertions, 68 deletions
diff --git a/camera/device/3.2/default/CameraDeviceSession.cpp b/camera/device/3.2/default/CameraDeviceSession.cpp
index d6a04bc56b..631404e79c 100644
--- a/camera/device/3.2/default/CameraDeviceSession.cpp
+++ b/camera/device/3.2/default/CameraDeviceSession.cpp
@@ -803,6 +803,89 @@ android_dataspace CameraDeviceSession::mapToLegacyDataspace(
return dataSpace;
}
+bool CameraDeviceSession::preProcessConfigurationLocked(
+ const StreamConfiguration& requestedConfiguration,
+ camera3_stream_configuration_t *stream_list /*out*/,
+ hidl_vec<camera3_stream_t*> *streams /*out*/) {
+
+ if ((stream_list == nullptr) || (streams == nullptr)) {
+ return false;
+ }
+
+ stream_list->operation_mode = (uint32_t) requestedConfiguration.operationMode;
+ stream_list->num_streams = requestedConfiguration.streams.size();
+ streams->resize(stream_list->num_streams);
+ stream_list->streams = streams->data();
+
+ for (uint32_t i = 0; i < stream_list->num_streams; i++) {
+ int id = requestedConfiguration.streams[i].id;
+
+ if (mStreamMap.count(id) == 0) {
+ Camera3Stream stream;
+ convertFromHidl(requestedConfiguration.streams[i], &stream);
+ mStreamMap[id] = stream;
+ mStreamMap[id].data_space = mapToLegacyDataspace(
+ mStreamMap[id].data_space);
+ mCirculatingBuffers.emplace(stream.mId, CirculatingBuffers{});
+ } else {
+ // width/height/format must not change, but usage/rotation might need to change
+ if (mStreamMap[id].stream_type !=
+ (int) requestedConfiguration.streams[i].streamType ||
+ mStreamMap[id].width != requestedConfiguration.streams[i].width ||
+ mStreamMap[id].height != requestedConfiguration.streams[i].height ||
+ mStreamMap[id].format != (int) requestedConfiguration.streams[i].format ||
+ mStreamMap[id].data_space !=
+ mapToLegacyDataspace( static_cast<android_dataspace_t> (
+ requestedConfiguration.streams[i].dataSpace))) {
+ ALOGE("%s: stream %d configuration changed!", __FUNCTION__, id);
+ return false;
+ }
+ mStreamMap[id].rotation = (int) requestedConfiguration.streams[i].rotation;
+ mStreamMap[id].usage = (uint32_t) requestedConfiguration.streams[i].usage;
+ }
+ (*streams)[i] = &mStreamMap[id];
+ }
+
+ return true;
+}
+
+void CameraDeviceSession::postProcessConfigurationLocked(
+ const StreamConfiguration& requestedConfiguration) {
+ // delete unused streams, note we do this after adding new streams to ensure new stream
+ // will not have the same address as deleted stream, and HAL has a chance to reference
+ // the to be deleted stream in configure_streams call
+ for(auto it = mStreamMap.begin(); it != mStreamMap.end();) {
+ int id = it->first;
+ bool found = false;
+ for (const auto& stream : requestedConfiguration.streams) {
+ if (id == stream.id) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ // Unmap all buffers of deleted stream
+ // in case the configuration call succeeds and HAL
+ // is able to release the corresponding resources too.
+ cleanupBuffersLocked(id);
+ it = mStreamMap.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
+ // Track video streams
+ mVideoStreamIds.clear();
+ for (const auto& stream : requestedConfiguration.streams) {
+ if (stream.streamType == StreamType::OUTPUT &&
+ stream.usage &
+ graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) {
+ mVideoStreamIds.push_back(stream.id);
+ }
+ }
+ mResultBatcher.setBatchedStreams(mVideoStreamIds);
+}
+
Return<void> CameraDeviceSession::configureStreams(
const StreamConfiguration& requestedConfiguration,
ICameraDeviceSession::configureStreams_cb _hidl_cb) {
@@ -840,42 +923,11 @@ Return<void> CameraDeviceSession::configureStreams(
return Void();
}
- camera3_stream_configuration_t stream_list;
+ camera3_stream_configuration_t stream_list{};
hidl_vec<camera3_stream_t*> streams;
-
- stream_list.operation_mode = (uint32_t) requestedConfiguration.operationMode;
- stream_list.num_streams = requestedConfiguration.streams.size();
- streams.resize(stream_list.num_streams);
- stream_list.streams = streams.data();
-
- for (uint32_t i = 0; i < stream_list.num_streams; i++) {
- int id = requestedConfiguration.streams[i].id;
-
- if (mStreamMap.count(id) == 0) {
- Camera3Stream stream;
- convertFromHidl(requestedConfiguration.streams[i], &stream);
- mStreamMap[id] = stream;
- mStreamMap[id].data_space = mapToLegacyDataspace(
- mStreamMap[id].data_space);
- mCirculatingBuffers.emplace(stream.mId, CirculatingBuffers{});
- } else {
- // width/height/format must not change, but usage/rotation might need to change
- if (mStreamMap[id].stream_type !=
- (int) requestedConfiguration.streams[i].streamType ||
- mStreamMap[id].width != requestedConfiguration.streams[i].width ||
- mStreamMap[id].height != requestedConfiguration.streams[i].height ||
- mStreamMap[id].format != (int) requestedConfiguration.streams[i].format ||
- mStreamMap[id].data_space !=
- mapToLegacyDataspace( static_cast<android_dataspace_t> (
- requestedConfiguration.streams[i].dataSpace))) {
- ALOGE("%s: stream %d configuration changed!", __FUNCTION__, id);
- _hidl_cb(Status::INTERNAL_ERROR, outStreams);
- return Void();
- }
- mStreamMap[id].rotation = (int) requestedConfiguration.streams[i].rotation;
- mStreamMap[id].usage = (uint32_t) requestedConfiguration.streams[i].usage;
- }
- streams[i] = &mStreamMap[id];
+ if (!preProcessConfigurationLocked(requestedConfiguration, &stream_list, &streams)) {
+ _hidl_cb(Status::INTERNAL_ERROR, outStreams);
+ return Void();
}
ATRACE_BEGIN("camera3->configure_streams");
@@ -885,39 +937,7 @@ Return<void> CameraDeviceSession::configureStreams(
// In case Hal returns error most likely it was not able to release
// the corresponding resources of the deleted streams.
if (ret == OK) {
- // delete unused streams, note we do this after adding new streams to ensure new stream
- // will not have the same address as deleted stream, and HAL has a chance to reference
- // the to be deleted stream in configure_streams call
- for(auto it = mStreamMap.begin(); it != mStreamMap.end();) {
- int id = it->first;
- bool found = false;
- for (const auto& stream : requestedConfiguration.streams) {
- if (id == stream.id) {
- found = true;
- break;
- }
- }
- if (!found) {
- // Unmap all buffers of deleted stream
- // in case the configuration call succeeds and HAL
- // is able to release the corresponding resources too.
- cleanupBuffersLocked(id);
- it = mStreamMap.erase(it);
- } else {
- ++it;
- }
- }
-
- // Track video streams
- mVideoStreamIds.clear();
- for (const auto& stream : requestedConfiguration.streams) {
- if (stream.streamType == StreamType::OUTPUT &&
- stream.usage &
- graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) {
- mVideoStreamIds.push_back(stream.id);
- }
- }
- mResultBatcher.setBatchedStreams(mVideoStreamIds);
+ postProcessConfigurationLocked(requestedConfiguration);
}
if (ret == -EINVAL) {