libcamera: formats: Adding Support for Y12P
diff mbox series

Message ID 20240808071433.10724-1-naush@raspberrypi.com
State Accepted
Commit f87bf964fc108675c48b168e9b1d2629a3461bef
Headers show
Series
  • libcamera: formats: Adding Support for Y12P
Related show

Commit Message

Naushir Patuck Aug. 8, 2024, 7:14 a.m. UTC
From: will whang <will@willwhang.com>

Add support for a 12-bit Mono format named formats::R12_CSI2P.

This format is added to support the IMX585 mono sensor, which uses the
MEDIA_BUS_FMT_Y12_1X12 media bus format.

Signed-off-by: will whang <will@willwhang.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/libcamera/bayer_format.cpp     |  2 ++
 src/libcamera/formats.cpp          | 10 ++++++++++
 src/libcamera/formats.yaml         |  3 +++
 src/libcamera/v4l2_pixelformat.cpp |  2 ++
 4 files changed, 17 insertions(+)

Comments

Laurent Pinchart Aug. 11, 2024, 5:34 p.m. UTC | #1
Hi Naush and Will,

Thank you for the patch.

On Thu, Aug 08, 2024 at 08:14:33AM +0100, Naushir Patuck wrote:
> From: will whang <will@willwhang.com>
> 
> Add support for a 12-bit Mono format named formats::R12_CSI2P.
> 
> This format is added to support the IMX585 mono sensor, which uses the
> MEDIA_BUS_FMT_Y12_1X12 media bus format.
> 
> Signed-off-by: will whang <will@willwhang.com>
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

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

> ---
>  src/libcamera/bayer_format.cpp     |  2 ++
>  src/libcamera/formats.cpp          | 10 ++++++++++
>  src/libcamera/formats.yaml         |  3 +++
>  src/libcamera/v4l2_pixelformat.cpp |  2 ++
>  4 files changed, 17 insertions(+)
> 
> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
> index 014f716d28f7..c2120d1c16d7 100644
> --- a/src/libcamera/bayer_format.cpp
> +++ b/src/libcamera/bayer_format.cpp
> @@ -184,6 +184,8 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
>  		{ formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },
>  	{ { BayerFormat::MONO, 12, BayerFormat::Packing::None },
>  		{ formats::R12, V4L2PixelFormat(V4L2_PIX_FMT_Y12) } },
> +	{ { BayerFormat::MONO, 12, BayerFormat::Packing::CSI2 },
> +		{ formats::R12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y12P) } },
>  	{ { BayerFormat::MONO, 16, BayerFormat::Packing::None },
>  		{ formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } },
>  	{ { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 },
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index cf41f2c261ed..f338fc373f33 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -527,6 +527,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>  		.pixelsPerGroup = 4,
>  		.planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},
>  	} },
> +	{ formats::R12_CSI2P, {
> +		.name = "R12_CSI2P",
> +		.format = formats::R12_CSI2P,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_Y12P), },
> +		.bitsPerPixel = 12,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
> +		.packed = true,
> +		.pixelsPerGroup = 2,
> +		.planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
>  	{ formats::R12, {
>  		.name = "R12",
>  		.format = formats::R12,
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index fe027a7cce70..2d54d391ca01 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -138,6 +138,9 @@ formats:
>    - R10_CSI2P:
>        fourcc: DRM_FORMAT_R10
>        mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +  - R12_CSI2P:
> +      fourcc: DRM_FORMAT_R12
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
>  
>    - SRGGB10_CSI2P:
>        fourcc: DRM_FORMAT_SRGGB10
> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> index 70568335b266..eb9ac2224fd1 100644
> --- a/src/libcamera/v4l2_pixelformat.cpp
> +++ b/src/libcamera/v4l2_pixelformat.cpp
> @@ -139,6 +139,8 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
>  		{ formats::R10_CSI2P, "10-bit Greyscale Packed" } },
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_Y12),
>  		{ formats::R12, "12-bit Greyscale" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_Y12P),
> +		{ formats::R12_CSI2P, "12-bit Greyscale Packed" } },
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_Y16),
>  		{ formats::R16, "16-bit Greyscale" } },
>
Dan Scally Aug. 12, 2024, 11:19 a.m. UTC | #2
Hi Naush, thanks for the patch

On 08/08/2024 08:14, Naushir Patuck wrote:
> From: will whang <will@willwhang.com>
>
> Add support for a 12-bit Mono format named formats::R12_CSI2P.
>
> This format is added to support the IMX585 mono sensor, which uses the
> MEDIA_BUS_FMT_Y12_1X12 media bus format.
>
> Signed-off-by: will whang <will@willwhang.com>
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> ---


Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>

