diff mbox series

[11/15] drm/ast: Validate DRM display modes against VBIOS modes

Message ID 20250124080546.9956-12-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series drm/ast: Clean up display-mode detection and validation | expand

Commit Message

Thomas Zimmermann Jan. 24, 2025, 7:57 a.m. UTC
Test DRM display modes against the list of modes supported by the
VBIOS. The helper will respect the supported-modes flags in struct
ast_device. Hence only DRM display modes supported by the VBIOS
will be reported; without the current duplication of this information.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/ast/ast_mode.c | 62 +++-------------------------------
 1 file changed, 5 insertions(+), 57 deletions(-)

Comments

Jocelyn Falempe Jan. 27, 2025, 2:48 p.m. UTC | #1
On 24/01/2025 08:57, Thomas Zimmermann wrote:
> Test DRM display modes against the list of modes supported by the
> VBIOS. The helper will respect the supported-modes flags in struct
> ast_device. Hence only DRM display modes supported by the VBIOS
> will be reported; without the current duplication of this information.

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_mode.c | 62 +++-------------------------------
>   1 file changed, 5 insertions(+), 57 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index e3d15d30aeeae..372abff1c8673 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -950,65 +950,13 @@ static enum drm_mode_status
>   ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
>   {
>   	struct ast_device *ast = to_ast_device(crtc->dev);
> -	enum drm_mode_status status;
> -
> -	if (ast->support_wsxga_p) {
> -		if ((mode->hdisplay == 1680) && (mode->vdisplay == 1050))
> -			return MODE_OK;
> -		if ((mode->hdisplay == 1280) && (mode->vdisplay == 800))
> -			return MODE_OK;
> -		if ((mode->hdisplay == 1440) && (mode->vdisplay == 900))
> -			return MODE_OK;
> -		if ((mode->hdisplay == 1360) && (mode->vdisplay == 768))
> -			return MODE_OK;
> -		if ((mode->hdisplay == 1600) && (mode->vdisplay == 900))
> -			return MODE_OK;
> -
> -		if (ast->support_fullhd) {
> -			if ((mode->hdisplay == 1920) && (mode->vdisplay == 1080))
> -				return MODE_OK;
> -
> -			if ((mode->hdisplay == 1920) && (mode->vdisplay == 1200)) {
> -				if (ast->support_wuxga)
> -					return MODE_OK;
> -				else
> -					return MODE_NOMODE;
> -			}
> -		}
> -	}
> +	const struct ast_vbios_enhtable *vmode;
>   
> -	status = MODE_NOMODE;
> +	vmode = ast_vbios_find_mode(ast, mode);
> +	if (!vmode)
> +		return MODE_NOMODE;
>   
> -	switch (mode->hdisplay) {
> -	case 640:
> -		if (mode->vdisplay == 480)
> -			status = MODE_OK;
> -		break;
> -	case 800:
> -		if (mode->vdisplay == 600)
> -			status = MODE_OK;
> -		break;
> -	case 1024:
> -		if (mode->vdisplay == 768)
> -			status = MODE_OK;
> -		break;
> -	case 1152:
> -		if (mode->vdisplay == 864)
> -			status = MODE_OK;
> -		break;
> -	case 1280:
> -		if (mode->vdisplay == 1024)
> -			status = MODE_OK;
> -		break;
> -	case 1600:
> -		if (mode->vdisplay == 1200)
> -			status = MODE_OK;
> -		break;
> -	default:
> -		break;
> -	}
> -
> -	return status;
> +	return MODE_OK;
>   }
>   
>   static void ast_crtc_helper_mode_set_nofb(struct drm_crtc *crtc)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index e3d15d30aeeae..372abff1c8673 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -950,65 +950,13 @@  static enum drm_mode_status
 ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
 {
 	struct ast_device *ast = to_ast_device(crtc->dev);
-	enum drm_mode_status status;
-
-	if (ast->support_wsxga_p) {
-		if ((mode->hdisplay == 1680) && (mode->vdisplay == 1050))
-			return MODE_OK;
-		if ((mode->hdisplay == 1280) && (mode->vdisplay == 800))
-			return MODE_OK;
-		if ((mode->hdisplay == 1440) && (mode->vdisplay == 900))
-			return MODE_OK;
-		if ((mode->hdisplay == 1360) && (mode->vdisplay == 768))
-			return MODE_OK;
-		if ((mode->hdisplay == 1600) && (mode->vdisplay == 900))
-			return MODE_OK;
-
-		if (ast->support_fullhd) {
-			if ((mode->hdisplay == 1920) && (mode->vdisplay == 1080))
-				return MODE_OK;
-
-			if ((mode->hdisplay == 1920) && (mode->vdisplay == 1200)) {
-				if (ast->support_wuxga)
-					return MODE_OK;
-				else
-					return MODE_NOMODE;
-			}
-		}
-	}
+	const struct ast_vbios_enhtable *vmode;
 
-	status = MODE_NOMODE;
+	vmode = ast_vbios_find_mode(ast, mode);
+	if (!vmode)
+		return MODE_NOMODE;
 
-	switch (mode->hdisplay) {
-	case 640:
-		if (mode->vdisplay == 480)
-			status = MODE_OK;
-		break;
-	case 800:
-		if (mode->vdisplay == 600)
-			status = MODE_OK;
-		break;
-	case 1024:
-		if (mode->vdisplay == 768)
-			status = MODE_OK;
-		break;
-	case 1152:
-		if (mode->vdisplay == 864)
-			status = MODE_OK;
-		break;
-	case 1280:
-		if (mode->vdisplay == 1024)
-			status = MODE_OK;
-		break;
-	case 1600:
-		if (mode->vdisplay == 1200)
-			status = MODE_OK;
-		break;
-	default:
-		break;
-	}
-
-	return status;
+	return MODE_OK;
 }
 
 static void ast_crtc_helper_mode_set_nofb(struct drm_crtc *crtc)