[libcamera-devel] libcamera: formats: Add 14-bits Bayer RAW formats
diff mbox series

Message ID 20230418141823.24642-1-jacopo.mondi@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] libcamera: formats: Add 14-bits Bayer RAW formats
Related show

Commit Message

Jacopo Mondi April 18, 2023, 2:18 p.m. UTC
Add formats definition and mappings for 14-bits Bayer RAW formats.

Add definitions for non-packed and CSI-2 packed variants.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/libcamera/bayer_format.cpp     | 16 ++++++
 src/libcamera/formats.c            |  0
 src/libcamera/formats.cpp          | 80 ++++++++++++++++++++++++++++++
 src/libcamera/formats.yaml         | 22 ++++++++
 src/libcamera/v4l2_pixelformat.cpp | 16 ++++++
 5 files changed, 134 insertions(+)
 create mode 100644 src/libcamera/formats.c

--
2.40.0

Comments

Laurent Pinchart April 18, 2023, 2:32 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Apr 18, 2023 at 04:18:23PM +0200, Jacopo Mondi via libcamera-devel wrote:
> Add formats definition and mappings for 14-bits Bayer RAW formats.
> 
> Add definitions for non-packed and CSI-2 packed variants.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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

> ---
>  src/libcamera/bayer_format.cpp     | 16 ++++++
>  src/libcamera/formats.c            |  0
>  src/libcamera/formats.cpp          | 80 ++++++++++++++++++++++++++++++
>  src/libcamera/formats.yaml         | 22 ++++++++
>  src/libcamera/v4l2_pixelformat.cpp | 16 ++++++
>  5 files changed, 134 insertions(+)
>  create mode 100644 src/libcamera/formats.c
> 
> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
> index 6a76d6a4b6dc..3bf15fb48f36 100644
> --- a/src/libcamera/bayer_format.cpp
> +++ b/src/libcamera/bayer_format.cpp
> @@ -140,6 +140,22 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
>  		{ formats::SGRBG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } },
>  	{ { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 },
>  		{ formats::SRGGB12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } },
> +	{ { BayerFormat::BGGR, 14, BayerFormat::Packing::None },
> +		{ formats::SBGGR14, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14) } },
> +	{ { BayerFormat::GBRG, 14, BayerFormat::Packing::None },
> +		{ formats::SGBRG14, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14) } },
> +	{ { BayerFormat::GRBG, 14, BayerFormat::Packing::None },
> +		{ formats::SGRBG14, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14) } },
> +	{ { BayerFormat::RGGB, 14, BayerFormat::Packing::None },
> +		{ formats::SRGGB14, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14) } },
> +	{ { BayerFormat::BGGR, 14, BayerFormat::Packing::CSI2 },
> +		{ formats::SBGGR14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P) } },
> +	{ { BayerFormat::GBRG, 14, BayerFormat::Packing::CSI2 },
> +		{ formats::SGBRG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P) } },
> +	{ { BayerFormat::GRBG, 14, BayerFormat::Packing::CSI2 },
> +		{ formats::SGRBG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P) } },
> +	{ { BayerFormat::RGGB, 14, BayerFormat::Packing::CSI2 },
> +		{ formats::SRGGB14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P) } },
>  	{ { BayerFormat::BGGR, 16, BayerFormat::Packing::None },
>  		{ formats::SBGGR16, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } },
>  	{ { BayerFormat::GBRG, 16, BayerFormat::Packing::None },
> diff --git a/src/libcamera/formats.c b/src/libcamera/formats.c
> new file mode 100644
> index 000000000000..e69de29bb2d1
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index f5769c489e16..447e623803c7 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -719,6 +719,86 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>  		.pixelsPerGroup = 2,
>  		.planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }},
>  	} },
> +	{ formats::SBGGR14, {
> +		.name = "SBGGR14",
> +		.format = formats::SBGGR14,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14), },
> +		.bitsPerPixel = 14,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = false,
> +		.pixelsPerGroup = 2,
> +		.planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
> +	{ formats::SGBRG14, {
> +		.name = "SGBRG14",
> +		.format = formats::SGBRG14,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14), },
> +		.bitsPerPixel = 14,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = false,
> +		.pixelsPerGroup = 2,
> +		.planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
> +	{ formats::SGRBG14, {
> +		.name = "SGRBG14",
> +		.format = formats::SGRBG14,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14), },
> +		.bitsPerPixel = 14,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = false,
> +		.pixelsPerGroup = 2,
> +		.planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
> +	{ formats::SRGGB14, {
> +		.name = "SRGGB14",
> +		.format = formats::SRGGB14,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14), },
> +		.bitsPerPixel = 14,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = false,
> +		.pixelsPerGroup = 2,
> +		.planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
> +	{ formats::SBGGR14_CSI2P, {
> +		.name = "SBGGR14_CSI2P",
> +		.format = formats::SBGGR14_CSI2P,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P), },
> +		.bitsPerPixel = 14,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = true,
> +		.pixelsPerGroup = 4,
> +		.planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
> +	{ formats::SGBRG14_CSI2P, {
> +		.name = "SGBRG14_CSI2P",
> +		.format = formats::SGBRG14_CSI2P,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P), },
> +		.bitsPerPixel = 14,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = true,
> +		.pixelsPerGroup = 4,
> +		.planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
> +	{ formats::SGRBG14_CSI2P, {
> +		.name = "SGRBG14_CSI2P",
> +		.format = formats::SGRBG14_CSI2P,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P), },
> +		.bitsPerPixel = 14,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = true,
> +		.pixelsPerGroup = 4,
> +		.planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
> +	{ formats::SRGGB14_CSI2P, {
> +		.name = "SRGGB14_CSI2P",
> +		.format = formats::SRGGB14_CSI2P,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P), },
> +		.bitsPerPixel = 14,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +		.packed = true,
> +		.pixelsPerGroup = 4,
> +		.planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
>  	{ formats::SBGGR16, {
>  		.name = "SBGGR16",
>  		.format = formats::SBGGR16,
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index e586cde1d705..539ac0b33084 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -110,6 +110,15 @@ formats:
>    - SBGGR12:
>        fourcc: DRM_FORMAT_SBGGR12
> 
> +  - SRGGB14:
> +      fourcc: DRM_FORMAT_SRGGB14
> +  - SGRBG14:
> +      fourcc: DRM_FORMAT_SGRBG14
> +  - SGBRG14:
> +      fourcc: DRM_FORMAT_SGBRG14
> +  - SBGGR14:
> +      fourcc: DRM_FORMAT_SBGGR14
> +
>    - SRGGB16:
>        fourcc: DRM_FORMAT_SRGGB16
>    - SGRBG16:
> @@ -149,6 +158,19 @@ formats:
>        fourcc: DRM_FORMAT_SBGGR12
>        mod: MIPI_FORMAT_MOD_CSI2_PACKED
> 
> +  - SRGGB14_CSI2P:
> +      fourcc: DRM_FORMAT_SRGGB14
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +  - SGRBG14_CSI2P:
> +      fourcc: DRM_FORMAT_SGRBG14
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +  - SGBRG14_CSI2P:
> +      fourcc: DRM_FORMAT_SGBRG14
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +  - SBGGR14_CSI2P:
> +      fourcc: DRM_FORMAT_SBGGR14
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +
>    - SRGGB10_IPU3:
>        fourcc: DRM_FORMAT_SRGGB10
>        mod: IPU3_FORMAT_MOD_PACKED
> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> index d87665a4916f..a7ae69bb317d 100644
> --- a/src/libcamera/v4l2_pixelformat.cpp
> +++ b/src/libcamera/v4l2_pixelformat.cpp
> @@ -177,6 +177,22 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
>  		{ formats::SGRBG12_CSI2P, "12-bit Bayer GRGR/BGBG Packed" } },
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P),
>  		{ formats::SRGGB12_CSI2P, "12-bit Bayer RGRG/GBGB Packed" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14),
> +		{ formats::SBGGR14, "14-bit Bayer BGBG/GRGR" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14),
> +		{ formats::SGBRG14, "14-bit Bayer GBGB/RGRG" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14),
> +		{ formats::SGRBG14, "14-bit Bayer GRGR/BGBG" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14),
> +		{ formats::SRGGB14, "14-bit Bayer RGRG/GBGB" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P),
> +		{ formats::SBGGR14_CSI2P, "14-bit Bayer BGBG/GRGR Packed" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P),
> +		{ formats::SGBRG14_CSI2P, "14-bit Bayer GBGB/RGRG Packed" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P),
> +		{ formats::SGRBG14_CSI2P, "14-bit Bayer GRGR/BGBG Packed" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P),
> +		{ formats::SRGGB14_CSI2P, "14-bit Bayer RGRG/GBGB Packed" } },
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16),
>  		{ formats::SBGGR16, "16-bit Bayer BGBG/GRGR" } },
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16),
Naushir Patuck April 18, 2023, 2:41 p.m. UTC | #2
Hi Jacopo,