>   src/libcamera/bayer_format.cpp     |  2 ++
>   src/libcamera/formats.cpp          | 10 ++++++++++
>   src/libcamera/formats.yaml         |  3 +++
>   src/libcamera/v4l2_pixelformat.cpp |  2 ++
>   4 files changed, 17 insertions(+)
>
> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
> index 014f716d28f7..c2120d1c16d7 100644
> --- a/src/libcamera/bayer_format.cpp
> +++ b/src/libcamera/bayer_format.cpp
> @@ -184,6 +184,8 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
>   		{ formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },
>   	{ { BayerFormat::MONO, 12, BayerFormat::Packing::None },
>   		{ formats::R12, V4L2PixelFormat(V4L2_PIX_FMT_Y12) } },
> +	{ { BayerFormat::MONO, 12, BayerFormat::Packing::CSI2 },
> +		{ formats::R12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y12P) } },
>   	{ { BayerFormat::MONO, 16, BayerFormat::Packing::None },
>   		{ formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } },
>   	{ { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 },
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index cf41f2c261ed..f338fc373f33 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -527,6 +527,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>   		.pixelsPerGroup = 4,
>   		.planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},
>   	} },
> +	{ formats::R12_CSI2P, {
> +		.name = "R12_CSI2P",
> +		.format = formats::R12_CSI2P,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_Y12P), },
> +		.bitsPerPixel = 12,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
> +		.packed = true,
> +		.pixelsPerGroup = 2,
> +		.planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
>   	{ formats::R12, {
>   		.name = "R12",
>   		.format = formats::R12,
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index fe027a7cce70..2d54d391ca01 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -138,6 +138,9 @@ formats:
>     - R10_CSI2P:
>         fourcc: DRM_FORMAT_R10
>         mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +  - R12_CSI2P:
> +      fourcc: DRM_FORMAT_R12
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
>   
>     - SRGGB10_CSI2P:
>         fourcc: DRM_FORMAT_SRGGB10
> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> index 70568335b266..eb9ac2224fd1 100644
> --- a/src/libcamera/v4l2_pixelformat.cpp
> +++ b/src/libcamera/v4l2_pixelformat.cpp
> @@ -139,6 +139,8 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
>   		{ formats::R10_CSI2P, "10-bit Greyscale Packed" } },
>   	{ V4L2PixelFormat(V4L2_PIX_FMT_Y12),
>   		{ formats::R12, "12-bit Greyscale" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_Y12P),
> +		{ formats::R12_CSI2P, "12-bit Greyscale Packed" } },
>   	{ V4L2PixelFormat(V4L2_PIX_FMT_Y16),
>   		{ formats::R16, "16-bit Greyscale" } },
>

Patch
diff mbox series

diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
index 014f716d28f7..c2120d1c16d7 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -184,6 +184,8 @@  const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
 		{ formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },
 	{ { BayerFormat::MONO, 12, BayerFormat::Packing::None },
 		{ formats::R12, V4L2PixelFormat(V4L2_PIX_FMT_Y12) } },
+	{ { BayerFormat::MONO, 12, BayerFormat::Packing::CSI2 },
+		{ formats::R12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y12P) } },
 	{ { BayerFormat::MONO, 16, BayerFormat::Packing::None },
 		{ formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } },
 	{ { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 },
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index cf41f2c261ed..f338fc373f33 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -527,6 +527,16 @@  const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
 		.pixelsPerGroup = 4,
 		.planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},
 	} },
+	{ formats::R12_CSI2P, {
+		.name = "R12_CSI2P",
+		.format = formats::R12_CSI2P,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_Y12P), },
+		.bitsPerPixel = 12,
+		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
+		.packed = true,
+		.pixelsPerGroup = 2,
+		.planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
 	{ formats::R12, {
 		.name = "R12",
 		.format = formats::R12,
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
index fe027a7cce70..2d54d391ca01 100644
--- a/src/libcamera/formats.yaml
+++ b/src/libcamera/formats.yaml
@@ -138,6 +138,9 @@  formats:
   - R10_CSI2P:
       fourcc: DRM_FORMAT_R10
       mod: MIPI_FORMAT_MOD_CSI2_PACKED
+  - R12_CSI2P:
+      fourcc: DRM_FORMAT_R12
+      mod: MIPI_FORMAT_MOD_CSI2_PACKED
 
   - SRGGB10_CSI2P:
       fourcc: DRM_FORMAT_SRGGB10
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
index 70568335b266..eb9ac2224fd1 100644
--- a/src/libcamera/v4l2_pixelformat.cpp
+++ b/src/libcamera/v4l2_pixelformat.cpp
@@ -139,6 +139,8 @@  const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
 		{ formats::R10_CSI2P, "10-bit Greyscale Packed" } },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_Y12),
 		{ formats::R12, "12-bit Greyscale" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_Y12P),
+		{ formats::R12_CSI2P, "12-bit Greyscale Packed" } },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_Y16),
 		{ formats::R16, "16-bit Greyscale" } },