From 9d32c13f0b0fea73648b218422cf881fd38df35b Mon Sep 17 00:00:00 2001 From: Yin-Chia Yeh Date: Thu, 24 May 2018 10:31:56 -0700 Subject: Camera: add FMQ size override logic Test: modify FMQ size in device.mk Bug: 80242493 Change-Id: Ie1fb12118ad53c5bbe0cf264bffaafcd3728f8db --- camera/device/3.2/default/CameraDeviceSession.cpp | 25 +++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/camera/device/3.2/default/CameraDeviceSession.cpp b/camera/device/3.2/default/CameraDeviceSession.cpp index f33da134..8d002646 100644 --- a/camera/device/3.2/default/CameraDeviceSession.cpp +++ b/camera/device/3.2/default/CameraDeviceSession.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -31,9 +32,9 @@ namespace V3_2 { namespace implementation { // Size of request metadata fast message queue. Change to 0 to always use hwbinder buffer. -static constexpr size_t CAMERA_REQUEST_METADATA_QUEUE_SIZE = 1 << 20 /* 1MB */; +static constexpr int32_t CAMERA_REQUEST_METADATA_QUEUE_SIZE = 1 << 20 /* 1MB */; // Size of result metadata fast message queue. Change to 0 to always use hwbinder buffer. -static constexpr size_t CAMERA_RESULT_METADATA_QUEUE_SIZE = 1 << 20 /* 1MB */; +static constexpr int32_t CAMERA_RESULT_METADATA_QUEUE_SIZE = 1 << 20 /* 1MB */; // Metadata sent by HAL will be replaced by a compact copy // if their (total size >= compact size + METADATA_SHRINK_ABS_THRESHOLD && @@ -95,14 +96,30 @@ bool CameraDeviceSession::initialize() { return true; } + int32_t reqFMQSize = property_get_int32("ro.camera.req.fmq.size", /*default*/-1); + if (reqFMQSize < 0) { + reqFMQSize = CAMERA_REQUEST_METADATA_QUEUE_SIZE; + } else { + ALOGV("%s: request FMQ size overridden to %d", __FUNCTION__, reqFMQSize); + } + mRequestMetadataQueue = std::make_unique( - CAMERA_REQUEST_METADATA_QUEUE_SIZE, false /* non blocking */); + static_cast(reqFMQSize), + false /* non blocking */); if (!mRequestMetadataQueue->isValid()) { ALOGE("%s: invalid request fmq", __FUNCTION__); return true; } + + int32_t resFMQSize = property_get_int32("ro.camera.res.fmq.size", /*default*/-1); + if (resFMQSize < 0) { + resFMQSize = CAMERA_RESULT_METADATA_QUEUE_SIZE; + } else { + ALOGV("%s: result FMQ size overridden to %d", __FUNCTION__, resFMQSize); + } mResultMetadataQueue = std::make_shared( - CAMERA_RESULT_METADATA_QUEUE_SIZE, false /* non blocking */); + static_cast(resFMQSize), + false /* non blocking */); if (!mResultMetadataQueue->isValid()) { ALOGE("%s: invalid result fmq", __FUNCTION__); return true; -- cgit v1.2.3-54-g00ecf