[2/2] pipeline: rpi: pisp: Ensure we don't run our SW correction with packed
diff mbox series

Message ID 20260624082705.272795-3-naush@raspberrypi.com
State New
Headers show
Series
  • RPi pipeline handler fixes
Related show

Commit Message

Naushir Patuck June 24, 2026, 8:24 a.m. UTC
Due to hardware bugs in the CSI-2 RX, we need to unpack 14-bit CSI-2
packed samples and swap endian order in 16-bit samples both in software.
These SW routines only work on unpacked/uncompresssed samples.

For this reason, ensure the user cannot configure 14/16-bit RAW streams
with PiSP Bayer compression in platformValidate().

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

Comments

David Plowman June 24, 2026, 8:46 a.m. UTC | #1
Hi Naush

Thanks for the patch.

On Wed, 24 Jun 2026 at 09:35, Naushir Patuck <naush@raspberrypi.com> wrote:
>
> Due to hardware bugs in the CSI-2 RX, we need to unpack 14-bit CSI-2
> packed samples and swap endian order in 16-bit samples both in software.
> These SW routines only work on unpacked/uncompresssed samples.
>
> For this reason, ensure the user cannot configure 14/16-bit RAW streams
> with PiSP Bayer compression in platformValidate().
>
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> ---
>  src/libcamera/pipeline/rpi/pisp/pisp.cpp | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp
> index b744c901f751..8e8da116ef6f 100644
> --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp
> +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp
> @@ -1223,6 +1223,17 @@ PiSPCameraData::platformValidate(RPi::RPiCameraConfiguration *rpiConfig) const
>                         status = CameraConfiguration::Adjusted;
>                 }
>
> +               unsigned bpp = MediaBusFormatInfo::info(rpiConfig->sensorFormat_.code).bitsPerPixel;
> +               if ((bpp == 16 || bpp == 14) &&
> +                   bayer.packing != BayerFormat::Packing::None) {
> +                       LOG(RPI, Info)
> +                               << "The sensor is configured for a 16/14-bit output, "
> +                               << "compression is not available for SW fixups needed.";
> +                       bayer.packing = BayerFormat::Packing::None;
> +                       rawStream->pixelFormat = bayer.toPixelFormat();
> +                       status = CameraConfiguration::Adjusted;
> +               }
> +
>                 rawStreams[0].format =
>                         RPi::PipelineHandlerBase::toV4L2DeviceFormat(cfe_[Cfe::Output0].dev(), rawStream);
>
> --
> 2.53.0
>

This looks fine to me. Packing/compression can't possibly work for 14
or 16 bit formats as things stand, so fixing it like this (with a
little complaint), is probably the best workaround. I suppose maybe
"Warning" level rather than "Info"? But really not bothered either
way...

Reviewed-by: David Plowman <david.plowman@raspberrypi.com>

Thanks!

David

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp
index b744c901f751..8e8da116ef6f 100644
--- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp
+++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp
@@ -1223,6 +1223,17 @@  PiSPCameraData::platformValidate(RPi::RPiCameraConfiguration *rpiConfig) const
 			status = CameraConfiguration::Adjusted;
 		}
 
+		unsigned bpp = MediaBusFormatInfo::info(rpiConfig->sensorFormat_.code).bitsPerPixel;
+		if ((bpp == 16 || bpp == 14) &&
+		    bayer.packing != BayerFormat::Packing::None) {
+			LOG(RPI, Info)
+				<< "The sensor is configured for a 16/14-bit output, "
+				<< "compression is not available for SW fixups needed.";
+			bayer.packing = BayerFormat::Packing::None;
+			rawStream->pixelFormat = bayer.toPixelFormat();
+			status = CameraConfiguration::Adjusted;
+		}
+
 		rawStreams[0].format =
 			RPi::PipelineHandlerBase::toV4L2DeviceFormat(cfe_[Cfe::Output0].dev(), rawStream);