diff mbox series

[4/4] drm: rcar-du: kms: Configure the CLU

Message ID 20201221015730.28333-5-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series drm: rcar-du: Add cubic LUT support | expand

Commit Message

Laurent Pinchart Dec. 21, 2020, 1:57 a.m. UTC
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

Link the DRM 3D-CLU configuration to the CMM setup configuration.

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

Comments

Kieran Bingham Dec. 21, 2020, 2:13 p.m. UTC | #1
Hi Laurent,

On 21/12/2020 01:57, Laurent Pinchart wrote:
> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> Link the DRM 3D-CLU configuration to the CMM setup configuration.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

And for the updates from my original patch (variable rename, and
property blob rework, and that ... obvious bug ... from my patch that's
now obviously gone :-D ...)

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> ---
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 23 ++++++++++++++++++-----
>  1 file changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> index 426b1870b3cb..5c77017084ed 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> @@ -484,19 +484,23 @@ static int rcar_du_cmm_check(struct drm_crtc *crtc,
>  			     struct drm_crtc_state *state)
>  {
>  	struct drm_property_blob *drm_lut = state->gamma_lut;
> +	struct drm_property_blob *drm_clu = state->cubic_lut;
>  	struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
>  	struct device *dev = rcrtc->dev->dev;
>  
> -	if (!drm_lut)
> -		return 0;
> -
> -	/* We only accept fully populated LUT tables. */
> -	if (drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
> +	/* We only accept fully populated LUTs. */
> +	if (drm_lut && drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
>  		dev_err(dev, "invalid gamma lut size: %zu bytes\n",
>  			drm_lut->length);
>  		return -EINVAL;
>  	}
>  
> +	if (drm_clu && drm_color_lut_size(drm_clu) != CM2_CLU_SIZE) {
> +		dev_err(dev, "invalid cubic lut size: %zu bytes\n",
> +			drm_clu->length);
> +		return -EINVAL;
> +	}
> +
>  	return 0;
>  }
>  
> @@ -518,6 +522,15 @@ static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
>  				     ? new_state->gamma_lut->data : NULL;
>  	}
>  
> +	if (!old_state ||
> +	    !old_state->cubic_lut != !new_state->cubic_lut ||
> +	    (old_state->cubic_lut && new_state->cubic_lut &&
> +	     old_state->cubic_lut->base.id != new_state->cubic_lut->base.id)) {
> +		cmm_config.clu.update = true;
> +		cmm_config.clu.table = new_state->cubic_lut
> +				     ? new_state->cubic_lut->data : NULL;
> +	}
> +
>  	rcar_cmm_setup(rcrtc->cmm, &cmm_config);
>  }
>  
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 426b1870b3cb..5c77017084ed 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -484,19 +484,23 @@  static int rcar_du_cmm_check(struct drm_crtc *crtc,
 			     struct drm_crtc_state *state)
 {
 	struct drm_property_blob *drm_lut = state->gamma_lut;
+	struct drm_property_blob *drm_clu = state->cubic_lut;
 	struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
 	struct device *dev = rcrtc->dev->dev;
 
-	if (!drm_lut)
-		return 0;
-
-	/* We only accept fully populated LUT tables. */
-	if (drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
+	/* We only accept fully populated LUTs. */
+	if (drm_lut && drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
 		dev_err(dev, "invalid gamma lut size: %zu bytes\n",
 			drm_lut->length);
 		return -EINVAL;
 	}
 
+	if (drm_clu && drm_color_lut_size(drm_clu) != CM2_CLU_SIZE) {
+		dev_err(dev, "invalid cubic lut size: %zu bytes\n",
+			drm_clu->length);
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
@@ -518,6 +522,15 @@  static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
 				     ? new_state->gamma_lut->data : NULL;
 	}
 
+	if (!old_state ||
+	    !old_state->cubic_lut != !new_state->cubic_lut ||
+	    (old_state->cubic_lut && new_state->cubic_lut &&
+	     old_state->cubic_lut->base.id != new_state->cubic_lut->base.id)) {
+		cmm_config.clu.update = true;
+		cmm_config.clu.table = new_state->cubic_lut
+				     ? new_state->cubic_lut->data : NULL;
+	}
+
 	rcar_cmm_setup(rcrtc->cmm, &cmm_config);
 }