media: v4l2-isp: Add per-block validation callback

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.

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
This commit is contained in:
Jacopo Mondi 2026-06-27 15:42:01 +02:00 committed by Sakari Ailus
parent 7041b0ebf1
commit cad05a2e23
2 changed files with 11 additions and 3 deletions

View File

@ -114,6 +114,9 @@ int v4l2_isp_params_validate_buffer(struct device *dev, struct vb2_buffer *vb,
return -EINVAL;
}
if (info->block_validate && info->block_validate(dev, block))
return -EINVAL;
block_offset += block->size;
buffer_size -= block->size;
}

View File

@ -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);
};
/**