diff mbox series

[3/4] drm/i915/display: Add async_flip flag in get_modifiers

Message ID 20241105102608.3912133-4-arun.r.murthy@intel.com (mailing list archive)
State New
Headers show
Series Expose modifiers/formats supported by async flips | expand

Commit Message

Murthy, Arun R Nov. 5, 2024, 10:26 a.m. UTC
get_modifiers will get the list of modifiers supported by the plane. Add
a flag async_flip to fetch only the async_flip supported modifiers.
Also expose function to get the number of modifiers supported by the
platform.

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
 drivers/gpu/drm/i915/display/i9xx_plane.c     |  2 +-
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_fb.c       | 40 +++++++++++++++----
 drivers/gpu/drm/i915/display/intel_fb.h       |  4 +-
 drivers/gpu/drm/i915/display/intel_sprite.c   |  2 +-
 .../drm/i915/display/skl_universal_plane.c    |  3 +-
 6 files changed, 41 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/i9xx_plane.c b/drivers/gpu/drm/i915/display/i9xx_plane.c
index 17a1e3801a85..08d8bb6c770e 100644
--- a/drivers/gpu/drm/i915/display/i9xx_plane.c
+++ b/drivers/gpu/drm/i915/display/i9xx_plane.c
@@ -973,7 +973,7 @@  intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
 		plane->disable_flip_done = ilk_primary_disable_flip_done;
 	}
 
