[RFC,v2,3/3] include: linux: Move local changes to separate headers
diff mbox series

Message ID 20261126091103.1843573-4-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • include: linux: Split local changes
Related show

Commit Message

Barnabás Pőcze Nov. 26, 2026, 9:11 a.m. UTC
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                 |   1 +
 include/linux/local/linux/drm_fourcc.h        | 123 ++++++++++++++++++
 include/linux/local/linux/media-bus-format.h  |  12 ++
 include/linux/local/linux/media.h             |  10 ++
 include/linux/local/linux/v4l2-controls.h     |  12 ++
 include/linux/local/linux/v4l2-subdev.h       |  14 ++
 include/linux/local/linux/videodev2.h         |  23 ++++
 include/linux/upstream/linux/drm_fourcc.h     | 117 -----------------
 .../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      |  14 --
 meson.build                                   |   1 +
 14 files changed, 196 insertions(+), 145 deletions(-)
 create mode 100644 include/linux/local/linux/drm_fourcc.h
 create mode 100644 include/linux/local/linux/media-bus-format.h
 create mode 100644 include/linux/local/linux/media.h
 create mode 100644 include/linux/local/linux/v4l2-controls.h
 create mode 100644 include/linux/local/linux/v4l2-subdev.h
 create mode 100644 include/linux/local/linux/videodev2.h

Comments

Kieran Bingham Nov. 26, 2026, 9:45 a.m. UTC | #1
Quoting Barnabás Pőcze (2026-11-26 09:11:03)
> 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.




I know in the previous version I talked about what could go wrong, and
I think we can solve those as they come up.

I could also envisage later adding another step of automation for
updates which pulls in the latest kernel headers and iterates over any
definition in local/ and prints a warning/error if there's a match in
upstream/ so my worries from before are also probably solvable..

