libcamera: formats: Add 16-bit mono format
diff mbox series

Message ID 20240123133410.4130945-1-kieran.bingham@ideasonboard.com
State Superseded
Headers show
Series
  • libcamera: formats: Add 16-bit mono format
Related show

Commit Message

Kieran Bingham Jan. 23, 2024, 1:34 p.m. UTC
From: Naushir Patuck <naush@raspberrypi.com>

Add the relevant definitions for a 16-bit mono pixel and media-bus
format.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---

Patch cherry-picked from
https://github.com/raspberrypi/libcamera/commit/d8c775077c33f7475c5d4828ce3e374d5769b59c
and rebased on top of the recent df770d4b0a6d ("include: linux: Update
kernel headers to version v6.7".


 src/libcamera/bayer_format.cpp     |  3 +++
 src/libcamera/formats.cpp          | 10 ++++++++++
 src/libcamera/formats.yaml         |  2 ++
 src/libcamera/v4l2_pixelformat.cpp |  2 ++
 src/libcamera/v4l2_subdevice.cpp   |  1 +
 5 files changed, 18 insertions(+)

Comments

Laurent Pinchart Jan. 23, 2024, 1:37 p.m. UTC | #1
On Tue, Jan 23, 2024 at 01:34:10PM +0000, Kieran Bingham wrote:
> From: Naushir Patuck <naush@raspberrypi.com>
> 
> Add the relevant definitions for a 16-bit mono pixel and media-bus
> format.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
> 
> Patch cherry-picked from
> https://github.com/raspberrypi/libcamera/commit/d8c775077c33f7475c5d4828ce3e374d5769b59c
> and rebased on top of the recent df770d4b0a6d ("include: linux: Update
> kernel headers to version v6.7".
> 
> 
>  src/libcamera/bayer_format.cpp     |  3 +++
>  src/libcamera/formats.cpp          | 10 ++++++++++
>  src/libcamera/formats.yaml         |  2 ++
>  src/libcamera/v4l2_pixelformat.cpp |  2 ++
>  src/libcamera/v4l2_subdevice.cpp   |  1 +
>  5 files changed, 18 insertions(+)
> 
> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
> index 3bf15fb48f36..2f55d33a915d 100644
> --- a/src/libcamera/bayer_format.cpp
> +++ b/src/libcamera/bayer_format.cpp
> @@ -168,8 +168,11 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
>  		{ formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } },
>  	{ { BayerFormat::MONO, 10, BayerFormat::Packing::None },
>  		{ formats::R10, V4L2PixelFormat(V4L2_PIX_FMT_Y10) } },
> +	{ { BayerFormat::MONO, 16, BayerFormat::Packing::None },
> +		{ formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } },

I would move the 16-bit format after the packed 10-bit format, like we
do for the Bayer formats. Same below.

>  	{ { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 },
>  		{ formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },
> +

Drop this.

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

with these fixed.

>  };
>  
>  const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index 447e623803c7..46ccd43ba63a 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -507,6 +507,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>  		.pixelsPerGroup = 1,
>  		.planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
>  	} },
> +	{ formats::R16, {
> +		.name = "R16",
> +		.format = formats::R16,
> +		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_Y16), },
> +		.bitsPerPixel = 16,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
> +		.packed = false,
> +		.pixelsPerGroup = 1,
> +		.planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
> +	} },
>  	{ formats::R10_CSI2P, {
>  		.name = "R10_CSI2P",
>  		.format = formats::R10_CSI2P,
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index 539ac0b33084..d8a379923b56 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -11,6 +11,8 @@ formats:
>        fourcc: DRM_FORMAT_R10
>    - R12:
>        fourcc: DRM_FORMAT_R12
> +  - R16:
> +      fourcc: DRM_FORMAT_R16
>  
>    - RGB565:
>        fourcc: DRM_FORMAT_RGB565
> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> index 5551c62eb39b..731dc10f1d73 100644
> --- a/src/libcamera/v4l2_pixelformat.cpp
> +++ b/src/libcamera/v4l2_pixelformat.cpp
> @@ -135,6 +135,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_Y16),
> +		{ formats::R16, "16-bit Greyscale" } },
>  
>  	/* Bayer formats. */
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8),
> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> index 75ad11e55272..265240dbd405 100644
> --- a/src/libcamera/v4l2_subdevice.cpp
> +++ b/src/libcamera/v4l2_subdevice.cpp
> @@ -88,6 +88,7 @@ const std::map<uint32_t, V4L2SubdeviceFormatInfo> formatInfoMap = {
>  	{ MEDIA_BUS_FMT_YUYV10_2X10, { 20, "YUYV10_2X10", PixelFormatInfo::ColourEncodingYUV } },
>  	{ MEDIA_BUS_FMT_YVYU10_2X10, { 20, "YVYU10_2X10", PixelFormatInfo::ColourEncodingYUV } },
>  	{ MEDIA_BUS_FMT_Y12_1X12, { 12, "Y12_1X12", PixelFormatInfo::ColourEncodingYUV } },
> +	{ MEDIA_BUS_FMT_Y16_1X16, { 16, "Y16_1X16", PixelFormatInfo::ColourEncodingYUV } },
>  	{ MEDIA_BUS_FMT_UYVY8_1X16, { 16, "UYVY8_1X16", PixelFormatInfo::ColourEncodingYUV } },
>  	{ MEDIA_BUS_FMT_VYUY8_1X16, { 16, "VYUY8_1X16", PixelFormatInfo::ColourEncodingYUV } },
>  	{ MEDIA_BUS_FMT_YUYV8_1X16, { 16, "YUYV8_1X16", PixelFormatInfo::ColourEncodingYUV } },
Kieran Bingham Jan. 23, 2024, 1:48 p.m. UTC | #2
Quoting Kieran Bingham (2024-01-23 13:34:10)
> From: Naushir Patuck <naush@raspberrypi.com>
> 
> Add the relevant definitions for a 16-bit mono pixel and media-bus
> format.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
> 
> Patch cherry-picked from
> https://github.com/raspberrypi/libcamera/commit/d8c775077c33f7475c5d4828ce3e374d5769b59c
> and rebased on top of the recent df770d4b0a6d ("include: linux: Update
> kernel headers to version v6.7".

Also, this will solve/fix https://github.com/raspberrypi/libcamera/issues/103

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> 
> 
>  src/libcamera/bayer_format.cpp     |  3 +++
>  src/libcamera/formats.cpp          | 10 ++++++++++
>  src/libcamera/formats.yaml         |  2 ++
>  src/libcamera/v4l2_pixelformat.cpp |  2 ++
>  src/libcamera/v4l2_subdevice.cpp   |  1 +
>  5 files changed, 18 insertions(+)
> 
> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
> index 3bf15fb48f36..2f55d33a915d 100644
> --- a/src/libcamera/bayer_format.cpp
> +++ b/src/libcamera/bayer_format.cpp
> @@ -168,8 +168,11 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
>                 { formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } },
>         { { BayerFormat::MONO, 10, BayerFormat::Packing::None },
>                 { formats::R10, V4L2PixelFormat(V4L2_PIX_FMT_Y10) } },

It looks like V4L2_PIX_FMT_Y12 might be missing here.
Not specifically for this patch though.

> +       { { BayerFormat::MONO, 16, BayerFormat::Packing::None },
> +               { formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } },
>         { { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 },
>                 { formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },
> +

No blank line required.
Can be dropped while applying.


>  };
>  
>  const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index 447e623803c7..46ccd43ba63a 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -507,6 +507,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>                 .pixelsPerGroup = 1,
>                 .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
>         } },

