[libcamera-devel] [PATCH 2/4] libcamera: pipeline: uvcvideo: enforce stream configuration

Niklas Söderlund niklas.soderlund at ragnatech.se
Thu Feb 21 00:59:37 CET 2019


The format requested by configureStreams() should exactly match what
programmed on the video device it self. If they do not match the call
should fail as the application in that case will not know what
configuration actually was programmed.

Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
 src/libcamera/pipeline/uvcvideo.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index 37a3477c2c56f3ea..b7b8ff109109e9c5 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -84,6 +84,7 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,
 					 std::map<Stream *, StreamConfiguration> &config)
 {
 	StreamConfiguration *cfg = &config[&stream_];
+	int ret;
 
 	LOG(UVC, Debug) << "Configure the camera for resolution "
 			<< cfg->width << "x" << cfg->height;
@@ -93,7 +94,16 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,
 	format.height = cfg->height;
 	format.fourcc = cfg->pixelFormat;
 
-	return video_->setFormat(&format);
+	ret = video_->setFormat(&format);
+	if (ret)
+		return ret;
+
+	if (format.width != cfg->width ||
+	    format.height != cfg->height ||
+	    format.fourcc != cfg->pixelFormat)
+		return -EINVAL;
+
+	return 0;
 }
 
 int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)
-- 
2.20.1



More information about the libcamera-devel mailing list