[libcamera-devel] [PATCH 20/27] libcamera: pipeline: uvcvideo: Implement capture support

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Feb 6 07:08:11 CET 2019


From: Kieran Bingham <kieran.bingham at ideasonboard.com>

Replace the buffer allocation, capture start/stop and request queue
stubs with real implementations.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 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 <libcamera/camera.h>
+#include <libcamera/request.h>
 #include <libcamera/stream.h>
 
 #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;
 }
 
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list