From 68e65da0ccc8308ba3d87b1522d77b36c54efae7 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Tue, 21 Apr 2020 23:39:53 +0300 Subject: libcamera: pipeline: simple: Make sure the formats at the link's pads match Change SimpleCameraData::setupFormats() to return -EINVAL if the sink pad of the link doesn't support the format set on the source pad of this link. Signed-off-by: Andrey Konovalov Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index b1814b08..c2498d4e 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -388,10 +388,24 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, } if (sink->entity()->function() != MEDIA_ENT_F_IO_V4L) { + V4L2SubdeviceFormat sourceFormat = *format; + V4L2Subdevice *subdev = pipe->subdev(sink->entity()); ret = subdev->setFormat(sink->index(), format, whence); if (ret < 0) return ret; + + if (format->mbus_code != sourceFormat.mbus_code || + format->size != sourceFormat.size) { + LOG(SimplePipeline, Debug) + << "Source '" << source->entity()->name() + << "':" << source->index() + << " produces " << sourceFormat.toString() + << ", sink '" << sink->entity()->name() + << "':" << sink->index() + << " requires " << format->toString(); + return -EINVAL; + } } LOG(SimplePipeline, Debug) -- cgit v1.2.1