diff mbox series

[v3,05/11] drm/ast: astdp: Simplify power management when detecting display

Message ID 20240815151953.184679-6-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series drm/ast: Transparently handle BMC in outputs | expand

Commit Message

Thomas Zimmermann Aug. 15, 2024, 3:18 p.m. UTC
Remove the CRTC handling in the ASTDP detect_ctx helper and enable
power while the detecting the display. Unconditionally wait a few
milliseconds after switching power. Simplifies the code and makes it
more robust.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/ast/ast_dp.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

Comments

Jocelyn Falempe Aug. 19, 2024, 9:50 a.m. UTC | #1
On 15/08/2024 17:18, Thomas Zimmermann wrote:
> Remove the CRTC handling in the ASTDP detect_ctx helper and enable
> power while the detecting the display. Unconditionally wait a few
> milliseconds after switching power. Simplifies the code and makes it
> more robust.
> 
Thanks, it looks good to me.

Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>


> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>   drivers/gpu/drm/ast/ast_dp.c | 19 ++++++-------------
>   1 file changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c
> index 45e5c92d19c2..ffbcc397ee6b 100644
> --- a/drivers/gpu/drm/ast/ast_dp.c
> +++ b/drivers/gpu/drm/ast/ast_dp.c
> @@ -170,6 +170,8 @@ static void ast_dp_power_on_off(struct drm_device *dev, bool on)
>   
>   	// DP Power on/off
>   	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_PHY_SLEEP, bE3);
> +
> +	msleep(50);
>   }
>   
>   static void ast_dp_link_training(struct ast_device *ast)
> @@ -367,27 +369,18 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
>   	struct drm_device *dev = connector->dev;
>   	struct ast_device *ast = to_ast_device(connector->dev);
>   	enum drm_connector_status status = connector_status_disconnected;
> -	struct drm_connector_state *connector_state = connector->state;
> -	bool is_active = false;
> +	bool power_is_on;
>   
>   	mutex_lock(&ast->modeset_lock);
>   
> -	if (connector_state && connector_state->crtc) {
> -		struct drm_crtc_state *crtc_state = connector_state->crtc->state;
> -
> -		if (crtc_state && crtc_state->active)
> -			is_active = true;
> -	}
> -
> -	if (!is_active && !ast_dp_power_is_on(ast)) {
> +	power_is_on = ast_dp_power_is_on(ast);
> +	if (!power_is_on)
>   		ast_dp_power_on_off(dev, true);
> -		msleep(50);
> -	}
>   
>   	if (ast_astdp_is_connected(ast))
>   		status = connector_status_connected;
>   
> -	if (!is_active && status == connector_status_disconnected)
> +	if (!power_is_on && status == connector_status_disconnected)
>   		ast_dp_power_on_off(dev, false);
>   
>   	mutex_unlock(&ast->modeset_lock);
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c
index 45e5c92d19c2..ffbcc397ee6b 100644
--- a/drivers/gpu/drm/ast/ast_dp.c
+++ b/drivers/gpu/drm/ast/ast_dp.c
@@ -170,6 +170,8 @@  static void ast_dp_power_on_off(struct drm_device *dev, bool on)
 
 	// DP Power on/off
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_PHY_SLEEP, bE3);
+
+	msleep(50);
 }
 
 static void ast_dp_link_training(struct ast_device *ast)
@@ -367,27 +369,18 @@  static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
 	struct drm_device *dev = connector->dev;
 	struct ast_device *ast = to_ast_device(connector->dev);
 	enum drm_connector_status status = connector_status_disconnected;
-	struct drm_connector_state *connector_state = connector->state;
-	bool is_active = false;
+	bool power_is_on;
 
 	mutex_lock(&ast->modeset_lock);
 
-	if (connector_state && connector_state->crtc) {
-		struct drm_crtc_state *crtc_state = connector_state->crtc->state;
-
-		if (crtc_state && crtc_state->active)
-			is_active = true;
-	}
-
-	if (!is_active && !ast_dp_power_is_on(ast)) {
+	power_is_on = ast_dp_power_is_on(ast);
+	if (!power_is_on)
 		ast_dp_power_on_off(dev, true);
-		msleep(50);
-	}
 
 	if (ast_astdp_is_connected(ast))
 		status = connector_status_connected;
 
-	if (!is_active && status == connector_status_disconnected)
+	if (!power_is_on && status == connector_status_disconnected)
 		ast_dp_power_on_off(dev, false);
 
 	mutex_unlock(&ast->modeset_lock);