[libcamera-devel,1/1] pipeline: raspberrypi: Detect monochrome "R" formats as being raw
diff mbox series

Message ID 20220815141637.4159-2-david.plowman@raspberrypi.com
State New
Headers show
Series
  • Raspberry Pi: handle monochrome raw formats correctly
Related show

Commit Message

David Plowman Aug. 15, 2022, 2:16 p.m. UTC
The "R" pixel formats (R8, R10, R10_CSI2P etc.) record the associated
colour space as being YUV rather than RAW, meaning that the code was
not detecting them as being raw formats.

In the case of Raspberry Pi, we deal only with raw formats, so the
revised test must work correctly for both these and the standard Bayer
formats.

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

Comments

Naushir Patuck Aug. 30, 2022, 11:44 a.m. UTC | #1
Hi David,

Thank you for your work.

On Mon, 15 Aug 2022 at 15:16, David Plowman via libcamera-devel <
libcamera-devel@lists.libcamera.org> wrote:

> The "R" pixel formats (R8, R10, R10_CSI2P etc.) record the associated
> colour space as being YUV rather than RAW, meaning that the code was
> not detecting them as being raw formats.
>
> In the case of Raspberry Pi, we deal only with raw formats, so the
> revised test must work correctly for both these and the standard Bayer
> formats.
>
> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
>

Reviewed-by: Naushir Patuck <naush@raspberrypi.com>


> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index e895584d..fae8e45e 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -105,18 +105,8 @@ V4L2DeviceFormat toV4L2DeviceFormat(const
> V4L2VideoDevice *dev,
>
>  bool isRaw(const PixelFormat &pixFmt)
>  {
> -       /*
> -        * The isRaw test might be redundant right now the pipeline
> handler only
> -        * supports RAW sensors. Leave it in for now, just as a sanity
> check.
> -        */
> -       if (!pixFmt.isValid())
> -               return false;
> -
> -       const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);
> -       if (!info.isValid())
> -               return false;
> -
> -       return info.colourEncoding == PixelFormatInfo::ColourEncodingRAW;
> +       /* This test works for both Bayer and raw mono formats. */
> +       return BayerFormat::fromPixelFormat(pixFmt).isValid();
>  }
>
>  double scoreFormat(double desired, double actual)
> --
> 2.30.2
>
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index e895584d..fae8e45e 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -105,18 +105,8 @@  V4L2DeviceFormat toV4L2DeviceFormat(const V4L2VideoDevice *dev,
 
 bool isRaw(const PixelFormat &pixFmt)
 {
-	/*
-	 * The isRaw test might be redundant right now the pipeline handler only
-	 * supports RAW sensors. Leave it in for now, just as a sanity check.
-	 */
-	if (!pixFmt.isValid())
-		return false;
-
-	const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);
-	if (!info.isValid())
-		return false;
-
-	return info.colourEncoding == PixelFormatInfo::ColourEncodingRAW;
+	/* This test works for both Bayer and raw mono formats. */
+	return BayerFormat::fromPixelFormat(pixFmt).isValid();
 }
 
 double scoreFormat(double desired, double actual)