I like this a lot, and I'd be happy to merge these so:

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  include/libcamera/meson.build                 |   1 +
>  include/linux/local/linux/drm_fourcc.h        | 123 ++++++++++++++++++
>  include/linux/local/linux/media-bus-format.h  |  12 ++
>  include/linux/local/linux/media.h             |  10 ++
>  include/linux/local/linux/v4l2-controls.h     |  12 ++
>  include/linux/local/linux/v4l2-subdev.h       |  14 ++
>  include/linux/local/linux/videodev2.h         |  23 ++++
>  include/linux/upstream/linux/drm_fourcc.h     | 117 -----------------
>  .../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      |  14 --
>  meson.build                                   |   1 +
>  14 files changed, 196 insertions(+), 145 deletions(-)
>  create mode 100644 include/linux/local/linux/drm_fourcc.h
>  create mode 100644 include/linux/local/linux/media-bus-format.h
>  create mode 100644 include/linux/local/linux/media.h
>  create mode 100644 include/linux/local/linux/v4l2-controls.h
>  create mode 100644 include/linux/local/linux/v4l2-subdev.h
>  create mode 100644 include/linux/local/linux/videodev2.h
> 
> diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
> index 931b5de582..5d1e3488dc 100644
> --- a/include/libcamera/meson.build
> +++ b/include/libcamera/meson.build
> @@ -104,6 +104,7 @@ formats_h = custom_target('formats_h',
>                                '../../src/libcamera/formats.yaml',
>                                'formats.h.in',
>                                '../linux/upstream/linux/drm_fourcc.h',
> +                              '../linux/local/linux/drm_fourcc.h',
>                            ),
>                            output : 'formats.h',
>                            command : [gen_formats, '-o', '@OUTPUT@', '@INPUT@'],
> diff --git a/include/linux/local/linux/drm_fourcc.h b/include/linux/local/linux/drm_fourcc.h
> new file mode 100644
> index 0000000000..69fd1c6014
> --- /dev/null
> +++ b/include/linux/local/linux/drm_fourcc.h
> @@ -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)
> diff --git a/include/linux/local/linux/media-bus-format.h b/include/linux/local/linux/media-bus-format.h
> new file mode 100644
> index 0000000000..3fefd5ee6f
> --- /dev/null
> +++ b/include/linux/local/linux/media-bus-format.h
> @@ -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
> diff --git a/include/linux/local/linux/media.h b/include/linux/local/linux/media.h
> new file mode 100644
> index 0000000000..01495fad17
> --- /dev/null
> +++ b/include/linux/local/linux/media.h
> @@ -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)
> diff --git a/include/linux/local/linux/v4l2-controls.h b/include/linux/local/linux/v4l2-controls.h
> new file mode 100644
> index 0000000000..2dbfe23b74
> --- /dev/null
> +++ b/include/linux/local/linux/v4l2-controls.h
> @@ -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)
> diff --git a/include/linux/local/linux/v4l2-subdev.h b/include/linux/local/linux/v4l2-subdev.h
> new file mode 100644
> index 0000000000..5f8c9e0700
> --- /dev/null
> +++ b/include/linux/local/linux/v4l2-subdev.h
> @@ -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)
> diff --git a/include/linux/local/linux/videodev2.h b/include/linux/local/linux/videodev2.h
> new file mode 100644
> index 0000000000..5bb46e1318
> --- /dev/null
> +++ b/include/linux/local/linux/videodev2.h
> @@ -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 */
> diff --git a/include/linux/upstream/linux/drm_fourcc.h b/include/linux/upstream/linux/drm_fourcc.h
> index 51033f08c2..8888cdd58b 100644
> --- a/include/linux/upstream/linux/drm_fourcc.h
> +++ b/include/linux/upstream/linux/drm_fourcc.h
> @@ -451,81 +451,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 */
>  
> -/*
> - * Y-only (greyscale) formats
> - *
> - * The Y-only formats are handled similarly to the YCbCr formats in the display
> - * pipeline, with the Cb and Cr implicitly neutral (0.0 in nominal values). This
> - * also means that COLOR_RANGE property applies to the Y-only formats.
> - */
> -
> -#define DRM_FORMAT_Y8          fourcc_code('G', 'R', 'E', 'Y')  /* 8-bit Y-only */
> -#define DRM_FORMAT_XYYY2101010 fourcc_code('Y', 'P', 'A', '4')  /* [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian */
> -
> -/* 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:
> @@ -552,8 +477,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 */
>  
> @@ -860,16 +783,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
>   *
> @@ -2055,36 +1968,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
> diff --git a/include/linux/upstream/linux/media-bus-format.h b/include/linux/upstream/linux/media-bus-format.h
> index 3e1c867e90..6005f033e6 100644
> --- a/include/linux/upstream/linux/media-bus-format.h
> +++ b/include/linux/upstream/linux/media-bus-format.h
> @@ -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 */
> diff --git a/include/linux/upstream/linux/media.h b/include/linux/upstream/linux/media.h
> index 4a733b9beb..b5a77bbf40 100644
> --- a/include/linux/upstream/linux/media.h
> +++ b/include/linux/upstream/linux/media.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 */
> diff --git a/include/linux/upstream/linux/v4l2-controls.h b/include/linux/upstream/linux/v4l2-controls.h
> index 9834301d7d..c12f5ff81f 100644
> --- a/include/linux/upstream/linux/v4l2-controls.h
> +++ b/include/linux/upstream/linux/v4l2-controls.h
> @@ -186,10 +186,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.
> diff --git a/include/linux/upstream/linux/v4l2-subdev.h b/include/linux/upstream/linux/v4l2-subdev.h
> index 839b1329af..2347e266cf 100644
> --- a/include/linux/upstream/linux/v4l2-subdev.h
> +++ b/include/linux/upstream/linux/v4l2-subdev.h
> @@ -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
> diff --git a/include/linux/upstream/linux/videodev2.h b/include/linux/upstream/linux/videodev2.h
> index c823409c7f..7d63fd2b8e 100644
> --- a/include/linux/upstream/linux/videodev2.h
> +++ b/include/linux/upstream/linux/videodev2.h
> @@ -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 */
> @@ -868,18 +866,6 @@ struct v4l2_pix_format {
>  #define V4L2_META_FMT_RPPX1_PARAMS     v4l2_fourcc('D', 'R', '1', 'P') /* Dreamchip RPP-X1 Parameters */
>  #define V4L2_META_FMT_RPPX1_STATS      v4l2_fourcc('D', 'R', '1', 'S') /* Dreamchip RPP-X1 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
>  
> diff --git a/meson.build b/meson.build
> index d0c6f50791..d6f0e0ed83 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -202,6 +202,7 @@ add_project_link_arguments(cpp_arguments, language : 'cpp')
>  
>  libcamera_includes = include_directories(
>      'include',
> +    'include/linux/local',
>      'include/linux/upstream',
>  )
>  
> -- 
> 2.56.1
>

Patch
diff mbox series

diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
index 931b5de582..5d1e3488dc 100644
--- a/include/libcamera/meson.build
+++ b/include/libcamera/meson.build
@@ -104,6 +104,7 @@  formats_h = custom_target('formats_h',
                               '../../src/libcamera/formats.yaml',
                               'formats.h.in',
                               '../linux/upstream/linux/drm_fourcc.h',
+                              '../linux/local/linux/drm_fourcc.h',
                           ),
                           output : 'formats.h',
                           command : [gen_formats, '-o', '@OUTPUT@', '@INPUT@'],
diff --git a/include/linux/local/linux/drm_fourcc.h b/include/linux/local/linux/drm_fourcc.h
new file mode 100644
index 0000000000..69fd1c6014
--- /dev/null
+++ b/include/linux/local/linux/drm_fourcc.h
@@ -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)
diff --git a/include/linux/local/linux/media-bus-format.h b/include/linux/local/linux/media-bus-format.h
new file mode 100644
index 0000000000..3fefd5ee6f
--- /dev/null
+++ b/include/linux/local/linux/media-bus-format.h
@@ -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
diff --git a/include/linux/local/linux/media.h b/include/linux/local/linux/media.h
new file mode 100644
index 0000000000..01495fad17
--- /dev/null
+++ b/include/linux/local/linux/media.h
@@ -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)
diff --git a/include/linux/local/linux/v4l2-controls.h b/include/linux/local/linux/v4l2-controls.h
new file mode 100644
index 0000000000..2dbfe23b74
--- /dev/null
+++ b/include/linux/local/linux/v4l2-controls.h
@@ -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)
diff --git a/include/linux/local/linux/v4l2-subdev.h b/include/linux/local/linux/v4l2-subdev.h
new file mode 100644
index 0000000000..5f8c9e0700
--- /dev/null
+++ b/include/linux/local/linux/v4l2-subdev.h
@@ -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)
diff --git a/include/linux/local/linux/videodev2.h b/include/linux/local/linux/videodev2.h
new file mode 100644
index 0000000000..5bb46e1318
--- /dev/null
+++ b/include/linux/local/linux/videodev2.h
@@ -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 */
diff --git a/include/linux/upstream/linux/drm_fourcc.h b/include/linux/upstream/linux/drm_fourcc.h
index 51033f08c2..8888cdd58b 100644
--- a/include/linux/upstream/linux/drm_fourcc.h
+++ b/include/linux/upstream/linux/drm_fourcc.h
@@ -451,81 +451,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 */
 
