From patchwork Thu Aug 18 09:44:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 17172 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 4FE91C3275 for ; Thu, 18 Aug 2022 09:44:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1BDFF61FD7; Thu, 18 Aug 2022 11:44:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660815886; bh=yAzfEucn64cZbT1mW9CLX+VERX4KGIvc6xRdCAfi+6E=; 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=EWfSg/Ujg4Tl/gOLAw0An7NqENh0qfDShuSNMSgqKWqLJjU/nUB8lQwJn0jDdKFDy CJo7295T6r2fFftwnKhD/KP5ddMsagE8Rd/tBYRlunAJwEhGPD20R9E8OGJgFq3Hxp 0BUNY1b+3z6QKnZPGRo5GCzaajtZKDITwv+uF5TIP/3P9NpEZMflc5sMBriBz22j5Y riBHjI8iTwFB+ZMmCOGLGrja9dn9HnV0+W1aHBoYiGgpR1EIoXYqkdw1gRhOZwwcJB T9rh/UWyS8xNsfrDh6Zq3YsAGWSssUQNcRhtAeppmdjTQpLIEULk261mIgMFRPS2ds IQ9ckMyCMSwcQ== Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CEB1061FDB for ; Thu, 18 Aug 2022 11:44:40 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id D2DB3FF806; Thu, 18 Aug 2022 09:44:39 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Thu, 18 Aug 2022 11:44:10 +0200 Message-Id: <20220818094410.1671-18-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220818094410.1671-1-jacopo@jmondi.org> References: <20220818094410.1671-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 17/17] ipa: rkisp1: Store configuration data in context 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The RkISP1 IPA module stores per-configuration session data, such as the sensor and lens controls and the sensor information, in class member variables. As the IPAContext structure has exactly a place for session-specific configuration data, move those information in the context_ and remove them from the class. Signed-off-by: Jacopo Mondi --- src/ipa/rkisp1/ipa_context.cpp | 15 +++++++++++++++ src/ipa/rkisp1/ipa_context.h | 6 ++++++ src/ipa/rkisp1/rkisp1.cpp | 33 ++++++++++++++------------------- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index ef8bb8e931c8..e31059e52cee 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -100,6 +100,21 @@ namespace libcamera::ipa::rkisp1 { * \brief Sensor output resolution */ +/** + * \var IPASessionConfiguration::sensorCtrls + * \brief The list of V4L2 sensor controls limits + */ + +/** + * \var IPASessionConfiguration::lensCtrls + * \brief The list of V4L2 lens controls limits + */ + +/** + * \var IPASessionConfiguration::sensorInfo + * \brief The sensor configuration for the streaming session + */ + /** * \var IPAFrameContext::agc * \brief Context for the Automatic Gain Control algorithm diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index dd756f4025d1..6151f35af900 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -14,6 +14,8 @@ #include +#include + #include namespace libcamera { @@ -41,6 +43,10 @@ struct IPASessionConfiguration { struct { rkisp1_cif_isp_version revision; } hw; + + ControlInfoMap sensorCtrls; + ControlInfoMap lensCtrls; + IPACameraSensorInfo sensorInfo; }; struct IPAActiveState { diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index a1834034e617..01d64c48b126 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -71,9 +71,6 @@ private: std::map buffers_; std::map mappedBuffers_; - ControlInfoMap sensorCtrls_; - std::optional lensCtrls_; - /* revision-specific data */ rkisp1_cif_isp_version hwRevision_; unsigned int hwHistBinNMax_; @@ -211,9 +208,17 @@ bool IPARkISP1::validateSensorControls(const ControlInfoMap &sensorControls) void IPARkISP1::updateSessionConfiguration(const IPAConfigInfo &configInfo) { - const IPACameraSensorInfo &sensorInfo = configInfo.sensorInfo; - const ControlInfoMap &sensorControls = configInfo.sensorControls; + /* Clear the IPA context before the streaming session. */ + context_.frameContexts.clear(); + context_ = {}; + + context_.configuration.sensorCtrls = configInfo.sensorControls; + context_.configuration.lensCtrls = configInfo.lensControls; + + /* Set the hardware revision for the algorithms. */ + context_.configuration.hw.revision = hwRevision_; + const ControlInfoMap &sensorControls = configInfo.sensorControls; const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second; const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second; int32_t minExposure = v4l2Exposure.min().get(); @@ -226,16 +231,9 @@ void IPARkISP1::updateSessionConfiguration(const IPAConfigInfo &configInfo) << "Exposure: " << minExposure << "-" << maxExposure << " Gain: " << minGain << "-" << maxGain; - /* Clear the IPA context before the streaming session. */ - context_.frameContexts.clear(); - context_ = {}; - - /* Set the hardware revision for the algorithms. */ - context_.configuration.hw.revision = hwRevision_; - - context_.configuration.sensor.size = sensorInfo.outputSize; - context_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s - / sensorInfo.pixelRate; + context_.configuration.sensor.size = configInfo.sensorInfo.outputSize; + context_.configuration.sensor.lineDuration = configInfo.sensorInfo.lineLength * 1.0s + / configInfo.sensorInfo.pixelRate; /* * When the AGC computes the new exposure values for a frame, it needs @@ -259,9 +257,6 @@ int IPARkISP1::configure(const IPAConfigInfo &configInfo) return -EINVAL; } - sensorCtrls_ = configInfo.sensorControls; - lensCtrls_ = configInfo.lensControls; - updateSessionConfiguration(configInfo); for (auto const &algo : algorithms()) { @@ -358,7 +353,7 @@ void IPARkISP1::setControls(unsigned int frame) uint32_t exposure = context_.activeState.agc.exposure; uint32_t gain = camHelper_->gainCode(context_.activeState.agc.gain); - ControlList ctrls(sensorCtrls_); + ControlList ctrls(context_.configuration.sensorCtrls); ctrls.set(V4L2_CID_EXPOSURE, static_cast(exposure)); ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain));