[{"id":1690,"web_url":"https://patchwork.libcamera.org/comment/1690/","msgid":"<20190523202527.GE21601@pendragon.ideasonboard.com>","date":"2019-05-23T20:25:27","subject":"Re: [libcamera-devel] [RFC PATCH v2 5/5] libcamera: pipelines:\n\tuvcvideo: add IPAManager","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Thu, May 23, 2019 at 12:42:10PM -0400, Paul Elder wrote:\n> Make the UVC pipeline query for one of the test IPA modules.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n> Changes in v2:\n> - remove IPAManager from PipelineHandler::match parameter\n> \n> This is a sample of how a IPAManager would be used.\n\nI'm afraid you picked one of the pipeline handlers that will very likely\nnot need an IPA :-) UVC cameras are high-level cameras, and implement\nthe 3A algorithms internally. For test purpose this could still be\nuseful as the hardware is easier to source, but in that case I would\nmove it to the VIMC pipeline handler as that's even easier to source.\n\n>  src/libcamera/pipeline/uvcvideo.cpp | 16 +++++++++++++++-\n>  1 file changed, 15 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index 351712c..8275f5a 100644\n> --- a/src/libcamera/pipeline/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> @@ -6,16 +6,20 @@\n>   */\n>  \n>  #include <libcamera/camera.h>\n> +#include <libcamera/ipa/ipa_module_info.h>\n>  #include <libcamera/request.h>\n>  #include <libcamera/stream.h>\n>  \n>  #include \"device_enumerator.h\"\n> +#include \"ipa_manager.h\"\n>  #include \"log.h\"\n>  #include \"media_device.h\"\n>  #include \"pipeline_handler.h\"\n>  #include \"utils.h\"\n>  #include \"v4l2_device.h\"\n>  \n> +#include <string.h>\n> +\n\nThis should move up, before the libcamera includes.\n\n>  namespace libcamera {\n>  \n>  LOG_DEFINE_CATEGORY(UVC)\n> @@ -175,6 +179,16 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n>  \tif (!media)\n>  \t\treturn false;\n>  \n> +\tIPAManager *ipaManager = IPAManager::instance();\n> +\tipaManager->addDir(\"test/ipa\");\n> +\tstruct IPAModuleInfo info;\n> +\tinfo.ipaAPIVersion = 1;\n> +\tinfo.pipelineVersion = 8999;\n> +\tstrcpy(info.pipelineName, \"bleep\");\n> +\tIPAModule *ipa = ipaManager->acquireIPA(info);\n> +\tif (ipa == nullptr)\n> +\t\tLOG(UVC, Warning) << \"no matching IPA found\";\n> +\n\nToo complicated for pipeline handlers :-) Here's what you want to\nachieve.\n\n\tIPAModule *ipa = IPAManager::instance()->find(this);\n\nand the ipa variable should be stored in the camera data (as it will be\nused later, that's the whole point :-)).\n\nThe next step will be to create the IPA implementation object that I\nmentioned in the review of 2/5 (created by a factory method exposed by\nthe module), and I think that the IPAModule itself will be hidden from\nthe pipeline handler. I foresee something along the lines of\n\n\t/* In the camera data class */\n\tstd::unique_ptr<IPAImplementation> ipa_;\n\n(IPAImplementation should be renamed)\n\n\t/* Here */\n\tipa_ = IPAManager::create(this);\n\nThis will internally find a corresponding IPAModule, and call its\nfactory method to create an IPAImplementation object, that will point\ninternally to the IPAModule in case the module needs to be accessed at\nruntime.\n\n>  \tstd::unique_ptr<UVCCameraData> data = utils::make_unique<UVCCameraData>(this);\n>  \n>  \t/* Locate and open the default video node. */\n> @@ -197,7 +211,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n>  \n>  \t/* Create and register the camera. */\n>  \tstd::set<Stream *> streams{ &data->stream_ };\n> -\tstd::shared_ptr<Camera> camera = Camera::create(this, media->model(), streams);\n> +\tstd::shared_ptr<Camera> camera = Camera::create(this, media->model() + \" \" + (ipa == nullptr ? \"\" : ipa->info().name), streams);\n\nThat's a very long line, and I'm not sure to understand why you would\nlike to include this in the camera name. The camera name is meant to be\nexposed to users, I don't think they should even know that an IPA is\nrunning.\n\n>  \tregisterCamera(std::move(camera), std::move(data));\n>  \n>  \t/* Enable hot-unplug notifications. */","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 CBD5C60E9A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 May 2019 22:25:45 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3639C5A9;\n\tThu, 23 May 2019 22:25:45 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1558643145;\n\tbh=tmp4GpL6PUICytFEAAVVCpH5zFRWMR6KTQb/CXQIXW4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OLiu2rDmcq680aotlbF/pPlFvagFyP3ZOwPuKHL3vN6lNwS5L7Qh7BjuysDOCZ7DU\n\tSMSZ9VBgB0Z6M9SvHruKF6wh2YaiDpkzAz8RPpEZvUi1hG9oCAAXL7elJesToV0ufu\n\tR2An0hngPVN53JAFq013SXvPPJpnMO96i1HSUbXE=","Date":"Thu, 23 May 2019 23:25:27 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190523202527.GE21601@pendragon.ideasonboard.com>","References":"<20190523164210.2105-1-paul.elder@ideasonboard.com>\n\t<20190523164210.2105-6-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190523164210.2105-6-paul.elder@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [RFC PATCH v2 5/5] libcamera: pipelines:\n\tuvcvideo: add IPAManager","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Thu, 23 May 2019 20:25:46 -0000"}}]