drm/ast: Validate DRM display modes against VBIOS modes
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 31 Jan 2025 09:21:11 +0000 (10:21 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 3 Feb 2025 13:01:13 +0000 (14:01 +0100)
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>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250131092257.115596-12-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_mode.c

index 14c0c281a6834f86db59ba0a8f7e417acd722071..f58ec35cb3a383ff801ac07d8434c4bab8557229 100644 (file)
@@ -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)