diff --git a/drivers/media/v4l2-core/v4l2-isp.c b/drivers/media/v4l2-core/v4l2-isp.c index 29831f7032e9..f497471e9f18 100644 --- a/drivers/media/v4l2-core/v4l2-isp.c +++ b/drivers/media/v4l2-core/v4l2-isp.c @@ -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; } 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); }; /**