{"id":19714,"url":"https://patchwork.libcamera.org/api/1.1/patches/19714/?format=json","web_url":"https://patchwork.libcamera.org/patch/19714/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240313121223.138150-13-stefan.klug@ideasonboard.com>","date":"2024-03-13T12:12:23","name":"[v2,12/12] pipeline: rkisp1: Apply initial controls","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"dd74453d9f441e83e1f2408e56f88f0a795f3a39","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19714/mbox/","series":[{"id":4221,"url":"https://patchwork.libcamera.org/api/1.1/series/4221/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4221","date":"2024-03-13T12:12:11","name":"Preparation for per-frame-controls and initial tests","version":2,"mbox":"https://patchwork.libcamera.org/series/4221/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19714/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19714/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 43443BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Mar 2024 12:13:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7684E62D27;\n\tWed, 13 Mar 2024 13:13:06 +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 EC1A162C9F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Mar 2024 13:12:46 +0100 (CET)","from jasper.fritz.box (unknown\n\t[IPv6:2a00:6020:448c:6c00:9b07:31b5:38e1:e957])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 59942A8F;\n\tWed, 13 Mar 2024 13:12:24 +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=\"TG5jZ4u1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1710331944;\n\tbh=K9QJJqMlbyeIAybLkwePUedqoG2A+3ScRBC8rZ4JR0Y=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=TG5jZ4u1WYCeEoNbkTmK986lc90sqfBYTjmcAChNeuSmsziXaEdm91LfWZTwWFkPT\n\t+1OVkl3JXlTLpA5BpiMdRg+oxAoMdj+g3lzuZ8YhW/jmpsZCGOA3y4BTJdilGkTvgd\n\tC4PuloEbrvvctkWz++VG2MU1OEkgbBRoL29h+Qbw=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v2 12/12] pipeline: rkisp1: Apply initial controls","Date":"Wed, 13 Mar 2024 13:12:23 +0100","Message-Id":"<20240313121223.138150-13-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.40.1","In-Reply-To":"<20240313121223.138150-1-stefan.klug@ideasonboard.com>","References":"<20240313121223.138150-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","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>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Controls passed to Camera::start() are now correctly applied.\nThis is needed to pass the per-frame-controls test.\nThe code uses the return value of ipa->start() to return the initial\ncontrols and pass them to the sensor instead of the setSensorControls\nsignal because setSensorControls is asynchronous and\nwould reach the sensor too late.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n include/libcamera/ipa/rkisp1.mojom       |  7 ++++++-\n src/ipa/rkisp1/rkisp1.cpp                | 20 ++++++++++++++++----\n src/libcamera/pipeline/rkisp1/rkisp1.cpp |  9 +++++++--\n 3 files changed, 29 insertions(+), 7 deletions(-)","diff":"diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom\nindex 1009e970..828308c6 100644\n--- a/include/libcamera/ipa/rkisp1.mojom\n+++ b/include/libcamera/ipa/rkisp1.mojom\n@@ -13,13 +13,18 @@ struct IPAConfigInfo {\n \tlibcamera.ControlInfoMap sensorControls;\n };\n \n+struct StartResult {\n+\tlibcamera.ControlList controls;\n+\tint32 code;\n+};\n+\n interface IPARkISP1Interface {\n \tinit(libcamera.IPASettings settings,\n \t     uint32 hwRevision,\n \t     libcamera.IPACameraSensorInfo sensorInfo,\n \t     libcamera.ControlInfoMap sensorControls)\n \t\t=> (int32 ret, libcamera.ControlInfoMap ipaControls);\n-\tstart() => (int32 ret);\n+\tstart(libcamera.ControlList controls) => (StartResult result);\n \tstop();\n \n \tconfigure(IPAConfigInfo configInfo,\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 8780abc9..6cde23cb 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -53,7 +53,7 @@ public:\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n \t\t ControlInfoMap *ipaControls) override;\n-\tint start() override;\n+\tvoid start(const ControlList &controls, StartResult *result) override;\n \tvoid stop() override;\n \n \tint configure(const IPAConfigInfo &ipaConfig,\n@@ -86,6 +86,7 @@ private:\n \n \t/* Local parameter storage */\n \tstruct IPAContext context_;\n+\tbool initialControlsDone_;\n };\n \n namespace {\n@@ -199,11 +200,19 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n \treturn 0;\n }\n \n-int IPARkISP1::start()\n+void IPARkISP1::start(const ControlList &controls, StartResult *result)\n {\n-\tsetControls(0);\n+\tinitialControlsDone_ = false;\n+\t/*\n+\t * Todo: This is really shady. In order to apply the initial controls we already\n+\t * queue a request for frame 0 and return the results.\n+\t * We need to discuss the official recommendation to handle start controls\n+\t */\n+\tqueueRequest(0, controls);\n \n-\treturn 0;\n+\tresult->controls = getControls(0);\n+\tresult->code = 0;\n+\tinitialControlsDone_ = true;\n }\n \n void IPARkISP1::stop()\n@@ -322,6 +331,9 @@ void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)\n \t\talgo->queueRequest(context_, frame, frameContext, controls);\n \t}\n \n+\tif (!initialControlsDone_)\n+\t\treturn;\n+\n \t/* Fast path, if we are not regulating */\n \tif (!frameContext.agc.autoEnabled) {\n \t\tControlList ctrls = getControls(frame);\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 3e061b52..7c68073d 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -927,13 +927,18 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL\n \tif (ret)\n \t\treturn ret;\n \n-\tret = data->ipa_->start();\n-\tif (ret) {\n+\tControlList ctrls;\n+\tif (!!controls)\n+\t\tctrls = *controls;\n+\tipa::rkisp1::StartResult res;\n+\tdata->ipa_->start(ctrls, &res);\n+\tif (res.code) {\n \t\tfreeBuffers(camera);\n \t\tLOG(RkISP1, Error)\n \t\t\t<< \"Failed to start IPA \" << camera->id();\n \t\treturn ret;\n \t}\n+\tdata->delayedCtrls_->reset(&res.controls);\n \n \tdata->frame_ = 0;\n \n","prefixes":["v2","12/12"]}