From patchwork Wed May 6 21:46:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 26648 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 C7069C32F6 for ; Wed, 6 May 2026 22:19:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1EF266302E; Thu, 7 May 2026 00:19:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=jetm.me header.i=@jetm.me header.b="CmGqEsCA"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="R98w9VOA"; dkim-atps=neutral Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 310876301A for ; Thu, 7 May 2026 00:19:43 +0200 (CEST) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 74A5714000FF; Wed, 6 May 2026 18:19:42 -0400 (EDT) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-02.internal (MEProxy); Wed, 06 May 2026 18:19:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetm.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1778105982; x=1778192382; bh=+uCojCTKCMOFVIV59W7fSxyYCD3fDWoJOIKPEBSOamQ=; b= CmGqEsCAEW/7L4YCkQ99iPcFk2FUmHP1qcFrYZjDf2ps7enCm1Zl21wvqlqlHPFn 8NPE6cRhQGpmLegWOWXG7D3eYQ+lr1GFIGa/UOKimI4CxZjNLpTOxmgyIAz4AB3l D/0mIAufA61ixWJblF7IMUQTBaWZtEUvpifRUrgwYVJuv9o/6ZMyHIiFEZQkyrf6 MbmAVIpTZYZV0/vIfY2VlEDV0OxsKur/XnvE20TmsrG7auVQP5k9EfYKfrk02I7/ IFF4kCO7s2Uf6+reCnaG5fpFYzZHVUen4tRuNwLs+/lifIRUjCONazhudMu3tjlv 1R88wPVrdrHejx39lJ1exw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1778105982; x= 1778192382; bh=+uCojCTKCMOFVIV59W7fSxyYCD3fDWoJOIKPEBSOamQ=; b=R 98w9VOARBcxVEGmiXkiPnIBsBldJHOUwe1RZ7XQDk6Y6s03qLHZTLNSXJNQRoTan iG/YAu493ACmUIy4VRP2L3HneyOBiSgyGVQaQmMIIwsPCmLRxTSfAFnJ1E+diIUA s/nYD76n/uwitCK2si/fLSoNRe9VWiY/SoPaIpmt43ImdZwn1XcoAItTHOl04g76 aoxIC4WWPFEJQcs5iIkMnueAHpKID5oHDckVlxBkETOKZs3Q2JFIxqoNTy26xFor 3t7i3GRfsdmMxZoJRo12uGGlCsk7T+Uy4/OeM4r78C6eNrnYRNymULer66E6QgnU Iq0R6MQKN/4SGtHiiwSpg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddutdehjeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgopfhokfffucdluddtmdenucfjughrpefotggggffhvf ffufevjghfsehtkedttdertdejnecuhfhrohhmpeflrghvihgvrhcuvfhirgcuoehflhho shhssehjvghtmhdrmhgvqeenucggtffrrghtthgvrhhnpedtudejffejkeekteelueefvd ejvdeuhfefteehkeevtddvleduteekleetvdelhfenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehflhhoshhssehjvghtmhdrmhgvpdhnsggprh gtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsrghrnhgrsggr shdrphhotgiivgesihguvggrshhonhgsohgrrhgurdgtohhmpdhrtghpthhtohepkhhivg hrrghnrdgsihhnghhhrghmsehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthho pehlihgstggrmhgvrhgrqdguvghvvghlsehlihhsthhsrdhlihgstggrmhgvrhgrrdhorh hgpdhrtghpthhtohepjhhohhgrnhhnvghsrdhgohgvuggvsehoshhsrdhquhgrlhgtohhm mhdrtghomhdprhgtphhtthhopehmiigrmhgriigrlhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: i9dde48b3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 55C4F1EA006B; Wed, 6 May 2026 18:19:42 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 From: Javier Tia To: libcamera-devel@lists.libcamera.org Date: Wed, 06 May 2026 15:46:01 -0600 Subject: [PATCH v5 1/3] ipa: simple: agc: Replace bang-bang controller with proportional Cc: mzamazal@redhat.com, barnabas.pocze@ideasonboard.com, kieran.bingham@ideasonboard.com, johannes.goede@oss.qualcomm.com In-Reply-To: <177810597783.688418.1631246733707368646@jetm.me> References: <177810597783.688418.1631246733707368646@jetm.me> Message-Id: <20260506221942.55C4F1EA006B@mailuser.phl.internal> 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's updateExposure() uses a fixed ~10% step per frame regardless of how far the current exposure is from optimal. With a hysteresis dead band of only +/-4%, the controller overshoots when the correct value falls within one step, causing visible brightness oscillation (flicker). Replace the fixed-step bang-bang controller with a proportional one where the correction factor scales linearly with the MSV error: factor = 1.0 + clamp(error * 0.04, -0.15, +0.15) At maximum error (~2.5), this gives the same ~10% step as before. Near the target, steps shrink to <1%, eliminating overshoot. The step is clamped to +/-15% to bound corrections when the scene changes dramatically. The existing hysteresis (kExposureSatisfactory) still prevents hunting on noise. Tested on OV2740 behind Intel IPU6 ISYS (ThinkPad X1 Carbon Gen 10) where the old controller produced continuous brightness flicker. The proportional controller converges in ~3 seconds from cold start with no visible oscillation. Signed-off-by: Javier Tia Reviewed-by: Milan Zamazal Tested-by: Barnabás Pőcze --- src/ipa/simple/algorithms/agc.cpp | 73 +++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp index 2f7e040c..a13a7552 100644 --- a/src/ipa/simple/algorithms/agc.cpp +++ b/src/ipa/simple/algorithms/agc.cpp @@ -7,6 +7,8 @@ #include "agc.h" +#include +#include #include #include @@ -37,52 +39,74 @@ static constexpr float kExposureOptimal = kExposureBinsCount / 2.0; */ static constexpr float kExposureSatisfactory = 0.2; +/* + * Proportional gain for exposure/gain adjustment. Maps the MSV error to a + * multiplicative correction factor: + * + * factor = 1.0 + kExpProportionalGain * error + * + * With kExpProportionalGain = 0.04: + * - max error ~2.5 -> factor 1.10 (~10% step, same as before) + * - error 1.0 -> factor 1.04 (~4% step) + * - error 0.3 -> factor 1.012 (~1.2% step) + * + * This replaces the fixed 10% bang-bang step with a proportional correction + * that converges smoothly and avoids overshooting near the target. + */ +static constexpr float kExpProportionalGain = 0.04; + +/* + * Maximum multiplicative step per frame, to bound the correction when the + * scene changes dramatically. + */ +static constexpr float kExpMaxStep = 0.15; + Agc::Agc() { } void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV) { - /* - * kExpDenominator of 10 gives ~10% increment/decrement; - * kExpDenominator of 5 - about ~20% - */ - static constexpr uint8_t kExpDenominator = 10; - static constexpr uint8_t kExpNumeratorUp = kExpDenominator + 1; - static constexpr uint8_t kExpNumeratorDown = kExpDenominator - 1; - int32_t &exposure = frameContext.sensor.exposure; double &again = frameContext.sensor.gain; - if (exposureMSV < kExposureOptimal - kExposureSatisfactory) { + double error = kExposureOptimal - exposureMSV; + + if (std::abs(error) <= kExposureSatisfactory) + return; + + /* + * Compute a proportional correction factor. The sign of the error + * determines the direction: positive error means too dark (increase), + * negative means too bright (decrease). + */ + float step = std::clamp(static_cast(error) * kExpProportionalGain, + -kExpMaxStep, kExpMaxStep); + float factor = 1.0f + step; + + if (factor > 1.0f) { + /* Scene too dark: increase exposure first, then gain. */ if (exposure < context.configuration.agc.exposureMax) { - int32_t next = exposure * kExpNumeratorUp / kExpDenominator; - if (next - exposure < 1) - exposure += 1; - else - exposure = next; + int32_t next = static_cast(exposure * factor); + exposure = std::max(next, exposure + 1); } else { - double next = again * kExpNumeratorUp / kExpDenominator; + double next = again * factor; if (next - again < context.configuration.agc.againMinStep) again += context.configuration.agc.againMinStep; else again = next; } - } - - if (exposureMSV > kExposureOptimal + kExposureSatisfactory) { + } else { + /* Scene too bright: decrease gain first, then exposure. */ if (again > context.configuration.agc.again10) { - double next = again * kExpNumeratorDown / kExpDenominator; + double next = again * factor; if (again - next < context.configuration.agc.againMinStep) again -= context.configuration.agc.againMinStep; else again = next; } else { - int32_t next = exposure * kExpNumeratorDown / kExpDenominator; - if (exposure - next < 1) - exposure -= 1; - else - exposure = next; + int32_t next = static_cast(exposure * factor); + exposure = std::min(next, exposure - 1); } } @@ -96,6 +120,7 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou LOG(IPASoftExposure, Debug) << "exposureMSV " << exposureMSV + << " error " << error << " factor " << factor << " exp " << exposure << " again " << again; } From patchwork Wed May 6 21:46:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 26649 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 4B35FC32F7 for ; Wed, 6 May 2026 22:19:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EEA1063021; Thu, 7 May 2026 00:19:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=jetm.me header.i=@jetm.me header.b="sCnzFFRr"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="DswLGRyn"; dkim-atps=neutral Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C88C66301A for ; Thu, 7 May 2026 00:19:44 +0200 (CEST) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 239EB1400104; Wed, 6 May 2026 18:19:44 -0400 (EDT) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-02.internal (MEProxy); Wed, 06 May 2026 18:19:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetm.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1778105984; x=1778192384; bh=5MB+QUJnQv7BuMZdc1sbTeJZxf3mGgcxn80Hy32zQLE=; b= sCnzFFRriEz+CHuS+K/Mh9dlP2X6xTDsORoVa4iu1oau7agLZ9wzP0OARV9lri+o JEWK0LP5payZCNUQTZlHoNpeSlK7XZTjb2yTD1Kx+X2AGrrnREKx0VzhWXQr0LJ6 38JDzpGT2sSMkKDThINdxATKPOByUhDmcZUc5vGsxnDRgdKa23KbMRBUTGGl94mA k89z9pTG0pRl+HL/wbIBy6b+fxNDClMeLWWeif7Ua1trsFVsE/S5ZVXMPLmSWxUq 2/cqCms2dWFAJHTfzSjSrpK7UC4APAhr9iyvx7t0V0weI4Cf1EMZ4DOijfzlgkSE e/B8ME0TKH18Hxk+pZOZ+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1778105984; x= 1778192384; bh=5MB+QUJnQv7BuMZdc1sbTeJZxf3mGgcxn80Hy32zQLE=; b=D swLGRynmyG8uiiiH2WGrbXgXjUhUs6Ho4TgbmCOVZH0TLXqQ3omqpzFgNDTKxXlb JINmiLDzzfbQhOTQun2KrgV+kNbfWR0+nGMIf3Zo0Qz2iuaXY0w0etPTqBNGdhB3 +hkr+DlaYxWhcDVoHIdXGb1e0jHl5mFz8kNjxrERzCFSJ6RxvminYe8yIeGAjG6G fyNSJ3bOhwyM0JwFgBqTKpCUiJcmzBIfesvDLkBsESvnEHyA7KFAKnKEkWXGCJd6 sgl1x+xgIvpmdDGUAVy2nj6pI1hFB0qIVIMq4Fgm7ZEaydK9FDcI3NCXFDaX6FhU pD9dx/89A7EWC2MW0gV0w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddutdehjeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgopfhokfffucdluddtmdenucfjughrpefotggggffhvf ffufevjghfsehtkedttdertdejnecuhfhrohhmpeflrghvihgvrhcuvfhirgcuoehflhho shhssehjvghtmhdrmhgvqeenucggtffrrghtthgvrhhnpedtudejffejkeekteelueefvd ejvdeuhfefteehkeevtddvleduteekleetvdelhfenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehflhhoshhssehjvghtmhdrmhgvpdhnsggprh gtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsrghrnhgrsggr shdrphhotgiivgesihguvggrshhonhgsohgrrhgurdgtohhmpdhrtghpthhtohepkhhivg hrrghnrdgsihhnghhhrghmsehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthho pehlihgstggrmhgvrhgrqdguvghvvghlsehlihhsthhsrdhlihgstggrmhgvrhgrrdhorh hgpdhrtghpthhtohepmhiirghmrgiirghlsehrvgguhhgrthdrtghomh X-ME-Proxy: Feedback-ID: i9dde48b3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 066FD1EA006B; Wed, 6 May 2026 18:19:44 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 From: Javier Tia To: libcamera-devel@lists.libcamera.org Date: Wed, 06 May 2026 15:46:28 -0600 Subject: [PATCH v5 2/3] libcamera: software_isp: Normalize statistics sums to 8-bit Cc: mzamazal@redhat.com, barnabas.pocze@ideasonboard.com, kieran.bingham@ideasonboard.com In-Reply-To: <177810597783.688418.1631246733707368646@jetm.me> References: <177810597783.688418.1631246733707368646@jetm.me> Message-Id: <20260506221944.066FD1EA006B@mailuser.phl.internal> 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 SWSTATS_ACCUMULATE_LINE_STATS() macro divides the luminance value for the histogram to normalize it to 8-bit range, but does not apply the same normalization to the RGB sums. For 10-bit and 12-bit unpacked Bayer formats this means the sums are accumulated at native bit depth (0-1023 or 0-4095 per pixel) while the AWB algorithm subtracts an 8-bit black level from them, under-correcting by 4x or 16x respectively. This mismatch between the AWB's gain calculation (using incorrectly BLC-subtracted sums) and the debayer's correct normalized BLC subtraction produces a visible color cast. For example, with the OV2740 sensor (10-bit, BLC=16), the under-subtraction skews R/G gain by ~9%. Fix this by right-shifting the RGB sums in finishFrame() to normalize them to 8-bit scale, matching the histogram and the 8-bit black level used by AWB. A per-format sumShift_ value is set in configure(): 0 for 8-bit and CSI-2 packed formats (already 8-bit), 2 for 10-bit, and 4 for 12-bit unpacked formats. Signed-off-by: Javier Tia Reviewed-by: Milan Zamazal Tested-by: Milan Zamazal Reviewed-by: Barnabás Pőcze Tested-by: Barnabás Pőcze --- include/libcamera/internal/software_isp/swstats_cpu.h | 1 + src/libcamera/software_isp/swstats_cpu.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h index 802370bd..2dac6945 100644 --- a/include/libcamera/internal/software_isp/swstats_cpu.h +++ b/include/libcamera/internal/software_isp/swstats_cpu.h @@ -116,6 +116,7 @@ private: unsigned int xShift_; unsigned int stride_; + unsigned int sumShift_; std::vector stats_; SharedMemObject sharedStats_; diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 5366e019..b40d3334 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -362,6 +362,11 @@ void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId) for (unsigned int j = 0; j < SwIspStats::kYHistogramSize; j++) sharedStats_->yHistogram[j] += s.yHistogram[j]; } + if (sumShift_) { + sharedStats_->sum_.r() >>= sumShift_; + sharedStats_->sum_.g() >>= sumShift_; + sharedStats_->sum_.b() >>= sumShift_; + } } sharedStats_->valid = valid; @@ -425,12 +430,15 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg, unsigned int stat switch (bayerFormat.bitDepth) { case 8: stats0_ = &SwStatsCpu::statsBGGR8Line0; + sumShift_ = 0; return 0; case 10: stats0_ = &SwStatsCpu::statsBGGR10Line0; + sumShift_ = 2; return 0; case 12: stats0_ = &SwStatsCpu::statsBGGR12Line0; + sumShift_ = 4; return 0; } } @@ -442,6 +450,7 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg, unsigned int stat /* Skip every 3th and 4th line, sample every other 2x2 block */ ySkipMask_ = 0x02; xShift_ = 0; + sumShift_ = 0; processFrame_ = &SwStatsCpu::processBayerFrame2; switch (bayerFormat.order) { From patchwork Wed May 6 21:46:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 26650 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 72E1EC32F8 for ; Wed, 6 May 2026 22:19:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E61026302A; Thu, 7 May 2026 00:19:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=jetm.me header.i=@jetm.me header.b="Ad72/8UJ"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="q+cW6hwV"; dkim-atps=neutral Received: from fout-a5-smtp.messagingengine.com (fout-a5-smtp.messagingengine.com [103.168.172.148]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 172F563022 for ; Thu, 7 May 2026 00:19:47 +0200 (CEST) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id CED21EC00BF; Wed, 6 May 2026 18:19:45 -0400 (EDT) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-02.internal (MEProxy); Wed, 06 May 2026 18:19:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetm.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1778105985; x=1778192385; bh=tprWUqY3r3XJz5Ghie815JLR38HBm1QesliNd+yOXh4=; b= Ad72/8UJdLeQkIt3PoMtHB+1EIpGyr/Z5MPoVffABpvavsBgNajkLbsIcp7v7Hrz YK9KrpyidrImDG5T8kDCKjcyaXeBXiMkCFT3gNm1ijoPRYkfiO21OXkvHAKDdiEr njY//gj03J70bwUyLd193rQeLxwaakNw6RqbhJXTJ2nbYAsvkvishbg+UmwqOvfe 8m4PEhFTu49iJUolQsSZc2wqaowAWXY5KQ6GPcGsBT6GdfNhz806wNwtJ9skZc1Y R5iqfPXJn4YbQMWM5+F1OuiNDfpypia+dtVGWbeZlxSUX4x1Nr+Po72Fp2pkh8iy YedU+wd1Ma+Owimu3wUkmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1778105985; x= 1778192385; bh=tprWUqY3r3XJz5Ghie815JLR38HBm1QesliNd+yOXh4=; b=q +cW6hwVDe4dbf8wCnrD/ZO/YY+24qcp4rnykqkTYXjVY2lLxN1Xnn9WI9IkU0TL0 khvT50rtNmskG4PEMSRz+e87vAAzmA/LCV5W7CZcw/9Ta+sgtV+8Anv+ebBRRlL7 WsnTpooH9UtT3uJbL+YGVuSjwu5F+znPA8NJaU6W5TW17EKceZb8rCDPhlOKJwxV kmcjt1gsP/p1bjyw3g/R81rvSDwN/y4gVH7vzva7wMz+UgrshcVU2ZpQh6Hxk9qg khgXbbcJcsXUDWR290+1GEwi7FX3fc9Net4QOLTrGfR+i8c7V3d/5BBx8DuNSnF1 z4AUGf5B0XFZgnYKxl/vQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddutdehjeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgopfhokfffucdluddtmdenucfjughrpefotggggffhvf ffufevjghfsehtkedttdertdejnecuhfhrohhmpeflrghvihgvrhcuvfhirgcuoehflhho shhssehjvghtmhdrmhgvqeenucggtffrrghtthgvrhhnpedtudejffejkeekteelueefvd ejvdeuhfefteehkeevtddvleduteekleetvdelhfenucevlhhushhtvghrufhiiigvpedv necurfgrrhgrmhepmhgrihhlfhhrohhmpehflhhoshhssehjvghtmhdrmhgvpdhnsggprh gtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehrohgsvghrthdr mhgruggvrhestgholhhlrggsohhrrgdrtghomhdprhgtphhtthhopehkihgvrhgrnhdrsg hinhhghhgrmhesihguvggrshhonhgsohgrrhgurdgtohhmpdhrtghpthhtoheplhhisggt rghmvghrrgdquggvvhgvlheslhhishhtshdrlhhisggtrghmvghrrgdrohhrghdprhgtph htthhopehmiigrmhgriigrlhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: i9dde48b3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id ACDC41EA006B; Wed, 6 May 2026 18:19:45 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 From: Javier Tia To: libcamera-devel@lists.libcamera.org Date: Wed, 06 May 2026 15:46:42 -0600 Subject: [PATCH v5 3/3] ipa: libipa: camera_sensor_helper: Add OV2740 black level Cc: mzamazal@redhat.com, kieran.bingham@ideasonboard.com, robert.mader@collabora.com In-Reply-To: <177810597783.688418.1631246733707368646@jetm.me> References: <177810597783.688418.1631246733707368646@jetm.me> Message-Id: <20260506221945.ACDC41EA006B@mailuser.phl.internal> 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" Set blackLevel_ = 4096 (0x40 at 10-bit) in CameraSensorHelperOv2740. The OV2740 kernel driver programs BLC target register 0x4003 with 0x40 for the 180 MHz link frequency mode. This matches the same pattern used by OV5675 and other OmniVision sensors with a 10-bit black level of 64. Without this, the Simple pipeline falls back to auto-guessing the black level, which happens to arrive at the same value but isn't documented. More importantly, the CameraSensorHelper is the canonical location for sensor calibration data and is used across all pipeline handlers, not just Simple. Suggested-by: Robert Mader Signed-off-by: Javier Tia Reviewed-by: Milan Zamazal Reviewed-by: Kieran Bingham --- src/ipa/libipa/camera_sensor_helper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index e3e3e535..3028197e 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -672,6 +672,8 @@ class CameraSensorHelperOv2740 : public CameraSensorHelper public: CameraSensorHelperOv2740() { + /* From Linux kernel driver: 0x40 at 10bits. */ + blackLevel_ = 4096; gain_ = AnalogueGainLinear{ 1, 0, 0, 128 }; } };