libcamera: pipeline: uvcvideo: enforce stream configuration
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 <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
9a37b4c5a8
commit
facb80bc5c
1 changed files with 11 additions and 1 deletions
|
@ -84,6 +84,7 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,
|
||||||
std::map<Stream *, StreamConfiguration> &config)
|
std::map<Stream *, StreamConfiguration> &config)
|
||||||
{
|
{
|
||||||
StreamConfiguration *cfg = &config[&stream_];
|
StreamConfiguration *cfg = &config[&stream_];
|
||||||
|
int ret;
|
||||||
|
|
||||||
LOG(UVC, Debug) << "Configure the camera for resolution "
|
LOG(UVC, Debug) << "Configure the camera for resolution "
|
||||||
<< cfg->width << "x" << cfg->height;
|
<< cfg->width << "x" << cfg->height;
|
||||||
|
@ -93,7 +94,16 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,
|
||||||
format.height = cfg->height;
|
format.height = cfg->height;
|
||||||
format.fourcc = cfg->pixelFormat;
|
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)
|
int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue