[RFC PATCH 09/37] drm: ast: Split mode adjustment from get_vbios_mode_info

Daniel Stone daniels at collabora.com
Wed Mar 18 21:33:08 PDT 2015


Further to the previous commit, instead of performing mode adjustment
inside a getter function called from mode_set, actually perform it in
mode_fixup instead. This allows us to drop the extra mode argument and
constify our original mode.

Signed-off-by: Daniel Stone <daniels at collabora.com>
---
 drivers/gpu/drm/ast/ast_mode.c | 63 +++++++++++++++++++++++++-----------------
 1 file changed, 38 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index e8c24a5..fcef5a6 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -74,12 +74,11 @@ static void ast_crtc_load_lut(struct drm_crtc *crtc)
 				       ast_crtc->lut_g[i], ast_crtc->lut_b[i]);
 }
 
-static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mode *mode,
-				    struct drm_display_mode *adjusted_mode,
+static bool ast_get_vbios_mode_info(struct drm_crtc *crtc,
+				    const struct drm_display_mode *mode,
 				    struct ast_vbios_mode_info *vbios_mode)
 {
 	u32 refresh_rate_index = 0, refresh_rate;
-	u32 hborder, vborder;
 	bool check_sync;
 	struct ast_vbios_enhtable *best = NULL;
 
@@ -172,27 +171,6 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
 	if (best)
 		vbios_mode->enh_table = best;
 
-	hborder = (vbios_mode->enh_table->flags & HBorder) ? 8 : 0;
-	vborder = (vbios_mode->enh_table->flags & VBorder) ? 8 : 0;
-
-	adjusted_mode->crtc_htotal = vbios_mode->enh_table->ht;
-	adjusted_mode->crtc_hblank_start = vbios_mode->enh_table->hde + hborder;
-	adjusted_mode->crtc_hblank_end = vbios_mode->enh_table->ht - hborder;
-	adjusted_mode->crtc_hsync_start = vbios_mode->enh_table->hde + hborder +
-		vbios_mode->enh_table->hfp;
-	adjusted_mode->crtc_hsync_end = (vbios_mode->enh_table->hde + hborder +
-					 vbios_mode->enh_table->hfp +
-					 vbios_mode->enh_table->hsync);
-
-	adjusted_mode->crtc_vtotal = vbios_mode->enh_table->vt;
-	adjusted_mode->crtc_vblank_start = vbios_mode->enh_table->vde + vborder;
-	adjusted_mode->crtc_vblank_end = vbios_mode->enh_table->vt - vborder;
-	adjusted_mode->crtc_vsync_start = vbios_mode->enh_table->vde + vborder +
-		vbios_mode->enh_table->vfp;
-	adjusted_mode->crtc_vsync_end = (vbios_mode->enh_table->vde + vborder +
-					 vbios_mode->enh_table->vfp +
-					 vbios_mode->enh_table->vsync);
-
 	return true;
 }
 
@@ -512,6 +490,37 @@ static bool ast_crtc_mode_fixup(struct drm_crtc *crtc,
 				const struct drm_display_mode *mode,
 				struct drm_display_mode *adjusted_mode)
 {
+	struct ast_vbios_mode_info vbios_mode;
+	u32 hborder, vborder;
+	bool ret;
+
+	ret = ast_get_vbios_mode_info(crtc, mode, &vbios_mode);
+	if (!ret)
+		return false;
+
+	hborder = (vbios_mode.enh_table->flags & HBorder) ? 8 : 0;
+	vborder = (vbios_mode.enh_table->flags & VBorder) ? 8 : 0;
+
+	adjusted_mode->crtc_htotal = vbios_mode.enh_table->ht;
+	adjusted_mode->crtc_hblank_start = vbios_mode.enh_table->hde + hborder;
+	adjusted_mode->crtc_hblank_end = vbios_mode.enh_table->ht - hborder;
+	adjusted_mode->crtc_hsync_start =
+		vbios_mode.enh_table->hde + hborder + vbios_mode.enh_table->hfp;
+	adjusted_mode->crtc_hsync_end =
+		(vbios_mode.enh_table->hde + hborder +
+			vbios_mode.enh_table->hfp +
+			vbios_mode.enh_table->hsync);
+
+	adjusted_mode->crtc_vtotal = vbios_mode.enh_table->vt;
+	adjusted_mode->crtc_vblank_start = vbios_mode.enh_table->vde + vborder;
+	adjusted_mode->crtc_vblank_end = vbios_mode.enh_table->vt - vborder;
+	adjusted_mode->crtc_vsync_start =
+		vbios_mode.enh_table->vde + vborder + vbios_mode.enh_table->vfp;
+	adjusted_mode->crtc_vsync_end =
+		(vbios_mode.enh_table->vde + vborder +
+			 vbios_mode.enh_table->vfp +
+			 vbios_mode.enh_table->vsync);
+
 	return true;
 }
 
@@ -587,7 +596,11 @@ static int ast_crtc_mode_set(struct drm_crtc *crtc,
 		return -EINVAL;
 	}
 
-	ret = ast_get_vbios_mode_info(crtc, mode, adjusted_mode, &vbios_mode);
+	/* mode_fixup should have already returned false if
+	 * ast_get_vbios_mode_info would have failed, so if that happens
+	 * here then something has gone wrong. */
+	ret = ast_get_vbios_mode_info(crtc, mode, &vbios_mode);
+	WARN_ON(ret == false);
 	if (ret == false)
 		return -EINVAL;
 
-- 
2.3.2



More information about the dri-devel mailing list