[libcamera-devel] [RFC 5/7] libcamera: pipeline: uvcvideo: add allocateBuffers and freeBuffers support
Niklas Söderlund
niklas.soderlund at ragnatech.se
Tue Feb 5 01:07:00 CET 2019
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 at ragnatech.se>
---
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<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)
--
2.20.1
More information about the libcamera-devel
mailing list