The one above here is R12.

Looks like R14 support could be added throughout. (separately).

So with only the excess blank line removed (while applying I think)

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> +       { formats::R16, {
> +               .name = "R16",
> +               .format = formats::R16,
> +               .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_Y16), },
> +               .bitsPerPixel = 16,
> +               .colourEncoding = PixelFormatInfo::ColourEncodingYUV,
> +               .packed = false,
> +               .pixelsPerGroup = 1,
> +               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
> +       } },
>         { formats::R10_CSI2P, {
>                 .name = "R10_CSI2P",
>                 .format = formats::R10_CSI2P,
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index 539ac0b33084..d8a379923b56 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -11,6 +11,8 @@ formats:
>        fourcc: DRM_FORMAT_R10
>    - R12:
>        fourcc: DRM_FORMAT_R12
> +  - R16:
> +      fourcc: DRM_FORMAT_R16
>  
>    - RGB565:
>        fourcc: DRM_FORMAT_RGB565
> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> index 5551c62eb39b..731dc10f1d73 100644
> --- a/src/libcamera/v4l2_pixelformat.cpp
> +++ b/src/libcamera/v4l2_pixelformat.cpp
> @@ -135,6 +135,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_Y16),
> +               { formats::R16, "16-bit Greyscale" } },
>  
>         /* Bayer formats. */
>         { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8),
> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> index 75ad11e55272..265240dbd405 100644
> --- a/src/libcamera/v4l2_subdevice.cpp
> +++ b/src/libcamera/v4l2_subdevice.cpp
> @@ -88,6 +88,7 @@ const std::map<uint32_t, V4L2SubdeviceFormatInfo> formatInfoMap = {
>         { MEDIA_BUS_FMT_YUYV10_2X10, { 20, "YUYV10_2X10", PixelFormatInfo::ColourEncodingYUV } },
>         { MEDIA_BUS_FMT_YVYU10_2X10, { 20, "YVYU10_2X10", PixelFormatInfo::ColourEncodingYUV } },
>         { MEDIA_BUS_FMT_Y12_1X12, { 12, "Y12_1X12", PixelFormatInfo::ColourEncodingYUV } },
> +       { MEDIA_BUS_FMT_Y16_1X16, { 16, "Y16_1X16", PixelFormatInfo::ColourEncodingYUV } },
>         { MEDIA_BUS_FMT_UYVY8_1X16, { 16, "UYVY8_1X16", PixelFormatInfo::ColourEncodingYUV } },
>         { MEDIA_BUS_FMT_VYUY8_1X16, { 16, "VYUY8_1X16", PixelFormatInfo::ColourEncodingYUV } },
>         { MEDIA_BUS_FMT_YUYV8_1X16, { 16, "YUYV8_1X16", PixelFormatInfo::ColourEncodingYUV } },
> -- 
> 2.34.1
>
Kieran Bingham Jan. 23, 2024, 2:02 p.m. UTC | #3
Quoting Laurent Pinchart (2024-01-23 13:37:04)
> On Tue, Jan 23, 2024 at 01:34:10PM +0000, Kieran Bingham wrote:
> > From: Naushir Patuck <naush@raspberrypi.com>
> > 
> > Add the relevant definitions for a 16-bit mono pixel and media-bus
> > format.
> > 
> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > ---
> > 
> > Patch cherry-picked from
> > https://github.com/raspberrypi/libcamera/commit/d8c775077c33f7475c5d4828ce3e374d5769b59c
> > and rebased on top of the recent df770d4b0a6d ("include: linux: Update
> > kernel headers to version v6.7".
> > 
> > 
> >  src/libcamera/bayer_format.cpp     |  3 +++
> >  src/libcamera/formats.cpp          | 10 ++++++++++
> >  src/libcamera/formats.yaml         |  2 ++
> >  src/libcamera/v4l2_pixelformat.cpp |  2 ++
> >  src/libcamera/v4l2_subdevice.cpp   |  1 +
> >  5 files changed, 18 insertions(+)
> > 
> > diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
> > index 3bf15fb48f36..2f55d33a915d 100644
> > --- a/src/libcamera/bayer_format.cpp
> > +++ b/src/libcamera/bayer_format.cpp
> > @@ -168,8 +168,11 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
> >               { formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } },
> >       { { BayerFormat::MONO, 10, BayerFormat::Packing::None },
> >               { formats::R10, V4L2PixelFormat(V4L2_PIX_FMT_Y10) } },
> > +     { { BayerFormat::MONO, 16, BayerFormat::Packing::None },
> > +             { formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } },
> 
> I would move the 16-bit format after the packed 10-bit format, like we
> do for the Bayer formats. Same below.

Done.

> 
> >       { { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 },
> >               { formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },
> > +
> 
> Drop this.

Done ;-)

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


bayer_format.cpp should also be updated with:

@@ -210,6 +210,7 @@ const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
        { MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::Packing::None } },
        { MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::Packing::None } },
        { MEDIA_BUS_FMT_Y12_1X12, { BayerFormat::MONO, 12, BayerFormat::Packing::None } },
