@@ -103,7 +103,8 @@ formats_h = custom_target('formats_h',
input : files(
'../../src/libcamera/formats.yaml',
'formats.h.in',
- '../linux/upstream/linux/drm_fourcc.h'
+ '../linux/upstream/linux/drm_fourcc.h',
+ '../linux/changes/linux/drm_fourcc.h',
),
output : 'formats.h',
command : [gen_formats, '-o', '@OUTPUT@', '@INPUT@'],
new file mode 100644
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas on Board Oy
+ */
+
+#pragma once
+
+#include_next <linux/drm_fourcc.h>
+
+/* ========================================================================== */
+/* DRM formats */
+
+/* Compressed formats */
+#define DRM_FORMAT_MJPEG fourcc_code('M', 'J', 'P', 'G') /* Motion-JPEG */
+
+/*
+ * Bayer formats
+ *
+ * Bayer formats contain green, red and blue components, with alternating lines
+ * of red and green, and blue and green pixels in different orders. For each
+ * block of 2x2 pixels there is one pixel with a red filter, two with a green
+ * filter, and one with a blue filter. The filters can be arranged in different
+ * patterns.
+ *
+ * For example, RGGB:
+ * row0: RGRGRGRG...
+ * row1: GBGBGBGB...
+ * row3: RGRGRGRG...
+ * row4: GBGBGBGB...
+ * ...
+ *
+ * Vendors have different methods to pack the sampling formats to increase data
+ * density. For this reason the fourcc only describes pixel sample size and the
+ * filter pattern for each block of 2x2 pixels. A modifier is needed to
+ * describe the memory layout.
+ *
+ * In addition to vendor modifiers for memory layout DRM_FORMAT_MOD_LINEAR may
+ * be used to describe a layout where all samples are placed consecutively in
+ * memory. If the sample does not fit inside a single byte, the sample storage
+ * is extended to the minimum number of (little endian) bytes that can hold the
+ * sample and any unused most-significant bits are defined as padding.
+ *
+ * For example, SRGGB10:
+ * Each 10-bit sample is contained in 2 consecutive little endian bytes, where
+ * the 6 most-significant bits are unused.
+ */
+
+/* 8-bit Bayer formats */
+#define DRM_FORMAT_SRGGB8 fourcc_code('R', 'G', 'G', 'B')
+#define DRM_FORMAT_SGRBG8 fourcc_code('G', 'R', 'B', 'G')
+#define DRM_FORMAT_SGBRG8 fourcc_code('G', 'B', 'R', 'G')
+#define DRM_FORMAT_SBGGR8 fourcc_code('B', 'A', '8', '1')
+
+/* 10-bit Bayer formats */
+#define DRM_FORMAT_SRGGB10 fourcc_code('R', 'G', '1', '0')
+#define DRM_FORMAT_SGRBG10 fourcc_code('B', 'A', '1', '0')
+#define DRM_FORMAT_SGBRG10 fourcc_code('G', 'B', '1', '0')
+#define DRM_FORMAT_SBGGR10 fourcc_code('B', 'G', '1', '0')
+
+/* 12-bit Bayer formats */
+#define DRM_FORMAT_SRGGB12 fourcc_code('R', 'G', '1', '2')
+#define DRM_FORMAT_SGRBG12 fourcc_code('B', 'A', '1', '2')
+#define DRM_FORMAT_SGBRG12 fourcc_code('G', 'B', '1', '2')
+#define DRM_FORMAT_SBGGR12 fourcc_code('B', 'G', '1', '2')
+
+/* 14-bit Bayer formats */
+#define DRM_FORMAT_SRGGB14 fourcc_code('R', 'G', '1', '4')
+#define DRM_FORMAT_SGRBG14 fourcc_code('B', 'A', '1', '4')
+#define DRM_FORMAT_SGBRG14 fourcc_code('G', 'B', '1', '4')
+#define DRM_FORMAT_SBGGR14 fourcc_code('B', 'G', '1', '4')
+
+/* 16-bit Bayer formats */
+#define DRM_FORMAT_SRGGB16 fourcc_code('R', 'G', 'B', '6')
+#define DRM_FORMAT_SGRBG16 fourcc_code('G', 'R', '1', '6')
+#define DRM_FORMAT_SGBRG16 fourcc_code('G', 'B', '1', '6')
+#define DRM_FORMAT_SBGGR16 fourcc_code('B', 'Y', 'R', '2')
+
+
+/* ========================================================================== */
+/* DRM format modifiers */
+
+#define DRM_FORMAT_MOD_VENDOR_MIPI 0x0b
+#define DRM_FORMAT_MOD_VENDOR_RPI 0x0c
+
+/*
+ * IPU3 Bayer packing layout
+ *
+ * The IPU3 raw Bayer formats use a custom packing layout where there are no
+ * gaps between each 10-bit sample. It packs 25 pixels into 32 bytes leaving
+ * the 6 most significant bits in the last byte unused. The format is little
+ * endian.
+ */
+#define IPU3_FORMAT_MOD_PACKED fourcc_mod_code(INTEL, 13)
+
+/* Mobile Industry Processor Interface (MIPI) modifiers */
+
+/*
+ * MIPI CSI-2 packing layout
+ *
+ * The CSI-2 RAW formats (for example Bayer) use a different packing layout
+ * depenindg on the sample size.
+ *
+ * - 10-bits per sample
+ * Every four consecutive samples are packed into 5 bytes. Each of the first 4
+ * bytes contain the 8 high order bits of the pixels, and the 5th byte
+ * contains the 2 least-significant bits of each pixel, in the same order.
+ *
+ * - 12-bits per sample
+ * Every two consecutive samples are packed into three bytes. Each of the
+ * first two bytes contain the 8 high order bits of the pixels, and the third
+ * byte contains the four least-significant bits of each pixel, in the same
+ * order.
+ *
+ * - 14-bits per sample
+ * Every four consecutive samples are packed into seven bytes. Each of the
+ * first four bytes contain the eight high order bits of the pixels, and the
+ * three following bytes contains the six least-significant bits of each
+ * pixel, in the same order.
+ */
+#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)
+
+#define PISP_FORMAT_MOD_COMPRESS_MODE1 fourcc_mod_code(RPI, 1)
+#define PISP_FORMAT_MOD_COMPRESS_MODE2 fourcc_mod_code(RPI, 2)
new file mode 100644
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas on Board Oy
+ */
+
+#pragma once
+
+#include_next <linux/media-bus-format.h>
+
+/* Specific metadata formats. Next is 0x9003. */
+#define MEDIA_BUS_FMT_CCS_EMBEDDED 0x9001
+#define MEDIA_BUS_FMT_OV2740_EMBEDDED 0x9002
new file mode 100644
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas on Board Oy
+ */
+
+#pragma once
+
+#include_next <linux/media.h>
+
+#define MEDIA_PAD_FL_INTERNAL (1U << 3)
new file mode 100644
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas on Board Oy
+ */
+
+#pragma once
+
+#include_next <linux/v4l2-controls.h>
+
+/* The base for the bcm2835-isp driver controls.
+ * We reserve 16 controls for this driver. */
+#define V4L2_CID_USER_BCM2835_ISP_BASE (V4L2_CID_USER_BASE + 0x10e0)
new file mode 100644
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas on Board Oy
+ */
+
+#pragma once
+
+#include_next <linux/v4l2-subdev.h>
+
+/*
+ * Is the route immutable? The ACTIVE flag of an immutable route may not be
+ * unset.
+ */
+#define V4L2_SUBDEV_ROUTE_FL_IMMUTABLE (1U << 1)
new file mode 100644
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas on Board Oy
+ */
+
+#pragma once
+
+#include_next <linux/videodev2.h>
+
+#define V4L2_META_FMT_SENSOR_DATA v4l2_fourcc('S', 'E', 'N', 'S') /* Sensor Ancillary metadata */
+#define V4L2_META_FMT_BCM2835_ISP_STATS v4l2_fourcc('B', 'S', 'T', 'A') /* BCM2835 ISP image statistics output */
+
+/*
+ * Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when
+ * adding new ones!
+ */
+#define V4L2_META_FMT_GENERIC_8 v4l2_fourcc('M', 'E', 'T', '8') /* Generic 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'C', '1', 'A') /* 10-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'C', '1', 'C') /* 12-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'C', '1', 'E') /* 14-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_16 v4l2_fourcc('M', 'C', '1', 'G') /* 16-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'C', '1', 'K') /* 20-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_24 v4l2_fourcc('M', 'C', '1', 'O') /* 24-bit CSI-2 packed 8-bit metadata */
@@ -433,70 +433,6 @@ extern "C" {
#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */
#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
-/* Compressed formats */
-#define DRM_FORMAT_MJPEG fourcc_code('M', 'J', 'P', 'G') /* Motion-JPEG */
-
-/*
- * Bayer formats
- *
- * Bayer formats contain green, red and blue components, with alternating lines
- * of red and green, and blue and green pixels in different orders. For each
- * block of 2x2 pixels there is one pixel with a red filter, two with a green
- * filter, and one with a blue filter. The filters can be arranged in different
- * patterns.
- *
- * For example, RGGB:
- * row0: RGRGRGRG...
- * row1: GBGBGBGB...
- * row3: RGRGRGRG...
- * row4: GBGBGBGB...
- * ...
- *
- * Vendors have different methods to pack the sampling formats to increase data
- * density. For this reason the fourcc only describes pixel sample size and the
- * filter pattern for each block of 2x2 pixels. A modifier is needed to
- * describe the memory layout.
- *
- * In addition to vendor modifiers for memory layout DRM_FORMAT_MOD_LINEAR may
- * be used to describe a layout where all samples are placed consecutively in
- * memory. If the sample does not fit inside a single byte, the sample storage
- * is extended to the minimum number of (little endian) bytes that can hold the
- * sample and any unused most-significant bits are defined as padding.
- *
- * For example, SRGGB10:
- * Each 10-bit sample is contained in 2 consecutive little endian bytes, where
- * the 6 most-significant bits are unused.
- */
-
-/* 8-bit Bayer formats */
-#define DRM_FORMAT_SRGGB8 fourcc_code('R', 'G', 'G', 'B')
-#define DRM_FORMAT_SGRBG8 fourcc_code('G', 'R', 'B', 'G')
-#define DRM_FORMAT_SGBRG8 fourcc_code('G', 'B', 'R', 'G')
-#define DRM_FORMAT_SBGGR8 fourcc_code('B', 'A', '8', '1')
-
-/* 10-bit Bayer formats */
-#define DRM_FORMAT_SRGGB10 fourcc_code('R', 'G', '1', '0')
-#define DRM_FORMAT_SGRBG10 fourcc_code('B', 'A', '1', '0')
-#define DRM_FORMAT_SGBRG10 fourcc_code('G', 'B', '1', '0')
-#define DRM_FORMAT_SBGGR10 fourcc_code('B', 'G', '1', '0')
-
-/* 12-bit Bayer formats */
-#define DRM_FORMAT_SRGGB12 fourcc_code('R', 'G', '1', '2')
-#define DRM_FORMAT_SGRBG12 fourcc_code('B', 'A', '1', '2')
-#define DRM_FORMAT_SGBRG12 fourcc_code('G', 'B', '1', '2')
-#define DRM_FORMAT_SBGGR12 fourcc_code('B', 'G', '1', '2')
-
-/* 14-bit Bayer formats */
-#define DRM_FORMAT_SRGGB14 fourcc_code('R', 'G', '1', '4')
-#define DRM_FORMAT_SGRBG14 fourcc_code('B', 'A', '1', '4')
-#define DRM_FORMAT_SGBRG14 fourcc_code('G', 'B', '1', '4')
-#define DRM_FORMAT_SBGGR14 fourcc_code('B', 'G', '1', '4')
-
-/* 16-bit Bayer formats */
-#define DRM_FORMAT_SRGGB16 fourcc_code('R', 'G', 'B', '6')
-#define DRM_FORMAT_SGRBG16 fourcc_code('G', 'R', '1', '6')
-#define DRM_FORMAT_SGBRG16 fourcc_code('G', 'B', '1', '6')
-#define DRM_FORMAT_SBGGR16 fourcc_code('B', 'Y', 'R', '2')
/*
* Format Modifiers:
@@ -523,8 +459,6 @@ extern "C" {
#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a
#define DRM_FORMAT_MOD_VENDOR_MTK 0x0b
#define DRM_FORMAT_MOD_VENDOR_APPLE 0x0c
-#define DRM_FORMAT_MOD_VENDOR_MIPI 0x0b
-#define DRM_FORMAT_MOD_VENDOR_RPI 0x0c
/* add more to the end as needed */
@@ -831,16 +765,6 @@ extern "C" {
*/
#define I915_FORMAT_MOD_4_TILED_BMG_CCS fourcc_mod_code(INTEL, 17)
-/*
- * IPU3 Bayer packing layout
- *
- * The IPU3 raw Bayer formats use a custom packing layout where there are no
- * gaps between each 10-bit sample. It packs 25 pixels into 32 bytes leaving
- * the 6 most significant bits in the last byte unused. The format is little
- * endian.
- */
-#define IPU3_FORMAT_MOD_PACKED fourcc_mod_code(INTEL, 13)
-
/*
* Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
*
@@ -1829,36 +1753,6 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
#define AMD_FMT_MOD_CLEAR(field) \
(~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
-/* Mobile Industry Processor Interface (MIPI) modifiers */
-
-/*
- * MIPI CSI-2 packing layout
- *
- * The CSI-2 RAW formats (for example Bayer) use a different packing layout
- * depenindg on the sample size.
- *
- * - 10-bits per sample
- * Every four consecutive samples are packed into 5 bytes. Each of the first 4
- * bytes contain the 8 high order bits of the pixels, and the 5th byte
- * contains the 2 least-significant bits of each pixel, in the same order.
- *
- * - 12-bits per sample
- * Every two consecutive samples are packed into three bytes. Each of the
- * first two bytes contain the 8 high order bits of the pixels, and the third
- * byte contains the four least-significant bits of each pixel, in the same
- * order.
- *
- * - 14-bits per sample
- * Every four consecutive samples are packed into seven bytes. Each of the
- * first four bytes contain the eight high order bits of the pixels, and the
- * three following bytes contains the six least-significant bits of each
- * pixel, in the same order.
- */
-#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)
-
-#define PISP_FORMAT_MOD_COMPRESS_MODE1 fourcc_mod_code(RPI, 1)
-#define PISP_FORMAT_MOD_COMPRESS_MODE2 fourcc_mod_code(RPI, 2)
-
#if defined(__cplusplus)
}
#endif
@@ -190,8 +190,4 @@
#define MEDIA_BUS_FMT_META_20 0x8006
#define MEDIA_BUS_FMT_META_24 0x8007
-/* Specific metadata formats. Next is 0x9003. */
-#define MEDIA_BUS_FMT_CCS_EMBEDDED 0x9001
-#define MEDIA_BUS_FMT_OV2740_EMBEDDED 0x9002
-
#endif /* __LINUX_MEDIA_BUS_FORMAT_H */
@@ -206,7 +206,6 @@ struct media_entity_desc {
#define MEDIA_PAD_FL_SINK (1U << 0)
#define MEDIA_PAD_FL_SOURCE (1U << 1)
#define MEDIA_PAD_FL_MUST_CONNECT (1U << 2)
-#define MEDIA_PAD_FL_INTERNAL (1U << 3)
struct media_pad_desc {
__u32 entity; /* entity ID */
@@ -177,10 +177,6 @@ enum v4l2_colorfx {
* We reserve 128 controls for this driver.
*/
#define V4L2_CID_USER_CCS_BASE (V4L2_CID_USER_BASE + 0x10f0)
-
-/* The base for the bcm2835-isp driver controls.
- * We reserve 16 controls for this driver. */
-#define V4L2_CID_USER_BCM2835_ISP_BASE (V4L2_CID_USER_BASE + 0x10e0)
/*
* The base for Allegro driver controls.
* We reserve 16 controls for this driver.
@@ -204,11 +204,6 @@ struct v4l2_subdev_capability {
* on a video node.
*/
#define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0)
-/*
- * Is the route immutable? The ACTIVE flag of an immutable route may not be
- * unset.
- */
-#define V4L2_SUBDEV_ROUTE_FL_IMMUTABLE (1U << 1)
/**
* struct v4l2_subdev_route - A route inside a subdev
@@ -843,8 +843,6 @@ struct v4l2_pix_format {
#define V4L2_META_FMT_D4XX v4l2_fourcc('D', '4', 'X', 'X') /* D4XX Payload Header metadata */
#define V4L2_META_FMT_UVC_MSXU_1_5 v4l2_fourcc('U', 'V', 'C', 'M') /* UVC MSXU metadata */
#define V4L2_META_FMT_VIVID v4l2_fourcc('V', 'I', 'V', 'D') /* Vivid Metadata */
-#define V4L2_META_FMT_SENSOR_DATA v4l2_fourcc('S', 'E', 'N', 'S') /* Sensor Ancillary metadata */
-#define V4L2_META_FMT_BCM2835_ISP_STATS v4l2_fourcc('B', 'S', 'T', 'A') /* BCM2835 ISP image statistics output */
/* Vendor specific - used for RK_ISP1 camera sub-system */
#define V4L2_META_FMT_RK_ISP1_PARAMS v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */
@@ -864,17 +862,6 @@ struct v4l2_pix_format {
#define V4L2_META_FMT_MALI_C55_PARAMS v4l2_fourcc('C', '5', '5', 'P') /* ARM Mali-C55 Parameters */
#define V4L2_META_FMT_MALI_C55_STATS v4l2_fourcc('C', '5', '5', 'S') /* ARM Mali-C55 3A Statistics */
-/*
- * Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when
- * adding new ones!
- */
-#define V4L2_META_FMT_GENERIC_8 v4l2_fourcc('M', 'E', 'T', '8') /* Generic 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'C', '1', 'A') /* 10-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'C', '1', 'C') /* 12-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'C', '1', 'E') /* 14-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_16 v4l2_fourcc('M', 'C', '1', 'G') /* 16-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'C', '1', 'K') /* 20-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_24 v4l2_fourcc('M', 'C', '1', 'O') /* 24-bit CSI-2 packed 8-bit metadata */
/* priv field value to indicates that subsequent fields are valid. */
#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe
@@ -202,6 +202,7 @@ add_project_link_arguments(cpp_arguments, language : 'cpp')
libcamera_includes = include_directories(
'include',
+ 'include/linux/changes',
'include/linux/upstream',
)
Mirror the "upstream" directory and create a header for each file that has local changes. Make those files contain the local changes and use `#include_next` to include the upstream headers. And undo the local changes from the "upstream" header files. The main advantage is that it is clear what is a local addition and what is an upstream thing. This should make it easier to update the headers and resolve potential conflicts. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- include/libcamera/meson.build | 3 +- include/linux/changes/linux/drm_fourcc.h | 123 ++++++++++++++++++ .../linux/changes/linux/media-bus-format.h | 12 ++ include/linux/changes/linux/media.h | 10 ++ include/linux/changes/linux/v4l2-controls.h | 12 ++ include/linux/changes/linux/v4l2-subdev.h | 14 ++ include/linux/changes/linux/videodev2.h | 23 ++++ include/linux/upstream/linux/drm_fourcc.h | 106 --------------- .../linux/upstream/linux/media-bus-format.h | 4 - include/linux/upstream/linux/media.h | 1 - include/linux/upstream/linux/v4l2-controls.h | 4 - include/linux/upstream/linux/v4l2-subdev.h | 5 - include/linux/upstream/linux/videodev2.h | 13 -- meson.build | 1 + 14 files changed, 197 insertions(+), 134 deletions(-) create mode 100644 include/linux/changes/linux/drm_fourcc.h create mode 100644 include/linux/changes/linux/media-bus-format.h create mode 100644 include/linux/changes/linux/media.h create mode 100644 include/linux/changes/linux/v4l2-controls.h create mode 100644 include/linux/changes/linux/v4l2-subdev.h create mode 100644 include/linux/changes/linux/videodev2.h