[Intel-gfx] [RFC 15/28] drm/i915: Simplify IS_GEN macros

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Wed Apr 14 11:50:15 UTC 2021


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h | 44 +++++++++++----------------------
 1 file changed, 14 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index fa5aa0e3a776..4f140e95207e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2723,36 +2723,20 @@ intel_info(const struct drm_i915_private *dev_priv)
  * have their own (e.g. HAS_PCH_SPLIT for ILK+ display, IS_foo for particular
  * chips, etc.).
  */
-#define IS_GEN2(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN2) && \
-	 ((dev_priv)->info.gen_mask & BIT(1)))
-#define IS_GEN3(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN3) && \
-	 ((dev_priv)->info.gen_mask & BIT(2)))
-#define IS_GEN4(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN4) && \
-	 ((dev_priv)->info.gen_mask & BIT(3)))
-#define IS_GEN5(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN5) && \
-	 ((dev_priv)->info.gen_mask & BIT(4)))
-#define IS_GEN6(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN6) && \
-	 ((dev_priv)->info.gen_mask & BIT(5)))
-#define IS_GEN7(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN7) && \
-	 ((dev_priv)->info.gen_mask & BIT(6)))
-#define IS_GEN8(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN8) && \
-	 ((dev_priv)->info.gen_mask & BIT(7)))
-#define IS_GEN9(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN9) && \
-	 ((dev_priv)->info.gen_mask & BIT(8)))
-#define IS_GEN10(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN10) && \
-	 ((dev_priv)->info.gen_mask & BIT(9)))
-#define IS_GEN11(dev_priv) \
-	(IS_ENABLED(CONFIG_DRM_I915_GEN11) && \
-	 ((dev_priv)->info.gen_mask & BIT(10)))
+#define IS_GENx(p, g) \
+	(IS_ENABLED(CONFIG_DRM_I915_GEN##g) && \
+	 ((p)->info.gen_mask & BIT((g) - 1)))
+
+#define IS_GEN2(p) IS_GENx(p, 2)
+#define IS_GEN3(p) IS_GENx(p, 3)
+#define IS_GEN4(p) IS_GENx(p, 4)
+#define IS_GEN5(p) IS_GENx(p, 5)
+#define IS_GEN6(p) IS_GENx(p, 6)
+#define IS_GEN7(p) IS_GENx(p, 7)
+#define IS_GEN8(p) IS_GENx(p, 8)
+#define IS_GEN9(p) IS_GENx(p, 9)
+#define IS_GEN10(p) IS_GENx(p, 10)
+#define IS_GEN11(p) IS_GENx(p, 11)
 
 #define IS_LP(dev_priv)	(INTEL_INFO(dev_priv)->is_lp)
 #define IS_GEN9_LP(dev_priv)	(IS_GEN9(dev_priv) && IS_LP(dev_priv))
-- 
2.27.0



More information about the Intel-gfx mailing list