[RFC v2 3/4] drm/i915/display: accept either i915 or display for feature tests

Jani Nikula jani.nikula at intel.com
Wed Mar 6 12:24:37 UTC 2024


Use _Generic() to allow passing either struct drm_i915_private * or
struct intel_display * to the feature test macros.

Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 drivers/gpu/drm/i915/display/intel_display_device.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display_device.h b/drivers/gpu/drm/i915/display/intel_display_device.h
index fe4268813786..ac52a6b27bd2 100644
--- a/drivers/gpu/drm/i915/display/intel_display_device.h
+++ b/drivers/gpu/drm/i915/display/intel_display_device.h
@@ -13,6 +13,12 @@
 struct drm_i915_private;
 struct drm_printer;
 
+/* transitional until we have no i915 pointers */
+#define __display(i915_or_display)					\
+	_Generic(*i915_or_display,					\
+		 struct drm_i915_private: (((const struct drm_i915_private *)(i915_or_display))->__intel_display_private), \
+		 struct intel_display: (i915_or_display))
+
 #define DEV_INFO_DISPLAY_FOR_EACH_FLAG(func) \
 	/* Keep in alphabetical order */ \
 	func(cursor_needs_physical); \
@@ -98,8 +104,8 @@ struct drm_printer;
 	(IS_DISPLAY_IP_RANGE((__i915), (ipver), (ipver)) && \
 	 IS_DISPLAY_STEP((__i915), (from), (until)))
 
-#define DISPLAY_INFO(i915)		((i915)->display.info.__device_info)
-#define DISPLAY_RUNTIME_INFO(i915)	(&(i915)->display.info.__runtime_info)
+#define DISPLAY_INFO(i915)		(__display(i915)->info.__device_info)
+#define DISPLAY_RUNTIME_INFO(i915)	(&__display(i915)->info.__runtime_info)
 
 #define DISPLAY_VER(i915)	(DISPLAY_RUNTIME_INFO(i915)->ip.ver)
 #define DISPLAY_VER_FULL(i915)	IP_VER(DISPLAY_RUNTIME_INFO(i915)->ip.ver, \
-- 
2.39.2



More information about the Intel-gfx mailing list