[libcamera-devel,05/10] libcamera: Define PixelFormat type

Message ID 20191027234312.35284-6-jacopo@jmondi.org
State Superseded
Headers show
Series
  • libcamera: Use DRM_FORMAT_* fourcc codes
Related show

Commit Message

Jacopo Mondi Oct. 27, 2019, 11:43 p.m. UTC
Define a PixelFormat type as a simple typedef to an uin32_t which
aliases the DRM/KMS-defined fourcc pixel format codes.

The usage of a dedicated type allows better separation between image
format codes used internally (ie. V4L2-defined pixel formats and media
bus codes) and application-facing image formats which use the
DRM_FORMAT_* pixel codes.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 include/libcamera/meson.build    |  1 +
 include/libcamera/pixelformats.h | 18 ++++++++++++++++++
 src/libcamera/meson.build        |  1 +
 src/libcamera/pixelformats.cpp   | 28 ++++++++++++++++++++++++++++
 4 files changed, 48 insertions(+)
 create mode 100644 include/libcamera/pixelformats.h
 create mode 100644 src/libcamera/pixelformats.cpp

Patch

diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
index ed8ff917e35a..99abf0609940 100644
--- a/include/libcamera/meson.build
+++ b/include/libcamera/meson.build
@@ -9,6 +9,7 @@  libcamera_api = files([
     'geometry.h',
     'logging.h',
     'object.h',
+    'pixelformats.h',
     'request.h',
     'signal.h',
     'stream.h',
diff --git a/include/libcamera/pixelformats.h b/include/libcamera/pixelformats.h
new file mode 100644
index 000000000000..6e25b8d8b76e
--- /dev/null
+++ b/include/libcamera/pixelformats.h
@@ -0,0 +1,18 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * pixelformats.h - libcamera pixel formats
+ */
+#ifndef __LIBCAMERA_PIXEL_FORMATS_H__
+#define __LIBCAMERA_PIXEL_FORMATS_H__
+
+#include <stdint.h>
+
+namespace libcamera {
+
+using PixelFormat = uint32_t;
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_PIXEL_FORMATS_H__ */
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index d329820b9582..f201f408ef07 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -25,6 +25,7 @@  libcamera_sources = files([
     'message.cpp',
     'object.cpp',
     'pipeline_handler.cpp',
+    'pixelformats.cpp',
     'process.cpp',
     'request.cpp',
     'signal.cpp',
diff --git a/src/libcamera/pixelformats.cpp b/src/libcamera/pixelformats.cpp
new file mode 100644
index 000000000000..c03335400b70
--- /dev/null
+++ b/src/libcamera/pixelformats.cpp
@@ -0,0 +1,28 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * pixelformats.cpp - libcamera pixel formats
+ */
+
+#include <libcamera/pixelformats.h>
+
+/**
+ * \file pixelformats.h
+ * \brief libcamera pixel formats
+ */
+
+namespace libcamera {
+
+/**
+ * \typedef PixelFormat
+ * \brief libcamera image pixel format
+ *
+ * The PixelFormat type describes the format of images in the public libcamera
+ * API. It stores a FourCC value as a 32-bit unsigned integer. The values are
+ * defined in the Linux kernel DRM/KMS API (see linux/drm_fourcc.h).
+ *
+ * \todo Add support for format modifiers
+ */
+
+} /* namespace libcamera */