Thank you for adding these!

On Tue, 18 Apr 2023 at 15:18, Jacopo Mondi
<jacopo.mondi@ideasonboard.com> wrote:
>
> Add formats definition and mappings for 14-bits Bayer RAW formats.
>
> Add definitions for non-packed and CSI-2 packed variants.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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

> ---
>  src/libcamera/bayer_format.cpp     | 16 ++++++
>  src/libcamera/formats.c            |  0
>  src/libcamera/formats.cpp          | 80 ++++++++++++++++++++++++++++++
>  src/libcamera/formats.yaml         | 22 ++++++++
>  src/libcamera/v4l2_pixelformat.cpp | 16 ++++++
>  5 files changed, 134 insertions(+)
>  create mode 100644 src/libcamera/formats.c
>
> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
> index 6a76d6a4b6dc..3bf15fb48f36 100644
> --- a/src/libcamera/bayer_format.cpp
> +++ b/src/libcamera/bayer_format.cpp
> @@ -140,6 +140,22 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
>                 { formats::SGRBG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } },
>         { { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 },
>                 { formats::SRGGB12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } },
> +       { { BayerFormat::BGGR, 14, BayerFormat::Packing::None },
> +               { formats::SBGGR14, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14) } },
> +       { { BayerFormat::GBRG, 14, BayerFormat::Packing::None },
> +               { formats::SGBRG14, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14) } },
> +       { { BayerFormat::GRBG, 14, BayerFormat::Packing::None },
> +               { formats::SGRBG14, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14) } },
> +       { { BayerFormat::RGGB, 14, BayerFormat::Packing::None },
> +               { formats::SRGGB14, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14) } },
> +       { { BayerFormat::BGGR, 14, BayerFormat::Packing::CSI2 },
> +               { formats::SBGGR14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P) } },
> +       { { BayerFormat::GBRG, 14, BayerFormat::Packing::CSI2 },
> +               { formats::SGBRG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P) } },
> +       { { BayerFormat::GRBG, 14, BayerFormat::Packing::CSI2 },
> +               { formats::SGRBG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P) } },
> +       { { BayerFormat::RGGB, 14, BayerFormat::Packing::CSI2 },
> +               { formats::SRGGB14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P) } },
>         { { BayerFormat::BGGR, 16, BayerFormat::Packing::None },
>                 { formats::SBGGR16, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } },
>         { { BayerFormat::GBRG, 16, BayerFormat::Packing::None },
> diff --git a/src/libcamera/formats.c b/src/libcamera/formats.c
> new file mode 100644
> index 000000000000..e69de29bb2d1
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index f5769c489e16..447e623803c7 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -719,6 +719,86 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>                 .pixelsPerGroup = 2,
>                 .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }},
>         } },
> +       { formats::SBGGR14, {
> +               .name = "SBGGR14",
> +               .format = formats::SBGGR14,
> +               .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14), },
> +               .bitsPerPixel = 14,
> +               .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +               .packed = false,
> +               .pixelsPerGroup = 2,
> +               .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
> +       } },
> +       { formats::SGBRG14, {
> +               .name = "SGBRG14",
> +               .format = formats::SGBRG14,
> +               .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14), },
> +               .bitsPerPixel = 14,
> +               .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +               .packed = false,
> +               .pixelsPerGroup = 2,
> +               .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
> +       } },
> +       { formats::SGRBG14, {
> +               .name = "SGRBG14",
> +               .format = formats::SGRBG14,
> +               .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14), },
> +               .bitsPerPixel = 14,
> +               .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +               .packed = false,
> +               .pixelsPerGroup = 2,
> +               .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
> +       } },
> +       { formats::SRGGB14, {
> +               .name = "SRGGB14",
> +               .format = formats::SRGGB14,
> +               .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14), },
> +               .bitsPerPixel = 14,
> +               .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +               .packed = false,
> +               .pixelsPerGroup = 2,
> +               .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
> +       } },
> +       { formats::SBGGR14_CSI2P, {
> +               .name = "SBGGR14_CSI2P",
> +               .format = formats::SBGGR14_CSI2P,
> +               .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P), },
> +               .bitsPerPixel = 14,
> +               .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +               .packed = true,
> +               .pixelsPerGroup = 4,
> +               .planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
> +       } },
> +       { formats::SGBRG14_CSI2P, {
> +               .name = "SGBRG14_CSI2P",
> +               .format = formats::SGBRG14_CSI2P,
> +               .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P), },
> +               .bitsPerPixel = 14,
> +               .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +               .packed = true,
> +               .pixelsPerGroup = 4,
> +               .planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
> +       } },
> +       { formats::SGRBG14_CSI2P, {
> +               .name = "SGRBG14_CSI2P",
> +               .format = formats::SGRBG14_CSI2P,
> +               .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P), },
> +               .bitsPerPixel = 14,
> +               .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +               .packed = true,
> +               .pixelsPerGroup = 4,
> +               .planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
> +       } },
> +       { formats::SRGGB14_CSI2P, {
> +               .name = "SRGGB14_CSI2P",
> +               .format = formats::SRGGB14_CSI2P,
> +               .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P), },
> +               .bitsPerPixel = 14,
> +               .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
> +               .packed = true,
> +               .pixelsPerGroup = 4,
> +               .planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
> +       } },
>         { formats::SBGGR16, {
>                 .name = "SBGGR16",
>                 .format = formats::SBGGR16,
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index e586cde1d705..539ac0b33084 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -110,6 +110,15 @@ formats:
>    - SBGGR12:
>        fourcc: DRM_FORMAT_SBGGR12
>
> +  - SRGGB14:
> +      fourcc: DRM_FORMAT_SRGGB14
> +  - SGRBG14:
> +      fourcc: DRM_FORMAT_SGRBG14
> +  - SGBRG14:
> +      fourcc: DRM_FORMAT_SGBRG14
> +  - SBGGR14:
> +      fourcc: DRM_FORMAT_SBGGR14
> +
>    - SRGGB16:
>        fourcc: DRM_FORMAT_SRGGB16
>    - SGRBG16:
> @@ -149,6 +158,19 @@ formats:
>        fourcc: DRM_FORMAT_SBGGR12
>        mod: MIPI_FORMAT_MOD_CSI2_PACKED
>
> +  - SRGGB14_CSI2P:
> +      fourcc: DRM_FORMAT_SRGGB14
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +  - SGRBG14_CSI2P:
> +      fourcc: DRM_FORMAT_SGRBG14
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +  - SGBRG14_CSI2P:
> +      fourcc: DRM_FORMAT_SGBRG14
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +  - SBGGR14_CSI2P:
> +      fourcc: DRM_FORMAT_SBGGR14
> +      mod: MIPI_FORMAT_MOD_CSI2_PACKED
> +
>    - SRGGB10_IPU3:
>        fourcc: DRM_FORMAT_SRGGB10
>        mod: IPU3_FORMAT_MOD_PACKED
> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> index d87665a4916f..a7ae69bb317d 100644
> --- a/src/libcamera/v4l2_pixelformat.cpp
> +++ b/src/libcamera/v4l2_pixelformat.cpp
> @@ -177,6 +177,22 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
>                 { formats::SGRBG12_CSI2P, "12-bit Bayer GRGR/BGBG Packed" } },
>         { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P),
>                 { formats::SRGGB12_CSI2P, "12-bit Bayer RGRG/GBGB Packed" } },
> +       { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14),
> +               { formats::SBGGR14, "14-bit Bayer BGBG/GRGR" } },
> +       { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14),
> +               { formats::SGBRG14, "14-bit Bayer GBGB/RGRG" } },
> +       { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14),
> +               { formats::SGRBG14, "14-bit Bayer GRGR/BGBG" } },
> +       { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14),
> +               { formats::SRGGB14, "14-bit Bayer RGRG/GBGB" } },
> +       { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P),
> +               { formats::SBGGR14_CSI2P, "14-bit Bayer BGBG/GRGR Packed" } },
> +       { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P),
> +               { formats::SGBRG14_CSI2P, "14-bit Bayer GBGB/RGRG Packed" } },
> +       { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P),
> +               { formats::SGRBG14_CSI2P, "14-bit Bayer GRGR/BGBG Packed" } },
> +       { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P),
> +               { formats::SRGGB14_CSI2P, "14-bit Bayer RGRG/GBGB Packed" } },
>         { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16),
>                 { formats::SBGGR16, "16-bit Bayer BGBG/GRGR" } },
>         { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16),
> --
> 2.40.0
>

