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 <andrey.konovalov@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Andrey Konovalov 2020-04-21 23:39:53 +03:00 committed by Laurent Pinchart
parent 7283eff090
commit 68e65da0cc

View file

@ -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)