[{"id":18788,"web_url":"https://patchwork.libcamera.org/comment/18788/","msgid":"<YRcLAKU5Cz4hD16s@pendragon.ideasonboard.com>","date":"2021-08-14T00:14:56","subject":"Re: [libcamera-devel] [PATCH v2 2/4] pipeline: vimc: Allocate fake\n\tIPA buffers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\nOn Fri, Aug 13, 2021 at 08:14:35PM +0530, Umang Jain wrote:\n> VIMC is a virtual test driver that doesn't generate statistics or\n> consume parameters buffers. Thus, create simple (single plane)\n> dmabuf-backed FrameBuffers, which can act as fake IPA buffers and\n> can be memory mapped(mmap) to VIMC IPA.\n> \n> To create these buffers, temporarily hijack the output video node\n> and configure it with a V4L2DeviceFormat. Buffers then can be exported\n> from the output video node using V4L2VideoDevice::exportBuffers().\n> These buffers will be mimicked as IPA buffers in subsequent commits.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/vimc/vimc.cpp | 27 +++++++++++++++++++++++++++\n>  1 file changed, 27 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index 4c92729d..edf8c58e 100644\n> --- a/src/libcamera/pipeline/vimc/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc/vimc.cpp\n> @@ -50,6 +50,7 @@ public:\n>  \t}\n>  \n>  \tint init();\n> +\tint allocateMockIPABuffers();\n>  \tvoid bufferReady(FrameBuffer *buffer);\n>  \n>  \tMediaDevice *media_;\n> @@ -61,6 +62,7 @@ public:\n>  \tStream stream_;\n>  \n>  \tstd::unique_ptr<ipa::vimc::IPAProxyVimc> ipa_;\n> +\tstd::vector<std::unique_ptr<FrameBuffer>> mockIPABufs_;\n>  };\n>  \n>  class VimcCameraConfiguration : public CameraConfiguration\n> @@ -500,6 +502,12 @@ int VimcCameraData::init()\n>  \tif (raw_->open())\n>  \t\treturn -ENODEV;\n>  \n> +\tret = allocateMockIPABuffers();\n> +\tif (!ret) {\n> +\t\tLOG(VIMC, Warning) << \"Cannot allocate fake IPA buffers\";\n\nI'd replace \"fake\" with \"mock\", as they're real buffers :-) Even \"mock\"\nmay not be totally accurate, we could talk about \"mock statistics\nbuffers\" instead of \"mock buffers\", but that's bikeshedding.\n\n> +\t\t/* \\todo fail hard or continue? */\n\nI don't see a reason why this should fail, so I'd make it a hard error.\n\n> +\t}\n> +\n>  \t/* Initialise the supported controls. */\n>  \tconst ControlInfoMap &controls = sensor_->controls();\n>  \tControlInfoMap::Map ctrls;\n> @@ -548,6 +556,25 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n>  \tpipe_->completeRequest(request);\n>  }\n>  \n> +int VimcCameraData::allocateMockIPABuffers()\n> +{\n> +\tunsigned int bufCount = 2;\n\n\tconstexpr unsigned int kBufCount = 2;\n\n> +\n> +\tV4L2DeviceFormat format;\n> +\tformat.fourcc = video_->toV4L2PixelFormat(formats::BGR888);\n> +\tformat.size = Size(160, 120);\n> +\n> +\tint ret = video_->tryFormat(&format);\n> +\tif (ret < 0)\n> +\t\treturn ret;\n\nNo need to call tryFormat(), setFormat() is enough.\n\nWith these small issues fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n> +\tret = video_->setFormat(&format);\n> +\tif (ret < 0)\n> +\t\treturn ret;\n> +\n> +\treturn video_->exportBuffers(bufCount, &mockIPABufs_);\n> +}\n> +\n>  REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc)\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 94085C3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 14 Aug 2021 00:15:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 17C656888F;\n\tSat, 14 Aug 2021 02:15:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AADFD68823\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Aug 2021 02:15:01 +0200 (CEST)","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 393A73F0;\n\tSat, 14 Aug 2021 02:15:01 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"cDv5fs3y\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628900101;\n\tbh=V0yzmDWiEfheEdc7La1/lqhQ6jOMsccifdV6bKZTKls=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=cDv5fs3y44pTLXL64X5LGQSTNrzP2zo9cK2rGMlLWje2tMm7o0EHjxrG/ECRXMaoo\n\t4WVivF5k2tmNAXGJNn8/8W2DdfZZx9p4bWv5j0SVW2527ZnPdVx7YIgSPUS+5BYXc5\n\tKf4G/PBMzniBw3zvC8lBCy+tNm6WIcxRcwIhXGH0=","Date":"Sat, 14 Aug 2021 03:14:56 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YRcLAKU5Cz4hD16s@pendragon.ideasonboard.com>","References":"<20210813144437.138005-1-umang.jain@ideasonboard.com>\n\t<20210813144437.138005-3-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210813144437.138005-3-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/4] pipeline: vimc: Allocate fake\n\tIPA buffers","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>"}}]