From patchwork Tue Aug 28 22:06:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 1382711 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 22038DF283 for ; Tue, 28 Aug 2012 22:10:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D772D9E9AF for ; Tue, 28 Aug 2012 15:10:39 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yx0-f177.google.com (mail-yx0-f177.google.com [209.85.213.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 484DA9E73D for ; Tue, 28 Aug 2012 15:07:23 -0700 (PDT) Received: by mail-yx0-f177.google.com with SMTP id q9so1203648yen.36 for ; Tue, 28 Aug 2012 15:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=emQhLGjKWk+emWHwZKmmDJxHI8ndhcf/Grjks9SCca0=; b=UIDIMCDqwzr4wjr84XyMJfhPGofBooLNy7gdwheRTJc4WjREArIogIXNZ8HSmmQP2T OjE6rWdsqpkiXPxbLmYBTYi/CBv0bLbvprx4uxvcbSIFlYvBXsGZwM4njYgelpWvJURR jAG7Z2phgjzTedLKlH+tTvB0OYP4SSJ8dAEJgy82rHA1RWJjV4Fu1yefROIET6wmLHb7 WUf37j7iWrZYaGG5aXaCQCLY9s8KAU5wwr9vrrDvX7mkUpgPRmZrZHRUiFOdTPlTVdzX wzlFbo3ZXwTQUuitsXVnJlp4uSs4E9Whr39E9FVfLiCdvp6gRnznyZaBAuN+nSPH1j+W eQFA== Received: by 10.236.185.201 with SMTP id u49mr15363446yhm.28.1346191643217; Tue, 28 Aug 2012 15:07:23 -0700 (PDT) Received: from vicky.domain.invalid (189.114.178.236.dynamic.adsl.gvt.net.br. [189.114.178.236]) by mx.google.com with ESMTPS id z3sm4434172anj.20.2012.08.28.15.07.21 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Aug 2012 15:07:22 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 28 Aug 2012 19:06:35 -0300 Message-Id: <1346191621-12996-5-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1346191621-12996-1-git-send-email-przanoni@gmail.com> References: <1346191621-12996-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [RFC 04/30] drm/i915: implement DDI disable function 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 From: Paulo Zanoni It follows the "mode unset" sequence recommended by the documentation. This is necessary so we can make PLLs available for the other mode sets and it also helps preventing machine hangs. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/intel_ddi.c | 31 +++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_hdmi.c | 1 + 3 files changed, 33 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index 4fd22ae..e3dac45 100644 --- a/drivers/gpu/drm/i915/intel_ddi.c +++ b/drivers/gpu/drm/i915/intel_ddi.c @@ -841,6 +841,37 @@ static void intel_ddi_disable_port(struct drm_i915_private *dev_priv, I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE); } +static bool intel_ddi_port_disabled(struct drm_i915_private *dev_priv, + enum port port) +{ + return (I915_READ(PORT_CLK_SEL(port)) == PORT_CLK_SEL_NONE); +} + +void intel_ddi_disable(struct drm_encoder *encoder) +{ + struct drm_i915_private *dev_priv = encoder->dev->dev_private; + struct drm_crtc *crtc = encoder->crtc; + struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); + int port = intel_hdmi->ddi_port; + + if (intel_ddi_port_disabled(dev_priv, port)) + return; + + if (!crtc) { + WARN(1, "Disabling encoder on port %c without CRTC\n", + port_name(port)); + } else { + struct intel_crtc *intel_crtc = to_intel_crtc(crtc); + int pipe = intel_crtc->pipe; + struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; + + (*crtc_funcs->dpms)(crtc, DRM_MODE_DPMS_OFF); + intel_ddi_disable_pipe(dev_priv, pipe); + } + + intel_ddi_disable_port(dev_priv, port); +} + void intel_ddi_pll_init(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 2578158..b99af38 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -526,5 +526,6 @@ extern void intel_ddi_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode); extern void intel_ddi_pll_init(struct drm_device *dev); +extern void intel_ddi_disable(struct drm_encoder *encoder); #endif /* __INTEL_DRV_H__ */ diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c index e4c37bb..c56d213 100644 --- a/drivers/gpu/drm/i915/intel_hdmi.c +++ b/drivers/gpu/drm/i915/intel_hdmi.c @@ -854,6 +854,7 @@ static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs_hsw = { .prepare = intel_encoder_prepare, .mode_set = intel_ddi_mode_set, .commit = intel_encoder_commit, + .disable = intel_ddi_disable, }; static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = {