[{"id":21273,"web_url":"https://patchwork.libcamera.org/comment/21273/","msgid":"<20211126085720.emnwgbq2sqrfl7ax@uno.localdomain>","date":"2021-11-26T08:57:20","subject":"Re: [libcamera-devel] [PATCH v8 3/3] libcamera: pipeline: ipu3:\n\tApply a requested test pattern mode","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Hiro\n\nOn Fri, Nov 26, 2021 at 02:08:10PM +0900, Hirokazu Honda wrote:\n> This introduces a way to set controls immediately for a capture\n> in ipu3 pipeline handler. It enables to apply a test pattern mode\n> per frame.\n>\n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nSorry, too soon\n\nAs commented on the previous version, Requests stored processingRequests_\nat the time stop() is called should be completed before the ones in\npendingRequests_\n\n\n> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 55 +++++++++++++++++++++++++++-\n>  1 file changed, 53 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 25490dcf..31f5f9dd 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -59,6 +59,7 @@ public:\n>  \tvoid statBufferReady(FrameBuffer *buffer);\n>  \tvoid queuePendingRequests();\n>  \tvoid cancelPendingRequests();\n> +\tvoid frameStart(uint32_t sequence);\n>\n>  \tCIO2Device cio2_;\n>  \tImgUDevice *imgu_;\n> @@ -76,7 +77,10 @@ public:\n>\n>  \tstd::unique_ptr<ipa::ipu3::IPAProxyIPU3> ipa_;\n>\n> +\t/* Requests before queueing cio2 device. */\n>  \tstd::queue<Request *> pendingRequests_;\n> +\t/* Requests queued in cio2 device and before passing imgu device. */\n> +\tstd::queue<Request *> processingRequests_;\n>\n>  \tControlInfoMap ipaControls_;\n>\n> @@ -823,6 +827,8 @@ void IPU3CameraData::cancelPendingRequests()\n>  \t\tpipe()->completeRequest(request);\n>  \t\tpendingRequests_.pop();\n>  \t}\n> +\n> +\tprocessingRequests_ = {};\n>  }\n>\n>  void IPU3CameraData::queuePendingRequests()\n> @@ -853,6 +859,8 @@ void IPU3CameraData::queuePendingRequests()\n>\n>  \t\tinfo->rawBuffer = rawBuffer;\n>\n> +\t\tprocessingRequests_.push(request);\n> +\n>  \t\tipa::ipu3::IPU3Event ev;\n>  \t\tev.op = ipa::ipu3::EventProcessControls;\n>  \t\tev.frame = info->id;\n> @@ -1121,8 +1129,8 @@ int PipelineHandlerIPU3::registerCameras()\n>  \t\tdata->delayedCtrls_ =\n>  \t\t\tstd::make_unique<DelayedControls>(cio2->sensor()->device(),\n>  \t\t\t\t\t\t\t  params);\n> -\t\tdata->cio2_.frameStart().connect(data->delayedCtrls_.get(),\n> -\t\t\t\t\t\t &DelayedControls::applyControls);\n> +\t\tdata->cio2_.frameStart().connect(data.get(),\n> +\t\t\t\t\t\t &IPU3CameraData::frameStart);\n>\n>  \t\t/* Convert the sensor rotation to a transformation */\n>  \t\tint32_t rotation = 0;\n> @@ -1414,6 +1422,49 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer)\n>  \tipa_->processEvent(ev);\n>  }\n>\n> +void IPU3CameraData::frameStart(uint32_t sequence)\n> +{\n> +\t/*\n> +\t * Handle the start of frame exposure signal.\n> +\t *\n> +\t * Inspect the list of pending requests waiting for a RAW frame to be\n> +\t * produced and apply controls for the 'next' one.\n> +\t *\n> +\t * Some controls need to be applied immediately, such as the\n> +\t * TestPatternMode one. Other controls are handled through the delayed\n> +\t * controls class.\n> +\t */\n\nI would have made of this a block before the function declaration\n\n> +\n> +\tdelayedCtrls_->applyControls(sequence);\n> +\n> +\tif (!processingRequests_.empty()) {\n\nReturn early to reduce indentation\n\n        if (processingRequests_.empty())\n                return;\n\n> +\t\t/* Handle controls which are to be set ready for the next frame to start. */\n\t\t/* Handle controls which have to be applied to the next frame. */\n\n> +\t\tRequest *request = processingRequests_.front();\n> +\t\tprocessingRequests_.pop();\n> +\n> +\t\t/* Assumes applying the test pattern mode affects immediately. */\n\ns/affect/takes effect\n\n> +\t\tif (!request->controls().contains(controls::draft::TestPatternMode))\n> +\t\t\treturn;\n\nBlank line\n\n> +\t\tconst int32_t testPatternMode = request->controls().get(\n> +\t\t\tcontrols::draft::TestPatternMode);\n> +\n> +\t\tLOG(IPU3, Debug) << \"Apply test pattern mode: \"\n> +\t\t\t\t << testPatternMode;\n\nI would actually move this to CameraSensor but ok\n\n> +\n> +\t\tint ret = cio2_.sensor()->setTestPatternMode(\n> +\t\t\tstatic_cast<controls::draft::TestPatternModeEnum>(\n> +\t\t\t\ttestPatternMode));\n> +\t\tif (ret) {\n> +\t\t\tLOG(IPU3, Error) << \"Failed to set test pattern mode: \"\n> +\t\t\t\t\t << ret;\n> +\t\t\treturn;\n> +\t\t}\n> +\n> +\t\trequest->metadata().set(controls::draft::TestPatternMode,\n> +\t\t\t\t\ttestPatternMode);\n\nNicer!\n\nThanks\n   j\n\n> +\t}\n> +}\n> +\n>  REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3)\n>\n>  } /* namespace libcamera */\n> --\n> 2.34.0.rc2.393.gf8c9666880-goog\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 3EBB9BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Nov 2021 08:56:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 06DBF6049B;\n\tFri, 26 Nov 2021 09:56:31 +0100 (CET)","from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ECD8460227\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Nov 2021 09:56:28 +0100 (CET)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 01F9C1C0004;\n\tFri, 26 Nov 2021 08:56:27 +0000 (UTC)"],"Date":"Fri, 26 Nov 2021 09:57:20 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<20211126085720.emnwgbq2sqrfl7ax@uno.localdomain>","References":"<20211126050810.1871781-1-hiroh@chromium.org>\n\t<20211126050810.1871781-4-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211126050810.1871781-4-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH v8 3/3] libcamera: pipeline: ipu3:\n\tApply a requested test pattern mode","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":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]