Patch Detail
Show a patch.
GET /api/1.1/patches/24250/?format=api
{ "id": 24250, "url": "https://patchwork.libcamera.org/api/1.1/patches/24250/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24250/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20250827222032.644435-1-niklas.soderlund+renesas@ragnatech.se>", "date": "2025-08-27T22:20:32", "name": "ipa: rkisp1: agc: awb: Apply digital gain using ISP", "commit_ref": null, "pull_url": null, "state": "rejected", "archived": false, "hash": "a313f5e4260bf983ed229c55b3285447b72ae3e3", "submitter": { "id": 230, "url": "https://patchwork.libcamera.org/api/1.1/people/230/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund+renesas@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24250/mbox/", "series": [ { "id": 5408, "url": "https://patchwork.libcamera.org/api/1.1/series/5408/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5408", "date": "2025-08-27T22:20:32", "name": "ipa: rkisp1: agc: awb: Apply digital gain using ISP", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5408/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24250/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24250/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 557C3BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Aug 2025 22:20:43 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EC6B5692EF;\n\tThu, 28 Aug 2025 00:20:41 +0200 (CEST)", "from fout-b5-smtp.messagingengine.com\n\t(fout-b5-smtp.messagingengine.com [202.12.124.148])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 557D8613B9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Aug 2025 00:20:39 +0200 (CEST)", "from phl-compute-06.internal (phl-compute-06.internal\n\t[10.202.2.46])\n\tby mailfout.stl.internal (Postfix) with ESMTP id C26901D00166;\n\tWed, 27 Aug 2025 18:20:37 -0400 (EDT)", "from phl-mailfrontend-01 ([10.202.2.162])\n\tby phl-compute-06.internal (MEProxy); Wed, 27 Aug 2025 18:20:37 -0400", "by mail.messagingengine.com (Postfix) with ESMTPA; Wed,\n\t27 Aug 2025 18:20:36 -0400 (EDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=ragnatech.se header.i=@ragnatech.se\n\theader.b=\"OmGIQv90\"; dkim=pass (2048-bit key;\n\tunprotected) header.d=messagingengine.com\n\theader.i=@messagingengine.com header.b=\"PywQtpUS\"; \n\tdkim-atps=neutral", "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h=\n\tcc:cc:content-transfer-encoding:content-type:content-type:date\n\t:date:from:from:in-reply-to:message-id:mime-version:reply-to\n\t:subject:subject:to:to; s=fm3; t=1756333237; x=1756419637; bh=Qp\n\tCtEUCsbeO46fOEL+qdBFUxhJ9l7FPU+UyZNWODveE=; b=OmGIQv90MDKjNlYBDr\n\tGaEOBK0F+hWgLxupL3KULeu6iu/SgrpT8VJmtSqHLjKk+FIutMKTiAo8+/k8yKY3\n\tKDw2Jox6lj/9x5p3xTkGfcPw3gFnAN2zhZPcGkvZT0a6cDlpXuTzD09hmgUXbi+7\n\tkuBx81zh54DwSj4F7RsVfC2R587jzceTZxIlhDQb7G7Wc+IjVo069GJbRp2yA1Rw\n\tStp188pmhkrxikCNsZ8Ti7bxnlkvUDLMJqTlqm4TYcR2SCtqPVEuGte+6hTSm4+5\n\t+pxuC2Bn/Hsw4dj6D9zQDByTUU/mfdFc/joteN8/gnHdX8JMx7PZZLpcTCHZs1nE\n\tjTcw==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n\tmessagingengine.com; h=cc:cc:content-transfer-encoding\n\t:content-type:content-type:date:date:feedback-id:feedback-id\n\t:from:from:in-reply-to:message-id:mime-version:reply-to:subject\n\t:subject:to:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=\n\tfm1; t=1756333237; x=1756419637; bh=QpCtEUCsbeO46fOEL+qdBFUxhJ9l\n\t7FPU+UyZNWODveE=; b=PywQtpUSZygi4sUDxUX2Pi7bd14liTvqkM2+VtVDNtpq\n\tetb0lP3wQDAUWty2UiySJ7F+w44II05bg3qF18khKcNqjMWJ+oqjWU/OThL7QPzO\n\tBjoW0p1b9mXhnbtSDuDBkRtCcTEbDaaeCupHuXPhQZ4Nrz4wfQOg4LXF5+6CMEtN\n\tQr/H4s4xEOpcR4ch8WpDUd06uuNUC/ZL8o2LyjmTgwGwApdQkmfL6IXSanjuznrM\n\tWICz6n1vaKrOTp8c/pVlJy/sXVC4VVznk0pF5qmaM7Qrb9Xq3fk0NCeAGtrBAEUq\n\tOkBuQkeHEBQ4goDCKPiI+hO7GxjS4GAHnd472zQ9aQ==" ], "X-ME-Sender": "<xms:tYSvaNg828EWxeSxn6nt-JQov6Nzlu63M4kcUNRfTJizMau9i6T12A>\n\t<xme:tYSvaFQAoR5yyXomI9sEK1u_IjTZdNHLps1QctOpytHSY9njWVcaE-eaRJDjrpK3H\n\tc7-5y80L_XE82AYZVs>", "X-ME-Received": "<xmr:tYSvaGgfE787LBdz9VKlG8FbJTZ4U3tcvbLAckBqDlGaaGg9ZuZdPk0RXEjtzhaTcm_EGVx1IjtDQu7T_xVVFfaXcw>", "X-ME-Proxy-Cause": "gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddujeelfeefucetufdoteggodetrf\n\tdotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu\n\trghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf\n\tgurhephffvvefufffkofggtgfgsehtkeertdertdejnecuhfhrohhmpefpihhklhgrshcu\n\tufpnuggvrhhluhhnugcuoehnihhklhgrshdrshhouggvrhhluhhnugdorhgvnhgvshgrsh\n\tesrhgrghhnrghtvggthhdrshgvqeenucggtffrrghtthgvrhhnpeehudelteetkefgffef\n\tudefuedvjeeivdekhfevieefgeffheeltddvvefhfeetgeenucevlhhushhtvghrufhiii\n\tgvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehnihhklhgrshdrshhouggvrhhluhhn\n\tugesrhgrghhnrghtvggthhdrshgvpdhnsggprhgtphhtthhopeefpdhmohguvgepshhmth\n\thpohhuthdprhgtphhtthhopehprghulhdrvghluggvrhesihguvggrshhonhgsohgrrhgu\n\trdgtohhmpdhrtghpthhtoheplhhisggtrghmvghrrgdquggvvhgvlheslhhishhtshdrlh\n\thisggtrghmvghrrgdrohhrghdprhgtphhtthhopehnihhklhgrshdrshhouggvrhhluhhn\n\tugdorhgvnhgvshgrshesrhgrghhnrghtvggthhdrshgv", "X-ME-Proxy": "<xmx:tYSvaN5KnRcbENz8zGxvqf-eHowrsTXfBXJ0aeGGtkZtRtCBaGHj4g>\n\t<xmx:tYSvaLDVdfKyVUHleFom53Mw2FrRYvPZ_TN-dyGG6d_-lh5znJHX7A>\n\t<xmx:tYSvaMYlOyaFMMV0nFcesqq5nHIG3fvBhoL4_RvVlqn_mHGSRjnHlA>\n\t<xmx:tYSvaOa51VTKAVT55G-clBorDGwBzWeW3-ymK1Hh7HPY7lZXMIvxLg>\n\t<xmx:tYSvaEyEw2qSufF6ew11chG5Xqtj5XaFQIbkyz77JDgmS9t7X1zfmVDK>", "Feedback-ID": "i80c9496c:Fastmail", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?=\n\t<niklas.soderlund+renesas@ragnatech.se>", "To": "Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org", "Cc": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund+renesas@ragnatech.se>", "Subject": "[PATCH] ipa: rkisp1: agc: awb: Apply digital gain using ISP", "Date": "Thu, 28 Aug 2025 00:20:32 +0200", "Message-ID": "<20250827222032.644435-1-niklas.soderlund+renesas@ragnatech.se>", "X-Mailer": "git-send-email 2.51.0", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "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": "The digital gain is already calculated in the AGC algorithm but the\nvalue is not consumed by the AWB algorithm, which is where the gain\nstage is located. Add the needed plumbing to carry the value between the\ntwo algorithms.\n\nThis is needed to get good images from sensors such as the IMX219 where\nlarge sensor frames needs a small VBLANK value. This results in images\nthat are so under exposed that even the sensors analog gain can't\ncompensate. The digital gain stage of the ISP helps with this.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>\n---\n src/ipa/rkisp1/algorithms/agc.cpp | 12 ++++++++++--\n src/ipa/rkisp1/algorithms/awb.cpp | 4 +++-\n src/ipa/rkisp1/ipa_context.h | 3 +++\n 3 files changed, 16 insertions(+), 3 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 35440b67e999..17aaa259244b 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -174,9 +174,11 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n {\n \t/* Configure the default exposure and gain. */\n \tcontext.activeState.agc.automatic.gain = context.configuration.sensor.minAnalogueGain;\n+\tcontext.activeState.agc.automatic.ispGain = 1.0;\n \tcontext.activeState.agc.automatic.exposure =\n \t\t10ms / context.configuration.sensor.lineDuration;\n \tcontext.activeState.agc.manual.gain = context.activeState.agc.automatic.gain;\n+\tcontext.activeState.agc.manual.ispGain = 1.0;\n \tcontext.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure;\n \tcontext.activeState.agc.autoExposureEnabled = !context.configuration.raw;\n \tcontext.activeState.agc.autoGainEnabled = !context.configuration.raw;\n@@ -280,8 +282,10 @@ void Agc::queueRequest(IPAContext &context,\n \n \tif (!frameContext.agc.autoExposureEnabled)\n \t\tframeContext.agc.exposure = agc.manual.exposure;\n-\tif (!frameContext.agc.autoGainEnabled)\n+\tif (!frameContext.agc.autoGainEnabled) {\n \t\tframeContext.agc.gain = agc.manual.gain;\n+\t\tframeContext.agc.ispGain = agc.manual.ispGain;\n+\t}\n \n \tconst auto &meteringMode = controls.get(controls::AeMeteringMode);\n \tif (meteringMode) {\n@@ -336,12 +340,15 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,\n {\n \tuint32_t activeAutoExposure = context.activeState.agc.automatic.exposure;\n \tdouble activeAutoGain = context.activeState.agc.automatic.gain;\n+\tdouble activeAutoIspGain = context.activeState.agc.automatic.ispGain;\n \n \t/* Populate exposure and gain in auto mode */\n \tif (frameContext.agc.autoExposureEnabled)\n \t\tframeContext.agc.exposure = activeAutoExposure;\n-\tif (frameContext.agc.autoGainEnabled)\n+\tif (frameContext.agc.autoGainEnabled) {\n \t\tframeContext.agc.gain = activeAutoGain;\n+\t\tframeContext.agc.ispGain = activeAutoIspGain;\n+\t}\n \n \t/*\n \t * Populate manual exposure and gain from the active auto values when\n@@ -581,6 +588,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \t/* Update the estimated exposure and gain. */\n \tactiveState.agc.automatic.exposure = newExposureTime / lineDuration;\n \tactiveState.agc.automatic.gain = aGain;\n+\tactiveState.agc.automatic.ispGain = dGain;\n \n \t/*\n \t * Expand the target frame duration so that we do not run faster than\ndiff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex 399fb51be414..569cac4a3466 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -218,7 +218,9 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n \t */\n \tif (frameContext.awb.autoEnabled) {\n \t\tconst auto &awb = context.activeState.awb;\n-\t\tframeContext.awb.gains = awb.automatic.gains;\n+\t\tconst auto &agc = context.activeState.agc;\n+\n+\t\tframeContext.awb.gains = awb.automatic.gains * agc.automatic.ispGain;\n \t\tframeContext.awb.temperatureK = awb.automatic.temperatureK;\n \t}\n \ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex 7ccc7b501aff..7180b0b7dff2 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -73,10 +73,12 @@ struct IPAActiveState {\n \t\tstruct {\n \t\t\tuint32_t exposure;\n \t\t\tdouble gain;\n+\t\t\tdouble ispGain;\n \t\t} manual;\n \t\tstruct {\n \t\t\tuint32_t exposure;\n \t\t\tdouble gain;\n+\t\t\tdouble ispGain;\n \t\t} automatic;\n \n \t\tbool autoExposureEnabled;\n@@ -130,6 +132,7 @@ struct IPAFrameContext : public FrameContext {\n \tstruct {\n \t\tuint32_t exposure;\n \t\tdouble gain;\n+\t\tdouble ispGain;\n \t\tdouble exposureValue;\n \t\tuint32_t vblank;\n \t\tbool autoExposureEnabled;\n", "prefixes": [] }