[v5,3/5] ipa: Update Mali C55 header file and adjust IPA
diff mbox series

Message ID 20251007-v4l2-params-v5-3-8db451a81398@ideasonboard.com
State Superseded
Headers show
Series
  • ipa: libipa: Introduce V4L2Params
Related show

Commit Message

Jacopo Mondi Oct. 7, 2025, 6:17 p.m. UTC
Update Mali C55 header file with the v11 version of the patch series,
based on v4l2 extensible parameters, sent to the linux-media mailing list at:
https://lore.kernel.org/all/20250714-c55-v11-0-bc20e460e42a@ideasonboard.com/

Adjust the IPA module to use the new v4l2-isp.h header file.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Tested-by: Antoine Bouyer <antoine.bouyer@nxp.com>
---
 include/linux/mali-c55-config.h         | 161 +++++---------------------------
 src/ipa/mali-c55/algorithms/agc.cpp     |  28 +++---
 src/ipa/mali-c55/algorithms/agc.h       |   2 +-
 src/ipa/mali-c55/algorithms/algorithm.h |   2 +-
 src/ipa/mali-c55/algorithms/awb.cpp     |  14 +--
 src/ipa/mali-c55/algorithms/awb.h       |   2 +-
 src/ipa/mali-c55/algorithms/blc.cpp     |   8 +-
 src/ipa/mali-c55/algorithms/blc.h       |   2 +-
 src/ipa/mali-c55/algorithms/lsc.cpp     |  14 +--
 src/ipa/mali-c55/algorithms/lsc.h       |   2 +-
 src/ipa/mali-c55/mali-c55.cpp           |  11 ++-
 src/ipa/mali-c55/module.h               |   2 +-
 12 files changed, 67 insertions(+), 181 deletions(-)

Comments

