]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/display: Abstract pipe/trans/cursor offset calculation
authorAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Fri, 19 Dec 2025 06:02:54 +0000 (11:32 +0530)
committerAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Mon, 29 Dec 2025 11:45:34 +0000 (17:15 +0530)
Introduce INTEL_DISPLAY_DEVICE_*_OFFSET() macros to compute absolute
MMIO offsets for pipe, transcoder, and cursor registers.

Update _MMIO_PIPE2/_MMIO_TRANS2/_MMIO_CURSOR2 to use these macros
for cleaner abstraction and to prepare for external API usage (e.g. GVT).

Also move DISPLAY_MMIO_BASE() to intel_display_device.h so it can be
abstracted in GVT, allowing register macros to resolve via
exported helpers rather than peeking into struct intel_display.

v2: Wrap the macro argument usages in parenthesis. (Jani)

Suggested-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patch.msgid.link/20251219060302.2365123-2-ankit.k.nautiyal@intel.com
drivers/gpu/drm/i915/display/intel_display_device.h
drivers/gpu/drm/i915/display/intel_display_reg_defs.h

index 50b2e9ae2c183ed72e2d4102f428597e19e2c15d..13b6616bc496af8a6379a946fc7f3231ffb7d9ed 100644 (file)
@@ -260,6 +260,23 @@ struct intel_display_platforms {
         ((id) == ARLS_HOST_BRIDGE_PCI_ID3) || \
         ((id) == ARLS_HOST_BRIDGE_PCI_ID4))
 
+#define INTEL_DISPLAY_DEVICE_PIPE_OFFSET(display, pipe) \
+       (DISPLAY_INFO((display))->pipe_offsets[(pipe)] - \
+        DISPLAY_INFO((display))->pipe_offsets[PIPE_A] + \
+        DISPLAY_MMIO_BASE((display)))
+
+#define INTEL_DISPLAY_DEVICE_TRANS_OFFSET(display, trans) \
+       (DISPLAY_INFO((display))->trans_offsets[(trans)] - \
+        DISPLAY_INFO((display))->trans_offsets[TRANSCODER_A] + \
+        DISPLAY_MMIO_BASE((display)))
+
+#define INTEL_DISPLAY_DEVICE_CURSOR_OFFSET(display, pipe) \
+       (DISPLAY_INFO((display))->cursor_offsets[(pipe)] - \
+        DISPLAY_INFO((display))->cursor_offsets[PIPE_A] + \
+        DISPLAY_MMIO_BASE((display)))
+
+#define DISPLAY_MMIO_BASE(display)     (DISPLAY_INFO((display))->mmio_offset)
+
 struct intel_display_runtime_info {
        struct intel_display_ip_ver {
                u16 ver;
index b83ad06f2ea7a5dba53cde7ff138cc5e30ec8ac3..175334b41bba2ecc1deebc0ab678f645ae306901 100644 (file)
@@ -8,8 +8,6 @@
 
 #include "i915_reg_defs.h"
 
-#define DISPLAY_MMIO_BASE(dev_priv)    (DISPLAY_INFO(dev_priv)->mmio_offset)
-
 #define VLV_DISPLAY_BASE               0x180000
 
 /*
  * Device info offset array based helpers for groups of registers with unevenly
  * spaced base offsets.
  */
-#define _MMIO_PIPE2(display, pipe, reg)                _MMIO(DISPLAY_INFO(display)->pipe_offsets[(pipe)] - \
-                                                     DISPLAY_INFO(display)->pipe_offsets[PIPE_A] + \
-                                                     DISPLAY_MMIO_BASE(display) + (reg))
-#define _MMIO_TRANS2(display, tran, reg)       _MMIO(DISPLAY_INFO(display)->trans_offsets[(tran)] - \
-                                                     DISPLAY_INFO(display)->trans_offsets[TRANSCODER_A] + \
-                                                     DISPLAY_MMIO_BASE(display) + (reg))
-#define _MMIO_CURSOR2(display, pipe, reg)      _MMIO(DISPLAY_INFO(display)->cursor_offsets[(pipe)] - \
-                                                     DISPLAY_INFO(display)->cursor_offsets[PIPE_A] + \
-                                                     DISPLAY_MMIO_BASE(display) + (reg))
+
+#define _MMIO_PIPE2(display, pipe, reg)                _MMIO(INTEL_DISPLAY_DEVICE_PIPE_OFFSET((display), (pipe)) + (reg))
+#define _MMIO_TRANS2(display, trans, reg)      _MMIO(INTEL_DISPLAY_DEVICE_TRANS_OFFSET((display), (trans)) + (reg))
+#define _MMIO_CURSOR2(display, pipe, reg)      _MMIO(INTEL_DISPLAY_DEVICE_CURSOR_OFFSET((display), (pipe)) + (reg))
 
 #endif /* __INTEL_DISPLAY_REG_DEFS_H__ */