[{"id":18793,"web_url":"https://patchwork.libcamera.org/comment/18793/","msgid":"<20210814053644.GB1513067@pyrite.rasen.tech>","date":"2021-08-14T05:36:44","subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\n\tIPA buffers","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:10AM +0530, Umang Jain wrote:\n> VIMC is a virtual test driver that doesn't have statistics or\n> parameters buffers that are typically passed from a pipeline\n> handler to its platform IPA. To increase the test coverage going\n> forward, we can atleast mimick the typical interaction of how\n> a pipeline handler and IPA interacts, and use it to increase the\n> test coverage.\n> \n> Hence, create simple (single plane) dmabuf-backed FrameBuffers,\n> which can act as mock IPA buffers and can be memory mapped(mmap)\n> to VIMC IPA. To create these buffers, temporarily hijack the output\n> video node and configure it with a V4L2DeviceFormat. Buffers then\n> can be exported from the output video node using\n> V4L2VideoDevice::exportBuffers(). These buffers will be mimicked as\n> IPA buffers in subsequent commits.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/vimc/vimc.cpp | 23 +++++++++++++++++++++++\n>  1 file changed, 23 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index 4c92729d..2dfa1418 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 mock IPA buffers\";\n> +\t\treturn ret;\n> +\t}\n> +\n>  \t/* Initialise the supported controls. */\n>  \tconst ControlInfoMap &controls = sensor_->controls();\n>  \tControlInfoMap::Map ctrls;\n> @@ -548,6 +556,21 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n>  \tpipe_->completeRequest(request);\n>  }\n>  \n> +int VimcCameraData::allocateMockIPABuffers()\n> +{\n> +\tconstexpr unsigned int kBufCount = 2;\n> +\n> +\tV4L2DeviceFormat format;\n> +\tformat.fourcc = video_->toV4L2PixelFormat(formats::BGR888);\n> +\tformat.size = Size (160, 120);\n> +\n> +\tint ret = video_->setFormat(&format);\n> +\tif (ret < 0)\n> +\t\treturn ret;\n> +\n> +\treturn video_->exportBuffers(kBufCount, &mockIPABufs_);\n\nDo we ever need to free these buffers?\n\n\nPaul\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 20334BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 14 Aug 2021 05:36:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 885626888D;\n\tSat, 14 Aug 2021 07:36:53 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9260A6025E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Aug 2021 07:36:51 +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 0CC013E5;\n\tSat, 14 Aug 2021 07:36:49 +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=\"LLUBEFQJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628919411;\n\tbh=Yz0uKQHvaAMMh+akha/9w73oOa1vJSuFN9KQtC/8WgE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LLUBEFQJQvy74Svo6i8nX+aEmyHp53BEt7JRI/kO1iNQWMVfdwLJd+E7YiN1o7hfd\n\t4DBn5kZec8ZE8/tAgFNyE2gWw1ySYZm/QYS9J8uwrkXmxk5WPKAEtZkQBg4AZ7HeBd\n\tNNoVTFm05s4CvgZ1WC2xjhCqJi0KrLhdFNUHkOq0=","Date":"Sat, 14 Aug 2021 14:36:44 +0900","From":"paul.elder@ideasonboard.com","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<20210814053644.GB1513067@pyrite.rasen.tech>","References":"<20210814050912.15113-1-umang.jain@ideasonboard.com>\n\t<20210814050912.15113-3-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210814050912.15113-3-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\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>"}},{"id":18796,"web_url":"https://patchwork.libcamera.org/comment/18796/","msgid":"<YRgUzrEOnmDaUjsA@pendragon.ideasonboard.com>","date":"2021-08-14T19:09:02","subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\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 Sat, Aug 14, 2021 at 10:39:10AM +0530, Umang Jain wrote:\n> VIMC is a virtual test driver that doesn't have statistics or\n> parameters buffers that are typically passed from a pipeline\n> handler to its platform IPA. To increase the test coverage going\n> forward, we can atleast mimick the typical interaction of how\n\ns/atleast/at least/\n\n> a pipeline handler and IPA interacts, and use it to increase the\n\ns/interacts/interact/\n\n> test coverage.\n> \n> Hence, create simple (single plane) dmabuf-backed FrameBuffers,\n> which can act as mock IPA buffers and can be memory mapped(mmap)\n\ns/mapped/mapped /\n\n> to VIMC IPA. To create these buffers, temporarily hijack the output\n> video node and configure it with a V4L2DeviceFormat. Buffers then\n> can be exported from the output video node using\n> V4L2VideoDevice::exportBuffers(). These buffers will be mimicked as\n> IPA buffers in subsequent commits.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/vimc/vimc.cpp | 23 +++++++++++++++++++++++\n>  1 file changed, 23 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index 4c92729d..2dfa1418 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\nThis should be ret < 0. Did test pass with !ret ?\n\n> +\t\tLOG(VIMC, Warning) << \"Cannot allocate mock IPA buffers\";\n> +\t\treturn ret;\n> +\t}\n> +\n>  \t/* Initialise the supported controls. */\n>  \tconst ControlInfoMap &controls = sensor_->controls();\n>  \tControlInfoMap::Map ctrls;\n> @@ -548,6 +556,21 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n>  \tpipe_->completeRequest(request);\n>  }\n>  \n> +int VimcCameraData::allocateMockIPABuffers()\n> +{\n> +\tconstexpr unsigned int kBufCount = 2;\n> +\n> +\tV4L2DeviceFormat format;\n> +\tformat.fourcc = video_->toV4L2PixelFormat(formats::BGR888);\n> +\tformat.size = Size (160, 120);\n> +\n> +\tint ret = video_->setFormat(&format);\n> +\tif (ret < 0)\n> +\t\treturn ret;\n> +\n> +\treturn video_->exportBuffers(kBufCount, &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 6E58BBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 14 Aug 2021 19:09:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BDC2F68855;\n\tSat, 14 Aug 2021 21:09:09 +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 6E1C260261\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Aug 2021 21:09:08 +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 D4F8851D;\n\tSat, 14 Aug 2021 21:09:07 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"dUpglETs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628968148;\n\tbh=uAaPtyqvHayhHwqpqAbbQE1ATTN1NWpZzXG42+aCpTQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=dUpglETs0gmBXehz8hi3KgLf9hkcWDNWLJOxFFNZRDan3XgHCf3sfGsKBb3LMhiJV\n\te59UnL/QbMX4XV8XC3QpHZmEaKVllV/Nqf3RwKfSs+pDB8KnYqW8r+vrK3/X2YnekX\n\tPJ73Kz2uwYk6xVQY+NeWzlKrrwmEmEoYksTHookw=","Date":"Sat, 14 Aug 2021 22:09:02 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YRgUzrEOnmDaUjsA@pendragon.ideasonboard.com>","References":"<20210814050912.15113-1-umang.jain@ideasonboard.com>\n\t<20210814050912.15113-3-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210814050912.15113-3-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\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>"}},{"id":18797,"web_url":"https://patchwork.libcamera.org/comment/18797/","msgid":"<YRgU9VKjSLcYG8m3@pendragon.ideasonboard.com>","date":"2021-08-14T19:09:41","subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\n\tIPA buffers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nOn Sat, Aug 14, 2021 at 02:36:44PM +0900, paul.elder@ideasonboard.com wrote:\n> On Sat, Aug 14, 2021 at 10:39:10AM +0530, Umang Jain wrote:\n> > VIMC is a virtual test driver that doesn't have statistics or\n> > parameters buffers that are typically passed from a pipeline\n> > handler to its platform IPA. To increase the test coverage going\n> > forward, we can atleast mimick the typical interaction of how\n> > a pipeline handler and IPA interacts, and use it to increase the\n> > test coverage.\n> > \n> > Hence, create simple (single plane) dmabuf-backed FrameBuffers,\n> > which can act as mock IPA buffers and can be memory mapped(mmap)\n> > to VIMC IPA. To create these buffers, temporarily hijack the output\n> > video node and configure it with a V4L2DeviceFormat. Buffers then\n> > can be exported from the output video node using\n> > V4L2VideoDevice::exportBuffers(). These buffers will be mimicked as\n> > IPA buffers in subsequent commits.\n> > \n> > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/libcamera/pipeline/vimc/vimc.cpp | 23 +++++++++++++++++++++++\n> >  1 file changed, 23 insertions(+)\n> > \n> > diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> > index 4c92729d..2dfa1418 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 mock IPA buffers\";\n> > +\t\treturn ret;\n> > +\t}\n> > +\n> >  \t/* Initialise the supported controls. */\n> >  \tconst ControlInfoMap &controls = sensor_->controls();\n> >  \tControlInfoMap::Map ctrls;\n> > @@ -548,6 +556,21 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n> >  \tpipe_->completeRequest(request);\n> >  }\n> >  \n> > +int VimcCameraData::allocateMockIPABuffers()\n> > +{\n> > +\tconstexpr unsigned int kBufCount = 2;\n> > +\n> > +\tV4L2DeviceFormat format;\n> > +\tformat.fourcc = video_->toV4L2PixelFormat(formats::BGR888);\n> > +\tformat.size = Size (160, 120);\n> > +\n> > +\tint ret = video_->setFormat(&format);\n> > +\tif (ret < 0)\n> > +\t\treturn ret;\n> > +\n> > +\treturn video_->exportBuffers(kBufCount, &mockIPABufs_);\n> \n> Do we ever need to free these buffers?\n\nIt's the beauty of a std::vector<std::unique_ptr<>> :-)\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 B25FEBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 14 Aug 2021 19:09:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6F52B68855;\n\tSat, 14 Aug 2021 21:09:49 +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 3F62960261\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Aug 2021 21:09:47 +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 D21A93F0;\n\tSat, 14 Aug 2021 21:09:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"uJSkCY79\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628968187;\n\tbh=C6omqP5Hk/W63ssrxBY8PFfMbmXQGgupidm44B/as3M=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uJSkCY792PhHT0Rh9Mcraph8pCJFR4iTQlBxjco8N9aX8cvH4YpaqomBWzM02zVcF\n\thfA82wpUd7wdyzWbvRQ2PIDOo6JbcmbolaqbH+pMDvfTZW5tX5MpVuDDhz0hndH+iz\n\tss4VujdnGACxuKgysXI348nprpD3jwlbljAmy5AQ=","Date":"Sat, 14 Aug 2021 22:09:41 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"paul.elder@ideasonboard.com","Message-ID":"<YRgU9VKjSLcYG8m3@pendragon.ideasonboard.com>","References":"<20210814050912.15113-1-umang.jain@ideasonboard.com>\n\t<20210814050912.15113-3-umang.jain@ideasonboard.com>\n\t<20210814053644.GB1513067@pyrite.rasen.tech>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210814053644.GB1513067@pyrite.rasen.tech>","Subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\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>"}},{"id":18814,"web_url":"https://patchwork.libcamera.org/comment/18814/","msgid":"<20210816044115.GA1733965@pyrite.rasen.tech>","date":"2021-08-16T04:41:15","subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\n\tIPA buffers","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Sat, Aug 14, 2021 at 10:09:41PM +0300, Laurent Pinchart wrote:\n> Hi Paul,\n> \n> On Sat, Aug 14, 2021 at 02:36:44PM +0900, paul.elder@ideasonboard.com wrote:\n> > On Sat, Aug 14, 2021 at 10:39:10AM +0530, Umang Jain wrote:\n> > > VIMC is a virtual test driver that doesn't have statistics or\n> > > parameters buffers that are typically passed from a pipeline\n> > > handler to its platform IPA. To increase the test coverage going\n> > > forward, we can atleast mimick the typical interaction of how\n> > > a pipeline handler and IPA interacts, and use it to increase the\n> > > test coverage.\n> > > \n> > > Hence, create simple (single plane) dmabuf-backed FrameBuffers,\n> > > which can act as mock IPA buffers and can be memory mapped(mmap)\n> > > to VIMC IPA. To create these buffers, temporarily hijack the output\n> > > video node and configure it with a V4L2DeviceFormat. Buffers then\n> > > can be exported from the output video node using\n> > > V4L2VideoDevice::exportBuffers(). These buffers will be mimicked as\n> > > IPA buffers in subsequent commits.\n> > > \n> > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >  src/libcamera/pipeline/vimc/vimc.cpp | 23 +++++++++++++++++++++++\n> > >  1 file changed, 23 insertions(+)\n> > > \n> > > diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> > > index 4c92729d..2dfa1418 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 mock IPA buffers\";\n> > > +\t\treturn ret;\n> > > +\t}\n> > > +\n> > >  \t/* Initialise the supported controls. */\n> > >  \tconst ControlInfoMap &controls = sensor_->controls();\n> > >  \tControlInfoMap::Map ctrls;\n> > > @@ -548,6 +556,21 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n> > >  \tpipe_->completeRequest(request);\n> > >  }\n> > >  \n> > > +int VimcCameraData::allocateMockIPABuffers()\n> > > +{\n> > > +\tconstexpr unsigned int kBufCount = 2;\n> > > +\n> > > +\tV4L2DeviceFormat format;\n> > > +\tformat.fourcc = video_->toV4L2PixelFormat(formats::BGR888);\n> > > +\tformat.size = Size (160, 120);\n> > > +\n> > > +\tint ret = video_->setFormat(&format);\n> > > +\tif (ret < 0)\n> > > +\t\treturn ret;\n> > > +\n> > > +\treturn video_->exportBuffers(kBufCount, &mockIPABufs_);\n> > \n> > Do we ever need to free these buffers?\n> \n> It's the beauty of a std::vector<std::unique_ptr<>> :-)\n\nOoh, fancy :D\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> > > +}\n> > > +\n> > >  REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc)\n> > >  \n> > >  } /* namespace libcamera */\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 54D98BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Aug 2021 04:41:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CEE6168893;\n\tMon, 16 Aug 2021 06:41:24 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DE77D6888A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Aug 2021 06:41: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 388813E5;\n\tMon, 16 Aug 2021 06:41:20 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"AekoMV6d\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629088882;\n\tbh=WX8dSlGkRdm19EIIcwHYiz/V3g1XPtY1gQY6lh0srLE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AekoMV6dypir5Cj4yoYZ8tP8D0DtRuNK8AUfqmm7PVQZrTiDpdrWq9F+ZGzF4yUDE\n\tBenIAxh3VduvMmRqPV66/ZxB2C5LMxc+OCzHi8XJO91UPXrGNQcOb7SFbuJClK76Mo\n\th6K2P1vrEsSQTkUEP/ojvDHyheyw9cupE555CVJk=","Date":"Mon, 16 Aug 2021 13:41:15 +0900","From":"paul.elder@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210816044115.GA1733965@pyrite.rasen.tech>","References":"<20210814050912.15113-1-umang.jain@ideasonboard.com>\n\t<20210814050912.15113-3-umang.jain@ideasonboard.com>\n\t<20210814053644.GB1513067@pyrite.rasen.tech>\n\t<YRgU9VKjSLcYG8m3@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<YRgU9VKjSLcYG8m3@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\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>"}},{"id":18817,"web_url":"https://patchwork.libcamera.org/comment/18817/","msgid":"<d51f8960-53ce-3e75-588c-184a2e13d820@ideasonboard.com>","date":"2021-08-16T07:06:53","subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\n\tIPA buffers","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Laurent\n\nOn 8/15/21 12:39 AM, Laurent Pinchart wrote:\n> Hi Umang,\n>\n> Thank you for the patch.\n>\n> On Sat, Aug 14, 2021 at 10:39:10AM +0530, Umang Jain wrote:\n>> VIMC is a virtual test driver that doesn't have statistics or\n>> parameters buffers that are typically passed from a pipeline\n>> handler to its platform IPA. To increase the test coverage going\n>> forward, we can atleast mimick the typical interaction of how\n> s/atleast/at least/\n>\n>> a pipeline handler and IPA interacts, and use it to increase the\n> s/interacts/interact/\n>\n>> test coverage.\n>>\n>> Hence, create simple (single plane) dmabuf-backed FrameBuffers,\n>> which can act as mock IPA buffers and can be memory mapped(mmap)\n> s/mapped/mapped /\n>\n>> to VIMC IPA. To create these buffers, temporarily hijack the output\n>> video node and configure it with a V4L2DeviceFormat. Buffers then\n>> can be exported from the output video node using\n>> V4L2VideoDevice::exportBuffers(). These buffers will be mimicked as\n>> IPA buffers in subsequent commits.\n>>\n>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>> ---\n>>   src/libcamera/pipeline/vimc/vimc.cpp | 23 +++++++++++++++++++++++\n>>   1 file changed, 23 insertions(+)\n>>\n>> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n>> index 4c92729d..2dfa1418 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> This should be ret < 0. Did test pass with !ret ?\nYes, it was. But I agree it should be ret < 0, I'll fixup! during push\n>\n>> +\t\tLOG(VIMC, Warning) << \"Cannot allocate mock IPA buffers\";\n>> +\t\treturn ret;\n>> +\t}\n>> +\n>>   \t/* Initialise the supported controls. */\n>>   \tconst ControlInfoMap &controls = sensor_->controls();\n>>   \tControlInfoMap::Map ctrls;\n>> @@ -548,6 +556,21 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n>>   \tpipe_->completeRequest(request);\n>>   }\n>>   \n>> +int VimcCameraData::allocateMockIPABuffers()\n>> +{\n>> +\tconstexpr unsigned int kBufCount = 2;\n>> +\n>> +\tV4L2DeviceFormat format;\n>> +\tformat.fourcc = video_->toV4L2PixelFormat(formats::BGR888);\n>> +\tformat.size = Size (160, 120);\n>> +\n>> +\tint ret = video_->setFormat(&format);\n>> +\tif (ret < 0)\n>> +\t\treturn ret;\n>> +\n>> +\treturn video_->exportBuffers(kBufCount, &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 59ECEBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Aug 2021 07:07:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8C0DF6888A;\n\tMon, 16 Aug 2021 09:07:01 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B33E60260\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Aug 2021 09:06:59 +0200 (CEST)","from [192.168.1.104] (unknown [103.238.109.15])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BE6B63E5;\n\tMon, 16 Aug 2021 09:06:58 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"AA85staE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629097619;\n\tbh=blWS/OHLczq4shsKCuNOHdXJmJyLnqmKyDOQf+uDNcw=;\n\th=Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=AA85staEhTvHMZqq4dR1ye5FHV2yuXSjtS4YuMNyO2/MiIMvuASx6HGRPLf4olX35\n\tCkzrhsA6WM7QYn382g9gbG1RqIg49ybFcB5oZH3QJ0d8KoZCM8VG6X/5AEjwyehSVX\n\tMJ5g6HO7r2RR7WGHkEbl4qD6ffZAtBZXt/K9CHDY=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20210814050912.15113-1-umang.jain@ideasonboard.com>\n\t<20210814050912.15113-3-umang.jain@ideasonboard.com>\n\t<YRgUzrEOnmDaUjsA@pendragon.ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<d51f8960-53ce-3e75-588c-184a2e13d820@ideasonboard.com>","Date":"Mon, 16 Aug 2021 12:36:53 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<YRgUzrEOnmDaUjsA@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v3 2/4] pipeline: vimc: Allocate mock\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>"}}]