From patchwork Fri Aug 13 14:44:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13350 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 D7535C3240 for ; Fri, 13 Aug 2021 14:44:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9AE5E688A5; Fri, 13 Aug 2021 16:44:56 +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="oclIokAM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6241E687FA for ; Fri, 13 Aug 2021 16:44:55 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.198]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B1598F; Fri, 13 Aug 2021 16:44:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628865895; bh=8y/DyMenMBrLhvsGAGEO/13PmCyL+mKFt+zQf8b8Vpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oclIokAMqZj3VYYSemO8vVW1XbgBFtDY7cj98FxkfJicmYD+m9nbLVuedt3vOG6Qv zTayPAUCkQLGQITqRtujKYEemrohkMDZ0cyP036bp2RJMVZ/chH5HgKz8kGE1X0iC6 6u8enzFncNrbrMr3y2qZUwuV7mCWOc3FNc4cbcIo= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Fri, 13 Aug 2021 20:14:36 +0530 Message-Id: <20210813144437.138005-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210813144437.138005-1-umang.jain@ideasonboard.com> References: <20210813144437.138005-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/4] ipa: vimc: Map and unmap buffers 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" VIMC pipeline-handler have dmabuf-backed mock FrameBuffers which are specifically targetted mimicking IPA buffers(parameter and statistics). Map these mock buffers to the VIMC IPA that would enable exercising IPA IPC code paths. This will provide leverage to our test suite to test IPA IPC code paths, which are common to various platforms. Signed-off-by: Umang Jain --- include/libcamera/ipa/vimc.mojom | 3 +++ src/ipa/vimc/vimc.cpp | 26 ++++++++++++++++++++++++++ src/libcamera/pipeline/vimc/vimc.cpp | 16 ++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/include/libcamera/ipa/vimc.mojom b/include/libcamera/ipa/vimc.mojom index ee66353d..8cb240d3 100644 --- a/include/libcamera/ipa/vimc.mojom +++ b/include/libcamera/ipa/vimc.mojom @@ -26,6 +26,9 @@ interface IPAVimcInterface { start() => (int32 ret); stop(); + + mapBuffers(array buffers); + unmapBuffers(array ids); }; interface IPAVimcEventInterface { diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index 0535c740..082b2db7 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -19,6 +19,8 @@ #include #include +#include "libcamera/internal/mapped_framebuffer.h" + namespace libcamera { LOG_DEFINE_CATEGORY(IPAVimc) @@ -38,11 +40,15 @@ public: const std::map &streamConfig, const std::map &entityControls) override; + void mapBuffers(const std::vector &buffers) override; + void unmapBuffers(const std::vector &ids) override; + private: void initTrace(); void trace(enum ipa::vimc::IPAOperationCode operation); int fd_; + std::map buffers_; }; IPAVimc::IPAVimc() @@ -99,6 +105,26 @@ int IPAVimc::configure([[maybe_unused]] const IPACameraSensorInfo &sensorInfo, return 0; } +void IPAVimc::mapBuffers(const std::vector &buffers) +{ + for (const IPABuffer &buffer : buffers) { + const FrameBuffer fb(buffer.planes); + buffers_.emplace(buffer.id, + MappedFrameBuffer(&fb, MappedFrameBuffer::MapFlag::Read)); + } +} + +void IPAVimc::unmapBuffers(const std::vector &ids) +{ + for (unsigned int id : ids) { + auto it = buffers_.find(id); + if (it == buffers_.end()) + continue; + + buffers_.erase(it); + } +} + void IPAVimc::initTrace() { struct stat fifoStat; diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index edf8c58e..c44a6242 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -63,6 +63,7 @@ public: std::unique_ptr ipa_; std::vector> mockIPABufs_; + std::vector ipaBuffers_; }; class VimcCameraConfiguration : public CameraConfiguration @@ -334,6 +335,15 @@ int PipelineHandlerVimc::start(Camera *camera, [[maybe_unused]] const ControlLis if (ret < 0) return ret; + /* Map the mock IPA buffers to VIMC IPA to exercise IPC code paths */ + unsigned int ipaBufferId = 1; + for (unsigned int i = 0; i < data->mockIPABufs_.size(); i++) { + std::unique_ptr &buffer = data->mockIPABufs_[i]; + buffer->setCookie(ipaBufferId++); + data->ipaBuffers_.emplace_back(buffer->cookie(), buffer->planes()); + } + data->ipa_->mapBuffers(data->ipaBuffers_); + ret = data->ipa_->start(); if (ret) { data->video_->releaseBuffers(); @@ -354,7 +364,13 @@ void PipelineHandlerVimc::stop(Camera *camera) { VimcCameraData *data = cameraData(camera); data->video_->streamOff(); + + std::vector ids; + for (IPABuffer &ipabuf : data->ipaBuffers_) + ids.push_back(ipabuf.id); + data->ipa_->unmapBuffers(ids); data->ipa_->stop(); + data->video_->releaseBuffers(); }