[04/13] drm/i915: abstract intel_panel_sanitize_ssc() from intel_modeset_init()

Submitted by Jani Nikula on Sept. 19, 2019, 2:03 p.m.

Details

Message ID 3dfcf6edec33a4485c5d29eec39d4f58f4d829df.1568901239.git.jani.nikula@intel.com
State New
Headers show
Series "drm/i915: modeset probe/remove path refactoring" ( rev: 1 ) in Intel GFX

Not browsing as part of any series.

Commit Message

Jani Nikula Sept. 19, 2019, 2:03 p.m.
The code is too specific and detailed to have open in a high level
function. Abstract away. As a drive-by improvement switch to using
enableddisabled() in logging. No functional changes.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 39 +++++++++++---------
 1 file changed, 22 insertions(+), 17 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index c0fc66903fec..ee0d34d76b08 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -7539,6 +7539,27 @@  intel_link_compute_m_n(u16 bits_per_pixel, int nlanes,
 		    constant_n);
 }
 
+static void intel_panel_sanitize_ssc(struct drm_i915_private *dev_priv)
+{
+	/*
+	 * There may be no VBT; and if the BIOS enabled SSC we can
+	 * just keep using it to avoid unnecessary flicker.  Whereas if the
+	 * BIOS isn't using it, don't assume it will work even if the VBT
+	 * indicates as much.
+	 */
+	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv)) {
+		bool bios_lvds_use_ssc = !!(I915_READ(PCH_DREF_CONTROL) &
+					    DREF_SSC1_ENABLE);
+
+		if (dev_priv->vbt.lvds_use_ssc != bios_lvds_use_ssc) {
+			DRM_DEBUG_KMS("SSC %s by BIOS, overriding VBT which says %s\n",
+				      enableddisabled(bios_lvds_use_ssc),
+				      enableddisabled(dev_priv->vbt.lvds_use_ssc));
+			dev_priv->vbt.lvds_use_ssc = bios_lvds_use_ssc;
+		}
+	}
+}
+
 static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv)
 {
 	if (i915_modparams.panel_use_ssc >= 0)
@@ -16116,23 +16137,7 @@  int intel_modeset_init(struct drm_device *dev)
 
 	intel_init_pm(dev_priv);
 
-	/*
-	 * There may be no VBT; and if the BIOS enabled SSC we can
-	 * just keep using it to avoid unnecessary flicker.  Whereas if the
-	 * BIOS isn't using it, don't assume it will work even if the VBT
-	 * indicates as much.
-	 */
-	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv)) {
-		bool bios_lvds_use_ssc = !!(I915_READ(PCH_DREF_CONTROL) &
-					    DREF_SSC1_ENABLE);
-
-		if (dev_priv->vbt.lvds_use_ssc != bios_lvds_use_ssc) {
-			DRM_DEBUG_KMS("SSC %sabled by BIOS, overriding VBT which says %sabled\n",
-				     bios_lvds_use_ssc ? "en" : "dis",
-				     dev_priv->vbt.lvds_use_ssc ? "en" : "dis");
-			dev_priv->vbt.lvds_use_ssc = bios_lvds_use_ssc;
-		}
-	}
+	intel_panel_sanitize_ssc(dev_priv);
 
 	/*
 	 * Maximum framebuffer dimensions, chosen to match

Comments

Quoting Jani Nikula (2019-09-19 15:03:51)
> The code is too specific and detailed to have open in a high level
> function. Abstract away. As a drive-by improvement switch to using
> enableddisabled() in logging. No functional changes.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 39 +++++++++++---------
>  1 file changed, 22 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index c0fc66903fec..ee0d34d76b08 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -7539,6 +7539,27 @@ intel_link_compute_m_n(u16 bits_per_pixel, int nlanes,
>                     constant_n);
>  }
>  
> +static void intel_panel_sanitize_ssc(struct drm_i915_private *dev_priv)
> +{
> +       /*
> +        * There may be no VBT; and if the BIOS enabled SSC we can
> +        * just keep using it to avoid unnecessary flicker.  Whereas if the
> +        * BIOS isn't using it, don't assume it will work even if the VBT
> +        * indicates as much.
> +        */
> +       if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv)) {
> +               bool bios_lvds_use_ssc = !!(I915_READ(PCH_DREF_CONTROL) &
> +                                           DREF_SSC1_ENABLE);

You could drive-by remove !! as well.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris