summaryrefslogtreecommitdiff
path: root/src/libcamera/formats.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-22 04:02:06 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-06-18 13:26:58 +0300
commit8b7e073e6eab6d62e6d8e8e0b4e120e2e016da3d (patch)
tree08ad0c8d87c1efe374ada44f66a7f84584b090c6 /src/libcamera/formats.cpp
parent56c99424edd64c5a2bfe255eabc9e00787fc75a0 (diff)
libcamera: Replace explicit DRM FourCCs with libcamera formats
Use the new pixel format constants to replace usage of macros from drm_fourcc.h. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/formats.cpp')
-rw-r--r--src/libcamera/formats.cpp146
1 files changed, 74 insertions, 72 deletions
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 74c239a5..97e98678 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -9,6 +9,8 @@
#include <errno.h>
+#include <libcamera/formats.h>
+
#include "libcamera/internal/log.h"
/**
@@ -166,43 +168,43 @@ namespace {
const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
/* RGB formats. */
- { PixelFormat(DRM_FORMAT_BGR888), {
- .format = PixelFormat(DRM_FORMAT_BGR888),
+ { formats::BGR888, {
+ .format = formats::BGR888,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_RGB24),
.bitsPerPixel = 24,
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_RGB888), {
- .format = PixelFormat(DRM_FORMAT_RGB888),
+ { formats::RGB888, {
+ .format = formats::RGB888,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_BGR24),
.bitsPerPixel = 24,
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_ABGR8888), {
- .format = PixelFormat(DRM_FORMAT_ABGR8888),
+ { formats::ABGR8888, {
+ .format = formats::ABGR8888,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_RGBA32),
.bitsPerPixel = 32,
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_ARGB8888), {
- .format = PixelFormat(DRM_FORMAT_ARGB8888),
+ { formats::ARGB8888, {
+ .format = formats::ARGB8888,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_ABGR32),
.bitsPerPixel = 32,
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_BGRA8888), {
- .format = PixelFormat(DRM_FORMAT_BGRA8888),
+ { formats::BGRA8888, {
+ .format = formats::BGRA8888,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_ARGB32),
.bitsPerPixel = 32,
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_RGBA8888), {
- .format = PixelFormat(DRM_FORMAT_RGBA8888),
+ { formats::RGBA8888, {
+ .format = formats::RGBA8888,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_BGRA32),
.bitsPerPixel = 32,
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
@@ -210,29 +212,29 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
} },
/* YUV packed formats. */
- { PixelFormat(DRM_FORMAT_YUYV), {
- .format = PixelFormat(DRM_FORMAT_YUYV),
+ { formats::YUYV, {
+ .format = formats::YUYV,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUYV),
.bitsPerPixel = 16,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_YVYU), {
- .format = PixelFormat(DRM_FORMAT_YVYU),
+ { formats::YVYU, {
+ .format = formats::YVYU,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YVYU),
.bitsPerPixel = 16,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_UYVY), {
- .format = PixelFormat(DRM_FORMAT_UYVY),
+ { formats::UYVY, {
+ .format = formats::UYVY,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_UYVY),
.bitsPerPixel = 16,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_VYUY), {
- .format = PixelFormat(DRM_FORMAT_VYUY),
+ { formats::VYUY, {
+ .format = formats::VYUY,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_VYUY),
.bitsPerPixel = 16,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
@@ -240,29 +242,29 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
} },
/* YUV planar formats. */
- { PixelFormat(DRM_FORMAT_NV16), {
- .format = PixelFormat(DRM_FORMAT_NV16),
+ { formats::NV16, {
+ .format = formats::NV16,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV16),
.bitsPerPixel = 16,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_NV61), {
- .format = PixelFormat(DRM_FORMAT_NV61),
+ { formats::NV61, {
+ .format = formats::NV61,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV61),
.bitsPerPixel = 16,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_NV12), {
- .format = PixelFormat(DRM_FORMAT_NV12),
+ { formats::NV12, {
+ .format = formats::NV12,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV12),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_NV21), {
- .format = PixelFormat(DRM_FORMAT_NV21),
+ { formats::NV21, {
+ .format = formats::NV21,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV21),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
@@ -270,8 +272,8 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
} },
/* Greyscale formats. */
- { PixelFormat(DRM_FORMAT_R8), {
- .format = PixelFormat(DRM_FORMAT_R8),
+ { formats::R8, {
+ .format = formats::R8,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_GREY),
.bitsPerPixel = 8,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
@@ -279,141 +281,141 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
} },
/* Bayer formats. */
- { PixelFormat(DRM_FORMAT_SBGGR8), {
- .format = PixelFormat(DRM_FORMAT_SBGGR8),
+ { formats::SBGGR8, {
+ .format = formats::SBGGR8,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8),
.bitsPerPixel = 8,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SGBRG8), {
- .format = PixelFormat(DRM_FORMAT_SGBRG8),
+ { formats::SGBRG8, {
+ .format = formats::SGBRG8,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8),
.bitsPerPixel = 8,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SGRBG8), {
- .format = PixelFormat(DRM_FORMAT_SGRBG8),
+ { formats::SGRBG8, {
+ .format = formats::SGRBG8,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8),
.bitsPerPixel = 8,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SRGGB8), {
- .format = PixelFormat(DRM_FORMAT_SRGGB8),
+ { formats::SRGGB8, {
+ .format = formats::SRGGB8,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8),
.bitsPerPixel = 8,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SBGGR10), {
- .format = PixelFormat(DRM_FORMAT_SBGGR10),
+ { formats::SBGGR10, {
+ .format = formats::SBGGR10,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10),
.bitsPerPixel = 10,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SGBRG10), {
- .format = PixelFormat(DRM_FORMAT_SGBRG10),
+ { formats::SGBRG10, {
+ .format = formats::SGBRG10,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10),
.bitsPerPixel = 10,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SGRBG10), {
- .format = PixelFormat(DRM_FORMAT_SGRBG10),
+ { formats::SGRBG10, {
+ .format = formats::SGRBG10,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10),
.bitsPerPixel = 10,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SRGGB10), {
- .format = PixelFormat(DRM_FORMAT_SRGGB10),
+ { formats::SRGGB10, {
+ .format = formats::SRGGB10,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10),
.bitsPerPixel = 10,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SBGGR10, MIPI_FORMAT_MOD_CSI2_PACKED), {
- .format = PixelFormat(DRM_FORMAT_SBGGR10, MIPI_FORMAT_MOD_CSI2_PACKED),
+ { formats::SBGGR10_CSI2P, {
+ .format = formats::SBGGR10_CSI2P,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P),
.bitsPerPixel = 10,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = true,
} },
- { PixelFormat(DRM_FORMAT_SGBRG10, MIPI_FORMAT_MOD_CSI2_PACKED), {
- .format = PixelFormat(DRM_FORMAT_SGBRG10, MIPI_FORMAT_MOD_CSI2_PACKED),
+ { formats::SGBRG10_CSI2P, {
+ .format = formats::SGBRG10_CSI2P,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P),
.bitsPerPixel = 10,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = true,
} },
- { PixelFormat(DRM_FORMAT_SGRBG10, MIPI_FORMAT_MOD_CSI2_PACKED), {
- .format = PixelFormat(DRM_FORMAT_SGRBG10, MIPI_FORMAT_MOD_CSI2_PACKED),
+ { formats::SGRBG10_CSI2P, {
+ .format = formats::SGRBG10_CSI2P,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P),
.bitsPerPixel = 10,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = true,
} },
- { PixelFormat(DRM_FORMAT_SRGGB10, MIPI_FORMAT_MOD_CSI2_PACKED), {
- .format = PixelFormat(DRM_FORMAT_SRGGB10, MIPI_FORMAT_MOD_CSI2_PACKED),
+ { formats::SRGGB10_CSI2P, {
+ .format = formats::SRGGB10_CSI2P,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P),
.bitsPerPixel = 10,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = true,
} },
- { PixelFormat(DRM_FORMAT_SBGGR12), {
- .format = PixelFormat(DRM_FORMAT_SBGGR12),
+ { formats::SBGGR12, {
+ .format = formats::SBGGR12,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SGBRG12), {
- .format = PixelFormat(DRM_FORMAT_SGBRG12),
+ { formats::SGBRG12, {
+ .format = formats::SGBRG12,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SGRBG12), {
- .format = PixelFormat(DRM_FORMAT_SGRBG12),
+ { formats::SGRBG12, {
+ .format = formats::SGRBG12,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SRGGB12), {
- .format = PixelFormat(DRM_FORMAT_SRGGB12),
+ { formats::SRGGB12, {
+ .format = formats::SRGGB12,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = false,
} },
- { PixelFormat(DRM_FORMAT_SBGGR12, MIPI_FORMAT_MOD_CSI2_PACKED), {
- .format = PixelFormat(DRM_FORMAT_SBGGR12, MIPI_FORMAT_MOD_CSI2_PACKED),
+ { formats::SBGGR12_CSI2P, {
+ .format = formats::SBGGR12_CSI2P,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = true,
} },
- { PixelFormat(DRM_FORMAT_SGBRG12, MIPI_FORMAT_MOD_CSI2_PACKED), {
- .format = PixelFormat(DRM_FORMAT_SGBRG12, MIPI_FORMAT_MOD_CSI2_PACKED),
+ { formats::SGBRG12_CSI2P, {
+ .format = formats::SGBRG12_CSI2P,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = true,
} },
- { PixelFormat(DRM_FORMAT_SGRBG12, MIPI_FORMAT_MOD_CSI2_PACKED), {
- .format = PixelFormat(DRM_FORMAT_SGRBG12, MIPI_FORMAT_MOD_CSI2_PACKED),
+ { formats::SGRBG12_CSI2P, {
+ .format = formats::SGRBG12_CSI2P,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
.packed = true,
} },
- { PixelFormat(DRM_FORMAT_SRGGB12, MIPI_FORMAT_MOD_CSI2_PACKED), {
- .format = PixelFormat(DRM_FORMAT_SRGGB12, MIPI_FORMAT_MOD_CSI2_PACKED),
+ { formats::SRGGB12_CSI2P, {
+ .format = formats::SRGGB12_CSI2P,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P),
.bitsPerPixel = 12,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
@@ -421,8 +423,8 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
} },
/* Compressed formats. */
- { PixelFormat(DRM_FORMAT_MJPEG), {
- .format = PixelFormat(DRM_FORMAT_MJPEG),
+ { formats::MJPEG, {
+ .format = formats::MJPEG,
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),
.bitsPerPixel = 0,
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,