[libcamera-devel,1/1] camera_sensor: Suppress error message if test patterns are unavailable
diff mbox series

Message ID 20220606085825.1145654-2-naush@raspberrypi.com
State Accepted
Commit 7ee7dc3369ebf26d142b6352cb3d309f48600433
Headers show
Series
  • Suppress test pattern error message
Related show

Commit Message

Naushir Patuck June 6, 2022, 8:58 a.m. UTC
If a sensor driver does not support test patterns (e.g. IMX477), libcamera
throws an unnecessary error message during initialisation when it sets the test
pattern to off.

Fix this by moving the error message into setTestPatternMode() where the
pipeline handler explicitly requests to set a test pattern.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/libcamera/camera_sensor.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Laurent Pinchart June 6, 2022, 9:12 a.m. UTC | #1
Hi Naush,

Thank you for the patch.

On Mon, Jun 06, 2022 at 09:58:25AM +0100, Naushir Patuck via libcamera-devel wrote:
> If a sensor driver does not support test patterns (e.g. IMX477), libcamera
> throws an unnecessary error message during initialisation when it sets the test
> pattern to off.
> 
> Fix this by moving the error message into setTestPatternMode() where the
> pipeline handler explicitly requests to set a test pattern.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/camera_sensor.cpp | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index 4bb2066f0fd4..d055c16a4885 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -582,16 +582,19 @@ int CameraSensor::setTestPatternMode(controls::draft::TestPatternModeEnum mode)
>  	if (testPatternMode_ == mode)
>  		return 0;
>  
> +	if (testPatternModes_.empty()) {
> +		LOG(CameraSensor, Error)
> +			<< "Camera sensor does not support test pattern modes.";
> +		return -EINVAL;
> +	}
> +
>  	return applyTestPatternMode(mode);
>  }
>  
>  int CameraSensor::applyTestPatternMode(controls::draft::TestPatternModeEnum mode)
>  {
> -	if (testPatternModes_.empty()) {
> -		LOG(CameraSensor, Error)
> -			<< "Camera sensor does not support test pattern modes.";
> +	if (testPatternModes_.empty())
>  		return 0;
> -	}
>  
>  	auto it = std::find(testPatternModes_.begin(), testPatternModes_.end(),
>  			    mode);
Kieran Bingham June 6, 2022, 11:59 a.m. UTC | #2
Quoting Naushir Patuck via libcamera-devel (2022-06-06 09:58:25)
> If a sensor driver does not support test patterns (e.g. IMX477), libcamera
> throws an unnecessary error message during initialisation when it sets the test
> pattern to off.
> 
> Fix this by moving the error message into setTestPatternMode() where the
> pipeline handler explicitly requests to set a test pattern.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

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

> ---
>  src/libcamera/camera_sensor.cpp | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index 4bb2066f0fd4..d055c16a4885 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -582,16 +582,19 @@ int CameraSensor::setTestPatternMode(controls::draft::TestPatternModeEnum mode)
>         if (testPatternMode_ == mode)
>                 return 0;
>  
> +       if (testPatternModes_.empty()) {
> +               LOG(CameraSensor, Error)
> +                       << "Camera sensor does not support test pattern modes.";
> +               return -EINVAL;
> +       }
> +
>         return applyTestPatternMode(mode);
>  }
>  
>  int CameraSensor::applyTestPatternMode(controls::draft::TestPatternModeEnum mode)
>  {
> -       if (testPatternModes_.empty()) {
> -               LOG(CameraSensor, Error)
> -                       << "Camera sensor does not support test pattern modes.";
> +       if (testPatternModes_.empty())
>                 return 0;
> -       }
>  
>         auto it = std::find(testPatternModes_.begin(), testPatternModes_.end(),
>                             mode);
> -- 
> 2.34.1
>

Patch
diff mbox series

diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 4bb2066f0fd4..d055c16a4885 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -582,16 +582,19 @@  int CameraSensor::setTestPatternMode(controls::draft::TestPatternModeEnum mode)
 	if (testPatternMode_ == mode)
 		return 0;
 
+	if (testPatternModes_.empty()) {
+		LOG(CameraSensor, Error)
+			<< "Camera sensor does not support test pattern modes.";
+		return -EINVAL;
+	}
+
 	return applyTestPatternMode(mode);
 }
 
 int CameraSensor::applyTestPatternMode(controls::draft::TestPatternModeEnum mode)
 {
-	if (testPatternModes_.empty()) {
-		LOG(CameraSensor, Error)
-			<< "Camera sensor does not support test pattern modes.";
+	if (testPatternModes_.empty())
 		return 0;
-	}
 
 	auto it = std::find(testPatternModes_.begin(), testPatternModes_.end(),
 			    mode);