Patch
diff mbox series

diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
index 6a76d6a4b6dc..3bf15fb48f36 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -140,6 +140,22 @@  const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
 		{ formats::SGRBG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } },
 	{ { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 },
 		{ formats::SRGGB12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } },
+	{ { BayerFormat::BGGR, 14, BayerFormat::Packing::None },
+		{ formats::SBGGR14, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14) } },
+	{ { BayerFormat::GBRG, 14, BayerFormat::Packing::None },
+		{ formats::SGBRG14, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14) } },
+	{ { BayerFormat::GRBG, 14, BayerFormat::Packing::None },
+		{ formats::SGRBG14, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14) } },
+	{ { BayerFormat::RGGB, 14, BayerFormat::Packing::None },
+		{ formats::SRGGB14, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14) } },
+	{ { BayerFormat::BGGR, 14, BayerFormat::Packing::CSI2 },
+		{ formats::SBGGR14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P) } },
+	{ { BayerFormat::GBRG, 14, BayerFormat::Packing::CSI2 },
+		{ formats::SGBRG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P) } },
+	{ { BayerFormat::GRBG, 14, BayerFormat::Packing::CSI2 },
+		{ formats::SGRBG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P) } },
+	{ { BayerFormat::RGGB, 14, BayerFormat::Packing::CSI2 },
+		{ formats::SRGGB14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P) } },
 	{ { BayerFormat::BGGR, 16, BayerFormat::Packing::None },
 		{ formats::SBGGR16, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } },
 	{ { BayerFormat::GBRG, 16, BayerFormat::Packing::None },
diff --git a/src/libcamera/formats.c b/src/libcamera/formats.c
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index f5769c489e16..447e623803c7 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -719,6 +719,86 @@  const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
 		.pixelsPerGroup = 2,
 		.planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }},
 	} },
