From patchwork Tue Feb 5 00:07:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 508 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E38D60DC9 for ; Tue, 5 Feb 2019 01:07:58 +0100 (CET) X-Halon-ID: 168d0373-28da-11e9-b530-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from localhost.localdomain (unknown [81.164.19.127]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 168d0373-28da-11e9-b530-005056917a89; Tue, 05 Feb 2019 01:07:56 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Feb 2019 01:07:00 +0100 Message-Id: <20190205000702.15370-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190205000702.15370-1-niklas.soderlund@ragnatech.se> References: <20190205000702.15370-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 5/7] libcamera: pipeline: uvcvideo: add allocateBuffers and freeBuffers 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: Tue, 05 Feb 2019 00:07:58 -0000 Allow the UVC pipeline to allocate and free buffers for the single stream attached to the camera. The buffers are allocated and freed utilising the V4L2Device requestBuffers() and releaseBuffers() interface. Signed-off-by: Niklas Söderlund --- src/libcamera/pipeline/uvcvideo.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 8b3f0ce7e2112564..3685dbf9d19c3d7d 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -96,12 +96,21 @@ std::map PipelineHandlerUVC::allocateBuffers(Camera *camera, std::map &config) { - return std::map {}; + StreamConfiguration *cfg = &config[&stream_]; + + LOG(UVC, Debug) << "Requesting " << cfg->bufferCount << " buffers"; + + BufferPool *pool = video_->requestBuffers(cfg->bufferCount); + + if (!pool) + LOG(UVC, Error) << "Failed to acquire a buffer pool"; + + return std::map { {&stream_, pool} }; } int PipelineHandlerUVC::freeBuffers(Camera *camera) { - return 0; + return video_->releaseBuffers(); } int PipelineHandlerUVC::start(const Camera *camera)