+       { MEDIA_BUS_FMT_Y16_1X16, { BayerFormat::MONO, 16, BayerFormat::Packing::None } },
 };

 } /* namespace */


I'll send out a v2 anyway, and the ordering fixup and add in R14.



> 
> >  };
> >  
> >  const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
> > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> > index 447e623803c7..46ccd43ba63a 100644
> > --- a/src/libcamera/formats.cpp
> > +++ b/src/libcamera/formats.cpp
> > @@ -507,6 +507,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
> >               .pixelsPerGroup = 1,
> >               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
> >       } },
> > +     { formats::R16, {
> > +             .name = "R16",
> > +             .format = formats::R16,
> > +             .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_Y16), },
> > +             .bitsPerPixel = 16,
> > +             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,
> > +             .packed = false,
> > +             .pixelsPerGroup = 1,
> > +             .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
> > +     } },

Moving this 'after' won't fix the R10_CSI2P to be adjacent to the R10,
so I'll move formats::R10_CSI2P separately.


> >       { formats::R10_CSI2P, {
> >               .name = "R10_CSI2P",
> >               .format = formats::R10_CSI2P,
> > diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> > index 539ac0b33084..d8a379923b56 100644
> > --- a/src/libcamera/formats.yaml
> > +++ b/src/libcamera/formats.yaml
> > @@ -11,6 +11,8 @@ formats:
> >        fourcc: DRM_FORMAT_R10
> >    - R12:
> >        fourcc: DRM_FORMAT_R12
> > +  - R16:
> > +      fourcc: DRM_FORMAT_R16
> >  
> >    - RGB565:
> >        fourcc: DRM_FORMAT_RGB565
> > diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> > index 5551c62eb39b..731dc10f1d73 100644
> > --- a/src/libcamera/v4l2_pixelformat.cpp
> > +++ b/src/libcamera/v4l2_pixelformat.cpp
> > @@ -135,6 +135,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_Y16),
> > +             { formats::R16, "16-bit Greyscale" } },
> >  
> >       /* Bayer formats. */
> >       { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8),
> > diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> > index 75ad11e55272..265240dbd405 100644
> > --- a/src/libcamera/v4l2_subdevice.cpp
> > +++ b/src/libcamera/v4l2_subdevice.cpp
> > @@ -88,6 +88,7 @@ const std::map<uint32_t, V4L2SubdeviceFormatInfo> formatInfoMap = {
> >       { MEDIA_BUS_FMT_YUYV10_2X10, { 20, "YUYV10_2X10", PixelFormatInfo::ColourEncodingYUV } },
> >       { MEDIA_BUS_FMT_YVYU10_2X10, { 20, "YVYU10_2X10", PixelFormatInfo::ColourEncodingYUV } },
> >       { MEDIA_BUS_FMT_Y12_1X12, { 12, "Y12_1X12", PixelFormatInfo::ColourEncodingYUV } },
> > +     { MEDIA_BUS_FMT_Y16_1X16, { 16, "Y16_1X16", PixelFormatInfo::ColourEncodingYUV } },
> >       { MEDIA_BUS_FMT_UYVY8_1X16, { 16, "UYVY8_1X16", PixelFormatInfo::ColourEncodingYUV } },
> >       { MEDIA_BUS_FMT_VYUY8_1X16, { 16, "VYUY8_1X16", PixelFormatInfo::ColourEncodingYUV } },
> >       { MEDIA_BUS_FMT_YUYV8_1X16, { 16, "YUYV8_1X16", PixelFormatInfo::ColourEncodingYUV } },
> 
> -- 
> Regards,
> 
> Laurent Pinchart

Patch
diff mbox series

diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
index 3bf15fb48f36..2f55d33a915d 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -168,8 +168,11 @@  const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
 		{ formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } },
 	{ { BayerFormat::MONO, 10, BayerFormat::Packing::None },
 		{ formats::R10, V4L2PixelFormat(V4L2_PIX_FMT_Y10) } },
