[v2,2/5] include: linux: Update kernel headers to version v6.10-rc1
diff mbox series

Message ID 20240530171600.259495-3-hdegoede@redhat.com
State Accepted
Headers show
Series
  • libcamera: dma_buffer_allocator: Add support for using udmabuf to alloc dma-buffers
Related show

Commit Message

Hans de Goede May 30, 2024, 5:15 p.m. UTC
Updated kernel headers to v6.10-rc1 using utils/update-kernel-headers.sh
and re-instating libcamera local modifications.

This includes adding include/linux/udmabuf.h which was not part
of libcamera's include/linux headers before.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 include/linux/README             |  2 +-
 include/linux/drm_fourcc.h       | 10 ++---
 include/linux/media-bus-format.h |  9 ++++
 include/linux/rkisp1-config.h    | 56 +++++++++++++------------
 include/linux/udmabuf.h          | 33 +++++++++++++++
 include/linux/v4l2-controls.h    |  6 +++
 include/linux/v4l2-mediabus.h    | 18 +++++---
 include/linux/v4l2-subdev.h      | 29 ++++++++++---
 include/linux/videodev2.h        | 72 ++++++++++++++++++++++++--------
 9 files changed, 172 insertions(+), 63 deletions(-)
 create mode 100644 include/linux/udmabuf.h

Comments

Kieran Bingham May 30, 2024, 9:47 p.m. UTC | #1
Quoting Hans de Goede (2024-05-30 18:15:57)
> Updated kernel headers to v6.10-rc1 using utils/update-kernel-headers.sh
> and re-instating libcamera local modifications.
> 
> This includes adding include/linux/udmabuf.h which was not part
> of libcamera's include/linux headers before.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

I thought I recalled we added something locally before it got merged for
RPi formats - but there's nothing being lost / removed here so I think
we're all good.

And the checkstyle warnings you mentioned are fine here. We should
figure out how to exclude this directory.

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

