drm/i915: export a CPT mode set verification function
authorJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 11 Oct 2011 17:43:02 +0000 (10:43 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 21 Oct 2011 06:21:56 +0000 (23:21 -0700)
At the point where we check, we can't do much about the failure, but it
can aid debugging.  Note that the auto-train override bit will be reset
as part of normal mode setting with this patch if a pipe ever does get
stuck, but that's consistent with the workaround for CPT provided by the
hardware team.  This patch helped catch the fact that the pipe wasn't
running in the !composite sync FDI case on my IVB SDV, so has already
shown to be useful.

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Tested-By: Eugeni Dodonov <eugeni.dodonov@intel.com>
Reviewed-By: Eugeni Dodonov <eugeni.dodonov@intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_drv.h

index ed5d4f4d702e84f4d7ed542c9391ab019446aa60..ad3a0187d306b364d6ee4e6e5ce151e53c1c7a69 100644 (file)
@@ -2971,6 +2971,24 @@ static void ironlake_pch_enable(struct drm_crtc *crtc)
        intel_enable_transcoder(dev_priv, pipe);
 }
 
+void intel_cpt_verify_modeset(struct drm_device *dev, int pipe)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       int dslreg = PIPEDSL(pipe), tc2reg = TRANS_CHICKEN2(pipe);
+       u32 temp;
+
+       temp = I915_READ(dslreg);
+       udelay(500);
+       if (wait_for(I915_READ(dslreg) != temp, 5)) {
+               /* Without this, mode sets may fail silently on FDI */
+               I915_WRITE(tc2reg, TRANS_AUTOTRAIN_GEN_STALL_DIS);
+               udelay(250);
+               I915_WRITE(tc2reg, 0);
+               if (wait_for(I915_READ(dslreg) != temp, 5))
+                       DRM_ERROR("mode set failed: pipe %d stuck\n", pipe);
+       }
+}
+
 static void ironlake_crtc_enable(struct drm_crtc *crtc)
 {
        struct drm_device *dev = crtc->dev;
@@ -3340,8 +3358,15 @@ void intel_encoder_prepare(struct drm_encoder *encoder)
 void intel_encoder_commit(struct drm_encoder *encoder)
 {
        struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
+       struct drm_device *dev = encoder->dev;
+       struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
+       struct intel_crtc *intel_crtc = to_intel_crtc(intel_encoder->base.crtc);
+
        /* lvds has its own version of commit see intel_lvds_commit */
        encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON);
+
+       if (HAS_PCH_CPT(dev))
+               intel_cpt_verify_modeset(dev, intel_crtc->pipe);
 }
 
 void intel_encoder_destroy(struct drm_encoder *encoder)
index 3009d2aaaa3a79198495e44b073adf92aed293ba..74c835272292695cda9cd6b6020d1c0a33845bf1 100644 (file)
@@ -1191,6 +1191,8 @@ static void intel_dp_prepare(struct drm_encoder *encoder)
 static void intel_dp_commit(struct drm_encoder *encoder)
 {
        struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+       struct drm_device *dev = encoder->dev;
+       struct intel_crtc *intel_crtc = to_intel_crtc(intel_dp->base.base.crtc);
 
        ironlake_edp_panel_vdd_on(intel_dp);
        intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
@@ -1202,6 +1204,9 @@ static void intel_dp_commit(struct drm_encoder *encoder)
        ironlake_edp_backlight_on(intel_dp);
 
        intel_dp->dpms_mode = DRM_MODE_DPMS_ON;
+
+       if (HAS_PCH_CPT(dev))
+               intel_cpt_verify_modeset(dev, intel_crtc->pipe);
 }
 
 static void
index 5829854ecbf6e62f91401d9d812d3c7d0bc1521d..51b1d752940b32d14fe0aa2006c47e7b99ab1006 100644 (file)
@@ -382,4 +382,6 @@ extern void intel_fb_restore_mode(struct drm_device *dev);
 extern void intel_init_clock_gating(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
                            struct drm_display_mode *mode);
+extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
+
 #endif /* __INTEL_DRV_H__ */