[{"id":37846,"web_url":"https://patchwork.libcamera.org/comment/37846/","msgid":"<176907333394.3882822.12343099945883425946@neptunite.rasen.tech>","date":"2026-01-22T09:15:33","subject":"Re: [PATCH v1 09/35] ipa: rkisp1: Refactor setControls()","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:33)\n> IPARkISP1::setControls() is called when new sensor controls shall be\n> queued to the pipeline handler. It constructs a list of sensor controls\n> and then emits the setSensorControls signal.\n> \n> To be able to return initial sensor controls from the IPARkISP1::start()\n> function, similar functionality will be needed. Prepare for that by\n> changing the setControls() function to a getSensorControls() that is\n> passed a frame context and by moving the setSensorControls.emit() out of\n> the function.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nLooks good to me.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/ipa/libipa/fc_queue.cpp |  6 ++++++\n>  src/ipa/libipa/fc_queue.h   |  2 ++\n>  src/ipa/rkisp1/rkisp1.cpp   | 26 +++++++++++++-------------\n>  3 files changed, 21 insertions(+), 13 deletions(-)\n> \n> diff --git a/src/ipa/libipa/fc_queue.cpp b/src/ipa/libipa/fc_queue.cpp\n> index 39222c2ed204..7ba28ed21611 100644\n> --- a/src/ipa/libipa/fc_queue.cpp\n> +++ b/src/ipa/libipa/fc_queue.cpp\n> @@ -38,6 +38,12 @@ namespace ipa {\n>   * \\brief The frame number\n>   */\n>  \n> +/**\n> + * \\fn FrameContext::frame()\n> + * \\brief Get the frame of that frame context\n> + * \\return THe frame number\n> + */\n> +\n>  /**\n>   * \\class FCQueue\n>   * \\brief A support class for managing FrameContext instances in IPA modules\n> diff --git a/src/ipa/libipa/fc_queue.h b/src/ipa/libipa/fc_queue.h\n> index 1128e42f8ca6..812022c496ed 100644\n> --- a/src/ipa/libipa/fc_queue.h\n> +++ b/src/ipa/libipa/fc_queue.h\n> @@ -22,6 +22,8 @@ template<typename FrameContext>\n>  class FCQueue;\n>  \n>  struct FrameContext {\n> +       uint32_t frame() const { return frame_; }\n> +\n>  private:\n>         template<typename T> friend class FCQueue;\n>         uint32_t frame_;\n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index fa22bfc34904..d64c72ecaf4f 100644\n> --- a/src/ipa/rkisp1/rkisp1.cpp\n> +++ b/src/ipa/rkisp1/rkisp1.cpp\n> @@ -77,7 +77,7 @@ private:\n>         void updateControls(const IPACameraSensorInfo &sensorInfo,\n>                             const ControlInfoMap &sensorControls,\n>                             ControlInfoMap *ipaControls);\n> -       void setControls(unsigned int frame);\n> +       ControlList getSensorControls(const IPAFrameContext &context);\n>  \n>         std::map<unsigned int, FrameBuffer> buffers_;\n>         std::map<unsigned int, MappedFrameBuffer> mappedBuffers_;\n> @@ -380,7 +380,12 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId,\n>                 algo->process(context_, frame, frameContext, stats, metadata);\n>         }\n>  \n> -       setControls(frame);\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> @@ -445,28 +450,23 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo,\n>         *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls);\n>  }\n>  \n> -void IPARkISP1::setControls(unsigned int frame)\n> +ControlList IPARkISP1::getSensorControls(const IPAFrameContext &frameContext)\n>  {\n> -       /*\n> -        * \\todo The frame number is most likely wrong here, we need to take\n> -        * internal sensor delays and other timing parameters into account.\n> -        */\n> -\n> -       IPAFrameContext &frameContext = context_.frameContexts.get(frame);\n>         uint32_t exposure = frameContext.agc.exposure;\n>         uint32_t gain = context_.camHelper->gainCode(frameContext.agc.gain);\n>         uint32_t vblank = frameContext.agc.vblank;\n>  \n>         LOG(IPARkISP1, Debug)\n> -               << \"Set controls for frame \" << frame << \": exposure \" << exposure\n> -               << \", gain \" << frameContext.agc.gain << \", vblank \" << vblank;\n> +               << \"Set controls for frame \" << frameContext.frame()\n> +               << \": exposure \" << exposure\n> +               << \", gain \" << frameContext.agc.gain\n> +               << \", vblank \" << vblank;\n>  \n>         ControlList ctrls(sensorControls_);\n>         ctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure));\n>         ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast<int32_t>(gain));\n>         ctrls.set(V4L2_CID_VBLANK, static_cast<int32_t>(vblank));\n> -\n> -       setSensorControls.emit(frame, ctrls);\n> +       return ctrls;\n>  }\n>  \n>  } /* namespace ipa::rkisp1 */\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 A890DBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Jan 2026 09:15:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 61F3A61FC8;\n\tThu, 22 Jan 2026 10:15:42 +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 38C7161FBB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Jan 2026 10:15:41 +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 43B3E9CE;\n\tThu, 22 Jan 2026 10:15:07 +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=\"QwP/rNok\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769073307;\n\tbh=AVnwLcCtvhiWue6BqXzPjX9xAg3lFwHp3hNbqoUmJWI=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=QwP/rNokpj3fJaHXtwz0jnYfIomJtQtZhxHQVtd+TmXuTC6dTOjxlDnPSPK0xjGfC\n\tvYgsCNQj8uGpWV1W2DYNA72k8UFbvT0MkznZ24sbwjXoHM44ykTu/5fv650m5qryXk\n\tEwRqsSTfXwzyjQJvv0apvXq9eybI/k8liICyWPJA=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251024085130.995967-10-stefan.klug@ideasonboard.com>","References":"<20251024085130.995967-1-stefan.klug@ideasonboard.com>\n\t<20251024085130.995967-10-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v1 09/35] ipa: rkisp1: Refactor setControls()","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:33 +0900","Message-ID":"<176907333394.3882822.12343099945883425946@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>"}}]