Re: [PATCH 4/6] media: v4l2-isp: Add per-block validation callback

From: Niklas Söderlund

Date: Fri May 15 2026 - 14:36:57 EST


Hello Jacopo,

Thanks for your work.

On 2026-05-05 16:12:15 +0200, Jacopo Mondi wrote:
> Drivers are expected to provide to the helper function
> v4l2_isp_params_validate_buffer() a list of 'struct
> v4l2_isp_params_block_type_info' entries, one for each supported ISP block.
>
> The type 'struct v4l2_isp_params_block_type_info' so far only contained the
> expected block size for the core framework to validate the declared block
> size against the expected one.
>
> For some blocks, drivers might want to implement more precise per-block
> validations. Add a function pointer member to 'struct
> v4l2_isp_params_block_type_info' to allow drivers to register a callback
> and call it from the core framework during validation.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@xxxxxxxxxxxxxxxx>

This is a neat idea!

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>

> ---
> drivers/media/v4l2-core/v4l2-isp.c | 4 ++++
> include/media/v4l2-isp.h | 11 ++++++++---
> 2 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-isp.c b/drivers/media/v4l2-core/v4l2-isp.c
> index 29831f7032e9..10760659f8a3 100644
> --- a/drivers/media/v4l2-core/v4l2-isp.c
> +++ b/drivers/media/v4l2-core/v4l2-isp.c
> @@ -114,6 +114,10 @@ int v4l2_isp_params_validate_buffer(struct device *dev, struct vb2_buffer *vb,
> return -EINVAL;
> }
>
> + if (type_info->block_validate &&
> + type_info->block_validate(dev, block))
> + return -EINVAL;
> +
> block_offset += block->size;
> buffer_size -= block->size;
> }
> diff --git a/include/media/v4l2-isp.h b/include/media/v4l2-isp.h
> index d70ed6b431e7..1f35a52f978a 100644
> --- a/include/media/v4l2-isp.h
> +++ b/include/media/v4l2-isp.h
> @@ -55,17 +55,22 @@ int v4l2_isp_params_validate_buffer_size(struct device *dev,
> /**
> * struct v4l2_isp_params_block_type_info - V4L2 ISP per-block-type info
> * @size: the block type expected size
> + * @block_validate: driver's callback to implement per-block validation
> *
> * The v4l2_isp_params_block_type_info collects information of the ISP
> - * configuration block types for validation purposes. It currently only contains
> - * the expected block type size.
> + * configuration block types for validation purposes. It contains the expected
> + * block type size and a function pointer where drivers can register a callback
> + * for additional per-block validation purposes. The validation function is
> + * expected to return 0 on success or a negative error number for errors.
> *
> * Drivers shall prepare a list of block type info, indexed by block type, one
> * for each supported ISP block type and correctly populate them with the
> - * expected block type size.
> + * expected block type size and the optional callback.
> */
> struct v4l2_isp_params_block_type_info {
> size_t size;
> + int (*block_validate)(struct device *dev,
> + const struct v4l2_isp_block_header *block);
> };
>
> /**
>
> --
> 2.53.0
>

--
Kind Regards,
Niklas Söderlund