From patchwork Thu Mar 19 04:33:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Stone X-Patchwork-Id: 6045751 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5906D9F2A9 for ; Thu, 19 Mar 2015 04:33:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B248204C9 for ; Thu, 19 Mar 2015 04:33:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7F67220465 for ; Thu, 19 Mar 2015 04:33:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6660B6E952; Wed, 18 Mar 2015 21:33:49 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [93.93.135.160]) by gabe.freedesktop.org (Postfix) with ESMTP id 915C86E952 for ; Wed, 18 Mar 2015 21:33:46 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: daniels) with ESMTPSA id 4CE64600EAE From: Daniel Stone To: dri-devel@lists.freedesktop.org Subject: [RFC PATCH 09/37] drm: ast: Split mode adjustment from get_vbios_mode_info Date: Thu, 19 Mar 2015 04:33:08 +0000 Message-Id: <1426739616-10635-9-git-send-email-daniels@collabora.com> X-Mailer: git-send-email 2.3.2 In-Reply-To: <1426739616-10635-1-git-send-email-daniels@collabora.com> References: <1426739556-10429-1-git-send-email-daniels@collabora.com> <1426739616-10635-1-git-send-email-daniels@collabora.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;