Skip to contentSkip to conversation

drm/i915: get mode clock when reading the pipe config v4

PATCH New Jesse Barnes 1 participant 5 messages May 10, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 drm/i915: get mode clock when reading the pipe config v4

We need this for comparing modes between configuration changes.

v2: try harder to calulate non-simple pixel clocks (Daniel)
call get_clock after getting the encoder config, needed for pixel multiply (Jesse)
v3: drop get_clock now that the pixel_multiply has been moved into
get_pipe_config
v4: re-add get_clock; we need to get the pixel multiplier in the
encoder, so need to calculate the clock value after the encoder's get_config is called

---
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_crt.c     |    1 +
 drivers/gpu/drm/i915/intel_display.c |   80 +++++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/intel_dp.c      |    8 ++++
 drivers/gpu/drm/i915/intel_drv.h     |    3 ++
 drivers/gpu/drm/i915/intel_dvo.c     |    1 +
 drivers/gpu/drm/i915/intel_hdmi.c    |    1 +
 drivers/gpu/drm/i915/intel_lvds.c    |    1 +
 drivers/gpu/drm/i915/intel_sdvo.c    |   24 ++++++++++
 9 files changed, 113 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 14817de..2e284bb 100644
@@ -323,6 +323,7 @@ struct drm_i915_display_funcs {
 	 * fills out the pipe-config with the hw state. */
 	bool (*get_pipe_config)(struct intel_crtc *,
 				struct intel_crtc_config *);
+	void (*get_clock)(struct intel_crtc *, struct intel_crtc_config *);
 	int (*crtc_mode_set)(struct drm_crtc *crtc,
 			     int x, int y,
 			     struct drm_framebuffer *old_fb);
drivers/gpu/drm/i915/intel_crt.c +1 -0
index 789c4ef..bd91e72 100644
@@ -101,6 +101,7 @@ static void intel_crt_get_config(struct intel_encoder *encoder,
 		flags |= DRM_MODE_FLAG_NVSYNC;
 
 	pipe_config->adjusted_mode.flags |= flags;
+	pipe_config->pixel_multiplier = 1;
 }
 
 static void intel_disable_crt(struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_display.c +73 -7

150 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dp.c +8 -0
index a423256..c32429d 100644
@@ -1376,6 +1376,14 @@ static void intel_dp_get_config(struct intel_encoder *encoder,
 		flags |= DRM_MODE_FLAG_NVSYNC;
 
 	pipe_config->adjusted_mode.flags |= flags;
+	pipe_config->pixel_multiplier = 1;
+
+	if (is_cpu_edp(intel_dp)) {
+		if ((I915_READ(DP_A) & DP_PLL_FREQ_MASK) == DP_PLL_FREQ_160MHZ)
+			pipe_config->cpu_edp_link_rate = 162000;
+		else
+			pipe_config->cpu_edp_link_rate = 270000;
+	}
 }
 
 static void intel_disable_dp(struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_drv.h +3 -0
index 4802483..a7c9293 100644
@@ -268,6 +268,9 @@ struct intel_crtc_config {
 	/* FDI configuration, only valid if has_pch_encoder is set. */
 	int fdi_lanes;
 	struct intel_link_m_n fdi_m_n;
+
+	/* CPU eDP config */
+	int cpu_edp_link_rate;
 };
 
 struct intel_crtc {
drivers/gpu/drm/i915/intel_dvo.c +1 -0
index 91e9905..d020a9c 100644
@@ -147,6 +147,7 @@ static void intel_dvo_get_config(struct intel_encoder *encoder,
 		flags |= DRM_MODE_FLAG_NVSYNC;
 
 	pipe_config->adjusted_mode.flags |= flags;
+	pipe_config->pixel_multiplier = 1;
 }
 
 static void intel_disable_dvo(struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_hdmi.c +1 -0
index 9091655..7b55a8a 100644
@@ -678,6 +678,7 @@ static void intel_hdmi_get_config(struct intel_encoder *encoder,
 		flags |= DRM_MODE_FLAG_NVSYNC;
 
 	pipe_config->adjusted_mode.flags |= flags;
+	pipe_config->pixel_multiplier = 1;
 }
 
 static void intel_enable_hdmi(struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_lvds.c +1 -0
index f87dd08..11cc0ac 100644
@@ -109,6 +109,7 @@ static void intel_lvds_get_config(struct intel_encoder *encoder,
 		flags |= DRM_MODE_FLAG_PVSYNC;
 
 	pipe_config->adjusted_mode.flags |= flags;
+	pipe_config->pixel_multiplier = 1;
 }
 
 /* The LVDS pin pair needs to be on before the DPLLs are enabled.
drivers/gpu/drm/i915/intel_sdvo.c +24 -0
index 416d23c..ee7f0ab 100644
@@ -780,6 +780,11 @@ static bool intel_sdvo_set_clock_rate_mult(struct intel_sdvo *intel_sdvo, u8 val
 	return intel_sdvo_set_value(intel_sdvo, SDVO_CMD_SET_CLOCK_RATE_MULT, &val, 1);
 }
 
+static bool intel_sdvo_get_clock_rate_mult(struct intel_sdvo *intel_sdvo, u8 *val)
+{
+	return intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT, &val, 1);
+}
+
 static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
 					 const struct drm_display_mode *mode)
 {
@@ -1315,6 +1320,7 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
 	struct intel_sdvo *intel_sdvo = to_intel_sdvo(&encoder->base);
 	struct intel_sdvo_dtd dtd;
 	u32 flags = 0;
+	u8 val;
 	bool ret;
 
 	ret = intel_sdvo_get_input_timing(intel_sdvo, &dtd);
@@ -1334,6 +1340,24 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
 		flags |= DRM_MODE_FLAG_NVSYNC;
 
 	pipe_config->adjusted_mode.flags |= flags;
+
+	ret = intel_sdvo_get_clock_rate_mult(intel_sdvo, &val);
+	if (!ret) {
+		DRM_DEBUG_DRIVER("failed to retrieve clock rate multiplier\n");
+		return;
+	}
+
+	switch (val) {
+	case SDVO_CLOCK_RATE_MULT_1X:
+		pipe_config->pixel_multiplier = 1;
+		break;
+	case SDVO_CLOCK_RATE_MULT_2X:
+		pipe_config->pixel_multiplier = 2;
+		break;
+	case SDVO_CLOCK_RATE_MULT_4X:
+		pipe_config->pixel_multiplier = 4;
+		break;
+	}
 }
 
 static void intel_disable_sdvo(struct intel_encoder *encoder)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/4 drm/i915: copy fetched mode state into crtc at setup_hw time

We already fetch and track other state into the main CRTC and encoder structs, and for fastboot we need to do the same with the mode and clock data we read out.

---
 drivers/gpu/drm/i915/intel_display.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/gpu/drm/i915/intel_display.c +29 -0
index 3d95a0e..53ad51c 100644
@@ -4788,6 +4788,24 @@ static void intel_get_pipe_timings(struct intel_crtc *crtc,
 	pipe_config->requested_mode.hdisplay = ((tmp >> 16) & 0xffff) + 1;
 }
 
+static void intel_pipe_config_to_crtc(struct intel_crtc *intel_crtc,
+				      struct intel_crtc_config *pipe_config)
+{
+	struct drm_crtc *crtc = &intel_crtc->base;
+
+	crtc->mode.hdisplay = pipe_config->adjusted_mode.crtc_hdisplay;
+	crtc->mode.htotal = pipe_config->adjusted_mode.crtc_htotal;
+	crtc->mode.hsync_start = pipe_config->adjusted_mode.crtc_hsync_start;
+	crtc->mode.hsync_end = pipe_config->adjusted_mode.crtc_hsync_end;
+
+	crtc->mode.vdisplay = pipe_config->adjusted_mode.crtc_vdisplay;
+	crtc->mode.vtotal = pipe_config->adjusted_mode.crtc_vtotal;
+	crtc->mode.vsync_start = pipe_config->adjusted_mode.crtc_vsync_start;
+	crtc->mode.vsync_end = pipe_config->adjusted_mode.crtc_vsync_end;
+
+	crtc->mode.flags = pipe_config->adjusted_mode.flags;
+}
+
 static void i9xx_set_pipeconf(struct intel_crtc *intel_crtc)
 {
 	struct drm_device *dev = intel_crtc->base.dev;
@@ -9578,6 +9596,13 @@ setup_pipes:
 
 		crtc->base.enabled = crtc->active;
 
+		if (crtc->active) {
+			intel_pipe_config_to_crtc(crtc, &crtc->config);
+
+			DRM_DEBUG_KMS("[CRTC:%d] found active mode: ");
+			drm_mode_debug_printmodeline(&crtc->base.mode);
+		}
+
 		DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n",
 			      crtc->base.base.id,
 			      crtc->active ? "enabled" : "disabled");
@@ -9596,6 +9621,10 @@ setup_pipes:
 				encoder->get_config(encoder, &crtc->config);
 				dev_priv->display.get_clock(crtc,
 							    &crtc->config);
+				crtc->base.mode.clock =
+					crtc->config.adjusted_mode.clock;
+				crtc->base.mode.flags |=
+					crtc->config.adjusted_mode.flags;
 			}
 			encoder->base.crtc = &crtc->base;
 		} else {
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 3/4 HACK: drm/i915: turn off panel fitting at flip time if needed

In reply to Jesse Barnes

Need better pfit tracking to do this right.

---
 drivers/gpu/drm/i915/intel_display.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/gpu/drm/i915/intel_display.c +12 -0
index 53ad51c..591ac2d 100644
@@ -2301,6 +2301,18 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 		return ret;
 	}
 
+	/* Update pipe size and adjust fitter if needed */
+	I915_WRITE(PIPESRC(intel_crtc->pipe),
+		   ((crtc->mode.hdisplay - 1) << 16) |
+		   (crtc->mode.vdisplay - 1));
+	if (!intel_crtc->config.pch_pfit.size &&
+	    (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) ||
+	     intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))) {
+		I915_WRITE(PF_CTL(intel_crtc->pipe), 0);
+		I915_WRITE(PF_WIN_POS(intel_crtc->pipe), 0);
+		I915_WRITE(PF_WIN_SZ(intel_crtc->pipe), 0);
+	}
+
 	ret = dev_priv->display.update_plane(crtc, fb, x, y);
 	if (ret) {
 		intel_unpin_fb_obj(to_intel_framebuffer(fb)->obj);
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 4/4 HACK: drm/i915: flip on a no fb -> fb transition

In reply to Jesse Barnes

This needs better checking since the display could be off in this case.

---
 drivers/gpu/drm/i915/intel_display.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -2
index 591ac2d..dda4501 100644
@@ -8422,8 +8422,8 @@ intel_set_config_compute_mode_changes(struct drm_mode_set *set,
 	if (set->crtc->fb != set->fb) {
 		/* If we have no fb then treat it as a full mode set */
 		if (set->crtc->fb == NULL) {
-			DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
-			config->mode_changed = true;
+			DRM_DEBUG_KMS("crtc has no fb, will flip\n");
+			config->fb_changed = true;
 		} else if (set->fb == NULL) {
 			config->mode_changed = true;
 		} else if (set->fb->pixel_format !=
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 1/1 drm/i915: fetch PCH PLL state at init time v2

In reply to Jesse Barnes

We need to properly track PCH PLL sharing configs, and generally set up PCH PLL state at init time as part of the state readout process.

v2: update to new code, use intel_crtc instead (Jesse)

---
 drivers/gpu/drm/i915/intel_display.c |   48 +++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +47 -1
index dda4501..2e7a5bb 100644
@@ -6974,6 +6974,49 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
 	pipe_config->adjusted_mode.clock = clock.dot;
 }
 
+static void ironlake_crtc_pll_get(struct intel_crtc *crtc)
+{
+	struct drm_device *dev = crtc->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 dpll_sel;
+
+	if (HAS_PCH_IBX(dev_priv->dev))
+		crtc->pch_pll = &dev_priv->pch_plls[crtc->pipe];
+
+	if (HAS_PCH_CPT(dev_priv->dev)) {
+		dpll_sel = I915_READ(PCH_DPLL_SEL);
+
+		switch (crtc->pipe) {
+		case PIPE_A:
+			if ((dpll_sel & TRANSA_DPLL_ENABLE) &&
+			    (dpll_sel & TRANSA_DPLLB_SEL))
+				crtc->pch_pll = &dev_priv->pch_plls[1];
+			else if (dpll_sel & TRANSA_DPLL_ENABLE)
+				crtc->pch_pll = &dev_priv->pch_plls[0];
+			break;
+		case PIPE_B:
+			if ((dpll_sel & TRANSB_DPLL_ENABLE) &&
+			    (dpll_sel & TRANSB_DPLLB_SEL))
+				crtc->pch_pll = &dev_priv->pch_plls[1];
+			else if (dpll_sel & TRANSB_DPLL_ENABLE)
+				crtc->pch_pll = &dev_priv->pch_plls[0];
+			break;
+		case PIPE_C:
+			if ((dpll_sel & TRANSC_DPLL_ENABLE) &&
+			    (dpll_sel & TRANSC_DPLLB_SEL))
+				crtc->pch_pll = &dev_priv->pch_plls[1];
+			else if (dpll_sel & TRANSC_DPLL_ENABLE)
+				crtc->pch_pll = &dev_priv->pch_plls[0];
+			break;
+		default:
+			BUG();
+		}
+	}
+
+	crtc->pch_pll->refcount++;
+	crtc->pch_pll->active = 1;
+}
+
 static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
 				    struct intel_crtc_config *pipe_config)
 {
@@ -7021,6 +7064,8 @@ static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
 	do_div(clock, link_n);
 
 	pipe_config->adjusted_mode.clock = clock;
+
+	ironlake_crtc_pll_get(crtc);
 }
 
 /** Returns the currently programmed mode of the given pipe. */
@@ -9611,7 +9656,8 @@ setup_pipes:
 		if (crtc->active) {
 			intel_pipe_config_to_crtc(crtc, &crtc->config);
 
-			DRM_DEBUG_KMS("[CRTC:%d] found active mode: ");
+			DRM_DEBUG_KMS("[CRTC:%d] found active mode: ",
+				      crtc->base.base.id);
 			drm_mode_debug_printmodeline(&crtc->base.mode);
 		}
 
Signature · 1 line
1.7.9.5