From patchwork Sun Aug 19 19:13:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1345211 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id E2EBD3FC33 for ; Sun, 19 Aug 2012 20:52:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4BB3A1044 for ; Sun, 19 Aug 2012 13:52:05 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by gabe.freedesktop.org (Postfix) with ESMTP id AEFB4A1024 for ; Sun, 19 Aug 2012 13:21:17 -0700 (PDT) Received: by mail-wi0-f171.google.com with SMTP id hq4so2753404wib.12 for ; Sun, 19 Aug 2012 13:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=Pe52CmBoCqFso6CxudqUeULlZ78GGW/h5ZJllVOPwUw=; b=Yt4f2qpYk1MrnmNaeTX9cy0lQ3pcgF0akJ6DWl2URE1WNbNQZyo1gLo3ADzgq0zloj OruQZHjFPtu3BFNr77D2gG97OC1GjNSc/MSisilFgOMls19RcbyJnjENAQ8z4w/jK9x9 N9EJ3St/3wQfVuCG1ZpH62d2cr9Kq4JHMWWME= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Pe52CmBoCqFso6CxudqUeULlZ78GGW/h5ZJllVOPwUw=; b=U6IiPU7EaiSUfHjNyABcBMvaKTz8OEQoyCc3ryQQGHSL0RyDBDtLMyqpUT9AU18U9F CDYJWcEw/xeiUQwgl8+VvZeNtSRtUztl2kHHZwZ/MuXuiOcZtU+IoZkUVGGOKe1jYuh3 h8Ry6NOO5l/ALdL4lpOUrTsQCS216drVH6/6sS2sY8rFf3vLEZA34kbQxOccnosdzlHT ptAB21vawDKi1uq/paD/RNcXkbFX8a0Qc7eyRrWl7zn6ojq5Hc4mwjaq47vAAYz99hF5 Xte9MFrhvsJXVT64U2k5XFSkQvvrkhX5Vb/uWB3mC9RiMMH+4qroW0jbagdW8BO6/lhX erhw== Received: by 10.216.30.83 with SMTP id j61mr6164401wea.168.1345407677345; Sun, 19 Aug 2012 13:21:17 -0700 (PDT) Received: from wespe.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id fu8sm24194367wib.5.2012.08.19.13.21.16 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 19 Aug 2012 13:21:16 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Sun, 19 Aug 2012 21:13:04 +0200 Message-Id: <1345403595-9678-48-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1345403595-9678-1-git-send-email-daniel.vetter@ffwll.ch> References: <1345403595-9678-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQlGGzUgGMxuJVpJl7kKXYoD/TN/sPZeNB27U03K8htmcpJUky9zw7UzPd4kxks+UasCylQR Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 47/58] drm/i915: extract adjusted mode computation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org While at it, adjust a few things: - Only assigng the new mode to crtc->mode right before calling the mode_set callbacks - none of the previous callbacks depend upon this, they all use the mode argument (as they should). - Check encoder->new_crtc instead of the current crtc to check whether the encoder will be used. This prepares for moving the staged output committing further down in the sequence. Follow-on patches will fix up individual ->mode_fixup callbacks (only tv and lvds are affected though). Signed-Off-by: Daniel Vetter Reviewed-by: Jesse Barnes --- drivers/gpu/drm/i915/intel_display.c | 75 ++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 348727d..c7bd573 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6642,6 +6642,48 @@ static void intel_modeset_commit_output_state(struct drm_device *dev) } } +static struct drm_display_mode * +intel_modeset_adjusted_mode(struct drm_crtc *crtc, + struct drm_display_mode *mode) +{ + struct drm_device *dev = crtc->dev; + struct drm_display_mode *adjusted_mode; + struct drm_encoder_helper_funcs *encoder_funcs; + struct intel_encoder *encoder; + + adjusted_mode = drm_mode_duplicate(dev, mode); + if (!adjusted_mode) + return ERR_PTR(-ENOMEM); + + /* Pass our mode to the connectors and the CRTC to give them a chance to + * adjust it according to limitations or connector properties, and also + * a chance to reject the mode entirely. + */ + list_for_each_entry(encoder, &dev->mode_config.encoder_list, + base.head) { + + if (&encoder->new_crtc->base != crtc) + continue; + encoder_funcs = encoder->base.helper_private; + if (!(encoder_funcs->mode_fixup(&encoder->base, mode, + adjusted_mode))) { + DRM_DEBUG_KMS("Encoder fixup failed\n"); + goto fail; + } + } + + if (!(intel_crtc_mode_fixup(crtc, mode, adjusted_mode))) { + DRM_DEBUG_KMS("CRTC fixup failed\n"); + goto fail; + } + DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); + + return adjusted_mode; +fail: + drm_mode_destroy(dev, adjusted_mode); + return ERR_PTR(-EINVAL); +} + bool intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode, int x, int y, struct drm_framebuffer *fb) @@ -6661,44 +6703,21 @@ bool intel_set_mode(struct drm_crtc *crtc, return true; } - adjusted_mode = drm_mode_duplicate(dev, mode); - if (!adjusted_mode) - return false; saved_hwmode = crtc->hwmode; saved_mode = crtc->mode; - /* Update crtc values up front so the driver can rely on them for mode - * setting. - */ - crtc->mode = *mode; - - /* Pass our mode to the connectors and the CRTC to give them a chance to - * adjust it according to limitations or connector properties, and also - * a chance to reject the mode entirely. - */ - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { - - if (encoder->crtc != crtc) - continue; - encoder_funcs = encoder->helper_private; - if (!(ret = encoder_funcs->mode_fixup(encoder, mode, - adjusted_mode))) { - DRM_DEBUG_KMS("Encoder fixup failed\n"); - goto done; - } - } - - if (!(ret = intel_crtc_mode_fixup(crtc, mode, adjusted_mode))) { - DRM_DEBUG_KMS("CRTC fixup failed\n"); - goto done; + adjusted_mode = intel_modeset_adjusted_mode(crtc, mode); + if (IS_ERR(adjusted_mode)) { + return false; } - DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); intel_crtc_prepare_encoders(dev); dev_priv->display.crtc_disable(crtc); + crtc->mode = *mode; + /* Set up the DPLL and any encoders state that needs to adjust or depend * on the DPLL. */