From patchwork Sun Jun 16 16:38:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20329 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 31E3CC3293 for ; Sun, 16 Jun 2024 16:39:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 51B1F65489; Sun, 16 Jun 2024 18:39:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="O87Kl/UN"; 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 16B0D65456 for ; Sun, 16 Jun 2024 18:39:33 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BDFC7581 for ; Sun, 16 Jun 2024 18:39:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555956; bh=iR8y/Opgedt1TxZ6K4koPl5aVQAl8MKbwjL3MeBy+8I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=O87Kl/UNl6WvFvPadfktVkFyOFyAF1IWn1RxA6HapNmE8iBeRYxERlF8GM7WhTUIl IUf5O/LCUlJcQ9agXXWxbYpilhmKSXZTmQrwwFRwPoDJjg0Z2kqJBZa1I7OrBZM70H gwYyisUTY0Z1tQP/aDycdyPmvSjJ2RwFicVtugiI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 01/12] ipa: rkisp1: agc: Fix initialization without metering modes Date: Sun, 16 Jun 2024 19:38:59 +0300 Message-ID: <20240616163910.5506-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" When no metering modes are specified in the tuning file, the AGC initialzation fails with [0:00:46.148508875] [209] ERROR RkISP1Agc agc.cpp:46 'AeMeteringMode' parameter not found in tuning file which results in a camera initialization failure. Fix it by downgrading the error into a warning, and continuing the AGC initialization with the default metering mode. Fixes: 35233938ee5d ("ipa: rkisp1: agc: Read histogram weights from tuning file") Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/agc.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 8702145187c7..0f60d08fd41c 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -42,11 +42,9 @@ LOG_DEFINE_CATEGORY(RkISP1Agc) int Agc::parseMeteringModes(IPAContext &context, const YamlObject &tuningData) { - if (!tuningData.isDictionary()) { - LOG(RkISP1Agc, Error) + if (!tuningData.isDictionary()) + LOG(RkISP1Agc, Warning) << "'AeMeteringMode' parameter not found in tuning file"; - return -EINVAL; - } for (const auto &[key, value] : tuningData.asDict()) { if (controls::AeMeteringModeNameValueMap.find(key) == From patchwork Sun Jun 16 16:39:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20330 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 97E10C3237 for ; Sun, 16 Jun 2024 16:39:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5232065497; Sun, 16 Jun 2024 18:39:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cGH7JqIK"; 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 9DDC365490 for ; Sun, 16 Jun 2024 18:39:34 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0FEA6581 for ; Sun, 16 Jun 2024 18:39:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555958; bh=bKLtOf6T59SA9mfNixAx/+I8pUBY+yw0kkTKyQ+dW4U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cGH7JqIKM9XPLuiJ5kuF7OIFZXEXoknaNBEh2oo0O0hQI09lJZ0HBly+L4YEo2PCY o69gy55UL157XbW4DMEvZa9pJNvw7Fej1uuyTORyEDxp0lNMekgDD4vQ8tif+pOPqj UckWaLaOW1Jf1S05Ab7FZdkHHcvRSQ641UjiDwHY= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 02/12] ipa: libipa: agc_mean_luminance: Fix enumerator names Date: Sun, 16 Jun 2024 19:39:00 +0300 Message-ID: <20240616163910.5506-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" Enumerators in libcamera start with an upper case letter. Fix the AgcConstraint::Bound enumerators. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder Reviewed-by: Daniel Scally --- src/ipa/libipa/agc_mean_luminance.cpp | 10 +++++----- src/ipa/libipa/agc_mean_luminance.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index 271b5ae4bc97..f97ef11771c4 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -59,9 +59,9 @@ static constexpr double kDefaultRelativeLuminanceTarget = 0.16; /** * \enum AgcMeanLuminance::AgcConstraint::Bound * \brief Specify whether the constraint defines a lower or upper bound - * \var AgcMeanLuminance::AgcConstraint::lower + * \var AgcMeanLuminance::AgcConstraint::Lower * \brief The constraint defines a lower bound - * \var AgcMeanLuminance::AgcConstraint::upper + * \var AgcMeanLuminance::AgcConstraint::Upper * \brief The constraint defines an upper bound */ @@ -209,7 +209,7 @@ int AgcMeanLuminance::parseConstraintModes(const YamlObject &tuningData) */ if (constraintModes_.empty()) { AgcConstraint constraint = { - AgcConstraint::Bound::lower, + AgcConstraint::Bound::Lower, 0.98, 1.0, 0.5 @@ -467,11 +467,11 @@ double AgcMeanLuminance::constraintClampGain(uint32_t constraintModeIndex, double newGain = constraint.yTarget * hist.bins() / hist.interQuantileMean(constraint.qLo, constraint.qHi); - if (constraint.bound == AgcConstraint::Bound::lower && + if (constraint.bound == AgcConstraint::Bound::Lower && newGain > gain) gain = newGain; - if (constraint.bound == AgcConstraint::Bound::upper && + if (constraint.bound == AgcConstraint::Bound::Upper && newGain < gain) gain = newGain; } diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h index 0a81c6d285b8..d1bddda5d162 100644 --- a/src/ipa/libipa/agc_mean_luminance.h +++ b/src/ipa/libipa/agc_mean_luminance.h @@ -31,8 +31,8 @@ public: struct AgcConstraint { enum class Bound { - lower = 0, - upper = 1 + Lower = 0, + Upper = 1 }; Bound bound; double qLo; From patchwork Sun Jun 16 16:39:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20331 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 BA00EC3293 for ; Sun, 16 Jun 2024 16:39:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DBC3865496; Sun, 16 Jun 2024 18:39:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="n+LeNkU1"; 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 B303465493 for ; Sun, 16 Jun 2024 18:39:35 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 60F30581 for ; Sun, 16 Jun 2024 18:39:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555959; bh=qHex/GhOpVtvSDNS+a2L9r0JIy5S2kkk3xz7tBdU+cE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=n+LeNkU1FGuoLZlAD9wa72O2DLjKKH/Bmhe0QHaFgMefCoYp0Kxx33llEebvh/+Ce 8iSi9Yi5vEnDl8R8f6BDo/0U4qcc3Zydb0Zs0uySVZXpIAeNTgxAqvFbLKhOKsH6rT rVjlR6RM8GeMjmpoMyzHWHsztIU0n6EchDWS2y+0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 03/12] ipa: libipa: agc_mean_luminance: Include missing header Date: Sun, 16 Jun 2024 19:39:01 +0300 Message-ID: <20240616163910.5506-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" agc_mean_luminance.h uses utils::Duration, include the corresponding header. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder Reviewed-by: Daniel Scally --- src/ipa/libipa/agc_mean_luminance.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h index d1bddda5d162..576d28be8eb0 100644 --- a/src/ipa/libipa/agc_mean_luminance.h +++ b/src/ipa/libipa/agc_mean_luminance.h @@ -12,6 +12,8 @@ #include #include +#include + #include #include "libcamera/internal/yaml_parser.h" From patchwork Sun Jun 16 16:39:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20332 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 B236DC3237 for ; Sun, 16 Jun 2024 16:39:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 45A5F654A5; Sun, 16 Jun 2024 18:39:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="k4Jq5xve"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 07ADD65456 for ; Sun, 16 Jun 2024 18:39:37 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A9624669 for ; Sun, 16 Jun 2024 18:39:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555960; bh=eaX8jpG3xNBuwdiaUqx/PYZYVBl1gQMkN9FvmnkPYso=; h=From:To:Subject:Date:In-Reply-To:References:From; b=k4Jq5xveFcxFinyvqQtHALUQnm0OBTQlKygNpt0wkOAs84HOciN/avLGgTg4P+R8Z 8gQ4ixlg+TaImUc0FflwgDnnHgNJjvrzjp9ftZGHaA4Ytf8sAfBlcc4JZSxnxiN/In A68G7QkoQJbP2k3TVCbxnjH61mYEm9pPUafegPis= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 04/12] ipa: rkisp1: Document all AGC parameters in IPAActiveState Date: Sun, 16 Jun 2024 19:39:02 +0300 Message-ID: <20240616163910.5506-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The IPAActiveState AGC documentation is lagging behind the implementation and misses many variables. Document them. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/ipa_context.cpp | 40 +++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 65e0c58cb2ca..c4895479204c 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -137,13 +137,43 @@ namespace libcamera::ipa::rkisp1 { * \var IPAActiveState::agc * \brief State for the Automatic Gain Control algorithm * - * The exposure and gain are the latest values computed by the AGC algorithm. + * The \a automatic variables track the latest values computed by algorithm + * based on the latest processed statistics. All other variables track the + * consolidated controls requested in queued requests. * - * \var IPAActiveState::agc.exposure - * \brief Exposure time expressed as a number of lines + * \struct IPAActiveState::agc.manual + * \brief Manual exposure time and analog gain (set through requests) * - * \var IPAActiveState::agc.gain - * \brief Analogue gain multiplier + * \var IPAActiveState::agc.manual.exposure + * \brief Manual exposure time expressed as a number of lines as set by the + * ExposureTime control + * + * \var IPAActiveState::agc.manual.gain + * \brief Manual analogue gain as set by the AnalogueGain control + * + * \struct IPAActiveState::agc.automatic + * \brief Automatic exposure time and analog gain (computed by the algorithm) + * + * \var IPAActiveState::agc.automatic.exposure + * \brief Automatic exposure time expressed as a number of lines + * + * \var IPAActiveState::agc.automatic.gain + * \brief Automatic analogue gain multiplier + * + * \var IPAActiveState::agc.autoEnabled + * \brief Manual/automatic AGC state as set by the AeEnable control + * + * \var IPAActiveState::agc.constraintMode + * \brief Constraint mode as set by the AeConstraintMode control + * + * \var IPAActiveState::agc.exposureMode + * \brief Exposure mode as set by the AeExposureMode control + * + * \var IPAActiveState::agc.meteringMode + * \brief Metering mode as set by the AeMeteringMode control + * + * \var IPAActiveState::agc.maxShutterSpeed + * \brief Maximum frame duration as set by the FrameDurationLimits control */ /** From patchwork Sun Jun 16 16:39:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20333 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 B7985C3293 for ; Sun, 16 Jun 2024 16:39:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 510B765490; Sun, 16 Jun 2024 18:39:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZGMsFvdm"; 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 639C865498 for ; Sun, 16 Jun 2024 18:39:38 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C1F0669 for ; Sun, 16 Jun 2024 18:39:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555962; bh=8iyKf+bPjPmGAYDOMbRnHb6gd0OCoDzdVrGUby671Fg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZGMsFvdmsP/D1M+HT++MFp3k2xMkQj0JkuMblADLkhjIM0CDCMPi+YYyQouhZaiJn kAVe5xk0zI4+ZSWiiTGZSpyNM7A3xy7cqHqHkS7pAWrfJkiT2f0zjMQRqL4i8VOpac X3zqJPC6b2AWmJ9WucYeURSN0ChoHGkfsTGUVnMU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 05/12] ipa: rkisp1: Document all AGC parameters in IPAFrameContext Date: Sun, 16 Jun 2024 19:39:03 +0300 Message-ID: <20240616163910.5506-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The IPAFrameContext AGC documentation is lagging behind the implementation and misses many variables. Document them. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/ipa_context.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index c4895479204c..9e445dcca933 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -295,12 +295,30 @@ namespace libcamera::ipa::rkisp1 { * applied to the sensor in order to take effect for this frame. * * \var IPAFrameContext::agc.exposure - * \brief Exposure time expressed as a number of lines + * \brief Exposure time expressed as a number of lines computed by the algorithm * * \var IPAFrameContext::agc.gain - * \brief Analogue gain multiplier + * \brief Analogue gain multiplier computed by the algorithm * * The gain should be adapted to the sensor specific gain code before applying. + * + * \var IPAFrameContext::agc.autoEnabled + * \brief Manual/automatic AGC state as set by the AeEnable control + * + * \var IPAFrameContext::agc.constraintMode + * \brief Constraint mode as set by the AeConstraintMode control + * + * \var IPAFrameContext::agc.exposureMode + * \brief Exposure mode as set by the AeExposureMode control + * + * \var IPAFrameContext::agc.meteringMode + * \brief Metering mode as set by the AeMeteringMode control + * + * \var IPAFrameContext::agc.maxShutterSpeed + * \brief Maximum frame duration as set by the FrameDurationLimits control + * + * \var IPAFrameContext::agc.update + * \brief Indicate if new ISP parameters need to be applied */ /** From patchwork Sun Jun 16 16:39:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20334 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 6F7F1C3237 for ; Sun, 16 Jun 2024 16:39:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E31546549C; Sun, 16 Jun 2024 18:39:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="l1/WFQ48"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A4DE465490 for ; Sun, 16 Jun 2024 18:39:39 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 608B9669 for ; Sun, 16 Jun 2024 18:39:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555963; bh=Cux+EXVIIdq/5V99cPg+41qLkr+U9xjwm5zElv5DWsY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=l1/WFQ48Tm93p4v2qCVPw94Fc8cY2YeVRFkBAXXhIS18mj/WwgOpgtPhlHghc8y49 35OHbi/bPRcXyDUaJMeqjY4mYOYJ3smW8UlM7KT5zGeydOZ7lwGu0Tr3Li12XxqVRY BZTmhWoax6U2zShtDcUgFZ2oojugvP9GkX8o2U84= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 06/12] ipa: rkisp1: agc: Make size argument to computeHistogramPredivider const Date: Sun, 16 Jun 2024 19:39:04 +0300 Message-ID: <20240616163910.5506-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The Agc::computeHistogramPredivider() function doesn't need to modify its size parameter. Make it const. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/agc.cpp | 3 ++- src/ipa/rkisp1/algorithms/agc.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 0f60d08fd41c..9dac60bdb24e 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -84,7 +84,8 @@ int Agc::parseMeteringModes(IPAContext &context, const YamlObject &tuningData) return 0; } -uint8_t Agc::computeHistogramPredivider(Size &size, enum rkisp1_cif_isp_histogram_mode mode) +uint8_t Agc::computeHistogramPredivider(const Size &size, + enum rkisp1_cif_isp_histogram_mode mode) { /* * The maximum number of pixels that could potentially be in one bin is diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h index 996fea71755c..9ceaa82b099e 100644 --- a/src/ipa/rkisp1/algorithms/agc.h +++ b/src/ipa/rkisp1/algorithms/agc.h @@ -45,7 +45,7 @@ public: private: int parseMeteringModes(IPAContext &context, const YamlObject &tuningData); - uint8_t computeHistogramPredivider(Size &size, + uint8_t computeHistogramPredivider(const Size &size, enum rkisp1_cif_isp_histogram_mode mode); void fillMetadata(IPAContext &context, IPAFrameContext &frameContext, From patchwork Sun Jun 16 16:39:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20335 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 73A59C32CF for ; Sun, 16 Jun 2024 16:39:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EE5A9654A3; Sun, 16 Jun 2024 18:39:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="l1Jnm9wo"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EF89E6549C for ; Sun, 16 Jun 2024 18:39:40 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9B404581 for ; Sun, 16 Jun 2024 18:39:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555964; bh=nvEjnxXDoaAzYywje7s9crWAt2mcK7HP1gh0xhKw5Jk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=l1Jnm9woZxzrcjQI7uu5+fztzFLnGZ9cppU92YeJd4Jb52FbJv5qzrw60Qbbi6Wlo gLrnd8SxPTgiIgg/EjLj55Bbu/iTai9FEUG8PYNp830O10tnLdcV3+/y1K5QfRmqde W7bXUS6aJ8eObfLDViaIrPD4xQVrfhlxuozGIAd4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 07/12] ipa: rkisp1: agc: Don't update histogram parameters unnecessarily Date: Sun, 16 Jun 2024 19:39:05 +0300 Message-ID: <20240616163910.5506-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The ISP histogram parameters depends on the AE metering mode, but not on the other AE algorithm controls. The exposure mode, constraints mode and frame duration limits influence the behaviour of the algorithm, but not the histogram computation parameters. Update the histogram parameters only when AE metering mode changes. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/agc.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 9dac60bdb24e..9f3b59b45f95 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -261,26 +261,21 @@ void Agc::queueRequest(IPAContext &context, frameContext.agc.meteringMode = agc.meteringMode; const auto &exposureMode = controls.get(controls::AeExposureMode); - if (exposureMode) { - frameContext.agc.update = agc.exposureMode != *exposureMode; + if (exposureMode) agc.exposureMode = static_cast(*exposureMode); - } frameContext.agc.exposureMode = agc.exposureMode; const auto &constraintMode = controls.get(controls::AeConstraintMode); - if (constraintMode) { - frameContext.agc.update = agc.constraintMode != *constraintMode; + if (constraintMode) agc.constraintMode = static_cast(*constraintMode); - } frameContext.agc.constraintMode = agc.constraintMode; const auto &frameDurationLimits = controls.get(controls::FrameDurationLimits); if (frameDurationLimits) { utils::Duration maxShutterSpeed = std::chrono::milliseconds((*frameDurationLimits).back()); - frameContext.agc.update = agc.maxShutterSpeed != maxShutterSpeed; agc.maxShutterSpeed = maxShutterSpeed; } frameContext.agc.maxShutterSpeed = agc.maxShutterSpeed; From patchwork Sun Jun 16 16:39:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20336 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 033C6C3293 for ; Sun, 16 Jun 2024 16:39:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9F4196549E; Sun, 16 Jun 2024 18:39:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fNpKPXXP"; 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 0089E6549D for ; Sun, 16 Jun 2024 18:39:43 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EAA4B581 for ; Sun, 16 Jun 2024 18:39:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555966; bh=C53sEocjWN6QqGh5FTS7x1cao59+Pmh6LGpurAx+yd4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fNpKPXXPOj+g3M6DRI+kRbctNGWAWywiVp7TxlytiFrO14iSlvrGsg32dgvpFvSkT 3U7jE42/dOZQD36tbuILBrZNcKWPPzhJ4LKcAOVtnletlLFEDtKbYXU17E4ff9WqG4 lwkoYTiGWtF9aEofKXRyTjb8oBGTMdmtAFODvtn4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 08/12] ipa: rkisp1: agc: Simplify predivider calculation Date: Sun, 16 Jun 2024 19:39:06 +0300 Message-ID: <20240616163910.5506-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The condition if (std::pow(std::floor(root), 2) < factor) predivider = static_cast(std::ceil(root)); else predivider = static_cast(std::floor(root)); can only be false when the factor's root is an integer. In that case, std::ceil(root) and std::floor(root) will be equal. The computation can thus be simplified by always rounding up. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/algorithms/agc.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 9f3b59b45f95..a61201bb05c9 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -115,12 +115,7 @@ uint8_t Agc::computeHistogramPredivider(const Size &size, int count = mode == RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED ? 3 : 1; double factor = size.width * size.height * count / 65536.0; double root = std::sqrt(factor); - uint8_t predivider; - - if (std::pow(std::floor(root), 2) < factor) - predivider = static_cast(std::ceil(root)); - else - predivider = static_cast(std::floor(root)); + uint8_t predivider = static_cast(std::ceil(root)); return std::clamp(predivider, 3, 127); } From patchwork Sun Jun 16 16:39:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20337 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 4B549C32D0 for ; Sun, 16 Jun 2024 16:39:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5C21A654A5; Sun, 16 Jun 2024 18:39:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P8FJwDhZ"; 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 93DC9654A2 for ; Sun, 16 Jun 2024 18:39:43 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4464B581 for ; Sun, 16 Jun 2024 18:39:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555967; bh=wV66rHTTxgF6HYtzo7gxMBuiUra1Pb0uzhzCBTZfLik=; h=From:To:Subject:Date:In-Reply-To:References:From; b=P8FJwDhZudfGTOKdaMpknTYOtcmj3nP2Yl5aj1wD9C7KemIsPCOqMnnB0S3P9KvT3 unP2HraBL4b/70YR6uxhh6jxfjUfwmYpRrIrAXCfG4kwje+kdzFGfIfXWmceQHZ62x MpGIkqiAAeSMkUKx5dwNevKJDDus22Qv8Ceu9E5M= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 09/12] ipa: rkisp1: agc: Use mode from frame context to calculate new EV Date: Sun, 16 Jun 2024 19:39:07 +0300 Message-ID: <20240616163910.5506-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The effective exposure value for each frame is split into shutter time, analog gain and digital gain based on the AGC constraint mode and exposure mode. The algorithm uses the modes from the active state, which tracks the latest queued request, instead of the frame context, which tracks the value of the controls requested for that frame. Fix it by using the correct modes. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/agc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index a61201bb05c9..6a199b47c9ad 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -439,8 +439,8 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, utils::Duration shutterTime; double aGain, dGain; std::tie(shutterTime, aGain, dGain) = - calculateNewEv(context.activeState.agc.constraintMode, - context.activeState.agc.exposureMode, + calculateNewEv(frameContext.agc.constraintMode, + frameContext.agc.exposureMode, hist, effectiveExposureValue); LOG(RkISP1Agc, Debug) From patchwork Sun Jun 16 16:39:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20338 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 C1C7FC3237 for ; Sun, 16 Jun 2024 16:39:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4D293654AE; Sun, 16 Jun 2024 18:39:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rTAqpTA0"; 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 03B4E6549A for ; Sun, 16 Jun 2024 18:39:45 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 99FE9669 for ; Sun, 16 Jun 2024 18:39:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555968; bh=ec3VZDnl/loOa8Me0JXcaDm2cGq95C0t9RVxYa4T6VA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rTAqpTA0a7pINwQaDekaK37SznK56IkN77JZs6L3ihtFCx5hA2deL94KAOyGNxl5p 6RA1ADOlAs/AODrc79dtD7UPMQUvsni4KrHIv6kTJZxZHHcyYOF7hgIAkhjduZvbfY w8/onGYukbmnRcJ6Q+J2oIgjJmCK7Z5tIGD+jnhk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 10/12] ipa: rkisp1: agc: Rename maxShutterSpeed to maxFrameDuration Date: Sun, 16 Jun 2024 19:39:08 +0300 Message-ID: <20240616163910.5506-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The AGC active state and frame context both contain a variable named maxShutterSpeed. The variable is used to limit the maximum shutter speed when computing the exposure time and gains, but stores the maximum frame duration, not clamped by the sensor's maximum shutter speed. Rename it to maxFrameDuration. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/agc.cpp | 10 +++++----- src/ipa/rkisp1/ipa_context.cpp | 4 ++-- src/ipa/rkisp1/ipa_context.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 6a199b47c9ad..5b917557b887 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -182,7 +182,7 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) * except it's computed in the IPA and not here so we'd have to * recompute it. */ - context.activeState.agc.maxShutterSpeed = context.configuration.sensor.maxShutterSpeed; + context.activeState.agc.maxFrameDuration = context.configuration.sensor.maxShutterSpeed; /* * Define the measurement window for AGC as a centered rectangle @@ -269,11 +269,11 @@ void Agc::queueRequest(IPAContext &context, const auto &frameDurationLimits = controls.get(controls::FrameDurationLimits); if (frameDurationLimits) { - utils::Duration maxShutterSpeed = + utils::Duration maxFrameDuration = std::chrono::milliseconds((*frameDurationLimits).back()); - agc.maxShutterSpeed = maxShutterSpeed; + agc.maxFrameDuration = maxFrameDuration; } - frameContext.agc.maxShutterSpeed = agc.maxShutterSpeed; + frameContext.agc.maxFrameDuration = agc.maxFrameDuration; } /** @@ -421,7 +421,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, expMeans_ = { params->ae.exp_mean, context.hw->numAeCells }; utils::Duration maxShutterSpeed = std::min(context.configuration.sensor.maxShutterSpeed, - frameContext.agc.maxShutterSpeed); + frameContext.agc.maxFrameDuration); setLimits(context.configuration.sensor.minShutterSpeed, maxShutterSpeed, context.configuration.sensor.minAnalogueGain, diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 9e445dcca933..ab6cfae17feb 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -172,7 +172,7 @@ namespace libcamera::ipa::rkisp1 { * \var IPAActiveState::agc.meteringMode * \brief Metering mode as set by the AeMeteringMode control * - * \var IPAActiveState::agc.maxShutterSpeed + * \var IPAActiveState::agc.maxFrameDuration * \brief Maximum frame duration as set by the FrameDurationLimits control */ @@ -314,7 +314,7 @@ namespace libcamera::ipa::rkisp1 { * \var IPAFrameContext::agc.meteringMode * \brief Metering mode as set by the AeMeteringMode control * - * \var IPAFrameContext::agc.maxShutterSpeed + * \var IPAFrameContext::agc.maxFrameDuration * \brief Maximum frame duration as set by the FrameDurationLimits control * * \var IPAFrameContext::agc.update diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 6022480d4fd2..734856cdb199 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -72,7 +72,7 @@ struct IPAActiveState { controls::AeConstraintModeEnum constraintMode; controls::AeExposureModeEnum exposureMode; controls::AeMeteringModeEnum meteringMode; - utils::Duration maxShutterSpeed; + utils::Duration maxFrameDuration; } agc; struct { @@ -121,7 +121,7 @@ struct IPAFrameContext : public FrameContext { controls::AeConstraintModeEnum constraintMode; controls::AeExposureModeEnum exposureMode; controls::AeMeteringModeEnum meteringMode; - utils::Duration maxShutterSpeed; + utils::Duration maxFrameDuration; bool update; } agc; From patchwork Sun Jun 16 16:39:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20339 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 E30FFC32D1 for ; Sun, 16 Jun 2024 16:40:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 479B6654A4; Sun, 16 Jun 2024 18:40:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nyBNZoxp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 485F6654A4 for ; Sun, 16 Jun 2024 18:39:46 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E444A581 for ; Sun, 16 Jun 2024 18:39:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555970; bh=T64M81Hstr4clue5nu8JTOwU06Oj25vE6cgxpk5BQws=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nyBNZoxp8XCrFqSu5p34M5cvWfszBlCWA13zQmXKXDWZKRSOcO5Su9Le2EVAjsAA5 +sUN6DTPKuX7fGxGamoPNy3bXcqP6an9pvKKae9T2hGw3kQ/9XundGHXKg8OXy6Cve 6vSaxU4nc73E7WWqx2mVh2Sf/yj0LCXKdGqmOzCM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 11/12] ipa: rkisp1: agc: Correctly clamp maximum shutter speed Date: Sun, 16 Jun 2024 19:39:09 +0300 Message-ID: <20240616163910.5506-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The sensor's maximum shutter speed is clamped by the maximum frame duration specified in requests. If the requested maximum frame duration is lower than the sensor's minimum shutter speed, the Agc::process() function will pass a minimum value higher than the maximum to the setLimits() function, resulting in an assertion failure. Fix it by clamping the value to both the lower and the upper bounds. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/algorithms/agc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 5b917557b887..0018c43f18cf 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -420,8 +420,10 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, [](uint32_t x) { return x >> 4; }); expMeans_ = { params->ae.exp_mean, context.hw->numAeCells }; - utils::Duration maxShutterSpeed = std::min(context.configuration.sensor.maxShutterSpeed, - frameContext.agc.maxFrameDuration); + utils::Duration maxShutterSpeed = + std::clamp(frameContext.agc.maxFrameDuration, + context.configuration.sensor.minShutterSpeed, + context.configuration.sensor.maxShutterSpeed); setLimits(context.configuration.sensor.minShutterSpeed, maxShutterSpeed, context.configuration.sensor.minAnalogueGain, From patchwork Sun Jun 16 16:39:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20340 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 B298AC32CF for ; Sun, 16 Jun 2024 16:40:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1C812654A7; Sun, 16 Jun 2024 18:40:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NISr7vM/"; 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 8BC6D65456 for ; Sun, 16 Jun 2024 18:39:47 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3A376581 for ; Sun, 16 Jun 2024 18:39:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555971; bh=vbZEaBuhxyxSTiN4bA+ueKmgglndFXZr11EeC948W98=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NISr7vM/x4CMoVz8lYZU77G72tgE4gVAoNKfOYG2/kHg3jSbLwzBcu6qxBB+qFO14 DT4fCnBnVnZ9oXb3BbWSAgqmIhw6bioVHpLGlfWrXIk7SrrzfozZn/1UbFe7UlEHFT /g6B2iSLk5waGAb9E4Yvwu3hkV96zFOpV2POY7zQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 12/12] ipa: rkisp1: agc: Move AeEnable control to the AGC algorithm Date: Sun, 16 Jun 2024 19:39:10 +0300 Message-ID: <20240616163910.5506-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The AGC algorithm implements the AeEnable control at runtime. Move the declaration of the control from the IPA module to the algorithm. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/agc.cpp | 1 + src/ipa/rkisp1/rkisp1.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 0018c43f18cf..965030b62de5 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -148,6 +148,7 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData) if (ret) return ret; + context.ctrlMap[&controls::AeEnable] = ControlInfo(false, true); context.ctrlMap.merge(controls()); return 0; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 62d56a3ae44a..d31cdbab020b 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -106,7 +106,6 @@ const IPAHwSettings ipaHwSettingsV12{ /* List of controls handled by the RkISP1 IPA */ const ControlInfoMap::Map rkisp1Controls{ - { &controls::AeEnable, ControlInfo(false, true) }, { &controls::AwbEnable, ControlInfo(false, true) }, { &controls::ColourGains, ControlInfo(0.0f, 3.996f, 1.0f) }, { &controls::Sharpness, ControlInfo(0.0f, 10.0f, 1.0f) },