From patchwork Fri Oct 17 10:05:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 24700 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 1BCA1C32CE for ; Fri, 17 Oct 2025 10:27:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 134E9606CC; Fri, 17 Oct 2025 12:27:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="mzQs1u8L"; dkim-atps=neutral Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 44763606BF for ; Fri, 17 Oct 2025 12:27:11 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-47112edf9f7so9879155e9.0 for ; Fri, 17 Oct 2025 03:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1760696830; x=1761301630; 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=zFHEnXvv4SPgv/9pwKCAUWV8dxbTetTQUiCP8syXNJc=; b=mzQs1u8LfoiHRsu1TJL++S/4h21hw7stSdFrugnoPN/nyqUxiL73uNa2YYXrunNC+R Rc+tbLghf3Ck1M8s3xd/CXs6PsiOcV5f71a519DWty9UCLpoOVjDz2SpecvAiAeF/c2z SL/QYg0HSWLBVloeRW+TbIhHk1lRlimDB3qDttldrrjFX28o4en6gsUCwM6/ZxWcicD0 ycimiq/kT5D2SZYETQ/OOVGDq+OTq/6sXdK1EKDaPD29r0m6WdWtBC8d8iS5w3uWZ498 W6PIPxVJCj5tAwzmA7B3ICnu+2u2P5x1RPJrvgRZeCU0f81atZr+0Py5SA34ogxu+LuT wMRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760696830; x=1761301630; 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=zFHEnXvv4SPgv/9pwKCAUWV8dxbTetTQUiCP8syXNJc=; b=Oq21fbPOYnY6zm/X0j4Vy0oASUKbx0G05hO13vDHqp46y8aKvIhO6zorW/VNjcdwWj 3pfT3Q59RqG9LSBWb/biB1n0EuZUSFP91rMNXJkWA7jwPU5lxnv7VtllYDwLS6N9Lgn6 oJPloO+ZuRfgoFMl8Zr0L9YtHSqN6qSLY4cnIgxPj3yOkFxXoypyNBLOaRY5Wa9L/8/y K2R8MEYcHSz/xHXSL6MBsXyJ87f7fs856PV3numSY/+RwS6SrXEIwFB9IIWicI6wL863 Dcu8Dxy8g8JZgZDq2lFStnFLob5tyE/xCL3lBjUxVM5NKVVn36WusNrlTzNTPJI9hHtn BGuw== X-Gm-Message-State: AOJu0YzhOskNAzVTp5UkKyzV7VcewpdGY9tdBqQM1LiXDeBop736iTu2 Zie2+yOpGrv0xcxsi0L9cVW7C+JiBhWbDNLtPQUA4wg95YBbaKRsCxEno0VoJS/uiuDQl5YRYST xB2r5ZBc= X-Gm-Gg: ASbGncsseYRY1aiKwDa+uFHZdxEemJ8/ZoYdUleogsXDxvviVHwzPtV2472foV4l1gH iUOc3lHEre7yMLXPXNqIEO7Ogncgg4Rfl2Q2z50ReCN2LeGQwyKE/aEkDbkzMwN86BhPEvTf4k8 umdiggFtkNxu8T/zOeyFmuTihP1B6QGF9KZddGMhk4epN5fbYJ65ENrkZ55ZQOw1ZMGk268g00v gopObaiyxRpuMOTLbBSeLxgWZKq6eWJE82D67TSTraW035w33XDajOX0k76tJfxGPpMxlXnkA9/ D/QYqTLeaISY9GB342EKgj78cV/BfX1iKE+irJ2WjOoVu50F5juv9fsZhsrvp/mL0ZbgiQmi9x/ rHUbbaXbEmkiOfn7wAsQjnu60B9m35EjC0ppPuVYyY6PxQIyo/xYCj3PBPZ7osnDQfd98D/KsLC Qboi4yAwXlTKm9PuYL1VK8ynOPd5Pj5Pcsd+H+k473JsXhucCvdihbKCjJaQNo5dp4GFz/tdC4H aU3KTwpJ0DjMKa0StrZJ5JhELIvgqvlP3un X-Google-Smtp-Source: AGHT+IEelgMGpovmxCuGbCTupR1pQCmaKO4nG1sHaa779TmgnMA1Lc/2ZWmOA53lOIJ1ENsGacVxIw== X-Received: by 2002:a05:600c:5026:b0:46e:477a:f3dd with SMTP id 5b1f17b1804b1-4711792a680mr25593295e9.36.1760696830319; Fri, 17 Oct 2025 03:27:10 -0700 (PDT) Received: from localhost.localdomain ([2a06:61c0:f337:0:8aba:2a85:b765:a23e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47114428dedsm73811905e9.7.2025.10.17.03.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Oct 2025 03:27:09 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH 3/5] ipa: rpi: pisp: Use a floating region to get whole image Y statistics Date: Fri, 17 Oct 2025 11:05:39 +0100 Message-ID: <20251017102704.3887-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251017102704.3887-1-david.plowman@raspberrypi.com> References: <20251017102704.3887-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" 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);