libcamera: rkisp1: Ensure a raw format is found with sensorConfig
diff mbox series

Message ID 20261112141214.976332-1-jacopo.mondi@ideasonboard.com
State New
Headers show
Series
  • libcamera: rkisp1: Ensure a raw format is found with sensorConfig
Related show

Commit Message

Jacopo Mondi Nov. 12, 2026, 2:12 p.m. UTC
The RkISP1Path::validate() function walks the list of all available
formats at the ISP output to ensure the supplied StreamConfiguration
has a valid pixelformat, or adjust it a supported one in case it
doesn't.

When a sensorConfig is specified, the selection of the sensor format is
restricted by the attributes of the supplied sensorConfig itself and the
presence of a valid rawFormat is required in the rest of the function.

Currently, whenever a valid pixel format is found, the loop is
interrupted, risking the rawFormat variable to remain non initialized.

This causes the validate() function to bail out if a sensor config is
specified.

So far the issue when unnoticed as 10bits and 12bits raw format are
enumerated, by chance, before processed formats, and once the loop
exists because a valid processed format has been found, rawFormat had
been initialized already.

8bits formats instead are enumerated, again by chance, after the
processed formats, and when the loop exists rawFormat is not
initialized, preventing the camera to operate with any 8 bit format.

Fix this by walking all supported formats even if the pixel format has
been found to ensure rawFormat is initialized when a sensorConfig is
specified.

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

---

I'm not 100% happy with this as I think the usage of rawFormat and the
fact it is populated during the validation of the StreamConfiguration
pixelformat is not correct. However, considering this part of the code
has been there for a long time, and I'm the first one hitting any error,
just make sure we support all sensor bit depths instead of rewriting the
function completely.
---
---
 src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--
2.56.0

Comments

Jacopo Mondi Nov. 25, 2026, 2:42 p.m. UTC | #1
gentle ping

I was trying to stream from an 8bit camera today and I hit this one
again.

On Thu, Nov 12, 2026 at 03:12:13PM +0100, Jacopo Mondi wrote:
> The RkISP1Path::validate() function walks the list of all available
> formats at the ISP output to ensure the supplied StreamConfiguration
> has a valid pixelformat, or adjust it a supported one in case it
> doesn't.
>
> When a sensorConfig is specified, the selection of the sensor format is
> restricted by the attributes of the supplied sensorConfig itself and the
> presence of a valid rawFormat is required in the rest of the function.
>
> Currently, whenever a valid pixel format is found, the loop is
> interrupted, risking the rawFormat variable to remain non initialized.
>
> This causes the validate() function to bail out if a sensor config is
> specified.
>
> So far the issue when unnoticed as 10bits and 12bits raw format are
> enumerated, by chance, before processed formats, and once the loop
> exists because a valid processed format has been found, rawFormat had
> been initialized already.
>
> 8bits formats instead are enumerated, again by chance, after the
> processed formats, and when the loop exists rawFormat is not
> initialized, preventing the camera to operate with any 8 bit format.
>
> Fix this by walking all supported formats even if the pixel format has
> been found to ensure rawFormat is initialized when a sensorConfig is
> specified.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>
> ---
>
> I'm not 100% happy with this as I think the usage of rawFormat and the
> fact it is populated during the validation of the StreamConfiguration
> pixelformat is not correct. However, considering this part of the code
> has been there for a long time, and I'm the first one hitting any error,
> just make sure we support all sensor bit depths instead of rewriting the
> function completely.
> ---
> ---
>  src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
> index 20157337022e..013e72d1aed4 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
> @@ -304,7 +304,12 @@ RkISP1Path::validate(const CameraSensor *sensor,
>
>  		if (cfg->pixelFormat == format) {
>  			found = true;
> -			break;
> +			/*
> +			 * If a sensorConfig has been specified, continue walking
> +			 * all supported formats to find a valid 'rawFormat'.
> +			 */
> +			if (!sensorConfig)
> +				break;
>  		}
>  	}
>
> --
> 2.56.0
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
index 20157337022e..013e72d1aed4 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
@@ -304,7 +304,12 @@  RkISP1Path::validate(const CameraSensor *sensor,

 		if (cfg->pixelFormat == format) {
 			found = true;
-			break;
+			/*
+			 * If a sensorConfig has been specified, continue walking
+			 * all supported formats to find a valid 'rawFormat'.
+			 */
+			if (!sensorConfig)
+				break;
 		}
 	}