* [PATCH v3 1/4] media: mali-c55: Add support for CCM
2026-06-27 14:29 [PATCH v3 0/4] media: mali-c55: Add support for CCM and Gamma Jacopo Mondi
@ 2026-06-27 14:29 ` Jacopo Mondi
2026-06-27 14:29 ` [PATCH v3 2/4] media: mali-c55: Implement CCM block validation Jacopo Mondi
` (2 subsequent siblings)
3 siblings, 0 replies; 16+ messages in thread
From: Jacopo Mondi @ 2026-06-27 14:29 UTC (permalink / raw)
To: Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
vincenzo.frascino, linus.walleij, laurent.pinchart, Daniel Scally,
Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Jacopo Mondi, Linus Walleij
From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Add support for the CCM (Color Correction Matrix) for the Mali C55 ISP.
Define a new block in the uAPI using the extensible v4l2-isp format and
implement support for configuring the CCM parameters in the mali-c55
ISP driver.
Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
---
.../media/platform/arm/mali-c55/mali-c55-params.c | 52 ++++++++++++++++++++++
include/uapi/linux/media/arm/mali-c55-config.h | 41 ++++++++++++++++-
2 files changed, 92 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
index dc483f0322d6..0da5215c52c3 100644
--- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
+++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
@@ -46,6 +46,7 @@
* @awb_config: For header->type == MALI_C55_PARAM_BLOCK_AWB_CONFIG
* @shading_config: For header->type == MALI_C55_PARAM_MESH_SHADING_CONFIG
* @shading_selection: For header->type == MALI_C55_PARAM_MESH_SHADING_SELECTION
+ * @ccm: For header->type == MALI_C55_PARAM_BLOCK_CCM
* @data: Allows easy initialisation of a union variable with a
* pointer into a __u8 array.
*/
@@ -59,6 +60,7 @@ union mali_c55_params_block {
const struct mali_c55_params_awb_config *awb_config;
const struct mali_c55_params_mesh_shading_config *shading_config;
const struct mali_c55_params_mesh_shading_selection *shading_selection;
+ const struct mali_c55_params_ccm *ccm;
const __u8 *data;
};
@@ -414,6 +416,52 @@ static void mali_c55_params_lsc_selection(struct mali_c55 *mali_c55,
params->mesh_strength);
}
+static void mali_c55_params_ccm(struct mali_c55 *mali_c55,
+ union mali_c55_params_block block)
+{
+ const struct mali_c55_params_ccm *params = block.ccm;
+
+ if (block.header->flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE) {
+ mali_c55_ctx_write(mali_c55, MALI_C55_REG_CCM_ENABLE, 0);
+ return;
+ }
+
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_COEF_R_R,
+ MALI_C55_CCM_COEF_MASK, params->coeffs[0][0]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_COEF_R_G,
+ MALI_C55_CCM_COEF_MASK, params->coeffs[0][1]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_COEF_R_B,
+ MALI_C55_CCM_COEF_MASK, params->coeffs[0][2]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_COEF_G_R,
+ MALI_C55_CCM_COEF_MASK, params->coeffs[1][0]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_COEF_G_G,
+ MALI_C55_CCM_COEF_MASK, params->coeffs[1][1]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_COEF_G_B,
+ MALI_C55_CCM_COEF_MASK, params->coeffs[1][2]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_COEF_B_R,
+ MALI_C55_CCM_COEF_MASK, params->coeffs[2][0]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_COEF_B_G,
+ MALI_C55_CCM_COEF_MASK, params->coeffs[2][1]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_COEF_B_B,
+ MALI_C55_CCM_COEF_MASK, params->coeffs[2][2]);
+
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_ANTIFOG_GAIN_R,
+ MALI_C55_CCM_ANTIFOG_GAIN_MASK, params->gains[0]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_ANTIFOG_GAIN_G,
+ MALI_C55_CCM_ANTIFOG_GAIN_MASK, params->gains[1]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_ANTIFOG_GAIN_B,
+ MALI_C55_CCM_ANTIFOG_GAIN_MASK, params->gains[2]);
+
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_ANTIFOG_OFFSET_R,
+ MALI_C55_CCM_ANTIFOG_OFFSET_MASK, params->offs[0]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_ANTIFOG_OFFSET_G,
+ MALI_C55_CCM_ANTIFOG_OFFSET_MASK, params->offs[1]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_CCM_ANTIFOG_OFFSET_B,
+ MALI_C55_CCM_ANTIFOG_OFFSET_MASK, params->offs[2]);
+
+ mali_c55_ctx_write(mali_c55, MALI_C55_REG_CCM_ENABLE, 1);
+}
+
static const mali_c55_params_handler mali_c55_params_handlers[] = {
[MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = &mali_c55_params_sensor_offs,
[MALI_C55_PARAM_BLOCK_AEXP_HIST] = &mali_c55_params_aexp_hist,
@@ -426,6 +474,7 @@ static const mali_c55_params_handler mali_c55_params_handlers[] = {
[MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP] = &mali_c55_params_awb_gains,
[MALI_C55_PARAM_MESH_SHADING_CONFIG] = &mali_c55_params_lsc_config,
[MALI_C55_PARAM_MESH_SHADING_SELECTION] = &mali_c55_params_lsc_selection,
+ [MALI_C55_PARAM_BLOCK_CCM] = &mali_c55_params_ccm,
};
static const struct v4l2_isp_params_block_type_info
@@ -463,6 +512,9 @@ mali_c55_params_block_types_info[] = {
[MALI_C55_PARAM_MESH_SHADING_SELECTION] = {
.size = sizeof(struct mali_c55_params_mesh_shading_selection),
},
+ [MALI_C55_PARAM_BLOCK_CCM] = {
+ .size = sizeof(struct mali_c55_params_ccm),
+ },
};
static_assert(ARRAY_SIZE(mali_c55_params_handlers) ==
diff --git a/include/uapi/linux/media/arm/mali-c55-config.h b/include/uapi/linux/media/arm/mali-c55-config.h
index 3d335f950eeb..0b2085eed81b 100644
--- a/include/uapi/linux/media/arm/mali-c55-config.h
+++ b/include/uapi/linux/media/arm/mali-c55-config.h
@@ -219,6 +219,7 @@ struct mali_c55_stats_buffer {
* @MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP: Auto-white balance gains for AEXP-0 tap
* @MALI_C55_PARAM_MESH_SHADING_CONFIG : Mesh shading tables configuration
* @MALI_C55_PARAM_MESH_SHADING_SELECTION: Mesh shading table selection
+ * @MALI_C55_PARAM_BLOCK_CCM: Colour correction matrix
*/
enum mali_c55_param_block_type {
MALI_C55_PARAM_BLOCK_SENSOR_OFFS,
@@ -232,6 +233,7 @@ enum mali_c55_param_block_type {
MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP,
MALI_C55_PARAM_MESH_SHADING_CONFIG,
MALI_C55_PARAM_MESH_SHADING_SELECTION,
+ MALI_C55_PARAM_BLOCK_CCM,
};
/**
@@ -757,6 +759,42 @@ struct mali_c55_params_mesh_shading_selection {
__u16 mesh_strength;
};
+/**
+ * struct mali_c55_params_ccm - Coefficients, offsets and gains for the colour
+ * correction matrix
+ *
+ * The colour correction module converts images data from a sensor-specific
+ * colour space to known one.
+ *
+ * Colour correction is applied after demosaicing and each pixel is represented
+ * as a column vector of the three RGB colour channels on which the following
+ * operations take place:
+ * 1) An offset is subtracted from each colour channel
+ * 2) Each colour channel is multiplied by a gain
+ * 3) The pixel column vector is multiplied by the colour correction matrix
+ *
+ * This struct allows users to configure the coefficients for CCM and the
+ * per-channel offsets and gains. The nine matrix coefficients are expressed as
+ * signed Q4.8 Sign/Magnitude fixed-point numbers, the three gain multipliers
+ * are expressed as unsigned Q4.8 fixed-point numbers and the three offsets are
+ * expressed as a 12-bit unsigned integers.
+ *
+ * header.type should be set to MALI_C55_PARAM_BLOCK_CCM from
+ * :c:type:`mali_c55_param_block_type`.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @coeffs: 3x3 color conversion matrix coefficients in sign/magnitude
+ * Q4.8 format
+ * @gains: Gains for red, green and blue channels in unsigned Q4.8 format
+ * @offs: Offsets for red, green and blue channels
+ */
+struct mali_c55_params_ccm {
+ struct v4l2_isp_params_block_header header;
+ __u16 coeffs[3][3];
+ __u16 gains[3];
+ __u16 offs[3];
+};
+
/**
* define MALI_C55_PARAMS_MAX_SIZE - Maximum size of all Mali C55 Parameters
*
@@ -780,6 +818,7 @@ struct mali_c55_params_mesh_shading_selection {
sizeof(struct mali_c55_params_awb_config) + \
sizeof(struct mali_c55_params_awb_gains) + \
sizeof(struct mali_c55_params_mesh_shading_config) + \
- sizeof(struct mali_c55_params_mesh_shading_selection))
+ sizeof(struct mali_c55_params_mesh_shading_selection) + \
+ sizeof(struct mali_c55_params_ccm))
#endif /* __UAPI_MALI_C55_CONFIG_H */
--
2.54.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 2/4] media: mali-c55: Implement CCM block validation
2026-06-27 14:29 [PATCH v3 0/4] media: mali-c55: Add support for CCM and Gamma Jacopo Mondi
2026-06-27 14:29 ` [PATCH v3 1/4] media: mali-c55: Add support for CCM Jacopo Mondi
@ 2026-06-27 14:29 ` Jacopo Mondi
2026-06-29 7:52 ` Vincenzo Frascino
2026-06-29 9:57 ` Laurent Pinchart
2026-06-27 14:29 ` [PATCH v3 3/4] media: mali-c55: Add support for RGB Gamma Jacopo Mondi
2026-06-27 14:29 ` [PATCH v3 4/4] media: mali-c55: Implement Gamma block validation Jacopo Mondi
3 siblings, 2 replies; 16+ messages in thread
From: Jacopo Mondi @ 2026-06-27 14:29 UTC (permalink / raw)
To: Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
vincenzo.frascino, linus.walleij, laurent.pinchart, Daniel Scally,
Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Jacopo Mondi
From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Implement validation of CCM block parameters.
CCM coefficients are expressed as 13 bits signed Q4.8 format and their
raw value cannot be higher than 8191 (BIT(13) - 1).
CCM gains are expressed as unsigned 12 bits Q4.8 format and their raw
value cannot be higher than 4095 (BIT(12) - 1).
CCM offsets are 12 bits unsigned integers and their value cannot be
higher than 4095 (BIT(12) - 1).
Validate the parameters provided by userspace using the .block_validate
callback of struct v4l2_isp_params_block_type_info.
Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
---
v3:
- new patch
---
.../media/platform/arm/mali-c55/mali-c55-params.c | 36 ++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
index 0da5215c52c3..333e66ee3923 100644
--- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
+++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
@@ -477,6 +477,41 @@ static const mali_c55_params_handler mali_c55_params_handlers[] = {
[MALI_C55_PARAM_BLOCK_CCM] = &mali_c55_params_ccm,
};
+static int mali_c55_ccm_validate(struct device *dev,
+ const struct v4l2_isp_block_header *block)
+{
+ const struct mali_c55_params_ccm *ccm =
+ (const struct mali_c55_params_ccm *)(block);
+
+ for (unsigned int i = 0; i < 3; i++) {
+
+ for (unsigned int j = 0; j < 3; j++) {
+ /* Coefficients are 13 bits signed Q4.8. */
+ if (ccm->coeffs[i][j] > 8191) {
+ dev_dbg(dev, "Invalid ccm coefficient %u\n",
+ ccm->coeffs[i][j]);
+ return -EINVAL;
+ }
+ }
+
+ /* Gains are 12 bits unsigned Q4.8. */
+ if (ccm->gains[i] > 4095) {
+ dev_dbg(dev, "Invalid ccm gain %u\n",
+ ccm->gains[i]);
+ return -EINVAL;
+ }
+
+ /* Offsets are 12 bits unsigned integers. */
+ if (ccm->offs[i] > 4095) {
+ dev_dbg(dev, "Invalid ccm offset %u\n",
+ ccm->offs[i]);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
static const struct v4l2_isp_params_block_type_info
mali_c55_params_block_types_info[] = {
[MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = {
@@ -514,6 +549,7 @@ mali_c55_params_block_types_info[] = {
},
[MALI_C55_PARAM_BLOCK_CCM] = {
.size = sizeof(struct mali_c55_params_ccm),
+ .block_validate = mali_c55_ccm_validate,
},
};
--
2.54.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH v3 2/4] media: mali-c55: Implement CCM block validation
2026-06-27 14:29 ` [PATCH v3 2/4] media: mali-c55: Implement CCM block validation Jacopo Mondi
@ 2026-06-29 7:52 ` Vincenzo Frascino
2026-06-29 9:15 ` Jacopo Mondi
2026-06-29 9:57 ` Laurent Pinchart
1 sibling, 1 reply; 16+ messages in thread
From: Vincenzo Frascino @ 2026-06-29 7:52 UTC (permalink / raw)
To: Jacopo Mondi, Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
linus.walleij, laurent.pinchart, Daniel Scally,
Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Jacopo Mondi
Hi Jacopo,
thank you for your patch.
On 27/06/2026 15:29, Jacopo Mondi wrote:
> From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
>
> Implement validation of CCM block parameters.
>
> CCM coefficients are expressed as 13 bits signed Q4.8 format and their
> raw value cannot be higher than 8191 (BIT(13) - 1).
>
> CCM gains are expressed as unsigned 12 bits Q4.8 format and their raw
> value cannot be higher than 4095 (BIT(12) - 1).
>
> CCM offsets are 12 bits unsigned integers and their value cannot be
> higher than 4095 (BIT(12) - 1).
>
> Validate the parameters provided by userspace using the .block_validate
> callback of struct v4l2_isp_params_block_type_info.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
>
I have a couple of comments. With this:
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> v3:
> - new patch
> ---
> .../media/platform/arm/mali-c55/mali-c55-params.c | 36 ++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> index 0da5215c52c3..333e66ee3923 100644
> --- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> +++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> @@ -477,6 +477,41 @@ static const mali_c55_params_handler mali_c55_params_handlers[] = {
> [MALI_C55_PARAM_BLOCK_CCM] = &mali_c55_params_ccm,
> };
>
> +static int mali_c55_ccm_validate(struct device *dev,
> + const struct v4l2_isp_block_header *block)
> +{
> + const struct mali_c55_params_ccm *ccm =
> + (const struct mali_c55_params_ccm *)(block);
> +
> + for (unsigned int i = 0; i < 3; i++) {
> +
Nit: extra blank line after the for opening brace, kernel style usually avoids this.
> + for (unsigned int j = 0; j < 3; j++) {
> + /* Coefficients are 13 bits signed Q4.8. */
> + if (ccm->coeffs[i][j] > 8191) {
No magic numbers please :) Maybe use GENMASK(12, 0) or BIT(13) - 1 for
readability and consistency with the commit message, and similarly GENMASK(11,
0) or BIT(12) - 1 for gains and offsets. This also avoids magic numbers in
validation. The same could be applied to the other cases in this patch.
> + dev_dbg(dev, "Invalid ccm coefficient %u\n",
> + ccm->coeffs[i][j]);
> + return -EINVAL;
> + }
> + }
> +
> + /* Gains are 12 bits unsigned Q4.8. */
> + if (ccm->gains[i] > 4095) {
> + dev_dbg(dev, "Invalid ccm gain %u\n",
> + ccm->gains[i]);
> + return -EINVAL;
> + }
> +
> + /* Offsets are 12 bits unsigned integers. */
> + if (ccm->offs[i] > 4095) {
> + dev_dbg(dev, "Invalid ccm offset %u\n",
> + ccm->offs[i]);
> + return -EINVAL;
> + }
> + }
> +
> + return 0;
> +}
> +
> static const struct v4l2_isp_params_block_type_info
> mali_c55_params_block_types_info[] = {
> [MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = {
> @@ -514,6 +549,7 @@ mali_c55_params_block_types_info[] = {
> },
> [MALI_C55_PARAM_BLOCK_CCM] = {
> .size = sizeof(struct mali_c55_params_ccm),
> + .block_validate = mali_c55_ccm_validate,
> },
> };
>
>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH v3 2/4] media: mali-c55: Implement CCM block validation
2026-06-29 7:52 ` Vincenzo Frascino
@ 2026-06-29 9:15 ` Jacopo Mondi
0 siblings, 0 replies; 16+ messages in thread
From: Jacopo Mondi @ 2026-06-29 9:15 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: Jacopo Mondi, Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
linus.walleij, laurent.pinchart, Daniel Scally,
Mauro Carvalho Chehab, linux-media, linux-kernel, Jacopo Mondi
Hi Vincenzo
thanks for the review
On Mon, Jun 29, 2026 at 08:52:09AM +0100, Vincenzo Frascino wrote:
> Hi Jacopo,
>
> thank you for your patch.
>
> On 27/06/2026 15:29, Jacopo Mondi wrote:
> > From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> >
> > Implement validation of CCM block parameters.
> >
> > CCM coefficients are expressed as 13 bits signed Q4.8 format and their
> > raw value cannot be higher than 8191 (BIT(13) - 1).
> >
> > CCM gains are expressed as unsigned 12 bits Q4.8 format and their raw
> > value cannot be higher than 4095 (BIT(12) - 1).
> >
> > CCM offsets are 12 bits unsigned integers and their value cannot be
> > higher than 4095 (BIT(12) - 1).
> >
> > Validate the parameters provided by userspace using the .block_validate
> > callback of struct v4l2_isp_params_block_type_info.
> >
> > Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> >
>
> I have a couple of comments. With this:
>
> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>
> > ---
> > v3:
> > - new patch
> > ---
> > .../media/platform/arm/mali-c55/mali-c55-params.c | 36 ++++++++++++++++++++++
> > 1 file changed, 36 insertions(+)
> >
> > diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> > index 0da5215c52c3..333e66ee3923 100644
> > --- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> > +++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> > @@ -477,6 +477,41 @@ static const mali_c55_params_handler mali_c55_params_handlers[] = {
> > [MALI_C55_PARAM_BLOCK_CCM] = &mali_c55_params_ccm,
> > };
> >
> > +static int mali_c55_ccm_validate(struct device *dev,
> > + const struct v4l2_isp_block_header *block)
> > +{
> > + const struct mali_c55_params_ccm *ccm =
> > + (const struct mali_c55_params_ccm *)(block);
> > +
> > + for (unsigned int i = 0; i < 3; i++) {
> > +
>
> Nit: extra blank line after the for opening brace, kernel style usually avoids this.
>
I know, checkpatch reports this as well, but as I have three
validation 'blocks' it felt nicer this way. I can drop the blank line
though
> > + for (unsigned int j = 0; j < 3; j++) {
> > + /* Coefficients are 13 bits signed Q4.8. */
> > + if (ccm->coeffs[i][j] > 8191) {
>
> No magic numbers please :) Maybe use GENMASK(12, 0) or BIT(13) - 1 for
> readability and consistency with the commit message, and similarly GENMASK(11,
> 0) or BIT(12) - 1 for gains and offsets. This also avoids magic numbers in
> validation. The same could be applied to the other cases in this patch.
>
Nice suggestion. I used comments to explain the meaning of 8191 and
4095 but indeed using GENMASK() is certainly more explicit.
I'll do so.
> > + dev_dbg(dev, "Invalid ccm coefficient %u\n",
> > + ccm->coeffs[i][j]);
> > + return -EINVAL;
> > + }
> > + }
> > +
> > + /* Gains are 12 bits unsigned Q4.8. */
> > + if (ccm->gains[i] > 4095) {
> > + dev_dbg(dev, "Invalid ccm gain %u\n",
> > + ccm->gains[i]);
> > + return -EINVAL;
> > + }
> > +
> > + /* Offsets are 12 bits unsigned integers. */
> > + if (ccm->offs[i] > 4095) {
> > + dev_dbg(dev, "Invalid ccm offset %u\n",
> > + ccm->offs[i]);
> > + return -EINVAL;
> > + }
> > + }
> > +
> > + return 0;
> > +}
> > +
> > static const struct v4l2_isp_params_block_type_info
> > mali_c55_params_block_types_info[] = {
> > [MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = {
> > @@ -514,6 +549,7 @@ mali_c55_params_block_types_info[] = {
> > },
> > [MALI_C55_PARAM_BLOCK_CCM] = {
> > .size = sizeof(struct mali_c55_params_ccm),
> > + .block_validate = mali_c55_ccm_validate,
> > },
> > };
> >
> >
>
> --
> Regards,
> Vincenzo
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 2/4] media: mali-c55: Implement CCM block validation
2026-06-27 14:29 ` [PATCH v3 2/4] media: mali-c55: Implement CCM block validation Jacopo Mondi
2026-06-29 7:52 ` Vincenzo Frascino
@ 2026-06-29 9:57 ` Laurent Pinchart
2026-06-29 11:08 ` Vincenzo Frascino
1 sibling, 1 reply; 16+ messages in thread
From: Laurent Pinchart @ 2026-06-29 9:57 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
vincenzo.frascino, linus.walleij, Daniel Scally,
Mauro Carvalho Chehab, linux-media, linux-kernel, Jacopo Mondi
Hi Jacopo,
Thank you for the patch.
On Sat, Jun 27, 2026 at 04:29:14PM +0200, Jacopo Mondi wrote:
> From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
>
> Implement validation of CCM block parameters.
>
> CCM coefficients are expressed as 13 bits signed Q4.8 format and their
> raw value cannot be higher than 8191 (BIT(13) - 1).
>
> CCM gains are expressed as unsigned 12 bits Q4.8 format and their raw
> value cannot be higher than 4095 (BIT(12) - 1).
>
> CCM offsets are 12 bits unsigned integers and their value cannot be
> higher than 4095 (BIT(12) - 1).
>
> Validate the parameters provided by userspace using the .block_validate
> callback of struct v4l2_isp_params_block_type_info.
I don't think this is needed.
We need to validate parameters that can cause the ISP to malfunction in
ways that requires a system reset, or in ways that cause malfunction of
other system components (e.g. buffer overflows, memory bus lock ups,
...). The rest doesn't need to be validated.
If you want to be cautious, you can just mask the value when writing to
registers, which I think you're doing in patch 1/4.
> Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
>
> ---
> v3:
> - new patch
> ---
> .../media/platform/arm/mali-c55/mali-c55-params.c | 36 ++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> index 0da5215c52c3..333e66ee3923 100644
> --- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> +++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> @@ -477,6 +477,41 @@ static const mali_c55_params_handler mali_c55_params_handlers[] = {
> [MALI_C55_PARAM_BLOCK_CCM] = &mali_c55_params_ccm,
> };
>
> +static int mali_c55_ccm_validate(struct device *dev,
> + const struct v4l2_isp_block_header *block)
> +{
> + const struct mali_c55_params_ccm *ccm =
> + (const struct mali_c55_params_ccm *)(block);
> +
> + for (unsigned int i = 0; i < 3; i++) {
> +
> + for (unsigned int j = 0; j < 3; j++) {
> + /* Coefficients are 13 bits signed Q4.8. */
> + if (ccm->coeffs[i][j] > 8191) {
> + dev_dbg(dev, "Invalid ccm coefficient %u\n",
> + ccm->coeffs[i][j]);
> + return -EINVAL;
> + }
> + }
> +
> + /* Gains are 12 bits unsigned Q4.8. */
> + if (ccm->gains[i] > 4095) {
> + dev_dbg(dev, "Invalid ccm gain %u\n",
> + ccm->gains[i]);
> + return -EINVAL;
> + }
> +
> + /* Offsets are 12 bits unsigned integers. */
> + if (ccm->offs[i] > 4095) {
> + dev_dbg(dev, "Invalid ccm offset %u\n",
> + ccm->offs[i]);
> + return -EINVAL;
> + }
> + }
> +
> + return 0;
> +}
> +
> static const struct v4l2_isp_params_block_type_info
> mali_c55_params_block_types_info[] = {
> [MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = {
> @@ -514,6 +549,7 @@ mali_c55_params_block_types_info[] = {
> },
> [MALI_C55_PARAM_BLOCK_CCM] = {
> .size = sizeof(struct mali_c55_params_ccm),
> + .block_validate = mali_c55_ccm_validate,
> },
> };
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH v3 2/4] media: mali-c55: Implement CCM block validation
2026-06-29 9:57 ` Laurent Pinchart
@ 2026-06-29 11:08 ` Vincenzo Frascino
2026-06-29 11:33 ` Jacopo Mondi
2026-06-29 12:05 ` Laurent Pinchart
0 siblings, 2 replies; 16+ messages in thread
From: Vincenzo Frascino @ 2026-06-29 11:08 UTC (permalink / raw)
To: Laurent Pinchart, Jacopo Mondi
Cc: Nayden.Kanchev, Konstantin Babin, Anthony McGivern, linus.walleij,
Daniel Scally, Mauro Carvalho Chehab, linux-media, linux-kernel,
Jacopo Mondi
Hello Laurent,
On 29/06/2026 10:57, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Sat, Jun 27, 2026 at 04:29:14PM +0200, Jacopo Mondi wrote:
>> From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
>>
>> Implement validation of CCM block parameters.
>>
>> CCM coefficients are expressed as 13 bits signed Q4.8 format and their
>> raw value cannot be higher than 8191 (BIT(13) - 1).
>>
>> CCM gains are expressed as unsigned 12 bits Q4.8 format and their raw
>> value cannot be higher than 4095 (BIT(12) - 1).
>>
>> CCM offsets are 12 bits unsigned integers and their value cannot be
>> higher than 4095 (BIT(12) - 1).
>>
>> Validate the parameters provided by userspace using the .block_validate
>> callback of struct v4l2_isp_params_block_type_info.
> I don't think this is needed.
>
> We need to validate parameters that can cause the ISP to malfunction in
> ways that requires a system reset, or in ways that cause malfunction of
> other system components (e.g. buffer overflows, memory bus lock ups,
> ...). The rest doesn't need to be validated.
>
> If you want to be cautious, you can just mask the value when writing to
> registers, which I think you're doing in patch 1/4.
According to me here is not a matter of being cautious, but of honouring the
contract with the userspace.
If the userspace is doing something wrong it should be notified. The only
reasonable argument against this would be if this code is on a critical path and
the validations have a performance impact.
@Jacopo, can you please confirm if this is the case?
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 2/4] media: mali-c55: Implement CCM block validation
2026-06-29 11:08 ` Vincenzo Frascino
@ 2026-06-29 11:33 ` Jacopo Mondi
2026-06-29 13:07 ` Vincenzo Frascino
2026-06-29 12:05 ` Laurent Pinchart
1 sibling, 1 reply; 16+ messages in thread
From: Jacopo Mondi @ 2026-06-29 11:33 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: Laurent Pinchart, Jacopo Mondi, Nayden.Kanchev, Konstantin Babin,
Anthony McGivern, linus.walleij, Daniel Scally,
Mauro Carvalho Chehab, linux-media, linux-kernel, Jacopo Mondi
Hi Vincenzo
On Mon, Jun 29, 2026 at 12:08:08PM +0100, Vincenzo Frascino wrote:
> Hello Laurent,
>
> On 29/06/2026 10:57, Laurent Pinchart wrote:
> > Hi Jacopo,
> >
> > Thank you for the patch.
> >
> > On Sat, Jun 27, 2026 at 04:29:14PM +0200, Jacopo Mondi wrote:
> >> From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> >>
> >> Implement validation of CCM block parameters.
> >>
> >> CCM coefficients are expressed as 13 bits signed Q4.8 format and their
> >> raw value cannot be higher than 8191 (BIT(13) - 1).
> >>
> >> CCM gains are expressed as unsigned 12 bits Q4.8 format and their raw
> >> value cannot be higher than 4095 (BIT(12) - 1).
> >>
> >> CCM offsets are 12 bits unsigned integers and their value cannot be
> >> higher than 4095 (BIT(12) - 1).
> >>
> >> Validate the parameters provided by userspace using the .block_validate
> >> callback of struct v4l2_isp_params_block_type_info.
> > I don't think this is needed.
> >
> > We need to validate parameters that can cause the ISP to malfunction in
> > ways that requires a system reset, or in ways that cause malfunction of
> > other system components (e.g. buffer overflows, memory bus lock ups,
> > ...). The rest doesn't need to be validated.
> >
> > If you want to be cautious, you can just mask the value when writing to
> > registers, which I think you're doing in patch 1/4.
>
> According to me here is not a matter of being cautious, but of honouring the
> contract with the userspace.
>
> If the userspace is doing something wrong it should be notified. The only
> reasonable argument against this would be if this code is on a critical path and
> the validations have a performance impact.
>
> @Jacopo, can you please confirm if this is the case?
validation happens in the qbuf ioctl handler call path (and in the
prepare_buf handler too).
I don't think it's strictly an hot path but we're in ioctl context and
I think it makes sense to minimize the time it takes to complete the
ioctl call.
Thing is, if we go down the path of validating everything, then why
would you validate Gamma LUT tables of 129 entries but not LSC tables
of 3k values ?
I feel it's hard and quite subjective to draw a line on when it's too
costly to perform validation or not, and I think the severity of the
potential issue caused by a wrong parameter is a more suitable metric
to decide what to validate ?
>
>
> --
> Regards,
> Vincenzo
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 2/4] media: mali-c55: Implement CCM block validation
2026-06-29 11:33 ` Jacopo Mondi
@ 2026-06-29 13:07 ` Vincenzo Frascino
0 siblings, 0 replies; 16+ messages in thread
From: Vincenzo Frascino @ 2026-06-29 13:07 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Laurent Pinchart, Nayden.Kanchev, Konstantin Babin,
Anthony McGivern, linus.walleij, Daniel Scally,
Mauro Carvalho Chehab, linux-media, linux-kernel, Jacopo Mondi
Hi Jacopo,
Thanks for the clarification.
On 29/06/2026 12:33, Jacopo Mondi wrote:
> I don't think it's strictly an hot path but we're in ioctl context and
> I think it makes sense to minimize the time it takes to complete the
> ioctl call.
I agree with what you are saying on the validation of the paramenters, I am fine
with dropping the checks.
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 2/4] media: mali-c55: Implement CCM block validation
2026-06-29 11:08 ` Vincenzo Frascino
2026-06-29 11:33 ` Jacopo Mondi
@ 2026-06-29 12:05 ` Laurent Pinchart
1 sibling, 0 replies; 16+ messages in thread
From: Laurent Pinchart @ 2026-06-29 12:05 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: Jacopo Mondi, Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
linus.walleij, Daniel Scally, Mauro Carvalho Chehab, linux-media,
linux-kernel, Jacopo Mondi
On Mon, Jun 29, 2026 at 12:08:08PM +0100, Vincenzo Frascino wrote:
> On 29/06/2026 10:57, Laurent Pinchart wrote:
> > On Sat, Jun 27, 2026 at 04:29:14PM +0200, Jacopo Mondi wrote:
> >> From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> >>
> >> Implement validation of CCM block parameters.
> >>
> >> CCM coefficients are expressed as 13 bits signed Q4.8 format and their
> >> raw value cannot be higher than 8191 (BIT(13) - 1).
> >>
> >> CCM gains are expressed as unsigned 12 bits Q4.8 format and their raw
> >> value cannot be higher than 4095 (BIT(12) - 1).
> >>
> >> CCM offsets are 12 bits unsigned integers and their value cannot be
> >> higher than 4095 (BIT(12) - 1).
> >>
> >> Validate the parameters provided by userspace using the .block_validate
> >> callback of struct v4l2_isp_params_block_type_info.
> > I don't think this is needed.
> >
> > We need to validate parameters that can cause the ISP to malfunction in
> > ways that requires a system reset, or in ways that cause malfunction of
> > other system components (e.g. buffer overflows, memory bus lock ups,
> > ...). The rest doesn't need to be validated.
> >
> > If you want to be cautious, you can just mask the value when writing to
> > registers, which I think you're doing in patch 1/4.
>
> According to me here is not a matter of being cautious, but of honouring the
> contract with the userspace.
>
> If the userspace is doing something wrong it should be notified. The only
> reasonable argument against this would be if this code is on a critical path and
> the validations have a performance impact.
I don't agree with this. As long as it doesn't have an impact on other
parts of the system, there's no need to notify userspace. It's purely a
userspace issue, it's pointless to waste CPU cycles every frame.
> @Jacopo, can you please confirm if this is the case?
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 3/4] media: mali-c55: Add support for RGB Gamma
2026-06-27 14:29 [PATCH v3 0/4] media: mali-c55: Add support for CCM and Gamma Jacopo Mondi
2026-06-27 14:29 ` [PATCH v3 1/4] media: mali-c55: Add support for CCM Jacopo Mondi
2026-06-27 14:29 ` [PATCH v3 2/4] media: mali-c55: Implement CCM block validation Jacopo Mondi
@ 2026-06-27 14:29 ` Jacopo Mondi
2026-06-27 14:29 ` [PATCH v3 4/4] media: mali-c55: Implement Gamma block validation Jacopo Mondi
3 siblings, 0 replies; 16+ messages in thread
From: Jacopo Mondi @ 2026-06-27 14:29 UTC (permalink / raw)
To: Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
vincenzo.frascino, linus.walleij, laurent.pinchart, Daniel Scally,
Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Jacopo Mondi, Linus Walleij
From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Add support for Gamma curve correction for the Mali C55 ISP.
Define a new block in the uAPI using the extensible v4l2-isp format and
implement support for configuring the RGB Gamma parameters in the
mali-c55 parameters handler.
While at it, rename the MALI_C55_REG_GAMMA_GAINS_[1|2] register name
to MALI_C55_REG_GAMMA_GAINS_[RG|B] and the
MALI_C55_REG_GAMMA_OFFSETS_[1|2] register name to
MALI_C55_REG_GAMMA_OFFSETS_[RG|B] to better clarify their intent.
Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
---
v3:
- Rename register as suggested by Linus
- Remove an additional tab and fix gamma maximum value in uapi as
suggested by Vincenzo
v2:
- Remove unused 'rgb_enable' member
- Address checkpatch issues
---
.../media/platform/arm/mali-c55/mali-c55-params.c | 75 ++++++++++++++++++++++
.../platform/arm/mali-c55/mali-c55-registers.h | 13 ++--
include/uapi/linux/media/arm/mali-c55-config.h | 45 ++++++++++++-
3 files changed, 128 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
index 333e66ee3923..5857e9c2daf7 100644
--- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
+++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
@@ -47,6 +47,8 @@
* @shading_config: For header->type == MALI_C55_PARAM_MESH_SHADING_CONFIG
* @shading_selection: For header->type == MALI_C55_PARAM_MESH_SHADING_SELECTION
* @ccm: For header->type == MALI_C55_PARAM_BLOCK_CCM
+ * @gamma: For header->type == MALI_C55_PARAM_BLOCK_GAMMA_FR and
+ * header->type = MALI_C55_PARAM_BLOCK_GAMMA_DS
* @data: Allows easy initialisation of a union variable with a
* pointer into a __u8 array.
*/
@@ -61,6 +63,7 @@ union mali_c55_params_block {
const struct mali_c55_params_mesh_shading_config *shading_config;
const struct mali_c55_params_mesh_shading_selection *shading_selection;
const struct mali_c55_params_ccm *ccm;
+ const struct mali_c55_params_gamma *gamma;
const __u8 *data;
};
@@ -462,6 +465,70 @@ static void mali_c55_params_ccm(struct mali_c55 *mali_c55,
mali_c55_ctx_write(mali_c55, MALI_C55_REG_CCM_ENABLE, 1);
}
+static void mali_c55_params_gamma(struct mali_c55 *mali_c55,
+ union mali_c55_params_block block,
+ __u32 offset, __u32 lut_base)
+{
+ const struct mali_c55_params_gamma *params = block.gamma;
+
+ if (block.header->flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE) {
+ mali_c55_ctx_update_bits(mali_c55,
+ MALI_C55_REG_GAMMA_RGB_ENABLE + offset,
+ MALI_C55_GAMMA_ENABLE_MASK, 0x00);
+ return;
+ }
+
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_GAMMA_GAINS_RG + offset,
+ MALI_C55_GAMMA_GAIN_R_MASK, params->gains[0]);
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_GAMMA_GAINS_RG + offset,
+ MALI_C55_GAMMA_GAIN_G_MASK,
+ MALI_C55_GAMMA_GAIN_G(params->gains[1]));
+ mali_c55_ctx_update_bits(mali_c55, MALI_C55_REG_GAMMA_GAINS_B + offset,
+ MALI_C55_GAMMA_GAIN_B_MASK, params->gains[2]);
+ mali_c55_ctx_update_bits(mali_c55,
+ MALI_C55_REG_GAMMA_OFFSETS_RG + offset,
+ MALI_C55_GAMMA_OFFSET_R_MASK,
+ params->offs[0]);
+ mali_c55_ctx_update_bits(mali_c55,
+ MALI_C55_REG_GAMMA_OFFSETS_RG + offset,
+ MALI_C55_GAMMA_OFFSET_G_MASK,
+ MALI_C55_GAMMA_OFFSET_G(params->offs[1]));
+ mali_c55_ctx_update_bits(mali_c55,
+ MALI_C55_REG_GAMMA_OFFSETS_B + offset,
+ MALI_C55_GAMMA_OFFSET_B_MASK,
+ params->offs[2]);
+
+ for (unsigned int i = 0; i < MALI_C55_NUM_GAMMA_LUT_ELEMENTS; i++) {
+ __u32 addr = lut_base + (i * 4);
+
+ mali_c55_ctx_write(mali_c55, addr, params->lut[i]);
+ }
+
+ mali_c55_ctx_update_bits(mali_c55,
+ MALI_C55_REG_GAMMA_RGB_ENABLE + offset,
+ MALI_C55_GAMMA_ENABLE_MASK, 0x1);
+}
+
+static void mali_c55_params_gamma_fr(struct mali_c55 *mali_c55,
+ union mali_c55_params_block block)
+{
+ return mali_c55_params_gamma(mali_c55, block,
+ MALI_C55_CAP_DEV_FR_REG_OFFSET,
+ MALI_C55_REG_FR_GAMMA_RGB_MEM);
+}
+
+static void mali_c55_params_gamma_ds(struct mali_c55 *mali_c55,
+ union mali_c55_params_block block)
+{
+ /* We cannot apply parameters to DS if it is not fitted. */
+ if (!(mali_c55->capabilities & MALI_C55_GPS_DS_PIPE_FITTED))
+ return;
+
+ return mali_c55_params_gamma(mali_c55, block,
+ MALI_C55_CAP_DEV_DS_REG_OFFSET,
+ MALI_C55_REG_DS_GAMMA_RGB_MEM);
+}
+
static const mali_c55_params_handler mali_c55_params_handlers[] = {
[MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = &mali_c55_params_sensor_offs,
[MALI_C55_PARAM_BLOCK_AEXP_HIST] = &mali_c55_params_aexp_hist,
@@ -475,6 +542,8 @@ static const mali_c55_params_handler mali_c55_params_handlers[] = {
[MALI_C55_PARAM_MESH_SHADING_CONFIG] = &mali_c55_params_lsc_config,
[MALI_C55_PARAM_MESH_SHADING_SELECTION] = &mali_c55_params_lsc_selection,
[MALI_C55_PARAM_BLOCK_CCM] = &mali_c55_params_ccm,
+ [MALI_C55_PARAM_BLOCK_GAMMA_FR] = &mali_c55_params_gamma_fr,
+ [MALI_C55_PARAM_BLOCK_GAMMA_DS] = &mali_c55_params_gamma_ds,
};
static int mali_c55_ccm_validate(struct device *dev,
@@ -551,6 +620,12 @@ mali_c55_params_block_types_info[] = {
.size = sizeof(struct mali_c55_params_ccm),
.block_validate = mali_c55_ccm_validate,
},
+ [MALI_C55_PARAM_BLOCK_GAMMA_FR] = {
+ .size = sizeof(struct mali_c55_params_gamma),
+ },
+ [MALI_C55_PARAM_BLOCK_GAMMA_DS] = {
+ .size = sizeof(struct mali_c55_params_gamma),
+ },
};
static_assert(ARRAY_SIZE(mali_c55_params_handlers) ==
diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-registers.h b/drivers/media/platform/arm/mali-c55/mali-c55-registers.h
index f098effde7b4..7d9f51b53448 100644
--- a/drivers/media/platform/arm/mali-c55/mali-c55-registers.h
+++ b/drivers/media/platform/arm/mali-c55/mali-c55-registers.h
@@ -422,15 +422,17 @@ enum mali_c55_interrupts {
#define MALI_C55_REG_GAMMA_RGB_ENABLE 0x1c064
#define MALI_C55_GAMMA_ENABLE_MASK BIT(0)
-#define MALI_C55_REG_GAMMA_GAINS_1 0x1c068
+#define MALI_C55_REG_GAMMA_GAINS_RG 0x1c068
#define MALI_C55_GAMMA_GAIN_R_MASK GENMASK(11, 0)
#define MALI_C55_GAMMA_GAIN_G_MASK GENMASK(27, 16)
-#define MALI_C55_REG_GAMMA_GAINS_2 0x1c06c
+#define MALI_C55_GAMMA_GAIN_G(x) ((x) << 16)
+#define MALI_C55_REG_GAMMA_GAINS_B 0x1c06c
#define MALI_C55_GAMMA_GAIN_B_MASK GENMASK(11, 0)
-#define MALI_C55_REG_GAMMA_OFFSETS_1 0x1c070
+#define MALI_C55_REG_GAMMA_OFFSETS_RG 0x1c070
#define MALI_C55_GAMMA_OFFSET_R_MASK GENMASK(11, 0)
#define MALI_C55_GAMMA_OFFSET_G_MASK GENMASK(27, 16)
-#define MALI_C55_REG_GAMMA_OFFSETS_2 0x1c074
+#define MALI_C55_GAMMA_OFFSET_G(x) ((x) << 16)
+#define MALI_C55_REG_GAMMA_OFFSETS_B 0x1c074
#define MALI_C55_GAMMA_OFFSET_B_MASK GENMASK(11, 0)
/*
@@ -441,6 +443,9 @@ enum mali_c55_interrupts {
#define MALI_C55_REG_FR_GAMMA_RGB_ENABLE 0x1c064
#define MALI_C55_REG_DS_GAMMA_RGB_ENABLE 0x1c1d8
+#define MALI_C55_REG_FR_GAMMA_RGB_MEM 0x18280
+#define MALI_C55_REG_DS_GAMMA_RGB_MEM 0x18484
+
#define MALI_C55_REG_FR_SCALER_HFILT 0x34a8
#define MALI_C55_REG_FR_SCALER_VFILT 0x44a8
#define MALI_C55_REG_DS_SCALER_HFILT 0x14a8
diff --git a/include/uapi/linux/media/arm/mali-c55-config.h b/include/uapi/linux/media/arm/mali-c55-config.h
index 0b2085eed81b..fc345809f746 100644
--- a/include/uapi/linux/media/arm/mali-c55-config.h
+++ b/include/uapi/linux/media/arm/mali-c55-config.h
@@ -36,6 +36,9 @@
*/
#define MALI_C55_MAX_ZONES (15 * 15)
+/* Number of RGB gamma LUT entries. */
+#define MALI_C55_NUM_GAMMA_LUT_ELEMENTS 129
+
/**
* struct mali_c55_ae_1024bin_hist - Auto Exposure 1024-bin histogram statistics
*
@@ -220,6 +223,8 @@ struct mali_c55_stats_buffer {
* @MALI_C55_PARAM_MESH_SHADING_CONFIG : Mesh shading tables configuration
* @MALI_C55_PARAM_MESH_SHADING_SELECTION: Mesh shading table selection
* @MALI_C55_PARAM_BLOCK_CCM: Colour correction matrix
+ * @MALI_C55_PARAM_BLOCK_GAMMA_FR: Gamma gain and offset for FR pipe
+ * @MALI_C55_PARAM_BLOCK_GAMMA_DS: Gamma gain and offset for DS pipe
*/
enum mali_c55_param_block_type {
MALI_C55_PARAM_BLOCK_SENSOR_OFFS,
@@ -234,6 +239,8 @@ enum mali_c55_param_block_type {
MALI_C55_PARAM_MESH_SHADING_CONFIG,
MALI_C55_PARAM_MESH_SHADING_SELECTION,
MALI_C55_PARAM_BLOCK_CCM,
+ MALI_C55_PARAM_BLOCK_GAMMA_FR,
+ MALI_C55_PARAM_BLOCK_GAMMA_DS,
};
/**
@@ -795,6 +802,40 @@ struct mali_c55_params_ccm {
__u16 offs[3];
};
+/**
+ * struct mali_c55_params_gamma - RGB Gamma correction
+ *
+ * Gamma correction is used to program a standard gamma curve such as the sRGB
+ * one. It provides gains and offsets to implement contrast adjustments.
+ *
+ * Gamma correction is applied on both the FR and DS pipes separately in the RGB
+ * colour domain where the following operations take place:
+ * 1) An offset is subtracted from each colour channel
+ * 2) Each colour channel is multiplied by a gain
+ * 3) The Gamma LUT is applied to each colour channel
+ *
+ * The Gamma LUT has 129 entries where each node is an unsigned 12 bit number.
+ * It is expected that LUT[0]=0 and LUT[128]=0xfff, with the other 127 values
+ * defining the Gamma correction curve.
+ *
+ * As one Gamma correction block is available on both the FR and DS pipes, the
+ * header.type field should be set to one of either
+ * MALI_C55_PARAM_BLOCK_GAMMA_FR or MALI_C55_PARAM_BLOCK_GAMMA_DS from
+ * :c:type:`mali_c55_param_block_type`.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @gains: Gains for the red, green and blue channel in unsigned Q4.8 format
+ * @offs: Offsets subtracted from the red, green and blue channels
+ * in unsigned 12-bit format
+ * @lut: 129-node Gamma LUT in u0.12 format
+ */
+struct mali_c55_params_gamma {
+ struct v4l2_isp_params_block_header header;
+ __u16 gains[3];
+ __u16 offs[3];
+ __u32 lut[MALI_C55_NUM_GAMMA_LUT_ELEMENTS];
+};
+
/**
* define MALI_C55_PARAMS_MAX_SIZE - Maximum size of all Mali C55 Parameters
*
@@ -819,6 +860,8 @@ struct mali_c55_params_ccm {
sizeof(struct mali_c55_params_awb_gains) + \
sizeof(struct mali_c55_params_mesh_shading_config) + \
sizeof(struct mali_c55_params_mesh_shading_selection) + \
- sizeof(struct mali_c55_params_ccm))
+ sizeof(struct mali_c55_params_ccm) + \
+ sizeof(struct mali_c55_params_gamma) + \
+ sizeof(struct mali_c55_params_gamma))
#endif /* __UAPI_MALI_C55_CONFIG_H */
--
2.54.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 4/4] media: mali-c55: Implement Gamma block validation
2026-06-27 14:29 [PATCH v3 0/4] media: mali-c55: Add support for CCM and Gamma Jacopo Mondi
` (2 preceding siblings ...)
2026-06-27 14:29 ` [PATCH v3 3/4] media: mali-c55: Add support for RGB Gamma Jacopo Mondi
@ 2026-06-27 14:29 ` Jacopo Mondi
2026-06-29 8:10 ` Vincenzo Frascino
2026-06-29 10:20 ` Laurent Pinchart
3 siblings, 2 replies; 16+ messages in thread
From: Jacopo Mondi @ 2026-06-27 14:29 UTC (permalink / raw)
To: Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
vincenzo.frascino, linus.walleij, laurent.pinchart, Daniel Scally,
Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Jacopo Mondi
From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Implement validation of Gamma block parameters.
Gamma gains are expressed as unsigned 12 bits Q4.8 format and their raw
value cannot be higher than 4095 (BIT(12) - 1).
Gamma offsets are 12 bits unsigned integers and their value cannot be
higher than 4095 (BIT(12) - 1).
The Gamma LUT table is expected to have 0 as first member and 0xfff
as last member.
Validate the parameters provided by userspace using the .block_validate
callback of struct v4l2_isp_params_block_type_info.
Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
---
v3:
- new patch
---
.../media/platform/arm/mali-c55/mali-c55-params.c | 34 ++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
index 5857e9c2daf7..e9ab0e2dee15 100644
--- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
+++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
@@ -581,6 +581,38 @@ static int mali_c55_ccm_validate(struct device *dev,
return 0;
}
+static int mali_c55_gamma_validate(struct device *dev,
+ const struct v4l2_isp_block_header *block)
+{
+ const struct mali_c55_params_gamma *gamma =
+ (const struct mali_c55_params_gamma *)(block);
+
+ for (unsigned int i = 0; i < 3; i++) {
+ /* Gains are 12 bits unsigned Q4.8. */
+ if (gamma->gains[i] > 4095) {
+ dev_dbg(dev, "Invalid gain value %u\n",
+ gamma->gains[i]);
+ return -EINVAL;
+ }
+
+ /* Offsets are 12 bits unsigned integers. */
+ if (gamma->offs[i] > 4095) {
+ dev_dbg(dev, "Invalid offset value %u\n",
+ gamma->offs[i]);
+ return -EINVAL;
+ }
+ }
+
+ /* Check the first and last gamma lut entries match the expectations. */
+ if (gamma->lut[0] != 0 ||
+ gamma->lut[MALI_C55_NUM_GAMMA_LUT_ELEMENTS - 1] != 0xfff) {
+ dev_dbg(dev, "Invalid Gamma LUT table\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static const struct v4l2_isp_params_block_type_info
mali_c55_params_block_types_info[] = {
[MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = {
@@ -622,9 +654,11 @@ mali_c55_params_block_types_info[] = {
},
[MALI_C55_PARAM_BLOCK_GAMMA_FR] = {
.size = sizeof(struct mali_c55_params_gamma),
+ .block_validate = mali_c55_gamma_validate,
},
[MALI_C55_PARAM_BLOCK_GAMMA_DS] = {
.size = sizeof(struct mali_c55_params_gamma),
+ .block_validate = mali_c55_gamma_validate,
},
};
--
2.54.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH v3 4/4] media: mali-c55: Implement Gamma block validation
2026-06-27 14:29 ` [PATCH v3 4/4] media: mali-c55: Implement Gamma block validation Jacopo Mondi
@ 2026-06-29 8:10 ` Vincenzo Frascino
2026-06-29 9:19 ` Jacopo Mondi
2026-06-29 10:20 ` Laurent Pinchart
1 sibling, 1 reply; 16+ messages in thread
From: Vincenzo Frascino @ 2026-06-29 8:10 UTC (permalink / raw)
To: Jacopo Mondi, Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
linus.walleij, laurent.pinchart, Daniel Scally,
Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Jacopo Mondi
Hi Jacopo,
thank you for your patch.
On 27/06/2026 15:29, Jacopo Mondi wrote:
> From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
>
> Implement validation of Gamma block parameters.
>
> Gamma gains are expressed as unsigned 12 bits Q4.8 format and their raw
> value cannot be higher than 4095 (BIT(12) - 1).
>
> Gamma offsets are 12 bits unsigned integers and their value cannot be
> higher than 4095 (BIT(12) - 1).
>
> The Gamma LUT table is expected to have 0 as first member and 0xfff
> as last member.
>
> Validate the parameters provided by userspace using the .block_validate
> callback of struct v4l2_isp_params_block_type_info.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
>
Looks good overall. I have just one comment. With this:
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> v3:
> - new patch
> ---
> .../media/platform/arm/mali-c55/mali-c55-params.c | 34 ++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> index 5857e9c2daf7..e9ab0e2dee15 100644
> --- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> +++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> @@ -581,6 +581,38 @@ static int mali_c55_ccm_validate(struct device *dev,
> return 0;
> }
>
> +static int mali_c55_gamma_validate(struct device *dev,
> + const struct v4l2_isp_block_header *block)
> +{
> + const struct mali_c55_params_gamma *gamma =
> + (const struct mali_c55_params_gamma *)(block);
> +
> + for (unsigned int i = 0; i < 3; i++) {
> + /* Gains are 12 bits unsigned Q4.8. */
> + if (gamma->gains[i] > 4095) {
> + dev_dbg(dev, "Invalid gain value %u\n",
> + gamma->gains[i]);
> + return -EINVAL;
> + }
> +
> + /* Offsets are 12 bits unsigned integers. */
> + if (gamma->offs[i] > 4095) {
> + dev_dbg(dev, "Invalid offset value %u\n",
> + gamma->offs[i]);
> + return -EINVAL;
> + }
> + }
> +
> + /* Check the first and last gamma lut entries match the expectations. */
> + if (gamma->lut[0] != 0 ||
> + gamma->lut[MALI_C55_NUM_GAMMA_LUT_ELEMENTS - 1] != 0xfff) {
I am still learning about these things and might be wrong. Should not we also
validate that intermediate LUT entries are monotonic and non-decreasing?
> + dev_dbg(dev, "Invalid Gamma LUT table\n");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> static const struct v4l2_isp_params_block_type_info
> mali_c55_params_block_types_info[] = {
> [MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = {
> @@ -622,9 +654,11 @@ mali_c55_params_block_types_info[] = {
> },
> [MALI_C55_PARAM_BLOCK_GAMMA_FR] = {
> .size = sizeof(struct mali_c55_params_gamma),
> + .block_validate = mali_c55_gamma_validate,
> },
> [MALI_C55_PARAM_BLOCK_GAMMA_DS] = {
> .size = sizeof(struct mali_c55_params_gamma),
> + .block_validate = mali_c55_gamma_validate,
> },
> };
>
>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH v3 4/4] media: mali-c55: Implement Gamma block validation
2026-06-29 8:10 ` Vincenzo Frascino
@ 2026-06-29 9:19 ` Jacopo Mondi
2026-06-29 10:14 ` Vincenzo Frascino
0 siblings, 1 reply; 16+ messages in thread
From: Jacopo Mondi @ 2026-06-29 9:19 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: Jacopo Mondi, Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
linus.walleij, laurent.pinchart, Daniel Scally,
Mauro Carvalho Chehab, linux-media, linux-kernel, Jacopo Mondi
Hi Vincenzo
On Mon, Jun 29, 2026 at 09:10:39AM +0100, Vincenzo Frascino wrote:
> Hi Jacopo,
>
> thank you for your patch.
>
> On 27/06/2026 15:29, Jacopo Mondi wrote:
> > From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> >
> > Implement validation of Gamma block parameters.
> >
> > Gamma gains are expressed as unsigned 12 bits Q4.8 format and their raw
> > value cannot be higher than 4095 (BIT(12) - 1).
> >
> > Gamma offsets are 12 bits unsigned integers and their value cannot be
> > higher than 4095 (BIT(12) - 1).
> >
> > The Gamma LUT table is expected to have 0 as first member and 0xfff
> > as last member.
> >
> > Validate the parameters provided by userspace using the .block_validate
> > callback of struct v4l2_isp_params_block_type_info.
> >
> > Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> >
>
> Looks good overall. I have just one comment. With this:
>
> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>
> > ---
> > v3:
> > - new patch
> > ---
> > .../media/platform/arm/mali-c55/mali-c55-params.c | 34 ++++++++++++++++++++++
> > 1 file changed, 34 insertions(+)
> >
> > diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> > index 5857e9c2daf7..e9ab0e2dee15 100644
> > --- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> > +++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> > @@ -581,6 +581,38 @@ static int mali_c55_ccm_validate(struct device *dev,
> > return 0;
> > }
> >
> > +static int mali_c55_gamma_validate(struct device *dev,
> > + const struct v4l2_isp_block_header *block)
> > +{
> > + const struct mali_c55_params_gamma *gamma =
> > + (const struct mali_c55_params_gamma *)(block);
> > +
> > + for (unsigned int i = 0; i < 3; i++) {
> > + /* Gains are 12 bits unsigned Q4.8. */
> > + if (gamma->gains[i] > 4095) {
> > + dev_dbg(dev, "Invalid gain value %u\n",
> > + gamma->gains[i]);
> > + return -EINVAL;
> > + }
> > +
> > + /* Offsets are 12 bits unsigned integers. */
> > + if (gamma->offs[i] > 4095) {
> > + dev_dbg(dev, "Invalid offset value %u\n",
> > + gamma->offs[i]);
> > + return -EINVAL;
> > + }
> > + }
> > +
> > + /* Check the first and last gamma lut entries match the expectations. */
> > + if (gamma->lut[0] != 0 ||
> > + gamma->lut[MALI_C55_NUM_GAMMA_LUT_ELEMENTS - 1] != 0xfff) {
>
> I am still learning about these things and might be wrong. Should not we also
> validate that intermediate LUT entries are monotonic and non-decreasing?
>
Eh, good question.
This all new for everyone, as this would be the first user of
'block_validate()' in tree.
Here I checked only the first and last member because it seems like a
good compromise between performances and correctness. This function
might potentially run for every frame (where a CCM table is specified
by userspace), so I'm a bit unsure how far we should go with
validation.
I kept these two patches broken out from the ones that introduce the
uapi specifically to get feedback on this. Maybe I'm overconcerned
about the additional cost of validation ?
> > + dev_dbg(dev, "Invalid Gamma LUT table\n");
> > + return -EINVAL;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > static const struct v4l2_isp_params_block_type_info
> > mali_c55_params_block_types_info[] = {
> > [MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = {
> > @@ -622,9 +654,11 @@ mali_c55_params_block_types_info[] = {
> > },
> > [MALI_C55_PARAM_BLOCK_GAMMA_FR] = {
> > .size = sizeof(struct mali_c55_params_gamma),
> > + .block_validate = mali_c55_gamma_validate,
> > },
> > [MALI_C55_PARAM_BLOCK_GAMMA_DS] = {
> > .size = sizeof(struct mali_c55_params_gamma),
> > + .block_validate = mali_c55_gamma_validate,
> > },
> > };
> >
> >
>
> --
> Regards,
> Vincenzo
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH v3 4/4] media: mali-c55: Implement Gamma block validation
2026-06-29 9:19 ` Jacopo Mondi
@ 2026-06-29 10:14 ` Vincenzo Frascino
0 siblings, 0 replies; 16+ messages in thread
From: Vincenzo Frascino @ 2026-06-29 10:14 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Nayden.Kanchev, Konstantin Babin, Anthony McGivern, linus.walleij,
laurent.pinchart, Daniel Scally, Mauro Carvalho Chehab,
linux-media, linux-kernel, Jacopo Mondi
Hi Jacopo,
On 29/06/2026 10:19, Jacopo Mondi wrote:
>>> + /* Check the first and last gamma lut entries match the expectations. */
>>> + if (gamma->lut[0] != 0 ||
>>> + gamma->lut[MALI_C55_NUM_GAMMA_LUT_ELEMENTS - 1] != 0xfff) {
>> I am still learning about these things and might be wrong. Should not we also
>> validate that intermediate LUT entries are monotonic and non-decreasing?
>>
> Eh, good question.
>
> This all new for everyone, as this would be the first user of
> 'block_validate()' in tree.
>
> Here I checked only the first and last member because it seems like a
> good compromise between performances and correctness. This function
> might potentially run for every frame (where a CCM table is specified
> by userspace), so I'm a bit unsure how far we should go with
> validation.
>
> I kept these two patches broken out from the ones that introduce the
> uapi specifically to get feedback on this. Maybe I'm overconcerned
> about the additional cost of validation ?
I am not sure either. As a strategy I always prefer to be on the safe side hence
my comment. Is there any way we could come up with a comparative analysis and
check what's the impact of these additional costs? This should answer my
question I guess.
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 4/4] media: mali-c55: Implement Gamma block validation
2026-06-27 14:29 ` [PATCH v3 4/4] media: mali-c55: Implement Gamma block validation Jacopo Mondi
2026-06-29 8:10 ` Vincenzo Frascino
@ 2026-06-29 10:20 ` Laurent Pinchart
1 sibling, 0 replies; 16+ messages in thread
From: Laurent Pinchart @ 2026-06-29 10:20 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Nayden.Kanchev, Konstantin Babin, Anthony McGivern,
vincenzo.frascino, linus.walleij, Daniel Scally,
Mauro Carvalho Chehab, linux-media, linux-kernel, Jacopo Mondi
On Sat, Jun 27, 2026 at 04:29:16PM +0200, Jacopo Mondi wrote:
> From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
>
> Implement validation of Gamma block parameters.
>
> Gamma gains are expressed as unsigned 12 bits Q4.8 format and their raw
> value cannot be higher than 4095 (BIT(12) - 1).
>
> Gamma offsets are 12 bits unsigned integers and their value cannot be
> higher than 4095 (BIT(12) - 1).
>
> The Gamma LUT table is expected to have 0 as first member and 0xfff
> as last member.
>
> Validate the parameters provided by userspace using the .block_validate
> callback of struct v4l2_isp_params_block_type_info.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
For the same reasons as 3/4, I'd drop this patch.
> ---
> v3:
> - new patch
> ---
> .../media/platform/arm/mali-c55/mali-c55-params.c | 34 ++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> index 5857e9c2daf7..e9ab0e2dee15 100644
> --- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> +++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> @@ -581,6 +581,38 @@ static int mali_c55_ccm_validate(struct device *dev,
> return 0;
> }
>
> +static int mali_c55_gamma_validate(struct device *dev,
> + const struct v4l2_isp_block_header *block)
> +{
> + const struct mali_c55_params_gamma *gamma =
> + (const struct mali_c55_params_gamma *)(block);
> +
> + for (unsigned int i = 0; i < 3; i++) {
> + /* Gains are 12 bits unsigned Q4.8. */
> + if (gamma->gains[i] > 4095) {
> + dev_dbg(dev, "Invalid gain value %u\n",
> + gamma->gains[i]);
> + return -EINVAL;
> + }
> +
> + /* Offsets are 12 bits unsigned integers. */
> + if (gamma->offs[i] > 4095) {
> + dev_dbg(dev, "Invalid offset value %u\n",
> + gamma->offs[i]);
> + return -EINVAL;
> + }
> + }
> +
> + /* Check the first and last gamma lut entries match the expectations. */
> + if (gamma->lut[0] != 0 ||
> + gamma->lut[MALI_C55_NUM_GAMMA_LUT_ELEMENTS - 1] != 0xfff) {
> + dev_dbg(dev, "Invalid Gamma LUT table\n");
> + return -EINVAL;
> + }
You can possibly hardcode the first and last values to 0 and 0xfff
respectively in mali_c55_params_gamma() if you want to guard against
invalid values being programmed in registers.
> +
> + return 0;
> +}
> +
> static const struct v4l2_isp_params_block_type_info
> mali_c55_params_block_types_info[] = {
> [MALI_C55_PARAM_BLOCK_SENSOR_OFFS] = {
> @@ -622,9 +654,11 @@ mali_c55_params_block_types_info[] = {
> },
> [MALI_C55_PARAM_BLOCK_GAMMA_FR] = {
> .size = sizeof(struct mali_c55_params_gamma),
> + .block_validate = mali_c55_gamma_validate,
> },
> [MALI_C55_PARAM_BLOCK_GAMMA_DS] = {
> .size = sizeof(struct mali_c55_params_gamma),
> + .block_validate = mali_c55_gamma_validate,
> },
> };
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 16+ messages in thread