From patchwork Sat Oct 11 16:03:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24594 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 0FDBBC3332 for ; Sat, 11 Oct 2025 16:03:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 992E56044D; Sat, 11 Oct 2025 18:03:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fw9fkwRL"; 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 C3F9B603E0 for ; Sat, 11 Oct 2025 18:03:43 +0200 (CEST) Received: from charm.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 787E5111D; Sat, 11 Oct 2025 18:02:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760198527; bh=nUwo8X77he7xCHYXX1WZpsW4CByiA4itnK5MKcAtNkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fw9fkwRLUirzvu3HJkG5h+6GFPy1QlwAz3VTaWE7PIuQ/2vkvXLACh/P+eG+PCv1H ZqvXW6qmIs+P+1xuPuB1OYFW6U8oqSOn/tGd2LNDz+zRpD1ceUTaMcd45CpE7pw15T C3P4Dy2uNnucCt0aDyJwnPURJNSfsSD9ntvATNMQ= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [RFC PATCH 6/7] ipa: softipa: Move camhelper to context Date: Sat, 11 Oct 2025 17:03:34 +0100 Message-ID: <20251011160335.50578-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011160335.50578-1-kieran.bingham@ideasonboard.com> References: <20251011160335.50578-1-kieran.bingham@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" Move the camhelper to the context structure so that it can be accessible for algorithms to use directly where needed. Signed-off-by: Kieran Bingham --- src/ipa/simple/ipa_context.h | 3 +++ src/ipa/simple/soft_simple.cpp | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h index c3081e3069b5..3d6a8b72861f 100644 --- a/src/ipa/simple/ipa_context.h +++ b/src/ipa/simple/ipa_context.h @@ -16,6 +16,7 @@ #include "libcamera/internal/matrix.h" #include "libcamera/internal/vector.h" +#include #include #include "core_ipa_interface.h" @@ -103,6 +104,8 @@ struct IPAContext { FCQueue frameContexts; ControlInfoMap::Map ctrlMap; bool ccmEnabled = false; + + std::unique_ptr camHelper; }; } /* namespace ipa::soft */ diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp index 0821d214815f..68ddf71e9f24 100644 --- a/src/ipa/simple/soft_simple.cpp +++ b/src/ipa/simple/soft_simple.cpp @@ -76,7 +76,6 @@ private: DebayerParams *params_; SwIspStats *stats_; - std::unique_ptr camHelper_; ControlInfoMap sensorInfoMap_; /* Local parameter storage */ @@ -99,8 +98,8 @@ int IPASoftSimple::init(const IPASettings &settings, ControlInfoMap *ipaControls, bool *ccmEnabled) { - camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel); - if (!camHelper_) { + context_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel); + if (!context_.camHelper) { LOG(IPASoft, Warning) << "Failed to create camera sensor helper for " << settings.sensorModel; @@ -220,15 +219,15 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo, int32_t againMax = gainInfo.max().get(); int32_t againDef = gainInfo.def().get(); - if (camHelper_) { - context_.configuration.agc.againMin = camHelper_->gain(againMin); - context_.configuration.agc.againMax = camHelper_->gain(againMax); - context_.configuration.agc.again10 = camHelper_->gain(1.0); + if (context_.camHelper) { + context_.configuration.agc.againMin = context_.camHelper->gain(againMin); + context_.configuration.agc.againMax = context_.camHelper->gain(againMax); + context_.configuration.agc.again10 = context_.camHelper->gain(1.0); context_.configuration.agc.againMinStep = (context_.configuration.agc.againMax - context_.configuration.agc.againMin) / 100.0; - if (camHelper_->blackLevel().has_value()) { + if (context_.camHelper->blackLevel().has_value()) { /* * The black level from camHelper_ is a 16 bit value, software ISP * works with 8 bit pixel values, both regardless of the actual @@ -236,7 +235,7 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo, * by dividing the value from the helper by 256. */ context_.configuration.black.level = - camHelper_->blackLevel().value() / 256; + context_.camHelper->blackLevel().value() / 256; } } else { /* @@ -313,7 +312,7 @@ void IPASoftSimple::processStats(const uint32_t frame, frameContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get(); int32_t again = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get(); - frameContext.sensor.gain = camHelper_ ? camHelper_->gain(again) : again; + frameContext.sensor.gain = context_.camHelper ? context_.camHelper->gain(again) : again; ControlList metadata(controls::controls); for (auto const &algo : algorithms()) @@ -332,7 +331,7 @@ void IPASoftSimple::processStats(const uint32_t frame, auto &againNew = frameContext.sensor.gain; ctrls.set(V4L2_CID_EXPOSURE, frameContext.sensor.exposure); ctrls.set(V4L2_CID_ANALOGUE_GAIN, - static_cast(camHelper_ ? camHelper_->gainCode(againNew) : againNew)); + static_cast(context_.camHelper ? context_.camHelper->gainCode(againNew) : againNew)); setSensorControls.emit(ctrls); }