From patchwork Tue Dec 21 05:10:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 15190 X-Patchwork-Delegate: paul.elder@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 3BA24BE080 for ; Tue, 21 Dec 2021 05:10:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DD7B8608FD; Tue, 21 Dec 2021 06:10:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jD+KhC0E"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 000FA608E7 for ; Tue, 21 Dec 2021 06:10:35 +0100 (CET) Received: from pyrite.mediacom.info (unknown [IPv6:2604:2d80:ad90:fb00:96fd:8874:873:6c16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2C8B6881; Tue, 21 Dec 2021 06:10:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1640063435; bh=LcWePXNJSt0SsZckOquvnaAXjKSBJB9cv+ngABrwQnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jD+KhC0EBsK9PpQ39OQrrJiPbz4AM3zNDwd3juiGHCn6a8kfCHcfyMtFfRv/6bxyI kzXxYoYDFga1MzLy5O1fDrlzrkH4iYYG9aRw4f4I4E5qycfKXzLwGIIZT6kMaaDJzh PQ4WFlVPyZvfXyhPKkXi5f3WMoHupt8PO2XgX1M0= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Dec 2021 23:10:21 -0600 Message-Id: <20211221051023.2628625-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211221051023.2628625-1-paul.elder@ideasonboard.com> References: <20211221051023.2628625-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] controls: Promote NoiseReductionMode to non-draft X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Promote NoiseReductionMode to a non-draft control. Upgrade the value descriptions. Update the raspberrypi IPA accordingly, as it is the only current user of this control. Signed-off-by: Paul Elder --- No change in v2 - I think that the framerate guarantees should stay. If the application wants no framerate drop at all costs, it should be able to get it, or at least be notified that it's not possible to be guaranteed. The lack of mechanism to do this communication I think is not a good idea. - the paragraph about ZSL has been left in --- include/libcamera/ipa/raspberrypi.h | 2 +- src/android/camera_capabilities.cpp | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 12 ++--- src/libcamera/control_ids.yaml | 73 +++++++++++++++++------------ 4 files changed, 52 insertions(+), 37 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index 672b85a5..548bfba0 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -46,7 +46,7 @@ static const ControlInfoMap Controls({ { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) }, { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, { &controls::FrameDurationLimits, ControlInfo(INT64_C(1000), INT64_C(1000000000)) }, - { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) } + { &controls::NoiseReductionMode, ControlInfo(controls::NoiseReductionModeValues) } }, controls::controls); } /* namespace RPi */ diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index fa5f3b8d..d6a1589e 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1398,7 +1398,7 @@ int CameraCapabilities::initializeStaticMetadata() { std::vector data; data.reserve(5); - const auto &infoMap = controlsInfo.find(&controls::draft::NoiseReductionMode); + const auto &infoMap = controlsInfo.find(&controls::NoiseReductionMode); if (infoMap != controlsInfo.end()) { for (const auto &value : infoMap->second.values()) data.push_back(value.get()); diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 9bea16e7..3f497be1 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -615,11 +615,11 @@ static const std::map AwbModeTable = { }; static const std::map DenoiseModeTable = { - { controls::draft::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, - { controls::draft::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, - { controls::draft::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, - { controls::draft::NoiseReductionModeMinimal, RPiController::DenoiseMode::ColourOff }, - { controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, + { controls::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, + { controls::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, + { controls::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, + { controls::NoiseReductionModeRaw, RPiController::DenoiseMode::ColourOff }, + { controls::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, }; void IPARPi::queueRequest(const ControlList &controls) @@ -929,7 +929,7 @@ void IPARPi::queueRequest(const ControlList &controls) * analysis image resolution or format mismatch, we should * report the status correctly in the metadata. */ - libcameraMetadata_.set(controls::draft::NoiseReductionMode, idx); + libcameraMetadata_.set(controls::NoiseReductionMode, idx); } else { LOG(IPARPI, Error) << "Noise reduction mode " << idx << " not recognised"; diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 84679317..84e843b1 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -526,6 +526,50 @@ controls: \todo Define how the sensor timestamp has to be used in the reprocessing use case. + - NoiseReductionMode: + type: int32_t + description: | + Mode of operation for the noise reduction algorithm. + + The noise reduction algorithm attempts to improve image quality by + removing excessive noise added by the capture process, especially in + dark conditions. + enum: + - name: NoiseReductionModeOff + value: 0 + description: | + No noise reduction will be applied by the camera device, for + both the raw and YUV domains. + - name: NoiseReductionModeFast + value: 1 + description: | + Noise reduction is applied without reducing the frame rate. + This may be the same as Raw if it is listed, or the same as Off if + any noise reduction will slow down the frame rate. + - name: NoiseReductionModeHighQuality + value: 2 + description: | + High quality noise reduction at the expense of frame rate. + - name: NoiseReductionModeRaw + value: 3 + description: | + Only sensor raw domain basic noise reduction is enabled, to remove + demosaicing or other processing artifacts. Frame rate will not be + reduced. + - name: NoiseReductionModeZSL + value: 4 + description: | + Noise reduction is applied at different levels to different streams. + + ZSL is meant to be used by applications that maintain a continuous + circular buffer of high-resolution images during preview and + reprocess image(s) from that buffer into a final capture when + triggered by the user. In this mode, the camera device applies + noise reduction to low-resolution streams (below maximum recording + resolution) to maximize preview quality, but does not apply noise + reduction to high-resolution streams, since those will be + reprocessed later if necessary. + # ---------------------------------------------------------------------------- # Draft controls section @@ -572,35 +616,6 @@ controls: The camera will cancel any active trigger and the AF routine is reset to its initial state. - - NoiseReductionMode: - type: int32_t - draft: true - description: | - Control to select the noise reduction algorithm mode. Currently - identical to ANDROID_NOISE_REDUCTION_MODE. - - Mode of operation for the noise reduction algorithm. - enum: - - name: NoiseReductionModeOff - value: 0 - description: No noise reduction is applied - - name: NoiseReductionModeFast - value: 1 - description: | - Noise reduction is applied without reducing the frame rate. - - name: NoiseReductionModeHighQuality - value: 2 - description: | - High quality noise reduction at the expense of frame rate. - - name: NoiseReductionModeMinimal - value: 3 - description: | - Minimal noise reduction is applied without reducing the frame rate. - - name: NoiseReductionModeZSL - value: 4 - description: | - Noise reduction is applied at different levels to different streams. - - ColorCorrectionAberrationMode: type: int32_t draft: true From patchwork Tue Dec 21 05:10:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 15191 X-Patchwork-Delegate: paul.elder@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5C97AC3258 for ; Tue, 21 Dec 2021 05:10:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 863CA608F9; Tue, 21 Dec 2021 06:10:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="clcqCXcC"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EABBB608E7 for ; Tue, 21 Dec 2021 06:10:36 +0100 (CET) Received: from pyrite.mediacom.info (unknown [IPv6:2604:2d80:ad90:fb00:96fd:8874:873:6c16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 18355881; Tue, 21 Dec 2021 06:10:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1640063436; bh=MxGOIeVSivwDTuR0LVtTL6rvOHsaDNX/QyYay+eNRpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=clcqCXcCEKTIzkmCDErJ4+Z9ZLx0wkO+KyWE6rybYs+u98tYCZqbL3jBIgfS4v932 sW7vXbgwayjw3Obg2yEjen4mAKgFj4C4H+vh9T+kGhESnx89Pm3elNPCVVREXDGMix 0LyyddHGbabavlYG+s/C50Y3J0N17p5K0DCZgnmU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Dec 2021 23:10:22 -0600 Message-Id: <20211221051023.2628625-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211221051023.2628625-1-paul.elder@ideasonboard.com> References: <20211221051023.2628625-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] ipa: raspberrypi: Clean up NoiseReductionMode values X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Remove the NoiseReductionMode values that the raspberrypi IPA does not support. The ControlInfo values that the IPA reports will be used for capability detection, so values that it does not support shall be removed. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham --- No change in v2: - constexpr did not work --- include/libcamera/ipa/raspberrypi.h | 8 +++++++- src/ipa/raspberrypi/raspberrypi.cpp | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index 548bfba0..593139c5 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -18,6 +18,12 @@ namespace libcamera { namespace RPi { +const std::array RPiNoiseReductionModeValues = { + static_cast(controls::NoiseReductionModeOff), + static_cast(controls::NoiseReductionModeFast), + static_cast(controls::NoiseReductionModeHighQuality), +}; + /* * List of controls handled by the Raspberry Pi IPA * @@ -46,7 +52,7 @@ static const ControlInfoMap Controls({ { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) }, { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, { &controls::FrameDurationLimits, ControlInfo(INT64_C(1000), INT64_C(1000000000)) }, - { &controls::NoiseReductionMode, ControlInfo(controls::NoiseReductionModeValues) } + { &controls::NoiseReductionMode, ControlInfo(RPiNoiseReductionModeValues) } }, controls::controls); } /* namespace RPi */ diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 3f497be1..e0685c69 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -618,8 +618,6 @@ static const std::map DenoiseModeTable = { { controls::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, { controls::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, { controls::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, - { controls::NoiseReductionModeRaw, RPiController::DenoiseMode::ColourOff }, - { controls::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, }; void IPARPi::queueRequest(const ControlList &controls) From patchwork Tue Dec 21 05:10:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 15192 X-Patchwork-Delegate: paul.elder@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AB975BE080 for ; Tue, 21 Dec 2021 05:10:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5EC4F608FB; Tue, 21 Dec 2021 06:10:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EivcPtmn"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E19AC608A2 for ; Tue, 21 Dec 2021 06:10:37 +0100 (CET) Received: from pyrite.mediacom.info (unknown [IPv6:2604:2d80:ad90:fb00:96fd:8874:873:6c16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E128881; Tue, 21 Dec 2021 06:10:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1640063437; bh=LDxye+Yt2azrg2N2mD2kFUpmtKkA2N67mtnHeY03Bxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EivcPtmntobPhOxeyngTyGsOo+/OZNO6X2p2/1niS/AH0fqDXRxCbxOytTXPVTW3q 6bILokoEH7V0VxxTcP2FoYxjPxCysSdo+GxiIS2iP3rSn8sMlTJb4IUO6+8NK7MRfH bL1FMQb+avfVOPsgt38bjEuO7c9ItfaqYxwqbjL4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Dec 2021 23:10:23 -0600 Message-Id: <20211221051023.2628625-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211221051023.2628625-1-paul.elder@ideasonboard.com> References: <20211221051023.2628625-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] android: Plumb noise reduction X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add: - hardware level detection based on available noise reduction values (no specific capabilities seem to require it; only FULL in general) - Conversion from android to libcamera noise reduction modes for request (use switch-case instead of direct copy just in case) - Conversion from libcamera to android noise reduction modes for result - noise reduction values to the templates We already have the mechanism to report the available noise reduction modes, so that is not added. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham --- Changes in v2: - change result metadata generation to switch-case --- src/android/camera_capabilities.cpp | 34 +++++++++++++- src/android/camera_device.cpp | 70 +++++++++++++++++++++++++++-- 2 files changed, 100 insertions(+), 4 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index d6a1589e..365937ed 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -412,6 +412,31 @@ void CameraCapabilities::computeHwLevel( hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; } + found = staticMetadata_->entryContains( + ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, + ANDROID_NOISE_REDUCTION_MODE_OFF); + if (!found) { + LOG(HAL, Info) << noFull << "missing noise reduction mode off"; + hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } + + found = staticMetadata_->entryContains( + ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, + ANDROID_NOISE_REDUCTION_MODE_FAST); + if (!found) { + LOG(HAL, Info) << noFull << "missing noise reduction mode fast"; + hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } + + /* Android docs don't say this is required, but CTS does. */ + found = staticMetadata_->entryContains( + ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, + ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY); + if (!found) { + LOG(HAL, Info) << noFull << "missing noise reduction mode high quality"; + hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } + hwLevel_ = hwLevel; } @@ -1727,7 +1752,7 @@ std::unique_ptr CameraCapabilities::requestTemplatePreview() con requestTemplate->addEntry(ANDROID_STATISTICS_FACE_DETECT_MODE, faceDetectMode); - uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_OFF; + uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_FAST; requestTemplate->addEntry(ANDROID_NOISE_REDUCTION_MODE, noiseReduction); @@ -1764,6 +1789,13 @@ std::unique_ptr CameraCapabilities::requestTemplateStill() const stillTemplate->appendEntry(ANDROID_EDGE_MODE, edgeMode); } + if (staticMetadata_->entryContains( + ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, + ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY)) { + uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY; + stillTemplate->appendEntry(ANDROID_NOISE_REDUCTION_MODE, noiseReduction); + } + return stillTemplate; } diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 8861447d..e521ae0a 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -920,6 +920,39 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor) controls.set(controls::DigitalGain, lastDigitalGain_); } + if (settings.getEntry(ANDROID_NOISE_REDUCTION_MODE, &entry)) { + const uint8_t data = *entry.data.u8; + int32_t noiseReductionMode; + switch (data) { + case ANDROID_NOISE_REDUCTION_MODE_OFF: + noiseReductionMode = controls::NoiseReductionModeOff; + break; + + case ANDROID_NOISE_REDUCTION_MODE_FAST: + noiseReductionMode = controls::NoiseReductionModeFast; + break; + + case ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY: + noiseReductionMode = controls::NoiseReductionModeHighQuality; + break; + + case ANDROID_NOISE_REDUCTION_MODE_MINIMAL: + noiseReductionMode = controls::NoiseReductionModeRaw; + break; + + case ANDROID_NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG: + noiseReductionMode = controls::NoiseReductionModeZSL; + break; + + default: + LOG(HAL, Error) + << "Unknown noise reduction mode: " << data; + return -EINVAL; + } + + controls.set(controls::NoiseReductionMode, noiseReductionMode); + } + if (settings.getEntry(ANDROID_EDGE_MODE, &entry)) { const auto &info = camera_->controls().find(&controls::Sharpness); if (info != camera_->controls().end()) { @@ -1587,9 +1620,6 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons value = ANDROID_STATISTICS_SCENE_FLICKER_NONE; resultMetadata->addEntry(ANDROID_STATISTICS_SCENE_FLICKER, value); - value = ANDROID_NOISE_REDUCTION_MODE_OFF; - resultMetadata->addEntry(ANDROID_NOISE_REDUCTION_MODE, value); - /* 33.3 msec */ const int64_t rolling_shutter_skew = 33300000; resultMetadata->addEntry(ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, @@ -1643,6 +1673,40 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons resultMetadata->addEntry(ANDROID_SCALER_CROP_REGION, cropRect); } + if (metadata.contains(controls::NoiseReductionMode)) { + bool valid; + switch (metadata.get(controls::NoiseReductionMode)) { + case controls::NoiseReductionModeOff: + value = ANDROID_NOISE_REDUCTION_MODE_OFF; + valid = true; + break; + case controls::NoiseReductionModeFast: + value = ANDROID_NOISE_REDUCTION_MODE_FAST; + valid = true; + break; + case controls::NoiseReductionModeHighQuality: + value = ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY; + valid = true; + break; + case controls::NoiseReductionModeRaw: + value = ANDROID_NOISE_REDUCTION_MODE_MINIMAL; + valid = true; + break; + case controls::NoiseReductionModeZSL: + value = ANDROID_NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG; + valid = true; + break; + default: + LOG(HAL, Error) + << "Unknown noise reduction mode"; + valid = false; + } + + /* Can be null on non-FULL */ + if (valid) + resultMetadata->addEntry(ANDROID_NOISE_REDUCTION_MODE, value); + } + if (metadata.contains(controls::draft::TestPatternMode)) { const int32_t testPatternMode = metadata.get(controls::draft::TestPatternMode);