From patchwork Sun Aug 19 19:13:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1345261 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 40C08DF264 for ; Sun, 19 Aug 2012 20:55:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8FB0AA1045 for ; Sun, 19 Aug 2012 13:55:36 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by gabe.freedesktop.org (Postfix) with ESMTP id E4CF2A1017 for ; Sun, 19 Aug 2012 13:21:24 -0700 (PDT) Received: by mail-we0-f177.google.com with SMTP id r3so3851112wey.36 for ; Sun, 19 Aug 2012 13:21:24 -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=s6AHwlj450idBvcrCfT8YU9ycmktoPphCBj7/4UXLpg=; b=OEkQQU7DX1XvMuzLwSPXxaoxD8J4MY0QnNECQXZD8Iv8VPf3AN4l+IR9nOeK0a3S/A J1q9KGcVaqCGUs+1flvMTI+V2xRh4kGV6HrgTuQHO+8fYeNEoP5NQpvAnRiQq162RVOy EIUuVsRZoLdKNpAx3fiz7SYqOWTPyz08dGDfE= 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=s6AHwlj450idBvcrCfT8YU9ycmktoPphCBj7/4UXLpg=; b=liWLfyzojch1h2QQF8LFVsC7qMpdwitHzJhCt1jDDFQpwpxcbMe838OsR5tk7sopZT /9/wTXLBQxZ1bNIfMsJlGI1c/G2ZeC4bh23wzaujCGt/4+r0kDtrV+/0r3xnXO3WkNfj 4BD/z1tYYrmOlYQwDMLIWQVPWLAd7SU8vQPcqUI8Si7wkJIftWahZhj8/NJN+UGtZpfE 5lHzM0ks5L/NEudiTl2q0H40E35hVWrDdjK24qzOGMEUmZ94LLpOnhCMmSEOTgqqUJ3l SRDkkZ/YIZG9Ti16F8x3lF5U9/SFwJGUx3PvfNTSEVtT2VcsyFCjAbTIpfkbUey/1je1 U20g== Received: by 10.216.243.1 with SMTP id j1mr5745665wer.29.1345407684614; Sun, 19 Aug 2012 13:21:24 -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.23 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 19 Aug 2012 13:21:23 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Sun, 19 Aug 2012 21:13:09 +0200 Message-Id: <1345403595-9678-53-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: ALoCoQk5w+5WJf4Hw5ukeqhrMcsHaU4q/SXNxIJDxjD80PTe9y46h27ZfNcoJX8hW0QrIilCl2bk Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 52/58] drm/i915: push commit_output_state past crtc disabling 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 This requires a few changes - We still need a noop function for crtc->disable, becuase the fb helper is a bit too intimate with the crtc helper. - We need to clear crtc->fb ourselves in intel_crtc_disable now that we no longer rely on the helper's disable_unused_functions to do that. - We need to split out the sare update code, becuase the crtc code can't call update_dpms any more, it needs to disable the crtc unconditionally. This is because we now keep onto the encoder -> crtc mapping of the (still) active output pipe configuration. - To check that we really disable a crtc that still has encoders, insert a WARN_ON(!enabled) in the crtc disable function. - Lastly, we need to walk over all crtcs to update their enabled state after having called commit_output_state - for all disabled crtc the crtc helper code has done that for us previously. v2: Update connector dpms and encoder->connectors_active after disabling the crtc, too. v3: Noop-out intel_encoder_disable. Similarly to the crtc disable callback used by the crtc helper code we can't simply remove all these encoder callbacks: The fb helper (which we still use) has a rather incetious relationship with the crtc helper code ... Signed-Off-by: Daniel Vetter Reviewed-by: Jesse Barnes --- drivers/gpu/drm/i915/intel_display.c | 81 +++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 3d99522..48d763d 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -3462,26 +3462,13 @@ static void i9xx_crtc_off(struct drm_crtc *crtc) { } -/** - * Sets the power management mode of the pipe and plane. - */ -void intel_crtc_update_dpms(struct drm_crtc *crtc) +static void intel_crtc_update_sarea(struct drm_crtc *crtc, + bool enabled) { struct drm_device *dev = crtc->dev; - struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_master_private *master_priv; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - struct intel_encoder *intel_encoder; int pipe = intel_crtc->pipe; - bool enabled, enable = false; - - for_each_encoder_on_crtc(dev, crtc, intel_encoder) - enable |= intel_encoder->connectors_active; - - if (enable) - dev_priv->display.crtc_enable(crtc); - else - dev_priv->display.crtc_disable(crtc); if (!dev->primary->master) return; @@ -3490,8 +3477,6 @@ void intel_crtc_update_dpms(struct drm_crtc *crtc) if (!master_priv->sarea_priv) return; - enabled = crtc->enabled && enable; - switch (pipe) { case 0: master_priv->sarea_priv->pipeA_w = enabled ? crtc->mode.hdisplay : 0; @@ -3507,14 +3492,42 @@ void intel_crtc_update_dpms(struct drm_crtc *crtc) } } +/** + * Sets the power management mode of the pipe and plane. + */ +void intel_crtc_update_dpms(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_encoder *intel_encoder; + bool enable = false; + + for_each_encoder_on_crtc(dev, crtc, intel_encoder) + enable |= intel_encoder->connectors_active; + + if (enable) + dev_priv->display.crtc_enable(crtc); + else + dev_priv->display.crtc_disable(crtc); + + intel_crtc_update_sarea(crtc, enable); +} + +static void intel_crtc_noop(struct drm_crtc *crtc) +{ +} + static void intel_crtc_disable(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; + struct drm_connector *connector; struct drm_i915_private *dev_priv = dev->dev_private; - /* crtc->disable is only called when we have no encoders, hence this - * will disable the pipe. */ - intel_crtc_update_dpms(crtc); + /* crtc should still be enabled when we disable it. */ + WARN_ON(!crtc->enabled); + + dev_priv->display.crtc_disable(crtc); + intel_crtc_update_sarea(crtc, false); dev_priv->display.off(crtc); assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane); @@ -3524,14 +3537,24 @@ static void intel_crtc_disable(struct drm_crtc *crtc) mutex_lock(&dev->struct_mutex); intel_unpin_fb_obj(to_intel_framebuffer(crtc->fb)->obj); mutex_unlock(&dev->struct_mutex); + crtc->fb = NULL; + } + + /* Update computed state. */ + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + if (!connector->encoder || !connector->encoder->crtc) + continue; + + if (connector->encoder->crtc != crtc) + continue; + + connector->dpms = DRM_MODE_DPMS_OFF; + to_intel_encoder(connector->encoder)->connectors_active = false; } } void intel_encoder_disable(struct drm_encoder *encoder) { - struct intel_encoder *intel_encoder = to_intel_encoder(encoder); - - intel_encoder->disable(intel_encoder); } void intel_encoder_destroy(struct drm_encoder *encoder) @@ -6560,7 +6583,7 @@ free_work: static struct drm_crtc_helper_funcs intel_helper_funcs = { .mode_set_base_atomic = intel_pipe_set_base_atomic, .load_lut = intel_crtc_load_lut, - .disable = intel_crtc_disable, + .disable = intel_crtc_noop, }; bool intel_encoder_check_non_cloned(struct intel_encoder *encoder) @@ -6816,12 +6839,14 @@ bool intel_set_mode(struct drm_crtc *crtc, DRM_DEBUG_KMS("set mode pipe masks: modeset: %x, prepare: %x, disable: %x\n", modeset_pipes, prepare_pipes, disable_pipes); - intel_modeset_commit_output_state(dev); + for_each_intel_crtc_masked(dev, disable_pipes, intel_crtc) + intel_crtc_disable(&intel_crtc->base); - crtc->enabled = drm_helper_crtc_in_use(crtc); + intel_modeset_commit_output_state(dev); - for_each_intel_crtc_masked(dev, disable_pipes, intel_crtc) - drm_helper_disable_unused_functions(dev); + list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list, + base.head) + intel_crtc->base.enabled = drm_helper_crtc_in_use(crtc); saved_hwmode = crtc->hwmode; saved_mode = crtc->mode;