pipeline: rpi: vc4: Use an unpacked format if no packed one is available
diff mbox series

Message ID 20240221124919.2684-1-david.plowman@raspberrypi.com
State Accepted
Headers show
Series
  • pipeline: rpi: vc4: Use an unpacked format if no packed one is available
Related show

Commit Message

David Plowman Feb. 21, 2024, 12:49 p.m. UTC
When validating a stream, and no valid packed pixel format can be
found, see if an unpacked format can be used instead.

This is particularly helpful for 8 (and 16) bit raw formats, where
asking for a packed format would previously have failed. Now the
configuration will be adjusted to give you a format (in fact, the only
format) that will work.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/libcamera/pipeline/rpi/vc4/vc4.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Laurent Pinchart Feb. 21, 2024, 1:09 p.m. UTC | #1
Hi David,

Thank you for the patch.

On Wed, Feb 21, 2024 at 12:49:19PM +0000, David Plowman wrote:
> When validating a stream, and no valid packed pixel format can be
> found, see if an unpacked format can be used instead.
> 
> This is particularly helpful for 8 (and 16) bit raw formats, where
> asking for a packed format would previously have failed. Now the
> configuration will be adjusted to give you a format (in fact, the only
> format) that will work.
> 
> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
> ---
>  src/libcamera/pipeline/rpi/vc4/vc4.cpp | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
> index a52f0e7a..ad76099b 100644
> --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp
> +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
> @@ -434,6 +434,16 @@ CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfig
>  			rawBayer.packing = BayerFormat::Packing::CSI2;
>  
>  		PixelFormat rawFormat = rawBayer.toPixelFormat();
> +
> +		/*
> +		 * Try for an unpacked format if a packed one wasn't available.This catches

s/This/ This/

I'll fix this locally.

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

> +		 * 8 (and 16) bit formats which would otherwise fail.
> +		 */
> +		if (!rawFormat.isValid() && rawBayer.packing != BayerFormat::Packing::None) {
> +			rawBayer.packing = BayerFormat::Packing::None;
> +			rawFormat = rawBayer.toPixelFormat();
> +		}
> +
>  		if (rawStream->pixelFormat != rawFormat ||
>  		    rawStream->size != rpiConfig->sensorFormat_.size) {
>  			rawStream->pixelFormat = rawFormat;
David Plowman Feb. 21, 2024, 3:02 p.m. UTC | #2
Hi Laurent

On Wed, 21 Feb 2024 at 13:09, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi David,
>
> Thank you for the patch.
>
> On Wed, Feb 21, 2024 at 12:49:19PM +0000, David Plowman wrote:
> > When validating a stream, and no valid packed pixel format can be
> > found, see if an unpacked format can be used instead.
> >
> > This is particularly helpful for 8 (and 16) bit raw formats, where
> > asking for a packed format would previously have failed. Now the
> > configuration will be adjusted to give you a format (in fact, the only
> > format) that will work.
> >
> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
> > ---
> >  src/libcamera/pipeline/rpi/vc4/vc4.cpp | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
> > index a52f0e7a..ad76099b 100644
> > --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp
> > +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
> > @@ -434,6 +434,16 @@ CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfig
> >                       rawBayer.packing = BayerFormat::Packing::CSI2;
> >
> >               PixelFormat rawFormat = rawBayer.toPixelFormat();
> > +
> > +             /*
> > +              * Try for an unpacked format if a packed one wasn't available.This catches
>
> s/This/ This/
>
> I'll fix this locally.

Ah yes, thank you very much!!

David

>
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> > +              * 8 (and 16) bit formats which would otherwise fail.
> > +              */
> > +             if (!rawFormat.isValid() && rawBayer.packing != BayerFormat::Packing::None) {
> > +                     rawBayer.packing = BayerFormat::Packing::None;
> > +                     rawFormat = rawBayer.toPixelFormat();
> > +             }
> > +
> >               if (rawStream->pixelFormat != rawFormat ||
> >                   rawStream->size != rpiConfig->sensorFormat_.size) {
> >                       rawStream->pixelFormat = rawFormat;
>
> --
> Regards,
>
> Laurent Pinchart

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
index a52f0e7a..ad76099b 100644
--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp
+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
@@ -434,6 +434,16 @@  CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfig
 			rawBayer.packing = BayerFormat::Packing::CSI2;
 
 		PixelFormat rawFormat = rawBayer.toPixelFormat();
+
+		/*
+		 * Try for an unpacked format if a packed one wasn't available.This catches
+		 * 8 (and 16) bit formats which would otherwise fail.
+		 */
+		if (!rawFormat.isValid() && rawBayer.packing != BayerFormat::Packing::None) {
+			rawBayer.packing = BayerFormat::Packing::None;
+			rawFormat = rawBayer.toPixelFormat();
+		}
+
 		if (rawStream->pixelFormat != rawFormat ||
 		    rawStream->size != rpiConfig->sensorFormat_.size) {
 			rawStream->pixelFormat = rawFormat;