/* * Copyright (C) 2019 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 "GCH_HidlCameraDeviceSession" #define ATRACE_TAG ATRACE_TAG_CAMERA //#define LOG_NDEBUG 0 #include "hidl_camera_device_session.h" #include #include #include #include #include #include "hidl_profiler.h" #include "hidl_utils.h" namespace android { namespace hardware { namespace camera { namespace device { namespace V3_7 { namespace implementation { namespace hidl_utils = ::android::hardware::camera::implementation::hidl_utils; using ::android::hardware::camera::device::V3_2::NotifyMsg; using ::android::hardware::camera::device::V3_2::StreamBuffer; using ::android::hardware::camera::device::V3_4::CaptureResult; using ::android::hardware::camera::device::V3_5::BufferRequest; using ::android::hardware::camera::device::V3_5::BufferRequestStatus; using ::android::hardware::camera::device::V3_5::StreamBufferRet; using ::android::hardware::camera::device::V3_5::StreamBuffersVal; using ::android::hardware::camera::device::V3_6::HalStreamConfiguration; using ::android::hardware::thermal::V1_0::ThermalStatus; using ::android::hardware::thermal::V1_0::ThermalStatusCode; using ::android::hardware::thermal::V2_0::Temperature; using ::android::hardware::thermal::V2_0::TemperatureType; std::unique_ptr HidlCameraDeviceSession::Create( const sp& callback, std::unique_ptr device_session, std::shared_ptr hidl_profiler) { ATRACE_NAME("HidlCameraDeviceSession::Create"); auto session = std::unique_ptr(new HidlCameraDeviceSession()); if (session == nullptr) { ALOGE("%s: Cannot create a HidlCameraDeviceSession.", __FUNCTION__); return nullptr; } status_t res = session->Initialize(callback, std::move(device_session), hidl_profiler); if (res != OK) { ALOGE("%s: Initializing HidlCameraDeviceSession failed: %s(%d)", __FUNCTION__, strerror(-res), res); return nullptr; } return session; } HidlCameraDeviceSession::~HidlCameraDeviceSession() { ATRACE_NAME("HidlCameraDeviceSession::~HidlCameraDeviceSession"); close(); // camera's closing, so flush any unused malloc pages mallopt(M_PURGE, 0); } void HidlCameraDeviceSession::ProcessCaptureResult( std::unique_ptr hal_result) { std::shared_lock lock(hidl_device_callback_lock_); if (hidl_device_callback_ == nullptr) { ALOGE("%s: hidl_device_callback_ is nullptr", __FUNCTION__); return; } { std::lock_guard pending_lock(pending_first_frame_buffers_mutex_); if (!hal_result->output_buffers.empty() && num_pending_first_frame_buffers_ > 0 && first_request_frame_number_ == hal_result->frame_number) { num_pending_first_frame_buffers_ -= hal_result->output_buffers.size(); if (num_pending_first_frame_buffers_ == 0) { ALOGI("%s: First frame done", __FUNCTION__); hidl_profiler_->FirstFrameEnd(); ATRACE_ASYNC_END("first_frame", 0); ATRACE_ASYNC_END("switch_mode", 0); } } } for (auto& buffer : hal_result->output_buffers) { hidl_profiler_->ProfileFrameRate("Stream " + std::to_string(buffer.stream_id)); } hidl_vec hidl_results(1); status_t res = hidl_utils::ConvertToHidlCaptureResult( result_metadata_queue_.get(), std::move(hal_result), &hidl_results[0]); if (res != OK) { ALOGE("%s: Converting to HIDL result failed: %s(%d)", __FUNCTION__, strerror(-res), res); return; } auto hidl_res = hidl_device_callback_->processCaptureResult_3_4(hidl_results); if (!hidl_res.isOk()) { ALOGE("%s: processCaptureResult transaction failed: %s.", __FUNCTION__, hidl_res.description().c_str()); return; } } void HidlCameraDeviceSession::NotifyHalMessage( const google_camera_hal::NotifyMessage& hal_message) { std::shared_lock lock(hidl_device_callback_lock_); if (hidl_device_callback_ == nullptr) { ALOGE("%s: hidl_device_callback_ is nullptr", __FUNCTION__); return; } hidl_vec hidl_messages(1); status_t res = hidl_utils::ConverToHidlNotifyMessage(hal_message, &hidl_messages[0]); if (res != OK) { ALOGE("%s: Converting to HIDL message failed: %s(%d)", __FUNCTION__, strerror(-res), res); return; } auto hidl_res = hidl_device_callback_->notify(hidl_messages); if (!hidl_res.isOk()) { ALOGE("%s: notify transaction failed: %s.", __FUNCTION__, hidl_res.description().c_str()); return; } } google_camera_hal::BufferRequestStatus HidlCameraDeviceSession::RequestStreamBuffers( const std::vector& hal_buffer_requests, std::vector* hal_buffer_returns) { std::shared_lock lock(hidl_device_callback_lock_); if (hidl_device_callback_ == nullptr) { ALOGE("%s: hidl_device_callback_ is nullptr", __FUNCTION__); return google_camera_hal::BufferRequestStatus::kFailedUnknown; } if (hal_buffer_returns == nullptr) { ALOGE("%s: hal_buffer_returns is nullptr", __FUNCTION__); return google_camera_hal::BufferRequestStatus::kFailedUnknown; } hidl_vec hidl_buffer_requests; status_t res = hidl_utils::ConvertToHidlBufferRequest(hal_buffer_requests, &hidl_buffer_requests); if (res != OK) { ALOGE("%s: Converting to Hidl buffer request failed: %s(%d)", __FUNCTION__, strerror(-res), res); return google_camera_hal::BufferRequestStatus::kFailedUnknown; } BufferRequestStatus hidl_status; hidl_vec stream_buffer_returns; auto cb_status = hidl_device_callback_->requestStreamBuffers( hidl_buffer_requests, [&hidl_status, &stream_buffer_returns]( BufferRequestStatus status_ret, const hidl_vec& buffer_ret) { hidl_status = status_ret; stream_buffer_returns = std::move(buffer_ret); }); if (!cb_status.isOk()) { ALOGE("%s: Transaction request stream buffers error: %s", __FUNCTION__, cb_status.description().c_str()); return google_camera_hal::BufferRequestStatus::kFailedUnknown; } google_camera_hal::BufferRequestStatus hal_buffer_request_status; res = hidl_utils::ConvertToHalBufferRequestStatus(hidl_status, &hal_buffer_request_status); if (res != OK) { ALOGE("%s: Converting to Hal buffer request status failed: %s(%d)", __FUNCTION__, strerror(-res), res); return google_camera_hal::BufferRequestStatus::kFailedUnknown; } hal_buffer_returns->clear(); // Converting HIDL stream buffer returns to HAL stream buffer returns. for (auto& stream_buffer_return : stream_buffer_returns) { google_camera_hal::BufferReturn hal_buffer_return; res = hidl_utils::ConvertToHalBufferReturnStatus(stream_buffer_return, &hal_buffer_return); if (res != OK) { ALOGE("%s: Converting to Hal buffer return status failed: %s(%d)", __FUNCTION__, strerror(-res), res); return google_camera_hal::BufferRequestStatus::kFailedUnknown; } if (stream_buffer_return.val.getDiscriminator() == V3_5::StreamBuffersVal::hidl_discriminator::buffers) { const hidl_vec& hidl_buffers = stream_buffer_return.val.buffers(); for (auto& hidl_buffer : hidl_buffers) { google_camera_hal::StreamBuffer hal_buffer = {}; hidl_utils::ConvertToHalStreamBuffer(hidl_buffer, &hal_buffer); if (res != OK) { ALOGE("%s: Converting to Hal stream buffer failed: %s(%d)", __FUNCTION__, strerror(-res), res); return google_camera_hal::BufferRequestStatus::kFailedUnknown; } if (hidl_buffer.acquireFence.getNativeHandle() != nullptr) { hal_buffer.acquire_fence = native_handle_clone(hidl_buffer.acquireFence.getNativeHandle()); if (hal_buffer.acquire_fence == nullptr) { ALOGE("%s: Cloning Hal stream buffer acquire fence failed", __FUNCTION__); } } hal_buffer.release_fence = nullptr; // If buffer handle is not null, we need to import buffer handle and // return to the caller. if (hidl_buffer.buffer.getNativeHandle() != nullptr) { if (buffer_mapper_v4_ != nullptr) { hal_buffer.buffer = ImportBufferHandle< android::hardware::graphics::mapper::V4_0::IMapper, android::hardware::graphics::mapper::V4_0::Error>( buffer_mapper_v4_, hidl_buffer.buffer); } else if (buffer_mapper_v3_ != nullptr) { hal_buffer.buffer = ImportBufferHandle< android::hardware::graphics::mapper::V3_0::IMapper, android::hardware::graphics::mapper::V3_0::Error>( buffer_mapper_v3_, hidl_buffer.buffer); } else { hal_buffer.buffer = ImportBufferHandle< android::hardware::graphics::mapper::V2_0::IMapper, android::hardware::graphics::mapper::V2_0::Error>( buffer_mapper_v2_, hidl_buffer.buffer); } } hal_buffer_return.val.buffers.push_back(hal_buffer); } } hal_buffer_returns->push_back(hal_buffer_return); } return hal_buffer_request_status; } template buffer_handle_t HidlCameraDeviceSession::ImportBufferHandle( const sp buffer_mapper_, const hidl_handle& buffer_hidl_handle) { U mapper_error; buffer_handle_t imported_buffer_handle; auto hidl_res = buffer_mapper_->importBuffer( buffer_hidl_handle, [&](const auto& error, const auto& buffer_handle) { mapper_error = error; imported_buffer_handle = static_cast(buffer_handle); }); if (!hidl_res.isOk() || mapper_error != U::NONE) { ALOGE("%s: Importing buffer failed: %s, mapper error %u", __FUNCTION__, hidl_res.description().c_str(), mapper_error); return nullptr; } return imported_buffer_handle; } void HidlCameraDeviceSession::ReturnStreamBuffers( const std::vector& return_hal_buffers) { std::shared_lock lock(hidl_device_callback_lock_); if (hidl_device_callback_ == nullptr) { ALOGE("%s: hidl_device_callback_ is nullptr", __FUNCTION__); return; } status_t res = OK; hidl_vec hidl_return_buffers; hidl_return_buffers.resize(return_hal_buffers.size()); for (uint32_t i = 0; i < return_hal_buffers.size(); i++) { res = hidl_utils::ConvertToHidlStreamBuffer(return_hal_buffers[i], &hidl_return_buffers[i]); if (res != OK) { ALOGE("%s: Converting to Hidl stream buffer failed: %s(%d)", __FUNCTION__, strerror(-res), res); return; } } hidl_device_callback_->returnStreamBuffers(hidl_return_buffers); } status_t HidlCameraDeviceSession::InitializeBufferMapper() { buffer_mapper_v4_ = android::hardware::graphics::mapper::V4_0::IMapper::getService(); if (buffer_mapper_v4_ != nullptr) { return OK; } buffer_mapper_v3_ = android::hardware::graphics::mapper::V3_0::IMapper::getService(); if (buffer_mapper_v3_ != nullptr) { return OK; } buffer_mapper_v2_ = android::hardware::graphics::mapper::V2_0::IMapper::getService(); if (buffer_mapper_v2_ != nullptr) { return OK; } ALOGE("%s: Getting buffer mapper failed.", __FUNCTION__); return UNKNOWN_ERROR; } status_t HidlCameraDeviceSession::Initialize( const sp& callback, std::unique_ptr device_session, std::shared_ptr hidl_profiler) { ATRACE_NAME("HidlCameraDeviceSession::Initialize"); if (device_session == nullptr) { ALOGE("%s: device_session is nullptr.", __FUNCTION__); return BAD_VALUE; } if (hidl_profiler == nullptr) { ALOGE("%s: hidl_profiler is nullptr.", __FUNCTION__); return BAD_VALUE; } status_t res = CreateMetadataQueue(&request_metadata_queue_, kRequestMetadataQueueSizeBytes, "ro.vendor.camera.req.fmq.size"); if (res != OK) { ALOGE("%s: Creating request metadata queue failed: %s(%d)", __FUNCTION__, strerror(-res), res); return res; } res = CreateMetadataQueue(&result_metadata_queue_, kResultMetadataQueueSizeBytes, "ro.vendor.camera.res.fmq.size"); if (res != OK) { ALOGE("%s: Creating result metadata queue failed: %s(%d)", __FUNCTION__, strerror(-res), res); return res; } // Cast V3.2 callback to V3.5 auto cast_res = ICameraDeviceCallback::castFrom(callback); if (!cast_res.isOk()) { ALOGE("%s: Cannot convert to V3.5 device callback.", __FUNCTION__); return UNKNOWN_ERROR; } // Initialize buffer mapper res = InitializeBufferMapper(); if (res != OK) { ALOGE("%s: Initialize buffer mapper failed: %s(%d)", __FUNCTION__, strerror(-res), res); return res; } thermal_ = android::hardware::thermal::V2_0::IThermal::getService(); if (thermal_ == nullptr) { ALOGE("%s: Getting thermal failed.", __FUNCTION__); // Continue without getting thermal information. } hidl_device_callback_ = cast_res; device_session_ = std::move(device_session); hidl_profiler_ = hidl_profiler; SetSessionCallbacks(); return OK; } void HidlCameraDeviceSession::SetSessionCallbacks() { google_camera_hal::CameraDeviceSessionCallback session_callback = { .process_capture_result = google_camera_hal::ProcessCaptureResultFunc( [this](std::unique_ptr result) { ProcessCaptureResult(std::move(result)); }), .notify = google_camera_hal::NotifyFunc( [this](const google_camera_hal::NotifyMessage& message) { NotifyHalMessage(message); }), .request_stream_buffers = google_camera_hal::RequestStreamBuffersFunc( [this]( const std::vector& hal_buffer_requests, std::vector* hal_buffer_returns) { return RequestStreamBuffers(hal_buffer_requests, hal_buffer_returns); }), .return_stream_buffers = google_camera_hal::ReturnStreamBuffersFunc( [this](const std::vector& return_hal_buffers) { ReturnStreamBuffers(return_hal_buffers); }), }; google_camera_hal::ThermalCallback thermal_callback = { .register_thermal_changed_callback = google_camera_hal::RegisterThermalChangedCallbackFunc( [this](google_camera_hal::NotifyThrottlingFunc notify_throttling, bool filter_type, google_camera_hal::TemperatureType type) { return RegisterThermalChangedCallback(notify_throttling, filter_type, type); }), .unregister_thermal_changed_callback = google_camera_hal::UnregisterThermalChangedCallbackFunc( [this]() { UnregisterThermalChangedCallback(); }), }; device_session_->SetSessionCallback(session_callback, thermal_callback); } status_t HidlCameraDeviceSession::RegisterThermalChangedCallback( google_camera_hal::NotifyThrottlingFunc notify_throttling, bool filter_type, google_camera_hal::TemperatureType type) { std::lock_guard lock(hidl_thermal_mutex_); if (thermal_ == nullptr) { ALOGE("%s: thermal was not initialized.", __FUNCTION__); return NO_INIT; } if (thermal_changed_callback_ != nullptr) { ALOGE("%s: thermal changed callback is already registered.", __FUNCTION__); return ALREADY_EXISTS; } TemperatureType hidl_type; status_t res = hidl_thermal_utils::ConvertToHidlTemperatureType(type, &hidl_type); if (res != OK) { ALOGE("%s: Converting to HIDL type failed: %s(%d)", __FUNCTION__, strerror(-res), res); return res; } std::unique_ptr callback = hidl_thermal_utils::HidlThermalChangedCallback::Create(notify_throttling); thermal_changed_callback_ = callback.release(); ThermalStatus thermal_status; auto hidl_res = thermal_->registerThermalChangedCallback( thermal_changed_callback_, filter_type, hidl_type, [&](ThermalStatus status) { thermal_status = status; }); if (!hidl_res.isOk() || thermal_status.code != ThermalStatusCode::SUCCESS) { thermal_changed_callback_ = nullptr; return UNKNOWN_ERROR; } return OK; } void HidlCameraDeviceSession::UnregisterThermalChangedCallback() { std::lock_guard lock(hidl_thermal_mutex_); if (thermal_changed_callback_ == nullptr) { // no-op if no thermal changed callback is registered. return; } if (thermal_ == nullptr) { ALOGE("%s: thermal was not initialized.", __FUNCTION__); return; } ThermalStatus thermal_status; auto hidl_res = thermal_->unregisterThermalChangedCallback( thermal_changed_callback_, [&](ThermalStatus status) { thermal_status = status; }); if (!hidl_res.isOk() || thermal_status.code != ThermalStatusCode::SUCCESS) { ALOGW("%s: Unregstering thermal callback failed: %s", __FUNCTION__, thermal_status.debugMessage.c_str()); } thermal_changed_callback_ = nullptr; } status_t HidlCameraDeviceSession::CreateMetadataQueue( std::unique_ptr* metadata_queue, uint32_t default_size_bytes, const char* override_size_property) { if (metadata_queue == nullptr) { ALOGE("%s: metadata_queue is nullptr", __FUNCTION__); return BAD_VALUE; } int32_t size = default_size_bytes; if (override_size_property != nullptr) { // Try to read the override size from the system property. size = property_get_int32(override_size_property, default_size_bytes); ALOGV("%s: request metadata queue size overridden to %d", __FUNCTION__, size); } *metadata_queue = std::make_unique( static_cast(size), /*configureEventFlagWord=*/false); if (!(*metadata_queue)->isValid()) { ALOGE("%s: Creating metadata queue (size %d) failed.", __FUNCTION__, size); return NO_INIT; } return OK; } Return HidlCameraDeviceSession::constructDefaultRequestSettings( RequestTemplate type, ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) { ATRACE_NAME("HidlCameraDeviceSession::constructDefaultRequestSettings"); V3_2::CameraMetadata hidl_metadata; if (device_session_ == nullptr) { _hidl_cb(Status::INTERNAL_ERROR, hidl_metadata); return Void(); } google_camera_hal::RequestTemplate hal_type; status_t res = hidl_utils::ConvertToHalTemplateType(type, &hal_type); if (res != OK) { _hidl_cb(Status::ILLEGAL_ARGUMENT, hidl_metadata); return Void(); } std::unique_ptr settings = nullptr; res = device_session_->ConstructDefaultRequestSettings(hal_type, &settings); if (res != OK) { _hidl_cb(hidl_utils::ConvertToHidlStatus(res), hidl_metadata); return Void(); } uint32_t metadata_size = settings->GetCameraMetadataSize(); hidl_metadata.setToExternal((uint8_t*)settings->ReleaseCameraMetadata(), metadata_size, /*shouldOwn=*/true); _hidl_cb(Status::OK, hidl_metadata); return Void(); } Return HidlCameraDeviceSession::configureStreams_3_7( const StreamConfiguration& requestedConfiguration, ICameraDeviceSession::configureStreams_3_6_cb _hidl_cb) { ATRACE_NAME("HidlCameraDeviceSession::configureStreams_3_7"); HalStreamConfiguration hidl_hal_configs; if (device_session_ == nullptr) { _hidl_cb(Status::ILLEGAL_ARGUMENT, hidl_hal_configs); return Void(); } auto profiler = hidl_profiler_->MakeScopedProfiler( HidlProfiler::ScopedType::kConfigureStream); first_frame_requested_ = false; num_pending_first_frame_buffers_ = 0; google_camera_hal::StreamConfiguration hal_stream_config; status_t res = hidl_utils::ConverToHalStreamConfig(requestedConfiguration, &hal_stream_config); if (res != OK) { _hidl_cb(Status::ILLEGAL_ARGUMENT, hidl_hal_configs); return Void(); } std::vector hal_configured_streams; res = device_session_->ConfigureStreams(hal_stream_config, &hal_configured_streams); if (res != OK) { ALOGE("%s: Configuring streams failed: %s(%d)", __FUNCTION__, strerror(-res), res); _hidl_cb(hidl_utils::ConvertToHidlStatus(res), hidl_hal_configs); return Void(); } res = hidl_utils::ConvertToHidlHalStreamConfig(hal_configured_streams, &hidl_hal_configs); _hidl_cb(hidl_utils::ConvertToHidlStatus(res), hidl_hal_configs); return Void(); } Return HidlCameraDeviceSession::getCaptureRequestMetadataQueue( ICameraDeviceSession::getCaptureRequestMetadataQueue_cb _hidl_cb) { _hidl_cb(*request_metadata_queue_->getDesc()); return Void(); } Return HidlCameraDeviceSession::getCaptureResultMetadataQueue( ICameraDeviceSession::getCaptureResultMetadataQueue_cb _hidl_cb) { _hidl_cb(*result_metadata_queue_->getDesc()); return Void(); } Return HidlCameraDeviceSession::processCaptureRequest_3_7( const hidl_vec& requests, const hidl_vec& cachesToRemove, processCaptureRequest_3_7_cb _hidl_cb) { if (device_session_ == nullptr) { _hidl_cb(Status::ILLEGAL_ARGUMENT, 0); return Void(); } bool profile_first_request = false; if (!first_frame_requested_) { first_frame_requested_ = true; profile_first_request = true; ATRACE_BEGIN("HidlCameraDeviceSession::FirstRequest"); num_pending_first_frame_buffers_ = requests[0].v3_4.v3_2.outputBuffers.size(); first_request_frame_number_ = requests[0].v3_4.v3_2.frameNumber; hidl_profiler_->FirstFrameStart(); ATRACE_ASYNC_BEGIN("first_frame", 0); } std::vector hal_buffer_caches; status_t res = hidl_utils::ConvertToHalBufferCaches(cachesToRemove, &hal_buffer_caches); if (res != OK) { _hidl_cb(Status::ILLEGAL_ARGUMENT, 0); if (profile_first_request) { ATRACE_END(); } return Void(); } device_session_->RemoveBufferCache(hal_buffer_caches); // Converting HIDL requests to HAL requests. std::vector hal_requests; for (auto& request : requests) { google_camera_hal::CaptureRequest hal_request = {}; res = hidl_utils::ConvertToHalCaptureRequest( request, request_metadata_queue_.get(), &hal_request); if (res != OK) { ALOGE("%s: Converting to HAL capture request failed: %s(%d)", __FUNCTION__, strerror(-res), res); _hidl_cb(hidl_utils::ConvertToHidlStatus(res), 0); if (profile_first_request) { ATRACE_END(); } return Void(); } hal_requests.push_back(std::move(hal_request)); } uint32_t num_processed_requests = 0; res = device_session_->ProcessCaptureRequest(hal_requests, &num_processed_requests); if (res != OK) { ALOGE( "%s: Processing capture request failed: %s(%d). Only processed %u" " out of %zu.", __FUNCTION__, strerror(-res), res, num_processed_requests, hal_requests.size()); } _hidl_cb(hidl_utils::ConvertToHidlStatus(res), num_processed_requests); if (profile_first_request) { ATRACE_END(); } return Void(); } Return HidlCameraDeviceSession::signalStreamFlush( const hidl_vec& /*streamIds*/, uint32_t /*streamConfigCounter*/) { // TODO(b/143902312): Implement this. return Void(); } Return HidlCameraDeviceSession::flush() { ATRACE_NAME("HidlCameraDeviceSession::flush"); ATRACE_ASYNC_BEGIN("switch_mode", 0); if (device_session_ == nullptr) { return Status::INTERNAL_ERROR; } hidl_profiler_->SetLatencyProfiler(device_session_->GetProfiler( hidl_profiler_->GetCameraId(), hidl_profiler_->GetLatencyFlag())); hidl_profiler_->SetFpsProfiler(device_session_->GetProfiler( hidl_profiler_->GetCameraId(), hidl_profiler_->GetFpsFlag())); auto profiler = hidl_profiler_->MakeScopedProfiler(HidlProfiler::ScopedType::kFlush); status_t res = device_session_->Flush(); if (res != OK) { ALOGE("%s: Flushing device failed: %s(%d).", __FUNCTION__, strerror(-res), res); return Status::INTERNAL_ERROR; } return Status::OK; } Return HidlCameraDeviceSession::close() { ATRACE_NAME("HidlCameraDeviceSession::close"); if (device_session_ != nullptr) { auto profiler = hidl_profiler_->MakeScopedProfiler(HidlProfiler::ScopedType::kClose); device_session_ = nullptr; } return Void(); } Return HidlCameraDeviceSession::isReconfigurationRequired( const V3_2::CameraMetadata& oldSessionParams, const V3_2::CameraMetadata& newSessionParams, ICameraDeviceSession::isReconfigurationRequired_cb _hidl_cb) { ATRACE_NAME("HidlCameraDeviceSession::isReconfigurationRequired"); std::unique_ptr old_hal_session_metadata; status_t res = hidl_utils::ConvertToHalMetadata(0, nullptr, oldSessionParams, &old_hal_session_metadata); if (res != OK) { ALOGE("%s: Converting to old session metadata failed: %s(%d)", __FUNCTION__, strerror(-res), res); _hidl_cb(Status::INTERNAL_ERROR, true); return Void(); } std::unique_ptr new_hal_session_metadata; res = hidl_utils::ConvertToHalMetadata(0, nullptr, newSessionParams, &new_hal_session_metadata); if (res != OK) { ALOGE("%s: Converting to new session metadata failed: %s(%d)", __FUNCTION__, strerror(-res), res); _hidl_cb(Status::INTERNAL_ERROR, true); return Void(); } bool reconfiguration_required = true; res = device_session_->IsReconfigurationRequired( old_hal_session_metadata.get(), new_hal_session_metadata.get(), &reconfiguration_required); if (res != OK) { ALOGE("%s: IsReconfigurationRequired failed: %s(%d)", __FUNCTION__, strerror(-res), res); _hidl_cb(Status::INTERNAL_ERROR, true); return Void(); } _hidl_cb(Status::OK, reconfiguration_required); return Void(); } Return HidlCameraDeviceSession::configureStreams( const V3_2::StreamConfiguration&, configureStreams_cb _hidl_cb) { _hidl_cb(Status::ILLEGAL_ARGUMENT, V3_2::HalStreamConfiguration()); return Void(); } Return HidlCameraDeviceSession::configureStreams_3_3( const V3_2::StreamConfiguration&, configureStreams_3_3_cb _hidl_cb) { _hidl_cb(Status::ILLEGAL_ARGUMENT, V3_3::HalStreamConfiguration()); return Void(); } Return HidlCameraDeviceSession::configureStreams_3_4( const V3_4::StreamConfiguration&, configureStreams_3_4_cb _hidl_cb) { _hidl_cb(Status::ILLEGAL_ARGUMENT, V3_4::HalStreamConfiguration()); return Void(); } Return HidlCameraDeviceSession::configureStreams_3_5( const V3_5::StreamConfiguration& requestedConfiguration, configureStreams_3_5_cb _hidl_cb) { configureStreams_3_6( requestedConfiguration, [_hidl_cb](Status s, device::V3_6::HalStreamConfiguration halConfig) { V3_4::HalStreamConfiguration halConfig3_4; halConfig3_4.streams.resize(halConfig.streams.size()); for (size_t i = 0; i < halConfig.streams.size(); i++) { halConfig3_4.streams[i] = halConfig.streams[i].v3_4; } _hidl_cb(s, halConfig3_4); }); return Void(); } Return HidlCameraDeviceSession::configureStreams_3_6( const V3_5::StreamConfiguration& requestedConfiguration, configureStreams_3_6_cb _hidl_cb) { StreamConfiguration requestedConfiguration3_7; requestedConfiguration3_7.streams.resize( requestedConfiguration.v3_4.streams.size()); for (size_t i = 0; i < requestedConfiguration.v3_4.streams.size(); i++) { requestedConfiguration3_7.streams[i].v3_4 = requestedConfiguration.v3_4.streams[i]; requestedConfiguration3_7.streams[i].groupId = -1; } requestedConfiguration3_7.operationMode = requestedConfiguration.v3_4.operationMode; requestedConfiguration3_7.sessionParams = requestedConfiguration.v3_4.sessionParams; requestedConfiguration3_7.streamConfigCounter = requestedConfiguration.streamConfigCounter; requestedConfiguration3_7.multiResolutionInputImage = false; configureStreams_3_7(requestedConfiguration3_7, _hidl_cb); return Void(); } Return HidlCameraDeviceSession::switchToOffline( const hidl_vec&, switchToOffline_cb _hidl_cb) { _hidl_cb(Status::ILLEGAL_ARGUMENT, V3_6::CameraOfflineSessionInfo(), nullptr); return Void(); } Return HidlCameraDeviceSession::processCaptureRequest( const hidl_vec& requests, const hidl_vec& cachesToRemove, processCaptureRequest_cb _hidl_cb) { hidl_vec requests_3_4; requests_3_4.resize(requests.size()); for (uint32_t i = 0; i < requests_3_4.size(); i++) { requests_3_4[i].v3_2 = requests[i]; } return processCaptureRequest_3_4(requests_3_4, cachesToRemove, _hidl_cb); } Return HidlCameraDeviceSession::processCaptureRequest_3_4( const hidl_vec& requests, const hidl_vec& cachesToRemove, processCaptureRequest_cb _hidl_cb) { hidl_vec requests_3_7; requests_3_7.resize(requests.size()); for (uint32_t i = 0; i < requests_3_7.size(); i++) { requests_3_7[i].v3_4 = requests[i]; } return processCaptureRequest_3_7(requests_3_7, cachesToRemove, _hidl_cb); } } // namespace implementation } // namespace V3_7 } // namespace device } // namespace camera } // namespace hardware } // namespace android