[{"id":18795,"web_url":"https://patchwork.libcamera.org/comment/18795/","msgid":"<20210814054014.GD1513067@pyrite.rasen.tech>","date":"2021-08-14T05:40:14","subject":"Re: [libcamera-devel] [PATCH v3 4/4] ipa: vimc: Send and retrieve\n\tFrameBuffers from IPA","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Umang,\n\nOn Sat, Aug 14, 2021 at 10:39:12AM +0530, Umang Jain wrote:\n> Plumb through VIMC mojo interface to enable buffers passing.\n> VIMC does not have parameters or statistics buffers but we can\n> mimick the typical case of passing IPA buffers from pipeline\n> handler to IPA using mock buffers. The mock IPA buffers are\n> FrameBuffers which are dmabuf backed (in other words, mmap()able\n> through MappedFramebuffer inside the IPA).\n> \n> This commits shows:\n> - Passing the parameter buffer from the pipeline handler to\n>   the IPA through functions defined in mojom interface.\n> - Passing request controls ControlList to the IPA.\n> \n> Any tests using VIMC will now loop in the IPA paths. Any tests running\n> in isolated mode will help us to test IPA IPC code paths especially\n> around (de)serialization of data passing from pipeline handlers to the\n> IPA. Future IPA interface tests can simply extend the vimc mojom\n> interface to achieve/test a specific use case as required.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  include/libcamera/ipa/vimc.mojom     | 11 ++++++++++-\n>  src/ipa/vimc/vimc.cpp                | 19 +++++++++++++++++++\n>  src/libcamera/pipeline/vimc/vimc.cpp | 11 +++++++++++\n>  3 files changed, 40 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/ipa/vimc.mojom b/include/libcamera/ipa/vimc.mojom\n> index 8cb240d3..e3b14e38 100644\n> --- a/include/libcamera/ipa/vimc.mojom\n> +++ b/include/libcamera/ipa/vimc.mojom\n> @@ -29,8 +29,17 @@ interface IPAVimcInterface {\n>  \n>  \tmapBuffers(array<libcamera.IPABuffer> buffers);\n>  \tunmapBuffers(array<uint32> ids);\n> +\n> +\t/*\n> +\t * The vimc driver doesn't use parameters buffers. To maximize coverage\n> +\t * of unit tests that rely on the VIMC pipeline handler, we still define\n> +\t * interface functions that mimick how other pipeline handlers typically\n> +\t * handle parameters at runtime.\n> +\t */\n> +\t[async] fillParams(uint32 frame, uint32 bufferId);\n> +\t[async] processControls(uint32 frame, libcamera.ControlList controls);\n>  };\n>  \n>  interface IPAVimcEventInterface {\n> -\tdummyEvent(uint32 val);\n> +\tparamsFilled(uint32 bufferId);\n>  };\n> diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp\n> index 7d9d22d0..8481b82b 100644\n> --- a/src/ipa/vimc/vimc.cpp\n> +++ b/src/ipa/vimc/vimc.cpp\n> @@ -43,6 +43,9 @@ public:\n>  \tvoid mapBuffers(const std::vector<IPABuffer> &buffers) override;\n>  \tvoid unmapBuffers(const std::vector<unsigned int> &ids) override;\n>  \n> +\tvoid fillParams(uint32_t frame, uint32_t bufferId) override;\n> +\tvoid processControls(uint32_t frame, const ControlList &controls) override;\n> +\n>  private:\n>  \tvoid initTrace();\n>  \tvoid trace(enum ipa::vimc::IPAOperationCode operation);\n> @@ -126,6 +129,22 @@ void IPAVimc::unmapBuffers(const std::vector<unsigned int> &ids)\n>  \t}\n>  }\n>  \n> +void IPAVimc::fillParams([[maybe_unused]] uint32_t frame, uint32_t bufferId)\n> +{\n> +\tauto it = buffers_.find(bufferId);\n> +\tif (it == buffers_.end()) {\n> +\t\tLOG(IPAVimc, Error) << \"Could not find parameter buffer\";\n> +\t\treturn;\n> +\t}\n> +\n> +\tparamsFilled.emit(bufferId);\n> +}\n> +\n> +void IPAVimc::processControls([[maybe_unused]] uint32_t frame,\n> +\t\t\t      [[maybe_unused]] const ControlList &controls)\n> +{\n> +}\n> +\n>  void IPAVimc::initTrace()\n>  {\n>  \tstruct stat fifoStat;\n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index b08325c2..b9fa6227 100644\n> --- a/src/libcamera/pipeline/vimc/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc/vimc.cpp\n> @@ -52,6 +52,7 @@ public:\n>  \tint init();\n>  \tint allocateMockIPABuffers();\n>  \tvoid bufferReady(FrameBuffer *buffer);\n> +\tvoid paramsFilled(unsigned int id);\n>  \n>  \tMediaDevice *media_;\n>  \tstd::unique_ptr<CameraSensor> sensor_;\n> @@ -432,6 +433,8 @@ int PipelineHandlerVimc::queueRequestDevice(Camera *camera, Request *request)\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>  \n> +\tdata->ipa_->processControls(request->sequence(), request->controls());\n> +\n>  \treturn 0;\n>  }\n>  \n> @@ -465,6 +468,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n>  \t\treturn false;\n>  \t}\n>  \n> +\tdata->ipa_->paramsFilled.connect(data.get(), &VimcCameraData::paramsFilled);\n> +\n>  \tstd::string conf = data->ipa_->configurationFile(\"vimc.conf\");\n>  \tdata->ipa_->init(IPASettings{ conf, data->sensor_->model() });\n>  \n> @@ -569,6 +574,8 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n>  \n>  \tpipe_->completeBuffer(request, buffer);\n>  \tpipe_->completeRequest(request);\n> +\n> +\tipa_->fillParams(request->sequence(), mockIPABufs_[0]->cookie());\n>  }\n>  \n>  int VimcCameraData::allocateMockIPABuffers()\n> @@ -586,6 +593,10 @@ int VimcCameraData::allocateMockIPABuffers()\n>  \treturn video_->exportBuffers(kBufCount, &mockIPABufs_);\n>  }\n>  \n> +void VimcCameraData::paramsFilled([[maybe_unused]] unsigned int id)\n> +{\n> +}\n> +\n>  REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc)\n>  \n>  } /* namespace libcamera */\n> -- \n> 2.31.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 480FFBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 14 Aug 2021 05:40:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ADFD368890;\n\tSat, 14 Aug 2021 07:40:23 +0200 (CEST)","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 085936888D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Aug 2021 07:40:22 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7FC963E5;\n\tSat, 14 Aug 2021 07:40:20 +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=\"DtVlkOKj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628919621;\n\tbh=+MFhfOX+J/1nFBlo/MxGqgAhATtjQmj3UuQZraSoLbs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=DtVlkOKjgdYfCg/zyRZaNVnYvdf9RquZOPdtWLa22QZ6ocw9cVQWzhoD9INCrNA80\n\to9xWfBfno5RdkfOOuEyFCKdmE3fwg8AFOSnSwB/hUn+vVFJYcOk2G4ICJsw/3oIgHX\n\t9kCAc7u6ULdVA0Rt2PY90zUKe+btR+aiW2Y/mIeA=","Date":"Sat, 14 Aug 2021 14:40:14 +0900","From":"paul.elder@ideasonboard.com","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<20210814054014.GD1513067@pyrite.rasen.tech>","References":"<20210814050912.15113-1-umang.jain@ideasonboard.com>\n\t<20210814050912.15113-5-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210814050912.15113-5-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 4/4] ipa: vimc: Send and retrieve\n\tFrameBuffers from IPA","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>"}},{"id":18799,"web_url":"https://patchwork.libcamera.org/comment/18799/","msgid":"<YRgdcRlNE72LA8gZ@pendragon.ideasonboard.com>","date":"2021-08-14T19:45:53","subject":"Re: [libcamera-devel] [PATCH v3 4/4] ipa: vimc: Send and retrieve\n\tFrameBuffers from IPA","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 Sat, Aug 14, 2021 at 10:39:12AM +0530, Umang Jain wrote:\n> Plumb through VIMC mojo interface to enable buffers passing.\n> VIMC does not have parameters or statistics buffers but we can\n> mimick the typical case of passing IPA buffers from pipeline\n> handler to IPA using mock buffers. The mock IPA buffers are\n> FrameBuffers which are dmabuf backed (in other words, mmap()able\n> through MappedFramebuffer inside the IPA).\n> \n> This commits shows:\n> - Passing the parameter buffer from the pipeline handler to\n>   the IPA through functions defined in mojom interface.\n> - Passing request controls ControlList to the IPA.\n> \n> Any tests using VIMC will now loop in the IPA paths. Any tests running\n> in isolated mode will help us to test IPA IPC code paths especially\n> around (de)serialization of data passing from pipeline handlers to the\n> IPA. Future IPA interface tests can simply extend the vimc mojom\n> interface to achieve/test a specific use case as required.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/ipa/vimc.mojom     | 11 ++++++++++-\n>  src/ipa/vimc/vimc.cpp                | 19 +++++++++++++++++++\n>  src/libcamera/pipeline/vimc/vimc.cpp | 11 +++++++++++\n>  3 files changed, 40 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/ipa/vimc.mojom b/include/libcamera/ipa/vimc.mojom\n> index 8cb240d3..e3b14e38 100644\n> --- a/include/libcamera/ipa/vimc.mojom\n> +++ b/include/libcamera/ipa/vimc.mojom\n> @@ -29,8 +29,17 @@ interface IPAVimcInterface {\n>  \n>  \tmapBuffers(array<libcamera.IPABuffer> buffers);\n>  \tunmapBuffers(array<uint32> ids);\n> +\n> +\t/*\n> +\t * The vimc driver doesn't use parameters buffers. To maximize coverage\n> +\t * of unit tests that rely on the VIMC pipeline handler, we still define\n> +\t * interface functions that mimick how other pipeline handlers typically\n> +\t * handle parameters at runtime.\n> +\t */\n> +\t[async] fillParams(uint32 frame, uint32 bufferId);\n> +\t[async] processControls(uint32 frame, libcamera.ControlList controls);\n>  };\n>  \n>  interface IPAVimcEventInterface {\n> -\tdummyEvent(uint32 val);\n> +\tparamsFilled(uint32 bufferId);\n>  };\n> diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp\n> index 7d9d22d0..8481b82b 100644\n> --- a/src/ipa/vimc/vimc.cpp\n> +++ b/src/ipa/vimc/vimc.cpp\n> @@ -43,6 +43,9 @@ public:\n>  \tvoid mapBuffers(const std::vector<IPABuffer> &buffers) override;\n>  \tvoid unmapBuffers(const std::vector<unsigned int> &ids) override;\n>  \n> +\tvoid fillParams(uint32_t frame, uint32_t bufferId) override;\n> +\tvoid processControls(uint32_t frame, const ControlList &controls) override;\n> +\n>  private:\n>  \tvoid initTrace();\n>  \tvoid trace(enum ipa::vimc::IPAOperationCode operation);\n> @@ -126,6 +129,22 @@ void IPAVimc::unmapBuffers(const std::vector<unsigned int> &ids)\n>  \t}\n>  }\n>  \n> +void IPAVimc::fillParams([[maybe_unused]] uint32_t frame, uint32_t bufferId)\n> +{\n> +\tauto it = buffers_.find(bufferId);\n> +\tif (it == buffers_.end()) {\n> +\t\tLOG(IPAVimc, Error) << \"Could not find parameter buffer\";\n> +\t\treturn;\n> +\t}\n> +\n> +\tparamsFilled.emit(bufferId);\n> +}\n> +\n> +void IPAVimc::processControls([[maybe_unused]] uint32_t frame,\n> +\t\t\t      [[maybe_unused]] const ControlList &controls)\n> +{\n> +}\n> +\n>  void IPAVimc::initTrace()\n>  {\n>  \tstruct stat fifoStat;\n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index b08325c2..b9fa6227 100644\n> --- a/src/libcamera/pipeline/vimc/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc/vimc.cpp\n> @@ -52,6 +52,7 @@ public:\n>  \tint init();\n>  \tint allocateMockIPABuffers();\n>  \tvoid bufferReady(FrameBuffer *buffer);\n> +\tvoid paramsFilled(unsigned int id);\n>  \n>  \tMediaDevice *media_;\n>  \tstd::unique_ptr<CameraSensor> sensor_;\n> @@ -432,6 +433,8 @@ int PipelineHandlerVimc::queueRequestDevice(Camera *camera, Request *request)\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>  \n> +\tdata->ipa_->processControls(request->sequence(), request->controls());\n> +\n>  \treturn 0;\n>  }\n>  \n> @@ -465,6 +468,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n>  \t\treturn false;\n>  \t}\n>  \n> +\tdata->ipa_->paramsFilled.connect(data.get(), &VimcCameraData::paramsFilled);\n> +\n>  \tstd::string conf = data->ipa_->configurationFile(\"vimc.conf\");\n>  \tdata->ipa_->init(IPASettings{ conf, data->sensor_->model() });\n>  \n> @@ -569,6 +574,8 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n>  \n>  \tpipe_->completeBuffer(request, buffer);\n>  \tpipe_->completeRequest(request);\n> +\n> +\tipa_->fillParams(request->sequence(), mockIPABufs_[0]->cookie());\n>  }\n>  \n>  int VimcCameraData::allocateMockIPABuffers()\n> @@ -586,6 +593,10 @@ int VimcCameraData::allocateMockIPABuffers()\n>  \treturn video_->exportBuffers(kBufCount, &mockIPABufs_);\n>  }\n>  \n> +void VimcCameraData::paramsFilled([[maybe_unused]] unsigned int id)\n> +{\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 61702BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 14 Aug 2021 19:46:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CDCBF60262;\n\tSat, 14 Aug 2021 21:46:00 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EA90F60261\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Aug 2021 21:45:58 +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 6F1873F0;\n\tSat, 14 Aug 2021 21:45:58 +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=\"Na6gSm1f\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628970358;\n\tbh=cngDRmmPHKBR7XZAZZHT5WGCbd+ODyXC9r2XppN8F+U=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Na6gSm1fAT/NVFRJGgkPnx76dKZqVBtH9+JdTCGCmslwAVFv2f3TYqU3p1vYjGuf0\n\tsGff8JFSrCOujCYNuY3LJvHO9XnTNtwkhGlJKWpE7jN+dwBXAo4XPV4cKnP6Yc35V/\n\tiP1k6GbXEc84bnyP3HSuQ5IqBG4CfVOdPMgOrLdc=","Date":"Sat, 14 Aug 2021 22:45:53 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YRgdcRlNE72LA8gZ@pendragon.ideasonboard.com>","References":"<20210814050912.15113-1-umang.jain@ideasonboard.com>\n\t<20210814050912.15113-5-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210814050912.15113-5-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 4/4] ipa: vimc: Send and retrieve\n\tFrameBuffers from IPA","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>"}}]