[{"id":37847,"web_url":"https://patchwork.libcamera.org/comment/37847/","msgid":"<176907334223.3882822.7488192589291441137@neptunite.rasen.tech>","date":"2026-01-22T09:15:42","subject":"Re: [PATCH v1 11/35] ipa: rkisp1: Move setSensorControls signal to\n\tcomputeParams","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-10-24 17:50:35)\n> The setSensorControls event is emitted in the processStats() function.\n> On first sight this looks reasonable as in processStats() we got the\n> latest statistics and can therefore calculate the most up to date sensor\n> controls.\n> \n> In the light of per-frame-controls however it produces difficult to\n> solve timing issues:\n> \n> - The frame context in processStats() is the frame context of the frame\n>   that produced the stats, not for the frame that should be prepared and\n> sent to the sensor.\n> \n> - To synchronize digital gain applied in the ISP with the analog gain\n>   applied in the sensor the set of parameters prepared for sensor and\n> ISP must also be synchronized, which is not the case.\n> \n> To fix that, move the calculation and setting of sensor controls into\n> the computeParams(). This way the model is far more easy to understand.\n> \n> We loose a tiny option for optimizations in that (in theory) we could\n> delay the calculation of ISP parameters by another frame (assuming the\n> sensor has a typical 2-frame delay). But all discussions and tests\n> showed that keeping all parameters in sync is more important than that\n> possible optimization for one frame.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/ipa/rkisp1/rkisp1.cpp | 10 +++-------\n>  1 file changed, 3 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index d64c72ecaf4f..ab8583e389d3 100644\n> --- a/src/ipa/rkisp1/rkisp1.cpp\n> +++ b/src/ipa/rkisp1/rkisp1.cpp\n> @@ -349,6 +349,9 @@ void IPARkISP1::computeParams(const uint32_t frame, const uint32_t bufferId)\n>         for (auto const &algo : algorithms())\n>                 algo->prepare(context_, frame, frameContext, &params);\n>  \n> +       ControlList ctrls = getSensorControls(frameContext);\n> +       setSensorControls.emit(frame, ctrls);\n> +\n>         paramsComputed.emit(frame, params.size());\n>  }\n>  \n> @@ -380,13 +383,6 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId,\n>                 algo->process(context_, frame, frameContext, stats, metadata);\n>         }\n>  \n> -       /*\n> -        * \\todo: Here we should do a lookahead that takes the sensor delays\n> -        * into account.\n> -        */\n> -       ControlList ctrls = getSensorControls(frameContext);\n> -       setSensorControls.emit(frame, ctrls);\n> -\n>         context_.debugMetadata.moveEntries(metadata);\n>         metadataReady.emit(frame, metadata);\n>  }\n> -- \n> 2.48.1\n>","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 6A213BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Jan 2026 09:15:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0AE5361FCE;\n\tThu, 22 Jan 2026 10:15:50 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F23C261FBB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Jan 2026 10:15:47 +0100 (CET)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:8816:a947:ebed:2ec7])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 130022DD;\n\tThu, 22 Jan 2026 10:15:14 +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=\"lhpqzADy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769073315;\n\tbh=7gGblJ8sGvZ027mJbR7+5HGn3KHOpgPzOYDb2ziAyck=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=lhpqzADyFoXc4dMBlj2WIbVSytzXblqhb33t1vP0AsdkZ1ZCo2YE0aTY5Y2Oy8gJZ\n\tw8gUpGvPywi8H7GkM7ioHZk3sUrgHYUFV/2fuUSQJw9zj1IZ5UnCdmRZUyPfg15LvM\n\tFXWfujjjrG4IhCDfMLHjEd17dgkQo6Pz40TpdSio=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251024085130.995967-12-stefan.klug@ideasonboard.com>","References":"<20251024085130.995967-1-stefan.klug@ideasonboard.com>\n\t<20251024085130.995967-12-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v1 11/35] ipa: rkisp1: Move setSensorControls signal to\n\tcomputeParams","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 22 Jan 2026 18:15:42 +0900","Message-ID":"<176907334223.3882822.7488192589291441137@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}}]