On Sat Jun 27 15:42:01 2026 +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.
> 
> Reviewed-by: Niklas Söderlund <[email protected]>
> Signed-off-by: Jacopo Mondi <[email protected]>
> Signed-off-by: Sakari Ailus <[email protected]>

Patch committed.

Thanks,
Sakari Ailus

 drivers/media/v4l2-core/v4l2-isp.c |  3 +++
 include/media/v4l2-isp.h           | 11 ++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

---

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);
 };
 
 /**
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to