From patchwork Thu Oct 23 11:49:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 24830 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by patchwork.libcamera.org (Postfix) with ESMTPS id AFFBCBE080 for ; Sun, 26 Oct 2025 23:32:02 +0000 (UTC) Received: from pendragon.ideasonboard.com (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 13F58AB4 for ; Mon, 27 Oct 2025 00:30:15 +0100 (CET) Authentication-Results: perceval.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.a=rsa-sha256 header.s=google header.b=E72KPq++; dkim-atps=neutral Delivered-To: kbingham@ideasonboard.com Received: from perceval.ideasonboard.com by perceval.ideasonboard.com with LMTP id OK0VGTUW+mgSUhcA4E0KoQ (envelope-from ) for ; Thu, 23 Oct 2025 13:49:09 +0200 Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by perceval.ideasonboard.com (Postfix) with ESMTPS id 1103E1AA6; Thu, 23 Oct 2025 13:49:03 +0200 (CEST) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0BE7C607DB; Thu, 23 Oct 2025 13:50:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="E72KPq++"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D87E4607D9 for ; Thu, 23 Oct 2025 13:50:42 +0200 (CEST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3ee64bc6b90so596154f8f.0 for ; Thu, 23 Oct 2025 04:50:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1761220242; x=1761825042; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i2AVjQETpTL9rS5lEaiFVmW3N5s72qqdEqXQEPC35yg=; b=E72KPq++0rE7gwL62Fts6J6UvQWan0C205Yt3/XfmWQy3YarPo6PEZ2bs37jY2NRJM I3ustot0UJbj9mY9IxZfkQokwPg/IQStJdJulHUrWpXmQn6bhT5CuFIsSINu9C/8Q+2q xtCQVwNSEqPalsxf5PD/01nL4l2y9zS0+/Hjd+yCosBTWSJFPcWYD4dWF1iD6gkHRafo AqelM7faN9nVxBGZ2Cy+3Buf2EiCmtAc40mqXRESpyQz8teimy39fRdYCaS2OhY6Ezsz smuPf4OQHnQGxyoS93yRMS2WFE1f2rhv5dFYNzkUnZpsDQ1yE7N79Qg2Gja0EGv7/86L 79Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761220242; x=1761825042; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i2AVjQETpTL9rS5lEaiFVmW3N5s72qqdEqXQEPC35yg=; b=R8m8PHElI1T1oersVMT+1D6UBF/2mi72Zmp6M2Mr32cnptQDywHlliincPvVZ/TES0 dgA3kKqI3cu7XAXVttOE1LdHLcXKUCDqGz3XH4kVTS7bEbsbDi1jMoVOSgnm8dKk4Oyt sDRhimeO2zabR+y9Dj3BYbJNzMNhdD0wcXxDl2PdJlWirO+dRC39tzzFya3TvIDhYZtk mfx+RnhpWk5e/qpiTkPfWPd4T/GgEnjqV6GxGvhYNcjxWKBjkxpTAE2e/3NDLTcJir7i zJ9x7Cad2JPE0BDU/V7/tYquOjOp5RE8peO3F/Wux6emiF7Ksn2tO3t2MsiauaI2WKAk iplA== X-Gm-Message-State: AOJu0YwN10DPqzFEzjq/CY7jJjFR3XccV7iQw+Qn6C1vqYvsEgwQMjQs hrR9+FQrZQwWY7hYMyNccKZHPc0gVEzx0F1Io55ncvqgEr8khCeTOKYQMjRLh1PTGubA4tBsXnW 1DvumziA= X-Gm-Gg: ASbGncu3B/xZx+3yERLuiirYcXD064jmkWADFDqsNTMArasVkJuMeGMgN1EHT+ATy4F fhDUhHUamfWOjevjYWEbNe8+bkHmPhkQnevNzWl0MNWm1ZDwxeodrXHoa+feFgtfrHAKBkVcPk8 ud4761jYRF/YQpqA9frDhTYQb1ogLHoT/aZiMjcv3ZY16eS6ub6BFsTr8VDfRrKrUpo7CwsqUtn P7KH8WLGGPve8WLtzUCWFFREx9fCRcaDRWXkQ5U8tmqG/1WdRx9u8qA5X+Zfh6h1aCLi7pWZONq xhS48VBmKMPESY8wvqV+5jEPZA5smqRATIxLiD1iw2zH4fDWsFiPVW9gb9dNNG4fr0FzZfphaT0 vJRR/y/0FPwmaCjV2WTxrHVEXVHKKDlvGO7qqinnqD7LxSXGONgp0PYzIsFXhTQ68d0IbH3x/Az iNfKlQzvsWple9paVruPAMoqhmB6x56dkAMWS71XLMsh5mLcO9c3zUVAsh+EeWuwGsR1Z9Xgu+I /R6lKtyVc58Z3Zp7FP8MDNLYaif X-Google-Smtp-Source: =?utf-8?q?AGHT+IGpfspp7BvS4ewcfI448Jgmchg2yWKZoSNOF?= =?utf-8?q?ZLBZ/Ohdlp7blPSVldPxLaUns4HMK2VbuB+xg=3D=3D?= X-Received: by 2002:a05:6000:420e:b0:3ec:db8b:cbf1 with SMTP id ffacd0b85a97d-42704d900a9mr16829375f8f.24.1761220241989; Thu, 23 Oct 2025 04:50:41 -0700 (PDT) Received: from davidp-pi.pitowers.org ([2a00:1098:3142:1f:f75f:a9a5:3eb7:34d4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4298b996aaasm1900760f8f.3.2025.10.23.04.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 04:50:41 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Stefan Klug , Naushir Patuck Subject: [PATCH v2 3/5] ipa: rpi: pisp: Use a floating region to get whole image Y statistics Date: Thu, 23 Oct 2025 12:49:15 +0100 Message-ID: <20251023115034.2207-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251023115034.2207-1-david.plowman@raspberrypi.com> References: <20251023115034.2207-1-david.plowman@raspberrypi.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" X-TUID: t1/H0G7Fme3r Resent-From: Kieran Bingham Resent-To: parsemail@patchwork.libcamera.org Floating regions are currently unused on the PiSP platform, so we can use one of them to get an average Y value for the whole image. If an algorithm (such as the "lux" algorithm) wants a scene-referred estimate of absolute brightness, then this would be a better choice than a value from Y histogram as the latter is not invariant to the metering mode (e.g. centre-weighted, spot etc.). (So note that for the AGC/AEC algorithm, where the metering mode is relevant, the Y histogram is the appropriate choice.) We also fix the loop that copies the hardware's floating region values into our statistics structure; it was using the wrong limit which was causing it not to do anything. A future commit will update the lux algorithm to use this feature. Signed-off-by: David Plowman Reviewed-by: Stefan Klug Reviewed-by: Naushir Patuck --- src/ipa/rpi/pisp/pisp.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp index bb50a9e0..2ba879c1 100644 --- a/src/ipa/rpi/pisp/pisp.cpp +++ b/src/ipa/rpi/pisp/pisp.cpp @@ -467,7 +467,7 @@ RPiController::StatisticsPtr IpaPiSP::platformProcessStats(Span mem) /* AGC region sums only get collected on floating zones. */ statistics->agcRegions.init({ 0, 0 }, PISP_FLOATING_STATS_NUM_ZONES); - for (i = 0; i < statistics->agcRegions.numRegions(); i++) + for (i = 0; i < PISP_FLOATING_STATS_NUM_ZONES; i++) statistics->agcRegions.setFloating(i, { { 0, 0, 0, stats->agc.floating[i].Y_sum }, stats->agc.floating[i].counted, 0 }); @@ -985,6 +985,12 @@ void IpaPiSP::setStatsAndDebin() */ setHistogramWeights(); + /* Configure the first AGC floating region to cover the whole image, for the lux algo. */ + pisp_fe_floating_stats_config floatingStatsConfig = {}; + floatingStatsConfig.regions[0].size_x = mode_.width; + floatingStatsConfig.regions[0].size_y = mode_.height; + fe_->SetFloatingStats(floatingStatsConfig); + pisp_be_global_config beGlobal; be_->GetGlobal(beGlobal);