[v2,11/16] include: linux: Partially update linux headers from v6.16-rc1-310-gd968e50b5c26
diff mbox series

Message ID 20250808141315.413839-12-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • Implement WDR algorithm
Related show

Commit Message

Stefan Klug Aug. 8, 2025, 2:12 p.m. UTC
Update rkisp1-config.h and v4l2-controls.h from the next branch of
https://gitlab.freedesktop.org/linux-media/media-committers.git to
include the WDR related updates. The rest was left as is to minimize the
risk of issues due to last minute changes in the upstream process.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>

---

Changes in v2:
- Updated headers from linux-media next branch
---
 include/linux/rkisp1-config.h | 108 +++++++++++++++++++++++++++++++++-
 include/linux/v4l2-controls.h |  17 ++++--
 2 files changed, 119 insertions(+), 6 deletions(-)

Comments

Kieran Bingham Aug. 9, 2025, 11:49 a.m. UTC | #1
Quoting Stefan Klug (2025-08-08 15:12:49)
> Update rkisp1-config.h and v4l2-controls.h from the next branch of
> https://gitlab.freedesktop.org/linux-media/media-committers.git to
> include the WDR related updates. The rest was left as is to minimize the
> risk of issues due to last minute changes in the upstream process.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> 
> ---
> 
> Changes in v2:
> - Updated headers from linux-media next branch
> ---
>  include/linux/rkisp1-config.h | 108 +++++++++++++++++++++++++++++++++-
>  include/linux/v4l2-controls.h |  17 ++++--
>  2 files changed, 119 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
> index edbc6cb65d1c..d323bfa72d8e 100644
> --- a/include/linux/rkisp1-config.h
> +++ b/include/linux/rkisp1-config.h
> @@ -169,6 +169,13 @@
>   */
>  #define RKISP1_CIF_ISP_COMPAND_NUM_POINTS      64
>  
> +/*
> + * Wide Dynamic Range
> + */
> +#define RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV    32
> +#define RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF     (RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV + 1)
> +#define RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS   4
> +
>  /*
>   * Measurement types
>   */
> @@ -889,6 +896,72 @@ struct rkisp1_cif_isp_compand_curve_config {
>         __u32 y[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
>  };
>  
> +/**
> + * struct rkisp1_cif_isp_wdr_tone_curve - Tone mapping curve definition for WDR.
> + *
> + * @dY: the dYn increments for horizontal (input) axis of the tone curve.
> + *      each 3-bit dY value represents an increment of 2**(value+3).
> + *      dY[0] bits 0:2 is increment dY1, bit 3 unused
> + *      dY[0] bits 4:6 is increment dY2, bit 7 unused
> + *      ...
> + *      dY[0] bits 28:30 is increment dY8, bit 31 unused
> + *      ... and so on till dY[3] bits 28:30 is increment dY32, bit 31 unused.
> + * @ym: the Ym values for the vertical (output) axis of the tone curve.
> + *      each value is 13 bit.
> + */
> +struct rkisp1_cif_isp_wdr_tone_curve {
> +       __u32 dY[RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS];
> +       __u16 ym[RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF];
> +};
> +
> +/**
> + * struct rkisp1_cif_isp_wdr_iref_config - Illumination reference config for WDR.
> + *
> + * Use illumination reference value as described below, instead of only the
> + * luminance (Y) value for tone mapping and gain calculations:
> + * IRef = (rgb_factor * RGBMax_tr + (8 - rgb_factor) * Y)/8
> + *
> + * @rgb_factor: defines how much influence the RGBmax approach has in
> + *              comparison to Y (valid values are 0..8).
> + * @use_y9_8: use Y*9/8 for maximum value calculation along with the
> + *            default of R, G, B for noise reduction.
> + * @use_rgb7_8: decrease RGBMax by 7/8 for noise reduction.
> + * @disable_transient: disable transient calculation between Y and RGBY_max.
> + */
> +struct rkisp1_cif_isp_wdr_iref_config {
> +       __u8 rgb_factor;
> +       __u8 use_y9_8;
> +       __u8 use_rgb7_8;
> +       __u8 disable_transient;
> +};
> +
> +/**
> + * struct rkisp1_cif_isp_wdr_config - Configuration for wide dynamic range.
> + *
> + * @tone_curve: tone mapping curve.
> + * @iref_config: illumination reference configuration. (when use_iref is true)
> + * @rgb_offset: RGB offset value for RGB operation mode. (12 bits)
> + * @luma_offset: luminance offset value for RGB operation mode. (12 bits)
> + * @dmin_thresh: lower threshold for deltaMin value. (12 bits)
> + * @dmin_strength: strength factor for deltaMin. (valid range is 0x00..0x10)
> + * @use_rgb_colorspace: use RGB instead of luminance/chrominance colorspace.
> + * @bypass_chroma_mapping: disable chrominance mapping (only valid if
> + *                         use_rgb_colorspace = 0)
> + * @use_iref: use illumination reference instead of Y for tone mapping
> + *            and gain calculations.
> + */
> +struct rkisp1_cif_isp_wdr_config {
> +       struct rkisp1_cif_isp_wdr_tone_curve tone_curve;
> +       struct rkisp1_cif_isp_wdr_iref_config iref_config;
> +       __u16 rgb_offset;
> +       __u16 luma_offset;
> +       __u16 dmin_thresh;
> +       __u8 dmin_strength;
> +       __u8 use_rgb_colorspace;
> +       __u8 bypass_chroma_mapping;
> +       __u8 use_iref;
> +};
> +
>  /*---------- PART2: Measurement Statistics ------------*/
>  
>  /**
> @@ -1059,6 +1132,7 @@ struct rkisp1_stat_buffer {
>   * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS: BLS in the compand block
>   * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND: Companding expand curve
>   * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS: Companding compress curve
> + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR: Wide dynamic range
>   */
>  enum rkisp1_ext_params_block_type {
>         RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS,
> @@ -1081,11 +1155,15 @@ enum rkisp1_ext_params_block_type {
>         RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS,
>         RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND,
>         RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS,
> +       RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR,
>  };
>  
>  #define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE     (1U << 0)
>  #define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE      (1U << 1)
>  
> +/* A bitmask of parameters blocks supported on the current hardware. */
> +#define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS     (V4L2_CID_USER_RKISP1_BASE + 0x01)
> +
>  /**
>   * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters block
>   *                                        header
> @@ -1460,6 +1538,23 @@ struct rkisp1_ext_params_compand_curve_config {
>         struct rkisp1_cif_isp_compand_curve_config config;
>  } __attribute__((aligned(8)));
>  
> +/**
> + * struct rkisp1_ext_params_wdr_config - RkISP1 extensible params
> + *                                       Wide dynamic range config
> + *
> + * RkISP1 extensible parameters WDR block.
> + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR`
> + *
> + * @header: The RkISP1 extensible parameters header, see
> + *         :c:type:`rkisp1_ext_params_block_header`
> + * @config: WDR configuration, see
> + *         :c:type:`rkisp1_cif_isp_wdr_config`
> + */
> +struct rkisp1_ext_params_wdr_config {
> +       struct rkisp1_ext_params_block_header header;
> +       struct rkisp1_cif_isp_wdr_config config;
> +} __attribute__((aligned(8)));
> +
>  /*
>   * The rkisp1_ext_params_compand_curve_config structure is counted twice as it
>   * is used for both the COMPAND_EXPAND and COMPAND_COMPRESS block types.
> @@ -1484,7 +1579,8 @@ struct rkisp1_ext_params_compand_curve_config {
>         sizeof(struct rkisp1_ext_params_afc_config)                     +\
>         sizeof(struct rkisp1_ext_params_compand_bls_config)             +\
>         sizeof(struct rkisp1_ext_params_compand_curve_config)           +\
> -       sizeof(struct rkisp1_ext_params_compand_curve_config))
> +       sizeof(struct rkisp1_ext_params_compand_curve_config)           +\
> +       sizeof(struct rkisp1_ext_params_wdr_config))
>  
>  /**
>   * enum rksip1_ext_param_buffer_version - RkISP1 extensible parameters version
> @@ -1520,6 +1616,14 @@ enum rksip1_ext_param_buffer_version {
>   * V4L2 control. If such control is not available, userspace should assume only
>   * RKISP1_EXT_PARAM_BUFFER_V1 is supported by the driver.
>   *
> + * The read-only V4L2 control ``RKISP1_CID_SUPPORTED_PARAMS_BLOCKS`` can be used
> + * to query the blocks supported by the device. It contains a bitmask where each
> + * bit represents the availability of the corresponding entry from the
> + * :c:type:`rkisp1_ext_params_block_type` enum. The current and default values
> + * of the control represents the blocks supported by the device instance, while
> + * the maximum value represents the blocks supported by the kernel driver,
> + * independently of the device instance.
> + *
>   * For each ISP block that userspace wants to configure, a block-specific
>   * structure is appended to the @data buffer, one after the other without gaps
>   * in between nor overlaps. Userspace shall populate the @data_size field with
> @@ -1528,7 +1632,7 @@ enum rksip1_ext_param_buffer_version {
>   * The expected memory layout of the parameters buffer is::
>   *
>   *     +-------------------- struct rkisp1_ext_params_cfg -------------------+
> - *     | version = RKISP_EXT_PARAMS_BUFFER_V1;                               |
> + *     | version = RKISP1_EXT_PARAM_BUFFER_V1;                               |
>   *     | data_size = sizeof(struct rkisp1_ext_params_bls_config)             |
>   *     |           + sizeof(struct rkisp1_ext_params_dpcc_config);           |
>   *     | +------------------------- data  ---------------------------------+ |
> diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
> index 882a81805783..fc43bb09efe3 100644
> --- a/include/linux/v4l2-controls.h
> +++ b/include/linux/v4l2-controls.h
> @@ -177,10 +177,6 @@ enum v4l2_colorfx {
>   * We reserve 128 controls for this driver.
>   */
>  #define V4L2_CID_USER_CCS_BASE                 (V4L2_CID_USER_BASE + 0x10f0)
> -
> -/* The base for the bcm2835-isp driver controls.
> - * We reserve 16 controls for this driver. */
> -#define V4L2_CID_USER_BCM2835_ISP_BASE         (V4L2_CID_USER_BASE + 0x10e0)

I expect this patch shouldn't be removing this?

>  /*
>   * The base for Allegro driver controls.
>   * We reserve 16 controls for this driver.
> @@ -217,6 +213,19 @@ enum v4l2_colorfx {
>   */
>  #define V4L2_CID_USER_THP7312_BASE             (V4L2_CID_USER_BASE + 0x11c0)
>  
> +/*
> + * The base for the uvc driver controls.
> + * See linux/uvcvideo.h for the list of controls.
> + * We reserve 64 controls for this driver.
> + */
> +#define V4L2_CID_USER_UVC_BASE                 (V4L2_CID_USER_BASE + 0x11e0)

Or adding this ?

> +
> +/*
> + * The base for Rockchip ISP1 driver controls.
> + * We reserve 16 controls for this driver.
> + */
> +#define V4L2_CID_USER_RKISP1_BASE              (V4L2_CID_USER_BASE + 0x1220)
> +
>  /* MPEG-class control IDs */
>  /* The MPEG controls are applicable to all codec controls
>   * and the 'MPEG' part of the define is historical */
> -- 
> 2.48.1
>
Stefan Klug Aug. 11, 2025, 5:28 a.m. UTC | #2
Hi Kieran,

Thank you for the review.

Quoting Kieran Bingham (2025-08-09 13:49:49)
> Quoting Stefan Klug (2025-08-08 15:12:49)
> > Update rkisp1-config.h and v4l2-controls.h from the next branch of
> > https://gitlab.freedesktop.org/linux-media/media-committers.git to
> > include the WDR related updates. The rest was left as is to minimize the
> > risk of issues due to last minute changes in the upstream process.
> > 
> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> > 
> > ---
> > 
> > Changes in v2:
> > - Updated headers from linux-media next branch
> > ---
> >  include/linux/rkisp1-config.h | 108 +++++++++++++++++++++++++++++++++-
> >  include/linux/v4l2-controls.h |  17 ++++--
> >  2 files changed, 119 insertions(+), 6 deletions(-)
> > 
> > diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
> > index edbc6cb65d1c..d323bfa72d8e 100644
> > --- a/include/linux/rkisp1-config.h
> > +++ b/include/linux/rkisp1-config.h
> > @@ -169,6 +169,13 @@
> >   */
> >  #define RKISP1_CIF_ISP_COMPAND_NUM_POINTS      64
> >  
> > +/*
> > + * Wide Dynamic Range
> > + */
> > +#define RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV    32
> > +#define RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF     (RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV + 1)
> > +#define RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS   4
> > +
> >  /*
> >   * Measurement types
> >   */
> > @@ -889,6 +896,72 @@ struct rkisp1_cif_isp_compand_curve_config {
> >         __u32 y[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
> >  };
> >  
> > +/**
> > + * struct rkisp1_cif_isp_wdr_tone_curve - Tone mapping curve definition for WDR.
> > + *
> > + * @dY: the dYn increments for horizontal (input) axis of the tone curve.
> > + *      each 3-bit dY value represents an increment of 2**(value+3).
> > + *      dY[0] bits 0:2 is increment dY1, bit 3 unused
> > + *      dY[0] bits 4:6 is increment dY2, bit 7 unused
> > + *      ...
> > + *      dY[0] bits 28:30 is increment dY8, bit 31 unused
> > + *      ... and so on till dY[3] bits 28:30 is increment dY32, bit 31 unused.
> > + * @ym: the Ym values for the vertical (output) axis of the tone curve.
> > + *      each value is 13 bit.
> > + */
> > +struct rkisp1_cif_isp_wdr_tone_curve {
> > +       __u32 dY[RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS];
> > +       __u16 ym[RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF];
> > +};
> > +
> > +/**
> > + * struct rkisp1_cif_isp_wdr_iref_config - Illumination reference config for WDR.
> > + *
> > + * Use illumination reference value as described below, instead of only the
> > + * luminance (Y) value for tone mapping and gain calculations:
> > + * IRef = (rgb_factor * RGBMax_tr + (8 - rgb_factor) * Y)/8
> > + *
> > + * @rgb_factor: defines how much influence the RGBmax approach has in
> > + *              comparison to Y (valid values are 0..8).
> > + * @use_y9_8: use Y*9/8 for maximum value calculation along with the
> > + *            default of R, G, B for noise reduction.
> > + * @use_rgb7_8: decrease RGBMax by 7/8 for noise reduction.
> > + * @disable_transient: disable transient calculation between Y and RGBY_max.
> > + */
> > +struct rkisp1_cif_isp_wdr_iref_config {
> > +       __u8 rgb_factor;
> > +       __u8 use_y9_8;
> > +       __u8 use_rgb7_8;
> > +       __u8 disable_transient;
> > +};
> > +
> > +/**
> > + * struct rkisp1_cif_isp_wdr_config - Configuration for wide dynamic range.
> > + *
> > + * @tone_curve: tone mapping curve.
> > + * @iref_config: illumination reference configuration. (when use_iref is true)
> > + * @rgb_offset: RGB offset value for RGB operation mode. (12 bits)
> > + * @luma_offset: luminance offset value for RGB operation mode. (12 bits)
> > + * @dmin_thresh: lower threshold for deltaMin value. (12 bits)
> > + * @dmin_strength: strength factor for deltaMin. (valid range is 0x00..0x10)
> > + * @use_rgb_colorspace: use RGB instead of luminance/chrominance colorspace.
> > + * @bypass_chroma_mapping: disable chrominance mapping (only valid if
> > + *                         use_rgb_colorspace = 0)
> > + * @use_iref: use illumination reference instead of Y for tone mapping
> > + *            and gain calculations.
> > + */
> > +struct rkisp1_cif_isp_wdr_config {
> > +       struct rkisp1_cif_isp_wdr_tone_curve tone_curve;
> > +       struct rkisp1_cif_isp_wdr_iref_config iref_config;
> > +       __u16 rgb_offset;
> > +       __u16 luma_offset;
> > +       __u16 dmin_thresh;
> > +       __u8 dmin_strength;
> > +       __u8 use_rgb_colorspace;
> > +       __u8 bypass_chroma_mapping;
> > +       __u8 use_iref;
> > +};
> > +
> >  /*---------- PART2: Measurement Statistics ------------*/
> >  
> >  /**
> > @@ -1059,6 +1132,7 @@ struct rkisp1_stat_buffer {
> >   * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS: BLS in the compand block
> >   * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND: Companding expand curve
> >   * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS: Companding compress curve
> > + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR: Wide dynamic range
> >   */
> >  enum rkisp1_ext_params_block_type {
> >         RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS,
> > @@ -1081,11 +1155,15 @@ enum rkisp1_ext_params_block_type {
> >         RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS,
> >         RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND,
> >         RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS,
> > +       RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR,
> >  };
> >  
> >  #define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE     (1U << 0)
> >  #define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE      (1U << 1)
> >  
> > +/* A bitmask of parameters blocks supported on the current hardware. */
> > +#define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS     (V4L2_CID_USER_RKISP1_BASE + 0x01)
> > +
> >  /**
> >   * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters block
> >   *                                        header
> > @@ -1460,6 +1538,23 @@ struct rkisp1_ext_params_compand_curve_config {
> >         struct rkisp1_cif_isp_compand_curve_config config;
> >  } __attribute__((aligned(8)));
> >  
> > +/**
> > + * struct rkisp1_ext_params_wdr_config - RkISP1 extensible params
> > + *                                       Wide dynamic range config
> > + *
> > + * RkISP1 extensible parameters WDR block.
> > + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR`
> > + *
> > + * @header: The RkISP1 extensible parameters header, see
> > + *         :c:type:`rkisp1_ext_params_block_header`
> > + * @config: WDR configuration, see
> > + *         :c:type:`rkisp1_cif_isp_wdr_config`
> > + */
> > +struct rkisp1_ext_params_wdr_config {
> > +       struct rkisp1_ext_params_block_header header;
> > +       struct rkisp1_cif_isp_wdr_config config;
> > +} __attribute__((aligned(8)));
> > +
> >  /*
> >   * The rkisp1_ext_params_compand_curve_config structure is counted twice as it
> >   * is used for both the COMPAND_EXPAND and COMPAND_COMPRESS block types.
> > @@ -1484,7 +1579,8 @@ struct rkisp1_ext_params_compand_curve_config {
> >         sizeof(struct rkisp1_ext_params_afc_config)                     +\
> >         sizeof(struct rkisp1_ext_params_compand_bls_config)             +\
> >         sizeof(struct rkisp1_ext_params_compand_curve_config)           +\
> > -       sizeof(struct rkisp1_ext_params_compand_curve_config))
> > +       sizeof(struct rkisp1_ext_params_compand_curve_config)           +\
> > +       sizeof(struct rkisp1_ext_params_wdr_config))
> >  
> >  /**
> >   * enum rksip1_ext_param_buffer_version - RkISP1 extensible parameters version
> > @@ -1520,6 +1616,14 @@ enum rksip1_ext_param_buffer_version {
> >   * V4L2 control. If such control is not available, userspace should assume only
> >   * RKISP1_EXT_PARAM_BUFFER_V1 is supported by the driver.
> >   *
> > + * The read-only V4L2 control ``RKISP1_CID_SUPPORTED_PARAMS_BLOCKS`` can be used
> > + * to query the blocks supported by the device. It contains a bitmask where each
> > + * bit represents the availability of the corresponding entry from the
> > + * :c:type:`rkisp1_ext_params_block_type` enum. The current and default values
> > + * of the control represents the blocks supported by the device instance, while
> > + * the maximum value represents the blocks supported by the kernel driver,
> > + * independently of the device instance.
> > + *
> >   * For each ISP block that userspace wants to configure, a block-specific
> >   * structure is appended to the @data buffer, one after the other without gaps
> >   * in between nor overlaps. Userspace shall populate the @data_size field with
> > @@ -1528,7 +1632,7 @@ enum rksip1_ext_param_buffer_version {
> >   * The expected memory layout of the parameters buffer is::
> >   *
> >   *     +-------------------- struct rkisp1_ext_params_cfg -------------------+
> > - *     | version = RKISP_EXT_PARAMS_BUFFER_V1;                               |
> > + *     | version = RKISP1_EXT_PARAM_BUFFER_V1;                               |
> >   *     | data_size = sizeof(struct rkisp1_ext_params_bls_config)             |
> >   *     |           + sizeof(struct rkisp1_ext_params_dpcc_config);           |
> >   *     | +------------------------- data  ---------------------------------+ |
> > diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
> > index 882a81805783..fc43bb09efe3 100644
> > --- a/include/linux/v4l2-controls.h
> > +++ b/include/linux/v4l2-controls.h
> > @@ -177,10 +177,6 @@ enum v4l2_colorfx {
> >   * We reserve 128 controls for this driver.
> >   */
> >  #define V4L2_CID_USER_CCS_BASE                 (V4L2_CID_USER_BASE + 0x10f0)
> > -
> > -/* The base for the bcm2835-isp driver controls.
> > - * We reserve 16 controls for this driver. */
> > -#define V4L2_CID_USER_BCM2835_ISP_BASE         (V4L2_CID_USER_BASE + 0x10e0)
> 
> I expect this patch shouldn't be removing this?

Yes, that was the cause of one of the CI failures.

> 
> >  /*
> >   * The base for Allegro driver controls.
> >   * We reserve 16 controls for this driver.
> > @@ -217,6 +213,19 @@ enum v4l2_colorfx {
> >   */
> >  #define V4L2_CID_USER_THP7312_BASE             (V4L2_CID_USER_BASE + 0x11c0)
> >  
> > +/*
> > + * The base for the uvc driver controls.
> > + * See linux/uvcvideo.h for the list of controls.
> > + * We reserve 64 controls for this driver.
> > + */
> > +#define V4L2_CID_USER_UVC_BASE                 (V4L2_CID_USER_BASE + 0x11e0)
> 
> Or adding this ?

Yes, I'll drop that also.

Best regards,
Stefan

> 
> > +
> > +/*
> > + * The base for Rockchip ISP1 driver controls.
> > + * We reserve 16 controls for this driver.
> > + */
> > +#define V4L2_CID_USER_RKISP1_BASE              (V4L2_CID_USER_BASE + 0x1220)
> > +
> >  /* MPEG-class control IDs */
> >  /* The MPEG controls are applicable to all codec controls
> >   * and the 'MPEG' part of the define is historical */
> > -- 
> > 2.48.1
> >

Patch
diff mbox series

diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
index edbc6cb65d1c..d323bfa72d8e 100644
--- a/include/linux/rkisp1-config.h
+++ b/include/linux/rkisp1-config.h
@@ -169,6 +169,13 @@ 
  */
 #define RKISP1_CIF_ISP_COMPAND_NUM_POINTS	64
 
+/*
+ * Wide Dynamic Range
+ */
+#define RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV	32
+#define RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF	(RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV + 1)
+#define RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS	4
+
 /*
  * Measurement types
  */
@@ -889,6 +896,72 @@  struct rkisp1_cif_isp_compand_curve_config {
 	__u32 y[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
 };
 
+/**
+ * struct rkisp1_cif_isp_wdr_tone_curve - Tone mapping curve definition for WDR.
+ *
+ * @dY: the dYn increments for horizontal (input) axis of the tone curve.
+ *      each 3-bit dY value represents an increment of 2**(value+3).
+ *      dY[0] bits 0:2 is increment dY1, bit 3 unused
+ *      dY[0] bits 4:6 is increment dY2, bit 7 unused
+ *      ...
+ *      dY[0] bits 28:30 is increment dY8, bit 31 unused
+ *      ... and so on till dY[3] bits 28:30 is increment dY32, bit 31 unused.
+ * @ym: the Ym values for the vertical (output) axis of the tone curve.
+ *      each value is 13 bit.
+ */
+struct rkisp1_cif_isp_wdr_tone_curve {
+	__u32 dY[RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS];
+	__u16 ym[RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF];
+};
+
+/**
+ * struct rkisp1_cif_isp_wdr_iref_config - Illumination reference config for WDR.
+ *
+ * Use illumination reference value as described below, instead of only the
+ * luminance (Y) value for tone mapping and gain calculations:
+ * IRef = (rgb_factor * RGBMax_tr + (8 - rgb_factor) * Y)/8
+ *
+ * @rgb_factor: defines how much influence the RGBmax approach has in
+ *              comparison to Y (valid values are 0..8).
+ * @use_y9_8: use Y*9/8 for maximum value calculation along with the
+ *            default of R, G, B for noise reduction.
+ * @use_rgb7_8: decrease RGBMax by 7/8 for noise reduction.
+ * @disable_transient: disable transient calculation between Y and RGBY_max.
+ */
+struct rkisp1_cif_isp_wdr_iref_config {
+	__u8 rgb_factor;
+	__u8 use_y9_8;
+	__u8 use_rgb7_8;
+	__u8 disable_transient;
+};
+
+/**
+ * struct rkisp1_cif_isp_wdr_config - Configuration for wide dynamic range.
+ *
+ * @tone_curve: tone mapping curve.
+ * @iref_config: illumination reference configuration. (when use_iref is true)
+ * @rgb_offset: RGB offset value for RGB operation mode. (12 bits)
+ * @luma_offset: luminance offset value for RGB operation mode. (12 bits)
+ * @dmin_thresh: lower threshold for deltaMin value. (12 bits)
+ * @dmin_strength: strength factor for deltaMin. (valid range is 0x00..0x10)
+ * @use_rgb_colorspace: use RGB instead of luminance/chrominance colorspace.
+ * @bypass_chroma_mapping: disable chrominance mapping (only valid if
+ *                         use_rgb_colorspace = 0)
+ * @use_iref: use illumination reference instead of Y for tone mapping
+ *            and gain calculations.
+ */
+struct rkisp1_cif_isp_wdr_config {
+	struct rkisp1_cif_isp_wdr_tone_curve tone_curve;
+	struct rkisp1_cif_isp_wdr_iref_config iref_config;
+	__u16 rgb_offset;
+	__u16 luma_offset;
+	__u16 dmin_thresh;
+	__u8 dmin_strength;
+	__u8 use_rgb_colorspace;
+	__u8 bypass_chroma_mapping;
+	__u8 use_iref;
+};
+
 /*---------- PART2: Measurement Statistics ------------*/
 
 /**
@@ -1059,6 +1132,7 @@  struct rkisp1_stat_buffer {
  * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS: BLS in the compand block
  * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND: Companding expand curve
  * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS: Companding compress curve
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR: Wide dynamic range
  */
 enum rkisp1_ext_params_block_type {
 	RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS,
@@ -1081,11 +1155,15 @@  enum rkisp1_ext_params_block_type {
 	RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS,
 	RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND,
 	RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS,
+	RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR,
 };
 
 #define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE	(1U << 0)
 #define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE	(1U << 1)
 
+/* A bitmask of parameters blocks supported on the current hardware. */
+#define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS	(V4L2_CID_USER_RKISP1_BASE + 0x01)
+
 /**
  * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters block
  *					   header
@@ -1460,6 +1538,23 @@  struct rkisp1_ext_params_compand_curve_config {
 	struct rkisp1_cif_isp_compand_curve_config config;
 } __attribute__((aligned(8)));
 
+/**
+ * struct rkisp1_ext_params_wdr_config - RkISP1 extensible params
+ *                                       Wide dynamic range config
+ *
+ * RkISP1 extensible parameters WDR block.
+ * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR`
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ *	    :c:type:`rkisp1_ext_params_block_header`
+ * @config: WDR configuration, see
+ *	    :c:type:`rkisp1_cif_isp_wdr_config`
+ */
+struct rkisp1_ext_params_wdr_config {
+	struct rkisp1_ext_params_block_header header;
+	struct rkisp1_cif_isp_wdr_config config;
+} __attribute__((aligned(8)));
+
 /*
  * The rkisp1_ext_params_compand_curve_config structure is counted twice as it
  * is used for both the COMPAND_EXPAND and COMPAND_COMPRESS block types.
@@ -1484,7 +1579,8 @@  struct rkisp1_ext_params_compand_curve_config {
 	sizeof(struct rkisp1_ext_params_afc_config)			+\
 	sizeof(struct rkisp1_ext_params_compand_bls_config)		+\
 	sizeof(struct rkisp1_ext_params_compand_curve_config)		+\
-	sizeof(struct rkisp1_ext_params_compand_curve_config))
+	sizeof(struct rkisp1_ext_params_compand_curve_config)		+\
+	sizeof(struct rkisp1_ext_params_wdr_config))
 
 /**
  * enum rksip1_ext_param_buffer_version - RkISP1 extensible parameters version
@@ -1520,6 +1616,14 @@  enum rksip1_ext_param_buffer_version {
  * V4L2 control. If such control is not available, userspace should assume only
  * RKISP1_EXT_PARAM_BUFFER_V1 is supported by the driver.
  *
+ * The read-only V4L2 control ``RKISP1_CID_SUPPORTED_PARAMS_BLOCKS`` can be used
+ * to query the blocks supported by the device. It contains a bitmask where each
+ * bit represents the availability of the corresponding entry from the
+ * :c:type:`rkisp1_ext_params_block_type` enum. The current and default values
+ * of the control represents the blocks supported by the device instance, while
+ * the maximum value represents the blocks supported by the kernel driver,
+ * independently of the device instance.
+ *
  * For each ISP block that userspace wants to configure, a block-specific
  * structure is appended to the @data buffer, one after the other without gaps
  * in between nor overlaps. Userspace shall populate the @data_size field with
@@ -1528,7 +1632,7 @@  enum rksip1_ext_param_buffer_version {
  * The expected memory layout of the parameters buffer is::
  *
  *	+-------------------- struct rkisp1_ext_params_cfg -------------------+
- *	| version = RKISP_EXT_PARAMS_BUFFER_V1;                               |
+ *	| version = RKISP1_EXT_PARAM_BUFFER_V1;                               |
  *	| data_size = sizeof(struct rkisp1_ext_params_bls_config)             |
  *	|           + sizeof(struct rkisp1_ext_params_dpcc_config);           |
  *	| +------------------------- data  ---------------------------------+ |
diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
index 882a81805783..fc43bb09efe3 100644
--- a/include/linux/v4l2-controls.h
+++ b/include/linux/v4l2-controls.h
@@ -177,10 +177,6 @@  enum v4l2_colorfx {
  * We reserve 128 controls for this driver.
  */
 #define V4L2_CID_USER_CCS_BASE			(V4L2_CID_USER_BASE + 0x10f0)
-
-/* The base for the bcm2835-isp driver controls.
- * We reserve 16 controls for this driver. */
-#define V4L2_CID_USER_BCM2835_ISP_BASE		(V4L2_CID_USER_BASE + 0x10e0)
 /*
  * The base for Allegro driver controls.
  * We reserve 16 controls for this driver.
@@ -217,6 +213,19 @@  enum v4l2_colorfx {
  */
 #define V4L2_CID_USER_THP7312_BASE		(V4L2_CID_USER_BASE + 0x11c0)
 
+/*
+ * The base for the uvc driver controls.
+ * See linux/uvcvideo.h for the list of controls.
+ * We reserve 64 controls for this driver.
+ */
+#define V4L2_CID_USER_UVC_BASE			(V4L2_CID_USER_BASE + 0x11e0)
+
+/*
+ * The base for Rockchip ISP1 driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_RKISP1_BASE		(V4L2_CID_USER_BASE + 0x1220)
+
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls
  * and the 'MPEG' part of the define is historical */