drm/i915/fbc: unexport the HW level activation functions
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Fri, 29 Jan 2016 20:57:39 +0000 (18:57 -0200)
committerPaulo Zanoni <paulo.r.zanoni@intel.com>
Thu, 4 Feb 2016 16:17:45 +0000 (14:17 -0200)
The recent introduction of a new caller of dev_priv->fbc.deactivate()
is a good example of why we need unexport those functions. Anything
outside intel_fbc.c should only call the functions exported by
intel_fbc.c, so in order to enforce that, kill the function pointers
stored inside dev_priv->fbc and replace them with functions that can't
be called from outside intel_fbc.c.

This should make it much harder for new code to call these functions
from outside intel_fbc.c.

Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1454101060-23198-2-git-send-email-paulo.r.zanoni@intel.com
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_fbc.c

index 77227a39f3d54e328dcf88a9dfc40455fd171012..856bfe8d1f42396560b2e28f75cc65b42a54f2a7 100644 (file)
@@ -964,10 +964,6 @@ struct intel_fbc {
        } work;
 
        const char *no_fbc_reason;
-
-       bool (*is_active)(struct drm_i915_private *dev_priv);
-       void (*activate)(struct drm_i915_private *dev_priv);
-       void (*deactivate)(struct drm_i915_private *dev_priv);
 };
 
 /**
index 5adf6d7620add78e1fd959769646b48f04b44de1..8d3caf26fc53f563d5ef1eb486f8c3b48c142931 100644 (file)
@@ -43,7 +43,7 @@
 
 static inline bool fbc_supported(struct drm_i915_private *dev_priv)
 {
-       return dev_priv->fbc.activate != NULL;
+       return HAS_FBC(dev_priv);
 }
 
 static inline bool fbc_on_pipe_a_only(struct drm_i915_private *dev_priv)
@@ -343,6 +343,38 @@ static void gen7_fbc_activate(struct drm_i915_private *dev_priv)
        intel_fbc_recompress(dev_priv);
 }
 
+static bool intel_fbc_hw_is_active(struct drm_i915_private *dev_priv)
+{
+       if (INTEL_INFO(dev_priv)->gen >= 5)
+               return ilk_fbc_is_active(dev_priv);
+       else if (IS_GM45(dev_priv))
+               return g4x_fbc_is_active(dev_priv);
+       else
+               return i8xx_fbc_is_active(dev_priv);
+}
+
+static void intel_fbc_hw_activate(struct drm_i915_private *dev_priv)
+{
+       if (INTEL_INFO(dev_priv)->gen >= 7)
+               gen7_fbc_activate(dev_priv);
+       else if (INTEL_INFO(dev_priv)->gen >= 5)
+               ilk_fbc_activate(dev_priv);
+       else if (IS_GM45(dev_priv))
+               g4x_fbc_activate(dev_priv);
+       else
+               i8xx_fbc_activate(dev_priv);
+}
+
+static void intel_fbc_hw_deactivate(struct drm_i915_private *dev_priv)
+{
+       if (INTEL_INFO(dev_priv)->gen >= 5)
+               ilk_fbc_deactivate(dev_priv);
+       else if (IS_GM45(dev_priv))
+               g4x_fbc_deactivate(dev_priv);
+       else
+               i8xx_fbc_deactivate(dev_priv);
+}
+
 /**
  * intel_fbc_is_active - Is FBC active?
  * @dev_priv: i915 device instance
@@ -405,7 +437,7 @@ retry:
                goto retry;
        }
 
-       fbc->activate(dev_priv);
+       intel_fbc_hw_activate(dev_priv);
 
        work->scheduled = false;
 
@@ -451,7 +483,7 @@ static void intel_fbc_deactivate(struct drm_i915_private *dev_priv)
        fbc->work.scheduled = false;
 
        if (fbc->active)
-               fbc->deactivate(dev_priv);
+               intel_fbc_hw_deactivate(dev_priv);
 }
 
 static bool multiple_pipes_ok(struct intel_crtc *crtc)
@@ -713,7 +745,7 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc)
 
        /* FIXME: We lack the proper locking here, so only run this on the
         * platforms that need. */
-       if (dev_priv->fbc.activate == ilk_fbc_activate)
+       if (INTEL_INFO(dev_priv)->gen >= 5 && INTEL_INFO(dev_priv)->gen < 7)
                cache->fb.ilk_ggtt_offset = i915_gem_obj_ggtt_offset(obj);
        cache->fb.pixel_format = fb->pixel_format;
        cache->fb.stride = fb->pitches[0];
@@ -1223,30 +1255,13 @@ void intel_fbc_init(struct drm_i915_private *dev_priv)
                        break;
        }
 
-       if (INTEL_INFO(dev_priv)->gen >= 7) {
-               fbc->is_active = ilk_fbc_is_active;
-               fbc->activate = gen7_fbc_activate;
-               fbc->deactivate = ilk_fbc_deactivate;
-       } else if (INTEL_INFO(dev_priv)->gen >= 5) {
-               fbc->is_active = ilk_fbc_is_active;
-               fbc->activate = ilk_fbc_activate;
-               fbc->deactivate = ilk_fbc_deactivate;
-       } else if (IS_GM45(dev_priv)) {
-               fbc->is_active = g4x_fbc_is_active;
-               fbc->activate = g4x_fbc_activate;
-               fbc->deactivate = g4x_fbc_deactivate;
-       } else {
-               fbc->is_active = i8xx_fbc_is_active;
-               fbc->activate = i8xx_fbc_activate;
-               fbc->deactivate = i8xx_fbc_deactivate;
-
-               /* This value was pulled out of someone's hat */
+       /* This value was pulled out of someone's hat */
+       if (INTEL_INFO(dev_priv)->gen <= 4 && !IS_GM45(dev_priv))
                I915_WRITE(FBC_CONTROL, 500 << FBC_CTL_INTERVAL_SHIFT);
-       }
 
        /* We still don't have any sort of hardware state readout for FBC, so
         * deactivate it in case the BIOS activated it to make sure software
         * matches the hardware state. */
-       if (fbc->is_active(dev_priv))
-               fbc->deactivate(dev_priv);
+       if (intel_fbc_hw_is_active(dev_priv))
+               intel_fbc_hw_deactivate(dev_priv);
 }