Patch Detail
Show a patch.
GET /api/patches/25082/?format=api
{ "id": 25082, "url": "https://patchwork.libcamera.org/api/patches/25082/?format=api", "web_url": "https://patchwork.libcamera.org/patch/25082/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20251119132221.2088013-3-stefan.klug@ideasonboard.com>", "date": "2025-11-19T13:22:11", "name": "[v3,2/4] ipa: rkisp1: lux: Properly handle frame context and active state", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "85730259b7d7a2f94821a8329959472f633cc93e", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/25082/mbox/", "series": [ { "id": 5595, "url": "https://patchwork.libcamera.org/api/series/5595/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5595", "date": "2025-11-19T13:22:09", "name": "libipa: agc: Fix constraints yTarget handling and add PWL support", "version": 3, "mbox": "https://patchwork.libcamera.org/series/5595/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/25082/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/25082/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E4EF3BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Nov 2025 13:22:33 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 949F260AA3;\n\tWed, 19 Nov 2025 14:22:33 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8089E606A0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Nov 2025 14:22:31 +0100 (CET)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:5419:7bb:83a3:3d7a])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id D284E195E; \n\tWed, 19 Nov 2025 14:20:26 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"CbKFEkx0\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763558426;\n\tbh=qGvT3BW9ZL4aP9kR1bgRb+4Ux+dAaMHhmM0jb17WS7w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=CbKFEkx0uQmc5O8rr04I9yBkopw8PTBLeYs1Kp94llrq3cZ6FxupBlh0Kr++etiW+\n\tXd6hFYf2e1vx3wJjXIxfZapfYiyqLxeyyCUPeoFDFjKmRsShJZW5LVXmKZQT30V6a9\n\tf4SObOQWNMaM0Z4b+am9/SmP6MBU7A82PrBrBvM0=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>", "Subject": "[PATCH v3 2/4] ipa: rkisp1: lux: Properly handle frame context and\n\tactive state", "Date": "Wed, 19 Nov 2025 14:22:11 +0100", "Message-ID": "<20251119132221.2088013-3-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.51.0", "In-Reply-To": "<20251119132221.2088013-1-stefan.klug@ideasonboard.com>", "References": "<20251119132221.2088013-1-stefan.klug@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "WIth the upcoming regulation rework the processing order in the IPA is\nupdated a bit so that process() updates the active state with new\nmeasurements and fills the metadata with the data from the corresponding\nframe context. In prepare() all parameters for one frame are tied\ntogether using the most up to date values from active state.\n\nChange the lux algorithm to support that order of events. Also prepare\nfor cases where stats can be null which can happen with the upcoming\nregulation rework.\n\nWhile at it fix a formatting issue reported by checkstyle and drop a\nunnecessary local variable.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\n---\n\nChanges in v3:\n- Added this patch in response to the comment from Kieran in\n https://patchwork.libcamera.org/patch/24982/#36740\n---\n src/ipa/rkisp1/algorithms/lux.cpp | 23 ++++++++++++++++++-----\n src/ipa/rkisp1/algorithms/lux.h | 3 +++\n src/ipa/rkisp1/ipa_context.h | 4 ++++\n 3 files changed, 25 insertions(+), 5 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/lux.cpp b/src/ipa/rkisp1/algorithms/lux.cpp\nindex e8da69810008..bc714b7a82c6 100644\n--- a/src/ipa/rkisp1/algorithms/lux.cpp\n+++ b/src/ipa/rkisp1/algorithms/lux.cpp\n@@ -46,6 +46,16 @@ int Lux::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData\n \treturn lux_.parseTuningData(tuningData);\n }\n \n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void Lux::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n+\t\t IPAFrameContext &frameContext,\n+\t\t [[maybe_unused]] RkISP1Params *params)\n+{\n+\tframeContext.lux.lux = context.activeState.lux.lux;\n+}\n+\n /**\n * \\copydoc libcamera::ipa::Algorithm::process\n */\n@@ -55,8 +65,13 @@ void Lux::process(IPAContext &context,\n \t\t const rkisp1_stat_buffer *stats,\n \t\t ControlList &metadata)\n {\n-\tutils::Duration exposureTime = context.configuration.sensor.lineDuration\n-\t\t\t\t * frameContext.sensor.exposure;\n+\tmetadata.set(controls::Lux, frameContext.lux.lux);\n+\n+\tif (!stats)\n+\t\treturn;\n+\n+\tutils::Duration exposureTime = context.configuration.sensor.lineDuration *\n+\t\t\t\t frameContext.sensor.exposure;\n \tdouble gain = frameContext.sensor.gain;\n \n \t/* \\todo Deduplicate the histogram calculation from AGC */\n@@ -64,9 +79,7 @@ void Lux::process(IPAContext &context,\n \tHistogram yHist({ params->hist.hist_bins, context.hw.numHistogramBins },\n \t\t\t[](uint32_t x) { return x >> 4; });\n \n-\tdouble lux = lux_.estimateLux(exposureTime, gain, 1.0, yHist);\n-\tframeContext.lux.lux = lux;\n-\tmetadata.set(controls::Lux, lux);\n+\tcontext.activeState.lux.lux = lux_.estimateLux(exposureTime, gain, 1.0, yHist);\n }\n \n REGISTER_IPA_ALGORITHM(Lux, \"Lux\")\ndiff --git a/src/ipa/rkisp1/algorithms/lux.h b/src/ipa/rkisp1/algorithms/lux.h\nindex 8dcadc284a84..e0239848e252 100644\n--- a/src/ipa/rkisp1/algorithms/lux.h\n+++ b/src/ipa/rkisp1/algorithms/lux.h\n@@ -23,6 +23,9 @@ public:\n \tLux();\n \n \tint init(IPAContext &context, const YamlObject &tuningData) override;\n+\tvoid prepare(IPAContext &context, const uint32_t frame,\n+\t\t IPAFrameContext &frameContext,\n+\t\t RkISP1Params *params) override;\n \tvoid process(IPAContext &context, const uint32_t frame,\n \t\t IPAFrameContext &frameContext,\n \t\t const rkisp1_stat_buffer *stats,\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex f85a130d9c23..b257cee55379 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -133,6 +133,10 @@ struct IPAActiveState {\n \t\tdouble gamma;\n \t} goc;\n \n+\tstruct {\n+\t\tdouble lux;\n+\t} lux;\n+\n \tstruct {\n \t\tcontrols::WdrModeEnum mode;\n \t\tAgcMeanLuminance::AgcConstraint constraint;\n", "prefixes": [ "v3", "2/4" ] }