media: amlogic-c3: Implement per-block validation

Use the newly introduced per-block validation in v4l2-isp framework to
implement a validation callback for the AWB and AE configuration blocks
to make sure the configured metering zones do not exceed the hardware
capabilities.

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:02 +02:00 committed by Sakari Ailus
parent cad05a2e23
commit 07a4324a81

View File

@ -535,16 +535,52 @@ static const c3_isp_block_handler c3_isp_params_handlers[] = {
[C3_ISP_PARAMS_BLOCK_BLC] = c3_isp_params_cfg_blc,
};
#define C3_ISP_PARAMS_BLOCK_INFO(block, data) \
static int
c3_isp_params_awb_config_validate(struct device *dev,
const struct v4l2_isp_block_header *block)
{
const struct c3_isp_params_awb_config *cfg =
(const struct c3_isp_params_awb_config *)block;
if (cfg->horiz_zones_num * cfg->vert_zones_num > C3_ISP_AWB_MAX_ZONES) {
dev_dbg(dev, "Invalid number of AWB measurement zones\n");
return -EINVAL;
}
return 0;
}
static int
c3_isp_params_ae_config_validate(struct device *dev,
const struct v4l2_isp_block_header *block)
{
const struct c3_isp_params_ae_config *cfg =
(const struct c3_isp_params_ae_config *)block;
if (cfg->horiz_zones_num * cfg->vert_zones_num > C3_ISP_AE_MAX_ZONES) {
dev_dbg(dev, "Invalid number of AE measurement zones\n");
return -EINVAL;
}
return 0;
}
#define C3_ISP_PARAMS_BLOCK_INFO_CBK(block, data, cbk) \
[C3_ISP_PARAMS_BLOCK_ ## block] = { \
.size = sizeof(struct c3_isp_params_ ## data), \
.block_validate = (cbk)\
}
#define C3_ISP_PARAMS_BLOCK_INFO(block, data) \
C3_ISP_PARAMS_BLOCK_INFO_CBK(block, data, NULL)
static const struct v4l2_isp_params_block_type_info
c3_isp_params_block_types_info[] = {
C3_ISP_PARAMS_BLOCK_INFO(AWB_GAINS, awb_gains),
C3_ISP_PARAMS_BLOCK_INFO(AWB_CONFIG, awb_config),
C3_ISP_PARAMS_BLOCK_INFO(AE_CONFIG, ae_config),
C3_ISP_PARAMS_BLOCK_INFO_CBK(AWB_CONFIG, awb_config,
&c3_isp_params_awb_config_validate),
C3_ISP_PARAMS_BLOCK_INFO_CBK(AE_CONFIG, ae_config,
&c3_isp_params_ae_config_validate),
C3_ISP_PARAMS_BLOCK_INFO(AF_CONFIG, af_config),
C3_ISP_PARAMS_BLOCK_INFO(PST_GAMMA, pst_gamma),
C3_ISP_PARAMS_BLOCK_INFO(CCM, ccm),