Patch Detail
Show a patch.
GET /api/patches/27577/?format=api
{ "id": 27577, "url": "https://patchwork.libcamera.org/api/patches/27577/?format=api", "web_url": "https://patchwork.libcamera.org/patch/27577/", "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": "<20260803131435.153927-30-barnabas.pocze@ideasonboard.com>", "date": "2026-08-03T13:14:14", "name": "[RFC,v3,29/50] ipa: libipa: agc: Calculate vblank and frame duration sooner", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "77b29979d2e2426937b7d8167580369a9787dc2a", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/27577/mbox/", "series": [ { "id": 6103, "url": "https://patchwork.libcamera.org/api/series/6103/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6103", "date": "2026-08-03T13:13:45", "name": "ipa: libipa: agc rework", "version": 3, "mbox": "https://patchwork.libcamera.org/series/6103/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/27577/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/27577/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 E8D1FC333E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 3 Aug 2026 13:15:16 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1290D680F0;\n\tMon, 3 Aug 2026 15:15:09 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6562E68088\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Aug 2026 15:14:45 +0200 (CEST)", "from pb-laptop.local (185.221.141.208.nat.pool.zt.hu\n\t[185.221.141.208])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 83DAB5B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Aug 2026 15:13:36 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"H/FW7byO\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1785762816;\n\tbh=5FCt395jOPww3Y7Uvh/WXpl6qsA0bNNWtDqi6cVxeQg=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=H/FW7byOAvU25rvqCZ+Kn58VhzJteSD1dLxpVKP0EwC6vLLr8lKJQDSmz1gF/lFRZ\n\t4RHEuaxu15tYKuJEpUd76lcGUnStG/lCd60wGmb2YoTHCjhaE2fq6Tya/tvNmjNLq2\n\tS/iarPWPz0mWUSVZGSMy9ETv6hbwqXxcldQTqnrs=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH v3 29/50] ipa: libipa: agc: Calculate vblank and frame\n\tduration sooner", "Date": "Mon, 3 Aug 2026 15:14:14 +0200", "Message-ID": "<20260803131435.153927-30-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.55.0", "In-Reply-To": "<20260803131435.153927-1-barnabas.pocze@ideasonboard.com>", "References": "<20260803131435.153927-1-barnabas.pocze@ideasonboard.com>", "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": "Calculating the vblank and frame duration is problematic in `process()`\nbecause at the moment it is calculated for an already finished frame\nbased on the new suggested exposure time.\n\nInstead, move the calculation to `prepare()` where the frame's\nexposure and gain are finalized.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/ipa/libipa/agc.cpp | 29 ++++++++++++++---------------\n src/ipa/libipa/agc.h | 3 ++-\n 2 files changed, 16 insertions(+), 16 deletions(-)", "diff": "diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp\nindex f420dfdce4..69f731569e 100644\n--- a/src/ipa/libipa/agc.cpp\n+++ b/src/ipa/libipa/agc.cpp\n@@ -502,7 +502,7 @@ void AgcAlgorithm::queueRequest(const agc::Session &session, agc::ActiveState &s\n /**\n * \\brief Handle a \\a prepare operation\n */\n-void AgcAlgorithm::prepare(agc::ActiveState &state, agc::FrameContext &frameContext)\n+void AgcAlgorithm::prepare(const agc::Session &session, agc::ActiveState &state, agc::FrameContext &frameContext)\n {\n \tuint32_t activeAutoExposure = state.automatic.exposure;\n \tdouble activeAutoGain = state.automatic.gain;\n@@ -533,6 +533,19 @@ void AgcAlgorithm::prepare(agc::ActiveState &state, agc::FrameContext &frameCont\n \t}\n \n \tframeContext.yTarget = state.automatic.yTarget;\n+\n+\t/*\n+\t * Expand the target frame duration so that we do not run faster than\n+\t * the minimum frame duration when we have short exposures.\n+\t */\n+\tconst auto frameDuration = std::max<uint32_t>(\n+\t\tframeContext.minFrameDuration / session.lineDuration,\n+\t\tframeContext.exposure);\n+\tframeContext.vblank = frameDuration - session.sensor.outputSize.height;\n+\n+\t/* Update frame duration accounting for line length quantization. */\n+\tframeContext.frameDuration =\n+\t\t(session.sensor.outputSize.height + frameContext.vblank) * session.lineDuration;\n }\n \n /**\n@@ -543,7 +556,6 @@ void AgcAlgorithm::process(const agc::Session &session, agc::ActiveState &state,\n \t\t\t ControlList &metadata)\n {\n \tconst utils::Duration &lineDuration = session.lineDuration;\n-\tutils::Duration newExposureTime = {};\n \n \tif (params) {\n \t\tASSERT(session.autoAllowed);\n@@ -603,8 +615,6 @@ void AgcAlgorithm::process(const agc::Session &session, agc::ActiveState &state,\n \t\tstate.automatic.digitalGain = newEv.digitalGain;\n \t\tstate.automatic.yTarget = newEv.yTarget;\n \n-\t\tnewExposureTime = newEv.exposureTime;\n-\n \t\tLOG(Agc, Debug)\n \t\t\t<< \"exposure-time:\" << utils::Duration(state.automatic.exposure * lineDuration)\n \t\t\t<< \" analogue-gain:\" << state.automatic.gain\n@@ -612,17 +622,6 @@ void AgcAlgorithm::process(const agc::Session &session, agc::ActiveState &state,\n \t\t\t<< \" digital-gain:\" << state.automatic.digitalGain;\n \t}\n \n-\t/*\n-\t * Expand the target frame duration so that we do not run faster than\n-\t * the minimum frame duration when we have short exposures.\n-\t */\n-\tconst auto frameDuration = std::max(frameContext.minFrameDuration, newExposureTime);\n-\tframeContext.vblank = (frameDuration / lineDuration) - session.sensor.outputSize.height;\n-\n-\t/* Update frame duration accounting for line length quantization. */\n-\tframeContext.frameDuration =\n-\t\t(session.sensor.outputSize.height + frameContext.vblank) * lineDuration;\n-\n \tmetadata.set(controls::AnalogueGain, frameContext.gain);\n \tmetadata.set(controls::ExposureTime,\n \t\t utils::Duration(lineDuration * frameContext.exposure).get<std::micro>());\ndiff --git a/src/ipa/libipa/agc.h b/src/ipa/libipa/agc.h\nindex b0f811e93d..e96c6926b2 100644\n--- a/src/ipa/libipa/agc.h\n+++ b/src/ipa/libipa/agc.h\n@@ -126,7 +126,8 @@ public:\n \tvoid queueRequest(const agc::Session &session, agc::ActiveState &state,\n \t\t\t agc::FrameContext &frameContext, const ControlList &controls);\n \n-\tvoid prepare(agc::ActiveState &state, agc::FrameContext &frameContext);\n+\tvoid prepare(const agc::Session &session, agc::ActiveState &state,\n+\t\t agc::FrameContext &frameContext);\n \n \tstruct ProcessParams {\n \t\tconst AgcMeanLuminance::Traits &traits;\n", "prefixes": [ "RFC", "v3", "29/50" ] }