From facb80bc5cd0e4f6e4e71ba915c1befa6e3fd73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Thu, 21 Feb 2019 00:07:05 +0100 Subject: libcamera: pipeline: uvcvideo: enforce stream configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The format requested by configureStreams() should exactly match what is programmed on the video device. If they do not match the call should fail as the application in that case will not know what configuration was actually programmed. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- 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 37a3477c..b7b8ff10 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -84,6 +84,7 @@ int PipelineHandlerUVC::configureStreams(Camera *camera, std::map &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) -- cgit v1.2.1