From patchwork Sat Aug 14 05:09:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13356 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 8B787BD87D for ; Sat, 14 Aug 2021 05:09:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 43C5A68893; Sat, 14 Aug 2021 07:09:32 +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="rfBq1epA"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A802968891 for ; Sat, 14 Aug 2021 07:09:30 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.70]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A7A623E5; Sat, 14 Aug 2021 07:09:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628917770; bh=oQ1q0UJSctsG617etS52rZEGQn1xPZrsfidpYHZoOlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rfBq1epAbxzbFkW6ze4NTlOepOttAjx5twXesjbChHwU7woZKfxnoZ64nnSyjp158 9HDPkKVobMpRF9crB7QlsSE4u1JEDVj1zBKLVRyehVm2vapib9KchMV8AxiSx5o4QO fxSYQLTCrxbS6LGrO9zfmO1+J5nvN+CX6BLER7WE= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Sat, 14 Aug 2021 10:39:11 +0530 Message-Id: <20210814050912.15113-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210814050912.15113-1-umang.jain@ideasonboard.com> References: <20210814050912.15113-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/vimc.mojom | 3 +++ src/ipa/vimc/vimc.cpp | 27 +++++++++++++++++++++++++++ src/libcamera/pipeline/vimc/vimc.cpp | 15 +++++++++++++++ 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 fb134084..7d9d22d0 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,27 @@ 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(std::piecewise_construct, + std::forward_as_tuple(buffer.id), + std::forward_as_tuple(&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 2dfa1418..b08325c2 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -334,6 +334,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; + std::vector ipaBuffers; + for (auto [i, buffer] : utils::enumerate(data->mockIPABufs_)) { + buffer->setCookie(ipaBufferId++); + ipaBuffers.emplace_back(buffer->cookie(), buffer->planes()); + } + data->ipa_->mapBuffers(ipaBuffers); + ret = data->ipa_->start(); if (ret) { data->video_->releaseBuffers(); @@ -354,7 +363,13 @@ void PipelineHandlerVimc::stop(Camera *camera) { VimcCameraData *data = cameraData(camera); data->video_->streamOff(); + + std::vector ids; + for (const std::unique_ptr &buffer : data->mockIPABufs_) + ids.push_back(buffer->cookie()); + data->ipa_->unmapBuffers(ids); data->ipa_->stop(); + data->video_->releaseBuffers(); }