From patchwork Wed Feb 6 06:08:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 535 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E12B61048 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 0B43F2D9 for ; Wed, 6 Feb 2019 07:08:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1549433308; bh=RKXY6CJrIGea4sPWYGzQGXfcjVU1phDzf+yLipwbUn4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HWX91i+mybB7eTstLxl6F9ejWKZ2uWVNXFfTe9I8XN0m4ICsB7Rh0yji0gXrPpjDz 9ezBIjxhAgMkgKDi8Uf6v3TraA7/g91P7Byt7h/VzofxnZ2hlE2OE+MmedsuIgVsY4 MKo/A4nASObhqaxHQb245XcuftNIT2z7TmKQnhDc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Feb 2019 08:08:11 +0200 Message-Id: <20190206060818.13907-21-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 20/27] libcamera: pipeline: uvcvideo: 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: Kieran Bingham Replace the buffer allocation, capture start/stop and request queue stubs with real implementations. Signed-off-by: Kieran Bingham Signed-off-by: Niklas Söderlund Signed-off-by: Jacopo Mondi Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/uvcvideo.cpp | 35 ++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 74bdf5c5aea5..fc31c52c0ecd 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include "device_enumerator.h" @@ -84,35 +85,53 @@ int PipelineHandlerUVC::configureStreams(Camera *camera, { StreamConfiguration *cfg = &config[&stream_]; - LOG(UVC, Info) << "TODO: Configure the camera for resolution " - << cfg->width << "x" << cfg->height; + LOG(UVC, 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 PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream) { - return -ENOTRECOVERABLE; + const StreamConfiguration &cfg = stream->configuration(); + + LOG(UVC, Debug) << "Requesting " << cfg.bufferCount << " buffers"; + + return video_->exportBuffers(cfg.bufferCount, &stream->bufferPool()); } int PipelineHandlerUVC::freeBuffers(Camera *camera, Stream *stream) { - return 0; + return video_->releaseBuffers(); } int PipelineHandlerUVC::start(const Camera *camera) { - LOG(UVC, Error) << "TODO: start camera"; - return 0; + return video_->streamOn(); } void PipelineHandlerUVC::stop(const Camera *camera) { - LOG(UVC, Error) << "TODO: stop camera"; + video_->streamOff(); } int PipelineHandlerUVC::queueRequest(const Camera *camera, Request *request) { + Buffer *buffer = request->findBuffer(&stream_); + if (!buffer) { + LOG(UVC, Error) + << "Attempt to queue request with invalid stream"; + + return -ENOENT; + } + + video_->queueBuffer(buffer); + return 0; }