+	{ formats::SBGGR14, {
+		.name = "SBGGR14",
+		.format = formats::SBGGR14,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14), },
+		.bitsPerPixel = 14,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = false,
+		.pixelsPerGroup = 2,
+		.planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
+	{ formats::SGBRG14, {
+		.name = "SGBRG14",
+		.format = formats::SGBRG14,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14), },
+		.bitsPerPixel = 14,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = false,
+		.pixelsPerGroup = 2,
+		.planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
+	{ formats::SGRBG14, {
+		.name = "SGRBG14",
+		.format = formats::SGRBG14,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14), },
+		.bitsPerPixel = 14,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = false,
+		.pixelsPerGroup = 2,
+		.planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
+	{ formats::SRGGB14, {
+		.name = "SRGGB14",
+		.format = formats::SRGGB14,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14), },
+		.bitsPerPixel = 14,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = false,
+		.pixelsPerGroup = 2,
+		.planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
+	{ formats::SBGGR14_CSI2P, {
+		.name = "SBGGR14_CSI2P",
+		.format = formats::SBGGR14_CSI2P,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P), },
+		.bitsPerPixel = 14,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = true,
+		.pixelsPerGroup = 4,
+		.planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
+	{ formats::SGBRG14_CSI2P, {
+		.name = "SGBRG14_CSI2P",
+		.format = formats::SGBRG14_CSI2P,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P), },
+		.bitsPerPixel = 14,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = true,
+		.pixelsPerGroup = 4,
+		.planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
+	{ formats::SGRBG14_CSI2P, {
+		.name = "SGRBG14_CSI2P",
+		.format = formats::SGRBG14_CSI2P,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P), },
+		.bitsPerPixel = 14,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = true,
+		.pixelsPerGroup = 4,
+		.planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
+	{ formats::SRGGB14_CSI2P, {
+		.name = "SRGGB14_CSI2P",
+		.format = formats::SRGGB14_CSI2P,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P), },
+		.bitsPerPixel = 14,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+		.packed = true,
+		.pixelsPerGroup = 4,
+		.planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
 	{ formats::SBGGR16, {
 		.name = "SBGGR16",
 		.format = formats::SBGGR16,
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
index e586cde1d705..539ac0b33084 100644
--- a/src/libcamera/formats.yaml
+++ b/src/libcamera/formats.yaml
@@ -110,6 +110,15 @@  formats:
   - SBGGR12:
       fourcc: DRM_FORMAT_SBGGR12

+  - SRGGB14:
+      fourcc: DRM_FORMAT_SRGGB14
+  - SGRBG14:
+      fourcc: DRM_FORMAT_SGRBG14
+  - SGBRG14:
+      fourcc: DRM_FORMAT_SGBRG14
+  - SBGGR14:
+      fourcc: DRM_FORMAT_SBGGR14
+
   - SRGGB16:
       fourcc: DRM_FORMAT_SRGGB16
   - SGRBG16:
@@ -149,6 +158,19 @@  formats:
       fourcc: DRM_FORMAT_SBGGR12
       mod: MIPI_FORMAT_MOD_CSI2_PACKED

+  - SRGGB14_CSI2P:
+      fourcc: DRM_FORMAT_SRGGB14
+      mod: MIPI_FORMAT_MOD_CSI2_PACKED
+  - SGRBG14_CSI2P:
+      fourcc: DRM_FORMAT_SGRBG14
+      mod: MIPI_FORMAT_MOD_CSI2_PACKED
+  - SGBRG14_CSI2P:
+      fourcc: DRM_FORMAT_SGBRG14
+      mod: MIPI_FORMAT_MOD_CSI2_PACKED
+  - SBGGR14_CSI2P:
+      fourcc: DRM_FORMAT_SBGGR14
+      mod: MIPI_FORMAT_MOD_CSI2_PACKED
+
   - SRGGB10_IPU3:
       fourcc: DRM_FORMAT_SRGGB10
       mod: IPU3_FORMAT_MOD_PACKED
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
index d87665a4916f..a7ae69bb317d 100644
--- a/src/libcamera/v4l2_pixelformat.cpp
+++ b/src/libcamera/v4l2_pixelformat.cpp
@@ -177,6 +177,22 @@  const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
 		{ formats::SGRBG12_CSI2P, "12-bit Bayer GRGR/BGBG Packed" } },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P),
 		{ formats::SRGGB12_CSI2P, "12-bit Bayer RGRG/GBGB Packed" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14),
+		{ formats::SBGGR14, "14-bit Bayer BGBG/GRGR" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14),
+		{ formats::SGBRG14, "14-bit Bayer GBGB/RGRG" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14),
+		{ formats::SGRBG14, "14-bit Bayer GRGR/BGBG" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14),
+		{ formats::SRGGB14, "14-bit Bayer RGRG/GBGB" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P),
+		{ formats::SBGGR14_CSI2P, "14-bit Bayer BGBG/GRGR Packed" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P),
+		{ formats::SGBRG14_CSI2P, "14-bit Bayer GBGB/RGRG Packed" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P),
+		{ formats::SGRBG14_CSI2P, "14-bit Bayer GRGR/BGBG Packed" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P),
+		{ formats::SRGGB14_CSI2P, "14-bit Bayer RGRG/GBGB Packed" } },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16),
 		{ formats::SBGGR16, "16-bit Bayer BGBG/GRGR" } },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16),