[v2,1/3] libcamera: pipeline: rkisp1: Detect invalid sensor configurations
diff mbox series

Message ID 20261102-kbingham-orientation-v2-1-21b1cdd0d167@ideasonboard.com
State New
Headers show
Series
  • libcamera: rkisp1: Camera Sensor Mode Validation
Related show

Commit Message

Kieran Bingham Nov. 2, 2026, 12:11 p.m. UTC
If we select a Sensor Format that is larger than the ISP capabilities
the pipeline will not be able to successfully start.

Detect this during validate - and report accordingly, returning
an 'Invalid' state to reflect that we were not able to
reconfigure to adjust to a working state in this instance.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Barnabás Pőcze Nov. 9, 2026, 1:52 p.m. UTC | #1
2026. 11. 02. 13:11 keltezéssel, Kieran Bingham írta:
> If we select a Sensor Format that is larger than the ISP capabilities
> the pipeline will not be able to successfully start.
> 
> Detect this during validate - and report accordingly, returning
> an 'Invalid' state to reflect that we were not able to
> reconfigure to adjust to a working state in this instance.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>   src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index 39fe0f0964d7..3086ddbeef76 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -772,9 +772,21 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()
>   	sensorFormat_ = sensor->getFormat(mbusCodes, accumulatedSensorSize,
>   					  mainPath->maxResolution());
>   
> +
> +	/*
> +	 * TODO: There doesn't seem to be a valid occasion to set the size to
> +	 * the native resolution if there was not a supported size found above.
> +	 */
>   	if (sensorFormat_.size.isNull())
>   		sensorFormat_.size = sensor->resolution();
>   
> +	if (sensorFormat_.size > mainPath->maxResolution()) {

How is this possible? If this is indeed possible, doesn't that mean
that there is a bug in `CameraSensor::getFormat()` ?


> +		LOG(RkISP1, Error)
> +			<< "Sensor format size " << sensorFormat_.size
> +			<< " exceeds maximum possible size " << mainPath->maxResolution();
> +		return Invalid;
> +	}
> +
>   	return status;
>   }
>   
>
Kieran Bingham Nov. 9, 2026, 3:12 p.m. UTC | #2
Quoting Barnabás Pőcze (2026-11-09 13:52:46)
> 2026. 11. 02. 13:11 keltezéssel, Kieran Bingham írta:
> > If we select a Sensor Format that is larger than the ISP capabilities
> > the pipeline will not be able to successfully start.
> > 
> > Detect this during validate - and report accordingly, returning
> > an 'Invalid' state to reflect that we were not able to
> > reconfigure to adjust to a working state in this instance.
> > 
> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > ---
> >   src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 ++++++++++++
> >   1 file changed, 12 insertions(+)
> > 
> > diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> > index 39fe0f0964d7..3086ddbeef76 100644
> > --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> > +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> > @@ -772,9 +772,21 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()
> >       sensorFormat_ = sensor->getFormat(mbusCodes, accumulatedSensorSize,
> >                                         mainPath->maxResolution());
> >   
> > +
> > +     /*
> > +      * TODO: There doesn't seem to be a valid occasion to set the size to
> > +      * the native resolution if there was not a supported size found above.
> > +      */
> >       if (sensorFormat_.size.isNull())
> >               sensorFormat_.size = sensor->resolution();
> >   
> > +     if (sensorFormat_.size > mainPath->maxResolution()) {
> 
> How is this possible? If this is indeed possible, doesn't that mean
> that there is a bug in `CameraSensor::getFormat()` ?

When these bugs were discovered it was due to adding rotation
capabilities in the dewarper and while we were extending support and
tests for that.

We have a large sensor (IMX283) mounted at a 90* rotation.

Captures that are valid in one orientation become invalid when rotated
90* - and from what I recall this was catching things like that
occuring.

For instance, the sensor might be configured to give 4096x3072, which
then goes to the dewarper and rotates 90* giving 3072x4096.


It was a long time ago now, but I recall we were frequently configuring
tests that had the wrong orientation and weren't being stopped early
enough - which was where I made this patch.

Stefan, do you have any clearer recollection or can you test the
rotation with/without this patch please? Is this patch still used in
your tree ? Or is it just something for me to drop already ?

--
Kieran



> > +             LOG(RkISP1, Error)
> > +                     << "Sensor format size " << sensorFormat_.size
> > +                     << " exceeds maximum possible size " << mainPath->maxResolution();
> > +             return Invalid;
> > +     }
> > +
> >       return status;
> >   }
> >   
> > 
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 39fe0f0964d7..3086ddbeef76 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -772,9 +772,21 @@  CameraConfiguration::Status RkISP1CameraConfiguration::validate()
 	sensorFormat_ = sensor->getFormat(mbusCodes, accumulatedSensorSize,
 					  mainPath->maxResolution());
 
+
+	/*
+	 * TODO: There doesn't seem to be a valid occasion to set the size to
+	 * the native resolution if there was not a supported size found above.
+	 */
 	if (sensorFormat_.size.isNull())
 		sensorFormat_.size = sensor->resolution();
 
+	if (sensorFormat_.size > mainPath->maxResolution()) {
+		LOG(RkISP1, Error)
+			<< "Sensor format size " << sensorFormat_.size
+			<< " exceeds maximum possible size " << mainPath->maxResolution();
+		return Invalid;
+	}
+
 	return status;
 }