From patchwork Sat Aug 14 05:09:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13355 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 39059BD87D for ; Sat, 14 Aug 2021 05:09:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E4DE86888D; Sat, 14 Aug 2021 07:09:29 +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="St6910U/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B56BA68892 for ; Sat, 14 Aug 2021 07:09:28 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.70]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 845D73E5; Sat, 14 Aug 2021 07:09:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628917768; bh=Tee/KMPLGPgvgC9XUtav/PFtO0gUaBitMDk58DK+Kro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=St6910U/cvVao4gCZXChDnPeGuOnVXLFc8197KZH1/UTeG9A/3dHvGqS9O+rjYcSS Qj27tusBTVBDxc5Nx3+GxVB/iD8bIPMV0r7W2E54Ud4GESFiS4yeM3EzICMAEWa//g ZtLXY0SqH0D+n3W7PvluxKnoYCQqri04+SD8IJVA= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Sat, 14 Aug 2021 10:39:10 +0530 Message-Id: <20210814050912.15113-3-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 2/4] pipeline: vimc: Allocate mock IPA 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 is a virtual test driver that doesn't have statistics or parameters buffers that are typically passed from a pipeline handler to its platform IPA. To increase the test coverage going forward, we can atleast mimick the typical interaction of how a pipeline handler and IPA interacts, and use it to increase the test coverage. Hence, create simple (single plane) dmabuf-backed FrameBuffers, which can act as mock IPA buffers and can be memory mapped(mmap) to VIMC IPA. To create these buffers, temporarily hijack the output video node and configure it with a V4L2DeviceFormat. Buffers then can be exported from the output video node using V4L2VideoDevice::exportBuffers(). These buffers will be mimicked as IPA buffers in subsequent commits. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/libcamera/pipeline/vimc/vimc.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 4c92729d..2dfa1418 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -50,6 +50,7 @@ public: } int init(); + int allocateMockIPABuffers(); void bufferReady(FrameBuffer *buffer); MediaDevice *media_; @@ -61,6 +62,7 @@ public: Stream stream_; std::unique_ptr ipa_; + std::vector> mockIPABufs_; }; class VimcCameraConfiguration : public CameraConfiguration @@ -500,6 +502,12 @@ int VimcCameraData::init() if (raw_->open()) return -ENODEV; + ret = allocateMockIPABuffers(); + if (!ret) { + LOG(VIMC, Warning) << "Cannot allocate mock IPA buffers"; + return ret; + } + /* Initialise the supported controls. */ const ControlInfoMap &controls = sensor_->controls(); ControlInfoMap::Map ctrls; @@ -548,6 +556,21 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer) pipe_->completeRequest(request); } +int VimcCameraData::allocateMockIPABuffers() +{ + constexpr unsigned int kBufCount = 2; + + V4L2DeviceFormat format; + format.fourcc = video_->toV4L2PixelFormat(formats::BGR888); + format.size = Size (160, 120); + + int ret = video_->setFormat(&format); + if (ret < 0) + return ret; + + return video_->exportBuffers(kBufCount, &mockIPABufs_); +} + REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc) } /* namespace libcamera */