[{"id":21607,"web_url":"https://patchwork.libcamera.org/comment/21607/","msgid":"<Ya35/2ONpE1rtArz@pendragon.ideasonboard.com>","date":"2021-12-06T11:54:39","subject":"Re: [libcamera-devel] [PATCH v10 3/3] libcamera: pipeline: ipu3:\n\tApply a requested test pattern mode","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nThank you for the patch.\n\nOn Mon, Dec 06, 2021 at 02:49:18PM +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> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 59 +++++++++++++++++++++++++++-\n>  1 file changed, 57 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 25490dcf..ee1ad27e 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> @@ -564,6 +568,11 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> +\tret = cio2->sensor()->setTestPatternMode(\n> +\t\tcontrols::draft::TestPatternModeEnum::TestPatternModeOff);\n> +\tif (ret)\n> +\t\treturn ret;\n\nShouldn't this be done at start() time instead ?\n\n> +\n>  \tIPACameraSensorInfo sensorInfo;\n>  \tcio2->sensor()->sensorInfo(&sensorInfo);\n>  \tdata->cropRegion_ = sensorInfo.analogCrop;\n> @@ -811,6 +820,8 @@ void PipelineHandlerIPU3::stop(Camera *camera)\n>  \n>  void IPU3CameraData::cancelPendingRequests()\n>  {\n> +\tprocessingRequests_ = {};\n> +\n>  \twhile (!pendingRequests_.empty()) {\n>  \t\tRequest *request = pendingRequests_.front();\n>  \n> @@ -853,6 +864,8 @@ void IPU3CameraData::queuePendingRequests()\n>  \n>  \t\tinfo->rawBuffer = rawBuffer;\n>  \n> +\t\tprocessingRequests_.push(request);\n> +\n\nI would have moved this to the end, after the pendingRequests_.pop()\ncall, to group code that moves the request from one queue to the other,\nbut it likely makes no real difference in practice.\n\n>  \t\tipa::ipu3::IPU3Event ev;\n>  \t\tev.op = ipa::ipu3::EventProcessControls;\n>  \t\tev.frame = info->id;\n> @@ -1121,8 +1134,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 +1427,48 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer)\n>  \tipa_->processEvent(ev);\n>  }\n>  \n> +/*\n> + * \\brief Handle the start of frame exposure signal\n> + * \\param[in] sequence The sequence number of frame\n> + *\n> + * Inspect the list of pending requests waiting for a RAW frame to be\n> + * produced and apply controls for the 'next' one.\n> + *\n> + * Some controls need to be applied immediately, such as the\n> + * TestPatternMode one. Other controls are handled through the delayed\n> + * controls class.\n> + */\n> +void IPU3CameraData::frameStart(uint32_t sequence)\n> +{\n> +\tdelayedCtrls_->applyControls(sequence);\n> +\n> +\tif (processingRequests_.empty())\n> +\t\treturn;\n> +\n> +\t/* Handle controls which are to be set ready for the next frame to start. */\n> +\tRequest *request = processingRequests_.front();\n> +\tprocessingRequests_.pop();\n\nThere's no synchronization with the sequence number, I can imagine many\nways how this could go wrong. I don't want to delay this series\nendlessly, so with a\n\n\t/* \\todo Synchronize with the sequence number */\n\ncomment,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n> +\t/* Takes effect applying the test pattern mode affects immediately. */\n> +\tif (!request->controls().contains(controls::draft::TestPatternMode))\n> +\t\treturn;\n> +\n> +\tconst int32_t testPatternMode = request->controls().get(\n> +\t\tcontrols::draft::TestPatternMode);\n> +\n> +\tint ret = cio2_.sensor()->setTestPatternMode(\n> +\t\tstatic_cast<controls::draft::TestPatternModeEnum>(\n> +\t\t\ttestPatternMode));\n> +\tif (ret) {\n> +\t\tLOG(IPU3, Error) << \"Failed to set test pattern mode: \"\n> +\t\t\t\t << ret;\n> +\t\treturn;\n> +\t}\n> +\n> +\trequest->metadata().set(controls::draft::TestPatternMode,\n> +\t\t\t\ttestPatternMode);\n> +}\n> +\n>  REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3)\n>  \n>  } /* namespace libcamera */","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 1D6ADBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Dec 2021 11:55:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D06C607DE;\n\tMon,  6 Dec 2021 12:55:08 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A4CBC60725\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Dec 2021 12:55:07 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0F790EE;\n\tMon,  6 Dec 2021 12:55:06 +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=\"cITCrkAS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638791707;\n\tbh=5isGrOapZ278yjV8GDJkBvA2G5tZu+Zvo0Nl9mxR6gc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=cITCrkASX8vooMhIQm34jsT5h5jLMS4Cr/MpNc3IlCigP5KMefnLGWOKWE21Y12c9\n\t4sokZoxFg0GmU/boLoRld5LQqzBX3L+lqEhqIH0LkyD8I379xG+Qv8O0X/uYm+Sg5R\n\thMihUV4lg3AqKiJrA5+WcG/kzM0l7CG+RhHwOsrA=","Date":"Mon, 6 Dec 2021 13:54:39 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<Ya35/2ONpE1rtArz@pendragon.ideasonboard.com>","References":"<20211206054918.2467049-1-hiroh@chromium.org>\n\t<20211206054918.2467049-3-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211206054918.2467049-3-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH v10 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>"}}]