From patchwork Fri Aug 6 10:14:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13247 X-Patchwork-Delegate: umang.jain@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9C9BAC323B for ; Fri, 6 Aug 2021 10:14:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2EC7A6884F; Fri, 6 Aug 2021 12:14:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Inl9iKrK"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C409868811 for ; Fri, 6 Aug 2021 12:14:36 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.40]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A25EDFA; Fri, 6 Aug 2021 12:14:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628244876; bh=1Jfde0KjsGzWfgxecrTZKjNvFdbRyw3tqfwXITxibjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Inl9iKrK0zm2LQGz/6Sm6qOI/p5nVn8tW5FDA2+w8J+MbYoK3avsWReqz0Yqh9zMY XuYibJd5oR3zr4ZfMAh2wP+D3pS5Jttn7MPtaOsjVwsn8/vSJ88ID/X+UnQsTfGgCY kBt9AOgyhI8sFnPH/hbzcKiRYx9UTlwRimbumYns= From: Umang Jain 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 Subject: [libcamera-devel] [PATCH 4/4] ipa: vimc: Send and retrieve FrameBuffers from IPA X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Plumb through actions and events in the VIMC mojo interface. Events are send from pipeline handler to IPA and actions can be emitted from IPA and handled in the pipeline handler. The plumbing ensures that, we can send/retrieve FrameBuffers from the vimc IPA. Signed-off-by: Umang Jain --- include/libcamera/ipa/vimc.mojom | 23 ++++++++++++++- src/ipa/vimc/vimc.cpp | 42 +++++++++++++++++++++++++++- src/libcamera/pipeline/vimc/vimc.cpp | 27 ++++++++++++++++++ 3 files changed, 90 insertions(+), 2 deletions(-) diff --git a/include/libcamera/ipa/vimc.mojom b/include/libcamera/ipa/vimc.mojom index 8452461d..85a87227 100644 --- a/include/libcamera/ipa/vimc.mojom +++ b/include/libcamera/ipa/vimc.mojom @@ -17,6 +17,25 @@ enum IPATraceCode { IPATraceStop, }; +enum VimcOperations { + ActionParamFilled = 1, + EventFillParams = 2, + EventProcessControls = 3, +}; + +struct VimcEvent { + VimcOperations op; + uint32 frame; + int64 frameTimestamp; + uint32 bufferId; + libcamera.ControlList controls; +}; + +struct VimcAction { + VimcOperations op; + libcamera.ControlList controls; +}; + interface IPAVimcInterface { init(libcamera.IPASettings settings) => (int32 ret); @@ -29,8 +48,10 @@ interface IPAVimcInterface { mapBuffers(array buffers); unmapBuffers(array ids); + + [async] processEvent(VimcEvent ev); }; interface IPAVimcEventInterface { - dummyEvent(uint32 val); + queueFrameAction(uint32 frame, VimcAction action); }; diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index 2b00687f..784d7993 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -25,6 +25,8 @@ namespace libcamera { LOG_DEFINE_CATEGORY(IPAVimc) +namespace ipa::vimc { + class IPAVimc : public ipa::vimc::IPAVimcInterface { public: @@ -43,7 +45,11 @@ public: void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; + void processEvent(const VimcEvent &event) override; + private: + void processControls(unsigned int frame, const ControlList &controls); + void initTrace(); void trace(enum ipa::vimc::IPATraceCode operation); @@ -125,6 +131,38 @@ void IPAVimc::unmapBuffers(const std::vector &ids) } } +void IPAVimc::processControls([[maybe_unused]] unsigned int frame, + [[maybe_unused]] const ControlList &controls) +{ + /* \todo Start processing for 'frame' based on 'controls'. */ +} + +void IPAVimc::processEvent(const VimcEvent &event) +{ + switch (event.op) { + case EventFillParams: { + auto it = buffers_.find(event.bufferId); + if (it == buffers_.end()) { + LOG(IPAVimc, Error) << "Could not find param buffer!"; + return; + } + + /* \todo Fill parameters with actual parameter buffer */ + VimcAction op; + op.op = ActionParamFilled; + queueFrameAction.emit(event.frame, op); + break; + } + case EventProcessControls: { + processControls(event.frame, event.controls); + break; + } + default: + LOG(IPAVimc, Error) << "Unknown event " << event.op; + break; + } +} + void IPAVimc::initTrace() { struct stat fifoStat; @@ -156,6 +194,8 @@ void IPAVimc::trace(enum ipa::vimc::IPATraceCode operation) } } +} /* namespace ipa::vimc */ + /* * External IPA module interface */ @@ -170,7 +210,7 @@ const struct IPAModuleInfo ipaModuleInfo = { IPAInterface *ipaCreate() { - return new IPAVimc(); + return new ipa::vimc::IPAVimc(); } } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index fa21128d..4b7a542d 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -51,6 +51,8 @@ public: int init(); void bufferReady(FrameBuffer *buffer); + void queueFrameAction(unsigned int id, + const ipa::vimc::VimcAction &action); MediaDevice *media_; std::unique_ptr sensor_; @@ -438,6 +440,12 @@ int PipelineHandlerVimc::queueRequestDevice(Camera *camera, Request *request) if (ret < 0) return ret; + ipa::vimc::VimcEvent ev; + ev.op = ipa::vimc::EventProcessControls; + ev.frame = request->sequence(); + ev.controls = request->controls(); + data->ipa_->processEvent(ev); + return 0; } @@ -471,6 +479,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) return false; } + data->ipa_->queueFrameAction.connect(data.get(), &VimcCameraData::queueFrameAction); + std::string conf = data->ipa_->configurationFile("vimc.conf"); data->ipa_->init(IPASettings{ conf, data->sensor_->model() }); @@ -569,6 +579,23 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer) pipe_->completeBuffer(request, buffer); pipe_->completeRequest(request); + + ipa::vimc::VimcEvent ev; + ev.op = ipa::vimc::EventFillParams; + ev.frame = request->sequence(); + ev.bufferId = buffer->cookie(); + ipa_->processEvent(ev); +} + +void VimcCameraData::queueFrameAction([[maybe_unused]] unsigned int id, + const ipa::vimc::VimcAction &action) +{ + switch (action.op) { + case ipa::vimc::ActionParamFilled: + break; + default: + LOG(VIMC, Error) << "unknown action: " << action.op; + } } REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc)