[05/10] libcamera: formats: Add CRU-packed RAWnn libcamera formats
diff mbox series

Message ID 20250724065256.75175-6-dan.scally@ideasonboard.com
State New
Headers show
Series
  • Support memory input mode in mali-c55
Related show

Commit Message

Dan Scally July 24, 2025, 6:52 a.m. UTC
Add libcamera formats for the CRU-packed, bayer order agnostic CRU
pixel formats that map to the V4L2 Pixel Formats in the kernel
header.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
 src/libcamera/formats.cpp  | 30 ++++++++++++++++++++++++++++++
 src/libcamera/formats.yaml | 13 +++++++++++++
 2 files changed, 43 insertions(+)

Comments

Jacopo Mondi Oct. 30, 2025, 11:41 a.m. UTC | #1
Hi Dan

On Thu, Jul 24, 2025 at 07:52:51AM +0100, Daniel Scally wrote:
> Add libcamera formats for the CRU-packed, bayer order agnostic CRU
> pixel formats that map to the V4L2 Pixel Formats in the kernel
> header.

Ah, so you need the DRM fourcc to be able to capture CRU-packaged
images in RAW format I guess

>
> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
> ---
>  src/libcamera/formats.cpp  | 30 ++++++++++++++++++++++++++++++
>  src/libcamera/formats.yaml | 13 +++++++++++++
>  2 files changed, 43 insertions(+)
>
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index bfcdfc08..8f10d1ec 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -969,6 +969,36 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>  		.pixelsPerGroup = 2,
>  		.planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
>  	} },
> +	{ formats::RAW10_CRU, {
> +		.name = "RAW10_CRU",
> +		.format = formats::RAW10_CRU,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU10), },
> +		.bitsPerPixel = 10,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = true,
> +		.pixelsPerGroup = 6,
> +		.planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
> +	{ formats::RAW12_CRU, {
> +		.name = "RAW12_CRU",
> +		.format = formats::RAW12_CRU,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU12), },
> +		.bitsPerPixel = 12,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = true,
> +		.pixelsPerGroup = 5,
> +		.planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
> +	{ formats::RAW14_CRU, {
> +		.name = "RAW14_CRU",
> +		.format = formats::RAW14_CRU,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU14), },
> +		.bitsPerPixel = 14,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = true,
> +		.pixelsPerGroup = 4,
> +		.planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }},

The CRU packaging for RAW14 has a padding byte in the upper byte of
64 bits word. I guess we should indeed report {8, 1} to describe the
packing and let the user know how to unpack the data. (The alternative
would be to specify { 7, 1 } as that's the actual number of
significant bytes, but that would mess up calculations..)


> +	} },
>  	/* Compressed formats. */
>  	{ formats::MJPEG, {
>  		.name = "MJPEG",
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index 2d54d391..47188fc8 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -209,4 +209,17 @@ formats:
>    - MONO_PISP_COMP1:
>        fourcc: DRM_FORMAT_R16
>        mod: PISP_FORMAT_MOD_COMPRESS_MODE1
> +
> +  - RAW10_CRU:
> +      fourcc: DRM_FORMAT_RAW10
> +      mod: RENESAS_CRU_FORMAT_MOD_PACKED
> +  - RAW12_CRU:
> +      fourcc: DRM_FORMAT_RAW12
> +      mod: RENESAS_CRU_FORMAT_MOD_PACKED
> +  - RAW14_CRU:
> +      fourcc: DRM_FORMAT_RAW14
> +      mod: RENESAS_CRU_FORMAT_MOD_PACKED
> +  - RAW20_CRU:
> +      fourcc: DRM_FORMAT_RAW20
> +      mod: RENESAS_CRU_FORMAT_MOD_PACKED

I don't see a 20bits format in CRU specs nor in the above table ? What
have I missed ?

Thanks
  j

>  ...
> --
> 2.30.2
>

Patch
diff mbox series

diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index bfcdfc08..8f10d1ec 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -969,6 +969,36 @@  const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
 		.pixelsPerGroup = 2,
 		.planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
 	} },
+	{ formats::RAW10_CRU, {
+		.name = "RAW10_CRU",
+		.format = formats::RAW10_CRU,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU10), },
+		.bitsPerPixel = 10,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = true,
+		.pixelsPerGroup = 6,
+		.planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
+	{ formats::RAW12_CRU, {
+		.name = "RAW12_CRU",
+		.format = formats::RAW12_CRU,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU12), },
+		.bitsPerPixel = 12,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = true,
+		.pixelsPerGroup = 5,
+		.planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
+	{ formats::RAW14_CRU, {
+		.name = "RAW14_CRU",
+		.format = formats::RAW14_CRU,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU14), },
+		.bitsPerPixel = 14,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = true,
+		.pixelsPerGroup = 4,
+		.planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
 	/* Compressed formats. */
 	{ formats::MJPEG, {
 		.name = "MJPEG",
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
index 2d54d391..47188fc8 100644
--- a/src/libcamera/formats.yaml
+++ b/src/libcamera/formats.yaml
@@ -209,4 +209,17 @@  formats:
   - MONO_PISP_COMP1:
       fourcc: DRM_FORMAT_R16
       mod: PISP_FORMAT_MOD_COMPRESS_MODE1
+
+  - RAW10_CRU:
+      fourcc: DRM_FORMAT_RAW10
+      mod: RENESAS_CRU_FORMAT_MOD_PACKED
+  - RAW12_CRU:
+      fourcc: DRM_FORMAT_RAW12
+      mod: RENESAS_CRU_FORMAT_MOD_PACKED
+  - RAW14_CRU:
+      fourcc: DRM_FORMAT_RAW14
+      mod: RENESAS_CRU_FORMAT_MOD_PACKED
+  - RAW20_CRU:
+      fourcc: DRM_FORMAT_RAW20
+      mod: RENESAS_CRU_FORMAT_MOD_PACKED
 ...