-	modifiers = intel_fb_plane_get_modifiers(dev_priv, INTEL_PLANE_CAP_TILING_X);
+	modifiers = intel_fb_plane_get_modifiers(dev_priv, INTEL_PLANE_CAP_TILING_X, false);
 
 	if (DISPLAY_VER(dev_priv) >= 5 || IS_G4X(dev_priv))
 		ret = drm_universal_plane_init(&dev_priv->drm, &plane->base,
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c
index 9ba77970dab7..a08f445fbcc7 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -1026,7 +1026,7 @@  intel_cursor_plane_create(struct drm_i915_private *dev_priv,
 	if (IS_I845G(dev_priv) || IS_I865G(dev_priv) || HAS_CUR_FBC(dev_priv))
 		cursor->cursor.size = ~0;
 
-	modifiers = intel_fb_plane_get_modifiers(dev_priv, INTEL_PLANE_CAP_NONE);
+	modifiers = intel_fb_plane_get_modifiers(dev_priv, INTEL_PLANE_CAP_NONE, false);
 
 	ret = drm_universal_plane_init(&dev_priv->drm, &cursor->base,
 				       0, &intel_cursor_plane_funcs,
diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
index f05e0c444618..fba1b6fb38ad 100644
--- a/drivers/gpu/drm/i915/display/intel_fb.c
+++ b/drivers/gpu/drm/i915/display/intel_fb.c
@@ -554,7 +554,8 @@  static bool check_modifier_display_ver_range(const struct intel_modifier_desc *m
 
 static bool plane_has_modifier(struct drm_i915_private *i915,
 			       u8 plane_caps,
-			       const struct intel_modifier_desc *md)
+			       const struct intel_modifier_desc *md,
+			       bool is_async_flip)
 {
 	if (!IS_DISPLAY_VER(i915, md->display_ver.from, md->display_ver.until))
 		return false;
@@ -562,6 +563,9 @@  static bool plane_has_modifier(struct drm_i915_private *i915,
 	if (!plane_caps_contain_all(plane_caps, md->plane_caps))
 		return false;
 
+	if (!(is_async_flip && md->async_flip))
+		return false;
+
 	/*
 	 * Separate AuxCCS and Flat CCS modifiers to be run only on platforms
 	 * where supported.
@@ -581,26 +585,48 @@  static bool plane_has_modifier(struct drm_i915_private *i915,
 	return true;
 }
 
+/**
+ * intel_fb_plane_get_modifiers_count - return the number of supported modifiers for a
+ *					given platform and plane capabilities
+ * @i915: i915 device instance
+ * @plane_caps: capabilities for the plane the modifiers are queried for
+ * @async_flip: flag to convey modifiers that support async flip
+ *
+ * Returns:
+ * Returns the number for modifiers supported by the @i915 platform and @plane_caps
+ * with/without @async_flip.
+ */
+int intel_fb_plane_get_modifiers_count(struct drm_i915_private *i915,
+				       u8 plane_caps, bool async_flip)
+{
+	int count = 1;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(intel_modifiers); i++) {
+		if (plane_has_modifier(i915, plane_caps, &intel_modifiers[i], async_flip))
+			count++;
+	}
+	return count;
+}
+
 /**
  * intel_fb_plane_get_modifiers: Get the modifiers for the given platform and plane capabilities
  * @i915: i915 device instance
  * @plane_caps: capabilities for the plane the modifiers are queried for
+ * @async_flip: flag to convey modifiers that support async flip
  *
  * Returns:
  * Returns the list of modifiers allowed by the @i915 platform and @plane_caps.
  * The caller must free the returned buffer.
  */
 u64 *intel_fb_plane_get_modifiers(struct drm_i915_private *i915,
-				  u8 plane_caps)
+				  u8 plane_caps, bool async_flip)
 {
 	u64 *list, *p;
 	int count = 1;		/* +1 for invalid modifier terminator */
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(intel_modifiers); i++) {
-		if (plane_has_modifier(i915, plane_caps, &intel_modifiers[i]))
-			count++;
-	}
+	count = intel_fb_plane_get_modifiers_count(i915, plane_caps, async_flip);
 
 	list = kmalloc_array(count, sizeof(*list), GFP_KERNEL);
 	if (drm_WARN_ON(&i915->drm, !list))
@@ -608,7 +634,7 @@  u64 *intel_fb_plane_get_modifiers(struct drm_i915_private *i915,
 
 	p = list;
 	for (i = 0; i < ARRAY_SIZE(intel_modifiers); i++) {
-		if (plane_has_modifier(i915, plane_caps, &intel_modifiers[i]))
+		if (plane_has_modifier(i915, plane_caps, &intel_modifiers[i], async_flip))
 			*p++ = intel_modifiers[i].modifier;
 	}
 	*p++ = DRM_FORMAT_MOD_INVALID;
diff --git a/drivers/gpu/drm/i915/display/intel_fb.h b/drivers/gpu/drm/i915/display/intel_fb.h
index d78993e5eb62..4ae7cc75fe77 100644
--- a/drivers/gpu/drm/i915/display/intel_fb.h
+++ b/drivers/gpu/drm/i915/display/intel_fb.h
@@ -41,8 +41,10 @@  bool intel_fb_is_tile4_modifier(u64 modifier);
 bool intel_fb_is_ccs_aux_plane(const struct drm_framebuffer *fb, int color_plane);
 int intel_fb_rc_ccs_cc_plane(const struct drm_framebuffer *fb);
 
+int intel_fb_plane_get_modifiers_count(struct drm_i915_private *i915,
+				       u8 plane_caps, bool async_flip);
 u64 *intel_fb_plane_get_modifiers(struct drm_i915_private *i915,
-				  u8 plane_caps);
+				  u8 plane_caps, bool async_flip);
 bool intel_fb_plane_supports_modifier(struct intel_plane *plane, u64 modifier);
 
 const struct drm_format_info *
diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c b/drivers/gpu/drm/i915/display/intel_sprite.c
index e6fadcef58e0..d1c5a3a3f13e 100644
--- a/drivers/gpu/drm/i915/display/intel_sprite.c
+++ b/drivers/gpu/drm/i915/display/intel_sprite.c
@@ -1685,7 +1685,7 @@  intel_sprite_plane_create(struct drm_i915_private *dev_priv,
 	plane->id = PLANE_SPRITE0 + sprite;
 	plane->frontbuffer_bit = INTEL_FRONTBUFFER(pipe, plane->id);
 
-	modifiers = intel_fb_plane_get_modifiers(dev_priv, INTEL_PLANE_CAP_TILING_X);
+	modifiers = intel_fb_plane_get_modifiers(dev_priv, INTEL_PLANE_CAP_TILING_X, false);
 
 	ret = drm_universal_plane_init(display->drm, &plane->base,
 				       0, plane_funcs,
diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
index 038ca2ec5d7a..54cf2c9374cb 100644
--- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
+++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
@@ -2673,7 +2673,8 @@  skl_universal_plane_create(struct drm_i915_private *dev_priv,
 		plane_type = DRM_PLANE_TYPE_OVERLAY;
 
 	modifiers = intel_fb_plane_get_modifiers(dev_priv,
-						 skl_get_plane_caps(dev_priv, pipe, plane_id));
+						 skl_get_plane_caps(dev_priv, pipe, plane_id),
+						 false);
 
 	ret = drm_universal_plane_init(&dev_priv->drm, &plane->base,
 				       0, plane_funcs,