+	{ { BayerFormat::MONO, 16, BayerFormat::Packing::None },
+		{ formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } },
 	{ { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 },
 		{ formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },
+
 };
 
 const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 447e623803c7..46ccd43ba63a 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -507,6 +507,16 @@  const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
 		.pixelsPerGroup = 1,
 		.planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
 	} },
+	{ formats::R16, {
+		.name = "R16",
+		.format = formats::R16,
+		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_Y16), },
+		.bitsPerPixel = 16,
+		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
+		.packed = false,
+		.pixelsPerGroup = 1,
+		.planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
 	{ formats::R10_CSI2P, {
 		.name = "R10_CSI2P",
 		.format = formats::R10_CSI2P,
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
index 539ac0b33084..d8a379923b56 100644
--- a/src/libcamera/formats.yaml
+++ b/src/libcamera/formats.yaml
@@ -11,6 +11,8 @@  formats:
       fourcc: DRM_FORMAT_R10
   - R12:
       fourcc: DRM_FORMAT_R12
+  - R16:
+      fourcc: DRM_FORMAT_R16
 
   - RGB565:
       fourcc: DRM_FORMAT_RGB565
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
index 5551c62eb39b..731dc10f1d73 100644
--- a/src/libcamera/v4l2_pixelformat.cpp
+++ b/src/libcamera/v4l2_pixelformat.cpp
@@ -135,6 +135,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_Y16),
+		{ formats::R16, "16-bit Greyscale" } },
 
 	/* Bayer formats. */
 	{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8),
diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index 75ad11e55272..265240dbd405 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -88,6 +88,7 @@  const std::map<uint32_t, V4L2SubdeviceFormatInfo> formatInfoMap = {
 	{ MEDIA_BUS_FMT_YUYV10_2X10, { 20, "YUYV10_2X10", PixelFormatInfo::ColourEncodingYUV } },
 	{ MEDIA_BUS_FMT_YVYU10_2X10, { 20, "YVYU10_2X10", PixelFormatInfo::ColourEncodingYUV } },
 	{ MEDIA_BUS_FMT_Y12_1X12, { 12, "Y12_1X12", PixelFormatInfo::ColourEncodingYUV } },
+	{ MEDIA_BUS_FMT_Y16_1X16, { 16, "Y16_1X16", PixelFormatInfo::ColourEncodingYUV } },
 	{ MEDIA_BUS_FMT_UYVY8_1X16, { 16, "UYVY8_1X16", PixelFormatInfo::ColourEncodingYUV } },
 	{ MEDIA_BUS_FMT_VYUY8_1X16, { 16, "VYUY8_1X16", PixelFormatInfo::ColourEncodingYUV } },
 	{ MEDIA_BUS_FMT_YUYV8_1X16, { 16, "YUYV8_1X16", PixelFormatInfo::ColourEncodingYUV } },