[libcamera-devel,RFC,5/7] libcamera: pipeline: uvcvideo: add allocateBuffers and freeBuffers support

Message ID 20190205000702.15370-6-niklas.soderlund@ragnatech.se
State Superseded
Delegated to: Niklas Söderlund
Headers show
Series
  • libcamera: extend camera and pipeline to support requests
Related show

Commit Message

Niklas Söderlund Feb. 5, 2019, 12:07 a.m. UTC
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 <niklas.soderlund@ragnatech.se>
---
 src/libcamera/pipeline/uvcvideo.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Patch

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<Stream *, BufferPool *>
 PipelineHandlerUVC::allocateBuffers(Camera *camera,
 				    std::map<Stream *, StreamConfiguration> &config)
 {
-	return std::map<Stream *, BufferPool *> {};
+	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 *, BufferPool *> { {&stream_, pool} };
 }
 
 int PipelineHandlerUVC::freeBuffers(Camera *camera)
 {
-	return 0;
+	return video_->releaseBuffers();
 }
 
 int PipelineHandlerUVC::start(const Camera *camera)