-/*
- * Y-only (greyscale) formats
- *
- * The Y-only formats are handled similarly to the YCbCr formats in the display
- * pipeline, with the Cb and Cr implicitly neutral (0.0 in nominal values). This
- * also means that COLOR_RANGE property applies to the Y-only formats.
- */
-
-#define DRM_FORMAT_Y8		fourcc_code('G', 'R', 'E', 'Y')  /* 8-bit Y-only */
-#define DRM_FORMAT_XYYY2101010	fourcc_code('Y', 'P', 'A', '4')  /* [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian */
-
-/* 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:
@@ -552,8 +477,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 */
 
@@ -860,16 +783,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
  *
@@ -2055,36 +1968,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
diff --git a/include/linux/upstream/linux/media-bus-format.h b/include/linux/upstream/linux/media-bus-format.h
index 3e1c867e90..6005f033e6 100644
--- a/include/linux/upstream/linux/media-bus-format.h
+++ b/include/linux/upstream/linux/media-bus-format.h
@@ -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 */
diff --git a/include/linux/upstream/linux/media.h b/include/linux/upstream/linux/media.h
index 4a733b9beb..b5a77bbf40 100644
--- a/include/linux/upstream/linux/media.h
+++ b/include/linux/upstream/linux/media.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 */
diff --git a/include/linux/upstream/linux/v4l2-controls.h b/include/linux/upstream/linux/v4l2-controls.h
index 9834301d7d..c12f5ff81f 100644
--- a/include/linux/upstream/linux/v4l2-controls.h
+++ b/include/linux/upstream/linux/v4l2-controls.h
@@ -186,10 +186,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.
diff --git a/include/linux/upstream/linux/v4l2-subdev.h b/include/linux/upstream/linux/v4l2-subdev.h
index 839b1329af..2347e266cf 100644
--- a/include/linux/upstream/linux/v4l2-subdev.h
+++ b/include/linux/upstream/linux/v4l2-subdev.h
@@ -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
diff --git a/include/linux/upstream/linux/videodev2.h b/include/linux/upstream/linux/videodev2.h
index c823409c7f..7d63fd2b8e 100644
--- a/include/linux/upstream/linux/videodev2.h
+++ b/include/linux/upstream/linux/videodev2.h
@@ -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 */
@@ -868,18 +866,6 @@  struct v4l2_pix_format {
 #define V4L2_META_FMT_RPPX1_PARAMS	v4l2_fourcc('D', 'R', '1', 'P') /* Dreamchip RPP-X1 Parameters */
 #define V4L2_META_FMT_RPPX1_STATS	v4l2_fourcc('D', 'R', '1', 'S') /* Dreamchip RPP-X1 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
 
diff --git a/meson.build b/meson.build
index d0c6f50791..d6f0e0ed83 100644
--- a/meson.build
+++ b/meson.build
@@ -202,6 +202,7 @@  add_project_link_arguments(cpp_arguments, language : 'cpp')
 
 libcamera_includes = include_directories(
     'include',
+    'include/linux/local',
     'include/linux/upstream',
 )