Patch Detail
Show a patch.
GET /api/1.1/patches/24694/?format=api
{ "id": 24694, "url": "https://patchwork.libcamera.org/api/1.1/patches/24694/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24694/", "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": "<20251017-exposure-limits-v1-1-6288cd86e719@ideasonboard.com>", "date": "2025-10-17T09:00:05", "name": "[1/3] ipa: rkisp1: Update exposure limits on vblank change", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "fccc51bed63d48c3ced6727df32b0b2d8cae6c17", "submitter": { "id": 143, "url": "https://patchwork.libcamera.org/api/1.1/people/143/?format=api", "name": "Jacopo Mondi", "email": "jacopo.mondi@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24694/mbox/", "series": [ { "id": 5508, "url": "https://patchwork.libcamera.org/api/1.1/series/5508/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5508", "date": "2025-10-17T09:00:04", "name": "rkisp1: Update exposure limits on vblank change", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5508/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24694/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24694/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 EE99FBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Oct 2025 09:00:20 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E853F606AD;\n\tFri, 17 Oct 2025 11:00:17 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F4CB6069F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Oct 2025 11:00:16 +0200 (CEST)", "from [192.168.1.182] (93-46-82-201.ip106.fastwebnet.it\n\t[93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 90C161574;\n\tFri, 17 Oct 2025 10:58:35 +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=\"dPwWkDM5\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1760691515;\n\tbh=ivkONw8MteuR+PHl4uEkAsL1BGyqPJPYtaLN60opCDY=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=dPwWkDM59niwrMM6u1rg46GAkmkvZEnhjvc889blIsnIyjmWWKdDwz64Nxj1ONPVY\n\tNf4vymmuqBgpKBNAIkDfYw2FNaDSERFPfq4T8cTbHAzicxwHFNJC8x8mtaZo+4pZtV\n\tPk99zB/or/z4xi2Zf5wGf4aNz94liFYL3Sbt9DbI=", "From": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Date": "Fri, 17 Oct 2025 11:00:05 +0200", "Subject": "[PATCH 1/3] ipa: rkisp1: Update exposure limits on vblank change", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20251017-exposure-limits-v1-1-6288cd86e719@ideasonboard.com>", "References": "<20251017-exposure-limits-v1-0-6288cd86e719@ideasonboard.com>", "In-Reply-To": "<20251017-exposure-limits-v1-0-6288cd86e719@ideasonboard.com>", "To": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tlibcamera-devel@lists.libcamera.org", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "X-Mailer": "b4 0.14.2", "X-Developer-Signature": "v=1; a=openpgp-sha256; l=4625;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=ivkONw8MteuR+PHl4uEkAsL1BGyqPJPYtaLN60opCDY=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo8gWefIr52rmMDCzttbcJF4HrjIZPSbvc46TMw\n\t7gOiTgjmvyJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaPIFngAKCRByNAaPFqFW\n\tPCkxD/9yGtj8x8o3TFHCHJyw5E3u76p5X9wmpO4V3fOOWBTKKsdapn/Fhs+0bv7Jq2Lw4HvO3CQ\n\tZbKBuH9YjDLN6IeR9rT71xYQxFiM2exYmcLYT/uFCa/J90LE5BN9sKTm4/1J8fguYgb/+dFl+G0\n\tgnEiWjqgoiyzuaKHo28TQzmpmFm4b7zw+N4KpnUrblb2CgeIHDUvLSc6yQR3Jc6EZCrwuSyJfLA\n\tHUaXZk+c8SE78OrqySbHPPztcfqgJLmjxsLRdJBG70t14Y1TcHtQSa+05LSfcg6MOD7s3YsjYEs\n\tUwgaatPLVwHMBLHYWdXnv03lfNkJiUSm9YzgzPxDjc7tACdVop7nkpjdtLXuHiqd05EK7TownzJ\n\t4daJ+0PJ4Ig9YV7gx3i4Vi3K2u2Dmj/SnrhMIBxT6L1dGcWMDDrRbeSN62mEaejfUWG3iHiRa9Y\n\tvCCKQvnHPvSW9CwdfuHI4spKyZuLri/RkMFZddhSQ81Ro9Can4vO+q04k464g9a2I94B5S7dgdU\n\tmUe/dx5BMVxoOPqajaR80ac9eGBayOGdJ/68DnAtTcv36fJiLpEaRwRuyjNUyR4uQ48yf6jJIFR\n\tt2PI/4BA6q4rEmGTUR+cCEsb9JJ/KrtdileEYCMhjsSjk4Ts/lU9/ZOUt0+/u0untRPv0pz9Hjb\n\tCH45Yfvta/Al9aA==", "X-Developer-Key": "i=jacopo.mondi@ideasonboard.com; a=openpgp;\n\tfpr=72392EDC88144A65C701EA9BA5826A2587AD026B", "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 AGC algorithm implementation of the RkISP1 IPA is implemented\nderiving the generic AgcMeanLuminance class, which limits the\nachievable exposure time using a maxExposureTime parameter provided by\nthe IPA module.\n\nThe RkISP1 IPA fetches the maxExposureTime value from the IPAContext\nsensor.maxExposureTime value, which is initialized at IPA init()\nand configure() time, but never updated later on, effectively limiting\nthe achievable exposure time to the frame duration programmed at\nstartup time.\n\nWhenever the frame duration is changed, the maximum exposure time\nshould change accordingly, but in the current implementation this\ndoesn't happen.\n\nFix this by updating the sensor.maxExposureTime value when a new set of\ncontrols is sent to the pipeline handler. Store the current VBLANK value\nin the IPAContext by replacing 'defVBlank' which is never used and use\nit to detect changes in the blanking value. Whenever the blanking\nchanges, update the maximum exposure limit accordingly.\n\nAs reported in a comment in the code, even if the new sensor controls\nwill be programmed in the sensor with a delay of a few frames on the\npipeline handler side, the limits for the algorithms should be updated\nimmediately.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/rkisp1/ipa_context.h | 2 +-\n src/ipa/rkisp1/rkisp1.cpp | 31 ++++++++++++++++++++++++++++---\n 2 files changed, 29 insertions(+), 4 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex f85a130d9c23dba7987f388e395239e4b141d776..af66a749052bc82bbbe7fbb0c4626f2422700926 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -65,7 +65,7 @@ struct IPASessionConfiguration {\n \t\tdouble minAnalogueGain;\n \t\tdouble maxAnalogueGain;\n \n-\t\tint32_t defVBlank;\n+\t\tunsigned int vBlank;\n \t\tutils::Duration lineDuration;\n \t\tSize size;\n \t} sensor;\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex fa22bfc349043002345d275b11a60ac983e329d7..54bd1434e0f4e34834beb1f9e9c39b77590f8b34 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -250,7 +250,7 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,\n \n \tconst IPACameraSensorInfo &info = ipaConfig.sensorInfo;\n \tconst ControlInfo vBlank = sensorControls_.find(V4L2_CID_VBLANK)->second;\n-\tcontext_.configuration.sensor.defVBlank = vBlank.def().get<int32_t>();\n+\tcontext_.configuration.sensor.vBlank = vBlank.def().get<int32_t>();\n \tcontext_.configuration.sensor.size = info.outputSize;\n \tcontext_.configuration.sensor.lineDuration = info.minLineLength * 1.0s / info.pixelRate;\n \n@@ -261,8 +261,6 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,\n \t * When the AGC computes the new exposure values for a frame, it needs\n \t * to know the limits for exposure time and analogue gain. As it depends\n \t * on the sensor, update it with the controls.\n-\t *\n-\t * \\todo take VBLANK into account for maximum exposure time\n \t */\n \tcontext_.configuration.sensor.minExposureTime =\n \t\tminExposure * context_.configuration.sensor.lineDuration;\n@@ -457,6 +455,33 @@ void IPARkISP1::setControls(unsigned int frame)\n \tuint32_t gain = context_.camHelper->gainCode(frameContext.agc.gain);\n \tuint32_t vblank = frameContext.agc.vblank;\n \n+\t/*\n+\t * Update the exposure limits if vblank has changed. Even if the controls\n+\t * will actually be applied to the sensor with some frames of latency\n+\t * by DelayedControls, all the algorithms calculations from now on should\n+\t * use the new limits.\n+\t *\n+\t * \\todo Sensors usually have a margin that limits the max exposure to\n+\t * be shorter by the full frame length:\n+\t *\n+\t * (max_exposure_lines = height + vblank - margin)\n+\t *\n+\t * As the margin is a sensor-specific parameter either:\n+\t * - Ignore the margin and rely on the driver clamping the exposure\n+\t * value correctly\n+\t * - Defer to the sensor helpers by creating an exposure() function that\n+\t * subtract the margin from the frame length\n+\t *\n+\t * For the time being ignore the margins and rely on the driver doing\n+\t * the adjustment.\n+\t */\n+\tif (vblank != context_.configuration.sensor.vBlank) {\n+\t\tcontext_.configuration.sensor.vBlank = vblank;\n+\t\tcontext_.configuration.sensor.maxExposureTime =\n+\t\t\t(vblank + context_.configuration.sensor.size.height) *\n+\t\t\tcontext_.configuration.sensor.lineDuration;\n+\t}\n+\n \tLOG(IPARkISP1, Debug)\n \t\t<< \"Set controls for frame \" << frame << \": exposure \" << exposure\n \t\t<< \", gain \" << frameContext.agc.gain << \", vblank \" << vblank;\n", "prefixes": [ "1/3" ] }