Kieran Bingham Oct. 8, 2025, 10:22 a.m. UTC | #1
Quoting Jacopo Mondi (2025-10-07 19:17:45)
> Update Mali C55 header file with the v11 version of the patch series,
> based on v4l2 extensible parameters, sent to the linux-media mailing list at:
> https://lore.kernel.org/all/20250714-c55-v11-0-bc20e460e42a@ideasonboard.com/
> 
> Adjust the IPA module to use the new v4l2-isp.h header file.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Tested-by: Antoine Bouyer <antoine.bouyer@nxp.com>
> ---
>  include/linux/mali-c55-config.h         | 161 +++++---------------------------
>  src/ipa/mali-c55/algorithms/agc.cpp     |  28 +++---
>  src/ipa/mali-c55/algorithms/agc.h       |   2 +-
>  src/ipa/mali-c55/algorithms/algorithm.h |   2 +-
>  src/ipa/mali-c55/algorithms/awb.cpp     |  14 +--
>  src/ipa/mali-c55/algorithms/awb.h       |   2 +-
>  src/ipa/mali-c55/algorithms/blc.cpp     |   8 +-
>  src/ipa/mali-c55/algorithms/blc.h       |   2 +-
>  src/ipa/mali-c55/algorithms/lsc.cpp     |  14 +--
>  src/ipa/mali-c55/algorithms/lsc.h       |   2 +-
>  src/ipa/mali-c55/mali-c55.cpp           |  11 ++-
>  src/ipa/mali-c55/module.h               |   2 +-
>  12 files changed, 67 insertions(+), 181 deletions(-)
> 
> diff --git a/include/linux/mali-c55-config.h b/include/linux/mali-c55-config.h
> index b31415597e886496b65f8fb396c095618467f1ac..109082c5694f6b927dc5511043e3bfbc27a0b675 100644
> --- a/include/linux/mali-c55-config.h
> +++ b/include/linux/mali-c55-config.h
> @@ -9,6 +9,21 @@
>  #define __UAPI_MALI_C55_CONFIG_H
>  
>  #include <linux/types.h>
> +#include <linux/v4l2-controls.h>
> +#include <linux/media/v4l2-isp.h>
> +
> +#define V4L2_CID_MALI_C55_CAPABILITIES (V4L2_CID_USER_MALI_C55_BASE + 0x0)
> +#define MALI_C55_GPS_PONG              (1U << 0)
> +#define MALI_C55_GPS_WDR               (1U << 1)
> +#define MALI_C55_GPS_COMPRESSION       (1U << 2)
> +#define MALI_C55_GPS_TEMPER            (1U << 3)
> +#define MALI_C55_GPS_SINTER_LITE       (1U << 4)
> +#define MALI_C55_GPS_SINTER            (1U << 5)
> +#define MALI_C55_GPS_IRIDIX_LTM                (1U << 6)
> +#define MALI_C55_GPS_IRIDIX_GTM                (1U << 7)
> +#define MALI_C55_GPS_CNR               (1U << 8)
> +#define MALI_C55_GPS_FRSCALER          (1U << 9)
> +#define MALI_C55_GPS_DS_PIPE           (1U << 10)
>  
>  /*
>   * Frames are split into zones of almost equal width and height - a zone is a
> @@ -228,65 +243,6 @@ enum mali_c55_param_block_type {
>         MALI_C55_PARAM_MESH_SHADING_SELECTION,
>  };
>  
> -#define MALI_C55_PARAM_BLOCK_FL_NONE                   0
> -#define MALI_C55_PARAM_BLOCK_FL_DISABLED               BIT(0)
> -
> -/**
> - * struct mali_c55_params_block_header - Mali-C55 parameter block header
> - *
> - * This structure represents the common part of all the ISP configuration
> - * blocks. Each parameters block embeds an instance of this structure type
> - * as its first member, followed by the block-specific configuration data. The
> - * driver inspects this common header to discern the block type and its size and
> - * properly handle the block content by casting it to the correct block-specific
> - * type.
> - *
> - * The @type field is one of the values enumerated by
> - * :c:type:`mali_c55_param_block_type` and specifies how the data should be
> - * interpreted by the driver. The @size field specifies the size of the
> - * parameters block and is used by the driver for validation purposes. The
> - * @flags field holds a bitmask of per-block flags MALI_C55_PARAM_BLOCK_FL_*.
> - *
> - * If userspace wants to disable an ISP block the
> - * MALI_C55_PARAM_BLOCK_FL_DISABLED bit should be set in the @flags field. In
> - * that case userspace may optionally omit the remainder of the configuration
> - * block, which will in any case be ignored by the driver. If a new
> - * configuration of an ISP block has to be applied userspace shall fully
> - * populate the ISP block and omit setting the MALI_C55_PARAM_BLOCK_FL_DISABLED
> - * bit in the @flags field.
> - *
> - * Userspace is responsible for correctly populating the parameters block header
> - * fields (@type, @flags and @size) and correctly populate the block-specific
> - * parameters.
> - *
> - * For example:
> - *
> - * .. code-block:: c
> - *
> - *     void populate_sensor_offs(struct mali_c55_params_block_header *block) {
> - *             block->type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;
> - *             block->enabled = MALI_C55_PARAM_BLOCK_FL_NONE;
> - *             block->size = sizeof(struct mali_c55_params_sensor_off_preshading);
> - *
> - *             struct mali_c55_params_sensor_off_preshading *sensor_offs =
> - *                     (struct mali_c55_params_sensor_off_preshading *)block;
> - *
> - *             sensor_offs->chan00 = offset00;
> - *             sensor_offs->chan01 = offset01;
> - *             sensor_offs->chan10 = offset10;
> - *             sensor_offs->chan11 = offset11;
> - *     }
> - *
> - * @type: The parameters block type from :c:type:`mali_c55_param_block_type`
> - * @flags: Bitmask of block flags
> - * @size: Size (in bytes) of the parameters block
> - */
> -struct mali_c55_params_block_header {
> -       __u16 type;
> -       __u16 flags;
> -       __u32 size;
> -} __attribute__((aligned(8)));
> -
>  /**
>   * struct mali_c55_params_sensor_off_preshading - offset subtraction for each
>   *                                               color channel
> @@ -305,7 +261,7 @@ struct mali_c55_params_block_header {
>   * @chan11: Offset for color channel 11 (default: B)
>   */
>  struct mali_c55_params_sensor_off_preshading {
> -       struct mali_c55_params_block_header header;
> +       struct v4l2_isp_params_block_header header;
>         __u32 chan00;
>         __u32 chan01;
>         __u32 chan10;
> @@ -470,7 +426,7 @@ enum mali_c55_aexp_hist_plane_mode {
>   *                     This parameter is unused for the post-Iridix Histogram
>   */
>  struct mali_c55_params_aexp_hist {
> -       struct mali_c55_params_block_header header;
> +       struct v4l2_isp_params_block_header header;
>         __u8 skip_x;
>         __u8 offset_x;
>         __u8 skip_y;
> @@ -502,7 +458,7 @@ struct mali_c55_params_aexp_hist {
>   *                     @nodes_used_horiz
>   */
>  struct mali_c55_params_aexp_weights {
> -       struct mali_c55_params_block_header header;
> +       struct v4l2_isp_params_block_header header;
>         __u8 nodes_used_horiz;
>         __u8 nodes_used_vert;
>         __u8 zone_weights[MALI_C55_MAX_ZONES];
> @@ -520,7 +476,7 @@ struct mali_c55_params_aexp_weights {
>   * @gain:      The digital gain value to apply, in Q5.8 format.
>   */
>  struct mali_c55_params_digital_gain {
> -       struct mali_c55_params_block_header header;
> +       struct v4l2_isp_params_block_header header;
>         __u16 gain;
>  };
>  
> @@ -560,7 +516,7 @@ enum mali_c55_awb_stats_mode {
>   * @gain11:    Multiplier for colour channel 11
>   */
>  struct mali_c55_params_awb_gains {
> -       struct mali_c55_params_block_header header;
> +       struct v4l2_isp_params_block_header header;
>         __u16 gain00;
>         __u16 gain01;
>         __u16 gain10;
> @@ -635,7 +591,7 @@ enum mali_c55_params_awb_tap_points {
>   * @cb_low:            B/G ratio trim low (Q4.8 format)
>   */
>  struct mali_c55_params_awb_config {
> -       struct mali_c55_params_block_header header;
> +       struct v4l2_isp_params_block_header header;
>         __u8 tap_point;
>         __u8 stats_mode;
>         __u16 white_level;
> @@ -745,7 +701,7 @@ struct mali_c55_params_awb_config {
>   * @mesh:              Mesh shading correction tables
>   */
>  struct mali_c55_params_mesh_shading_config {
> -       struct mali_c55_params_block_header header;
> +       struct v4l2_isp_params_block_header header;
>         __u8 mesh_show;
>         __u8 mesh_scale;
>         __u8 mesh_page_r;
> @@ -800,7 +756,7 @@ enum mali_c55_params_mesh_alpha_bank {
>   * @mesh_strength:     Mesh strength in Q4.12 format [0..4096]
>   */
>  struct mali_c55_params_mesh_shading_selection {
> -       struct mali_c55_params_block_header header;
> +       struct v4l2_isp_params_block_header header;
>         __u8 mesh_alpha_bank_r;
>         __u8 mesh_alpha_bank_g;
>         __u8 mesh_alpha_bank_b;
> @@ -835,75 +791,4 @@ struct mali_c55_params_mesh_shading_selection {
>         sizeof(struct mali_c55_params_mesh_shading_config) +    \
>         sizeof(struct mali_c55_params_mesh_shading_selection))
>  
> -/**
> - * struct mali_c55_params_buffer - 3A configuration parameters
> - *
> - * This struct contains the configuration parameters of the Mali-C55 ISP
> - * algorithms, serialized by userspace into a data buffer. Each configuration
> - * parameter block is represented by a block-specific structure which contains a
> - * :c:type:`mali_c55_params_block_header` entry as first member. Userspace
> - * populates the @data buffer with configuration parameters for the blocks that
> - * it intends to configure. As a consequence, the data buffer effective size
> - * changes according to the number of ISP blocks that userspace intends to
> - * configure.
> - *
> - * The parameters buffer is versioned by the @version field to allow modifying
> - * and extending its definition. Userspace shall populate the @version field to
> - * inform the driver about the version it intends to use. The driver will parse
> - * and handle the @data buffer according to the data layout specific to the
> - * indicated version and return an error if the desired version is not
> - * supported.
> - *
> - * 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 @total_size field with
> - * the effective size, in bytes, of the @data buffer.
> - *
> - * The expected memory layout of the parameters buffer is::
> - *
> - *     +-------------------- struct mali_c55_params_buffer ------------------+
> - *     | version = MALI_C55_PARAM_BUFFER_V1;                                 |
> - *     | total_size = sizeof(struct mali_c55_params_sensor_off_preshading)   |
> - *     |              sizeof(struct mali_c55_params_aexp_hist);              |
> - *     | +------------------------- data  ---------------------------------+ |
> - *     | | +--------- struct mali_c55_params_sensor_off_preshading ------+ | |
> - *     | | | +-------- struct mali_c55_params_block_header header -----+ | | |
> - *     | | | | type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;                | | | |
> - *     | | | | flags = MALI_C55_PARAM_BLOCK_FL_NONE;                   | | | |
> - *     | | | | size =                                                  | | | |
> - *     | | | |    sizeof(struct mali_c55_params_sensor_off_preshading);| | | |
> - *     | | | +---------------------------------------------------------+ | | |
> - *     | | | chan00 = ...;                                               | | |
> - *     | | | chan01 = ...;                                               | | |
> - *     | | | chan10 = ...;                                               | | |
> - *     | | | chan11 = ...;                                               | | |
> - *     | | +------------ struct mali_c55_params_aexp_hist ---------------+ | |
> - *     | | | +-------- struct mali_c55_params_block_header header -----+ | | |
> - *     | | | | type = MALI_C55_PARAM_BLOCK_AEXP_HIST;                  | | | |
> - *     | | | | flags = MALI_C55_PARAM_BLOCK_FL_NONE;                   | | | |
> - *     | | | | size = sizeof(struct mali_c55_params_aexp_hist);        | | | |
> - *     | | | +---------------------------------------------------------+ | | |
> - *     | | | skip_x = ...;                                               | | |
> - *     | | | offset_x = ...;                                             | | |
> - *     | | | skip_y = ...;                                               | | |
> - *     | | | offset_y = ...;                                             | | |
> - *     | | | scale_bottom = ...;                                         | | |
> - *     | | | scale_top = ...;                                            | | |
> - *     | | | plane_mode = ...;                                           | | |
> - *     | | | tap_point = ...;                                            | | |
> - *     | | +-------------------------------------------------------------+ | |
> - *     | +-----------------------------------------------------------------+ |
> - *     +---------------------------------------------------------------------+
> - *
> - * @version: The version from :c:type:`mali_c55_param_buffer_version`
> - * @total_size: The Mali-C55 configuration data effective size, excluding this
> - *             header
> - * @data: The Mali-C55 configuration blocks data
> - */
> -struct mali_c55_params_buffer {
> -       __u8 version;
> -       __u32 total_size;
> -       __u8 data[MALI_C55_PARAMS_MAX_SIZE];
> -};
> -
>  #endif /* __UAPI_MALI_C55_CONFIG_H */

well all of that is kernel update so not really for review here - but it
looks great to be removing all the duplicated documentation/descriptions
- so I'm really excited to see your work here complete.

For the above going into libcamera which is only updating to track the
out of tree patches - so no 'regression'...

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

> diff --git a/src/ipa/mali-c55/algorithms/agc.cpp b/src/ipa/mali-c55/algorithms/agc.cpp
> index f60fddac3f04fd6f09dc782e929ff1593758c29b..78e7e07b2348a711e6261bac45e006f49a59513a 100644
> --- a/src/ipa/mali-c55/algorithms/agc.cpp
> +++ b/src/ipa/mali-c55/algorithms/agc.cpp
> @@ -253,7 +253,7 @@ size_t Agc::fillGainParamBlock(IPAContext &context, IPAFrameContext &frameContex
>                 gain = activeState.agc.manual.ispGain;
>  
>         block.header->type = MALI_C55_PARAM_BLOCK_DIGITAL_GAIN;
> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
> +       block.header->flags = 0;
>         block.header->size = sizeof(struct mali_c55_params_digital_gain);
>  
>         block.digital_gain->gain = floatingToFixedPoint<5, 8, uint16_t, double>(gain);
> @@ -266,7 +266,7 @@ size_t Agc::fillParamsBuffer(mali_c55_params_block block,
>                              enum mali_c55_param_block_type type)
>  {
>         block.header->type = type;
> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
> +       block.header->flags = 0;
>         block.header->size = sizeof(struct mali_c55_params_aexp_hist);
>  
>         /* Collect every 3rd pixel horizontally */
> @@ -292,7 +292,7 @@ size_t Agc::fillWeightsArrayBuffer(mali_c55_params_block block,
>                                    enum mali_c55_param_block_type type)
>  {
>         block.header->type = type;
> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
> +       block.header->flags = 0;
>         block.header->size = sizeof(struct mali_c55_params_aexp_weights);
>  
>         /* We use every zone - a 15x15 grid */
> @@ -314,30 +314,30 @@ size_t Agc::fillWeightsArrayBuffer(mali_c55_params_block block,
>  }
>  
>  void Agc::prepare(IPAContext &context, const uint32_t frame,
> -                 IPAFrameContext &frameContext, mali_c55_params_buffer *params)
> +                 IPAFrameContext &frameContext, v4l2_isp_params_buffer *params)
>  {
>         mali_c55_params_block block;
>  
> -       block.data = &params->data[params->total_size];
> -       params->total_size += fillGainParamBlock(context, frameContext, block);
> +       block.data = &params->data[params->data_size];
> +       params->data_size += fillGainParamBlock(context, frameContext, block);
>  
>         if (frame > 0)
>                 return;
>  
> -       block.data = &params->data[params->total_size];
> -       params->total_size += fillParamsBuffer(block,
> +       block.data = &params->data[params->data_size];
> +       params->data_size += fillParamsBuffer(block,
>                                                MALI_C55_PARAM_BLOCK_AEXP_HIST);
>  
> -       block.data = &params->data[params->total_size];
> -       params->total_size += fillWeightsArrayBuffer(block,
> +       block.data = &params->data[params->data_size];
> +       params->data_size += fillWeightsArrayBuffer(block,
>                                                      MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS);
>  
> -       block.data = &params->data[params->total_size];
> -       params->total_size += fillParamsBuffer(block,
> +       block.data = &params->data[params->data_size];
> +       params->data_size += fillParamsBuffer(block,
>                                                MALI_C55_PARAM_BLOCK_AEXP_IHIST);
>  
> -       block.data = &params->data[params->total_size];
> -       params->total_size += fillWeightsArrayBuffer(block,
> +       block.data = &params->data[params->data_size];
> +       params->data_size += fillWeightsArrayBuffer(block,
>                                                      MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS);
>  }
>  
> diff --git a/src/ipa/mali-c55/algorithms/agc.h b/src/ipa/mali-c55/algorithms/agc.h
> index 0b4bf7eda1c2a7c9894f6932452fea5f53699b30..4325ef5a9b7dcef36107b64a65db993f194d4167 100644
> --- a/src/ipa/mali-c55/algorithms/agc.h
> +++ b/src/ipa/mali-c55/algorithms/agc.h
> @@ -57,7 +57,7 @@ public:
>                           const ControlList &controls) override;
>         void prepare(IPAContext &context, const uint32_t frame,
>                      IPAFrameContext &frameContext,
> -                    mali_c55_params_buffer *params) override;
> +                    v4l2_isp_params_buffer *params) override;
>         void process(IPAContext &context, const uint32_t frame,
>                      IPAFrameContext &frameContext,
>                      const mali_c55_stats_buffer *stats,
> diff --git a/src/ipa/mali-c55/algorithms/algorithm.h b/src/ipa/mali-c55/algorithms/algorithm.h
> index ec8dd3973eaf2d804d8de8620840f716340e9cfd..e61115f6c2d6c911c15a1d877833d3f2b06a0db8 100644
> --- a/src/ipa/mali-c55/algorithms/algorithm.h
> +++ b/src/ipa/mali-c55/algorithms/algorithm.h
> @@ -22,7 +22,7 @@ class Algorithm : public libcamera::ipa::Algorithm<Module>
>  };
>  
>  union mali_c55_params_block {
> -       struct mali_c55_params_block_header *header;
> +       struct v4l2_isp_params_block_header *header;
>         struct mali_c55_params_sensor_off_preshading *sensor_offs;
>         struct mali_c55_params_aexp_hist *aexp_hist;
>         struct mali_c55_params_aexp_weights *aexp_weights;
> diff --git a/src/ipa/mali-c55/algorithms/awb.cpp b/src/ipa/mali-c55/algorithms/awb.cpp
> index 3d546e5a854b8aa02987c44f57109a6171e3794b..694c0aaa9c6804bb58e380ba9c744f11c39224fe 100644
> --- a/src/ipa/mali-c55/algorithms/awb.cpp
> +++ b/src/ipa/mali-c55/algorithms/awb.cpp
> @@ -47,7 +47,7 @@ size_t Awb::fillGainsParamBlock(mali_c55_params_block block, IPAContext &context
>                                 IPAFrameContext &frameContext)
>  {
>         block.header->type = MALI_C55_PARAM_BLOCK_AWB_GAINS;
> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
> +       block.header->flags = 0;
>         block.header->size = sizeof(struct mali_c55_params_awb_gains);
>  
>         double rGain = context.activeState.awb.rGain;
> @@ -77,7 +77,7 @@ size_t Awb::fillGainsParamBlock(mali_c55_params_block block, IPAContext &context
>  size_t Awb::fillConfigParamBlock(mali_c55_params_block block)
>  {
>         block.header->type = MALI_C55_PARAM_BLOCK_AWB_CONFIG;
> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
> +       block.header->flags = 0;
>         block.header->size = sizeof(struct mali_c55_params_awb_config);
>  
>         /* Tap the stats after the purple fringe block */
> @@ -126,18 +126,18 @@ size_t Awb::fillConfigParamBlock(mali_c55_params_block block)
>  }
>  
>  void Awb::prepare(IPAContext &context, const uint32_t frame,
> -                 IPAFrameContext &frameContext, mali_c55_params_buffer *params)
> +                 IPAFrameContext &frameContext, v4l2_isp_params_buffer *params)
>  {
>         mali_c55_params_block block;
> -       block.data = &params->data[params->total_size];
> +       block.data = &params->data[params->data_size];
>  
> -       params->total_size += fillGainsParamBlock(block, context, frameContext);
> +       params->data_size += fillGainsParamBlock(block, context, frameContext);
>  
>         if (frame > 0)
>                 return;
>  
> -       block.data = &params->data[params->total_size];
> -       params->total_size += fillConfigParamBlock(block);
> +       block.data = &params->data[params->data_size];
> +       params->data_size += fillConfigParamBlock(block);
>  }
>  
>  void Awb::process(IPAContext &context, const uint32_t frame,
> diff --git a/src/ipa/mali-c55/algorithms/awb.h b/src/ipa/mali-c55/algorithms/awb.h
> index 2351d405553058dbff569e9e09e265a56baaa23f..647525ff700e8281e3cce63e64ba56a91294bcc2 100644
> --- a/src/ipa/mali-c55/algorithms/awb.h
> +++ b/src/ipa/mali-c55/algorithms/awb.h
> @@ -22,7 +22,7 @@ public:
>                       const IPACameraSensorInfo &configInfo) override;
>         void prepare(IPAContext &context, const uint32_t frame,
>                      IPAFrameContext &frameContext,
> -                    mali_c55_params_buffer *params) override;
> +                    v4l2_isp_params_buffer *params) override;
>         void process(IPAContext &context, const uint32_t frame,
>                      IPAFrameContext &frameContext,
>                      const mali_c55_stats_buffer *stats,
> diff --git a/src/ipa/mali-c55/algorithms/blc.cpp b/src/ipa/mali-c55/algorithms/blc.cpp
> index 2a54c86a91f83d24183cb7236fcd5181302eb622..543ba96cb57ac0cca2b8f822180d8d8b42f21fc7 100644
> --- a/src/ipa/mali-c55/algorithms/blc.cpp
> +++ b/src/ipa/mali-c55/algorithms/blc.cpp
> @@ -85,10 +85,10 @@ int BlackLevelCorrection::configure(IPAContext &context,
>  void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
>                                    const uint32_t frame,
>                                    [[maybe_unused]] IPAFrameContext &frameContext,
> -                                  mali_c55_params_buffer *params)
> +                                  v4l2_isp_params_buffer *params)
>  {
>         mali_c55_params_block block;
> -       block.data = &params->data[params->total_size];
> +       block.data = &params->data[params->data_size];
>  
>         if (frame > 0)
>                 return;
> @@ -97,7 +97,7 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
>                 return;
>  
>         block.header->type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;
> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
> +       block.header->flags = 0;
>         block.header->size = sizeof(mali_c55_params_sensor_off_preshading);
>  
>         block.sensor_offs->chan00 = offset00;
> @@ -105,7 +105,7 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
>         block.sensor_offs->chan10 = offset10;
>         block.sensor_offs->chan11 = offset11;
>  
> -       params->total_size += block.header->size;
> +       params->data_size += block.header->size;
>  }
>  
>  void BlackLevelCorrection::process([[maybe_unused]] IPAContext &context,
> diff --git a/src/ipa/mali-c55/algorithms/blc.h b/src/ipa/mali-c55/algorithms/blc.h
> index 9696e8e9f2aa8b9076a3a41fb8f5ea356e32be12..ee6c889ed89ac2230b231cb58a9fe4412c0ce164 100644
> --- a/src/ipa/mali-c55/algorithms/blc.h
> +++ b/src/ipa/mali-c55/algorithms/blc.h
> @@ -22,7 +22,7 @@ public:
>                       const IPACameraSensorInfo &configInfo) override;
>         void prepare(IPAContext &context, const uint32_t frame,
>                      IPAFrameContext &frameContext,
> -                    mali_c55_params_buffer *params) override;
> +                    v4l2_isp_params_buffer *params) override;
>         void process(IPAContext &context, const uint32_t frame,
>                      IPAFrameContext &frameContext,
>                      const mali_c55_stats_buffer *stats,
> diff --git a/src/ipa/mali-c55/algorithms/lsc.cpp b/src/ipa/mali-c55/algorithms/lsc.cpp
> index c43d034a181edb7559706189f8d75edd67a2dc08..cb915c5efd3c22952035f2b03ee659f293942ec9 100644
> --- a/src/ipa/mali-c55/algorithms/lsc.cpp
> +++ b/src/ipa/mali-c55/algorithms/lsc.cpp
> @@ -111,7 +111,7 @@ int Lsc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData
>  size_t Lsc::fillConfigParamsBlock(mali_c55_params_block block) const
>  {
>         block.header->type = MALI_C55_PARAM_MESH_SHADING_CONFIG;
> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
> +       block.header->flags = 0;
>         block.header->size = sizeof(struct mali_c55_params_mesh_shading_config);
>  
>         block.shading_config->mesh_show = false;
> @@ -131,7 +131,7 @@ size_t Lsc::fillSelectionParamsBlock(mali_c55_params_block block, uint8_t bank,
>                                      uint8_t alpha) const
>  {
>         block.header->type = MALI_C55_PARAM_MESH_SHADING_SELECTION;
> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
> +       block.header->flags = 0;
>         block.header->size = sizeof(struct mali_c55_params_mesh_shading_selection);
>  
>         block.shading_selection->mesh_alpha_bank_r = bank;
> @@ -170,7 +170,7 @@ std::tuple<uint8_t, uint8_t> Lsc::findBankAndAlpha(uint32_t ct) const
>  
>  void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>                   [[maybe_unused]] IPAFrameContext &frameContext,
> -                 mali_c55_params_buffer *params)
> +                 v4l2_isp_params_buffer *params)
>  {
>         /*
>          * For each frame we assess the colour temperature of the **last** frame
> @@ -194,9 +194,9 @@ void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>         }
>  
>         mali_c55_params_block block;
> -       block.data = &params->data[params->total_size];
> +       block.data = &params->data[params->data_size];
>  
> -       params->total_size += fillSelectionParamsBlock(block, bank, alpha);
> +       params->data_size += fillSelectionParamsBlock(block, bank, alpha);
>  
>         if (frame > 0)
>                 return;
> @@ -205,8 +205,8 @@ void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>          * If this is the first frame, we need to load the parsed coefficient
>          * tables from tuning data to the ISP.
>          */
> -       block.data = &params->data[params->total_size];
> -       params->total_size += fillConfigParamsBlock(block);
> +       block.data = &params->data[params->data_size];
> +       params->data_size += fillConfigParamsBlock(block);
>  }
>  
>  REGISTER_IPA_ALGORITHM(Lsc, "Lsc")
> diff --git a/src/ipa/mali-c55/algorithms/lsc.h b/src/ipa/mali-c55/algorithms/lsc.h
> index d11e23bc7c34fa3e1f45ccf015b50f3d390d7159..c287900502528ca82ab6c62d732b6ffc28ad8df6 100644
> --- a/src/ipa/mali-c55/algorithms/lsc.h
> +++ b/src/ipa/mali-c55/algorithms/lsc.h
> @@ -23,7 +23,7 @@ public:
>         int init(IPAContext &context, const YamlObject &tuningData) override;
>         void prepare(IPAContext &context, const uint32_t frame,
>                      IPAFrameContext &frameContext,
> -                    mali_c55_params_buffer *params) override;
> +                    v4l2_isp_params_buffer *params) override;
>  private:
>         static constexpr unsigned int kRedOffset = 0;
>         static constexpr unsigned int kGreenOffset = 1024;
> diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp
> index 7d45e7310aecdae0e47655e6d2e8830e776d74cd..504d95222074a35b033949a25178f998738e5699 100644
> --- a/src/ipa/mali-c55/mali-c55.cpp
> +++ b/src/ipa/mali-c55/mali-c55.cpp
> @@ -331,22 +331,23 @@ void IPAMaliC55::queueRequest(const uint32_t request, const ControlList &control
>  void IPAMaliC55::fillParams(unsigned int request,
>                             [[maybe_unused]] uint32_t bufferId)
>  {
> -       struct mali_c55_params_buffer *params;
> +       struct v4l2_isp_params_buffer *params;
>         IPAFrameContext &frameContext = context_.frameContexts.get(request);
>  
> -       params = reinterpret_cast<mali_c55_params_buffer *>(
> +       params = reinterpret_cast<v4l2_isp_params_buffer *>(
>                 buffers_.at(bufferId).planes()[0].data());
> -       memset(params, 0, sizeof(mali_c55_params_buffer));
> +       memset(params, 0,
> +              buffers_.at(bufferId).planes()[0].size());
>  
>         params->version = MALI_C55_PARAM_BUFFER_V1;
>  
>         for (auto const &algo : algorithms()) {
>                 algo->prepare(context_, request, frameContext, params);
>  
> -               ASSERT(params->total_size <= MALI_C55_PARAMS_MAX_SIZE);
> +               ASSERT(params->data_size <= MALI_C55_PARAMS_MAX_SIZE);
>         }
>  
> -       size_t bytesused = offsetof(struct mali_c55_params_buffer, data) + params->total_size;
> +       size_t bytesused = offsetof(struct v4l2_isp_params_buffer, data) + params->data_size;
>         paramsComputed.emit(request, bytesused);
>  }
>  
> diff --git a/src/ipa/mali-c55/module.h b/src/ipa/mali-c55/module.h
> index 4f6a4f18bfaf83263ccb5b7eb1723da9b655cc3c..a8dcb20841a4ebd7bde22cae4ff1f8eef530d8bb 100644
> --- a/src/ipa/mali-c55/module.h
> +++ b/src/ipa/mali-c55/module.h
> @@ -20,7 +20,7 @@ namespace libcamera {
>  namespace ipa::mali_c55 {
>  
>  using Module = ipa::Module<IPAContext, IPAFrameContext, IPACameraSensorInfo,
> -                          mali_c55_params_buffer, mali_c55_stats_buffer>;
> +                          v4l2_isp_params_buffer, mali_c55_stats_buffer>;

And the above looks consistent so :

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

>  
>  } /* namespace ipa::mali_c55 */
>  
> 
> -- 
> 2.51.0
>
Dan Scally Oct. 8, 2025, 3:14 p.m. UTC | #2
Hi Jacopo

On 08/10/2025 11:22, Kieran Bingham wrote:
> Quoting Jacopo Mondi (2025-10-07 19:17:45)
>> Update Mali C55 header file with the v11 version of the patch series,
>> based on v4l2 extensible parameters, sent to the linux-media mailing list at:
>> https://lore.kernel.org/all/20250714-c55-v11-0-bc20e460e42a@ideasonboard.com/
>>
>> Adjust the IPA module to use the new v4l2-isp.h header file.
>>
>> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>> Tested-by: Antoine Bouyer <antoine.bouyer@nxp.com>

Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>>> ---
>>   include/linux/mali-c55-config.h         | 161 +++++---------------------------
>>   src/ipa/mali-c55/algorithms/agc.cpp     |  28 +++---
>>   src/ipa/mali-c55/algorithms/agc.h       |   2 +-
>>   src/ipa/mali-c55/algorithms/algorithm.h |   2 +-
>>   src/ipa/mali-c55/algorithms/awb.cpp     |  14 +--
>>   src/ipa/mali-c55/algorithms/awb.h       |   2 +-
>>   src/ipa/mali-c55/algorithms/blc.cpp     |   8 +-
>>   src/ipa/mali-c55/algorithms/blc.h       |   2 +-
>>   src/ipa/mali-c55/algorithms/lsc.cpp     |  14 +--
>>   src/ipa/mali-c55/algorithms/lsc.h       |   2 +-
>>   src/ipa/mali-c55/mali-c55.cpp           |  11 ++-
>>   src/ipa/mali-c55/module.h               |   2 +-
>>   12 files changed, 67 insertions(+), 181 deletions(-)
>>
>> diff --git a/include/linux/mali-c55-config.h b/include/linux/mali-c55-config.h
>> index b31415597e886496b65f8fb396c095618467f1ac..109082c5694f6b927dc5511043e3bfbc27a0b675 100644
>> --- a/include/linux/mali-c55-config.h
>> +++ b/include/linux/mali-c55-config.h
>> @@ -9,6 +9,21 @@
>>   #define __UAPI_MALI_C55_CONFIG_H
>>   
>>   #include <linux/types.h>
>> +#include <linux/v4l2-controls.h>
>> +#include <linux/media/v4l2-isp.h>
>> +
>> +#define V4L2_CID_MALI_C55_CAPABILITIES (V4L2_CID_USER_MALI_C55_BASE + 0x0)
>> +#define MALI_C55_GPS_PONG              (1U << 0)
>> +#define MALI_C55_GPS_WDR               (1U << 1)
>> +#define MALI_C55_GPS_COMPRESSION       (1U << 2)
>> +#define MALI_C55_GPS_TEMPER            (1U << 3)
>> +#define MALI_C55_GPS_SINTER_LITE       (1U << 4)
>> +#define MALI_C55_GPS_SINTER            (1U << 5)
>> +#define MALI_C55_GPS_IRIDIX_LTM                (1U << 6)
>> +#define MALI_C55_GPS_IRIDIX_GTM                (1U << 7)
>> +#define MALI_C55_GPS_CNR               (1U << 8)
>> +#define MALI_C55_GPS_FRSCALER          (1U << 9)
>> +#define MALI_C55_GPS_DS_PIPE           (1U << 10)
>>   
>>   /*
>>    * Frames are split into zones of almost equal width and height - a zone is a
>> @@ -228,65 +243,6 @@ enum mali_c55_param_block_type {
>>          MALI_C55_PARAM_MESH_SHADING_SELECTION,
>>   };
>>   
>> -#define MALI_C55_PARAM_BLOCK_FL_NONE                   0
>> -#define MALI_C55_PARAM_BLOCK_FL_DISABLED               BIT(0)
>> -
>> -/**
>> - * struct mali_c55_params_block_header - Mali-C55 parameter block header
>> - *
>> - * This structure represents the common part of all the ISP configuration
>> - * blocks. Each parameters block embeds an instance of this structure type
>> - * as its first member, followed by the block-specific configuration data. The
>> - * driver inspects this common header to discern the block type and its size and
>> - * properly handle the block content by casting it to the correct block-specific
>> - * type.
>> - *
>> - * The @type field is one of the values enumerated by
>> - * :c:type:`mali_c55_param_block_type` and specifies how the data should be
>> - * interpreted by the driver. The @size field specifies the size of the
>> - * parameters block and is used by the driver for validation purposes. The
>> - * @flags field holds a bitmask of per-block flags MALI_C55_PARAM_BLOCK_FL_*.
>> - *
>> - * If userspace wants to disable an ISP block the
>> - * MALI_C55_PARAM_BLOCK_FL_DISABLED bit should be set in the @flags field. In
>> - * that case userspace may optionally omit the remainder of the configuration
>> - * block, which will in any case be ignored by the driver. If a new
>> - * configuration of an ISP block has to be applied userspace shall fully
>> - * populate the ISP block and omit setting the MALI_C55_PARAM_BLOCK_FL_DISABLED
>> - * bit in the @flags field.
>> - *
>> - * Userspace is responsible for correctly populating the parameters block header
>> - * fields (@type, @flags and @size) and correctly populate the block-specific
>> - * parameters.
>> - *
>> - * For example:
>> - *
>> - * .. code-block:: c
>> - *
>> - *     void populate_sensor_offs(struct mali_c55_params_block_header *block) {
>> - *             block->type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;
>> - *             block->enabled = MALI_C55_PARAM_BLOCK_FL_NONE;
>> - *             block->size = sizeof(struct mali_c55_params_sensor_off_preshading);
>> - *
>> - *             struct mali_c55_params_sensor_off_preshading *sensor_offs =
>> - *                     (struct mali_c55_params_sensor_off_preshading *)block;
>> - *
>> - *             sensor_offs->chan00 = offset00;
>> - *             sensor_offs->chan01 = offset01;
>> - *             sensor_offs->chan10 = offset10;
>> - *             sensor_offs->chan11 = offset11;
>> - *     }
>> - *
>> - * @type: The parameters block type from :c:type:`mali_c55_param_block_type`
>> - * @flags: Bitmask of block flags
>> - * @size: Size (in bytes) of the parameters block
>> - */
>> -struct mali_c55_params_block_header {
>> -       __u16 type;
>> -       __u16 flags;
>> -       __u32 size;
>> -} __attribute__((aligned(8)));
>> -
>>   /**
>>    * struct mali_c55_params_sensor_off_preshading - offset subtraction for each
>>    *                                               color channel
>> @@ -305,7 +261,7 @@ struct mali_c55_params_block_header {
>>    * @chan11: Offset for color channel 11 (default: B)
>>    */
>>   struct mali_c55_params_sensor_off_preshading {
>> -       struct mali_c55_params_block_header header;
>> +       struct v4l2_isp_params_block_header header;
>>          __u32 chan00;
>>          __u32 chan01;
>>          __u32 chan10;
>> @@ -470,7 +426,7 @@ enum mali_c55_aexp_hist_plane_mode {
>>    *                     This parameter is unused for the post-Iridix Histogram
>>    */
>>   struct mali_c55_params_aexp_hist {
>> -       struct mali_c55_params_block_header header;
>> +       struct v4l2_isp_params_block_header header;
>>          __u8 skip_x;
>>          __u8 offset_x;
>>          __u8 skip_y;
>> @@ -502,7 +458,7 @@ struct mali_c55_params_aexp_hist {
>>    *                     @nodes_used_horiz
>>    */
>>   struct mali_c55_params_aexp_weights {
>> -       struct mali_c55_params_block_header header;
>> +       struct v4l2_isp_params_block_header header;
>>          __u8 nodes_used_horiz;
>>          __u8 nodes_used_vert;
>>          __u8 zone_weights[MALI_C55_MAX_ZONES];
>> @@ -520,7 +476,7 @@ struct mali_c55_params_aexp_weights {
>>    * @gain:      The digital gain value to apply, in Q5.8 format.
>>    */
>>   struct mali_c55_params_digital_gain {
>> -       struct mali_c55_params_block_header header;
>> +       struct v4l2_isp_params_block_header header;
>>          __u16 gain;
>>   };
>>   
>> @@ -560,7 +516,7 @@ enum mali_c55_awb_stats_mode {
>>    * @gain11:    Multiplier for colour channel 11
>>    */
>>   struct mali_c55_params_awb_gains {
>> -       struct mali_c55_params_block_header header;
>> +       struct v4l2_isp_params_block_header header;
>>          __u16 gain00;
>>          __u16 gain01;
>>          __u16 gain10;
>> @@ -635,7 +591,7 @@ enum mali_c55_params_awb_tap_points {
>>    * @cb_low:            B/G ratio trim low (Q4.8 format)
>>    */
>>   struct mali_c55_params_awb_config {
>> -       struct mali_c55_params_block_header header;
>> +       struct v4l2_isp_params_block_header header;
>>          __u8 tap_point;
>>          __u8 stats_mode;
>>          __u16 white_level;
>> @@ -745,7 +701,7 @@ struct mali_c55_params_awb_config {
>>    * @mesh:              Mesh shading correction tables
>>    */
>>   struct mali_c55_params_mesh_shading_config {
>> -       struct mali_c55_params_block_header header;
>> +       struct v4l2_isp_params_block_header header;
>>          __u8 mesh_show;
>>          __u8 mesh_scale;
>>          __u8 mesh_page_r;
>> @@ -800,7 +756,7 @@ enum mali_c55_params_mesh_alpha_bank {
>>    * @mesh_strength:     Mesh strength in Q4.12 format [0..4096]
>>    */
>>   struct mali_c55_params_mesh_shading_selection {
>> -       struct mali_c55_params_block_header header;
>> +       struct v4l2_isp_params_block_header header;
>>          __u8 mesh_alpha_bank_r;
>>          __u8 mesh_alpha_bank_g;
>>          __u8 mesh_alpha_bank_b;
>> @@ -835,75 +791,4 @@ struct mali_c55_params_mesh_shading_selection {
>>          sizeof(struct mali_c55_params_mesh_shading_config) +    \
>>          sizeof(struct mali_c55_params_mesh_shading_selection))
>>   
>> -/**
>> - * struct mali_c55_params_buffer - 3A configuration parameters
>> - *
>> - * This struct contains the configuration parameters of the Mali-C55 ISP
>> - * algorithms, serialized by userspace into a data buffer. Each configuration
>> - * parameter block is represented by a block-specific structure which contains a
>> - * :c:type:`mali_c55_params_block_header` entry as first member. Userspace
>> - * populates the @data buffer with configuration parameters for the blocks that
>> - * it intends to configure. As a consequence, the data buffer effective size
>> - * changes according to the number of ISP blocks that userspace intends to
>> - * configure.
>> - *
>> - * The parameters buffer is versioned by the @version field to allow modifying
>> - * and extending its definition. Userspace shall populate the @version field to
>> - * inform the driver about the version it intends to use. The driver will parse
>> - * and handle the @data buffer according to the data layout specific to the
>> - * indicated version and return an error if the desired version is not
>> - * supported.
>> - *
>> - * 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 @total_size field with
>> - * the effective size, in bytes, of the @data buffer.
>> - *
>> - * The expected memory layout of the parameters buffer is::
>> - *
>> - *     +-------------------- struct mali_c55_params_buffer ------------------+
>> - *     | version = MALI_C55_PARAM_BUFFER_V1;                                 |
>> - *     | total_size = sizeof(struct mali_c55_params_sensor_off_preshading)   |
>> - *     |              sizeof(struct mali_c55_params_aexp_hist);              |
>> - *     | +------------------------- data  ---------------------------------+ |
>> - *     | | +--------- struct mali_c55_params_sensor_off_preshading ------+ | |
>> - *     | | | +-------- struct mali_c55_params_block_header header -----+ | | |
>> - *     | | | | type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;                | | | |
>> - *     | | | | flags = MALI_C55_PARAM_BLOCK_FL_NONE;                   | | | |
>> - *     | | | | size =                                                  | | | |
>> - *     | | | |    sizeof(struct mali_c55_params_sensor_off_preshading);| | | |
>> - *     | | | +---------------------------------------------------------+ | | |
>> - *     | | | chan00 = ...;                                               | | |
>> - *     | | | chan01 = ...;                                               | | |
>> - *     | | | chan10 = ...;                                               | | |
>> - *     | | | chan11 = ...;                                               | | |
>> - *     | | +------------ struct mali_c55_params_aexp_hist ---------------+ | |
>> - *     | | | +-------- struct mali_c55_params_block_header header -----+ | | |
>> - *     | | | | type = MALI_C55_PARAM_BLOCK_AEXP_HIST;                  | | | |
>> - *     | | | | flags = MALI_C55_PARAM_BLOCK_FL_NONE;                   | | | |
>> - *     | | | | size = sizeof(struct mali_c55_params_aexp_hist);        | | | |
>> - *     | | | +---------------------------------------------------------+ | | |
>> - *     | | | skip_x = ...;                                               | | |
>> - *     | | | offset_x = ...;                                             | | |
>> - *     | | | skip_y = ...;                                               | | |
>> - *     | | | offset_y = ...;                                             | | |
>> - *     | | | scale_bottom = ...;                                         | | |
>> - *     | | | scale_top = ...;                                            | | |
>> - *     | | | plane_mode = ...;                                           | | |
>> - *     | | | tap_point = ...;                                            | | |
>> - *     | | +-------------------------------------------------------------+ | |
>> - *     | +-----------------------------------------------------------------+ |
>> - *     +---------------------------------------------------------------------+
>> - *
>> - * @version: The version from :c:type:`mali_c55_param_buffer_version`
>> - * @total_size: The Mali-C55 configuration data effective size, excluding this
>> - *             header
>> - * @data: The Mali-C55 configuration blocks data
>> - */
>> -struct mali_c55_params_buffer {
>> -       __u8 version;
>> -       __u32 total_size;
>> -       __u8 data[MALI_C55_PARAMS_MAX_SIZE];
>> -};
>> -
>>   #endif /* __UAPI_MALI_C55_CONFIG_H */
> 
> well all of that is kernel update so not really for review here - but it
> looks great to be removing all the duplicated documentation/descriptions
> - so I'm really excited to see your work here complete.
> 
> For the above going into libcamera which is only updating to track the
> out of tree patches - so no 'regression'...
> 
> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
>> diff --git a/src/ipa/mali-c55/algorithms/agc.cpp b/src/ipa/mali-c55/algorithms/agc.cpp
>> index f60fddac3f04fd6f09dc782e929ff1593758c29b..78e7e07b2348a711e6261bac45e006f49a59513a 100644
>> --- a/src/ipa/mali-c55/algorithms/agc.cpp
>> +++ b/src/ipa/mali-c55/algorithms/agc.cpp
>> @@ -253,7 +253,7 @@ size_t Agc::fillGainParamBlock(IPAContext &context, IPAFrameContext &frameContex
>>                  gain = activeState.agc.manual.ispGain;
>>   
>>          block.header->type = MALI_C55_PARAM_BLOCK_DIGITAL_GAIN;
>> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
>> +       block.header->flags = 0;
>>          block.header->size = sizeof(struct mali_c55_params_digital_gain);
>>   
>>          block.digital_gain->gain = floatingToFixedPoint<5, 8, uint16_t, double>(gain);
>> @@ -266,7 +266,7 @@ size_t Agc::fillParamsBuffer(mali_c55_params_block block,
>>                               enum mali_c55_param_block_type type)
>>   {
>>          block.header->type = type;
>> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
>> +       block.header->flags = 0;
>>          block.header->size = sizeof(struct mali_c55_params_aexp_hist);
>>   
>>          /* Collect every 3rd pixel horizontally */
>> @@ -292,7 +292,7 @@ size_t Agc::fillWeightsArrayBuffer(mali_c55_params_block block,
>>                                     enum mali_c55_param_block_type type)
>>   {
>>          block.header->type = type;
>> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
>> +       block.header->flags = 0;
>>          block.header->size = sizeof(struct mali_c55_params_aexp_weights);
>>   
>>          /* We use every zone - a 15x15 grid */
>> @@ -314,30 +314,30 @@ size_t Agc::fillWeightsArrayBuffer(mali_c55_params_block block,
>>   }
>>   
>>   void Agc::prepare(IPAContext &context, const uint32_t frame,
>> -                 IPAFrameContext &frameContext, mali_c55_params_buffer *params)
>> +                 IPAFrameContext &frameContext, v4l2_isp_params_buffer *params)
>>   {
>>          mali_c55_params_block block;
>>   
>> -       block.data = &params->data[params->total_size];
>> -       params->total_size += fillGainParamBlock(context, frameContext, block);
>> +       block.data = &params->data[params->data_size];
>> +       params->data_size += fillGainParamBlock(context, frameContext, block);
>>   
>>          if (frame > 0)
>>                  return;
>>   
>> -       block.data = &params->data[params->total_size];
>> -       params->total_size += fillParamsBuffer(block,
>> +       block.data = &params->data[params->data_size];
>> +       params->data_size += fillParamsBuffer(block,
>>                                                 MALI_C55_PARAM_BLOCK_AEXP_HIST);
>>   
>> -       block.data = &params->data[params->total_size];
>> -       params->total_size += fillWeightsArrayBuffer(block,
>> +       block.data = &params->data[params->data_size];
>> +       params->data_size += fillWeightsArrayBuffer(block,
>>                                                       MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS);
>>   
>> -       block.data = &params->data[params->total_size];
>> -       params->total_size += fillParamsBuffer(block,
>> +       block.data = &params->data[params->data_size];
>> +       params->data_size += fillParamsBuffer(block,
>>                                                 MALI_C55_PARAM_BLOCK_AEXP_IHIST);
>>   
>> -       block.data = &params->data[params->total_size];
>> -       params->total_size += fillWeightsArrayBuffer(block,
>> +       block.data = &params->data[params->data_size];
>> +       params->data_size += fillWeightsArrayBuffer(block,
>>                                                       MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS);
>>   }
>>   
>> diff --git a/src/ipa/mali-c55/algorithms/agc.h b/src/ipa/mali-c55/algorithms/agc.h
>> index 0b4bf7eda1c2a7c9894f6932452fea5f53699b30..4325ef5a9b7dcef36107b64a65db993f194d4167 100644
>> --- a/src/ipa/mali-c55/algorithms/agc.h
>> +++ b/src/ipa/mali-c55/algorithms/agc.h
>> @@ -57,7 +57,7 @@ public:
>>                            const ControlList &controls) override;
>>          void prepare(IPAContext &context, const uint32_t frame,
>>                       IPAFrameContext &frameContext,
>> -                    mali_c55_params_buffer *params) override;
>> +                    v4l2_isp_params_buffer *params) override;
>>          void process(IPAContext &context, const uint32_t frame,
>>                       IPAFrameContext &frameContext,
>>                       const mali_c55_stats_buffer *stats,
>> diff --git a/src/ipa/mali-c55/algorithms/algorithm.h b/src/ipa/mali-c55/algorithms/algorithm.h
>> index ec8dd3973eaf2d804d8de8620840f716340e9cfd..e61115f6c2d6c911c15a1d877833d3f2b06a0db8 100644
>> --- a/src/ipa/mali-c55/algorithms/algorithm.h
>> +++ b/src/ipa/mali-c55/algorithms/algorithm.h
>> @@ -22,7 +22,7 @@ class Algorithm : public libcamera::ipa::Algorithm<Module>
>>   };
>>   
>>   union mali_c55_params_block {
>> -       struct mali_c55_params_block_header *header;
>> +       struct v4l2_isp_params_block_header *header;
>>          struct mali_c55_params_sensor_off_preshading *sensor_offs;
>>          struct mali_c55_params_aexp_hist *aexp_hist;
>>          struct mali_c55_params_aexp_weights *aexp_weights;
>> diff --git a/src/ipa/mali-c55/algorithms/awb.cpp b/src/ipa/mali-c55/algorithms/awb.cpp
>> index 3d546e5a854b8aa02987c44f57109a6171e3794b..694c0aaa9c6804bb58e380ba9c744f11c39224fe 100644
>> --- a/src/ipa/mali-c55/algorithms/awb.cpp
>> +++ b/src/ipa/mali-c55/algorithms/awb.cpp
>> @@ -47,7 +47,7 @@ size_t Awb::fillGainsParamBlock(mali_c55_params_block block, IPAContext &context
>>                                  IPAFrameContext &frameContext)
>>   {
>>          block.header->type = MALI_C55_PARAM_BLOCK_AWB_GAINS;
>> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
>> +       block.header->flags = 0;
>>          block.header->size = sizeof(struct mali_c55_params_awb_gains);
>>   
>>          double rGain = context.activeState.awb.rGain;
>> @@ -77,7 +77,7 @@ size_t Awb::fillGainsParamBlock(mali_c55_params_block block, IPAContext &context
>>   size_t Awb::fillConfigParamBlock(mali_c55_params_block block)
>>   {
>>          block.header->type = MALI_C55_PARAM_BLOCK_AWB_CONFIG;
>> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
>> +       block.header->flags = 0;
>>          block.header->size = sizeof(struct mali_c55_params_awb_config);
>>   
>>          /* Tap the stats after the purple fringe block */
>> @@ -126,18 +126,18 @@ size_t Awb::fillConfigParamBlock(mali_c55_params_block block)
>>   }
>>   
>>   void Awb::prepare(IPAContext &context, const uint32_t frame,
>> -                 IPAFrameContext &frameContext, mali_c55_params_buffer *params)
>> +                 IPAFrameContext &frameContext, v4l2_isp_params_buffer *params)
>>   {
>>          mali_c55_params_block block;
>> -       block.data = &params->data[params->total_size];
>> +       block.data = &params->data[params->data_size];
>>   
>> -       params->total_size += fillGainsParamBlock(block, context, frameContext);
>> +       params->data_size += fillGainsParamBlock(block, context, frameContext);
>>   
>>          if (frame > 0)
>>                  return;
>>   
>> -       block.data = &params->data[params->total_size];
>> -       params->total_size += fillConfigParamBlock(block);
>> +       block.data = &params->data[params->data_size];
>> +       params->data_size += fillConfigParamBlock(block);
>>   }
>>   
>>   void Awb::process(IPAContext &context, const uint32_t frame,
>> diff --git a/src/ipa/mali-c55/algorithms/awb.h b/src/ipa/mali-c55/algorithms/awb.h
>> index 2351d405553058dbff569e9e09e265a56baaa23f..647525ff700e8281e3cce63e64ba56a91294bcc2 100644
>> --- a/src/ipa/mali-c55/algorithms/awb.h
>> +++ b/src/ipa/mali-c55/algorithms/awb.h
>> @@ -22,7 +22,7 @@ public:
>>                        const IPACameraSensorInfo &configInfo) override;
>>          void prepare(IPAContext &context, const uint32_t frame,
>>                       IPAFrameContext &frameContext,
>> -                    mali_c55_params_buffer *params) override;
>> +                    v4l2_isp_params_buffer *params) override;
>>          void process(IPAContext &context, const uint32_t frame,
>>                       IPAFrameContext &frameContext,
>>                       const mali_c55_stats_buffer *stats,
>> diff --git a/src/ipa/mali-c55/algorithms/blc.cpp b/src/ipa/mali-c55/algorithms/blc.cpp
>> index 2a54c86a91f83d24183cb7236fcd5181302eb622..543ba96cb57ac0cca2b8f822180d8d8b42f21fc7 100644
>> --- a/src/ipa/mali-c55/algorithms/blc.cpp
>> +++ b/src/ipa/mali-c55/algorithms/blc.cpp
>> @@ -85,10 +85,10 @@ int BlackLevelCorrection::configure(IPAContext &context,
>>   void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
>>                                     const uint32_t frame,
>>                                     [[maybe_unused]] IPAFrameContext &frameContext,
>> -                                  mali_c55_params_buffer *params)
>> +                                  v4l2_isp_params_buffer *params)
>>   {
>>          mali_c55_params_block block;
>> -       block.data = &params->data[params->total_size];
>> +       block.data = &params->data[params->data_size];
>>   
>>          if (frame > 0)
>>                  return;
>> @@ -97,7 +97,7 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
>>                  return;
>>   
>>          block.header->type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;
>> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
>> +       block.header->flags = 0;
>>          block.header->size = sizeof(mali_c55_params_sensor_off_preshading);
>>   
>>          block.sensor_offs->chan00 = offset00;
>> @@ -105,7 +105,7 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
>>          block.sensor_offs->chan10 = offset10;
>>          block.sensor_offs->chan11 = offset11;
>>   
>> -       params->total_size += block.header->size;
>> +       params->data_size += block.header->size;
>>   }
>>   
>>   void BlackLevelCorrection::process([[maybe_unused]] IPAContext &context,
>> diff --git a/src/ipa/mali-c55/algorithms/blc.h b/src/ipa/mali-c55/algorithms/blc.h
>> index 9696e8e9f2aa8b9076a3a41fb8f5ea356e32be12..ee6c889ed89ac2230b231cb58a9fe4412c0ce164 100644
>> --- a/src/ipa/mali-c55/algorithms/blc.h
>> +++ b/src/ipa/mali-c55/algorithms/blc.h
>> @@ -22,7 +22,7 @@ public:
>>                        const IPACameraSensorInfo &configInfo) override;
>>          void prepare(IPAContext &context, const uint32_t frame,
>>                       IPAFrameContext &frameContext,
>> -                    mali_c55_params_buffer *params) override;
>> +                    v4l2_isp_params_buffer *params) override;
>>          void process(IPAContext &context, const uint32_t frame,
>>                       IPAFrameContext &frameContext,
>>                       const mali_c55_stats_buffer *stats,
>> diff --git a/src/ipa/mali-c55/algorithms/lsc.cpp b/src/ipa/mali-c55/algorithms/lsc.cpp
>> index c43d034a181edb7559706189f8d75edd67a2dc08..cb915c5efd3c22952035f2b03ee659f293942ec9 100644
>> --- a/src/ipa/mali-c55/algorithms/lsc.cpp
>> +++ b/src/ipa/mali-c55/algorithms/lsc.cpp
>> @@ -111,7 +111,7 @@ int Lsc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData
>>   size_t Lsc::fillConfigParamsBlock(mali_c55_params_block block) const
>>   {
>>          block.header->type = MALI_C55_PARAM_MESH_SHADING_CONFIG;
>> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
>> +       block.header->flags = 0;
>>          block.header->size = sizeof(struct mali_c55_params_mesh_shading_config);
>>   
>>          block.shading_config->mesh_show = false;
>> @@ -131,7 +131,7 @@ size_t Lsc::fillSelectionParamsBlock(mali_c55_params_block block, uint8_t bank,
>>                                       uint8_t alpha) const
>>   {
>>          block.header->type = MALI_C55_PARAM_MESH_SHADING_SELECTION;
>> -       block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
>> +       block.header->flags = 0;
>>          block.header->size = sizeof(struct mali_c55_params_mesh_shading_selection);
>>   
>>          block.shading_selection->mesh_alpha_bank_r = bank;
>> @@ -170,7 +170,7 @@ std::tuple<uint8_t, uint8_t> Lsc::findBankAndAlpha(uint32_t ct) const
>>   
>>   void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>>                    [[maybe_unused]] IPAFrameContext &frameContext,
>> -                 mali_c55_params_buffer *params)
>> +                 v4l2_isp_params_buffer *params)
>>   {
>>          /*
>>           * For each frame we assess the colour temperature of the **last** frame
>> @@ -194,9 +194,9 @@ void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>>          }
>>   
>>          mali_c55_params_block block;
>> -       block.data = &params->data[params->total_size];
>> +       block.data = &params->data[params->data_size];
>>   
>> -       params->total_size += fillSelectionParamsBlock(block, bank, alpha);
>> +       params->data_size += fillSelectionParamsBlock(block, bank, alpha);
>>   
>>          if (frame > 0)
>>                  return;
>> @@ -205,8 +205,8 @@ void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>>           * If this is the first frame, we need to load the parsed coefficient
>>           * tables from tuning data to the ISP.
>>           */
>> -       block.data = &params->data[params->total_size];
>> -       params->total_size += fillConfigParamsBlock(block);
>> +       block.data = &params->data[params->data_size];
>> +       params->data_size += fillConfigParamsBlock(block);
>>   }
>>   
>>   REGISTER_IPA_ALGORITHM(Lsc, "Lsc")
>> diff --git a/src/ipa/mali-c55/algorithms/lsc.h b/src/ipa/mali-c55/algorithms/lsc.h
>> index d11e23bc7c34fa3e1f45ccf015b50f3d390d7159..c287900502528ca82ab6c62d732b6ffc28ad8df6 100644
>> --- a/src/ipa/mali-c55/algorithms/lsc.h
>> +++ b/src/ipa/mali-c55/algorithms/lsc.h
>> @@ -23,7 +23,7 @@ public:
>>          int init(IPAContext &context, const YamlObject &tuningData) override;
>>          void prepare(IPAContext &context, const uint32_t frame,
>>                       IPAFrameContext &frameContext,
>> -                    mali_c55_params_buffer *params) override;
>> +                    v4l2_isp_params_buffer *params) override;
>>   private:
>>          static constexpr unsigned int kRedOffset = 0;
>>          static constexpr unsigned int kGreenOffset = 1024;
>> diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp
>> index 7d45e7310aecdae0e47655e6d2e8830e776d74cd..504d95222074a35b033949a25178f998738e5699 100644
>> --- a/src/ipa/mali-c55/mali-c55.cpp
>> +++ b/src/ipa/mali-c55/mali-c55.cpp
>> @@ -331,22 +331,23 @@ void IPAMaliC55::queueRequest(const uint32_t request, const ControlList &control
>>   void IPAMaliC55::fillParams(unsigned int request,
>>                              [[maybe_unused]] uint32_t bufferId)
>>   {
>> -       struct mali_c55_params_buffer *params;
>> +       struct v4l2_isp_params_buffer *params;
>>          IPAFrameContext &frameContext = context_.frameContexts.get(request);
>>   
>> -       params = reinterpret_cast<mali_c55_params_buffer *>(
>> +       params = reinterpret_cast<v4l2_isp_params_buffer *>(
>>                  buffers_.at(bufferId).planes()[0].data());
>> -       memset(params, 0, sizeof(mali_c55_params_buffer));
>> +       memset(params, 0,
>> +              buffers_.at(bufferId).planes()[0].size());
>>   
>>          params->version = MALI_C55_PARAM_BUFFER_V1;
>>   
>>          for (auto const &algo : algorithms()) {
>>                  algo->prepare(context_, request, frameContext, params);
>>   
>> -               ASSERT(params->total_size <= MALI_C55_PARAMS_MAX_SIZE);
>> +               ASSERT(params->data_size <= MALI_C55_PARAMS_MAX_SIZE);
>>          }
>>   
>> -       size_t bytesused = offsetof(struct mali_c55_params_buffer, data) + params->total_size;
>> +       size_t bytesused = offsetof(struct v4l2_isp_params_buffer, data) + params->data_size;
>>          paramsComputed.emit(request, bytesused);
>>   }
>>   
>> diff --git a/src/ipa/mali-c55/module.h b/src/ipa/mali-c55/module.h
>> index 4f6a4f18bfaf83263ccb5b7eb1723da9b655cc3c..a8dcb20841a4ebd7bde22cae4ff1f8eef530d8bb 100644
>> --- a/src/ipa/mali-c55/module.h
>> +++ b/src/ipa/mali-c55/module.h
>> @@ -20,7 +20,7 @@ namespace libcamera {
>>   namespace ipa::mali_c55 {
>>   
>>   using Module = ipa::Module<IPAContext, IPAFrameContext, IPACameraSensorInfo,
>> -                          mali_c55_params_buffer, mali_c55_stats_buffer>;
>> +                          v4l2_isp_params_buffer, mali_c55_stats_buffer>;
> 
> And the above looks consistent so :
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
>>   
>>   } /* namespace ipa::mali_c55 */
>>   
>>
>> -- 
>> 2.51.0
>>

Patch
diff mbox series

diff --git a/include/linux/mali-c55-config.h b/include/linux/mali-c55-config.h
index b31415597e886496b65f8fb396c095618467f1ac..109082c5694f6b927dc5511043e3bfbc27a0b675 100644
--- a/include/linux/mali-c55-config.h
+++ b/include/linux/mali-c55-config.h
@@ -9,6 +9,21 @@ 
 #define __UAPI_MALI_C55_CONFIG_H
 
 #include <linux/types.h>
+#include <linux/v4l2-controls.h>
+#include <linux/media/v4l2-isp.h>
+
+#define V4L2_CID_MALI_C55_CAPABILITIES	(V4L2_CID_USER_MALI_C55_BASE + 0x0)
+#define MALI_C55_GPS_PONG		(1U << 0)
+#define MALI_C55_GPS_WDR		(1U << 1)
+#define MALI_C55_GPS_COMPRESSION	(1U << 2)
+#define MALI_C55_GPS_TEMPER		(1U << 3)
+#define MALI_C55_GPS_SINTER_LITE	(1U << 4)
+#define MALI_C55_GPS_SINTER		(1U << 5)
+#define MALI_C55_GPS_IRIDIX_LTM		(1U << 6)
+#define MALI_C55_GPS_IRIDIX_GTM		(1U << 7)
+#define MALI_C55_GPS_CNR		(1U << 8)
+#define MALI_C55_GPS_FRSCALER		(1U << 9)
+#define MALI_C55_GPS_DS_PIPE		(1U << 10)
 
 /*
  * Frames are split into zones of almost equal width and height - a zone is a
@@ -228,65 +243,6 @@  enum mali_c55_param_block_type {
 	MALI_C55_PARAM_MESH_SHADING_SELECTION,
 };
 
-#define MALI_C55_PARAM_BLOCK_FL_NONE			0
-#define MALI_C55_PARAM_BLOCK_FL_DISABLED		BIT(0)
-
-/**
- * struct mali_c55_params_block_header - Mali-C55 parameter block header
- *
- * This structure represents the common part of all the ISP configuration
- * blocks. Each parameters block embeds an instance of this structure type
- * as its first member, followed by the block-specific configuration data. The
- * driver inspects this common header to discern the block type and its size and
- * properly handle the block content by casting it to the correct block-specific
- * type.
- *
- * The @type field is one of the values enumerated by
- * :c:type:`mali_c55_param_block_type` and specifies how the data should be
- * interpreted by the driver. The @size field specifies the size of the
- * parameters block and is used by the driver for validation purposes. The
- * @flags field holds a bitmask of per-block flags MALI_C55_PARAM_BLOCK_FL_*.
- *
- * If userspace wants to disable an ISP block the
- * MALI_C55_PARAM_BLOCK_FL_DISABLED bit should be set in the @flags field. In
- * that case userspace may optionally omit the remainder of the configuration
- * block, which will in any case be ignored by the driver. If a new
- * configuration of an ISP block has to be applied userspace shall fully
- * populate the ISP block and omit setting the MALI_C55_PARAM_BLOCK_FL_DISABLED
- * bit in the @flags field.
- *
- * Userspace is responsible for correctly populating the parameters block header
- * fields (@type, @flags and @size) and correctly populate the block-specific
- * parameters.
- *
- * For example:
- *
- * .. code-block:: c
- *
- *	void populate_sensor_offs(struct mali_c55_params_block_header *block) {
- *		block->type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;
- *		block->enabled = MALI_C55_PARAM_BLOCK_FL_NONE;
- *		block->size = sizeof(struct mali_c55_params_sensor_off_preshading);
- *
- *		struct mali_c55_params_sensor_off_preshading *sensor_offs =
- *			(struct mali_c55_params_sensor_off_preshading *)block;
- *
- *		sensor_offs->chan00 = offset00;
- *		sensor_offs->chan01 = offset01;
- *		sensor_offs->chan10 = offset10;
- *		sensor_offs->chan11 = offset11;
- *	}
- *
- * @type: The parameters block type from :c:type:`mali_c55_param_block_type`
- * @flags: Bitmask of block flags
- * @size: Size (in bytes) of the parameters block
- */
-struct mali_c55_params_block_header {
-	__u16 type;
-	__u16 flags;
-	__u32 size;
-} __attribute__((aligned(8)));
-
 /**
  * struct mali_c55_params_sensor_off_preshading - offset subtraction for each
  *						  color channel
@@ -305,7 +261,7 @@  struct mali_c55_params_block_header {
  * @chan11: Offset for color channel 11 (default: B)
  */
 struct mali_c55_params_sensor_off_preshading {
-	struct mali_c55_params_block_header header;
+	struct v4l2_isp_params_block_header header;
 	__u32 chan00;
 	__u32 chan01;
 	__u32 chan10;
@@ -470,7 +426,7 @@  enum mali_c55_aexp_hist_plane_mode {
  *			This parameter is unused for the post-Iridix Histogram
  */
 struct mali_c55_params_aexp_hist {
-	struct mali_c55_params_block_header header;
+	struct v4l2_isp_params_block_header header;
 	__u8 skip_x;
 	__u8 offset_x;
 	__u8 skip_y;
@@ -502,7 +458,7 @@  struct mali_c55_params_aexp_hist {
  *			@nodes_used_horiz
  */
 struct mali_c55_params_aexp_weights {
-	struct mali_c55_params_block_header header;
+	struct v4l2_isp_params_block_header header;
 	__u8 nodes_used_horiz;
 	__u8 nodes_used_vert;
 	__u8 zone_weights[MALI_C55_MAX_ZONES];
@@ -520,7 +476,7 @@  struct mali_c55_params_aexp_weights {
  * @gain:	The digital gain value to apply, in Q5.8 format.
  */
 struct mali_c55_params_digital_gain {
-	struct mali_c55_params_block_header header;
+	struct v4l2_isp_params_block_header header;
 	__u16 gain;
 };
 
@@ -560,7 +516,7 @@  enum mali_c55_awb_stats_mode {
  * @gain11:	Multiplier for colour channel 11
  */
 struct mali_c55_params_awb_gains {
-	struct mali_c55_params_block_header header;
+	struct v4l2_isp_params_block_header header;
 	__u16 gain00;
 	__u16 gain01;
 	__u16 gain10;
@@ -635,7 +591,7 @@  enum mali_c55_params_awb_tap_points {
  * @cb_low:		B/G ratio trim low (Q4.8 format)
  */
 struct mali_c55_params_awb_config {
-	struct mali_c55_params_block_header header;
+	struct v4l2_isp_params_block_header header;
 	__u8 tap_point;
 	__u8 stats_mode;
 	__u16 white_level;
@@ -745,7 +701,7 @@  struct mali_c55_params_awb_config {
  * @mesh:		Mesh shading correction tables
  */
 struct mali_c55_params_mesh_shading_config {
-	struct mali_c55_params_block_header header;
+	struct v4l2_isp_params_block_header header;
 	__u8 mesh_show;
 	__u8 mesh_scale;
 	__u8 mesh_page_r;
@@ -800,7 +756,7 @@  enum mali_c55_params_mesh_alpha_bank {
  * @mesh_strength:	Mesh strength in Q4.12 format [0..4096]
  */
 struct mali_c55_params_mesh_shading_selection {
-	struct mali_c55_params_block_header header;
+	struct v4l2_isp_params_block_header header;
 	__u8 mesh_alpha_bank_r;
 	__u8 mesh_alpha_bank_g;
 	__u8 mesh_alpha_bank_b;
@@ -835,75 +791,4 @@  struct mali_c55_params_mesh_shading_selection {
 	sizeof(struct mali_c55_params_mesh_shading_config) +	\
 	sizeof(struct mali_c55_params_mesh_shading_selection))
 
-/**
- * struct mali_c55_params_buffer - 3A configuration parameters
- *
- * This struct contains the configuration parameters of the Mali-C55 ISP
- * algorithms, serialized by userspace into a data buffer. Each configuration
- * parameter block is represented by a block-specific structure which contains a
- * :c:type:`mali_c55_params_block_header` entry as first member. Userspace
- * populates the @data buffer with configuration parameters for the blocks that
- * it intends to configure. As a consequence, the data buffer effective size
- * changes according to the number of ISP blocks that userspace intends to
- * configure.
- *
- * The parameters buffer is versioned by the @version field to allow modifying
- * and extending its definition. Userspace shall populate the @version field to
- * inform the driver about the version it intends to use. The driver will parse
- * and handle the @data buffer according to the data layout specific to the
- * indicated version and return an error if the desired version is not
- * supported.
- *
- * 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 @total_size field with
- * the effective size, in bytes, of the @data buffer.
- *
- * The expected memory layout of the parameters buffer is::
- *
- *	+-------------------- struct mali_c55_params_buffer ------------------+
- *	| version = MALI_C55_PARAM_BUFFER_V1;                                 |
- *	| total_size = sizeof(struct mali_c55_params_sensor_off_preshading)   |
- *	|              sizeof(struct mali_c55_params_aexp_hist);              |
- *	| +------------------------- data  ---------------------------------+ |
- *	| | +--------- struct mali_c55_params_sensor_off_preshading ------+ | |
- *	| | | +-------- struct mali_c55_params_block_header header -----+ | | |
- *	| | | | type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;                | | | |
- *	| | | | flags = MALI_C55_PARAM_BLOCK_FL_NONE;                   | | | |
- *	| | | | size =                                                  | | | |
- *	| | | |    sizeof(struct mali_c55_params_sensor_off_preshading);| | | |
- *	| | | +---------------------------------------------------------+ | | |
- *	| | | chan00 = ...;                                               | | |
- *	| | | chan01 = ...;                                               | | |
- *	| | | chan10 = ...;                                               | | |
- *	| | | chan11 = ...;                                               | | |
- *	| | +------------ struct mali_c55_params_aexp_hist ---------------+ | |
- *	| | | +-------- struct mali_c55_params_block_header header -----+ | | |
- *	| | | | type = MALI_C55_PARAM_BLOCK_AEXP_HIST;                  | | | |
- *	| | | | flags = MALI_C55_PARAM_BLOCK_FL_NONE;                   | | | |
- *	| | | | size = sizeof(struct mali_c55_params_aexp_hist);        | | | |
- *	| | | +---------------------------------------------------------+ | | |
- *	| | | skip_x = ...;                                               | | |
- *	| | | offset_x = ...;                                             | | |
- *	| | | skip_y = ...;                                               | | |
- *	| | | offset_y = ...;                                             | | |
- *	| | | scale_bottom = ...;                                         | | |
- *	| | | scale_top = ...;                                            | | |
- *	| | | plane_mode = ...;                                           | | |
- *	| | | tap_point = ...;                                            | | |
- *	| | +-------------------------------------------------------------+ | |
- *	| +-----------------------------------------------------------------+ |
- *	+---------------------------------------------------------------------+
- *
- * @version: The version from :c:type:`mali_c55_param_buffer_version`
- * @total_size: The Mali-C55 configuration data effective size, excluding this
- *		header
- * @data: The Mali-C55 configuration blocks data
- */
-struct mali_c55_params_buffer {
-	__u8 version;
-	__u32 total_size;
-	__u8 data[MALI_C55_PARAMS_MAX_SIZE];
-};
-
 #endif /* __UAPI_MALI_C55_CONFIG_H */
diff --git a/src/ipa/mali-c55/algorithms/agc.cpp b/src/ipa/mali-c55/algorithms/agc.cpp
index f60fddac3f04fd6f09dc782e929ff1593758c29b..78e7e07b2348a711e6261bac45e006f49a59513a 100644
--- a/src/ipa/mali-c55/algorithms/agc.cpp
+++ b/src/ipa/mali-c55/algorithms/agc.cpp
@@ -253,7 +253,7 @@  size_t Agc::fillGainParamBlock(IPAContext &context, IPAFrameContext &frameContex
 		gain = activeState.agc.manual.ispGain;
 
 	block.header->type = MALI_C55_PARAM_BLOCK_DIGITAL_GAIN;
-	block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
+	block.header->flags = 0;
 	block.header->size = sizeof(struct mali_c55_params_digital_gain);
 
 	block.digital_gain->gain = floatingToFixedPoint<5, 8, uint16_t, double>(gain);
@@ -266,7 +266,7 @@  size_t Agc::fillParamsBuffer(mali_c55_params_block block,
 			     enum mali_c55_param_block_type type)
 {
 	block.header->type = type;
-	block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
+	block.header->flags = 0;
 	block.header->size = sizeof(struct mali_c55_params_aexp_hist);
 
 	/* Collect every 3rd pixel horizontally */
@@ -292,7 +292,7 @@  size_t Agc::fillWeightsArrayBuffer(mali_c55_params_block block,
 				   enum mali_c55_param_block_type type)
 {
 	block.header->type = type;
-	block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
+	block.header->flags = 0;
 	block.header->size = sizeof(struct mali_c55_params_aexp_weights);
 
 	/* We use every zone - a 15x15 grid */
@@ -314,30 +314,30 @@  size_t Agc::fillWeightsArrayBuffer(mali_c55_params_block block,
 }
 
 void Agc::prepare(IPAContext &context, const uint32_t frame,
-		  IPAFrameContext &frameContext, mali_c55_params_buffer *params)
+		  IPAFrameContext &frameContext, v4l2_isp_params_buffer *params)
 {
 	mali_c55_params_block block;
 
-	block.data = &params->data[params->total_size];
-	params->total_size += fillGainParamBlock(context, frameContext, block);
+	block.data = &params->data[params->data_size];
+	params->data_size += fillGainParamBlock(context, frameContext, block);
 
 	if (frame > 0)
 		return;
 
-	block.data = &params->data[params->total_size];
-	params->total_size += fillParamsBuffer(block,
+	block.data = &params->data[params->data_size];
+	params->data_size += fillParamsBuffer(block,
 					       MALI_C55_PARAM_BLOCK_AEXP_HIST);
 
-	block.data = &params->data[params->total_size];
-	params->total_size += fillWeightsArrayBuffer(block,
+	block.data = &params->data[params->data_size];
+	params->data_size += fillWeightsArrayBuffer(block,
 						     MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS);
 
-	block.data = &params->data[params->total_size];
-	params->total_size += fillParamsBuffer(block,
+	block.data = &params->data[params->data_size];
+	params->data_size += fillParamsBuffer(block,
 					       MALI_C55_PARAM_BLOCK_AEXP_IHIST);
 
-	block.data = &params->data[params->total_size];
-	params->total_size += fillWeightsArrayBuffer(block,
+	block.data = &params->data[params->data_size];
+	params->data_size += fillWeightsArrayBuffer(block,
 						     MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS);
 }
 
diff --git a/src/ipa/mali-c55/algorithms/agc.h b/src/ipa/mali-c55/algorithms/agc.h
index 0b4bf7eda1c2a7c9894f6932452fea5f53699b30..4325ef5a9b7dcef36107b64a65db993f194d4167 100644
--- a/src/ipa/mali-c55/algorithms/agc.h
+++ b/src/ipa/mali-c55/algorithms/agc.h
@@ -57,7 +57,7 @@  public:
 			  const ControlList &controls) override;
 	void prepare(IPAContext &context, const uint32_t frame,
 		     IPAFrameContext &frameContext,
-		     mali_c55_params_buffer *params) override;
+		     v4l2_isp_params_buffer *params) override;
 	void process(IPAContext &context, const uint32_t frame,
 		     IPAFrameContext &frameContext,
 		     const mali_c55_stats_buffer *stats,
diff --git a/src/ipa/mali-c55/algorithms/algorithm.h b/src/ipa/mali-c55/algorithms/algorithm.h
index ec8dd3973eaf2d804d8de8620840f716340e9cfd..e61115f6c2d6c911c15a1d877833d3f2b06a0db8 100644
--- a/src/ipa/mali-c55/algorithms/algorithm.h
+++ b/src/ipa/mali-c55/algorithms/algorithm.h
@@ -22,7 +22,7 @@  class Algorithm : public libcamera::ipa::Algorithm<Module>
 };
 
 union mali_c55_params_block {
-	struct mali_c55_params_block_header *header;
+	struct v4l2_isp_params_block_header *header;
 	struct mali_c55_params_sensor_off_preshading *sensor_offs;
 	struct mali_c55_params_aexp_hist *aexp_hist;
 	struct mali_c55_params_aexp_weights *aexp_weights;
diff --git a/src/ipa/mali-c55/algorithms/awb.cpp b/src/ipa/mali-c55/algorithms/awb.cpp
index 3d546e5a854b8aa02987c44f57109a6171e3794b..694c0aaa9c6804bb58e380ba9c744f11c39224fe 100644
--- a/src/ipa/mali-c55/algorithms/awb.cpp
+++ b/src/ipa/mali-c55/algorithms/awb.cpp
@@ -47,7 +47,7 @@  size_t Awb::fillGainsParamBlock(mali_c55_params_block block, IPAContext &context
 				IPAFrameContext &frameContext)
 {
 	block.header->type = MALI_C55_PARAM_BLOCK_AWB_GAINS;
-	block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
+	block.header->flags = 0;
 	block.header->size = sizeof(struct mali_c55_params_awb_gains);
 
 	double rGain = context.activeState.awb.rGain;
@@ -77,7 +77,7 @@  size_t Awb::fillGainsParamBlock(mali_c55_params_block block, IPAContext &context
 size_t Awb::fillConfigParamBlock(mali_c55_params_block block)
 {
 	block.header->type = MALI_C55_PARAM_BLOCK_AWB_CONFIG;
-	block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
+	block.header->flags = 0;
 	block.header->size = sizeof(struct mali_c55_params_awb_config);
 
 	/* Tap the stats after the purple fringe block */
@@ -126,18 +126,18 @@  size_t Awb::fillConfigParamBlock(mali_c55_params_block block)
 }
 
 void Awb::prepare(IPAContext &context, const uint32_t frame,
-		  IPAFrameContext &frameContext, mali_c55_params_buffer *params)
+		  IPAFrameContext &frameContext, v4l2_isp_params_buffer *params)
 {
 	mali_c55_params_block block;
-	block.data = &params->data[params->total_size];
+	block.data = &params->data[params->data_size];
 
-	params->total_size += fillGainsParamBlock(block, context, frameContext);
+	params->data_size += fillGainsParamBlock(block, context, frameContext);
 
 	if (frame > 0)
 		return;
 
-	block.data = &params->data[params->total_size];
-	params->total_size += fillConfigParamBlock(block);
+	block.data = &params->data[params->data_size];
+	params->data_size += fillConfigParamBlock(block);
 }
 
 void Awb::process(IPAContext &context, const uint32_t frame,
diff --git a/src/ipa/mali-c55/algorithms/awb.h b/src/ipa/mali-c55/algorithms/awb.h
index 2351d405553058dbff569e9e09e265a56baaa23f..647525ff700e8281e3cce63e64ba56a91294bcc2 100644
--- a/src/ipa/mali-c55/algorithms/awb.h
+++ b/src/ipa/mali-c55/algorithms/awb.h
@@ -22,7 +22,7 @@  public:
 		      const IPACameraSensorInfo &configInfo) override;
 	void prepare(IPAContext &context, const uint32_t frame,
 		     IPAFrameContext &frameContext,
-		     mali_c55_params_buffer *params) override;
+		     v4l2_isp_params_buffer *params) override;
 	void process(IPAContext &context, const uint32_t frame,
 		     IPAFrameContext &frameContext,
 		     const mali_c55_stats_buffer *stats,
diff --git a/src/ipa/mali-c55/algorithms/blc.cpp b/src/ipa/mali-c55/algorithms/blc.cpp
index 2a54c86a91f83d24183cb7236fcd5181302eb622..543ba96cb57ac0cca2b8f822180d8d8b42f21fc7 100644
--- a/src/ipa/mali-c55/algorithms/blc.cpp
+++ b/src/ipa/mali-c55/algorithms/blc.cpp
@@ -85,10 +85,10 @@  int BlackLevelCorrection::configure(IPAContext &context,
 void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
 				   const uint32_t frame,
 				   [[maybe_unused]] IPAFrameContext &frameContext,
-				   mali_c55_params_buffer *params)
+				   v4l2_isp_params_buffer *params)
 {
 	mali_c55_params_block block;
-	block.data = &params->data[params->total_size];
+	block.data = &params->data[params->data_size];
 
 	if (frame > 0)
 		return;
@@ -97,7 +97,7 @@  void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
 		return;
 
 	block.header->type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;
-	block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
+	block.header->flags = 0;
 	block.header->size = sizeof(mali_c55_params_sensor_off_preshading);
 
 	block.sensor_offs->chan00 = offset00;
@@ -105,7 +105,7 @@  void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
 	block.sensor_offs->chan10 = offset10;
 	block.sensor_offs->chan11 = offset11;
 
-	params->total_size += block.header->size;
+	params->data_size += block.header->size;
 }
 
 void BlackLevelCorrection::process([[maybe_unused]] IPAContext &context,
diff --git a/src/ipa/mali-c55/algorithms/blc.h b/src/ipa/mali-c55/algorithms/blc.h
index 9696e8e9f2aa8b9076a3a41fb8f5ea356e32be12..ee6c889ed89ac2230b231cb58a9fe4412c0ce164 100644
--- a/src/ipa/mali-c55/algorithms/blc.h
+++ b/src/ipa/mali-c55/algorithms/blc.h
@@ -22,7 +22,7 @@  public:
 		      const IPACameraSensorInfo &configInfo) override;
 	void prepare(IPAContext &context, const uint32_t frame,
 		     IPAFrameContext &frameContext,
-		     mali_c55_params_buffer *params) override;
+		     v4l2_isp_params_buffer *params) override;
 	void process(IPAContext &context, const uint32_t frame,
 		     IPAFrameContext &frameContext,
 		     const mali_c55_stats_buffer *stats,
diff --git a/src/ipa/mali-c55/algorithms/lsc.cpp b/src/ipa/mali-c55/algorithms/lsc.cpp
index c43d034a181edb7559706189f8d75edd67a2dc08..cb915c5efd3c22952035f2b03ee659f293942ec9 100644
--- a/src/ipa/mali-c55/algorithms/lsc.cpp
+++ b/src/ipa/mali-c55/algorithms/lsc.cpp
@@ -111,7 +111,7 @@  int Lsc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData
 size_t Lsc::fillConfigParamsBlock(mali_c55_params_block block) const
 {
 	block.header->type = MALI_C55_PARAM_MESH_SHADING_CONFIG;
-	block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
+	block.header->flags = 0;
 	block.header->size = sizeof(struct mali_c55_params_mesh_shading_config);
 
 	block.shading_config->mesh_show = false;
@@ -131,7 +131,7 @@  size_t Lsc::fillSelectionParamsBlock(mali_c55_params_block block, uint8_t bank,
 				     uint8_t alpha) const
 {
 	block.header->type = MALI_C55_PARAM_MESH_SHADING_SELECTION;
-	block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE;
+	block.header->flags = 0;
 	block.header->size = sizeof(struct mali_c55_params_mesh_shading_selection);
 
 	block.shading_selection->mesh_alpha_bank_r = bank;
@@ -170,7 +170,7 @@  std::tuple<uint8_t, uint8_t> Lsc::findBankAndAlpha(uint32_t ct) const
 
 void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 		  [[maybe_unused]] IPAFrameContext &frameContext,
-		  mali_c55_params_buffer *params)
+		  v4l2_isp_params_buffer *params)
 {
 	/*
 	 * For each frame we assess the colour temperature of the **last** frame
@@ -194,9 +194,9 @@  void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 	}
 
 	mali_c55_params_block block;
-	block.data = &params->data[params->total_size];
+	block.data = &params->data[params->data_size];
 
-	params->total_size += fillSelectionParamsBlock(block, bank, alpha);
+	params->data_size += fillSelectionParamsBlock(block, bank, alpha);
 
 	if (frame > 0)
 		return;
@@ -205,8 +205,8 @@  void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 	 * If this is the first frame, we need to load the parsed coefficient
 	 * tables from tuning data to the ISP.
 	 */
-	block.data = &params->data[params->total_size];
-	params->total_size += fillConfigParamsBlock(block);
+	block.data = &params->data[params->data_size];
+	params->data_size += fillConfigParamsBlock(block);
 }
 
 REGISTER_IPA_ALGORITHM(Lsc, "Lsc")
diff --git a/src/ipa/mali-c55/algorithms/lsc.h b/src/ipa/mali-c55/algorithms/lsc.h
index d11e23bc7c34fa3e1f45ccf015b50f3d390d7159..c287900502528ca82ab6c62d732b6ffc28ad8df6 100644
--- a/src/ipa/mali-c55/algorithms/lsc.h
+++ b/src/ipa/mali-c55/algorithms/lsc.h
@@ -23,7 +23,7 @@  public:
 	int init(IPAContext &context, const YamlObject &tuningData) override;
 	void prepare(IPAContext &context, const uint32_t frame,
 		     IPAFrameContext &frameContext,
-		     mali_c55_params_buffer *params) override;
+		     v4l2_isp_params_buffer *params) override;
 private:
 	static constexpr unsigned int kRedOffset = 0;
 	static constexpr unsigned int kGreenOffset = 1024;
diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp
index 7d45e7310aecdae0e47655e6d2e8830e776d74cd..504d95222074a35b033949a25178f998738e5699 100644
--- a/src/ipa/mali-c55/mali-c55.cpp
+++ b/src/ipa/mali-c55/mali-c55.cpp
@@ -331,22 +331,23 @@  void IPAMaliC55::queueRequest(const uint32_t request, const ControlList &control
 void IPAMaliC55::fillParams(unsigned int request,
 			    [[maybe_unused]] uint32_t bufferId)
 {
-	struct mali_c55_params_buffer *params;
+	struct v4l2_isp_params_buffer *params;
 	IPAFrameContext &frameContext = context_.frameContexts.get(request);
 
-	params = reinterpret_cast<mali_c55_params_buffer *>(
+	params = reinterpret_cast<v4l2_isp_params_buffer *>(
 		buffers_.at(bufferId).planes()[0].data());
-	memset(params, 0, sizeof(mali_c55_params_buffer));
+	memset(params, 0,
+	       buffers_.at(bufferId).planes()[0].size());
 
 	params->version = MALI_C55_PARAM_BUFFER_V1;
 
 	for (auto const &algo : algorithms()) {
 		algo->prepare(context_, request, frameContext, params);
 
-		ASSERT(params->total_size <= MALI_C55_PARAMS_MAX_SIZE);
+		ASSERT(params->data_size <= MALI_C55_PARAMS_MAX_SIZE);
 	}
 
-	size_t bytesused = offsetof(struct mali_c55_params_buffer, data) + params->total_size;
+	size_t bytesused = offsetof(struct v4l2_isp_params_buffer, data) + params->data_size;
 	paramsComputed.emit(request, bytesused);
 }
 
diff --git a/src/ipa/mali-c55/module.h b/src/ipa/mali-c55/module.h
index 4f6a4f18bfaf83263ccb5b7eb1723da9b655cc3c..a8dcb20841a4ebd7bde22cae4ff1f8eef530d8bb 100644
--- a/src/ipa/mali-c55/module.h
+++ b/src/ipa/mali-c55/module.h
@@ -20,7 +20,7 @@  namespace libcamera {
 namespace ipa::mali_c55 {
 
 using Module = ipa::Module<IPAContext, IPAFrameContext, IPACameraSensorInfo,
-			   mali_c55_params_buffer, mali_c55_stats_buffer>;
+			   v4l2_isp_params_buffer, mali_c55_stats_buffer>;
 
 } /* namespace ipa::mali_c55 */