[libcamera-devel] [PATCH 15/17] cam: Validate camera configuration

Kieran Bingham kieran.bingham at ideasonboard.com
Thu May 30 10:27:26 CEST 2019


Hi Niklas,

On 27/05/2019 01:15, Niklas Söderlund wrote:
> Use CameraConfiguration::validate() to validate and possibly update the
> camera configuration when its prepared.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
>  src/cam/main.cpp | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index 338740d1512c7189..25538f5ba95552d6 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -236,6 +236,18 @@ int CamApp::prepareConfig()
>  		}
>  	}
>  
> +	switch (config_->validate()) {
> +	case CameraConfiguration::Valid:
> +		break;
> +	case CameraConfiguration::Adjusted:
> +		std::cout << "Camera configuration adjusted" << std::endl;
> +		break;
> +	case CameraConfiguration::Invalid:
> +		std::cout << "Camera configuration invalid" << std::endl;
> +		config_.reset();
> +		return -EINVAL;

Part of me is screaming where's the 'default:' option for the switch
here - but I don't think it makes sense at all. What would the default
option be ... except an error...

And fortunately the compiler yells at us if we don't support all
enumeration values in the statement.

So - LGTM.

Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>


> +	}
> +
>  	return 0;
>  }
>  
> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list