{"id":13247,"url":"https://patchwork.libcamera.org/api/1.1/patches/13247/?format=json","web_url":"https://patchwork.libcamera.org/patch/13247/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210806101409.324645-5-umang.jain@ideasonboard.com>","date":"2021-08-06T10:14:09","name":"[libcamera-devel,4/4] ipa: vimc: Send and retrieve FrameBuffers from IPA","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"b4cb35bc15b3e4b4abc6dba3a6ae283eb913ee80","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/1.1/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/13247/mbox/","series":[{"id":2316,"url":"https://patchwork.libcamera.org/api/1.1/series/2316/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2316","date":"2021-08-06T10:14:05","name":"Pass buffers to VIMC IPA","version":1,"mbox":"https://patchwork.libcamera.org/series/2316/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13247/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13247/checks/","tags":{},"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 9C9BAC323B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Aug 2021 10:14:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2EC7A6884F;\n\tFri,  6 Aug 2021 12:14:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C409868811\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Aug 2021 12:14:36 +0200 (CEST)","from perceval.ideasonboard.com (unknown [103.251.226.40])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A25EDFA;\n\tFri,  6 Aug 2021 12:14:35 +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=\"Inl9iKrK\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628244876;\n\tbh=1Jfde0KjsGzWfgxecrTZKjNvFdbRyw3tqfwXITxibjg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Inl9iKrK0zm2LQGz/6Sm6qOI/p5nVn8tW5FDA2+w8J+MbYoK3avsWReqz0Yqh9zMY\n\tXuYibJd5oR3zr4ZfMAh2wP+D3pS5Jttn7MPtaOsjVwsn8/vSJ88ID/X+UnQsTfGgCY\n\tkBt9AOgyhI8sFnPH/hbzcKiRYx9UTlwRimbumYns=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  6 Aug 2021 15:44:09 +0530","Message-Id":"<20210806101409.324645-5-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210806101409.324645-1-umang.jain@ideasonboard.com>","References":"<20210806101409.324645-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Plumb through actions and events in the VIMC mojo interface.\nEvents are send from pipeline handler to IPA and actions can be\nemitted from IPA and handled in the pipeline handler. The plumbing\nensures that, we can send/retrieve FrameBuffers from the vimc IPA.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n include/libcamera/ipa/vimc.mojom     | 23 ++++++++++++++-\n src/ipa/vimc/vimc.cpp                | 42 +++++++++++++++++++++++++++-\n src/libcamera/pipeline/vimc/vimc.cpp | 27 ++++++++++++++++++\n 3 files changed, 90 insertions(+), 2 deletions(-)","diff":"diff --git a/include/libcamera/ipa/vimc.mojom b/include/libcamera/ipa/vimc.mojom\nindex 8452461d..85a87227 100644\n--- a/include/libcamera/ipa/vimc.mojom\n+++ b/include/libcamera/ipa/vimc.mojom\n@@ -17,6 +17,25 @@ enum IPATraceCode {\n \tIPATraceStop,\n };\n \n+enum VimcOperations {\n+        ActionParamFilled = 1,\n+        EventFillParams = 2,\n+        EventProcessControls = 3,\n+};\n+\n+struct VimcEvent {\n+        VimcOperations op;\n+        uint32 frame;\n+        int64 frameTimestamp;\n+        uint32 bufferId;\n+        libcamera.ControlList controls;\n+};\n+\n+struct VimcAction {\n+        VimcOperations op;\n+        libcamera.ControlList controls;\n+};\n+\n interface IPAVimcInterface {\n \tinit(libcamera.IPASettings settings) => (int32 ret);\n \n@@ -29,8 +48,10 @@ interface IPAVimcInterface {\n \n \tmapBuffers(array<libcamera.IPABuffer> buffers);\n \tunmapBuffers(array<uint32> ids);\n+\n+\t[async] processEvent(VimcEvent ev);\n };\n \n interface IPAVimcEventInterface {\n-\tdummyEvent(uint32 val);\n+\tqueueFrameAction(uint32 frame, VimcAction action);\n };\ndiff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp\nindex 2b00687f..784d7993 100644\n--- a/src/ipa/vimc/vimc.cpp\n+++ b/src/ipa/vimc/vimc.cpp\n@@ -25,6 +25,8 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(IPAVimc)\n \n+namespace ipa::vimc {\n+\n class IPAVimc : public ipa::vimc::IPAVimcInterface\n {\n public:\n@@ -43,7 +45,11 @@ public:\n \tvoid mapBuffers(const std::vector<IPABuffer> &buffers) override;\n \tvoid unmapBuffers(const std::vector<unsigned int> &ids) override;\n \n+\tvoid processEvent(const VimcEvent &event) override;\n+\n private:\n+\tvoid processControls(unsigned int frame, const ControlList &controls);\n+\n \tvoid initTrace();\n \tvoid trace(enum ipa::vimc::IPATraceCode operation);\n \n@@ -125,6 +131,38 @@ void IPAVimc::unmapBuffers(const std::vector<unsigned int> &ids)\n \t}\n }\n \n+void IPAVimc::processControls([[maybe_unused]] unsigned int frame,\n+\t\t\t      [[maybe_unused]] const ControlList &controls)\n+{\n+        /* \\todo Start processing for 'frame' based on 'controls'. */\n+}\n+\n+void IPAVimc::processEvent(const VimcEvent &event)\n+{\n+\tswitch (event.op) {\n+\tcase EventFillParams: {\n+\t\tauto it = buffers_.find(event.bufferId);\n+\t\tif (it == buffers_.end()) {\n+\t\t\tLOG(IPAVimc, Error) << \"Could not find param buffer!\";\n+\t\t\treturn;\n+\t\t}\n+\n+\t\t/* \\todo Fill parameters with actual parameter buffer */\n+\t\tVimcAction op;\n+\t\top.op = ActionParamFilled;\n+\t\tqueueFrameAction.emit(event.frame, op);\n+\t\tbreak;\n+\t}\n+\tcase EventProcessControls: {\n+\t\tprocessControls(event.frame, event.controls);\n+\t\tbreak;\n+\t}\n+\tdefault:\n+\t\tLOG(IPAVimc, Error) << \"Unknown event \" << event.op;\n+\t\tbreak;\n+\t}\n+}\n+\n void IPAVimc::initTrace()\n {\n \tstruct stat fifoStat;\n@@ -156,6 +194,8 @@ void IPAVimc::trace(enum ipa::vimc::IPATraceCode operation)\n \t}\n }\n \n+} /* namespace ipa::vimc */\n+\n /*\n  * External IPA module interface\n  */\n@@ -170,7 +210,7 @@ const struct IPAModuleInfo ipaModuleInfo = {\n \n IPAInterface *ipaCreate()\n {\n-\treturn new IPAVimc();\n+\treturn new ipa::vimc::IPAVimc();\n }\n }\n \ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex fa21128d..4b7a542d 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -51,6 +51,8 @@ public:\n \n \tint init();\n \tvoid bufferReady(FrameBuffer *buffer);\n+\tvoid queueFrameAction(unsigned int id,\n+\t\t\t      const ipa::vimc::VimcAction &action);\n \n \tMediaDevice *media_;\n \tstd::unique_ptr<CameraSensor> sensor_;\n@@ -438,6 +440,12 @@ int PipelineHandlerVimc::queueRequestDevice(Camera *camera, Request *request)\n \tif (ret < 0)\n \t\treturn ret;\n \n+\tipa::vimc::VimcEvent ev;\n+\tev.op = ipa::vimc::EventProcessControls;\n+\tev.frame = request->sequence();\n+\tev.controls = request->controls();\n+\tdata->ipa_->processEvent(ev);\n+\n \treturn 0;\n }\n \n@@ -471,6 +479,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \t}\n \n+\tdata->ipa_->queueFrameAction.connect(data.get(), &VimcCameraData::queueFrameAction);\n+\n \tstd::string conf = data->ipa_->configurationFile(\"vimc.conf\");\n \tdata->ipa_->init(IPASettings{ conf, data->sensor_->model() });\n \n@@ -569,6 +579,23 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n \n \tpipe_->completeBuffer(request, buffer);\n \tpipe_->completeRequest(request);\n+\n+\tipa::vimc::VimcEvent ev;\n+\tev.op = ipa::vimc::EventFillParams;\n+\tev.frame = request->sequence();\n+\tev.bufferId = buffer->cookie();\n+\tipa_->processEvent(ev);\n+}\n+\n+void VimcCameraData::queueFrameAction([[maybe_unused]] unsigned int id,\n+\t\t\t\t      const ipa::vimc::VimcAction &action)\n+{\n+\tswitch (action.op) {\n+\tcase ipa::vimc::ActionParamFilled:\n+\t\tbreak;\n+\tdefault:\n+\t\tLOG(VIMC, Error) << \"unknown action: \" << action.op;\n+\t}\n }\n \n REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc)\n","prefixes":["libcamera-devel","4/4"]}