Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Packard <keithp@keithp.com>
To: przanoni@gmail.com, intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: Re: [PATCH] drm/i915: add missing "break"
Date: Thu, 22 Sep 2011 12:55:22 -0700	[thread overview]
Message-ID: <yunr5381hed.fsf@aiko.keithp.com> (raw)
In-Reply-To: <1316715222-2815-1-git-send-email-przanoni@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 5712 bytes --]

On Thu, 22 Sep 2011 15:13:42 -0300, przanoni@gmail.com wrote:

> It seems to be missing from this commit:
>   "drm/i915: split out PCH refclk update code"

Oh, this code is missing far more than that. It doesn't deal with the
LVDS case at all.

Here's a patch which turns on the right bits of SSC, in the right order,
for any combination of CPU-eDP, PCH-eDP and LVDS.

Jesse: you wrote this stuff, can you review what I did? Also, my two SNB
systems (X220 and MacBook Air) both have a BIOS table that disables SSC,
is there any reason for us to believe the BIOS table on a PCH system?
Can't we always use SSC?

I've tested this on LVDS and CPU-connected eDP with and without SSC and
it seems to work for me.

From ea63d98df915f81c80cf4f91bf9d1bcaece7fce0 Mon Sep 17 00:00:00 2001
From: Keith Packard <keithp@keithp.com>
Date: Thu, 22 Sep 2011 12:01:57 -0700
Subject: [PATCH 1/3] drm/i915: Fix PCH SSC reference clock settings

The PCH refclk settings are global, so we need to look at all of the
encoders, not just the current encoder when deciding how to configure
it. Also, handle systems with more than one panel (any combination of
PCH/non-PCH eDP and LVDS).

Disable SSC clocks when no panels are connected.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 drivers/gpu/drm/i915/intel_display.c |   88 ++++++++++++++++++++++++---------
 1 files changed, 64 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 04411ad..01a52fc 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5113,9 +5113,11 @@ static void ironlake_update_pch_refclk(struct drm_device *dev)
 	struct drm_mode_config *mode_config = &dev->mode_config;
 	struct drm_crtc *crtc;
 	struct intel_encoder *encoder;
-	struct intel_encoder *has_edp_encoder = NULL;
 	u32 temp;
 	bool has_lvds = false;
+	bool has_cpu_edp = false;
+	bool has_pch_edp = false;
+	bool has_panel = false;
 
 	/* We need to take the global config into account */
 	list_for_each_entry(crtc, &mode_config->crtc_list, head) {
@@ -5124,18 +5126,23 @@ static void ironlake_update_pch_refclk(struct drm_device *dev)
 
 		list_for_each_entry(encoder, &mode_config->encoder_list,
 				    base.head) {
-			if (encoder->base.crtc != crtc)
-				continue;
-
 			switch (encoder->type) {
 			case INTEL_OUTPUT_LVDS:
+				has_panel = true;
 				has_lvds = true;
+				break;
 			case INTEL_OUTPUT_EDP:
-				has_edp_encoder = encoder;
+				has_panel = true;
+				if (intel_encoder_is_pch_edp(&encoder->base))
+					has_pch_edp = true;
+				else
+					has_cpu_edp = true;
 				break;
 			}
 		}
 	}
+	DRM_DEBUG_KMS("has_panel %d has_lvds %d has_pch_edp %d has_cpu_edp %d\n",
+		      has_panel, has_lvds, has_pch_edp, has_cpu_edp);
 
 	/* Ironlake: try to setup display ref clock before DPLL
 	 * enabling. This is only under driver's control after
@@ -5146,36 +5153,69 @@ static void ironlake_update_pch_refclk(struct drm_device *dev)
 	/* Always enable nonspread source */
 	temp &= ~DREF_NONSPREAD_SOURCE_MASK;
 	temp |= DREF_NONSPREAD_SOURCE_ENABLE;
-	temp &= ~DREF_SSC_SOURCE_MASK;
-	temp |= DREF_SSC_SOURCE_ENABLE;
-	I915_WRITE(PCH_DREF_CONTROL, temp);
 
-	POSTING_READ(PCH_DREF_CONTROL);
-	udelay(200);
+	if (has_panel) {
+		temp &= ~DREF_SSC_SOURCE_MASK;
+		temp |= DREF_SSC_SOURCE_ENABLE;
 
-	if (has_edp_encoder) {
+		/* SSC must be turned on before enabling the CPU output  */
 		if (intel_panel_use_ssc(dev_priv)) {
+			DRM_DEBUG_KMS("Using SSC on panel\n");
 			temp |= DREF_SSC1_ENABLE;
-			I915_WRITE(PCH_DREF_CONTROL, temp);
-
-			POSTING_READ(PCH_DREF_CONTROL);
-			udelay(200);
 		}
+
+		/* Get SSC going before enabling the outputs */
+		I915_WRITE(PCH_DREF_CONTROL, temp);
+		POSTING_READ(PCH_DREF_CONTROL);
+		udelay(200);
+
 		temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK;
+		temp &= ~DREF_SUPERSPREAD_SOURCE_MASK;
 
 		/* Enable CPU source on CPU attached eDP */
-		if (!intel_encoder_is_pch_edp(&has_edp_encoder->base)) {
-			if (intel_panel_use_ssc(dev_priv))
+		if (has_cpu_edp) {
+			if (intel_panel_use_ssc(dev_priv)) {
+				DRM_DEBUG_KMS("Using SSC on eDP\n");
 				temp |= DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD;
+			}
 			else
 				temp |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD;
-		} else {
-			/* Enable SSC on PCH eDP if needed */
-			if (intel_panel_use_ssc(dev_priv)) {
-				DRM_ERROR("enabling SSC on PCH\n");
-				temp |= DREF_SUPERSPREAD_SOURCE_ENABLE;
-			}
-		}
+		} else
+			temp |= DREF_CPU_SOURCE_OUTPUT_DISABLE;
+
+		/* Enable SSC on PCH eDP or LVDS if needed */
+		if ((has_pch_edp || has_lvds) && intel_panel_use_ssc(dev_priv)) {
+			DRM_DEBUG_KMS("Using SSC on PCH eDP or LVDS\n");
+			temp |= DREF_SUPERSPREAD_SOURCE_ENABLE;
+		} else
+			temp |= DREF_SUPERSPREAD_SOURCE_DISABLE;
+
+		I915_WRITE(PCH_DREF_CONTROL, temp);
+		POSTING_READ(PCH_DREF_CONTROL);
+		udelay(200);
+	} else {
+		temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK;
+		temp &= ~DREF_SUPERSPREAD_SOURCE_MASK;
+
+		DRM_DEBUG_KMS("Disabling SSC entirely\n");
+
+		/* Turn off CPU output */
+		temp |= DREF_CPU_SOURCE_OUTPUT_DISABLE;
+
+		/* Disable SSC on PCH */
+		temp |= DREF_SUPERSPREAD_SOURCE_DISABLE;
+
+		I915_WRITE(PCH_DREF_CONTROL, temp);
+		POSTING_READ(PCH_DREF_CONTROL);
+		udelay(200);
+
+		/* Turn off the SSC source */
+		temp &= ~DREF_SSC_SOURCE_MASK;
+		temp |= DREF_SSC_SOURCE_DISABLE;
+
+		/* Turn off SSC1 */
+		temp &= ~ DREF_SSC1_ENABLE;
+
 		I915_WRITE(PCH_DREF_CONTROL, temp);
 		POSTING_READ(PCH_DREF_CONTROL);
 		udelay(200);
-- 
1.7.6.3




-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2011-09-22 19:55 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-22 18:13 [PATCH] drm/i915: add missing "break" przanoni
2011-09-22 19:55 ` Keith Packard [this message]
2011-09-23  2:43   ` Jesse Barnes
2011-09-23  4:35     ` Keith Packard
2011-09-23 12:06       ` Paulo Zanoni
2011-09-23 16:15         ` Keith Packard
2011-09-23 16:30           ` Paulo Zanoni
2011-09-23 19:07           ` Chris Wilson
2011-09-26 20:56             ` Keith Packard
2011-09-26 23:05               ` Keith Packard
2011-09-27  6:11                 ` PCH reference clock cleanups Keith Packard
2011-09-27  6:11                   ` [PATCH 1/9] drm/i915: broken copyright encoding in intel_bios.c Keith Packard
2011-09-27  6:11                   ` [PATCH 2/9] drm/i915: Use DRM_DEBUG_KMS for all messages " Keith Packard
2011-09-27 16:39                     ` Chris Wilson
2011-09-27  6:11                   ` [PATCH 3/9] drv/i915: Pull display_clock_mode out of VBT table Keith Packard
2011-09-27 16:40                     ` Chris Wilson
2011-09-27  6:11                   ` [PATCH 4/9] drm/i915: Document a few more BDB_GENERAL_FEATURES bits from PCH BIOS Keith Packard
2011-09-27  6:11                   ` [PATCH 5/9] drm/i915: Allow SSC parameter to override VBT value Keith Packard
2011-09-27 16:41                     ` Chris Wilson
2011-09-27  6:11                   ` [PATCH 6/9] drm/i915: Fix PCH SSC reference clock settings Keith Packard
2011-09-27 16:47                     ` Chris Wilson
2011-09-27 18:03                       ` Keith Packard
2011-09-28  9:09                         ` Chris Wilson
2011-09-28 16:36                           ` Keith Packard
2011-09-27  6:11                   ` [PATCH 7/9] drm/i915: Use CK505 as non-SSC source where available Keith Packard
2011-09-27 16:49                     ` Chris Wilson
2011-09-27  6:11                   ` [PATCH 8/9] drm/i915: All PCH refclks are 120MHz Keith Packard
2011-09-27 16:53                     ` Chris Wilson
2011-09-27  6:11                   ` [PATCH 9/9] drm/i915: Initialize PCH refclks at modeset init time Keith Packard
2011-09-27 16:56                     ` Chris Wilson
2011-09-27 18:11                       ` Keith Packard
2011-10-03 21:12                         ` [Intel-gfx] " Jesse Barnes
2011-09-28 23:15                     ` Keith Packard
2011-09-27  9:01                   ` PCH reference clock cleanups Chris Wilson
2011-09-27 16:54                     ` Keith Packard
2011-09-28 18:22                   ` [Intel-gfx] " Paulo Zanoni
2011-09-28 20:02                     ` Keith Packard
2011-10-03 21:14                     ` Jesse Barnes
2011-10-03 23:18                       ` [Intel-gfx] " Keith Packard
2011-10-03 23:21                         ` Jesse Barnes
2011-10-03 23:39                           ` Keith Packard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yunr5381hed.fsf@aiko.keithp.com \
    --to=keithp@keithp.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=paulo.r.zanoni@intel.com \
    --cc=przanoni@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox