[2/3] libcamera: camera_sensor: Extend reporting in getFormat()
diff mbox series

Message ID 20250501141609.717148-3-kieran.bingham@ideasonboard.com
State New
Headers show
Series
  • libcamera: rkisp1: Camera Sensor Mode Validation
Related show

Commit Message

Kieran Bingham May 1, 2025, 2:16 p.m. UTC
When a pipeline handler asks the CameraSensor for a format, which is not
achievable, it can be very helpful to the user to identify what size was
requested and why it could not be provided within any constrained
maximum size.

This can make otherwise difficult to diagnose user errors visible and
quickly correctable.

Both of the CameraSensorRaw and CameraSensorLegacy are updated
accordingly but that likely means these two classes could soon benefit
from a more common base class to share otherwise identical code.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/sensor/camera_sensor_legacy.cpp | 4 +++-
 src/libcamera/sensor/camera_sensor_raw.cpp    | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

Comments

Jacopo Mondi May 2, 2025, 8:23 a.m. UTC | #1
Hi Kieran

On Thu, May 01, 2025 at 03:16:08PM +0100, Kieran Bingham wrote:
> When a pipeline handler asks the CameraSensor for a format, which is not
> achievable, it can be very helpful to the user to identify what size was
> requested and why it could not be provided within any constrained
> maximum size.
>
> This can make otherwise difficult to diagnose user errors visible and
> quickly correctable.
>
> Both of the CameraSensorRaw and CameraSensorLegacy are updated
> accordingly but that likely means these two classes could soon benefit
> from a more common base class to share otherwise identical code.
>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Certainly doesn't hurt

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> ---
>  src/libcamera/sensor/camera_sensor_legacy.cpp | 4 +++-
>  src/libcamera/sensor/camera_sensor_raw.cpp    | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp
> index 32989c19c019..20275f3bb1b2 100644
> --- a/src/libcamera/sensor/camera_sensor_legacy.cpp
> +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp
> @@ -742,7 +742,9 @@ CameraSensorLegacy::getFormat(const std::vector<unsigned int> &mbusCodes,
>  	}
>
>  	if (!bestSize) {
> -		LOG(CameraSensor, Debug) << "No supported format or size found";
> +		LOG(CameraSensor, Warning)
> +			<< "No supported format or size found. Requested "
> +			<< size << " with a maximum size " << maxSize;
>  		return {};
>  	}
>
> diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp
> index ab75b1f8204c..07d1e2bfa600 100644
> --- a/src/libcamera/sensor/camera_sensor_raw.cpp
> +++ b/src/libcamera/sensor/camera_sensor_raw.cpp
> @@ -800,7 +800,9 @@ CameraSensorRaw::getFormat(const std::vector<unsigned int> &mbusCodes,
>  	}
>
>  	if (!bestSize) {
> -		LOG(CameraSensor, Debug) << "No supported format or size found";
> +		LOG(CameraSensor, Warning)
> +			<< "No supported format or size found. Requested "
> +			<< size << " with a maximum size " << maxSize;
>  		return {};
>  	}
>
> --
> 2.48.1
>

Patch
diff mbox series

diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp
index 32989c19c019..20275f3bb1b2 100644
--- a/src/libcamera/sensor/camera_sensor_legacy.cpp
+++ b/src/libcamera/sensor/camera_sensor_legacy.cpp
@@ -742,7 +742,9 @@  CameraSensorLegacy::getFormat(const std::vector<unsigned int> &mbusCodes,
 	}
 
 	if (!bestSize) {
-		LOG(CameraSensor, Debug) << "No supported format or size found";
+		LOG(CameraSensor, Warning)
+			<< "No supported format or size found. Requested "
+			<< size << " with a maximum size " << maxSize;
 		return {};
 	}
 
diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp
index ab75b1f8204c..07d1e2bfa600 100644
--- a/src/libcamera/sensor/camera_sensor_raw.cpp
+++ b/src/libcamera/sensor/camera_sensor_raw.cpp
@@ -800,7 +800,9 @@  CameraSensorRaw::getFormat(const std::vector<unsigned int> &mbusCodes,
 	}
 
 	if (!bestSize) {
-		LOG(CameraSensor, Debug) << "No supported format or size found";
+		LOG(CameraSensor, Warning)
+			<< "No supported format or size found. Requested "
+			<< size << " with a maximum size " << maxSize;
 		return {};
 	}