[libcamera-devel] [PATCH 2/2] libcamera: formats: Add RGB565_BE format

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sun Jan 31 19:43:52 CET 2021


This new format corresponds to the V4L2 V4L2_PIX_FMT_RGB565X format, and
is the big-endian version of the DRM_FORMAT_RGB565 format.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 src/libcamera/formats.cpp          | 10 ++++++++++
 src/libcamera/formats.yaml         |  3 +++
 src/libcamera/v4l2_pixelformat.cpp |  1 +
 3 files changed, 14 insertions(+)

diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 14940bee3724..4f70e47e0c97 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -155,6 +155,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
 		.pixelsPerGroup = 1,
 		.planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }},
 	} },
+	{ formats::RGB565_BE, {
+		.name = "RGB565_BE",
+		.format = formats::RGB565_BE,
+		.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_RGB565X),
+		.bitsPerPixel = 16,
+		.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
+		.packed = false,
+		.pixelsPerGroup = 1,
+		.planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }},
+	} },
 	{ formats::BGR888, {
 		.name = "BGR888",
 		.format = formats::BGR888,
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
index de4254df9334..c3adef54ca0f 100644
--- a/src/libcamera/formats.yaml
+++ b/src/libcamera/formats.yaml
@@ -10,6 +10,9 @@ formats:
 
   - RGB565:
       fourcc: DRM_FORMAT_RGB565
+  - RGB565_BE:
+      fourcc: DRM_FORMAT_RGB565
+      big_endian: true
 
   - RGB888:
       fourcc: DRM_FORMAT_RGB888
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
index 2665d5a7af08..abb1824c5673 100644
--- a/src/libcamera/v4l2_pixelformat.cpp
+++ b/src/libcamera/v4l2_pixelformat.cpp
@@ -47,6 +47,7 @@ namespace {
 const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{
 	/* RGB formats. */
 	{ V4L2PixelFormat(V4L2_PIX_FMT_RGB565), formats::RGB565 },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_RGB565X), formats::RGB565_BE },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_RGB24), formats::BGR888 },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_BGR24), formats::RGB888 },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_XBGR32), formats::XRGB8888 },
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list