[libcamera-devel] [PATCH 08/15] v4l2: v4l2_camera: Re-validate configuration after adjusted

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Jun 17 03:10:39 CEST 2020


Hi Paul,

Thank you for the patch.

On Tue, Jun 16, 2020 at 10:12:37PM +0900, Paul Elder wrote:
> If the camera configuration has been adjusted, validate it again to
> ensure that it's valid, before configuring the camera with it.

This shouldn't be needed, an adjusted configuration is supposed to be
valid. If that's not the case, it's a bug in the pipeline handler (in
which case a unit test should be added to catch this, in addition to
fixing the bug).

> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
> ---
>  src/v4l2/v4l2_camera.cpp | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp
> index 2557320..fdbf461 100644
> --- a/src/v4l2/v4l2_camera.cpp
> +++ b/src/v4l2/v4l2_camera.cpp
> @@ -119,11 +119,18 @@ int V4L2Camera::configure(StreamConfiguration *streamConfigOut,
>  		LOG(V4L2Compat, Debug) << "Configuration invalid";
>  		return -EINVAL;
>  	}
> -	if (validation == CameraConfiguration::Adjusted)
> +	if (validation == CameraConfiguration::Adjusted) {
>  		LOG(V4L2Compat, Debug) << "Configuration adjusted";
> +		validation = config_->validate();
> +		if (validation != CameraConfiguration::Valid) {
> +			LOG(V4L2Compat, Error)
> +				<< "Configuration adjusted but not valid";
> +			return -EINVAL;
> +		}
> +	}
>  
> -	LOG(V4L2Compat, Debug) << "Validated configuration is: "
> -			      << streamConfig.toString();
> +	LOG(V4L2Compat, Debug)
> +		<< "Validated configuration is: " << streamConfig.toString();
>  
>  	int ret = camera_->configure(config_.get());
>  	if (ret < 0)

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list