Reviewed-by: Rodrigo Vivi <<a href="mailto:rodrigo.vivi@gmail.com">rodrigo.vivi@gmail.com</a>><br><br><div class="gmail_quote">On Tue, Oct 23, 2012 at 6:29 PM, Paulo Zanoni <span dir="ltr"><<a href="mailto:przanoni@gmail.com" target="_blank">przanoni@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Paulo Zanoni <<a href="mailto:paulo.r.zanoni@intel.com">paulo.r.zanoni@intel.com</a>><br>
<br>
The way we enable and disable the PCH on Haswell changed considerably<br>
since now we have only one PCH transcoder, so we can't keep the same<br>
asserts and we also can't just unconditionally disable the PCH<br>
transcoder for non-PCH outputs. So let's fork a Haswell version.<br>
<br>
These new functions look exactly the same as the ironlake versions.<br>
The next patches will introduce the differences.<br>
<br>
Signed-off-by: Paulo Zanoni <<a href="mailto:paulo.r.zanoni@intel.com">paulo.r.zanoni@intel.com</a>><br>
---<br>
 drivers/gpu/drm/i915/intel_display.c | 183 ++++++++++++++++++++++++++++++++++-<br>
 1 file changed, 181 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c<br>
index 0fb5542..eb4dba6 100644<br>
--- a/drivers/gpu/drm/i915/intel_display.c<br>
+++ b/drivers/gpu/drm/i915/intel_display.c<br>
@@ -3283,6 +3283,99 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)<br>
        intel_wait_for_vblank(dev, intel_crtc->pipe);<br>
 }<br>
<br>
+static void haswell_crtc_enable(struct drm_crtc *crtc)<br>
+{<br>
+       struct drm_device *dev = crtc->dev;<br>
+       struct drm_i915_private *dev_priv = dev->dev_private;<br>
+       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);<br>
+       struct intel_encoder *encoder;<br>
+       int pipe = intel_crtc->pipe;<br>
+       int plane = intel_crtc->plane;<br>
+       u32 temp;<br>
+       bool is_pch_port;<br>
+<br>
+       WARN_ON(!crtc->enabled);<br>
+<br>
+       if (intel_crtc->active)<br>
+               return;<br>
+<br>
+       intel_crtc->active = true;<br>
+       intel_update_watermarks(dev);<br>
+<br>
+       if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {<br>
+               temp = I915_READ(PCH_LVDS);<br>
+               if ((temp & LVDS_PORT_EN) == 0)<br>
+                       I915_WRITE(PCH_LVDS, temp | LVDS_PORT_EN);<br>
+       }<br>
+<br>
+       is_pch_port = intel_crtc_driving_pch(crtc);<br>
+<br>
+       if (is_pch_port) {<br>
+               ironlake_fdi_pll_enable(intel_crtc);<br>
+       } else {<br>
+               assert_fdi_tx_disabled(dev_priv, pipe);<br>
+               assert_fdi_rx_disabled(dev_priv, pipe);<br>
+       }<br>
+<br>
+       for_each_encoder_on_crtc(dev, crtc, encoder)<br>
+               if (encoder->pre_enable)<br>
+                       encoder->pre_enable(encoder);<br>
+<br>
+       if (IS_HASWELL(dev))<br>
+               intel_ddi_enable_pipe_clock(intel_crtc);<br>
+<br>
+       /* Enable panel fitting for LVDS */<br>
+       if (dev_priv->pch_pf_size &&<br>
+           (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) || HAS_eDP)) {<br>
+               /* Force use of hard-coded filter coefficients<br>
+                * as some pre-programmed values are broken,<br>
+                * e.g. x201.<br>
+                */<br>
+               I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3);<br>
+               I915_WRITE(PF_WIN_POS(pipe), dev_priv->pch_pf_pos);<br>
+               I915_WRITE(PF_WIN_SZ(pipe), dev_priv->pch_pf_size);<br>
+       }<br>
+<br>
+       /*<br>
+        * On ILK+ LUT must be loaded before the pipe is running but with<br>
+        * clocks enabled<br>
+        */<br>
+       intel_crtc_load_lut(crtc);<br>
+<br>
+       if (IS_HASWELL(dev)) {<br>
+               intel_ddi_set_pipe_settings(crtc);<br>
+               intel_ddi_enable_pipe_func(crtc);<br>
+       }<br>
+<br>
+       intel_enable_pipe(dev_priv, pipe, is_pch_port);<br>
+       intel_enable_plane(dev_priv, plane, pipe);<br>
+<br>
+       if (is_pch_port)<br>
+               ironlake_pch_enable(crtc);<br>
+<br>
+       mutex_lock(&dev->struct_mutex);<br>
+       intel_update_fbc(dev);<br>
+       mutex_unlock(&dev->struct_mutex);<br>
+<br>
+       intel_crtc_update_cursor(crtc, true);<br>
+<br>
+       for_each_encoder_on_crtc(dev, crtc, encoder)<br>
+               encoder->enable(encoder);<br>
+<br>
+       if (HAS_PCH_CPT(dev))<br>
+               intel_cpt_verify_modeset(dev, intel_crtc->pipe);<br>
+<br>
+       /*<br>
+        * There seems to be a race in PCH platform hw (at least on some<br>
+        * outputs) where an enabled pipe still completes any pageflip right<br>
+        * away (as if the pipe is off) instead of waiting for vblank. As soon<br>
+        * as the first vblank happend, everything works as expected. Hence just<br>
+        * wait for one vblank before returning to avoid strange things<br>
+        * happening.<br>
+        */<br>
+       intel_wait_for_vblank(dev, intel_crtc->pipe);<br>
+}<br>
+<br>
 static void ironlake_crtc_disable(struct drm_crtc *crtc)<br>
 {<br>
        struct drm_device *dev = crtc->dev;<br>
@@ -3369,6 +3462,92 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)<br>
        mutex_unlock(&dev->struct_mutex);<br>
 }<br>
<br>
+static void haswell_crtc_disable(struct drm_crtc *crtc)<br>
+{<br>
+       struct drm_device *dev = crtc->dev;<br>
+       struct drm_i915_private *dev_priv = dev->dev_private;<br>
+       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);<br>
+       struct intel_encoder *encoder;<br>
+       int pipe = intel_crtc->pipe;<br>
+       int plane = intel_crtc->plane;<br>
+       u32 reg, temp;<br>
+<br>
+<br>
+       if (!intel_crtc->active)<br>
+               return;<br>
+<br>
+       for_each_encoder_on_crtc(dev, crtc, encoder)<br>
+               encoder->disable(encoder);<br>
+<br>
+       intel_crtc_wait_for_pending_flips(crtc);<br>
+       drm_vblank_off(dev, pipe);<br>
+       intel_crtc_update_cursor(crtc, false);<br>
+<br>
+       intel_disable_plane(dev_priv, plane, pipe);<br>
+<br>
+       if (dev_priv->cfb_plane == plane)<br>
+               intel_disable_fbc(dev);<br>
+<br>
+       intel_disable_pipe(dev_priv, pipe);<br>
+<br>
+       if (IS_HASWELL(dev))<br>
+               intel_ddi_disable_pipe_func(dev_priv, pipe);<br>
+<br>
+       /* Disable PF */<br>
+       I915_WRITE(PF_CTL(pipe), 0);<br>
+       I915_WRITE(PF_WIN_SZ(pipe), 0);<br>
+<br>
+       if (IS_HASWELL(dev))<br>
+               intel_ddi_disable_pipe_clock(intel_crtc);<br>
+<br>
+       for_each_encoder_on_crtc(dev, crtc, encoder)<br>
+               if (encoder->post_disable)<br>
+                       encoder->post_disable(encoder);<br>
+<br>
+       ironlake_fdi_disable(crtc);<br>
+<br>
+       intel_disable_transcoder(dev_priv, pipe);<br>
+<br>
+       if (HAS_PCH_CPT(dev)) {<br>
+               /* disable TRANS_DP_CTL */<br>
+               reg = TRANS_DP_CTL(pipe);<br>
+               temp = I915_READ(reg);<br>
+               temp &= ~(TRANS_DP_OUTPUT_ENABLE | TRANS_DP_PORT_SEL_MASK);<br>
+               temp |= TRANS_DP_PORT_SEL_NONE;<br>
+               I915_WRITE(reg, temp);<br>
+<br>
+               /* disable DPLL_SEL */<br>
+               temp = I915_READ(PCH_DPLL_SEL);<br>
+               switch (pipe) {<br>
+               case 0:<br>
+                       temp &= ~(TRANSA_DPLL_ENABLE | TRANSA_DPLLB_SEL);<br>
+                       break;<br>
+               case 1:<br>
+                       temp &= ~(TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL);<br>
+                       break;<br>
+               case 2:<br>
+                       /* C shares PLL A or B */<br>
+                       temp &= ~(TRANSC_DPLL_ENABLE | TRANSC_DPLLB_SEL);<br>
+                       break;<br>
+               default:<br>
+                       BUG(); /* wtf */<br>
+               }<br>
+               I915_WRITE(PCH_DPLL_SEL, temp);<br>
+       }<br>
+<br>
+       /* disable PCH DPLL */<br>
+       intel_disable_pch_pll(intel_crtc);<br>
+<br>
+       ironlake_fdi_pll_disable(intel_crtc);<br>
+<br>
+       intel_crtc->active = false;<br>
+       intel_update_watermarks(dev);<br>
+<br>
+       mutex_lock(&dev->struct_mutex);<br>
+       intel_update_fbc(dev);<br>
+       mutex_unlock(&dev->struct_mutex);<br>
+}<br>
+<br>
 static void ironlake_crtc_off(struct drm_crtc *crtc)<br>
 {<br>
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);<br>
@@ -8109,8 +8288,8 @@ static void intel_init_display(struct drm_device *dev)<br>
        /* We always want a DPMS function */<br>
        if (IS_HASWELL(dev)) {<br>
                dev_priv->display.crtc_mode_set = haswell_crtc_mode_set;<br>
-               dev_priv->display.crtc_enable = ironlake_crtc_enable;<br>
-               dev_priv->display.crtc_disable = ironlake_crtc_disable;<br>
+               dev_priv->display.crtc_enable = haswell_crtc_enable;<br>
+               dev_priv->display.crtc_disable = haswell_crtc_disable;<br>
                dev_priv->display.off = haswell_crtc_off;<br>
                dev_priv->display.update_plane = ironlake_update_plane;<br>
        } else if (HAS_PCH_SPLIT(dev)) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.4<br>
<br>
_______________________________________________<br>
Intel-gfx mailing list<br>
<a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div>Rodrigo Vivi</div><div>Blog: <a href="http://blog.vivi.eng.br" target="_blank">http://blog.vivi.eng.br</a></div><div> </div><br>