From patchwork Mon Oct 24 00:03:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17665 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 AEE6EC3285 for ; Mon, 24 Oct 2022 00:04:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 473C562EE1; Mon, 24 Oct 2022 02:04:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666569868; bh=JE+NAC0fH+332zKjoX/apa/qS38zFdF3xFEWWL7kJDs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=2PmovXopavjJhiUu7uKZx+vV9jhsgaFnRx+n6nBeb0WkwVqprZy3oLkmS5D9UL8V1 wYpTVctTgorRsDCTlaRrdfy/hxjILgfz2OPrkVt36yDbwwkpDtoCMhxOTzALgu58Pv yfC7wDRoxf9Qx/uB7iOyRhNeRy2IB5gdAQ2+K/BmCQ/pvedsniWRheA+5xRmnZfEov ptGmYEhBBc2Nln9dtPu05FhhrtxPUniQV/B6mhq1TxA1OiyNtEbcNkNeGokgU0kGaK DcvnT26pH3ls/H1jFFniEBPe3ZyVioIIdlrvYFlo0WoO4XU53Rt+iZF96tNwNs7TMB S3e3BxZOjeAgQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5BD662EDA for ; Mon, 24 Oct 2022 02:04:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bgaV2PqE"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F19CF471; Mon, 24 Oct 2022 02:04:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1666569864; bh=JE+NAC0fH+332zKjoX/apa/qS38zFdF3xFEWWL7kJDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bgaV2PqEHeCRq5Zl5fx/p7Wto3iZYZpZUGyGExVulTOuacXFNAe+vE0SnbIJ2A8SM NNJnNL6SiRXgDnWPBeFVzhSakEqTVEDMgdYzT/1f/DlalS3o9LesAWF78M5qXBBRaH +g334I0QEnp4OSmExopf3zLwKNmjOoiaXkHaGq5Y= To: libcamera-devel@lists.libcamera.org Date: Mon, 24 Oct 2022 03:03:45 +0300 Message-Id: <20221024000356.29521-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221024000356.29521-1-laurent.pinchart@ideasonboard.com> References: <20221024000356.29521-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 02/13] ipa: rkisp1: Move shutter speed and analogue gain limits from agc to sensor 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The limits for the shutter speed and analogue gain are stored in IPASessionConfiguration::agc. While they're related to the AGC, they are properties of the sensor, and are stored in the session configuration by the IPA module, not the AGC algorithm. Move them to the IPASessionConfiguration::sensor structure where they belong. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/algorithms/agc.cpp | 11 ++++++----- src/ipa/rkisp1/ipa_context.cpp | 28 +++++++++++++++------------- src/ipa/rkisp1/ipa_context.h | 25 +++++++++++++------------ src/ipa/rkisp1/rkisp1.cpp | 10 ++++++---- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 3fcbfa608467..169afe372803 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -74,7 +74,8 @@ Agc::Agc() int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) { /* Configure the default exposure and gain. */ - context.activeState.agc.gain = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain); + context.activeState.agc.gain = std::max(context.configuration.sensor.minAnalogueGain, + kMinAnalogueGain); context.activeState.agc.exposure = 10ms / context.configuration.sensor.lineDuration; /* @@ -202,13 +203,13 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext &frameContext, /* Use the highest of the two gain estimates. */ double evGain = std::max(yGain, iqMeanGain); - utils::Duration minShutterSpeed = configuration.agc.minShutterSpeed; - utils::Duration maxShutterSpeed = std::min(configuration.agc.maxShutterSpeed, + utils::Duration minShutterSpeed = configuration.sensor.minShutterSpeed; + utils::Duration maxShutterSpeed = std::min(configuration.sensor.maxShutterSpeed, kMaxShutterSpeed); - double minAnalogueGain = std::max(configuration.agc.minAnalogueGain, + double minAnalogueGain = std::max(configuration.sensor.minAnalogueGain, kMinAnalogueGain); - double maxAnalogueGain = std::min(configuration.agc.maxAnalogueGain, + double maxAnalogueGain = std::min(configuration.sensor.maxAnalogueGain, kMaxAnalogueGain); /* Consider within 1% of the target as correctly exposed. */ diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 3c14cf3476ce..7a987497bd03 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -28,21 +28,11 @@ namespace libcamera::ipa::rkisp1 { * \var IPASessionConfiguration::agc * \brief AGC parameters configuration of the IPA * - * \var IPASessionConfiguration::agc.minShutterSpeed - * \brief Minimum shutter speed supported with the configured sensor - * - * \var IPASessionConfiguration::agc.maxShutterSpeed - * \brief Maximum shutter speed supported with the configured sensor - * - * \var IPASessionConfiguration::agc.minAnalogueGain - * \brief Minimum analogue gain supported with the configured sensor - * - * \var IPASessionConfiguration::agc.maxAnalogueGain - * \brief Maximum analogue gain supported with the configured sensor - * * \var IPASessionConfiguration::agc.measureWindow * \brief AGC measure window - * + */ + +/** * \var IPASessionConfiguration::hw * \brief RkISP1-specific hardware information * @@ -77,6 +67,18 @@ namespace libcamera::ipa::rkisp1 { * \var IPASessionConfiguration::sensor * \brief Sensor-specific configuration of the IPA * + * \var IPASessionConfiguration::sensor.minShutterSpeed + * \brief Minimum shutter speed supported with the sensor + * + * \var IPASessionConfiguration::sensor.maxShutterSpeed + * \brief Maximum shutter speed supported with the sensor + * + * \var IPASessionConfiguration::sensor.minAnalogueGain + * \brief Minimum analogue gain supported with the sensor + * + * \var IPASessionConfiguration::sensor.maxAnalogueGain + * \brief Maximum analogue gain supported with the sensor + * * \var IPASessionConfiguration::sensor.defVBlank * \brief The default vblank value of the sensor * diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 60e8a7e11196..bb60ab9eab72 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -21,24 +21,25 @@ namespace libcamera { namespace ipa::rkisp1 { struct IPASessionConfiguration { + struct { + struct rkisp1_cif_isp_window measureWindow; + } agc; + + struct { + struct rkisp1_cif_isp_window measureWindow; + bool enabled; + } awb; + + struct { + bool enabled; + } lsc; + struct { utils::Duration minShutterSpeed; utils::Duration maxShutterSpeed; double minAnalogueGain; double maxAnalogueGain; - struct rkisp1_cif_isp_window measureWindow; - } agc; - struct { - struct rkisp1_cif_isp_window measureWindow; - bool enabled; - } awb; - - struct { - bool enabled; - } lsc; - - struct { int32_t defVBlank; utils::Duration lineDuration; Size size; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 9061a189cbce..fcb9dacccc3c 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -257,10 +257,12 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, * * \todo take VBLANK into account for maximum shutter speed */ - context_.configuration.agc.minShutterSpeed = minExposure * context_.configuration.sensor.lineDuration; - context_.configuration.agc.maxShutterSpeed = maxExposure * context_.configuration.sensor.lineDuration; - context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain); - context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain); + context_.configuration.sensor.minShutterSpeed = + minExposure * context_.configuration.sensor.lineDuration; + context_.configuration.sensor.maxShutterSpeed = + maxExposure * context_.configuration.sensor.lineDuration; + context_.configuration.sensor.minAnalogueGain = camHelper_->gain(minGain); + context_.configuration.sensor.maxAnalogueGain = camHelper_->gain(maxGain); for (auto const &algo : algorithms()) { int ret = algo->configure(context_, info);