> ---
>  include/linux/README             |  2 +-
>  include/linux/drm_fourcc.h       | 10 ++---
>  include/linux/media-bus-format.h |  9 ++++
>  include/linux/rkisp1-config.h    | 56 +++++++++++++------------
>  include/linux/udmabuf.h          | 33 +++++++++++++++
>  include/linux/v4l2-controls.h    |  6 +++
>  include/linux/v4l2-mediabus.h    | 18 +++++---
>  include/linux/v4l2-subdev.h      | 29 ++++++++++---
>  include/linux/videodev2.h        | 72 ++++++++++++++++++++++++--------
>  9 files changed, 172 insertions(+), 63 deletions(-)
>  create mode 100644 include/linux/udmabuf.h
> 
> diff --git a/include/linux/README b/include/linux/README
> index 101e4997..b7795309 100644
> --- a/include/linux/README
> +++ b/include/linux/README
> @@ -1,4 +1,4 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
> -Files in this directory are imported from v6.7 of the Linux kernel. Do not
> +Files in this directory are imported from v6.10-rc1 of the Linux kernel. Do not
>  modify them manually.
> diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h
> index b4e1a092..d8e99940 100644
> --- a/include/linux/drm_fourcc.h
> +++ b/include/linux/drm_fourcc.h
> @@ -54,7 +54,7 @@ extern "C" {
>   * Format modifiers may change any property of the buffer, including the number
>   * of planes and/or the required allocation size. Format modifiers are
>   * vendor-namespaced, and as such the relationship between a fourcc code and a
> - * modifier is specific to the modifer being used. For example, some modifiers
> + * modifier is specific to the modifier being used. For example, some modifiers
>   * may preserve meaning - such as number of planes - from the fourcc code,
>   * whereas others may not.
>   *
> @@ -79,7 +79,7 @@ extern "C" {
>   *   format.
>   * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users
>   *   see modifiers as opaque tokens they can check for equality and intersect.
> - *   These users musn't need to know to reason about the modifier value
> + *   These users mustn't need to know to reason about the modifier value
>   *   (i.e. they are not expected to extract information out of the modifier).
>   *
>   * Vendors should document their modifier usage in as much detail as
> @@ -610,7 +610,7 @@ extern "C" {
>   * This is a tiled layout using 4Kb tiles in row-major layout.
>   * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which
>   * are arranged in four groups (two wide, two high) with column-major layout.
> - * Each group therefore consits out of four 256 byte units, which are also laid
> + * Each group therefore consists out of four 256 byte units, which are also laid
>   * out as 2x2 column-major.
>   * 256 byte units are made out of four 64 byte blocks of pixels, producing
>   * either a square block or a 2:1 unit.
> @@ -1183,7 +1183,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>   */
>  
>  /*
> - * The top 4 bits (out of the 56 bits alloted for specifying vendor specific
> + * The top 4 bits (out of the 56 bits allotted for specifying vendor specific
>   * modifiers) denote the category for modifiers. Currently we have three
>   * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of
>   * sixteen different categories.
> @@ -1499,7 +1499,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>   * Amlogic FBC Memory Saving mode
>   *
>   * Indicates the storage is packed when pixel size is multiple of word
> - * boudaries, i.e. 8bit should be stored in this mode to save allocation
> + * boundaries, i.e. 8bit should be stored in this mode to save allocation
>   * memory.
>   *
>   * This mode reduces body layout to 3072 bytes per 64x32 superblock with
> diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
> index f05f747e..d4c1d991 100644
> --- a/include/linux/media-bus-format.h
> +++ b/include/linux/media-bus-format.h
> @@ -174,4 +174,13 @@
>   */
>  #define MEDIA_BUS_FMT_METADATA_FIXED           0x7001
>  
> +/* Generic line based metadata formats for serial buses. Next is 0x8008. */
> +#define MEDIA_BUS_FMT_META_8                   0x8001
> +#define MEDIA_BUS_FMT_META_10                  0x8002
> +#define MEDIA_BUS_FMT_META_12                  0x8003
> +#define MEDIA_BUS_FMT_META_14                  0x8004
> +#define MEDIA_BUS_FMT_META_16                  0x8005
> +#define MEDIA_BUS_FMT_META_20                  0x8006
> +#define MEDIA_BUS_FMT_META_24                  0x8007
> +
>  #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
> diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
> index 2d1c448a..f87c6bd4 100644
> --- a/include/linux/rkisp1-config.h
> +++ b/include/linux/rkisp1-config.h
> @@ -4,8 +4,8 @@
>   * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
>   */
>  
> -#ifndef _UAPI_RKISP1_CONFIG_H
> -#define _UAPI_RKISP1_CONFIG_H
> +#ifndef _RKISP1_CONFIG_H
> +#define _RKISP1_CONFIG_H
>  
>  #include <linux/types.h>
>  
> @@ -175,11 +175,14 @@
>  /**
>   * enum rkisp1_cif_isp_version - ISP variants
>   *
> - * @RKISP1_V10: used at least in rk3288 and rk3399
> - * @RKISP1_V11: declared in the original vendor code, but not used
> - * @RKISP1_V12: used at least in rk3326 and px30
> - * @RKISP1_V13: used at least in rk1808
> - * @RKISP1_V_IMX8MP: used in at least imx8mp
> + * @RKISP1_V10: Used at least in RK3288 and RK3399.
> + * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
> + *     of entries in grids and histogram as v10.
> + * @RKISP1_V12: Used at least in RK3326 and PX30.
> + * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
> + *     histogram as v12.
> + * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
> + *     and histogram as v10.
>   */
>  enum rkisp1_cif_isp_version {
>         RKISP1_V10 = 10,
> @@ -586,10 +589,9 @@ enum rkisp1_cif_isp_goc_mode {
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
> - * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
> - * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
> - * of the two.
> + * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
>   */
>  struct rkisp1_cif_isp_goc_config {
>         __u32 mode;
> @@ -609,10 +611,10 @@ struct rkisp1_cif_isp_goc_config {
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
> - * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
> - * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
> - * of the two.
> + * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
> + * two.
>   */
>  struct rkisp1_cif_isp_hst_config {
>         __u32 mode;
> @@ -904,9 +906,9 @@ struct rkisp1_cif_isp_bls_meas_val {
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
> - * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
> - * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
> + * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
> + * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
> + * to the maximum of the two.
>   *
>   * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
>   */
> @@ -946,21 +948,21 @@ struct rkisp1_cif_isp_af_stat {
>   *            integer part.
>   *
>   * The window of the measurements area is divided to 5x5 sub-windows for
> - * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
> - * each sub-window independently and the final result is a weighted average of
> - * the histogram measurements on all sub-windows. The window of the
> - * measurements area and the weight of each sub-window are configurable using
> + * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
> + * sub-window independently and the final result is a weighted average of the
> + * histogram measurements on all sub-windows. The window of the measurements
> + * area and the weight of each sub-window are configurable using
>   * struct @rkisp1_cif_isp_hst_config.
>   *
> - * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
> + * The histogram contains 16 bins in V10 and 32 bins in V12.
>   *
>   * The number of entries of @hist_bins depends on the hardware revision
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
> - * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
> - * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
> + * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
> + * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
> + * equal to the maximum of the two.
>   */
>  struct rkisp1_cif_isp_hist_stat {
>         __u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
> @@ -994,4 +996,4 @@ struct rkisp1_stat_buffer {
>         struct rkisp1_cif_isp_stat params;
>  };
>  
> -#endif /* _UAPI_RKISP1_CONFIG_H */
> +#endif /* _RKISP1_CONFIG_H */
> diff --git a/include/linux/udmabuf.h b/include/linux/udmabuf.h
> new file mode 100644
> index 00000000..76cc7de9
> --- /dev/null
> +++ b/include/linux/udmabuf.h
> @@ -0,0 +1,33 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +#ifndef _LINUX_UDMABUF_H
> +#define _LINUX_UDMABUF_H
> +
> +#include <linux/types.h>
> +#include <linux/ioctl.h>
> +
> +#define UDMABUF_FLAGS_CLOEXEC  0x01
> +
> +struct udmabuf_create {
> +       __u32 memfd;
> +       __u32 flags;
> +       __u64 offset;
> +       __u64 size;
> +};
> +
> +struct udmabuf_create_item {
> +       __u32 memfd;
> +       __u32 __pad;
> +       __u64 offset;
> +       __u64 size;
> +};
> +
> +struct udmabuf_create_list {
> +       __u32 flags;
> +       __u32 count;
> +       struct udmabuf_create_item list[];
> +};
> +
> +#define UDMABUF_CREATE       _IOW('u', 0x42, struct udmabuf_create)
> +#define UDMABUF_CREATE_LIST  _IOW('u', 0x43, struct udmabuf_create_list)
> +
> +#endif /* _LINUX_UDMABUF_H */
> diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
> index b9f64810..1e6e816b 100644
> --- a/include/linux/v4l2-controls.h
> +++ b/include/linux/v4l2-controls.h
> @@ -211,6 +211,12 @@ enum v4l2_colorfx {
>   */
>  #define V4L2_CID_USER_NPCM_BASE                        (V4L2_CID_USER_BASE + 0x11b0)
>  
> +/*
> + * The base for THine THP7312 driver controls.
> + * We reserve 32 controls for this driver.
> + */
> +#define V4L2_CID_USER_THP7312_BASE             (V4L2_CID_USER_BASE + 0x11c0)
> +
>  /* MPEG-class control IDs */
>  /* The MPEG controls are applicable to all codec controls
>   * and the 'MPEG' part of the define is historical */
> diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
> index 2c318de1..097ef739 100644
> --- a/include/linux/v4l2-mediabus.h
> +++ b/include/linux/v4l2-mediabus.h
> @@ -19,12 +19,18 @@
>   * @width:     image width
>   * @height:    image height
>   * @code:      data format code (from enum v4l2_mbus_pixelcode)
> - * @field:     used interlacing type (from enum v4l2_field)
> - * @colorspace:        colorspace of the data (from enum v4l2_colorspace)
> - * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
> - * @hsv_enc:   HSV encoding of the data (from enum v4l2_hsv_encoding)
> - * @quantization: quantization of the data (from enum v4l2_quantization)
> - * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func)
> + * @field:     used interlacing type (from enum v4l2_field), zero for metadata
> + *             mbus codes
> + * @colorspace:        colorspace of the data (from enum v4l2_colorspace), zero on
> + *             metadata mbus codes
> + * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero
> + *             for metadata mbus codes
> + * @hsv_enc:   HSV encoding of the data (from enum v4l2_hsv_encoding), zero for
> + *             metadata mbus codes
> + * @quantization: quantization of the data (from enum v4l2_quantization), zero
> + *             for metadata mbus codes
> + * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func), zero
> + *             for metadata mbus codes
>   * @flags:     flags (V4L2_MBUS_FRAMEFMT_*)
>   * @reserved:  reserved bytes that can be later used
>   */
> diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
> index b383c2fe..2347e266 100644
> --- a/include/linux/v4l2-subdev.h
> +++ b/include/linux/v4l2-subdev.h
> @@ -50,6 +50,10 @@ struct v4l2_subdev_format {
>   * @rect: pad crop rectangle boundaries
>   * @stream: stream number, defined in subdev routing
>   * @reserved: drivers and applications must zero this array
> + *
> + * The subdev crop API is an obsolete interface and may be removed in the
> + * future. It is superseded by the selection API. No new extensions to this
> + * structure will be accepted.
>   */
>  struct v4l2_subdev_crop {
>         __u32 which;
> @@ -116,13 +120,15 @@ struct v4l2_subdev_frame_size_enum {
>   * @pad: pad number, as reported by the media API
>   * @interval: frame interval in seconds
>   * @stream: stream number, defined in subdev routing
> + * @which: interval type (from enum v4l2_subdev_format_whence)
>   * @reserved: drivers and applications must zero this array
>   */
>  struct v4l2_subdev_frame_interval {
>         __u32 pad;
>         struct v4l2_fract interval;
>         __u32 stream;
> -       __u32 reserved[8];
> +       __u32 which;
> +       __u32 reserved[7];
>  };
>  
>  /**
> @@ -133,7 +139,7 @@ struct v4l2_subdev_frame_interval {
>   * @width: frame width in pixels
>   * @height: frame height in pixels
>   * @interval: frame interval in seconds
> - * @which: format type (from enum v4l2_subdev_format_whence)
> + * @which: interval type (from enum v4l2_subdev_format_whence)
>   * @stream: stream number, defined in subdev routing
>   * @reserved: drivers and applications must zero this array
>   */
> @@ -222,15 +228,19 @@ struct v4l2_subdev_route {
>   * struct v4l2_subdev_routing - Subdev routing information
>   *
>   * @which: configuration type (from enum v4l2_subdev_format_whence)
> - * @num_routes: the total number of routes in the routes array
> + * @len_routes: the length of the routes array, in routes; set by the user, not
> + *             modified by the kernel
>   * @routes: pointer to the routes array
> + * @num_routes: the total number of routes, possibly more than fits in the
> + *             routes array
>   * @reserved: drivers and applications must zero this array
>   */
>  struct v4l2_subdev_routing {
>         __u32 which;
> -       __u32 num_routes;
> +       __u32 len_routes;
>         __u64 routes;
> -       __u32 reserved[6];
> +       __u32 num_routes;
> +       __u32 reserved[11];
>  };
>  
>  /*
> @@ -239,7 +249,14 @@ struct v4l2_subdev_routing {
>   * set (which is the default), the 'stream' fields will be forced to 0 by the
>   * kernel.
>   */
> - #define V4L2_SUBDEV_CLIENT_CAP_STREAMS                (1ULL << 0)
> +#define V4L2_SUBDEV_CLIENT_CAP_STREAMS                 (1ULL << 0)
> +
> +/*
> + * The client is aware of the struct v4l2_subdev_frame_interval which field. If
> + * this is not set (which is the default), the which field is forced to
> + * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
> + */
> +#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH     (1ULL << 1)
>  
>  /**
>   * struct v4l2_subdev_client_capability - Capabilities of the client accessing
> diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
> index 0b5482a0..7fe522e8 100644
> --- a/include/linux/videodev2.h
> +++ b/include/linux/videodev2.h
> @@ -574,6 +574,8 @@ struct v4l2_pix_format {
>  #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
>  #define V4L2_PIX_FMT_Y10P    v4l2_fourcc('Y', '1', '0', 'P') /* 10  Greyscale, MIPI RAW10 packed */
>  #define V4L2_PIX_FMT_IPU3_Y10          v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
> +#define V4L2_PIX_FMT_Y12P    v4l2_fourcc('Y', '1', '2', 'P') /* 12  Greyscale, MIPI RAW12 packed */
> +#define V4L2_PIX_FMT_Y14P    v4l2_fourcc('Y', '1', '4', 'P') /* 14  Greyscale, MIPI RAW14 packed */
>  
>  /* Palette formats */
>  #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */
> @@ -867,6 +869,7 @@ struct v4l2_fmtdesc {
>  #define V4L2_FMT_FLAG_CSC_YCBCR_ENC            0x0080
>  #define V4L2_FMT_FLAG_CSC_HSV_ENC              V4L2_FMT_FLAG_CSC_YCBCR_ENC
>  #define V4L2_FMT_FLAG_CSC_QUANTIZATION         0x0100
> +#define V4L2_FMT_FLAG_META_LINE_BASED          0x0200
>  
>         /* Frame Size and frame rate enumeration */
>  /*
> @@ -1016,18 +1019,20 @@ struct v4l2_requestbuffers {
>  #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS            (1 << 4)
>  #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF     (1 << 5)
>  #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS         (1 << 6)
> +#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS          (1 << 7)
> +#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS              (1 << 8)
>  
>  /**
>   * struct v4l2_plane - plane info for multi-planar buffers
>   * @bytesused:         number of bytes occupied by data in the plane (payload)
>   * @length:            size of this plane (NOT the payload) in bytes
> - * @mem_offset:                when memory in the associated struct v4l2_buffer is
> + * @m.mem_offset:      when memory in the associated struct v4l2_buffer is
>   *                     V4L2_MEMORY_MMAP, equals the offset from the start of
>   *                     the device memory for this plane (or is a "cookie" that
>   *                     should be passed to mmap() called on the video node)
> - * @userptr:           when memory is V4L2_MEMORY_USERPTR, a userspace pointer
> + * @m.userptr:         when memory is V4L2_MEMORY_USERPTR, a userspace pointer
>   *                     pointing to this plane
> - * @fd:                        when memory is V4L2_MEMORY_DMABUF, a userspace file
> + * @m.fd:              when memory is V4L2_MEMORY_DMABUF, a userspace file
>   *                     descriptor associated with this plane
>   * @m:                 union of @mem_offset, @userptr and @fd
>   * @data_offset:       offset in the plane to the start of data; usually 0,
> @@ -1065,14 +1070,14 @@ struct v4l2_plane {
>   * @sequence:  sequence count of this frame
>   * @memory:    enum v4l2_memory; the method, in which the actual video data is
>   *             passed
> - * @offset:    for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
> + * @m.offset:  for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
>   *             offset from the start of the device memory for this plane,
>   *             (or a "cookie" that should be passed to mmap() as offset)
> - * @userptr:   for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
> + * @m.userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
>   *             a userspace pointer pointing to this buffer
> - * @fd:                for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
> + * @m.fd:              for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
>   *             a userspace file descriptor associated with this buffer
> - * @planes:    for multiplanar buffers; userspace pointer to the array of plane
> + * @m.planes:  for multiplanar buffers; userspace pointer to the array of plane
>   *             info structs for this buffer
>   * @m:         union of @offset, @userptr, @planes and @fd
>   * @length:    size in bytes of the buffer (NOT its payload) for single-plane
> @@ -1810,8 +1815,10 @@ struct v4l2_ext_control {
>                 struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
>                 struct v4l2_ctrl_av1_frame *p_av1_frame;
>                 struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
> +               struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll_info;
> +               struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering_display;
>                 void *ptr;
> -       };
> +       } __attribute__ ((packed));
>  } __attribute__ ((packed));
>  
>  struct v4l2_ext_controls {
> @@ -2381,23 +2388,32 @@ struct v4l2_sdr_format {
>   * struct v4l2_meta_format - metadata format definition
>   * @dataformat:                little endian four character code (fourcc)
>   * @buffersize:                maximum size in bytes required for data
> + * @width:             number of data units of data per line (valid for line
> + *                     based formats only, see format documentation)
> + * @height:            number of lines of data per buffer (valid for line based
> + *                     formats only)
> + * @bytesperline:      offset between the beginnings of two adjacent lines in
> + *                     bytes (valid for line based formats only)
>   */
>  struct v4l2_meta_format {
>         __u32                           dataformat;
>         __u32                           buffersize;
> +       __u32                           width;
> +       __u32                           height;
> +       __u32                           bytesperline;
>  } __attribute__ ((packed));
>  
>  /**
>   * struct v4l2_format - stream data format
> - * @type:      enum v4l2_buf_type; type of the data stream
> - * @pix:       definition of an image format
> - * @pix_mp:    definition of a multiplanar image format
> - * @win:       definition of an overlaid image
> - * @vbi:       raw VBI capture or output parameters
> - * @sliced:    sliced VBI capture or output parameters
> - * @raw_data:  placeholder for future extensions and custom formats
> - * @fmt:       union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta
> - *             and @raw_data
> + * @type:              enum v4l2_buf_type; type of the data stream
> + * @fmt.pix:           definition of an image format
> + * @fmt.pix_mp:                definition of a multiplanar image format
> + * @fmt.win:           definition of an overlaid image
> + * @fmt.vbi:           raw VBI capture or output parameters
> + * @fmt.sliced:                sliced VBI capture or output parameters
> + * @fmt.raw_data:      placeholder for future extensions and custom formats
> + * @fmt:               union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr,
> + *                     @meta and @raw_data
>   */
>  struct v4l2_format {
>         __u32    type;
> @@ -2570,6 +2586,9 @@ struct v4l2_dbg_chip_info {
>   * @flags:     additional buffer management attributes (ignored unless the
>   *             queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability
>   *             and configured for MMAP streaming I/O).
> + * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set
> + *             this field indicate the maximum possible number of buffers
> + *             for this queue.
>   * @reserved:  future extensions
>   */
>  struct v4l2_create_buffers {
> @@ -2579,7 +2598,22 @@ struct v4l2_create_buffers {
>         struct v4l2_format      format;
>         __u32                   capabilities;
>         __u32                   flags;
> -       __u32                   reserved[6];
> +       __u32                   max_num_buffers;
> +       __u32                   reserved[5];
> +};
> +
> +/**
> + * struct v4l2_remove_buffers - VIDIOC_REMOVE_BUFS argument
> + * @index:     the first buffer to be removed
> + * @count:     number of buffers to removed
> + * @type:      enum v4l2_buf_type
> + * @reserved:  future extensions
> + */
> +struct v4l2_remove_buffers {
> +       __u32                   index;
> +       __u32                   count;
> +       __u32                   type;
> +       __u32                   reserved[13];
>  };
>  
>  /*
> @@ -2681,6 +2715,8 @@ struct v4l2_create_buffers {
>  #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)
>  
>  #define VIDIOC_QUERY_EXT_CTRL  _IOWR('V', 103, struct v4l2_query_ext_ctrl)
> +#define VIDIOC_REMOVE_BUFS     _IOWR('V', 104, struct v4l2_remove_buffers)
> +
>  
>  /* Reminder: when adding new ioctls please add support for them to
>     drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */
> -- 
> 2.45.1
>
Hans de Goede May 31, 2024, 7:27 a.m. UTC | #2
Hi,

On 5/30/24 11:47 PM, Kieran Bingham wrote:
> Quoting Hans de Goede (2024-05-30 18:15:57)
>> Updated kernel headers to v6.10-rc1 using utils/update-kernel-headers.sh
>> and re-instating libcamera local modifications.
>>
>> This includes adding include/linux/udmabuf.h which was not part
>> of libcamera's include/linux headers before.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> I thought I recalled we added something locally before it got merged for
> RPi formats

That is correct.

> - but there's nothing being lost / removed here so I think
> we're all good.

Right I manually re-applied local changes that is what the "re-instating
libcamera local modifications." part in the commit message refers to.

> And the checkstyle warnings you mentioned are fine here. We should
> figure out how to exclude this directory.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Thank you for the reviews.

Regards,

Hans




> 
>> ---
>>  include/linux/README             |  2 +-
>>  include/linux/drm_fourcc.h       | 10 ++---
>>  include/linux/media-bus-format.h |  9 ++++
>>  include/linux/rkisp1-config.h    | 56 +++++++++++++------------
>>  include/linux/udmabuf.h          | 33 +++++++++++++++
>>  include/linux/v4l2-controls.h    |  6 +++
>>  include/linux/v4l2-mediabus.h    | 18 +++++---
>>  include/linux/v4l2-subdev.h      | 29 ++++++++++---
>>  include/linux/videodev2.h        | 72 ++++++++++++++++++++++++--------
>>  9 files changed, 172 insertions(+), 63 deletions(-)
>>  create mode 100644 include/linux/udmabuf.h
>>
>> diff --git a/include/linux/README b/include/linux/README
>> index 101e4997..b7795309 100644
>> --- a/include/linux/README
>> +++ b/include/linux/README
>> @@ -1,4 +1,4 @@
>>  # SPDX-License-Identifier: CC0-1.0
>>  
>> -Files in this directory are imported from v6.7 of the Linux kernel. Do not
>> +Files in this directory are imported from v6.10-rc1 of the Linux kernel. Do not
>>  modify them manually.
>> diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h
>> index b4e1a092..d8e99940 100644
>> --- a/include/linux/drm_fourcc.h
>> +++ b/include/linux/drm_fourcc.h
>> @@ -54,7 +54,7 @@ extern "C" {
>>   * Format modifiers may change any property of the buffer, including the number
>>   * of planes and/or the required allocation size. Format modifiers are
>>   * vendor-namespaced, and as such the relationship between a fourcc code and a
>> - * modifier is specific to the modifer being used. For example, some modifiers
>> + * modifier is specific to the modifier being used. For example, some modifiers
>>   * may preserve meaning - such as number of planes - from the fourcc code,
>>   * whereas others may not.
>>   *
>> @@ -79,7 +79,7 @@ extern "C" {
>>   *   format.
>>   * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users
>>   *   see modifiers as opaque tokens they can check for equality and intersect.
>> - *   These users musn't need to know to reason about the modifier value
>> + *   These users mustn't need to know to reason about the modifier value
>>   *   (i.e. they are not expected to extract information out of the modifier).
>>   *
>>   * Vendors should document their modifier usage in as much detail as
>> @@ -610,7 +610,7 @@ extern "C" {
>>   * This is a tiled layout using 4Kb tiles in row-major layout.
>>   * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which
>>   * are arranged in four groups (two wide, two high) with column-major layout.
>> - * Each group therefore consits out of four 256 byte units, which are also laid
>> + * Each group therefore consists out of four 256 byte units, which are also laid
>>   * out as 2x2 column-major.
>>   * 256 byte units are made out of four 64 byte blocks of pixels, producing
>>   * either a square block or a 2:1 unit.
>> @@ -1183,7 +1183,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>>   */
>>  
>>  /*
>> - * The top 4 bits (out of the 56 bits alloted for specifying vendor specific
>> + * The top 4 bits (out of the 56 bits allotted for specifying vendor specific
>>   * modifiers) denote the category for modifiers. Currently we have three
>>   * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of
>>   * sixteen different categories.
>> @@ -1499,7 +1499,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>>   * Amlogic FBC Memory Saving mode
>>   *
>>   * Indicates the storage is packed when pixel size is multiple of word
>> - * boudaries, i.e. 8bit should be stored in this mode to save allocation
>> + * boundaries, i.e. 8bit should be stored in this mode to save allocation
>>   * memory.
>>   *
>>   * This mode reduces body layout to 3072 bytes per 64x32 superblock with
>> diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
>> index f05f747e..d4c1d991 100644
>> --- a/include/linux/media-bus-format.h
>> +++ b/include/linux/media-bus-format.h
>> @@ -174,4 +174,13 @@
>>   */
>>  #define MEDIA_BUS_FMT_METADATA_FIXED           0x7001
>>  
>> +/* Generic line based metadata formats for serial buses. Next is 0x8008. */
>> +#define MEDIA_BUS_FMT_META_8                   0x8001
>> +#define MEDIA_BUS_FMT_META_10                  0x8002
>> +#define MEDIA_BUS_FMT_META_12                  0x8003
>> +#define MEDIA_BUS_FMT_META_14                  0x8004
>> +#define MEDIA_BUS_FMT_META_16                  0x8005
>> +#define MEDIA_BUS_FMT_META_20                  0x8006
>> +#define MEDIA_BUS_FMT_META_24                  0x8007
>> +
>>  #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
>> diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
>> index 2d1c448a..f87c6bd4 100644
>> --- a/include/linux/rkisp1-config.h
>> +++ b/include/linux/rkisp1-config.h
>> @@ -4,8 +4,8 @@
>>   * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
>>   */
>>  
>> -#ifndef _UAPI_RKISP1_CONFIG_H
>> -#define _UAPI_RKISP1_CONFIG_H
>> +#ifndef _RKISP1_CONFIG_H
>> +#define _RKISP1_CONFIG_H
>>  
>>  #include <linux/types.h>
>>  
>> @@ -175,11 +175,14 @@
>>  /**
>>   * enum rkisp1_cif_isp_version - ISP variants
>>   *
>> - * @RKISP1_V10: used at least in rk3288 and rk3399
>> - * @RKISP1_V11: declared in the original vendor code, but not used
>> - * @RKISP1_V12: used at least in rk3326 and px30
>> - * @RKISP1_V13: used at least in rk1808
>> - * @RKISP1_V_IMX8MP: used in at least imx8mp
>> + * @RKISP1_V10: Used at least in RK3288 and RK3399.
>> + * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
>> + *     of entries in grids and histogram as v10.
>> + * @RKISP1_V12: Used at least in RK3326 and PX30.
>> + * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
>> + *     histogram as v12.
>> + * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
>> + *     and histogram as v10.
>>   */
>>  enum rkisp1_cif_isp_version {
>>         RKISP1_V10 = 10,
>> @@ -586,10 +589,9 @@ enum rkisp1_cif_isp_goc_mode {
>>   * as is reported by the hw_revision field of the struct media_device_info
>>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>>   *
>> - * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
>> - * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
>> - * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
>> - * of the two.
>> + * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
>> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
>> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
>>   */
>>  struct rkisp1_cif_isp_goc_config {
>>         __u32 mode;
>> @@ -609,10 +611,10 @@ struct rkisp1_cif_isp_goc_config {
>>   * as is reported by the hw_revision field of the struct media_device_info
>>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>>   *
>> - * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
>> - * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
>> - * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
>> - * of the two.
>> + * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
>> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
>> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
>> + * two.
>>   */
>>  struct rkisp1_cif_isp_hst_config {
>>         __u32 mode;
>> @@ -904,9 +906,9 @@ struct rkisp1_cif_isp_bls_meas_val {
>>   * as is reported by the hw_revision field of the struct media_device_info
>>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>>   *
>> - * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
>> - * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
>> - * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
>> + * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
>> + * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
>> + * to the maximum of the two.
>>   *
>>   * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
>>   */
>> @@ -946,21 +948,21 @@ struct rkisp1_cif_isp_af_stat {
>>   *            integer part.
>>   *
>>   * The window of the measurements area is divided to 5x5 sub-windows for
>> - * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
>> - * each sub-window independently and the final result is a weighted average of
>> - * the histogram measurements on all sub-windows. The window of the
>> - * measurements area and the weight of each sub-window are configurable using
>> + * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
>> + * sub-window independently and the final result is a weighted average of the
>> + * histogram measurements on all sub-windows. The window of the measurements
>> + * area and the weight of each sub-window are configurable using
>>   * struct @rkisp1_cif_isp_hst_config.
>>   *
>> - * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
>> + * The histogram contains 16 bins in V10 and 32 bins in V12.
>>   *
>>   * The number of entries of @hist_bins depends on the hardware revision
>>   * as is reported by the hw_revision field of the struct media_device_info
>>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>>   *
>> - * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
>> - * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
>> - * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
>> + * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
>> + * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
>> + * equal to the maximum of the two.
>>   */
>>  struct rkisp1_cif_isp_hist_stat {
>>         __u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
>> @@ -994,4 +996,4 @@ struct rkisp1_stat_buffer {
>>         struct rkisp1_cif_isp_stat params;
>>  };
>>  
>> -#endif /* _UAPI_RKISP1_CONFIG_H */
>> +#endif /* _RKISP1_CONFIG_H */
>> diff --git a/include/linux/udmabuf.h b/include/linux/udmabuf.h
>> new file mode 100644
>> index 00000000..76cc7de9
>> --- /dev/null
>> +++ b/include/linux/udmabuf.h
>> @@ -0,0 +1,33 @@
>> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>> +#ifndef _LINUX_UDMABUF_H
>> +#define _LINUX_UDMABUF_H
>> +
>> +#include <linux/types.h>
>> +#include <linux/ioctl.h>
>> +
>> +#define UDMABUF_FLAGS_CLOEXEC  0x01
>> +
>> +struct udmabuf_create {
>> +       __u32 memfd;
>> +       __u32 flags;
>> +       __u64 offset;
>> +       __u64 size;
>> +};
>> +
>> +struct udmabuf_create_item {
>> +       __u32 memfd;
>> +       __u32 __pad;
>> +       __u64 offset;
>> +       __u64 size;
>> +};
>> +
>> +struct udmabuf_create_list {
>> +       __u32 flags;
>> +       __u32 count;
>> +       struct udmabuf_create_item list[];
>> +};
>> +
>> +#define UDMABUF_CREATE       _IOW('u', 0x42, struct udmabuf_create)
>> +#define UDMABUF_CREATE_LIST  _IOW('u', 0x43, struct udmabuf_create_list)
>> +
>> +#endif /* _LINUX_UDMABUF_H */
>> diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
>> index b9f64810..1e6e816b 100644
>> --- a/include/linux/v4l2-controls.h
>> +++ b/include/linux/v4l2-controls.h
>> @@ -211,6 +211,12 @@ enum v4l2_colorfx {
>>   */
>>  #define V4L2_CID_USER_NPCM_BASE                        (V4L2_CID_USER_BASE + 0x11b0)
>>  
>> +/*
>> + * The base for THine THP7312 driver controls.
>> + * We reserve 32 controls for this driver.
>> + */
>> +#define V4L2_CID_USER_THP7312_BASE             (V4L2_CID_USER_BASE + 0x11c0)
>> +
>>  /* MPEG-class control IDs */
>>  /* The MPEG controls are applicable to all codec controls
>>   * and the 'MPEG' part of the define is historical */
>> diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
>> index 2c318de1..097ef739 100644
>> --- a/include/linux/v4l2-mediabus.h
>> +++ b/include/linux/v4l2-mediabus.h
>> @@ -19,12 +19,18 @@
>>   * @width:     image width
>>   * @height:    image height
>>   * @code:      data format code (from enum v4l2_mbus_pixelcode)
>> - * @field:     used interlacing type (from enum v4l2_field)
>> - * @colorspace:        colorspace of the data (from enum v4l2_colorspace)
>> - * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
>> - * @hsv_enc:   HSV encoding of the data (from enum v4l2_hsv_encoding)
>> - * @quantization: quantization of the data (from enum v4l2_quantization)
>> - * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func)
>> + * @field:     used interlacing type (from enum v4l2_field), zero for metadata
>> + *             mbus codes
>> + * @colorspace:        colorspace of the data (from enum v4l2_colorspace), zero on
>> + *             metadata mbus codes
>> + * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero
>> + *             for metadata mbus codes
>> + * @hsv_enc:   HSV encoding of the data (from enum v4l2_hsv_encoding), zero for
>> + *             metadata mbus codes
>> + * @quantization: quantization of the data (from enum v4l2_quantization), zero
>> + *             for metadata mbus codes
>> + * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func), zero
>> + *             for metadata mbus codes
>>   * @flags:     flags (V4L2_MBUS_FRAMEFMT_*)
>>   * @reserved:  reserved bytes that can be later used
>>   */
>> diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
>> index b383c2fe..2347e266 100644
>> --- a/include/linux/v4l2-subdev.h
>> +++ b/include/linux/v4l2-subdev.h
>> @@ -50,6 +50,10 @@ struct v4l2_subdev_format {
>>   * @rect: pad crop rectangle boundaries
>>   * @stream: stream number, defined in subdev routing
>>   * @reserved: drivers and applications must zero this array
>> + *
>> + * The subdev crop API is an obsolete interface and may be removed in the
>> + * future. It is superseded by the selection API. No new extensions to this
>> + * structure will be accepted.
>>   */
>>  struct v4l2_subdev_crop {
>>         __u32 which;
>> @@ -116,13 +120,15 @@ struct v4l2_subdev_frame_size_enum {
>>   * @pad: pad number, as reported by the media API
>>   * @interval: frame interval in seconds
>>   * @stream: stream number, defined in subdev routing
>> + * @which: interval type (from enum v4l2_subdev_format_whence)
>>   * @reserved: drivers and applications must zero this array
>>   */
>>  struct v4l2_subdev_frame_interval {
>>         __u32 pad;
>>         struct v4l2_fract interval;
>>         __u32 stream;
>> -       __u32 reserved[8];
>> +       __u32 which;
>> +       __u32 reserved[7];
>>  };
>>  
>>  /**
>> @@ -133,7 +139,7 @@ struct v4l2_subdev_frame_interval {
>>   * @width: frame width in pixels
>>   * @height: frame height in pixels
>>   * @interval: frame interval in seconds
>> - * @which: format type (from enum v4l2_subdev_format_whence)
>> + * @which: interval type (from enum v4l2_subdev_format_whence)
>>   * @stream: stream number, defined in subdev routing
>>   * @reserved: drivers and applications must zero this array
>>   */
>> @@ -222,15 +228,19 @@ struct v4l2_subdev_route {
>>   * struct v4l2_subdev_routing - Subdev routing information
>>   *
>>   * @which: configuration type (from enum v4l2_subdev_format_whence)
>> - * @num_routes: the total number of routes in the routes array
>> + * @len_routes: the length of the routes array, in routes; set by the user, not
>> + *             modified by the kernel
>>   * @routes: pointer to the routes array
>> + * @num_routes: the total number of routes, possibly more than fits in the
>> + *             routes array
>>   * @reserved: drivers and applications must zero this array
>>   */
>>  struct v4l2_subdev_routing {
>>         __u32 which;
>> -       __u32 num_routes;
>> +       __u32 len_routes;
>>         __u64 routes;
>> -       __u32 reserved[6];
>> +       __u32 num_routes;
>> +       __u32 reserved[11];
>>  };
>>  
>>  /*
>> @@ -239,7 +249,14 @@ struct v4l2_subdev_routing {
>>   * set (which is the default), the 'stream' fields will be forced to 0 by the
>>   * kernel.
>>   */
>> - #define V4L2_SUBDEV_CLIENT_CAP_STREAMS                (1ULL << 0)
>> +#define V4L2_SUBDEV_CLIENT_CAP_STREAMS                 (1ULL << 0)
>> +
>> +/*
>> + * The client is aware of the struct v4l2_subdev_frame_interval which field. If
>> + * this is not set (which is the default), the which field is forced to
>> + * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
>> + */
>> +#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH     (1ULL << 1)
>>  
>>  /**
>>   * struct v4l2_subdev_client_capability - Capabilities of the client accessing
>> diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
>> index 0b5482a0..7fe522e8 100644
>> --- a/include/linux/videodev2.h
>> +++ b/include/linux/videodev2.h
>> @@ -574,6 +574,8 @@ struct v4l2_pix_format {
>>  #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
>>  #define V4L2_PIX_FMT_Y10P    v4l2_fourcc('Y', '1', '0', 'P') /* 10  Greyscale, MIPI RAW10 packed */
>>  #define V4L2_PIX_FMT_IPU3_Y10          v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
>> +#define V4L2_PIX_FMT_Y12P    v4l2_fourcc('Y', '1', '2', 'P') /* 12  Greyscale, MIPI RAW12 packed */
>> +#define V4L2_PIX_FMT_Y14P    v4l2_fourcc('Y', '1', '4', 'P') /* 14  Greyscale, MIPI RAW14 packed */
>>  
>>  /* Palette formats */
>>  #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */
>> @@ -867,6 +869,7 @@ struct v4l2_fmtdesc {
>>  #define V4L2_FMT_FLAG_CSC_YCBCR_ENC            0x0080
>>  #define V4L2_FMT_FLAG_CSC_HSV_ENC              V4L2_FMT_FLAG_CSC_YCBCR_ENC
>>  #define V4L2_FMT_FLAG_CSC_QUANTIZATION         0x0100
>> +#define V4L2_FMT_FLAG_META_LINE_BASED          0x0200
>>  
>>         /* Frame Size and frame rate enumeration */
>>  /*
>> @@ -1016,18 +1019,20 @@ struct v4l2_requestbuffers {
>>  #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS            (1 << 4)
>>  #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF     (1 << 5)
>>  #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS         (1 << 6)
>> +#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS          (1 << 7)
>> +#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS              (1 << 8)
>>  
>>  /**
>>   * struct v4l2_plane - plane info for multi-planar buffers
>>   * @bytesused:         number of bytes occupied by data in the plane (payload)
>>   * @length:            size of this plane (NOT the payload) in bytes
>> - * @mem_offset:                when memory in the associated struct v4l2_buffer is
>> + * @m.mem_offset:      when memory in the associated struct v4l2_buffer is
>>   *                     V4L2_MEMORY_MMAP, equals the offset from the start of
>>   *                     the device memory for this plane (or is a "cookie" that
>>   *                     should be passed to mmap() called on the video node)
>> - * @userptr:           when memory is V4L2_MEMORY_USERPTR, a userspace pointer
>> + * @m.userptr:         when memory is V4L2_MEMORY_USERPTR, a userspace pointer
>>   *                     pointing to this plane
>> - * @fd:                        when memory is V4L2_MEMORY_DMABUF, a userspace file
>> + * @m.fd:              when memory is V4L2_MEMORY_DMABUF, a userspace file
>>   *                     descriptor associated with this plane
>>   * @m:                 union of @mem_offset, @userptr and @fd
>>   * @data_offset:       offset in the plane to the start of data; usually 0,
>> @@ -1065,14 +1070,14 @@ struct v4l2_plane {
>>   * @sequence:  sequence count of this frame
>>   * @memory:    enum v4l2_memory; the method, in which the actual video data is
>>   *             passed
>> - * @offset:    for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
>> + * @m.offset:  for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
>>   *             offset from the start of the device memory for this plane,
>>   *             (or a "cookie" that should be passed to mmap() as offset)
>> - * @userptr:   for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
>> + * @m.userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
>>   *             a userspace pointer pointing to this buffer
>> - * @fd:                for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
>> + * @m.fd:              for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
>>   *             a userspace file descriptor associated with this buffer
>> - * @planes:    for multiplanar buffers; userspace pointer to the array of plane
>> + * @m.planes:  for multiplanar buffers; userspace pointer to the array of plane
>>   *             info structs for this buffer
>>   * @m:         union of @offset, @userptr, @planes and @fd
>>   * @length:    size in bytes of the buffer (NOT its payload) for single-plane
>> @@ -1810,8 +1815,10 @@ struct v4l2_ext_control {
>>                 struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
>>                 struct v4l2_ctrl_av1_frame *p_av1_frame;
>>                 struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
>> +               struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll_info;
>> +               struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering_display;
>>                 void *ptr;
>> -       };
>> +       } __attribute__ ((packed));
>>  } __attribute__ ((packed));
>>  
>>  struct v4l2_ext_controls {
>> @@ -2381,23 +2388,32 @@ struct v4l2_sdr_format {
>>   * struct v4l2_meta_format - metadata format definition
>>   * @dataformat:                little endian four character code (fourcc)
>>   * @buffersize:                maximum size in bytes required for data
>> + * @width:             number of data units of data per line (valid for line
>> + *                     based formats only, see format documentation)
>> + * @height:            number of lines of data per buffer (valid for line based
>> + *                     formats only)
>> + * @bytesperline:      offset between the beginnings of two adjacent lines in
>> + *                     bytes (valid for line based formats only)
>>   */
>>  struct v4l2_meta_format {
>>         __u32                           dataformat;
>>         __u32                           buffersize;
>> +       __u32                           width;
>> +       __u32                           height;
>> +       __u32                           bytesperline;
>>  } __attribute__ ((packed));
>>  
>>  /**
>>   * struct v4l2_format - stream data format
>> - * @type:      enum v4l2_buf_type; type of the data stream
>> - * @pix:       definition of an image format
>> - * @pix_mp:    definition of a multiplanar image format
>> - * @win:       definition of an overlaid image
>> - * @vbi:       raw VBI capture or output parameters
>> - * @sliced:    sliced VBI capture or output parameters
>> - * @raw_data:  placeholder for future extensions and custom formats
>> - * @fmt:       union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta
>> - *             and @raw_data
>> + * @type:              enum v4l2_buf_type; type of the data stream
>> + * @fmt.pix:           definition of an image format
>> + * @fmt.pix_mp:                definition of a multiplanar image format
>> + * @fmt.win:           definition of an overlaid image
>> + * @fmt.vbi:           raw VBI capture or output parameters
>> + * @fmt.sliced:                sliced VBI capture or output parameters
>> + * @fmt.raw_data:      placeholder for future extensions and custom formats
>> + * @fmt:               union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr,
>> + *                     @meta and @raw_data
>>   */
>>  struct v4l2_format {
>>         __u32    type;
>> @@ -2570,6 +2586,9 @@ struct v4l2_dbg_chip_info {
>>   * @flags:     additional buffer management attributes (ignored unless the
>>   *             queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability
>>   *             and configured for MMAP streaming I/O).
>> + * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set
>> + *             this field indicate the maximum possible number of buffers
>> + *             for this queue.
>>   * @reserved:  future extensions
>>   */
>>  struct v4l2_create_buffers {
>> @@ -2579,7 +2598,22 @@ struct v4l2_create_buffers {
>>         struct v4l2_format      format;
>>         __u32                   capabilities;
>>         __u32                   flags;
>> -       __u32                   reserved[6];
>> +       __u32                   max_num_buffers;
>> +       __u32                   reserved[5];
>> +};
>> +
>> +/**
>> + * struct v4l2_remove_buffers - VIDIOC_REMOVE_BUFS argument
>> + * @index:     the first buffer to be removed
>> + * @count:     number of buffers to removed
>> + * @type:      enum v4l2_buf_type
>> + * @reserved:  future extensions
>> + */
>> +struct v4l2_remove_buffers {
>> +       __u32                   index;
>> +       __u32                   count;
>> +       __u32                   type;
>> +       __u32                   reserved[13];
>>  };
>>  
>>  /*
>> @@ -2681,6 +2715,8 @@ struct v4l2_create_buffers {
>>  #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)
>>  
>>  #define VIDIOC_QUERY_EXT_CTRL  _IOWR('V', 103, struct v4l2_query_ext_ctrl)
>> +#define VIDIOC_REMOVE_BUFS     _IOWR('V', 104, struct v4l2_remove_buffers)
>> +
>>  
>>  /* Reminder: when adding new ioctls please add support for them to
>>     drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */
>> -- 
>> 2.45.1
>>
>
Laurent Pinchart June 1, 2024, 1:45 p.m. UTC | #3
Hi Hans,

Thank you for the patch.

On Thu, May 30, 2024 at 07:15:57PM +0200, Hans de Goede wrote:
> Updated kernel headers to v6.10-rc1 using utils/update-kernel-headers.sh
> and re-instating libcamera local modifications.
> 
> This includes adding include/linux/udmabuf.h which was not part
> of libcamera's include/linux headers before.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  include/linux/README             |  2 +-
>  include/linux/drm_fourcc.h       | 10 ++---
>  include/linux/media-bus-format.h |  9 ++++
>  include/linux/rkisp1-config.h    | 56 +++++++++++++------------
>  include/linux/udmabuf.h          | 33 +++++++++++++++
>  include/linux/v4l2-controls.h    |  6 +++
>  include/linux/v4l2-mediabus.h    | 18 +++++---
>  include/linux/v4l2-subdev.h      | 29 ++++++++++---
>  include/linux/videodev2.h        | 72 ++++++++++++++++++++++++--------
>  9 files changed, 172 insertions(+), 63 deletions(-)
>  create mode 100644 include/linux/udmabuf.h
> 
> diff --git a/include/linux/README b/include/linux/README
> index 101e4997..b7795309 100644
> --- a/include/linux/README
> +++ b/include/linux/README
> @@ -1,4 +1,4 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
> -Files in this directory are imported from v6.7 of the Linux kernel. Do not
> +Files in this directory are imported from v6.10-rc1 of the Linux kernel. Do not
>  modify them manually.
> diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h
> index b4e1a092..d8e99940 100644
> --- a/include/linux/drm_fourcc.h
> +++ b/include/linux/drm_fourcc.h
> @@ -54,7 +54,7 @@ extern "C" {
>   * Format modifiers may change any property of the buffer, including the number
>   * of planes and/or the required allocation size. Format modifiers are
>   * vendor-namespaced, and as such the relationship between a fourcc code and a
> - * modifier is specific to the modifer being used. For example, some modifiers
> + * modifier is specific to the modifier being used. For example, some modifiers
>   * may preserve meaning - such as number of planes - from the fourcc code,
>   * whereas others may not.
>   *
> @@ -79,7 +79,7 @@ extern "C" {
>   *   format.
>   * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users
>   *   see modifiers as opaque tokens they can check for equality and intersect.
> - *   These users musn't need to know to reason about the modifier value
> + *   These users mustn't need to know to reason about the modifier value
>   *   (i.e. they are not expected to extract information out of the modifier).
>   *
>   * Vendors should document their modifier usage in as much detail as
> @@ -610,7 +610,7 @@ extern "C" {
>   * This is a tiled layout using 4Kb tiles in row-major layout.
>   * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which
>   * are arranged in four groups (two wide, two high) with column-major layout.
> - * Each group therefore consits out of four 256 byte units, which are also laid
> + * Each group therefore consists out of four 256 byte units, which are also laid
>   * out as 2x2 column-major.
>   * 256 byte units are made out of four 64 byte blocks of pixels, producing
>   * either a square block or a 2:1 unit.
> @@ -1183,7 +1183,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>   */
>  
>  /*
> - * The top 4 bits (out of the 56 bits alloted for specifying vendor specific
> + * The top 4 bits (out of the 56 bits allotted for specifying vendor specific
>   * modifiers) denote the category for modifiers. Currently we have three
>   * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of
>   * sixteen different categories.
> @@ -1499,7 +1499,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>   * Amlogic FBC Memory Saving mode
>   *
>   * Indicates the storage is packed when pixel size is multiple of word
> - * boudaries, i.e. 8bit should be stored in this mode to save allocation
> + * boundaries, i.e. 8bit should be stored in this mode to save allocation
>   * memory.
>   *
>   * This mode reduces body layout to 3072 bytes per 64x32 superblock with
> diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
> index f05f747e..d4c1d991 100644
> --- a/include/linux/media-bus-format.h
> +++ b/include/linux/media-bus-format.h
> @@ -174,4 +174,13 @@
>   */
>  #define MEDIA_BUS_FMT_METADATA_FIXED		0x7001
>  
> +/* Generic line based metadata formats for serial buses. Next is 0x8008. */
> +#define MEDIA_BUS_FMT_META_8			0x8001
> +#define MEDIA_BUS_FMT_META_10			0x8002
> +#define MEDIA_BUS_FMT_META_12			0x8003
> +#define MEDIA_BUS_FMT_META_14			0x8004
> +#define MEDIA_BUS_FMT_META_16			0x8005
> +#define MEDIA_BUS_FMT_META_20			0x8006
> +#define MEDIA_BUS_FMT_META_24			0x8007
> +
>  #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
> diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
> index 2d1c448a..f87c6bd4 100644
> --- a/include/linux/rkisp1-config.h
> +++ b/include/linux/rkisp1-config.h
> @@ -4,8 +4,8 @@
>   * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
>   */
>  
> -#ifndef _UAPI_RKISP1_CONFIG_H
> -#define _UAPI_RKISP1_CONFIG_H
> +#ifndef _RKISP1_CONFIG_H
> +#define _RKISP1_CONFIG_H
>  
>  #include <linux/types.h>
>  
> @@ -175,11 +175,14 @@
>  /**
>   * enum rkisp1_cif_isp_version - ISP variants
>   *
> - * @RKISP1_V10: used at least in rk3288 and rk3399
> - * @RKISP1_V11: declared in the original vendor code, but not used
> - * @RKISP1_V12: used at least in rk3326 and px30
> - * @RKISP1_V13: used at least in rk1808
> - * @RKISP1_V_IMX8MP: used in at least imx8mp
> + * @RKISP1_V10: Used at least in RK3288 and RK3399.
> + * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
> + *	of entries in grids and histogram as v10.
> + * @RKISP1_V12: Used at least in RK3326 and PX30.
> + * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
> + *	histogram as v12.
> + * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
> + *	and histogram as v10.
>   */
>  enum rkisp1_cif_isp_version {
>  	RKISP1_V10 = 10,
> @@ -586,10 +589,9 @@ enum rkisp1_cif_isp_goc_mode {
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
> - * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
> - * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
> - * of the two.
> + * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
>   */
>  struct rkisp1_cif_isp_goc_config {
>  	__u32 mode;
> @@ -609,10 +611,10 @@ struct rkisp1_cif_isp_goc_config {
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
> - * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
> - * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
> - * of the two.
> + * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
> + * two.
>   */
>  struct rkisp1_cif_isp_hst_config {
>  	__u32 mode;
> @@ -904,9 +906,9 @@ struct rkisp1_cif_isp_bls_meas_val {
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
> - * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
> - * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
> + * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
> + * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
> + * to the maximum of the two.
>   *
>   * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
>   */
> @@ -946,21 +948,21 @@ struct rkisp1_cif_isp_af_stat {
>   *	       integer part.
>   *
>   * The window of the measurements area is divided to 5x5 sub-windows for
> - * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
> - * each sub-window independently and the final result is a weighted average of
> - * the histogram measurements on all sub-windows. The window of the
> - * measurements area and the weight of each sub-window are configurable using
> + * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
> + * sub-window independently and the final result is a weighted average of the
> + * histogram measurements on all sub-windows. The window of the measurements
> + * area and the weight of each sub-window are configurable using
>   * struct @rkisp1_cif_isp_hst_config.
>   *
> - * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
> + * The histogram contains 16 bins in V10 and 32 bins in V12.
>   *
>   * The number of entries of @hist_bins depends on the hardware revision
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
> - * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
> - * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
> + * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
> + * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
> + * equal to the maximum of the two.
>   */
>  struct rkisp1_cif_isp_hist_stat {
>  	__u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
> @@ -994,4 +996,4 @@ struct rkisp1_stat_buffer {
>  	struct rkisp1_cif_isp_stat params;
>  };
>  
> -#endif /* _UAPI_RKISP1_CONFIG_H */
> +#endif /* _RKISP1_CONFIG_H */
> diff --git a/include/linux/udmabuf.h b/include/linux/udmabuf.h
> new file mode 100644
> index 00000000..76cc7de9
> --- /dev/null
> +++ b/include/linux/udmabuf.h
> @@ -0,0 +1,33 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +#ifndef _LINUX_UDMABUF_H
> +#define _LINUX_UDMABUF_H
> +
> +#include <linux/types.h>
> +#include <linux/ioctl.h>
> +
> +#define UDMABUF_FLAGS_CLOEXEC	0x01
> +
> +struct udmabuf_create {
> +	__u32 memfd;
> +	__u32 flags;
> +	__u64 offset;
> +	__u64 size;
> +};
> +
> +struct udmabuf_create_item {
> +	__u32 memfd;
> +	__u32 __pad;
> +	__u64 offset;
> +	__u64 size;
> +};
> +
> +struct udmabuf_create_list {
> +	__u32 flags;
> +	__u32 count;
> +	struct udmabuf_create_item list[];
> +};
> +
> +#define UDMABUF_CREATE       _IOW('u', 0x42, struct udmabuf_create)
> +#define UDMABUF_CREATE_LIST  _IOW('u', 0x43, struct udmabuf_create_list)
> +
> +#endif /* _LINUX_UDMABUF_H */
> diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
> index b9f64810..1e6e816b 100644
> --- a/include/linux/v4l2-controls.h
> +++ b/include/linux/v4l2-controls.h
> @@ -211,6 +211,12 @@ enum v4l2_colorfx {
>   */
>  #define V4L2_CID_USER_NPCM_BASE			(V4L2_CID_USER_BASE + 0x11b0)
>  
> +/*
> + * The base for THine THP7312 driver controls.
> + * We reserve 32 controls for this driver.
> + */
> +#define V4L2_CID_USER_THP7312_BASE		(V4L2_CID_USER_BASE + 0x11c0)
> +
>  /* MPEG-class control IDs */
>  /* The MPEG controls are applicable to all codec controls
>   * and the 'MPEG' part of the define is historical */
> diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
> index 2c318de1..097ef739 100644
> --- a/include/linux/v4l2-mediabus.h
> +++ b/include/linux/v4l2-mediabus.h
> @@ -19,12 +19,18 @@
>   * @width:	image width
>   * @height:	image height
>   * @code:	data format code (from enum v4l2_mbus_pixelcode)
> - * @field:	used interlacing type (from enum v4l2_field)
> - * @colorspace:	colorspace of the data (from enum v4l2_colorspace)
> - * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
> - * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding)
> - * @quantization: quantization of the data (from enum v4l2_quantization)
> - * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func)
> + * @field:	used interlacing type (from enum v4l2_field), zero for metadata
> + *		mbus codes
> + * @colorspace:	colorspace of the data (from enum v4l2_colorspace), zero on
> + *		metadata mbus codes
> + * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero
> + *		for metadata mbus codes
> + * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding), zero for
> + *		metadata mbus codes
> + * @quantization: quantization of the data (from enum v4l2_quantization), zero
> + *		for metadata mbus codes
> + * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func), zero
> + *		for metadata mbus codes
>   * @flags:	flags (V4L2_MBUS_FRAMEFMT_*)
>   * @reserved:  reserved bytes that can be later used
>   */
> diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
> index b383c2fe..2347e266 100644
> --- a/include/linux/v4l2-subdev.h
> +++ b/include/linux/v4l2-subdev.h
> @@ -50,6 +50,10 @@ struct v4l2_subdev_format {
>   * @rect: pad crop rectangle boundaries
>   * @stream: stream number, defined in subdev routing
>   * @reserved: drivers and applications must zero this array
> + *
> + * The subdev crop API is an obsolete interface and may be removed in the
> + * future. It is superseded by the selection API. No new extensions to this
> + * structure will be accepted.
>   */
>  struct v4l2_subdev_crop {
>  	__u32 which;
> @@ -116,13 +120,15 @@ struct v4l2_subdev_frame_size_enum {
>   * @pad: pad number, as reported by the media API
>   * @interval: frame interval in seconds
>   * @stream: stream number, defined in subdev routing
> + * @which: interval type (from enum v4l2_subdev_format_whence)
>   * @reserved: drivers and applications must zero this array
>   */
>  struct v4l2_subdev_frame_interval {
>  	__u32 pad;
>  	struct v4l2_fract interval;
>  	__u32 stream;
> -	__u32 reserved[8];
> +	__u32 which;
> +	__u32 reserved[7];
>  };
>  
>  /**
> @@ -133,7 +139,7 @@ struct v4l2_subdev_frame_interval {
>   * @width: frame width in pixels
>   * @height: frame height in pixels
>   * @interval: frame interval in seconds
> - * @which: format type (from enum v4l2_subdev_format_whence)
> + * @which: interval type (from enum v4l2_subdev_format_whence)
>   * @stream: stream number, defined in subdev routing
>   * @reserved: drivers and applications must zero this array
>   */
> @@ -222,15 +228,19 @@ struct v4l2_subdev_route {
>   * struct v4l2_subdev_routing - Subdev routing information
>   *
>   * @which: configuration type (from enum v4l2_subdev_format_whence)
> - * @num_routes: the total number of routes in the routes array
> + * @len_routes: the length of the routes array, in routes; set by the user, not
> + *		modified by the kernel
>   * @routes: pointer to the routes array
> + * @num_routes: the total number of routes, possibly more than fits in the
> + *		routes array
>   * @reserved: drivers and applications must zero this array
>   */
>  struct v4l2_subdev_routing {
>  	__u32 which;
> -	__u32 num_routes;
> +	__u32 len_routes;
>  	__u64 routes;
> -	__u32 reserved[6];
> +	__u32 num_routes;
> +	__u32 reserved[11];

This will cause some issues. The routing API has changed, we need to
handle it in a backward-compatible way. I have patches for that, I think
I have even posted them. I'll rebase on top of this patch and repost.
The two series will need to be merged together.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  };
>  
>  /*
> @@ -239,7 +249,14 @@ struct v4l2_subdev_routing {
>   * set (which is the default), the 'stream' fields will be forced to 0 by the
>   * kernel.
>   */
> - #define V4L2_SUBDEV_CLIENT_CAP_STREAMS		(1ULL << 0)
> +#define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0)
> +
> +/*
> + * The client is aware of the struct v4l2_subdev_frame_interval which field. If
> + * this is not set (which is the default), the which field is forced to
> + * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
> + */
> +#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1)
>  
>  /**
>   * struct v4l2_subdev_client_capability - Capabilities of the client accessing
> diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
> index 0b5482a0..7fe522e8 100644
> --- a/include/linux/videodev2.h
> +++ b/include/linux/videodev2.h
> @@ -574,6 +574,8 @@ struct v4l2_pix_format {
>  #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
>  #define V4L2_PIX_FMT_Y10P    v4l2_fourcc('Y', '1', '0', 'P') /* 10  Greyscale, MIPI RAW10 packed */
>  #define V4L2_PIX_FMT_IPU3_Y10		v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
> +#define V4L2_PIX_FMT_Y12P    v4l2_fourcc('Y', '1', '2', 'P') /* 12  Greyscale, MIPI RAW12 packed */
> +#define V4L2_PIX_FMT_Y14P    v4l2_fourcc('Y', '1', '4', 'P') /* 14  Greyscale, MIPI RAW14 packed */
>  
>  /* Palette formats */
>  #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */
> @@ -867,6 +869,7 @@ struct v4l2_fmtdesc {
>  #define V4L2_FMT_FLAG_CSC_YCBCR_ENC		0x0080
>  #define V4L2_FMT_FLAG_CSC_HSV_ENC		V4L2_FMT_FLAG_CSC_YCBCR_ENC
>  #define V4L2_FMT_FLAG_CSC_QUANTIZATION		0x0100
> +#define V4L2_FMT_FLAG_META_LINE_BASED		0x0200
>  
>  	/* Frame Size and frame rate enumeration */
>  /*
> @@ -1016,18 +1019,20 @@ struct v4l2_requestbuffers {
>  #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS		(1 << 4)
>  #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF	(1 << 5)
>  #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS		(1 << 6)
> +#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS		(1 << 7)
> +#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS		(1 << 8)
>  
>  /**
>   * struct v4l2_plane - plane info for multi-planar buffers
>   * @bytesused:		number of bytes occupied by data in the plane (payload)
>   * @length:		size of this plane (NOT the payload) in bytes
> - * @mem_offset:		when memory in the associated struct v4l2_buffer is
> + * @m.mem_offset:	when memory in the associated struct v4l2_buffer is
>   *			V4L2_MEMORY_MMAP, equals the offset from the start of
>   *			the device memory for this plane (or is a "cookie" that
>   *			should be passed to mmap() called on the video node)
> - * @userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
> + * @m.userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
>   *			pointing to this plane
> - * @fd:			when memory is V4L2_MEMORY_DMABUF, a userspace file
> + * @m.fd:		when memory is V4L2_MEMORY_DMABUF, a userspace file
>   *			descriptor associated with this plane
>   * @m:			union of @mem_offset, @userptr and @fd
>   * @data_offset:	offset in the plane to the start of data; usually 0,
> @@ -1065,14 +1070,14 @@ struct v4l2_plane {
>   * @sequence:	sequence count of this frame
>   * @memory:	enum v4l2_memory; the method, in which the actual video data is
>   *		passed
> - * @offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
> + * @m.offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
>   *		offset from the start of the device memory for this plane,
>   *		(or a "cookie" that should be passed to mmap() as offset)
> - * @userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
> + * @m.userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
>   *		a userspace pointer pointing to this buffer
> - * @fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
> + * @m.fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
>   *		a userspace file descriptor associated with this buffer
> - * @planes:	for multiplanar buffers; userspace pointer to the array of plane
> + * @m.planes:	for multiplanar buffers; userspace pointer to the array of plane
>   *		info structs for this buffer
>   * @m:		union of @offset, @userptr, @planes and @fd
>   * @length:	size in bytes of the buffer (NOT its payload) for single-plane
> @@ -1810,8 +1815,10 @@ struct v4l2_ext_control {
>  		struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
>  		struct v4l2_ctrl_av1_frame *p_av1_frame;
>  		struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
> +		struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll_info;
> +		struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering_display;
>  		void *ptr;
> -	};
> +	} __attribute__ ((packed));
>  } __attribute__ ((packed));
>  
>  struct v4l2_ext_controls {
> @@ -2381,23 +2388,32 @@ struct v4l2_sdr_format {
>   * struct v4l2_meta_format - metadata format definition
>   * @dataformat:		little endian four character code (fourcc)
>   * @buffersize:		maximum size in bytes required for data
> + * @width:		number of data units of data per line (valid for line
> + *			based formats only, see format documentation)
> + * @height:		number of lines of data per buffer (valid for line based
> + *			formats only)
> + * @bytesperline:	offset between the beginnings of two adjacent lines in
> + *			bytes (valid for line based formats only)
>   */
>  struct v4l2_meta_format {
>  	__u32				dataformat;
>  	__u32				buffersize;
> +	__u32				width;
> +	__u32				height;
> +	__u32				bytesperline;
>  } __attribute__ ((packed));
>  
>  /**
>   * struct v4l2_format - stream data format
> - * @type:	enum v4l2_buf_type; type of the data stream
> - * @pix:	definition of an image format
> - * @pix_mp:	definition of a multiplanar image format
> - * @win:	definition of an overlaid image
> - * @vbi:	raw VBI capture or output parameters
> - * @sliced:	sliced VBI capture or output parameters
> - * @raw_data:	placeholder for future extensions and custom formats
> - * @fmt:	union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta
> - *		and @raw_data
> + * @type:		enum v4l2_buf_type; type of the data stream
> + * @fmt.pix:		definition of an image format
> + * @fmt.pix_mp:		definition of a multiplanar image format
> + * @fmt.win:		definition of an overlaid image
> + * @fmt.vbi:		raw VBI capture or output parameters
> + * @fmt.sliced:		sliced VBI capture or output parameters
> + * @fmt.raw_data:	placeholder for future extensions and custom formats
> + * @fmt:		union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr,
> + *			@meta and @raw_data
>   */
>  struct v4l2_format {
>  	__u32	 type;
> @@ -2570,6 +2586,9 @@ struct v4l2_dbg_chip_info {
>   * @flags:	additional buffer management attributes (ignored unless the
>   *		queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability
>   *		and configured for MMAP streaming I/O).
> + * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set
> + *		this field indicate the maximum possible number of buffers
> + *		for this queue.
>   * @reserved:	future extensions
>   */
>  struct v4l2_create_buffers {
> @@ -2579,7 +2598,22 @@ struct v4l2_create_buffers {
>  	struct v4l2_format	format;
>  	__u32			capabilities;
>  	__u32			flags;
> -	__u32			reserved[6];
> +	__u32			max_num_buffers;
> +	__u32			reserved[5];
> +};
> +
> +/**
> + * struct v4l2_remove_buffers - VIDIOC_REMOVE_BUFS argument
> + * @index:	the first buffer to be removed
> + * @count:	number of buffers to removed
> + * @type:	enum v4l2_buf_type
> + * @reserved:	future extensions
> + */
> +struct v4l2_remove_buffers {
> +	__u32			index;
> +	__u32			count;
> +	__u32			type;
> +	__u32			reserved[13];
>  };
>  
>  /*
> @@ -2681,6 +2715,8 @@ struct v4l2_create_buffers {
>  #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)
>  
>  #define VIDIOC_QUERY_EXT_CTRL	_IOWR('V', 103, struct v4l2_query_ext_ctrl)
> +#define VIDIOC_REMOVE_BUFS	_IOWR('V', 104, struct v4l2_remove_buffers)
> +
>  
>  /* Reminder: when adding new ioctls please add support for them to
>     drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */
Hans de Goede June 1, 2024, 2:16 p.m. UTC | #4
Hi Laurent,

On 6/1/24 3:45 PM, Laurent Pinchart wrote:
> Hi Hans,
> 
> Thank you for the patch.
> 
> On Thu, May 30, 2024 at 07:15:57PM +0200, Hans de Goede wrote:
>> Updated kernel headers to v6.10-rc1 using utils/update-kernel-headers.sh
>> and re-instating libcamera local modifications.
>>
>> This includes adding include/linux/udmabuf.h which was not part
>> of libcamera's include/linux headers before.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>  include/linux/README             |  2 +-
>>  include/linux/drm_fourcc.h       | 10 ++---
>>  include/linux/media-bus-format.h |  9 ++++
>>  include/linux/rkisp1-config.h    | 56 +++++++++++++------------
>>  include/linux/udmabuf.h          | 33 +++++++++++++++
>>  include/linux/v4l2-controls.h    |  6 +++
>>  include/linux/v4l2-mediabus.h    | 18 +++++---
>>  include/linux/v4l2-subdev.h      | 29 ++++++++++---
>>  include/linux/videodev2.h        | 72 ++++++++++++++++++++++++--------
>>  9 files changed, 172 insertions(+), 63 deletions(-)
>>  create mode 100644 include/linux/udmabuf.h
>>
>> diff --git a/include/linux/README b/include/linux/README
>> index 101e4997..b7795309 100644
>> --- a/include/linux/README
>> +++ b/include/linux/README
>> @@ -1,4 +1,4 @@
>>  # SPDX-License-Identifier: CC0-1.0
>>  
>> -Files in this directory are imported from v6.7 of the Linux kernel. Do not
>> +Files in this directory are imported from v6.10-rc1 of the Linux kernel. Do not
>>  modify them manually.
>> diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h
>> index b4e1a092..d8e99940 100644
>> --- a/include/linux/drm_fourcc.h
>> +++ b/include/linux/drm_fourcc.h
>> @@ -54,7 +54,7 @@ extern "C" {
>>   * Format modifiers may change any property of the buffer, including the number
>>   * of planes and/or the required allocation size. Format modifiers are
>>   * vendor-namespaced, and as such the relationship between a fourcc code and a
>> - * modifier is specific to the modifer being used. For example, some modifiers
>> + * modifier is specific to the modifier being used. For example, some modifiers
>>   * may preserve meaning - such as number of planes - from the fourcc code,
>>   * whereas others may not.
>>   *
>> @@ -79,7 +79,7 @@ extern "C" {
>>   *   format.
>>   * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users
>>   *   see modifiers as opaque tokens they can check for equality and intersect.
>> - *   These users musn't need to know to reason about the modifier value
>> + *   These users mustn't need to know to reason about the modifier value
>>   *   (i.e. they are not expected to extract information out of the modifier).
>>   *
>>   * Vendors should document their modifier usage in as much detail as
>> @@ -610,7 +610,7 @@ extern "C" {
>>   * This is a tiled layout using 4Kb tiles in row-major layout.
>>   * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which
>>   * are arranged in four groups (two wide, two high) with column-major layout.
>> - * Each group therefore consits out of four 256 byte units, which are also laid
>> + * Each group therefore consists out of four 256 byte units, which are also laid
>>   * out as 2x2 column-major.
>>   * 256 byte units are made out of four 64 byte blocks of pixels, producing
>>   * either a square block or a 2:1 unit.
>> @@ -1183,7 +1183,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>>   */
>>  
>>  /*
>> - * The top 4 bits (out of the 56 bits alloted for specifying vendor specific
>> + * The top 4 bits (out of the 56 bits allotted for specifying vendor specific
>>   * modifiers) denote the category for modifiers. Currently we have three
>>   * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of
>>   * sixteen different categories.
>> @@ -1499,7 +1499,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>>   * Amlogic FBC Memory Saving mode
>>   *
>>   * Indicates the storage is packed when pixel size is multiple of word
>> - * boudaries, i.e. 8bit should be stored in this mode to save allocation
>> + * boundaries, i.e. 8bit should be stored in this mode to save allocation
>>   * memory.
>>   *
>>   * This mode reduces body layout to 3072 bytes per 64x32 superblock with
>> diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
>> index f05f747e..d4c1d991 100644
>> --- a/include/linux/media-bus-format.h
>> +++ b/include/linux/media-bus-format.h
>> @@ -174,4 +174,13 @@
>>   */
>>  #define MEDIA_BUS_FMT_METADATA_FIXED		0x7001
>>  
>> +/* Generic line based metadata formats for serial buses. Next is 0x8008. */
>> +#define MEDIA_BUS_FMT_META_8			0x8001
>> +#define MEDIA_BUS_FMT_META_10			0x8002
>> +#define MEDIA_BUS_FMT_META_12			0x8003
>> +#define MEDIA_BUS_FMT_META_14			0x8004
>> +#define MEDIA_BUS_FMT_META_16			0x8005
>> +#define MEDIA_BUS_FMT_META_20			0x8006
>> +#define MEDIA_BUS_FMT_META_24			0x8007
>> +
>>  #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
>> diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
>> index 2d1c448a..f87c6bd4 100644
>> --- a/include/linux/rkisp1-config.h
>> +++ b/include/linux/rkisp1-config.h
>> @@ -4,8 +4,8 @@
>>   * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
>>   */
>>  
>> -#ifndef _UAPI_RKISP1_CONFIG_H
>> -#define _UAPI_RKISP1_CONFIG_H
>> +#ifndef _RKISP1_CONFIG_H
>> +#define _RKISP1_CONFIG_H
>>  
>>  #include <linux/types.h>
>>  
>> @@ -175,11 +175,14 @@
>>  /**
>>   * enum rkisp1_cif_isp_version - ISP variants
>>   *
>> - * @RKISP1_V10: used at least in rk3288 and rk3399
>> - * @RKISP1_V11: declared in the original vendor code, but not used
>> - * @RKISP1_V12: used at least in rk3326 and px30
>> - * @RKISP1_V13: used at least in rk1808
>> - * @RKISP1_V_IMX8MP: used in at least imx8mp
>> + * @RKISP1_V10: Used at least in RK3288 and RK3399.
>> + * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
>> + *	of entries in grids and histogram as v10.
>> + * @RKISP1_V12: Used at least in RK3326 and PX30.
>> + * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
>> + *	histogram as v12.
>> + * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
>> + *	and histogram as v10.
>>   */
>>  enum rkisp1_cif_isp_version {
>>  	RKISP1_V10 = 10,
>> @@ -586,10 +589,9 @@ enum rkisp1_cif_isp_goc_mode {
>>   * as is reported by the hw_revision field of the struct media_device_info
>>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>>   *
>> - * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
>> - * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
>> - * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
>> - * of the two.
>> + * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
>> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
>> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
>>   */
>>  struct rkisp1_cif_isp_goc_config {
>>  	__u32 mode;
>> @@ -609,10 +611,10 @@ struct rkisp1_cif_isp_goc_config {
>>   * as is reported by the hw_revision field of the struct media_device_info
>>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>>   *
>> - * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
>> - * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
>> - * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
>> - * of the two.
>> + * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
>> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
>> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
>> + * two.
>>   */
>>  struct rkisp1_cif_isp_hst_config {
>>  	__u32 mode;
>> @@ -904,9 +906,9 @@ struct rkisp1_cif_isp_bls_meas_val {
>>   * as is reported by the hw_revision field of the struct media_device_info
>>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>>   *
>> - * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
>> - * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
>> - * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
>> + * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
>> + * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
>> + * to the maximum of the two.
>>   *
>>   * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
>>   */
>> @@ -946,21 +948,21 @@ struct rkisp1_cif_isp_af_stat {
>>   *	       integer part.
>>   *
>>   * The window of the measurements area is divided to 5x5 sub-windows for
>> - * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
>> - * each sub-window independently and the final result is a weighted average of
>> - * the histogram measurements on all sub-windows. The window of the
>> - * measurements area and the weight of each sub-window are configurable using
>> + * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
>> + * sub-window independently and the final result is a weighted average of the
>> + * histogram measurements on all sub-windows. The window of the measurements
>> + * area and the weight of each sub-window are configurable using
>>   * struct @rkisp1_cif_isp_hst_config.
>>   *
>> - * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
>> + * The histogram contains 16 bins in V10 and 32 bins in V12.
>>   *
>>   * The number of entries of @hist_bins depends on the hardware revision
>>   * as is reported by the hw_revision field of the struct media_device_info
>>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>>   *
>> - * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
>> - * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
>> - * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
>> + * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
>> + * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
>> + * equal to the maximum of the two.
>>   */
>>  struct rkisp1_cif_isp_hist_stat {
>>  	__u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
>> @@ -994,4 +996,4 @@ struct rkisp1_stat_buffer {
>>  	struct rkisp1_cif_isp_stat params;
>>  };
>>  
>> -#endif /* _UAPI_RKISP1_CONFIG_H */
>> +#endif /* _RKISP1_CONFIG_H */
>> diff --git a/include/linux/udmabuf.h b/include/linux/udmabuf.h
>> new file mode 100644
>> index 00000000..76cc7de9
>> --- /dev/null
>> +++ b/include/linux/udmabuf.h
>> @@ -0,0 +1,33 @@
>> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>> +#ifndef _LINUX_UDMABUF_H
>> +#define _LINUX_UDMABUF_H
>> +
>> +#include <linux/types.h>
>> +#include <linux/ioctl.h>
>> +
>> +#define UDMABUF_FLAGS_CLOEXEC	0x01
>> +
>> +struct udmabuf_create {
>> +	__u32 memfd;
>> +	__u32 flags;
>> +	__u64 offset;
>> +	__u64 size;
>> +};
>> +
>> +struct udmabuf_create_item {
>> +	__u32 memfd;
>> +	__u32 __pad;
>> +	__u64 offset;
>> +	__u64 size;
>> +};
>> +
>> +struct udmabuf_create_list {
>> +	__u32 flags;
>> +	__u32 count;
>> +	struct udmabuf_create_item list[];
>> +};
>> +
>> +#define UDMABUF_CREATE       _IOW('u', 0x42, struct udmabuf_create)
>> +#define UDMABUF_CREATE_LIST  _IOW('u', 0x43, struct udmabuf_create_list)
>> +
>> +#endif /* _LINUX_UDMABUF_H */
>> diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
>> index b9f64810..1e6e816b 100644
>> --- a/include/linux/v4l2-controls.h
>> +++ b/include/linux/v4l2-controls.h
>> @@ -211,6 +211,12 @@ enum v4l2_colorfx {
>>   */
>>  #define V4L2_CID_USER_NPCM_BASE			(V4L2_CID_USER_BASE + 0x11b0)
>>  
>> +/*
>> + * The base for THine THP7312 driver controls.
>> + * We reserve 32 controls for this driver.
>> + */
>> +#define V4L2_CID_USER_THP7312_BASE		(V4L2_CID_USER_BASE + 0x11c0)
>> +
>>  /* MPEG-class control IDs */
>>  /* The MPEG controls are applicable to all codec controls
>>   * and the 'MPEG' part of the define is historical */
>> diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
>> index 2c318de1..097ef739 100644
>> --- a/include/linux/v4l2-mediabus.h
>> +++ b/include/linux/v4l2-mediabus.h
>> @@ -19,12 +19,18 @@
>>   * @width:	image width
>>   * @height:	image height
>>   * @code:	data format code (from enum v4l2_mbus_pixelcode)
>> - * @field:	used interlacing type (from enum v4l2_field)
>> - * @colorspace:	colorspace of the data (from enum v4l2_colorspace)
>> - * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
>> - * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding)
>> - * @quantization: quantization of the data (from enum v4l2_quantization)
>> - * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func)
>> + * @field:	used interlacing type (from enum v4l2_field), zero for metadata
>> + *		mbus codes
>> + * @colorspace:	colorspace of the data (from enum v4l2_colorspace), zero on
>> + *		metadata mbus codes
>> + * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero
>> + *		for metadata mbus codes
>> + * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding), zero for
>> + *		metadata mbus codes
>> + * @quantization: quantization of the data (from enum v4l2_quantization), zero
>> + *		for metadata mbus codes
>> + * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func), zero
>> + *		for metadata mbus codes
>>   * @flags:	flags (V4L2_MBUS_FRAMEFMT_*)
>>   * @reserved:  reserved bytes that can be later used
>>   */
>> diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
>> index b383c2fe..2347e266 100644
>> --- a/include/linux/v4l2-subdev.h
>> +++ b/include/linux/v4l2-subdev.h
>> @@ -50,6 +50,10 @@ struct v4l2_subdev_format {
>>   * @rect: pad crop rectangle boundaries
>>   * @stream: stream number, defined in subdev routing
>>   * @reserved: drivers and applications must zero this array
>> + *
>> + * The subdev crop API is an obsolete interface and may be removed in the
>> + * future. It is superseded by the selection API. No new extensions to this
>> + * structure will be accepted.
>>   */
>>  struct v4l2_subdev_crop {
>>  	__u32 which;
>> @@ -116,13 +120,15 @@ struct v4l2_subdev_frame_size_enum {
>>   * @pad: pad number, as reported by the media API
>>   * @interval: frame interval in seconds
>>   * @stream: stream number, defined in subdev routing
>> + * @which: interval type (from enum v4l2_subdev_format_whence)
>>   * @reserved: drivers and applications must zero this array
>>   */
>>  struct v4l2_subdev_frame_interval {
>>  	__u32 pad;
>>  	struct v4l2_fract interval;
>>  	__u32 stream;
>> -	__u32 reserved[8];
>> +	__u32 which;
>> +	__u32 reserved[7];
>>  };
>>  
>>  /**
>> @@ -133,7 +139,7 @@ struct v4l2_subdev_frame_interval {
>>   * @width: frame width in pixels
>>   * @height: frame height in pixels
>>   * @interval: frame interval in seconds
>> - * @which: format type (from enum v4l2_subdev_format_whence)
>> + * @which: interval type (from enum v4l2_subdev_format_whence)
>>   * @stream: stream number, defined in subdev routing
>>   * @reserved: drivers and applications must zero this array
>>   */
>> @@ -222,15 +228,19 @@ struct v4l2_subdev_route {
>>   * struct v4l2_subdev_routing - Subdev routing information
>>   *
>>   * @which: configuration type (from enum v4l2_subdev_format_whence)
>> - * @num_routes: the total number of routes in the routes array
>> + * @len_routes: the length of the routes array, in routes; set by the user, not
>> + *		modified by the kernel
>>   * @routes: pointer to the routes array
>> + * @num_routes: the total number of routes, possibly more than fits in the
>> + *		routes array
>>   * @reserved: drivers and applications must zero this array
>>   */
>>  struct v4l2_subdev_routing {
>>  	__u32 which;
>> -	__u32 num_routes;
>> +	__u32 len_routes;
>>  	__u64 routes;
>> -	__u32 reserved[6];
>> +	__u32 num_routes;
>> +	__u32 reserved[11];
> 
> This will cause some issues. The routing API has changed, we need to
> handle it in a backward-compatible way. I have patches for that, I think
> I have even posted them. 

I thought that this was only exposed to userspace when
v4l2_subdev_enable_streams_api is set to true in
drivers/media/v4l2-core/v4l2-subdev.c

And that is never set to true unless the kernel is manually editted
because the API is not stable yet (which is why it was ok
for Sakari to make this change upstream) ?

I guess this may be enabled already on some downstream kernels
and that libcamera needs to handle that ?

> I'll rebase on top of this patch and repost.
> The two series will need to be merged together.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thank you the review(s) and for rebasing your series.

Regards,

Hans




>>  };
>>  
>>  /*
>> @@ -239,7 +249,14 @@ struct v4l2_subdev_routing {
>>   * set (which is the default), the 'stream' fields will be forced to 0 by the
>>   * kernel.
>>   */
>> - #define V4L2_SUBDEV_CLIENT_CAP_STREAMS		(1ULL << 0)
>> +#define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0)
>> +
>> +/*
>> + * The client is aware of the struct v4l2_subdev_frame_interval which field. If
>> + * this is not set (which is the default), the which field is forced to
>> + * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
>> + */
>> +#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1)
>>  
>>  /**
>>   * struct v4l2_subdev_client_capability - Capabilities of the client accessing
>> diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
>> index 0b5482a0..7fe522e8 100644
>> --- a/include/linux/videodev2.h
>> +++ b/include/linux/videodev2.h
>> @@ -574,6 +574,8 @@ struct v4l2_pix_format {
>>  #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
>>  #define V4L2_PIX_FMT_Y10P    v4l2_fourcc('Y', '1', '0', 'P') /* 10  Greyscale, MIPI RAW10 packed */
>>  #define V4L2_PIX_FMT_IPU3_Y10		v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
>> +#define V4L2_PIX_FMT_Y12P    v4l2_fourcc('Y', '1', '2', 'P') /* 12  Greyscale, MIPI RAW12 packed */
>> +#define V4L2_PIX_FMT_Y14P    v4l2_fourcc('Y', '1', '4', 'P') /* 14  Greyscale, MIPI RAW14 packed */
>>  
>>  /* Palette formats */
>>  #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */
>> @@ -867,6 +869,7 @@ struct v4l2_fmtdesc {
>>  #define V4L2_FMT_FLAG_CSC_YCBCR_ENC		0x0080
>>  #define V4L2_FMT_FLAG_CSC_HSV_ENC		V4L2_FMT_FLAG_CSC_YCBCR_ENC
>>  #define V4L2_FMT_FLAG_CSC_QUANTIZATION		0x0100
>> +#define V4L2_FMT_FLAG_META_LINE_BASED		0x0200
>>  
>>  	/* Frame Size and frame rate enumeration */
>>  /*
>> @@ -1016,18 +1019,20 @@ struct v4l2_requestbuffers {
>>  #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS		(1 << 4)
>>  #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF	(1 << 5)
>>  #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS		(1 << 6)
>> +#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS		(1 << 7)
>> +#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS		(1 << 8)
>>  
>>  /**
>>   * struct v4l2_plane - plane info for multi-planar buffers
>>   * @bytesused:		number of bytes occupied by data in the plane (payload)
>>   * @length:		size of this plane (NOT the payload) in bytes
>> - * @mem_offset:		when memory in the associated struct v4l2_buffer is
>> + * @m.mem_offset:	when memory in the associated struct v4l2_buffer is
>>   *			V4L2_MEMORY_MMAP, equals the offset from the start of
>>   *			the device memory for this plane (or is a "cookie" that
>>   *			should be passed to mmap() called on the video node)
>> - * @userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
>> + * @m.userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
>>   *			pointing to this plane
>> - * @fd:			when memory is V4L2_MEMORY_DMABUF, a userspace file
>> + * @m.fd:		when memory is V4L2_MEMORY_DMABUF, a userspace file
>>   *			descriptor associated with this plane
>>   * @m:			union of @mem_offset, @userptr and @fd
>>   * @data_offset:	offset in the plane to the start of data; usually 0,
>> @@ -1065,14 +1070,14 @@ struct v4l2_plane {
>>   * @sequence:	sequence count of this frame
>>   * @memory:	enum v4l2_memory; the method, in which the actual video data is
>>   *		passed
>> - * @offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
>> + * @m.offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
>>   *		offset from the start of the device memory for this plane,
>>   *		(or a "cookie" that should be passed to mmap() as offset)
>> - * @userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
>> + * @m.userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
>>   *		a userspace pointer pointing to this buffer
>> - * @fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
>> + * @m.fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
>>   *		a userspace file descriptor associated with this buffer
>> - * @planes:	for multiplanar buffers; userspace pointer to the array of plane
>> + * @m.planes:	for multiplanar buffers; userspace pointer to the array of plane
>>   *		info structs for this buffer
>>   * @m:		union of @offset, @userptr, @planes and @fd
>>   * @length:	size in bytes of the buffer (NOT its payload) for single-plane
>> @@ -1810,8 +1815,10 @@ struct v4l2_ext_control {
>>  		struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
>>  		struct v4l2_ctrl_av1_frame *p_av1_frame;
>>  		struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
>> +		struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll_info;
>> +		struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering_display;
>>  		void *ptr;
>> -	};
>> +	} __attribute__ ((packed));
>>  } __attribute__ ((packed));
>>  
>>  struct v4l2_ext_controls {
>> @@ -2381,23 +2388,32 @@ struct v4l2_sdr_format {
>>   * struct v4l2_meta_format - metadata format definition
>>   * @dataformat:		little endian four character code (fourcc)
>>   * @buffersize:		maximum size in bytes required for data
>> + * @width:		number of data units of data per line (valid for line
>> + *			based formats only, see format documentation)
>> + * @height:		number of lines of data per buffer (valid for line based
>> + *			formats only)
>> + * @bytesperline:	offset between the beginnings of two adjacent lines in
>> + *			bytes (valid for line based formats only)
>>   */
>>  struct v4l2_meta_format {
>>  	__u32				dataformat;
>>  	__u32				buffersize;
>> +	__u32				width;
>> +	__u32				height;
>> +	__u32				bytesperline;
>>  } __attribute__ ((packed));
>>  
>>  /**
>>   * struct v4l2_format - stream data format
>> - * @type:	enum v4l2_buf_type; type of the data stream
>> - * @pix:	definition of an image format
>> - * @pix_mp:	definition of a multiplanar image format
>> - * @win:	definition of an overlaid image
>> - * @vbi:	raw VBI capture or output parameters
>> - * @sliced:	sliced VBI capture or output parameters
>> - * @raw_data:	placeholder for future extensions and custom formats
>> - * @fmt:	union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta
>> - *		and @raw_data
>> + * @type:		enum v4l2_buf_type; type of the data stream
>> + * @fmt.pix:		definition of an image format
>> + * @fmt.pix_mp:		definition of a multiplanar image format
>> + * @fmt.win:		definition of an overlaid image
>> + * @fmt.vbi:		raw VBI capture or output parameters
>> + * @fmt.sliced:		sliced VBI capture or output parameters
>> + * @fmt.raw_data:	placeholder for future extensions and custom formats
>> + * @fmt:		union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr,
>> + *			@meta and @raw_data
>>   */
>>  struct v4l2_format {
>>  	__u32	 type;
>> @@ -2570,6 +2586,9 @@ struct v4l2_dbg_chip_info {
>>   * @flags:	additional buffer management attributes (ignored unless the
>>   *		queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability
>>   *		and configured for MMAP streaming I/O).
>> + * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set
>> + *		this field indicate the maximum possible number of buffers
>> + *		for this queue.
>>   * @reserved:	future extensions
>>   */
>>  struct v4l2_create_buffers {
>> @@ -2579,7 +2598,22 @@ struct v4l2_create_buffers {
>>  	struct v4l2_format	format;
>>  	__u32			capabilities;
>>  	__u32			flags;
>> -	__u32			reserved[6];
>> +	__u32			max_num_buffers;
>> +	__u32			reserved[5];
>> +};
>> +
>> +/**
>> + * struct v4l2_remove_buffers - VIDIOC_REMOVE_BUFS argument
>> + * @index:	the first buffer to be removed
>> + * @count:	number of buffers to removed
>> + * @type:	enum v4l2_buf_type
>> + * @reserved:	future extensions
>> + */
>> +struct v4l2_remove_buffers {
>> +	__u32			index;
>> +	__u32			count;
>> +	__u32			type;
>> +	__u32			reserved[13];
>>  };
>>  
>>  /*
>> @@ -2681,6 +2715,8 @@ struct v4l2_create_buffers {
>>  #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)
>>  
>>  #define VIDIOC_QUERY_EXT_CTRL	_IOWR('V', 103, struct v4l2_query_ext_ctrl)
>> +#define VIDIOC_REMOVE_BUFS	_IOWR('V', 104, struct v4l2_remove_buffers)
>> +
>>  
>>  /* Reminder: when adding new ioctls please add support for them to
>>     drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */
>
Laurent Pinchart June 1, 2024, 9:43 p.m. UTC | #5
On Thu, May 30, 2024 at 07:15:57PM +0200, Hans de Goede wrote:
> Updated kernel headers to v6.10-rc1 using utils/update-kernel-headers.sh
> and re-instating libcamera local modifications.

I think you've dropped the following change from v6.10-rc1:

diff --git a/include/linux/intel-ipu3.h b/include/linux/intel-ipu3.h
index bd771f1b4f6d..8c192f352e13 100644
--- a/include/linux/intel-ipu3.h
+++ b/include/linux/intel-ipu3.h
@@ -2485,11 +2485,9 @@ struct ipu3_uapi_anr_config {
  *		&ipu3_uapi_yuvp1_y_ee_nr_config
  * @yds:	y down scaler config. See &ipu3_uapi_yuvp1_yds_config
  * @chnr:	chroma noise reduction config. See &ipu3_uapi_yuvp1_chnr_config
- * @reserved1: reserved
  * @yds2:	y channel down scaler config. See &ipu3_uapi_yuvp1_yds_config
  * @tcc:	total color correction config as defined in struct
  *		&ipu3_uapi_yuvp2_tcc_static_config
- * @reserved2: reserved
  * @anr:	advanced noise reduction config.See &ipu3_uapi_anr_config
  * @awb_fr:	AWB filter response config. See ipu3_uapi_awb_fr_config
  * @ae:	auto exposure config  As specified by &ipu3_uapi_ae_config
@@ -2724,7 +2722,6 @@ struct ipu3_uapi_obgrid_param {
  * @acc_ae: 0 = no update, 1 = update.
  * @acc_af: 0 = no update, 1 = update.
  * @acc_awb: 0 = no update, 1 = update.
- * @__acc_osys: 0 = no update, 1 = update.
  * @reserved3: Not used.
  * @lin_vmem_params: 0 = no update, 1 = update.
  * @tnr3_vmem_params: 0 = no update, 1 = update.

This isn't a libcamera local modification. I'll add it back.

The rest looks good,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> This includes adding include/linux/udmabuf.h which was not part
> of libcamera's include/linux headers before.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  include/linux/README             |  2 +-
>  include/linux/drm_fourcc.h       | 10 ++---
>  include/linux/media-bus-format.h |  9 ++++
>  include/linux/rkisp1-config.h    | 56 +++++++++++++------------
>  include/linux/udmabuf.h          | 33 +++++++++++++++
>  include/linux/v4l2-controls.h    |  6 +++
>  include/linux/v4l2-mediabus.h    | 18 +++++---
>  include/linux/v4l2-subdev.h      | 29 ++++++++++---
>  include/linux/videodev2.h        | 72 ++++++++++++++++++++++++--------
>  9 files changed, 172 insertions(+), 63 deletions(-)
>  create mode 100644 include/linux/udmabuf.h
> 
> diff --git a/include/linux/README b/include/linux/README
> index 101e4997..b7795309 100644
> --- a/include/linux/README
> +++ b/include/linux/README
> @@ -1,4 +1,4 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
> -Files in this directory are imported from v6.7 of the Linux kernel. Do not
> +Files in this directory are imported from v6.10-rc1 of the Linux kernel. Do not
>  modify them manually.
> diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h
> index b4e1a092..d8e99940 100644
> --- a/include/linux/drm_fourcc.h
> +++ b/include/linux/drm_fourcc.h
> @@ -54,7 +54,7 @@ extern "C" {
>   * Format modifiers may change any property of the buffer, including the number
>   * of planes and/or the required allocation size. Format modifiers are
>   * vendor-namespaced, and as such the relationship between a fourcc code and a
> - * modifier is specific to the modifer being used. For example, some modifiers
> + * modifier is specific to the modifier being used. For example, some modifiers
>   * may preserve meaning - such as number of planes - from the fourcc code,
>   * whereas others may not.
>   *
> @@ -79,7 +79,7 @@ extern "C" {
>   *   format.
>   * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users
>   *   see modifiers as opaque tokens they can check for equality and intersect.
> - *   These users musn't need to know to reason about the modifier value
> + *   These users mustn't need to know to reason about the modifier value
>   *   (i.e. they are not expected to extract information out of the modifier).
>   *
>   * Vendors should document their modifier usage in as much detail as
> @@ -610,7 +610,7 @@ extern "C" {
>   * This is a tiled layout using 4Kb tiles in row-major layout.
>   * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which
>   * are arranged in four groups (two wide, two high) with column-major layout.
> - * Each group therefore consits out of four 256 byte units, which are also laid
> + * Each group therefore consists out of four 256 byte units, which are also laid
>   * out as 2x2 column-major.
>   * 256 byte units are made out of four 64 byte blocks of pixels, producing
>   * either a square block or a 2:1 unit.
> @@ -1183,7 +1183,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>   */
>  
>  /*
> - * The top 4 bits (out of the 56 bits alloted for specifying vendor specific
> + * The top 4 bits (out of the 56 bits allotted for specifying vendor specific
>   * modifiers) denote the category for modifiers. Currently we have three
>   * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of
>   * sixteen different categories.
> @@ -1499,7 +1499,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
>   * Amlogic FBC Memory Saving mode
>   *
>   * Indicates the storage is packed when pixel size is multiple of word
> - * boudaries, i.e. 8bit should be stored in this mode to save allocation
> + * boundaries, i.e. 8bit should be stored in this mode to save allocation
>   * memory.
>   *
>   * This mode reduces body layout to 3072 bytes per 64x32 superblock with
> diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
> index f05f747e..d4c1d991 100644
> --- a/include/linux/media-bus-format.h
> +++ b/include/linux/media-bus-format.h
> @@ -174,4 +174,13 @@
>   */
>  #define MEDIA_BUS_FMT_METADATA_FIXED		0x7001
>  
> +/* Generic line based metadata formats for serial buses. Next is 0x8008. */
> +#define MEDIA_BUS_FMT_META_8			0x8001
> +#define MEDIA_BUS_FMT_META_10			0x8002
> +#define MEDIA_BUS_FMT_META_12			0x8003
> +#define MEDIA_BUS_FMT_META_14			0x8004
> +#define MEDIA_BUS_FMT_META_16			0x8005
> +#define MEDIA_BUS_FMT_META_20			0x8006
> +#define MEDIA_BUS_FMT_META_24			0x8007
> +
>  #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
> diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
> index 2d1c448a..f87c6bd4 100644
> --- a/include/linux/rkisp1-config.h
> +++ b/include/linux/rkisp1-config.h
> @@ -4,8 +4,8 @@
>   * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
>   */
>  
> -#ifndef _UAPI_RKISP1_CONFIG_H
> -#define _UAPI_RKISP1_CONFIG_H
> +#ifndef _RKISP1_CONFIG_H
> +#define _RKISP1_CONFIG_H
>  
>  #include <linux/types.h>
>  
> @@ -175,11 +175,14 @@
>  /**
>   * enum rkisp1_cif_isp_version - ISP variants
>   *
> - * @RKISP1_V10: used at least in rk3288 and rk3399
> - * @RKISP1_V11: declared in the original vendor code, but not used
> - * @RKISP1_V12: used at least in rk3326 and px30
> - * @RKISP1_V13: used at least in rk1808
> - * @RKISP1_V_IMX8MP: used in at least imx8mp
> + * @RKISP1_V10: Used at least in RK3288 and RK3399.
> + * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
> + *	of entries in grids and histogram as v10.
> + * @RKISP1_V12: Used at least in RK3326 and PX30.
> + * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
> + *	histogram as v12.
> + * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
> + *	and histogram as v10.
>   */
>  enum rkisp1_cif_isp_version {
>  	RKISP1_V10 = 10,
> @@ -586,10 +589,9 @@ enum rkisp1_cif_isp_goc_mode {
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
> - * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
> - * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
> - * of the two.
> + * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
>   */
>  struct rkisp1_cif_isp_goc_config {
>  	__u32 mode;
> @@ -609,10 +611,10 @@ struct rkisp1_cif_isp_goc_config {
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
> - * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
> - * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
> - * of the two.
> + * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
> + * two.
>   */
>  struct rkisp1_cif_isp_hst_config {
>  	__u32 mode;
> @@ -904,9 +906,9 @@ struct rkisp1_cif_isp_bls_meas_val {
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
> - * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
> - * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
> + * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
> + * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
> + * to the maximum of the two.
>   *
>   * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
>   */
> @@ -946,21 +948,21 @@ struct rkisp1_cif_isp_af_stat {
>   *	       integer part.
>   *
>   * The window of the measurements area is divided to 5x5 sub-windows for
> - * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
> - * each sub-window independently and the final result is a weighted average of
> - * the histogram measurements on all sub-windows. The window of the
> - * measurements area and the weight of each sub-window are configurable using
> + * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
> + * sub-window independently and the final result is a weighted average of the
> + * histogram measurements on all sub-windows. The window of the measurements
> + * area and the weight of each sub-window are configurable using
>   * struct @rkisp1_cif_isp_hst_config.
>   *
> - * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
> + * The histogram contains 16 bins in V10 and 32 bins in V12.
>   *
>   * The number of entries of @hist_bins depends on the hardware revision
>   * as is reported by the hw_revision field of the struct media_device_info
>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
>   *
> - * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
> - * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
> - * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
> + * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
> + * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
> + * equal to the maximum of the two.
>   */
>  struct rkisp1_cif_isp_hist_stat {
>  	__u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
> @@ -994,4 +996,4 @@ struct rkisp1_stat_buffer {
>  	struct rkisp1_cif_isp_stat params;
>  };
>  
> -#endif /* _UAPI_RKISP1_CONFIG_H */
> +#endif /* _RKISP1_CONFIG_H */
> diff --git a/include/linux/udmabuf.h b/include/linux/udmabuf.h
> new file mode 100644
> index 00000000..76cc7de9
> --- /dev/null
> +++ b/include/linux/udmabuf.h
> @@ -0,0 +1,33 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +#ifndef _LINUX_UDMABUF_H
> +#define _LINUX_UDMABUF_H
> +
> +#include <linux/types.h>
> +#include <linux/ioctl.h>
> +
> +#define UDMABUF_FLAGS_CLOEXEC	0x01
> +
> +struct udmabuf_create {
> +	__u32 memfd;
> +	__u32 flags;
> +	__u64 offset;
> +	__u64 size;
> +};
> +
> +struct udmabuf_create_item {
> +	__u32 memfd;
> +	__u32 __pad;
> +	__u64 offset;
> +	__u64 size;
> +};
> +
> +struct udmabuf_create_list {
> +	__u32 flags;
> +	__u32 count;
> +	struct udmabuf_create_item list[];
> +};
> +
> +#define UDMABUF_CREATE       _IOW('u', 0x42, struct udmabuf_create)
> +#define UDMABUF_CREATE_LIST  _IOW('u', 0x43, struct udmabuf_create_list)
> +
> +#endif /* _LINUX_UDMABUF_H */
> diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
> index b9f64810..1e6e816b 100644
> --- a/include/linux/v4l2-controls.h
> +++ b/include/linux/v4l2-controls.h
> @@ -211,6 +211,12 @@ enum v4l2_colorfx {
>   */
>  #define V4L2_CID_USER_NPCM_BASE			(V4L2_CID_USER_BASE + 0x11b0)
>  
> +/*
> + * The base for THine THP7312 driver controls.
> + * We reserve 32 controls for this driver.
> + */
> +#define V4L2_CID_USER_THP7312_BASE		(V4L2_CID_USER_BASE + 0x11c0)
> +
>  /* MPEG-class control IDs */
>  /* The MPEG controls are applicable to all codec controls
>   * and the 'MPEG' part of the define is historical */
> diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
> index 2c318de1..097ef739 100644
> --- a/include/linux/v4l2-mediabus.h
> +++ b/include/linux/v4l2-mediabus.h
> @@ -19,12 +19,18 @@
>   * @width:	image width
>   * @height:	image height
>   * @code:	data format code (from enum v4l2_mbus_pixelcode)
> - * @field:	used interlacing type (from enum v4l2_field)
> - * @colorspace:	colorspace of the data (from enum v4l2_colorspace)
> - * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
> - * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding)
> - * @quantization: quantization of the data (from enum v4l2_quantization)
> - * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func)
> + * @field:	used interlacing type (from enum v4l2_field), zero for metadata
> + *		mbus codes
> + * @colorspace:	colorspace of the data (from enum v4l2_colorspace), zero on
> + *		metadata mbus codes
> + * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero
> + *		for metadata mbus codes
> + * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding), zero for
> + *		metadata mbus codes
> + * @quantization: quantization of the data (from enum v4l2_quantization), zero
> + *		for metadata mbus codes
> + * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func), zero
> + *		for metadata mbus codes
>   * @flags:	flags (V4L2_MBUS_FRAMEFMT_*)
>   * @reserved:  reserved bytes that can be later used
>   */
> diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
> index b383c2fe..2347e266 100644
> --- a/include/linux/v4l2-subdev.h
> +++ b/include/linux/v4l2-subdev.h
> @@ -50,6 +50,10 @@ struct v4l2_subdev_format {
>   * @rect: pad crop rectangle boundaries
>   * @stream: stream number, defined in subdev routing
>   * @reserved: drivers and applications must zero this array
> + *
> + * The subdev crop API is an obsolete interface and may be removed in the
> + * future. It is superseded by the selection API. No new extensions to this
> + * structure will be accepted.
>   */
>  struct v4l2_subdev_crop {
>  	__u32 which;
> @@ -116,13 +120,15 @@ struct v4l2_subdev_frame_size_enum {
>   * @pad: pad number, as reported by the media API
>   * @interval: frame interval in seconds
>   * @stream: stream number, defined in subdev routing
> + * @which: interval type (from enum v4l2_subdev_format_whence)
>   * @reserved: drivers and applications must zero this array
>   */
>  struct v4l2_subdev_frame_interval {
>  	__u32 pad;
>  	struct v4l2_fract interval;
>  	__u32 stream;
> -	__u32 reserved[8];
> +	__u32 which;
> +	__u32 reserved[7];
>  };
>  
>  /**
> @@ -133,7 +139,7 @@ struct v4l2_subdev_frame_interval {
>   * @width: frame width in pixels
>   * @height: frame height in pixels
>   * @interval: frame interval in seconds
> - * @which: format type (from enum v4l2_subdev_format_whence)
> + * @which: interval type (from enum v4l2_subdev_format_whence)
>   * @stream: stream number, defined in subdev routing
>   * @reserved: drivers and applications must zero this array
>   */
> @@ -222,15 +228,19 @@ struct v4l2_subdev_route {
>   * struct v4l2_subdev_routing - Subdev routing information
>   *
>   * @which: configuration type (from enum v4l2_subdev_format_whence)
> - * @num_routes: the total number of routes in the routes array
> + * @len_routes: the length of the routes array, in routes; set by the user, not
> + *		modified by the kernel
>   * @routes: pointer to the routes array
> + * @num_routes: the total number of routes, possibly more than fits in the
> + *		routes array
>   * @reserved: drivers and applications must zero this array
>   */
>  struct v4l2_subdev_routing {
>  	__u32 which;
> -	__u32 num_routes;
> +	__u32 len_routes;
>  	__u64 routes;
> -	__u32 reserved[6];
> +	__u32 num_routes;
> +	__u32 reserved[11];
>  };
>  
>  /*
> @@ -239,7 +249,14 @@ struct v4l2_subdev_routing {
>   * set (which is the default), the 'stream' fields will be forced to 0 by the
>   * kernel.
>   */
> - #define V4L2_SUBDEV_CLIENT_CAP_STREAMS		(1ULL << 0)
> +#define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0)
> +
> +/*
> + * The client is aware of the struct v4l2_subdev_frame_interval which field. If
> + * this is not set (which is the default), the which field is forced to
> + * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
> + */
> +#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1)
>  
>  /**
>   * struct v4l2_subdev_client_capability - Capabilities of the client accessing
> diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
> index 0b5482a0..7fe522e8 100644
> --- a/include/linux/videodev2.h
> +++ b/include/linux/videodev2.h
> @@ -574,6 +574,8 @@ struct v4l2_pix_format {
>  #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
>  #define V4L2_PIX_FMT_Y10P    v4l2_fourcc('Y', '1', '0', 'P') /* 10  Greyscale, MIPI RAW10 packed */
>  #define V4L2_PIX_FMT_IPU3_Y10		v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
> +#define V4L2_PIX_FMT_Y12P    v4l2_fourcc('Y', '1', '2', 'P') /* 12  Greyscale, MIPI RAW12 packed */
> +#define V4L2_PIX_FMT_Y14P    v4l2_fourcc('Y', '1', '4', 'P') /* 14  Greyscale, MIPI RAW14 packed */
>  
>  /* Palette formats */
>  #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */
> @@ -867,6 +869,7 @@ struct v4l2_fmtdesc {
>  #define V4L2_FMT_FLAG_CSC_YCBCR_ENC		0x0080
>  #define V4L2_FMT_FLAG_CSC_HSV_ENC		V4L2_FMT_FLAG_CSC_YCBCR_ENC
>  #define V4L2_FMT_FLAG_CSC_QUANTIZATION		0x0100
> +#define V4L2_FMT_FLAG_META_LINE_BASED		0x0200
>  
>  	/* Frame Size and frame rate enumeration */
>  /*
> @@ -1016,18 +1019,20 @@ struct v4l2_requestbuffers {
>  #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS		(1 << 4)
>  #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF	(1 << 5)
>  #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS		(1 << 6)
> +#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS		(1 << 7)
> +#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS		(1 << 8)
>  
>  /**
>   * struct v4l2_plane - plane info for multi-planar buffers
>   * @bytesused:		number of bytes occupied by data in the plane (payload)
>   * @length:		size of this plane (NOT the payload) in bytes
> - * @mem_offset:		when memory in the associated struct v4l2_buffer is
> + * @m.mem_offset:	when memory in the associated struct v4l2_buffer is
>   *			V4L2_MEMORY_MMAP, equals the offset from the start of
>   *			the device memory for this plane (or is a "cookie" that
>   *			should be passed to mmap() called on the video node)
> - * @userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
> + * @m.userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
>   *			pointing to this plane
> - * @fd:			when memory is V4L2_MEMORY_DMABUF, a userspace file
> + * @m.fd:		when memory is V4L2_MEMORY_DMABUF, a userspace file
>   *			descriptor associated with this plane
>   * @m:			union of @mem_offset, @userptr and @fd
>   * @data_offset:	offset in the plane to the start of data; usually 0,
> @@ -1065,14 +1070,14 @@ struct v4l2_plane {
>   * @sequence:	sequence count of this frame
>   * @memory:	enum v4l2_memory; the method, in which the actual video data is
>   *		passed
> - * @offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
> + * @m.offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
>   *		offset from the start of the device memory for this plane,
>   *		(or a "cookie" that should be passed to mmap() as offset)
> - * @userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
> + * @m.userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
>   *		a userspace pointer pointing to this buffer
> - * @fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
> + * @m.fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
>   *		a userspace file descriptor associated with this buffer
> - * @planes:	for multiplanar buffers; userspace pointer to the array of plane
> + * @m.planes:	for multiplanar buffers; userspace pointer to the array of plane
>   *		info structs for this buffer
>   * @m:		union of @offset, @userptr, @planes and @fd
>   * @length:	size in bytes of the buffer (NOT its payload) for single-plane
> @@ -1810,8 +1815,10 @@ struct v4l2_ext_control {
>  		struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
>  		struct v4l2_ctrl_av1_frame *p_av1_frame;
>  		struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
> +		struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll_info;
> +		struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering_display;
>  		void *ptr;
> -	};
> +	} __attribute__ ((packed));
>  } __attribute__ ((packed));
>  
>  struct v4l2_ext_controls {
> @@ -2381,23 +2388,32 @@ struct v4l2_sdr_format {
>   * struct v4l2_meta_format - metadata format definition
>   * @dataformat:		little endian four character code (fourcc)
>   * @buffersize:		maximum size in bytes required for data
> + * @width:		number of data units of data per line (valid for line
> + *			based formats only, see format documentation)
> + * @height:		number of lines of data per buffer (valid for line based
> + *			formats only)
> + * @bytesperline:	offset between the beginnings of two adjacent lines in
> + *			bytes (valid for line based formats only)
>   */
>  struct v4l2_meta_format {
>  	__u32				dataformat;
>  	__u32				buffersize;
> +	__u32				width;
> +	__u32				height;
> +	__u32				bytesperline;
>  } __attribute__ ((packed));
>  
>  /**
>   * struct v4l2_format - stream data format
> - * @type:	enum v4l2_buf_type; type of the data stream
> - * @pix:	definition of an image format
> - * @pix_mp:	definition of a multiplanar image format
> - * @win:	definition of an overlaid image
> - * @vbi:	raw VBI capture or output parameters
> - * @sliced:	sliced VBI capture or output parameters
> - * @raw_data:	placeholder for future extensions and custom formats
> - * @fmt:	union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta
> - *		and @raw_data
> + * @type:		enum v4l2_buf_type; type of the data stream
> + * @fmt.pix:		definition of an image format
> + * @fmt.pix_mp:		definition of a multiplanar image format
> + * @fmt.win:		definition of an overlaid image
> + * @fmt.vbi:		raw VBI capture or output parameters
> + * @fmt.sliced:		sliced VBI capture or output parameters
> + * @fmt.raw_data:	placeholder for future extensions and custom formats
> + * @fmt:		union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr,
> + *			@meta and @raw_data
>   */
>  struct v4l2_format {
>  	__u32	 type;
> @@ -2570,6 +2586,9 @@ struct v4l2_dbg_chip_info {
>   * @flags:	additional buffer management attributes (ignored unless the
>   *		queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability
>   *		and configured for MMAP streaming I/O).
> + * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set
> + *		this field indicate the maximum possible number of buffers
> + *		for this queue.
>   * @reserved:	future extensions
>   */
>  struct v4l2_create_buffers {
> @@ -2579,7 +2598,22 @@ struct v4l2_create_buffers {
>  	struct v4l2_format	format;
>  	__u32			capabilities;
>  	__u32			flags;
> -	__u32			reserved[6];
> +	__u32			max_num_buffers;
> +	__u32			reserved[5];
> +};
> +
> +/**
> + * struct v4l2_remove_buffers - VIDIOC_REMOVE_BUFS argument
> + * @index:	the first buffer to be removed
> + * @count:	number of buffers to removed
> + * @type:	enum v4l2_buf_type
> + * @reserved:	future extensions
> + */
> +struct v4l2_remove_buffers {
> +	__u32			index;
> +	__u32			count;
> +	__u32			type;
> +	__u32			reserved[13];
>  };
>  
>  /*
> @@ -2681,6 +2715,8 @@ struct v4l2_create_buffers {
>  #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)
>  
>  #define VIDIOC_QUERY_EXT_CTRL	_IOWR('V', 103, struct v4l2_query_ext_ctrl)
> +#define VIDIOC_REMOVE_BUFS	_IOWR('V', 104, struct v4l2_remove_buffers)
> +
>  
>  /* Reminder: when adding new ioctls please add support for them to
>     drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */
Laurent Pinchart June 1, 2024, 9:50 p.m. UTC | #6
Hi Hans,

On Sat, Jun 01, 2024 at 04:16:04PM +0200, Hans de Goede wrote:
> On 6/1/24 3:45 PM, Laurent Pinchart wrote:
> > On Thu, May 30, 2024 at 07:15:57PM +0200, Hans de Goede wrote:
> >> Updated kernel headers to v6.10-rc1 using utils/update-kernel-headers.sh
> >> and re-instating libcamera local modifications.
> >>
> >> This includes adding include/linux/udmabuf.h which was not part
> >> of libcamera's include/linux headers before.
> >>
> >> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> >> ---
> >>  include/linux/README             |  2 +-
> >>  include/linux/drm_fourcc.h       | 10 ++---
> >>  include/linux/media-bus-format.h |  9 ++++
> >>  include/linux/rkisp1-config.h    | 56 +++++++++++++------------
> >>  include/linux/udmabuf.h          | 33 +++++++++++++++
> >>  include/linux/v4l2-controls.h    |  6 +++
> >>  include/linux/v4l2-mediabus.h    | 18 +++++---
> >>  include/linux/v4l2-subdev.h      | 29 ++++++++++---
> >>  include/linux/videodev2.h        | 72 ++++++++++++++++++++++++--------
> >>  9 files changed, 172 insertions(+), 63 deletions(-)
> >>  create mode 100644 include/linux/udmabuf.h
> >>
> >> diff --git a/include/linux/README b/include/linux/README
> >> index 101e4997..b7795309 100644
> >> --- a/include/linux/README
> >> +++ b/include/linux/README
> >> @@ -1,4 +1,4 @@
> >>  # SPDX-License-Identifier: CC0-1.0
> >>  
> >> -Files in this directory are imported from v6.7 of the Linux kernel. Do not
> >> +Files in this directory are imported from v6.10-rc1 of the Linux kernel. Do not
> >>  modify them manually.
> >> diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h
> >> index b4e1a092..d8e99940 100644
> >> --- a/include/linux/drm_fourcc.h
> >> +++ b/include/linux/drm_fourcc.h
> >> @@ -54,7 +54,7 @@ extern "C" {
> >>   * Format modifiers may change any property of the buffer, including the number
> >>   * of planes and/or the required allocation size. Format modifiers are
> >>   * vendor-namespaced, and as such the relationship between a fourcc code and a
> >> - * modifier is specific to the modifer being used. For example, some modifiers
> >> + * modifier is specific to the modifier being used. For example, some modifiers
> >>   * may preserve meaning - such as number of planes - from the fourcc code,
> >>   * whereas others may not.
> >>   *
> >> @@ -79,7 +79,7 @@ extern "C" {
> >>   *   format.
> >>   * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users
> >>   *   see modifiers as opaque tokens they can check for equality and intersect.
> >> - *   These users musn't need to know to reason about the modifier value
> >> + *   These users mustn't need to know to reason about the modifier value
> >>   *   (i.e. they are not expected to extract information out of the modifier).
> >>   *
> >>   * Vendors should document their modifier usage in as much detail as
> >> @@ -610,7 +610,7 @@ extern "C" {
> >>   * This is a tiled layout using 4Kb tiles in row-major layout.
> >>   * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which
> >>   * are arranged in four groups (two wide, two high) with column-major layout.
> >> - * Each group therefore consits out of four 256 byte units, which are also laid
> >> + * Each group therefore consists out of four 256 byte units, which are also laid
> >>   * out as 2x2 column-major.
> >>   * 256 byte units are made out of four 64 byte blocks of pixels, producing
> >>   * either a square block or a 2:1 unit.
> >> @@ -1183,7 +1183,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
> >>   */
> >>  
> >>  /*
> >> - * The top 4 bits (out of the 56 bits alloted for specifying vendor specific
> >> + * The top 4 bits (out of the 56 bits allotted for specifying vendor specific
> >>   * modifiers) denote the category for modifiers. Currently we have three
> >>   * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of
> >>   * sixteen different categories.
> >> @@ -1499,7 +1499,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
> >>   * Amlogic FBC Memory Saving mode
> >>   *
> >>   * Indicates the storage is packed when pixel size is multiple of word
> >> - * boudaries, i.e. 8bit should be stored in this mode to save allocation
> >> + * boundaries, i.e. 8bit should be stored in this mode to save allocation
> >>   * memory.
> >>   *
> >>   * This mode reduces body layout to 3072 bytes per 64x32 superblock with
> >> diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
> >> index f05f747e..d4c1d991 100644
> >> --- a/include/linux/media-bus-format.h
> >> +++ b/include/linux/media-bus-format.h
> >> @@ -174,4 +174,13 @@
> >>   */
> >>  #define MEDIA_BUS_FMT_METADATA_FIXED		0x7001
> >>  
> >> +/* Generic line based metadata formats for serial buses. Next is 0x8008. */
> >> +#define MEDIA_BUS_FMT_META_8			0x8001
> >> +#define MEDIA_BUS_FMT_META_10			0x8002
> >> +#define MEDIA_BUS_FMT_META_12			0x8003
> >> +#define MEDIA_BUS_FMT_META_14			0x8004
> >> +#define MEDIA_BUS_FMT_META_16			0x8005
> >> +#define MEDIA_BUS_FMT_META_20			0x8006
> >> +#define MEDIA_BUS_FMT_META_24			0x8007
> >> +
> >>  #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
> >> diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
> >> index 2d1c448a..f87c6bd4 100644
> >> --- a/include/linux/rkisp1-config.h
> >> +++ b/include/linux/rkisp1-config.h
> >> @@ -4,8 +4,8 @@
> >>   * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
> >>   */
> >>  
> >> -#ifndef _UAPI_RKISP1_CONFIG_H
> >> -#define _UAPI_RKISP1_CONFIG_H
> >> +#ifndef _RKISP1_CONFIG_H
> >> +#define _RKISP1_CONFIG_H
> >>  
> >>  #include <linux/types.h>
> >>  
> >> @@ -175,11 +175,14 @@
> >>  /**
> >>   * enum rkisp1_cif_isp_version - ISP variants
> >>   *
> >> - * @RKISP1_V10: used at least in rk3288 and rk3399
> >> - * @RKISP1_V11: declared in the original vendor code, but not used
> >> - * @RKISP1_V12: used at least in rk3326 and px30
> >> - * @RKISP1_V13: used at least in rk1808
> >> - * @RKISP1_V_IMX8MP: used in at least imx8mp
> >> + * @RKISP1_V10: Used at least in RK3288 and RK3399.
> >> + * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
> >> + *	of entries in grids and histogram as v10.
> >> + * @RKISP1_V12: Used at least in RK3326 and PX30.
> >> + * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
> >> + *	histogram as v12.
> >> + * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
> >> + *	and histogram as v10.
> >>   */
> >>  enum rkisp1_cif_isp_version {
> >>  	RKISP1_V10 = 10,
> >> @@ -586,10 +589,9 @@ enum rkisp1_cif_isp_goc_mode {
> >>   * as is reported by the hw_revision field of the struct media_device_info
> >>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
> >>   *
> >> - * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
> >> - * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
> >> - * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
> >> - * of the two.
> >> + * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
> >> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
> >> + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
> >>   */
> >>  struct rkisp1_cif_isp_goc_config {
> >>  	__u32 mode;
> >> @@ -609,10 +611,10 @@ struct rkisp1_cif_isp_goc_config {
> >>   * as is reported by the hw_revision field of the struct media_device_info
> >>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
> >>   *
> >> - * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
> >> - * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
> >> - * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
> >> - * of the two.
> >> + * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
> >> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
> >> + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
> >> + * two.
> >>   */
> >>  struct rkisp1_cif_isp_hst_config {
> >>  	__u32 mode;
> >> @@ -904,9 +906,9 @@ struct rkisp1_cif_isp_bls_meas_val {
> >>   * as is reported by the hw_revision field of the struct media_device_info
> >>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
> >>   *
> >> - * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
> >> - * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
> >> - * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
> >> + * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
> >> + * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
> >> + * to the maximum of the two.
> >>   *
> >>   * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
> >>   */
> >> @@ -946,21 +948,21 @@ struct rkisp1_cif_isp_af_stat {
> >>   *	       integer part.
> >>   *
> >>   * The window of the measurements area is divided to 5x5 sub-windows for
> >> - * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
> >> - * each sub-window independently and the final result is a weighted average of
> >> - * the histogram measurements on all sub-windows. The window of the
> >> - * measurements area and the weight of each sub-window are configurable using
> >> + * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
> >> + * sub-window independently and the final result is a weighted average of the
> >> + * histogram measurements on all sub-windows. The window of the measurements
> >> + * area and the weight of each sub-window are configurable using
> >>   * struct @rkisp1_cif_isp_hst_config.
> >>   *
> >> - * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
> >> + * The histogram contains 16 bins in V10 and 32 bins in V12.
> >>   *
> >>   * The number of entries of @hist_bins depends on the hardware revision
> >>   * as is reported by the hw_revision field of the struct media_device_info
> >>   * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
> >>   *
> >> - * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
> >> - * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
> >> - * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
> >> + * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
> >> + * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
> >> + * equal to the maximum of the two.
> >>   */
> >>  struct rkisp1_cif_isp_hist_stat {
> >>  	__u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
> >> @@ -994,4 +996,4 @@ struct rkisp1_stat_buffer {
> >>  	struct rkisp1_cif_isp_stat params;
> >>  };
> >>  
> >> -#endif /* _UAPI_RKISP1_CONFIG_H */
> >> +#endif /* _RKISP1_CONFIG_H */
> >> diff --git a/include/linux/udmabuf.h b/include/linux/udmabuf.h
> >> new file mode 100644
> >> index 00000000..76cc7de9
> >> --- /dev/null
> >> +++ b/include/linux/udmabuf.h
> >> @@ -0,0 +1,33 @@
> >> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> >> +#ifndef _LINUX_UDMABUF_H
> >> +#define _LINUX_UDMABUF_H
> >> +
> >> +#include <linux/types.h>
> >> +#include <linux/ioctl.h>
> >> +
> >> +#define UDMABUF_FLAGS_CLOEXEC	0x01
> >> +
> >> +struct udmabuf_create {
> >> +	__u32 memfd;
> >> +	__u32 flags;
> >> +	__u64 offset;
> >> +	__u64 size;
> >> +};
> >> +
> >> +struct udmabuf_create_item {
> >> +	__u32 memfd;
> >> +	__u32 __pad;
> >> +	__u64 offset;
> >> +	__u64 size;
> >> +};
> >> +
> >> +struct udmabuf_create_list {
> >> +	__u32 flags;
> >> +	__u32 count;
> >> +	struct udmabuf_create_item list[];
> >> +};
> >> +
> >> +#define UDMABUF_CREATE       _IOW('u', 0x42, struct udmabuf_create)
> >> +#define UDMABUF_CREATE_LIST  _IOW('u', 0x43, struct udmabuf_create_list)
> >> +
> >> +#endif /* _LINUX_UDMABUF_H */
> >> diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
> >> index b9f64810..1e6e816b 100644
> >> --- a/include/linux/v4l2-controls.h
> >> +++ b/include/linux/v4l2-controls.h
> >> @@ -211,6 +211,12 @@ enum v4l2_colorfx {
> >>   */
> >>  #define V4L2_CID_USER_NPCM_BASE			(V4L2_CID_USER_BASE + 0x11b0)
> >>  
> >> +/*
> >> + * The base for THine THP7312 driver controls.
> >> + * We reserve 32 controls for this driver.
> >> + */
> >> +#define V4L2_CID_USER_THP7312_BASE		(V4L2_CID_USER_BASE + 0x11c0)
> >> +
> >>  /* MPEG-class control IDs */
> >>  /* The MPEG controls are applicable to all codec controls
> >>   * and the 'MPEG' part of the define is historical */
> >> diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
> >> index 2c318de1..097ef739 100644
> >> --- a/include/linux/v4l2-mediabus.h
> >> +++ b/include/linux/v4l2-mediabus.h
> >> @@ -19,12 +19,18 @@
> >>   * @width:	image width
> >>   * @height:	image height
> >>   * @code:	data format code (from enum v4l2_mbus_pixelcode)
> >> - * @field:	used interlacing type (from enum v4l2_field)
> >> - * @colorspace:	colorspace of the data (from enum v4l2_colorspace)
> >> - * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
> >> - * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding)
> >> - * @quantization: quantization of the data (from enum v4l2_quantization)
> >> - * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func)
> >> + * @field:	used interlacing type (from enum v4l2_field), zero for metadata
> >> + *		mbus codes
> >> + * @colorspace:	colorspace of the data (from enum v4l2_colorspace), zero on
> >> + *		metadata mbus codes
> >> + * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero
> >> + *		for metadata mbus codes
> >> + * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding), zero for
> >> + *		metadata mbus codes
> >> + * @quantization: quantization of the data (from enum v4l2_quantization), zero
> >> + *		for metadata mbus codes
> >> + * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func), zero
> >> + *		for metadata mbus codes
> >>   * @flags:	flags (V4L2_MBUS_FRAMEFMT_*)
> >>   * @reserved:  reserved bytes that can be later used
> >>   */
> >> diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
> >> index b383c2fe..2347e266 100644
> >> --- a/include/linux/v4l2-subdev.h
> >> +++ b/include/linux/v4l2-subdev.h
> >> @@ -50,6 +50,10 @@ struct v4l2_subdev_format {
> >>   * @rect: pad crop rectangle boundaries
> >>   * @stream: stream number, defined in subdev routing
> >>   * @reserved: drivers and applications must zero this array
> >> + *
> >> + * The subdev crop API is an obsolete interface and may be removed in the
> >> + * future. It is superseded by the selection API. No new extensions to this
> >> + * structure will be accepted.
> >>   */
> >>  struct v4l2_subdev_crop {
> >>  	__u32 which;
> >> @@ -116,13 +120,15 @@ struct v4l2_subdev_frame_size_enum {
> >>   * @pad: pad number, as reported by the media API
> >>   * @interval: frame interval in seconds
> >>   * @stream: stream number, defined in subdev routing
> >> + * @which: interval type (from enum v4l2_subdev_format_whence)
> >>   * @reserved: drivers and applications must zero this array
> >>   */
> >>  struct v4l2_subdev_frame_interval {
> >>  	__u32 pad;
> >>  	struct v4l2_fract interval;
> >>  	__u32 stream;
> >> -	__u32 reserved[8];
> >> +	__u32 which;
> >> +	__u32 reserved[7];
> >>  };
> >>  
> >>  /**
> >> @@ -133,7 +139,7 @@ struct v4l2_subdev_frame_interval {
> >>   * @width: frame width in pixels
> >>   * @height: frame height in pixels
> >>   * @interval: frame interval in seconds
> >> - * @which: format type (from enum v4l2_subdev_format_whence)
> >> + * @which: interval type (from enum v4l2_subdev_format_whence)
> >>   * @stream: stream number, defined in subdev routing
> >>   * @reserved: drivers and applications must zero this array
> >>   */
> >> @@ -222,15 +228,19 @@ struct v4l2_subdev_route {
> >>   * struct v4l2_subdev_routing - Subdev routing information
> >>   *
> >>   * @which: configuration type (from enum v4l2_subdev_format_whence)
> >> - * @num_routes: the total number of routes in the routes array
> >> + * @len_routes: the length of the routes array, in routes; set by the user, not
> >> + *		modified by the kernel
> >>   * @routes: pointer to the routes array
> >> + * @num_routes: the total number of routes, possibly more than fits in the
> >> + *		routes array
> >>   * @reserved: drivers and applications must zero this array
> >>   */
> >>  struct v4l2_subdev_routing {
> >>  	__u32 which;
> >> -	__u32 num_routes;
> >> +	__u32 len_routes;
> >>  	__u64 routes;
> >> -	__u32 reserved[6];
> >> +	__u32 num_routes;
> >> +	__u32 reserved[11];
> > 
> > This will cause some issues. The routing API has changed, we need to
> > handle it in a backward-compatible way. I have patches for that, I think
> > I have even posted them. 
> 
> I thought that this was only exposed to userspace when
> v4l2_subdev_enable_streams_api is set to true in
> drivers/media/v4l2-core/v4l2-subdev.c
> 
> And that is never set to true unless the kernel is manually editted
> because the API is not stable yet (which is why it was ok
> for Sakari to make this change upstream) ?
> 
> I guess this may be enabled already on some downstream kernels
> and that libcamera needs to handle that ?

Yes, that's exactly the reson :-)

> > I'll rebase on top of this patch and repost.
> > The two series will need to be merged together.
> > 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Thank you the review(s) and for rebasing your series.
> 
> >>  };
> >>  
> >>  /*
> >> @@ -239,7 +249,14 @@ struct v4l2_subdev_routing {
> >>   * set (which is the default), the 'stream' fields will be forced to 0 by the
> >>   * kernel.
> >>   */
> >> - #define V4L2_SUBDEV_CLIENT_CAP_STREAMS		(1ULL << 0)
> >> +#define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0)
> >> +
> >> +/*
> >> + * The client is aware of the struct v4l2_subdev_frame_interval which field. If
> >> + * this is not set (which is the default), the which field is forced to
> >> + * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
> >> + */
> >> +#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1)
> >>  
> >>  /**
> >>   * struct v4l2_subdev_client_capability - Capabilities of the client accessing
> >> diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
> >> index 0b5482a0..7fe522e8 100644
> >> --- a/include/linux/videodev2.h
> >> +++ b/include/linux/videodev2.h
> >> @@ -574,6 +574,8 @@ struct v4l2_pix_format {
> >>  #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
> >>  #define V4L2_PIX_FMT_Y10P    v4l2_fourcc('Y', '1', '0', 'P') /* 10  Greyscale, MIPI RAW10 packed */
> >>  #define V4L2_PIX_FMT_IPU3_Y10		v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
> >> +#define V4L2_PIX_FMT_Y12P    v4l2_fourcc('Y', '1', '2', 'P') /* 12  Greyscale, MIPI RAW12 packed */
> >> +#define V4L2_PIX_FMT_Y14P    v4l2_fourcc('Y', '1', '4', 'P') /* 14  Greyscale, MIPI RAW14 packed */
> >>  
> >>  /* Palette formats */
> >>  #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */
> >> @@ -867,6 +869,7 @@ struct v4l2_fmtdesc {
> >>  #define V4L2_FMT_FLAG_CSC_YCBCR_ENC		0x0080
> >>  #define V4L2_FMT_FLAG_CSC_HSV_ENC		V4L2_FMT_FLAG_CSC_YCBCR_ENC
> >>  #define V4L2_FMT_FLAG_CSC_QUANTIZATION		0x0100
> >> +#define V4L2_FMT_FLAG_META_LINE_BASED		0x0200
> >>  
> >>  	/* Frame Size and frame rate enumeration */
> >>  /*
> >> @@ -1016,18 +1019,20 @@ struct v4l2_requestbuffers {
> >>  #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS		(1 << 4)
> >>  #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF	(1 << 5)
> >>  #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS		(1 << 6)
> >> +#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS		(1 << 7)
> >> +#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS		(1 << 8)
> >>  
> >>  /**
> >>   * struct v4l2_plane - plane info for multi-planar buffers
> >>   * @bytesused:		number of bytes occupied by data in the plane (payload)
> >>   * @length:		size of this plane (NOT the payload) in bytes
> >> - * @mem_offset:		when memory in the associated struct v4l2_buffer is
> >> + * @m.mem_offset:	when memory in the associated struct v4l2_buffer is
> >>   *			V4L2_MEMORY_MMAP, equals the offset from the start of
> >>   *			the device memory for this plane (or is a "cookie" that
> >>   *			should be passed to mmap() called on the video node)
> >> - * @userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
> >> + * @m.userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
> >>   *			pointing to this plane
> >> - * @fd:			when memory is V4L2_MEMORY_DMABUF, a userspace file
> >> + * @m.fd:		when memory is V4L2_MEMORY_DMABUF, a userspace file
> >>   *			descriptor associated with this plane
> >>   * @m:			union of @mem_offset, @userptr and @fd
> >>   * @data_offset:	offset in the plane to the start of data; usually 0,
> >> @@ -1065,14 +1070,14 @@ struct v4l2_plane {
> >>   * @sequence:	sequence count of this frame
> >>   * @memory:	enum v4l2_memory; the method, in which the actual video data is
> >>   *		passed
> >> - * @offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
> >> + * @m.offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
> >>   *		offset from the start of the device memory for this plane,
> >>   *		(or a "cookie" that should be passed to mmap() as offset)
> >> - * @userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
> >> + * @m.userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
> >>   *		a userspace pointer pointing to this buffer
> >> - * @fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
> >> + * @m.fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
> >>   *		a userspace file descriptor associated with this buffer
> >> - * @planes:	for multiplanar buffers; userspace pointer to the array of plane
> >> + * @m.planes:	for multiplanar buffers; userspace pointer to the array of plane
> >>   *		info structs for this buffer
> >>   * @m:		union of @offset, @userptr, @planes and @fd
> >>   * @length:	size in bytes of the buffer (NOT its payload) for single-plane
> >> @@ -1810,8 +1815,10 @@ struct v4l2_ext_control {
> >>  		struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
> >>  		struct v4l2_ctrl_av1_frame *p_av1_frame;
> >>  		struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
> >> +		struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll_info;
> >> +		struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering_display;
> >>  		void *ptr;
> >> -	};
> >> +	} __attribute__ ((packed));
> >>  } __attribute__ ((packed));
> >>  
> >>  struct v4l2_ext_controls {
> >> @@ -2381,23 +2388,32 @@ struct v4l2_sdr_format {
> >>   * struct v4l2_meta_format - metadata format definition
> >>   * @dataformat:		little endian four character code (fourcc)
> >>   * @buffersize:		maximum size in bytes required for data
> >> + * @width:		number of data units of data per line (valid for line
> >> + *			based formats only, see format documentation)
> >> + * @height:		number of lines of data per buffer (valid for line based
> >> + *			formats only)
> >> + * @bytesperline:	offset between the beginnings of two adjacent lines in
> >> + *			bytes (valid for line based formats only)
> >>   */
> >>  struct v4l2_meta_format {
> >>  	__u32				dataformat;
> >>  	__u32				buffersize;
> >> +	__u32				width;
> >> +	__u32				height;
> >> +	__u32				bytesperline;
> >>  } __attribute__ ((packed));
> >>  
> >>  /**
> >>   * struct v4l2_format - stream data format
> >> - * @type:	enum v4l2_buf_type; type of the data stream
> >> - * @pix:	definition of an image format
> >> - * @pix_mp:	definition of a multiplanar image format
> >> - * @win:	definition of an overlaid image
> >> - * @vbi:	raw VBI capture or output parameters
> >> - * @sliced:	sliced VBI capture or output parameters
> >> - * @raw_data:	placeholder for future extensions and custom formats
> >> - * @fmt:	union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta
> >> - *		and @raw_data
> >> + * @type:		enum v4l2_buf_type; type of the data stream
> >> + * @fmt.pix:		definition of an image format
> >> + * @fmt.pix_mp:		definition of a multiplanar image format
> >> + * @fmt.win:		definition of an overlaid image
> >> + * @fmt.vbi:		raw VBI capture or output parameters
> >> + * @fmt.sliced:		sliced VBI capture or output parameters
> >> + * @fmt.raw_data:	placeholder for future extensions and custom formats
> >> + * @fmt:		union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr,
> >> + *			@meta and @raw_data
> >>   */
> >>  struct v4l2_format {
> >>  	__u32	 type;
> >> @@ -2570,6 +2586,9 @@ struct v4l2_dbg_chip_info {
> >>   * @flags:	additional buffer management attributes (ignored unless the
> >>   *		queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability
> >>   *		and configured for MMAP streaming I/O).
> >> + * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set
> >> + *		this field indicate the maximum possible number of buffers
> >> + *		for this queue.
> >>   * @reserved:	future extensions
> >>   */
> >>  struct v4l2_create_buffers {
> >> @@ -2579,7 +2598,22 @@ struct v4l2_create_buffers {
> >>  	struct v4l2_format	format;
> >>  	__u32			capabilities;
> >>  	__u32			flags;
> >> -	__u32			reserved[6];
> >> +	__u32			max_num_buffers;
> >> +	__u32			reserved[5];
> >> +};
> >> +
> >> +/**
> >> + * struct v4l2_remove_buffers - VIDIOC_REMOVE_BUFS argument
> >> + * @index:	the first buffer to be removed
> >> + * @count:	number of buffers to removed
> >> + * @type:	enum v4l2_buf_type
> >> + * @reserved:	future extensions
> >> + */
> >> +struct v4l2_remove_buffers {
> >> +	__u32			index;
> >> +	__u32			count;
> >> +	__u32			type;
> >> +	__u32			reserved[13];
> >>  };
> >>  
> >>  /*
> >> @@ -2681,6 +2715,8 @@ struct v4l2_create_buffers {
> >>  #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)
> >>  
> >>  #define VIDIOC_QUERY_EXT_CTRL	_IOWR('V', 103, struct v4l2_query_ext_ctrl)
> >> +#define VIDIOC_REMOVE_BUFS	_IOWR('V', 104, struct v4l2_remove_buffers)
> >> +
> >>  
> >>  /* Reminder: when adding new ioctls please add support for them to
> >>     drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */

Patch
diff mbox series

diff --git a/include/linux/README b/include/linux/README
index 101e4997..b7795309 100644
--- a/include/linux/README
+++ b/include/linux/README
@@ -1,4 +1,4 @@ 
 # SPDX-License-Identifier: CC0-1.0
 
-Files in this directory are imported from v6.7 of the Linux kernel. Do not
+Files in this directory are imported from v6.10-rc1 of the Linux kernel. Do not
 modify them manually.
diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h
index b4e1a092..d8e99940 100644
--- a/include/linux/drm_fourcc.h
+++ b/include/linux/drm_fourcc.h
@@ -54,7 +54,7 @@  extern "C" {
  * Format modifiers may change any property of the buffer, including the number
  * of planes and/or the required allocation size. Format modifiers are
  * vendor-namespaced, and as such the relationship between a fourcc code and a
- * modifier is specific to the modifer being used. For example, some modifiers
+ * modifier is specific to the modifier being used. For example, some modifiers
  * may preserve meaning - such as number of planes - from the fourcc code,
  * whereas others may not.
  *
@@ -79,7 +79,7 @@  extern "C" {
  *   format.
  * - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users
  *   see modifiers as opaque tokens they can check for equality and intersect.
- *   These users musn't need to know to reason about the modifier value
+ *   These users mustn't need to know to reason about the modifier value
  *   (i.e. they are not expected to extract information out of the modifier).
  *
  * Vendors should document their modifier usage in as much detail as
@@ -610,7 +610,7 @@  extern "C" {
  * This is a tiled layout using 4Kb tiles in row-major layout.
  * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which
  * are arranged in four groups (two wide, two high) with column-major layout.
- * Each group therefore consits out of four 256 byte units, which are also laid
+ * Each group therefore consists out of four 256 byte units, which are also laid
  * out as 2x2 column-major.
  * 256 byte units are made out of four 64 byte blocks of pixels, producing
  * either a square block or a 2:1 unit.
@@ -1183,7 +1183,7 @@  drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
  */
 
 /*
- * The top 4 bits (out of the 56 bits alloted for specifying vendor specific
+ * The top 4 bits (out of the 56 bits allotted for specifying vendor specific
  * modifiers) denote the category for modifiers. Currently we have three
  * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of
  * sixteen different categories.
@@ -1499,7 +1499,7 @@  drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
  * Amlogic FBC Memory Saving mode
  *
  * Indicates the storage is packed when pixel size is multiple of word
- * boudaries, i.e. 8bit should be stored in this mode to save allocation
+ * boundaries, i.e. 8bit should be stored in this mode to save allocation
  * memory.
  *
  * This mode reduces body layout to 3072 bytes per 64x32 superblock with
diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
index f05f747e..d4c1d991 100644
--- a/include/linux/media-bus-format.h
+++ b/include/linux/media-bus-format.h
@@ -174,4 +174,13 @@ 
  */
 #define MEDIA_BUS_FMT_METADATA_FIXED		0x7001
 
+/* Generic line based metadata formats for serial buses. Next is 0x8008. */
+#define MEDIA_BUS_FMT_META_8			0x8001
+#define MEDIA_BUS_FMT_META_10			0x8002
+#define MEDIA_BUS_FMT_META_12			0x8003
+#define MEDIA_BUS_FMT_META_14			0x8004
+#define MEDIA_BUS_FMT_META_16			0x8005
+#define MEDIA_BUS_FMT_META_20			0x8006
+#define MEDIA_BUS_FMT_META_24			0x8007
+
 #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
index 2d1c448a..f87c6bd4 100644
--- a/include/linux/rkisp1-config.h
+++ b/include/linux/rkisp1-config.h
@@ -4,8 +4,8 @@ 
  * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
  */
 
-#ifndef _UAPI_RKISP1_CONFIG_H
-#define _UAPI_RKISP1_CONFIG_H
+#ifndef _RKISP1_CONFIG_H
+#define _RKISP1_CONFIG_H
 
 #include <linux/types.h>
 
@@ -175,11 +175,14 @@ 
 /**
  * enum rkisp1_cif_isp_version - ISP variants
  *
- * @RKISP1_V10: used at least in rk3288 and rk3399
- * @RKISP1_V11: declared in the original vendor code, but not used
- * @RKISP1_V12: used at least in rk3326 and px30
- * @RKISP1_V13: used at least in rk1808
- * @RKISP1_V_IMX8MP: used in at least imx8mp
+ * @RKISP1_V10: Used at least in RK3288 and RK3399.
+ * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
+ *	of entries in grids and histogram as v10.
+ * @RKISP1_V12: Used at least in RK3326 and PX30.
+ * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
+ *	histogram as v12.
+ * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
+ *	and histogram as v10.
  */
 enum rkisp1_cif_isp_version {
 	RKISP1_V10 = 10,
@@ -586,10 +589,9 @@  enum rkisp1_cif_isp_goc_mode {
  * as is reported by the hw_revision field of the struct media_device_info
  * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  *
- * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
- * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
- * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
- * of the two.
+ * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
+ * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
+ * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
  */
 struct rkisp1_cif_isp_goc_config {
 	__u32 mode;
@@ -609,10 +611,10 @@  struct rkisp1_cif_isp_goc_config {
  * as is reported by the hw_revision field of the struct media_device_info
  * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  *
- * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
- * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
- * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
- * of the two.
+ * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
+ * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
+ * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
+ * two.
  */
 struct rkisp1_cif_isp_hst_config {
 	__u32 mode;
@@ -904,9 +906,9 @@  struct rkisp1_cif_isp_bls_meas_val {
  * as is reported by the hw_revision field of the struct media_device_info
  * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  *
- * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
- * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
- * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
+ * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
+ * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
+ * to the maximum of the two.
  *
  * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
  */
@@ -946,21 +948,21 @@  struct rkisp1_cif_isp_af_stat {
  *	       integer part.
  *
  * The window of the measurements area is divided to 5x5 sub-windows for
- * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
- * each sub-window independently and the final result is a weighted average of
- * the histogram measurements on all sub-windows. The window of the
- * measurements area and the weight of each sub-window are configurable using
+ * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
+ * sub-window independently and the final result is a weighted average of the
+ * histogram measurements on all sub-windows. The window of the measurements
+ * area and the weight of each sub-window are configurable using
  * struct @rkisp1_cif_isp_hst_config.
  *
- * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
+ * The histogram contains 16 bins in V10 and 32 bins in V12.
  *
  * The number of entries of @hist_bins depends on the hardware revision
  * as is reported by the hw_revision field of the struct media_device_info
  * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  *
- * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
- * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
- * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
+ * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
+ * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
+ * equal to the maximum of the two.
  */
 struct rkisp1_cif_isp_hist_stat {
 	__u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
@@ -994,4 +996,4 @@  struct rkisp1_stat_buffer {
 	struct rkisp1_cif_isp_stat params;
 };
 
-#endif /* _UAPI_RKISP1_CONFIG_H */
+#endif /* _RKISP1_CONFIG_H */
diff --git a/include/linux/udmabuf.h b/include/linux/udmabuf.h
new file mode 100644
index 00000000..76cc7de9
--- /dev/null
+++ b/include/linux/udmabuf.h
@@ -0,0 +1,33 @@ 
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _LINUX_UDMABUF_H
+#define _LINUX_UDMABUF_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define UDMABUF_FLAGS_CLOEXEC	0x01
+
+struct udmabuf_create {
+	__u32 memfd;
+	__u32 flags;
+	__u64 offset;
+	__u64 size;
+};
+
+struct udmabuf_create_item {
+	__u32 memfd;
+	__u32 __pad;
+	__u64 offset;
+	__u64 size;
+};
+
+struct udmabuf_create_list {
+	__u32 flags;
+	__u32 count;
+	struct udmabuf_create_item list[];
+};
+
+#define UDMABUF_CREATE       _IOW('u', 0x42, struct udmabuf_create)
+#define UDMABUF_CREATE_LIST  _IOW('u', 0x43, struct udmabuf_create_list)
+
+#endif /* _LINUX_UDMABUF_H */
diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
index b9f64810..1e6e816b 100644
--- a/include/linux/v4l2-controls.h
+++ b/include/linux/v4l2-controls.h
@@ -211,6 +211,12 @@  enum v4l2_colorfx {
  */
 #define V4L2_CID_USER_NPCM_BASE			(V4L2_CID_USER_BASE + 0x11b0)
 
+/*
+ * The base for THine THP7312 driver controls.
+ * We reserve 32 controls for this driver.
+ */
+#define V4L2_CID_USER_THP7312_BASE		(V4L2_CID_USER_BASE + 0x11c0)
+
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls
  * and the 'MPEG' part of the define is historical */
diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
index 2c318de1..097ef739 100644
--- a/include/linux/v4l2-mediabus.h
+++ b/include/linux/v4l2-mediabus.h
@@ -19,12 +19,18 @@ 
  * @width:	image width
  * @height:	image height
  * @code:	data format code (from enum v4l2_mbus_pixelcode)
- * @field:	used interlacing type (from enum v4l2_field)
- * @colorspace:	colorspace of the data (from enum v4l2_colorspace)
- * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
- * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding)
- * @quantization: quantization of the data (from enum v4l2_quantization)
- * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func)
+ * @field:	used interlacing type (from enum v4l2_field), zero for metadata
+ *		mbus codes
+ * @colorspace:	colorspace of the data (from enum v4l2_colorspace), zero on
+ *		metadata mbus codes
+ * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero
+ *		for metadata mbus codes
+ * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding), zero for
+ *		metadata mbus codes
+ * @quantization: quantization of the data (from enum v4l2_quantization), zero
+ *		for metadata mbus codes
+ * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func), zero
+ *		for metadata mbus codes
  * @flags:	flags (V4L2_MBUS_FRAMEFMT_*)
  * @reserved:  reserved bytes that can be later used
  */
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
index b383c2fe..2347e266 100644
--- a/include/linux/v4l2-subdev.h
+++ b/include/linux/v4l2-subdev.h
@@ -50,6 +50,10 @@  struct v4l2_subdev_format {
  * @rect: pad crop rectangle boundaries
  * @stream: stream number, defined in subdev routing
  * @reserved: drivers and applications must zero this array
+ *
+ * The subdev crop API is an obsolete interface and may be removed in the
+ * future. It is superseded by the selection API. No new extensions to this
+ * structure will be accepted.
  */
 struct v4l2_subdev_crop {
 	__u32 which;
@@ -116,13 +120,15 @@  struct v4l2_subdev_frame_size_enum {
  * @pad: pad number, as reported by the media API
  * @interval: frame interval in seconds
  * @stream: stream number, defined in subdev routing
+ * @which: interval type (from enum v4l2_subdev_format_whence)
  * @reserved: drivers and applications must zero this array
  */
 struct v4l2_subdev_frame_interval {
 	__u32 pad;
 	struct v4l2_fract interval;
 	__u32 stream;
-	__u32 reserved[8];
+	__u32 which;
+	__u32 reserved[7];
 };
 
 /**
@@ -133,7 +139,7 @@  struct v4l2_subdev_frame_interval {
  * @width: frame width in pixels
  * @height: frame height in pixels
  * @interval: frame interval in seconds
- * @which: format type (from enum v4l2_subdev_format_whence)
+ * @which: interval type (from enum v4l2_subdev_format_whence)
  * @stream: stream number, defined in subdev routing
  * @reserved: drivers and applications must zero this array
  */
@@ -222,15 +228,19 @@  struct v4l2_subdev_route {
  * struct v4l2_subdev_routing - Subdev routing information
  *
  * @which: configuration type (from enum v4l2_subdev_format_whence)
- * @num_routes: the total number of routes in the routes array
+ * @len_routes: the length of the routes array, in routes; set by the user, not
+ *		modified by the kernel
  * @routes: pointer to the routes array
+ * @num_routes: the total number of routes, possibly more than fits in the
+ *		routes array
  * @reserved: drivers and applications must zero this array
  */
 struct v4l2_subdev_routing {
 	__u32 which;
-	__u32 num_routes;
+	__u32 len_routes;
 	__u64 routes;
-	__u32 reserved[6];
+	__u32 num_routes;
+	__u32 reserved[11];
 };
 
 /*
@@ -239,7 +249,14 @@  struct v4l2_subdev_routing {
  * set (which is the default), the 'stream' fields will be forced to 0 by the
  * kernel.
  */
- #define V4L2_SUBDEV_CLIENT_CAP_STREAMS		(1ULL << 0)
+#define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0)
+
+/*
+ * The client is aware of the struct v4l2_subdev_frame_interval which field. If
+ * this is not set (which is the default), the which field is forced to
+ * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
+ */
+#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1)
 
 /**
  * struct v4l2_subdev_client_capability - Capabilities of the client accessing
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 0b5482a0..7fe522e8 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -574,6 +574,8 @@  struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
 #define V4L2_PIX_FMT_Y10P    v4l2_fourcc('Y', '1', '0', 'P') /* 10  Greyscale, MIPI RAW10 packed */
 #define V4L2_PIX_FMT_IPU3_Y10		v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
+#define V4L2_PIX_FMT_Y12P    v4l2_fourcc('Y', '1', '2', 'P') /* 12  Greyscale, MIPI RAW12 packed */
+#define V4L2_PIX_FMT_Y14P    v4l2_fourcc('Y', '1', '4', 'P') /* 14  Greyscale, MIPI RAW14 packed */
 
 /* Palette formats */
 #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */
@@ -867,6 +869,7 @@  struct v4l2_fmtdesc {
 #define V4L2_FMT_FLAG_CSC_YCBCR_ENC		0x0080
 #define V4L2_FMT_FLAG_CSC_HSV_ENC		V4L2_FMT_FLAG_CSC_YCBCR_ENC
 #define V4L2_FMT_FLAG_CSC_QUANTIZATION		0x0100
+#define V4L2_FMT_FLAG_META_LINE_BASED		0x0200
 
 	/* Frame Size and frame rate enumeration */
 /*
@@ -1016,18 +1019,20 @@  struct v4l2_requestbuffers {
 #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS		(1 << 4)
 #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF	(1 << 5)
 #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS		(1 << 6)
+#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS		(1 << 7)
+#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS		(1 << 8)
 
 /**
  * struct v4l2_plane - plane info for multi-planar buffers
  * @bytesused:		number of bytes occupied by data in the plane (payload)
  * @length:		size of this plane (NOT the payload) in bytes
- * @mem_offset:		when memory in the associated struct v4l2_buffer is
+ * @m.mem_offset:	when memory in the associated struct v4l2_buffer is
  *			V4L2_MEMORY_MMAP, equals the offset from the start of
  *			the device memory for this plane (or is a "cookie" that
  *			should be passed to mmap() called on the video node)
- * @userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
+ * @m.userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer
  *			pointing to this plane
- * @fd:			when memory is V4L2_MEMORY_DMABUF, a userspace file
+ * @m.fd:		when memory is V4L2_MEMORY_DMABUF, a userspace file
  *			descriptor associated with this plane
  * @m:			union of @mem_offset, @userptr and @fd
  * @data_offset:	offset in the plane to the start of data; usually 0,
@@ -1065,14 +1070,14 @@  struct v4l2_plane {
  * @sequence:	sequence count of this frame
  * @memory:	enum v4l2_memory; the method, in which the actual video data is
  *		passed
- * @offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
+ * @m.offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
  *		offset from the start of the device memory for this plane,
  *		(or a "cookie" that should be passed to mmap() as offset)
- * @userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
+ * @m.userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
  *		a userspace pointer pointing to this buffer
- * @fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
+ * @m.fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
  *		a userspace file descriptor associated with this buffer
- * @planes:	for multiplanar buffers; userspace pointer to the array of plane
+ * @m.planes:	for multiplanar buffers; userspace pointer to the array of plane
  *		info structs for this buffer
  * @m:		union of @offset, @userptr, @planes and @fd
  * @length:	size in bytes of the buffer (NOT its payload) for single-plane
@@ -1810,8 +1815,10 @@  struct v4l2_ext_control {
 		struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
 		struct v4l2_ctrl_av1_frame *p_av1_frame;
 		struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
+		struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll_info;
+		struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering_display;
 		void *ptr;
-	};
+	} __attribute__ ((packed));
 } __attribute__ ((packed));
 
 struct v4l2_ext_controls {
@@ -2381,23 +2388,32 @@  struct v4l2_sdr_format {
  * struct v4l2_meta_format - metadata format definition
  * @dataformat:		little endian four character code (fourcc)
  * @buffersize:		maximum size in bytes required for data
+ * @width:		number of data units of data per line (valid for line
+ *			based formats only, see format documentation)
+ * @height:		number of lines of data per buffer (valid for line based
+ *			formats only)
+ * @bytesperline:	offset between the beginnings of two adjacent lines in
+ *			bytes (valid for line based formats only)
  */
 struct v4l2_meta_format {
 	__u32				dataformat;
 	__u32				buffersize;
+	__u32				width;
+	__u32				height;
+	__u32				bytesperline;
 } __attribute__ ((packed));
 
 /**
  * struct v4l2_format - stream data format
- * @type:	enum v4l2_buf_type; type of the data stream
- * @pix:	definition of an image format
- * @pix_mp:	definition of a multiplanar image format
- * @win:	definition of an overlaid image
- * @vbi:	raw VBI capture or output parameters
- * @sliced:	sliced VBI capture or output parameters
- * @raw_data:	placeholder for future extensions and custom formats
- * @fmt:	union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta
- *		and @raw_data
+ * @type:		enum v4l2_buf_type; type of the data stream
+ * @fmt.pix:		definition of an image format
+ * @fmt.pix_mp:		definition of a multiplanar image format
+ * @fmt.win:		definition of an overlaid image
+ * @fmt.vbi:		raw VBI capture or output parameters
+ * @fmt.sliced:		sliced VBI capture or output parameters
+ * @fmt.raw_data:	placeholder for future extensions and custom formats
+ * @fmt:		union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr,
+ *			@meta and @raw_data
  */
 struct v4l2_format {
 	__u32	 type;
@@ -2570,6 +2586,9 @@  struct v4l2_dbg_chip_info {
  * @flags:	additional buffer management attributes (ignored unless the
  *		queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability
  *		and configured for MMAP streaming I/O).
+ * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set
+ *		this field indicate the maximum possible number of buffers
+ *		for this queue.
  * @reserved:	future extensions
  */
 struct v4l2_create_buffers {
@@ -2579,7 +2598,22 @@  struct v4l2_create_buffers {
 	struct v4l2_format	format;
 	__u32			capabilities;
 	__u32			flags;
-	__u32			reserved[6];
+	__u32			max_num_buffers;
+	__u32			reserved[5];
+};
+
+/**
+ * struct v4l2_remove_buffers - VIDIOC_REMOVE_BUFS argument
+ * @index:	the first buffer to be removed
+ * @count:	number of buffers to removed
+ * @type:	enum v4l2_buf_type
+ * @reserved:	future extensions
+ */
+struct v4l2_remove_buffers {
+	__u32			index;
+	__u32			count;
+	__u32			type;
+	__u32			reserved[13];
 };
 
 /*
@@ -2681,6 +2715,8 @@  struct v4l2_create_buffers {
 #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)
 
 #define VIDIOC_QUERY_EXT_CTRL	_IOWR('V', 103, struct v4l2_query_ext_ctrl)
+#define VIDIOC_REMOVE_BUFS	_IOWR('V', 104, struct v4l2_remove_buffers)
+
 
 /* Reminder: when adding new ioctls please add support for them to
    drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */