From: Daniel Vetter Subject: Re: [PATCH 1/4] drm/i915: Convert gmch platforms over to ilk_crtc_{enable, disable}_planes() Date: Mon, 12 May 2014 21:58:12 +0200 Message-ID: <20140512195812.GJ25056@phenom.ffwll.local> References: <1399566196-25086-1-git-send-email-ville.syrjala@linux.intel.com> <1399566196-25086-2-git-send-email-ville.syrjala@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B87E6E982 for ; Mon, 12 May 2014 12:58:17 -0700 (PDT) Received: by mail-ee0-f48.google.com with SMTP id e49so5003931eek.35 for ; Mon, 12 May 2014 12:58:16 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1399566196-25086-2-git-send-email-ville.syrjala@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: ville.syrjala@linux.intel.com Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Thu, May 08, 2014 at 07:23:13PM +0300, ville.syrjala@linux.intel.com wro= te: > From: Ville Syrj=E4l=E4 > = > Use the same code for enabling/disabling planes on all platforms. Rename > the functions to reflect that they're no longer specific to any > platform. > = > For now we leave the plane enable/disable to ccur at the same old > position in the modeset sequence. > = > Signed-off-by: Ville Syrj=E4l=E4 > --- > drivers/gpu/drm/i915/intel_display.c | 134 +++++++++++++++--------------= ------ > 1 file changed, 56 insertions(+), 78 deletions(-) > = > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/= intel_display.c > index c65e7f7..3ee4995 100644 > --- a/drivers/gpu/drm/i915/intel_display.c > +++ b/drivers/gpu/drm/i915/intel_display.c > @@ -3634,7 +3634,49 @@ static void intel_crtc_load_lut(struct drm_crtc *c= rtc) > hsw_enable_ips(intel_crtc); > } > = > -static void ilk_crtc_enable_planes(struct drm_crtc *crtc) > +static void intel_crtc_dpms_overlay(struct intel_crtc *intel_crtc, bool = enable) > +{ > + if (!enable && intel_crtc->overlay) { > + struct drm_device *dev =3D intel_crtc->base.dev; > + struct drm_i915_private *dev_priv =3D dev->dev_private; > + > + mutex_lock(&dev->struct_mutex); > + dev_priv->mm.interruptible =3D false; > + (void) intel_overlay_switch_off(intel_crtc->overlay); > + dev_priv->mm.interruptible =3D true; > + mutex_unlock(&dev->struct_mutex); > + } > + > + /* Let userspace switch the overlay on again. In most cases userspace > + * has to recompute where to put it anyway. > + */ > +} > + > +/** > + * i9xx_fixup_plane - ugly workaround for G45 to fire up the hardware > + * cursor plane briefly if not already running after enabling the display > + * plane. > + * This workaround avoids occasional blank screens when self refresh is > + * enabled. > + */ > +static void > +g4x_fixup_plane(struct drm_i915_private *dev_priv, enum pipe pipe) > +{ > + u32 cntl =3D I915_READ(CURCNTR(pipe)); > + > + if ((cntl & CURSOR_MODE) =3D=3D 0) { > + u32 fw_bcl_self =3D I915_READ(FW_BLC_SELF); > + > + I915_WRITE(FW_BLC_SELF, fw_bcl_self & ~FW_BLC_SELF_EN); > + I915_WRITE(CURCNTR(pipe), CURSOR_MODE_64_ARGB_AX); > + intel_wait_for_vblank(dev_priv->dev, pipe); > + I915_WRITE(CURCNTR(pipe), cntl); > + I915_WRITE(CURBASE(pipe), I915_READ(CURBASE(pipe))); > + I915_WRITE(FW_BLC_SELF, fw_bcl_self); > + } > +} > + > +static void intel_crtc_enable_planes(struct drm_crtc *crtc) i9xx_crtc_enable_planes might have been better, given Damien's pet project. But otoh we might just want to switch to doing a generic atomic pageflip across all planes before we call down into crtc_disable hooks (and the reverse after crtc_enable), so meh ;-) -Daniel > { > struct drm_device *dev =3D crtc->dev; > struct drm_i915_private *dev_priv =3D dev->dev_private; > @@ -3644,7 +3686,11 @@ static void ilk_crtc_enable_planes(struct drm_crtc= *crtc) > = > intel_enable_primary_hw_plane(dev_priv, plane, pipe); > intel_enable_planes(crtc); > + /* The fixup needs to happen before cursor is enabled */ > + if (IS_G4X(dev)) > + g4x_fixup_plane(dev_priv, pipe); > intel_crtc_update_cursor(crtc, true); > + intel_crtc_dpms_overlay(intel_crtc, true); > = > hsw_enable_ips(intel_crtc); > = > @@ -3653,7 +3699,7 @@ static void ilk_crtc_enable_planes(struct drm_crtc = *crtc) > mutex_unlock(&dev->struct_mutex); > } > = > -static void ilk_crtc_disable_planes(struct drm_crtc *crtc) > +static void intel_crtc_disable_planes(struct drm_crtc *crtc) > { > struct drm_device *dev =3D crtc->dev; > struct drm_i915_private *dev_priv =3D dev->dev_private; > @@ -3669,6 +3715,7 @@ static void ilk_crtc_disable_planes(struct drm_crtc= *crtc) > = > hsw_disable_ips(intel_crtc); > = > + intel_crtc_dpms_overlay(intel_crtc, false); > intel_crtc_update_cursor(crtc, false); > intel_disable_planes(crtc); > intel_disable_primary_hw_plane(dev_priv, plane, pipe); > @@ -3726,7 +3773,7 @@ static void ironlake_crtc_enable(struct drm_crtc *c= rtc) > if (HAS_PCH_CPT(dev)) > cpt_verify_modeset(dev, intel_crtc->pipe); > = > - ilk_crtc_enable_planes(crtc); > + intel_crtc_enable_planes(crtc); > = > /* > * There seems to be a race in PCH platform hw (at least on some > @@ -3829,7 +3876,7 @@ static void haswell_crtc_enable(struct drm_crtc *cr= tc) > /* If we change the relative order between pipe/planes enabling, we need > * to change the workaround. */ > haswell_mode_set_planes_workaround(intel_crtc); > - ilk_crtc_enable_planes(crtc); > + intel_crtc_enable_planes(crtc); > = > drm_vblank_on(dev, pipe); > } > @@ -3861,7 +3908,7 @@ static void ironlake_crtc_disable(struct drm_crtc *= crtc) > if (!intel_crtc->active) > return; > = > - ilk_crtc_disable_planes(crtc); > + intel_crtc_disable_planes(crtc); > = > for_each_encoder_on_crtc(dev, crtc, encoder) > encoder->disable(encoder); > @@ -3924,7 +3971,7 @@ static void haswell_crtc_disable(struct drm_crtc *c= rtc) > if (!intel_crtc->active) > return; > = > - ilk_crtc_disable_planes(crtc); > + intel_crtc_disable_planes(crtc); > = > for_each_encoder_on_crtc(dev, crtc, encoder) { > intel_opregion_notify_encoder(encoder, false); > @@ -3970,48 +4017,6 @@ static void haswell_crtc_off(struct drm_crtc *crtc) > intel_ddi_put_crtc_pll(crtc); > } > = > -static void intel_crtc_dpms_overlay(struct intel_crtc *intel_crtc, bool = enable) > -{ > - if (!enable && intel_crtc->overlay) { > - struct drm_device *dev =3D intel_crtc->base.dev; > - struct drm_i915_private *dev_priv =3D dev->dev_private; > - > - mutex_lock(&dev->struct_mutex); > - dev_priv->mm.interruptible =3D false; > - (void) intel_overlay_switch_off(intel_crtc->overlay); > - dev_priv->mm.interruptible =3D true; > - mutex_unlock(&dev->struct_mutex); > - } > - > - /* Let userspace switch the overlay on again. In most cases userspace > - * has to recompute where to put it anyway. > - */ > -} > - > -/** > - * i9xx_fixup_plane - ugly workaround for G45 to fire up the hardware > - * cursor plane briefly if not already running after enabling the display > - * plane. > - * This workaround avoids occasional blank screens when self refresh is > - * enabled. > - */ > -static void > -g4x_fixup_plane(struct drm_i915_private *dev_priv, enum pipe pipe) > -{ > - u32 cntl =3D I915_READ(CURCNTR(pipe)); > - > - if ((cntl & CURSOR_MODE) =3D=3D 0) { > - u32 fw_bcl_self =3D I915_READ(FW_BLC_SELF); > - > - I915_WRITE(FW_BLC_SELF, fw_bcl_self & ~FW_BLC_SELF_EN); > - I915_WRITE(CURCNTR(pipe), CURSOR_MODE_64_ARGB_AX); > - intel_wait_for_vblank(dev_priv->dev, pipe); > - I915_WRITE(CURCNTR(pipe), cntl); > - I915_WRITE(CURBASE(pipe), I915_READ(CURBASE(pipe))); > - I915_WRITE(FW_BLC_SELF, fw_bcl_self); > - } > -} > - > static void i9xx_pfit_enable(struct intel_crtc *crtc) > { > struct drm_device *dev =3D crtc->base.dev; > @@ -4315,7 +4320,6 @@ static void valleyview_crtc_enable(struct drm_crtc = *crtc) > struct intel_crtc *intel_crtc =3D to_intel_crtc(crtc); > struct intel_encoder *encoder; > int pipe =3D intel_crtc->pipe; > - int plane =3D intel_crtc->plane; > bool is_dsi; > = > WARN_ON(!crtc->enabled); > @@ -4347,11 +4351,7 @@ static void valleyview_crtc_enable(struct drm_crtc= *crtc) > intel_wait_for_vblank(dev_priv->dev, pipe); > intel_set_cpu_fifo_underrun_reporting(dev, pipe, true); > = > - intel_enable_primary_hw_plane(dev_priv, plane, pipe); > - intel_enable_planes(crtc); > - intel_crtc_update_cursor(crtc, true); > - > - intel_update_fbc(dev); > + intel_crtc_enable_planes(crtc); > = > for_each_encoder_on_crtc(dev, crtc, encoder) > encoder->enable(encoder); > @@ -4366,7 +4366,6 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc) > struct intel_crtc *intel_crtc =3D to_intel_crtc(crtc); > struct intel_encoder *encoder; > int pipe =3D intel_crtc->pipe; > - int plane =3D intel_crtc->plane; > = > WARN_ON(!crtc->enabled); > = > @@ -4390,17 +4389,7 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc) > intel_wait_for_vblank(dev_priv->dev, pipe); > intel_set_cpu_fifo_underrun_reporting(dev, pipe, true); > = > - intel_enable_primary_hw_plane(dev_priv, plane, pipe); > - intel_enable_planes(crtc); > - /* The fixup needs to happen before cursor is enabled */ > - if (IS_G4X(dev)) > - g4x_fixup_plane(dev_priv, pipe); > - intel_crtc_update_cursor(crtc, true); > - > - /* Give the overlay scaler a chance to enable if it's on this pipe */ > - intel_crtc_dpms_overlay(intel_crtc, true); > - > - intel_update_fbc(dev); > + intel_crtc_enable_planes(crtc); > = > for_each_encoder_on_crtc(dev, crtc, encoder) > encoder->enable(encoder); > @@ -4430,7 +4419,6 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc) > struct intel_crtc *intel_crtc =3D to_intel_crtc(crtc); > struct intel_encoder *encoder; > int pipe =3D intel_crtc->pipe; > - int plane =3D intel_crtc->plane; > = > if (!intel_crtc->active) > return; > @@ -4438,17 +4426,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crt= c) > for_each_encoder_on_crtc(dev, crtc, encoder) > encoder->disable(encoder); > = > - /* Give the overlay scaler a chance to disable if it's on this pipe */ > - intel_crtc_wait_for_pending_flips(crtc); > - drm_vblank_off(dev, pipe); > - > - if (dev_priv->fbc.plane =3D=3D plane) > - intel_disable_fbc(dev); > - > - intel_crtc_dpms_overlay(intel_crtc, false); > - intel_crtc_update_cursor(crtc, false); > - intel_disable_planes(crtc); > - intel_disable_primary_hw_plane(dev_priv, plane, pipe); > + intel_crtc_disable_planes(crtc); > = > intel_set_cpu_fifo_underrun_reporting(dev, pipe, false); > intel_disable_pipe(dev_priv, pipe); > -- = > 1.8.3.2 > = > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch