From patchwork Tue Oct 28 09:31:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 24840 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 3BDA1BE080 for ; Tue, 28 Oct 2025 09:32:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A07F360794; Tue, 28 Oct 2025 10:32:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="On0EWrKk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3038760791 for ; Tue, 28 Oct 2025 10:32:08 +0100 (CET) Received: from [192.168.0.172] (mob-5-90-58-13.net.vodafone.it [5.90.58.13]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 812431D29; Tue, 28 Oct 2025 10:30:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761643819; bh=LnOy57B0dhajeFihc9nwOXI4ugAWSbZamws1XO1+2V4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=On0EWrKkaVz1YXUTzFMgg4WmSM3s1LxMb+F8PhwJ36gyQAO6hncLpGd2higTY6cY4 8TR0Z6N30ntQuUluEPdduDKdqyWC5TJMvDOAHRMzK+cZ8zhycKNWj9LcVETxF1N0ps mXHr1O9xuwLZZMLnfiwZH5nefKasDpV/16ja6Od8= From: Jacopo Mondi Date: Tue, 28 Oct 2025 10:31:48 +0100 Subject: [PATCH v2 02/10] ipa: mali-c55: Move CameraHelper to context MIME-Version: 1.0 Message-Id: <20251028-exposure-limits-v2-2-a8b5a318323e@ideasonboard.com> References: <20251028-exposure-limits-v2-0-a8b5a318323e@ideasonboard.com> In-Reply-To: <20251028-exposure-limits-v2-0-a8b5a318323e@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Robert Mader , libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Kieran Bingham X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5693; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=PQkhZX8GHLnV60t4CeY04DEIjNCw6nFgT/razeFVaWE=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpAI2Vf/+iu1EP0c1d6uDJ4uY8Uh6VjGDQND4hy WtGLtzzddaJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQCNlQAKCRByNAaPFqFW PAM7EAC1giyUMVw3buFTrIrCtaXgYrGKuF1PuJ5I2hxScOeYp44xHyYh+/i5virirL4RhxIisEc IYLr9JDhxPSWHTWyFqmsNEoVRot5AlRm6fA3nXY95z22L4w1U4YrOHrnD6ltxgZ1nwdo0RIgs+I 7IKMrXqT2LFlw6WWqFNRotL2h/ZVOWopqtVZaqOeKAUNPi7uwWc6Pgzka1RANVcnij8JGKMjMia mXoKS2gIuuchUOUQfJ/xKv+SN3xEffWD6DP0lZdL9PkEFI7M52zEwMkqZGlC1eCr/CcBXpSXXT+ ypbEf5HkvubcFDS40cLjt/C7h5/uA/4UhEVlOnlca2VQPeffJ1uvfdHisltxEn5Qjq3bAeW/1a2 QzNEHYczwNreXLnFakUNc/2WWAlMbyAUaJBsQbwXAdMCn5WvVLwFlmPJ1n4YR2RRonF54vfcPqq D6nNQ8sbPOhYO+BE9LQbOeDpdDs0PPfa/fl4EO56byAVcMLUMEDgC+SIoTBhm5AoU1Wwl+dDvmU N6UtivmevEQcCuKiBJ2N18rchMtho5M8/4uMrUPkFR/5ZOHAwCnlXClNJmGg3WeQMNawNmCqnqW nZCDJJzz1Vb594J0Zb6GLfvRVAShCmUiiJy6PdzVGK9zT5QSJDtDe8efWXfnZ/5ey2A8E4obm0G P0o1uaXGYaXhXJQ== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" From: Kieran Bingham Move the CameraHelper sensor to the Context so that it can be used by the algorithms directly. While at it, document the undocumented ctrlMap member of IPAContext. Signed-off-by: Kieran Bingham Signed-off-by: Jacopo Mondi --- src/ipa/mali-c55/ipa_context.cpp | 6 ++++++ src/ipa/mali-c55/ipa_context.h | 4 ++++ src/ipa/mali-c55/mali-c55.cpp | 27 ++++++++++++--------------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/ipa/mali-c55/ipa_context.cpp b/src/ipa/mali-c55/ipa_context.cpp index 1b203e2b260592cda945855d54f1aceefaaece91..a1e4c39f38704d3a4b5948ab789ffb9773f216c9 100644 --- a/src/ipa/mali-c55/ipa_context.cpp +++ b/src/ipa/mali-c55/ipa_context.cpp @@ -96,6 +96,12 @@ namespace libcamera::ipa::mali_c55 { * * \var IPAContext::frameContexts * \brief Ring buffer of per-frame contexts + * + * \var IPAContext::ctrlMap + * \brief A ControlInfoMap::Map of controls populated by the algorithms + * + * \var IPAContext::camHelper + * \brief The camera sensor helper */ } /* namespace libcamera::ipa::mali_c55 */ diff --git a/src/ipa/mali-c55/ipa_context.h b/src/ipa/mali-c55/ipa_context.h index 13885eb83b5c4d7c7af6c4f8d5673890834fed58..bfa805c7b93f313dda2497365e83542bbc39e291 100644 --- a/src/ipa/mali-c55/ipa_context.h +++ b/src/ipa/mali-c55/ipa_context.h @@ -12,6 +12,7 @@ #include "libcamera/internal/bayer_format.h" +#include #include namespace libcamera { @@ -83,6 +84,9 @@ struct IPAContext { FCQueue frameContexts; ControlInfoMap::Map ctrlMap; + + /* Interface to the Camera Helper */ + std::unique_ptr camHelper; }; } /* namespace ipa::mali_c55 */ diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp index 7d45e7310aecdae0e47655e6d2e8830e776d74cd..0751513dc584ca84dd212bf8c1469dd4b40c053d 100644 --- a/src/ipa/mali-c55/mali-c55.cpp +++ b/src/ipa/mali-c55/mali-c55.cpp @@ -74,9 +74,6 @@ private: ControlInfoMap sensorControls_; - /* Interface to the Camera Helper */ - std::unique_ptr camHelper_; - /* Local parameter storage */ struct IPAContext context_; }; @@ -98,8 +95,8 @@ std::string IPAMaliC55::logPrefix() const int IPAMaliC55::init(const IPASettings &settings, const IPAConfigInfo &ipaConfig, ControlInfoMap *ipaControls) { - camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel); - if (!camHelper_) { + context_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel); + if (!context_.camHelper) { LOG(IPAMaliC55, Error) << "Failed to create camera sensor helper for " << settings.sensorModel; @@ -142,10 +139,10 @@ void IPAMaliC55::setControls() if (activeState.agc.autoEnabled) { exposure = activeState.agc.automatic.exposure; - gain = camHelper_->gainCode(activeState.agc.automatic.sensorGain); + gain = context_.camHelper->gainCode(activeState.agc.automatic.sensorGain); } else { exposure = activeState.agc.manual.exposure; - gain = camHelper_->gainCode(activeState.agc.manual.sensorGain); + gain = context_.camHelper->gainCode(activeState.agc.manual.sensorGain); } ControlList ctrls(sensorControls_); @@ -191,17 +188,17 @@ void IPAMaliC55::updateSessionConfiguration(const IPACameraSensorInfo &info, context_.configuration.agc.minShutterSpeed = minExposure * context_.configuration.sensor.lineDuration; context_.configuration.agc.maxShutterSpeed = maxExposure * context_.configuration.sensor.lineDuration; context_.configuration.agc.defaultExposure = defExposure; - context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain); - context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain); + context_.configuration.agc.minAnalogueGain = context_.camHelper->gain(minGain); + context_.configuration.agc.maxAnalogueGain = context_.camHelper->gain(maxGain); - if (camHelper_->blackLevel().has_value()) { + if (context_.camHelper->blackLevel().has_value()) { /* * The black level from CameraSensorHelper is a 16-bit value. * The Mali-C55 ISP expects 20-bit settings, so we shift it to * the appropriate width */ context_.configuration.sensor.blackLevel = - camHelper_->blackLevel().value() << 4; + context_.camHelper->blackLevel().value() << 4; } } @@ -252,9 +249,9 @@ void IPAMaliC55::updateControls(const IPACameraSensorInfo &sensorInfo, /* Compute the analogue gain limits. */ const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second; - float minGain = camHelper_->gain(v4l2Gain.min().get()); - float maxGain = camHelper_->gain(v4l2Gain.max().get()); - float defGain = camHelper_->gain(v4l2Gain.def().get()); + float minGain = context_.camHelper->gain(v4l2Gain.min().get()); + float maxGain = context_.camHelper->gain(v4l2Gain.max().get()); + float defGain = context_.camHelper->gain(v4l2Gain.def().get()); ctrlMap[&controls::AnalogueGain] = ControlInfo(minGain, maxGain, defGain); /* @@ -362,7 +359,7 @@ void IPAMaliC55::processStats(unsigned int request, unsigned int bufferId, frameContext.agc.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get(); frameContext.agc.sensorGain = - camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); + context_.camHelper->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); ControlList metadata(controls::controls);