summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-22 03:49:26 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-06-18 13:26:36 +0300
commite8dc74317afa43ffa4096e7e7e0c25b5c5189682 (patch)
tree259b9df651935b40e807c1219034ad02cb7159ac /src
parent469a85f74d631a83e325982d4101909e5e0a7834 (diff)
libcamera: Define constants for pixel formats in the public API
libcamera uses pixel format FourCC and modifier values from DRM. This requires inclusion of drm_fourcc.h, creating a dependency on a header that is packaged differently between distributions, and causing possible issues with third-party applications. Define constants for the supported pixel formats in the new formats.h public API header, in order to remove the dependency on drm_fourcc.h. The header is generated by a Python script from a list of supported formats. The numerical values for the FourCC and modifier are extracted from drm_fourcc.h by the script, ensuring that numerical values are not inadvertently modified and preserving the direct interoperability. The pixel formats constants can't be generated solely from drm_fourcc.h, as that header defines FourCC values and modifier values, but doesn't list the valid combinations. The supported formats are thus stored in a YAML file, which contains the FourCC and optional modifier for each supported format. We may later extend the YAML file to include formats documentation, and possibly formats metadata to populate the pixelFormatInfo map (in formats.cpp) automatically. Now that two formats.h header are present (one in include/libcamera/ and one in include/libcamera/internal/), we need to explicitly qualify the Doxygen \file directive with a path. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/formats.cpp2
-rw-r--r--src/libcamera/formats.yaml124
-rw-r--r--src/libcamera/meson.build3
-rw-r--r--src/libcamera/pixel_format.cpp4
4 files changed, 130 insertions, 3 deletions
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 2ac3b412..74c239a5 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -12,7 +12,7 @@
#include "libcamera/internal/log.h"
/**
- * \file formats.h
+ * \file internal/formats.h
* \brief Types and helper methods to handle libcamera image formats
*/
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
new file mode 100644
index 00000000..a6841c61
--- /dev/null
+++ b/src/libcamera/formats.yaml
@@ -0,0 +1,124 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# Copyright (C) 2020, Google Inc.
+#
+%YAML 1.2
+---
+formats:
+ - R8:
+ fourcc: DRM_FORMAT_R8
+
+ - RGB888:
+ fourcc: DRM_FORMAT_RGB888
+ - BGR888:
+ fourcc: DRM_FORMAT_BGR888
+
+ - XRGB8888:
+ fourcc: DRM_FORMAT_XRGB8888
+ - XBGR8888:
+ fourcc: DRM_FORMAT_XBGR8888
+ - RGBX8888:
+ fourcc: DRM_FORMAT_RGBX8888
+ - BGRX8888:
+ fourcc: DRM_FORMAT_BGRX8888
+
+ - ARGB8888:
+ fourcc: DRM_FORMAT_ARGB8888
+ - ABGR8888:
+ fourcc: DRM_FORMAT_ABGR8888
+ - RGBA8888:
+ fourcc: DRM_FORMAT_RGBA8888
+ - BGRA8888:
+ fourcc: DRM_FORMAT_BGRA8888
+
+ - YUYV:
+ fourcc: DRM_FORMAT_YUYV
+ - YVYU:
+ fourcc: DRM_FORMAT_YVYU
+ - UYVY:
+ fourcc: DRM_FORMAT_UYVY
+ - VYUY:
+ fourcc: DRM_FORMAT_VYUY
+
+ - NV12:
+ fourcc: DRM_FORMAT_NV12
+ - NV21:
+ fourcc: DRM_FORMAT_NV21
+ - NV16:
+ fourcc: DRM_FORMAT_NV16
+ - NV61:
+ fourcc: DRM_FORMAT_NV61
+ - NV24:
+ fourcc: DRM_FORMAT_NV24
+ - NV42:
+ fourcc: DRM_FORMAT_NV42
+
+ - MJPEG:
+ fourcc: DRM_FORMAT_MJPEG
+
+ - SRGGB8:
+ fourcc: DRM_FORMAT_SRGGB8
+ - SGRBG8:
+ fourcc: DRM_FORMAT_SGRBG8
+ - SGBRG8:
+ fourcc: DRM_FORMAT_SGBRG8
+ - SBGGR8:
+ fourcc: DRM_FORMAT_SBGGR8
+
+ - SRGGB10:
+ fourcc: DRM_FORMAT_SRGGB10
+ - SGRBG10:
+ fourcc: DRM_FORMAT_SGRBG10
+ - SGBRG10:
+ fourcc: DRM_FORMAT_SGBRG10
+ - SBGGR10:
+ fourcc: DRM_FORMAT_SBGGR10
+
+ - SRGGB12:
+ fourcc: DRM_FORMAT_SRGGB12
+ - SGRBG12:
+ fourcc: DRM_FORMAT_SGRBG12
+ - SGBRG12:
+ fourcc: DRM_FORMAT_SGBRG12
+ - SBGGR12:
+ fourcc: DRM_FORMAT_SBGGR12
+
+ - SRGGB10_CSI2P:
+ fourcc: DRM_FORMAT_SRGGB10
+ mod: MIPI_FORMAT_MOD_CSI2_PACKED
+ - SGRBG10_CSI2P:
+ fourcc: DRM_FORMAT_SGRBG10
+ mod: MIPI_FORMAT_MOD_CSI2_PACKED
+ - SGBRG10_CSI2P:
+ fourcc: DRM_FORMAT_SGBRG10
+ mod: MIPI_FORMAT_MOD_CSI2_PACKED
+ - SBGGR10_CSI2P:
+ fourcc: DRM_FORMAT_SBGGR10
+ mod: MIPI_FORMAT_MOD_CSI2_PACKED
+
+ - SRGGB12_CSI2P:
+ fourcc: DRM_FORMAT_SRGGB12
+ mod: MIPI_FORMAT_MOD_CSI2_PACKED
+ - SGRBG12_CSI2P:
+ fourcc: DRM_FORMAT_SGRBG12
+ mod: MIPI_FORMAT_MOD_CSI2_PACKED
+ - SGBRG12_CSI2P:
+ fourcc: DRM_FORMAT_SGBRG12
+ mod: MIPI_FORMAT_MOD_CSI2_PACKED
+ - SBGGR12_CSI2P:
+ fourcc: DRM_FORMAT_SBGGR12
+ mod: MIPI_FORMAT_MOD_CSI2_PACKED
+
+ - SRGGB10_IPU3:
+ fourcc: DRM_FORMAT_SRGGB10
+ mod: IPU3_FORMAT_MOD_PACKED
+ - SGRBG10_IPU3:
+ fourcc: DRM_FORMAT_SGRBG10
+ mod: IPU3_FORMAT_MOD_PACKED
+ - SGBRG10_IPU3:
+ fourcc: DRM_FORMAT_SGBRG10
+ mod: IPU3_FORMAT_MOD_PACKED
+ - SBGGR10_IPU3:
+ fourcc: DRM_FORMAT_SBGGR10
+ mod: IPU3_FORMAT_MOD_PACKED
+...
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index 611fc061..3aad4386 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -51,6 +51,8 @@ libcamera_sources = files([
'v4l2_videodevice.cpp',
])
+libcamera_sources += libcamera_public_headers
+
includes = [
libcamera_includes,
]
@@ -87,7 +89,6 @@ foreach source : control_source_files
command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@'])
endforeach
-libcamera_sources += control_headers
libcamera_sources += control_sources
gen_version = join_paths(meson.source_root(), 'utils', 'gen-version.sh')
diff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp
index d501c5f0..f191851a 100644
--- a/src/libcamera/pixel_format.cpp
+++ b/src/libcamera/pixel_format.cpp
@@ -5,6 +5,7 @@
* pixel_format.cpp - libcamera Pixel Format
*/
+#include <libcamera/formats.h>
#include <libcamera/pixel_format.h>
/**
@@ -21,7 +22,8 @@ namespace libcamera {
* The PixelFormat type describes the format of images in the public libcamera
* API. It stores a FourCC value as a 32-bit unsigned integer and a modifier.
* The FourCC and modifier values are defined in the Linux kernel DRM/KMS API
- * (see linux/drm_fourcc.h).
+ * (see linux/drm_fourcc.h). Constant expressions for all pixel formats
+ * supported by libcamera are available in libcamera/formats.h.
*/
/**