From patchwork Wed Feb 6 06:08:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 537 Return-Path: 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 CFBB76104A for ; Wed, 6 Feb 2019 07:08:28 +0100 (CET) Received: from pendragon.ideasonboard.com (d51A4137F.access.telenet.be [81.164.19.127]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7C8A62D9 for ; Wed, 6 Feb 2019 07:08:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1549433308; bh=5JOE8bvH20QvrILDhnKB9gtX6Y5bWWTSaiqR7FsSGVE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=igynAZmpVdjz5PtGfIxKtxhZyA+k7T7KoyubjPVJOQtj0uqq3nxInNEYl59QYaX58 uTwo+zQKXie0L3WSl5XwUBFVWcKvqSt9GvKGDIeRaEParAAuRETasYFnZMGiUxfbJO EcQ+qGwtxcMXpilVivJbFBy8OPwHWzhoynFutUFU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Feb 2019 08:08:13 +0200 Message-Id: <20190206060818.13907-23-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190206060818.13907-1-laurent.pinchart@ideasonboard.com> References: <20190206060818.13907-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 22/27] libcamera: pipeline: vimc: Implement capture support X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2019 06:08:30 -0000 From: Niklas Söderlund Replace the buffer allocation, capture start/stop and request queue stubs with real implementations. Signed-off-by: Niklas Söderlund Signed-off-by: Jacopo Mondi Signed-off-by: Kieran Bingham Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/vimc.cpp | 35 +++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 9c0406bef9dc..0e9ad7b59ee5 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include "device_enumerator.h" @@ -83,35 +84,53 @@ int PipeHandlerVimc::configureStreams(Camera *camera, { StreamConfiguration *cfg = &config[&stream_]; - LOG(VIMC, Info) << "TODO: Configure the camera for resolution " - << cfg->width << "x" << cfg->height; + LOG(VIMC, Debug) << "Configure the camera for resolution " + << cfg->width << "x" << cfg->height; - return 0; + V4L2DeviceFormat format = {}; + format.width = cfg->width; + format.height = cfg->height; + format.fourcc = cfg->pixelFormat; + + return video_->setFormat(&format); } int PipeHandlerVimc::allocateBuffers(Camera *camera, Stream *stream) { - return -ENOTRECOVERABLE; + const StreamConfiguration &cfg = stream->configuration(); + + LOG(VIMC, Debug) << "Requesting " << cfg.bufferCount << " buffers"; + + return video_->exportBuffers(cfg.bufferCount, &stream->bufferPool()); } int PipeHandlerVimc::freeBuffers(Camera *camera, Stream *stream) { - return 0; + return video_->releaseBuffers(); } int PipeHandlerVimc::start(const Camera *camera) { - LOG(VIMC, Error) << "TODO: start camera"; - return 0; + return video_->streamOn(); } void PipeHandlerVimc::stop(const Camera *camera) { - LOG(VIMC, Error) << "TODO: stop camera"; + video_->streamOff(); } int PipeHandlerVimc::queueRequest(const Camera *camera, Request *request) { + Buffer *buffer = request->findBuffer(&stream_); + if (!buffer) { + LOG(VIMC, Error) + << "Attempt to queue request with invalid stream"; + + return -ENOENT; + } + + video_->queueBuffer(buffer); + return 0; }