OSDN Git Service

drm/i915/fbc: Introduce intel_fbc_add_plane()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 24 Nov 2021 11:36:44 +0000 (13:36 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 3 Dec 2021 11:13:04 +0000 (13:13 +0200)
In order to better encapsulate the FBC implementation
introduce a small helper to do the plane<->FBC instance
association.

We'll also try to structure the plane init code such
that introducing multiple FBC instances will be easier
down the line.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211124113652.22090-13-ville.syrjala@linux.intel.com
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
drivers/gpu/drm/i915/display/i9xx_plane.c
drivers/gpu/drm/i915/display/intel_fbc.c
drivers/gpu/drm/i915/display/intel_fbc.h
drivers/gpu/drm/i915/display/skl_universal_plane.c

index 2194f74..84f50c9 100644 (file)
@@ -13,6 +13,7 @@
 #include "intel_de.h"
 #include "intel_display_types.h"
 #include "intel_fb.h"
+#include "intel_fbc.h"
 #include "intel_sprite.h"
 #include "i9xx_plane.h"
 
@@ -120,6 +121,15 @@ static bool i9xx_plane_has_fbc(struct drm_i915_private *dev_priv,
                return i9xx_plane == PLANE_A;
 }
 
+static struct intel_fbc *i9xx_plane_fbc(struct drm_i915_private *dev_priv,
+                                       enum i9xx_plane_id i9xx_plane)
+{
+       if (i9xx_plane_has_fbc(dev_priv, i9xx_plane))
+               return &dev_priv->fbc;
+       else
+               return NULL;
+}
+
 static bool i9xx_plane_has_windowing(struct intel_plane *plane)
 {
        struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
@@ -807,10 +817,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
        plane->id = PLANE_PRIMARY;
        plane->frontbuffer_bit = INTEL_FRONTBUFFER(pipe, plane->id);
 
-       if (i9xx_plane_has_fbc(dev_priv, plane->i9xx_plane))
-               plane->fbc = &dev_priv->fbc;
-       if (plane->fbc)
-               plane->fbc->possible_framebuffer_bits |= plane->frontbuffer_bit;
+       intel_fbc_add_plane(i9xx_plane_fbc(dev_priv, plane->i9xx_plane), plane);
 
        if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
                formats = vlv_primary_formats;
index ee4e318..9be8e7d 100644 (file)
@@ -1612,6 +1612,15 @@ static bool need_fbc_vtd_wa(struct drm_i915_private *i915)
        return false;
 }
 
+void intel_fbc_add_plane(struct intel_fbc *fbc, struct intel_plane *plane)
+{
+       if (!fbc)
+               return;
+
+       plane->fbc = fbc;
+       fbc->possible_framebuffer_bits |= plane->frontbuffer_bit;
+}
+
 /**
  * intel_fbc_init - Initialize FBC
  * @i915: the i915 device
index 0f5884f..b8d9cda 100644 (file)
@@ -15,6 +15,7 @@ struct intel_atomic_state;
 struct intel_crtc;
 struct intel_crtc_state;
 struct intel_fbc;
+struct intel_plane;
 struct intel_plane_state;
 
 int intel_fbc_atomic_check(struct intel_atomic_state *state);
@@ -33,6 +34,7 @@ void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
                          enum fb_op_origin origin);
 void intel_fbc_flush(struct drm_i915_private *dev_priv,
                     unsigned int frontbuffer_bits, enum fb_op_origin origin);
+void intel_fbc_add_plane(struct intel_fbc *fbc, struct intel_plane *plane);
 void intel_fbc_handle_fifo_underrun_irq(struct drm_i915_private *i915);
 void intel_fbc_reset_underrun(struct drm_i915_private *i915);
 void intel_fbc_debugfs_register(struct drm_i915_private *i915);
index d881a30..253d69a 100644 (file)
@@ -13,6 +13,7 @@
 #include "intel_de.h"
 #include "intel_display_types.h"
 #include "intel_fb.h"
+#include "intel_fbc.h"
 #include "intel_pm.h"
 #include "intel_psr.h"
 #include "intel_sprite.h"
@@ -1828,6 +1829,15 @@ static bool skl_plane_has_fbc(struct drm_i915_private *dev_priv,
        return pipe == PIPE_A && plane_id == PLANE_PRIMARY;
 }
 
+static struct intel_fbc *skl_plane_fbc(struct drm_i915_private *dev_priv,
+                                      enum pipe pipe, enum plane_id plane_id)
+{
+       if (skl_plane_has_fbc(dev_priv, pipe, plane_id))
+               return &dev_priv->fbc;
+       else
+               return NULL;
+}
+
 static bool skl_plane_has_planar(struct drm_i915_private *dev_priv,
                                 enum pipe pipe, enum plane_id plane_id)
 {
@@ -2114,10 +2124,7 @@ skl_universal_plane_create(struct drm_i915_private *dev_priv,
        plane->id = plane_id;
        plane->frontbuffer_bit = INTEL_FRONTBUFFER(pipe, plane_id);
 
-       if (skl_plane_has_fbc(dev_priv, pipe, plane_id))
-               plane->fbc = &dev_priv->fbc;
-       if (plane->fbc)
-               plane->fbc->possible_framebuffer_bits |= plane->frontbuffer_bit;
+       intel_fbc_add_plane(skl_plane_fbc(dev_priv, pipe, plane_id), plane);
 
        if (DISPLAY_VER(dev_priv) >= 11) {
                plane->min_width = icl_plane_min_width;