diff mbox

[RFC,13/30] drm/i915: add intel_ddi_commit

Message ID 1346191621-12996-14-git-send-email-przanoni@gmail.com (mailing list archive)
State RFC
Headers show

Commit Message

Paulo Zanoni Aug. 28, 2012, 10:06 p.m. UTC
From: Paulo Zanoni <paulo.r.zanoni@intel.com>

On DDI code we should only enable the DDI pipe registers after the
link train, so adjust the code in a way that makes this possible. Also
use intel_ddi_commit for the HDMI mode.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c  | 27 +++++++++++++++++++--------
 drivers/gpu/drm/i915/intel_dp.c   |  2 +-
 drivers/gpu/drm/i915/intel_drv.h  |  2 ++
 drivers/gpu/drm/i915/intel_hdmi.c |  2 +-
 4 files changed, 23 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 23ec6a2..151963e 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -787,14 +787,14 @@  bool intel_ddi_pll_mode_set(struct drm_crtc *crtc)
 	return true;
 }
 
-static void intel_ddi_enable_pipe(struct intel_encoder *intel_encoder,
-				  struct drm_display_mode *adjusted_mode)
+static void intel_ddi_enable_pipe(struct intel_encoder *intel_encoder)
 {
 	struct drm_encoder *encoder = &intel_encoder->base;
 	struct drm_device *dev = encoder->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc = encoder->crtc;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct drm_display_mode *mode = &crtc->mode;
 	int port;
 	int pipe = intel_crtc->pipe;
 	u32 func_val, msa_val;
@@ -836,9 +836,9 @@  static void intel_ddi_enable_pipe(struct intel_encoder *intel_encoder,
 		     intel_crtc->bpp);
 	}
 
-	if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
+	if (mode->flags & DRM_MODE_FLAG_PVSYNC)
 		func_val |= PIPE_DDI_PVSYNC;
-	if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
+	if (mode->flags & DRM_MODE_FLAG_PHSYNC)
 		func_val |= PIPE_DDI_PHSYNC;
 
 	if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
@@ -875,10 +875,10 @@  static void intel_ddi_enable_pipe(struct intel_encoder *intel_encoder,
 				      pipe_name(intel_crtc->pipe));
 
 			DRM_DEBUG_KMS("HDMI audio: write eld information\n");
-			intel_write_eld(encoder, adjusted_mode);
+			intel_write_eld(encoder, mode);
 		}
 
-		intel_hdmi->set_infoframes(encoder, adjusted_mode);
+		intel_hdmi->set_infoframes(encoder, mode);
 	} else {
 		if (intel_dp->has_audio)
 			DRM_DEBUG_KMS("DP audio not supported yet\n");
@@ -929,8 +929,6 @@  void intel_ddi_mode_set(struct drm_encoder *encoder,
 
 		intel_dp_init_link_config(intel_dp);
 	}
-
-	intel_ddi_enable_pipe(intel_encoder, adjusted_mode);
 }
 
 static void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv,
@@ -974,6 +972,19 @@  void intel_ddi_dpms(struct drm_encoder *encoder, int mode)
 		intel_wait_ddi_buf_idle(dev_priv, port);
 }
 
+void intel_ddi_commit(struct drm_encoder *encoder)
+{
+	struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
+
+	if (intel_encoder->type != INTEL_OUTPUT_HDMI)
+		intel_dp_commit(encoder);
+
+	intel_ddi_enable_pipe(intel_encoder);
+
+	if (intel_encoder->type == INTEL_OUTPUT_HDMI)
+		intel_ddi_dpms(encoder, DRM_MODE_DPMS_ON);
+}
+
 static void intel_ddi_disable_pipe(struct drm_i915_private *dev_priv,
 				   enum pipe pipe)
 {
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index a7a5178..24c699a 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1265,7 +1265,7 @@  static void intel_dp_prepare(struct drm_encoder *encoder)
 	intel_dp_link_down(intel_dp);
 }
 
-static void intel_dp_commit(struct drm_encoder *encoder)
+void intel_dp_commit(struct drm_encoder *encoder)
 {
 	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 	struct drm_device *dev = encoder->dev;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 1b9c549..f3f5b83 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -383,6 +383,7 @@  void
 intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
 		 struct drm_display_mode *adjusted_mode);
 extern void intel_dp_init_link_config(struct intel_dp *intel_dp);
+extern void intel_dp_commit(struct drm_encoder *encoder);
 extern bool intel_dpd_is_edp(struct drm_device *dev);
 extern void intel_edp_link_config(struct intel_encoder *, int *, int *);
 extern int intel_edp_target_clock(struct intel_encoder *,
@@ -533,5 +534,6 @@  extern void intel_ddi_mode_set(struct drm_encoder *encoder,
 				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);
+extern void intel_ddi_commit(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 c56d213..ad58bec 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -853,7 +853,7 @@  static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs_hsw = {
 	.mode_fixup = intel_hdmi_mode_fixup,
 	.prepare = intel_encoder_prepare,
 	.mode_set = intel_ddi_mode_set,
-	.commit = intel_encoder_commit,
+	.commit = intel_ddi_commit,
 	.disable = intel_ddi_disable,
 };