diff mbox series

[v5,1/3] drm/ingenic : add ingenic_drm_bridge_atomic_enable and disable

Message ID 20220321133651.291592-2-cbranchereau@gmail.com (mailing list archive)
State New, archived
Headers show
Series Ingenic DRM bridge_atomic_enable proposal | expand

Commit Message

Christophe Branchereau March 21, 2022, 1:36 p.m. UTC
ingenic_drm_bridge_atomic_enable allows the CRTC to be enabled after
panels have slept out, and before their display is turned on, solving
a graphical bug on the newvision nv3502c.

Also add ingenic_drm_bridge_atomic_disable to balance it out.

Signed-off-by: Christophe Branchereau <cbranchereau@gmail.com>
---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 34 +++++++++++++++--------
 1 file changed, 23 insertions(+), 11 deletions(-)

Comments

Artur Rojek April 5, 2022, 8:26 p.m. UTC | #1
On 2022-03-21 14:36, Christophe Branchereau wrote:
Hi Christophe,

looks good to me.

Cheers,
Artur

Acked-by: Artur Rojek <contact@artur-rojek.eu>

> ingenic_drm_bridge_atomic_enable allows the CRTC to be enabled after
> panels have slept out, and before their display is turned on, solving
> a graphical bug on the newvision nv3502c.
> 
> Also add ingenic_drm_bridge_atomic_disable to balance it out.
> 
> Signed-off-by: Christophe Branchereau <cbranchereau@gmail.com>
> ---
>  drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 34 +++++++++++++++--------
>  1 file changed, 23 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> index dcf44cb00821..2bbfd2e7fdab 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> @@ -226,6 +226,18 @@ static int ingenic_drm_update_pixclk(struct
> notifier_block *nb,
>  	}
>  }
> 
> +static void ingenic_drm_bridge_atomic_enable(struct drm_bridge 
> *bridge,
> +					     struct drm_bridge_state *old_bridge_state)
> +{
> +	struct ingenic_drm *priv = drm_device_get_priv(bridge->dev);
> +
> +	regmap_write(priv->map, JZ_REG_LCD_STATE, 0);
> +
> +	regmap_update_bits(priv->map, JZ_REG_LCD_CTRL,
> +			   JZ_LCD_CTRL_ENABLE | JZ_LCD_CTRL_DISABLE,
> +			   JZ_LCD_CTRL_ENABLE);
> +}
> +
>  static void ingenic_drm_crtc_atomic_enable(struct drm_crtc *crtc,
>  					   struct drm_atomic_state *state)
>  {
> @@ -237,28 +249,20 @@ static void
> ingenic_drm_crtc_atomic_enable(struct drm_crtc *crtc,
>  	if (WARN_ON(IS_ERR(priv_state)))
>  		return;
> 
> -	regmap_write(priv->map, JZ_REG_LCD_STATE, 0);
> -
>  	/* Set addresses of our DMA descriptor chains */
>  	next_id = priv_state->use_palette ? HWDESC_PALETTE : 0;
>  	regmap_write(priv->map, JZ_REG_LCD_DA0, dma_hwdesc_addr(priv, 
> next_id));
>  	regmap_write(priv->map, JZ_REG_LCD_DA1, dma_hwdesc_addr(priv, 1));
> 
> -	regmap_update_bits(priv->map, JZ_REG_LCD_CTRL,
> -			   JZ_LCD_CTRL_ENABLE | JZ_LCD_CTRL_DISABLE,
> -			   JZ_LCD_CTRL_ENABLE);
> -
>  	drm_crtc_vblank_on(crtc);
>  }
> 
> -static void ingenic_drm_crtc_atomic_disable(struct drm_crtc *crtc,
> -					    struct drm_atomic_state *state)
> +static void ingenic_drm_bridge_atomic_disable(struct drm_bridge 
> *bridge,
> +					      struct drm_bridge_state *old_bridge_state)
>  {
> -	struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
> +	struct ingenic_drm *priv = drm_device_get_priv(bridge->dev);
>  	unsigned int var;
> 
> -	drm_crtc_vblank_off(crtc);
> -
>  	regmap_update_bits(priv->map, JZ_REG_LCD_CTRL,
>  			   JZ_LCD_CTRL_DISABLE, JZ_LCD_CTRL_DISABLE);
> 
> @@ -267,6 +271,12 @@ static void
> ingenic_drm_crtc_atomic_disable(struct drm_crtc *crtc,
>  				 1000, 0);
>  }
> 
> +static void ingenic_drm_crtc_atomic_disable(struct drm_crtc *crtc,
> +					    struct drm_atomic_state *state)
> +{
> +	drm_crtc_vblank_off(crtc);
> +}
> +
>  static void ingenic_drm_crtc_update_timings(struct ingenic_drm *priv,
>  					    struct drm_display_mode *mode)
>  {
> @@ -968,6 +978,8 @@ static const struct drm_encoder_helper_funcs
> ingenic_drm_encoder_helper_funcs =
> 
>  static const struct drm_bridge_funcs ingenic_drm_bridge_funcs = {
>  	.attach			= ingenic_drm_bridge_attach,
> +	.atomic_enable		= ingenic_drm_bridge_atomic_enable,
> +	.atomic_disable		= ingenic_drm_bridge_atomic_disable,
>  	.atomic_check		= ingenic_drm_bridge_atomic_check,
>  	.atomic_reset		= drm_atomic_helper_bridge_reset,
>  	.atomic_duplicate_state	= drm_atomic_helper_bridge_duplicate_state,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index dcf44cb00821..2bbfd2e7fdab 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -226,6 +226,18 @@  static int ingenic_drm_update_pixclk(struct notifier_block *nb,
 	}
 }
 
+static void ingenic_drm_bridge_atomic_enable(struct drm_bridge *bridge,
+					     struct drm_bridge_state *old_bridge_state)
+{
+	struct ingenic_drm *priv = drm_device_get_priv(bridge->dev);
+
+	regmap_write(priv->map, JZ_REG_LCD_STATE, 0);
+
+	regmap_update_bits(priv->map, JZ_REG_LCD_CTRL,
+			   JZ_LCD_CTRL_ENABLE | JZ_LCD_CTRL_DISABLE,
+			   JZ_LCD_CTRL_ENABLE);
+}
+
 static void ingenic_drm_crtc_atomic_enable(struct drm_crtc *crtc,
 					   struct drm_atomic_state *state)
 {
@@ -237,28 +249,20 @@  static void ingenic_drm_crtc_atomic_enable(struct drm_crtc *crtc,
 	if (WARN_ON(IS_ERR(priv_state)))
 		return;
 
-	regmap_write(priv->map, JZ_REG_LCD_STATE, 0);
-
 	/* Set addresses of our DMA descriptor chains */
 	next_id = priv_state->use_palette ? HWDESC_PALETTE : 0;
 	regmap_write(priv->map, JZ_REG_LCD_DA0, dma_hwdesc_addr(priv, next_id));
 	regmap_write(priv->map, JZ_REG_LCD_DA1, dma_hwdesc_addr(priv, 1));
 
-	regmap_update_bits(priv->map, JZ_REG_LCD_CTRL,
-			   JZ_LCD_CTRL_ENABLE | JZ_LCD_CTRL_DISABLE,
-			   JZ_LCD_CTRL_ENABLE);
-
 	drm_crtc_vblank_on(crtc);
 }
 
-static void ingenic_drm_crtc_atomic_disable(struct drm_crtc *crtc,
-					    struct drm_atomic_state *state)
+static void ingenic_drm_bridge_atomic_disable(struct drm_bridge *bridge,
+					      struct drm_bridge_state *old_bridge_state)
 {
-	struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
+	struct ingenic_drm *priv = drm_device_get_priv(bridge->dev);
 	unsigned int var;
 
-	drm_crtc_vblank_off(crtc);
-
 	regmap_update_bits(priv->map, JZ_REG_LCD_CTRL,
 			   JZ_LCD_CTRL_DISABLE, JZ_LCD_CTRL_DISABLE);
 
@@ -267,6 +271,12 @@  static void ingenic_drm_crtc_atomic_disable(struct drm_crtc *crtc,
 				 1000, 0);
 }
 
+static void ingenic_drm_crtc_atomic_disable(struct drm_crtc *crtc,
+					    struct drm_atomic_state *state)
+{
+	drm_crtc_vblank_off(crtc);
+}
+
 static void ingenic_drm_crtc_update_timings(struct ingenic_drm *priv,
 					    struct drm_display_mode *mode)
 {
@@ -968,6 +978,8 @@  static const struct drm_encoder_helper_funcs ingenic_drm_encoder_helper_funcs =
 
 static const struct drm_bridge_funcs ingenic_drm_bridge_funcs = {
 	.attach			= ingenic_drm_bridge_attach,
+	.atomic_enable		= ingenic_drm_bridge_atomic_enable,
+	.atomic_disable		= ingenic_drm_bridge_atomic_disable,
 	.atomic_check		= ingenic_drm_bridge_atomic_check,
 	.atomic_reset		= drm_atomic_helper_bridge_reset,
 	.atomic_duplicate_state	= drm_atomic_helper_bridge_duplicate_state,