display_member.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* SPDX-License-Identifier: MIT */
  2. /* Copyright © 2025 Intel Corporation */
  3. #ifndef __DRM_INTEL_DISPLAY_H__
  4. #define __DRM_INTEL_DISPLAY_H__
  5. #include <linux/build_bug.h>
  6. #include <linux/stddef.h>
  7. #include <linux/stringify.h>
  8. #include <drm/drm_device.h>
  9. struct intel_display;
  10. /*
  11. * A dummy device struct to define the relative offsets of drm and display
  12. * members. With the members identically placed in struct drm_i915_private and
  13. * struct xe_device, this allows figuring out the struct intel_display pointer
  14. * without the definition of either driver specific structure.
  15. */
  16. struct __intel_generic_device {
  17. struct drm_device drm;
  18. struct intel_display *display;
  19. };
  20. /**
  21. * INTEL_DISPLAY_MEMBER_STATIC_ASSERT() - ensure correct placing of drm and display members
  22. * @type: The struct to check
  23. * @drm_member: Name of the struct drm_device member
  24. * @display_member: Name of the struct intel_display * member.
  25. *
  26. * Use this static assert macro to ensure the struct drm_i915_private and struct
  27. * xe_device struct drm_device and struct intel_display * members are at the
  28. * same relative offsets.
  29. */
  30. #define INTEL_DISPLAY_MEMBER_STATIC_ASSERT(type, drm_member, display_member) \
  31. static_assert( \
  32. offsetof(struct __intel_generic_device, display) - offsetof(struct __intel_generic_device, drm) == \
  33. offsetof(type, display_member) - offsetof(type, drm_member), \
  34. __stringify(type) " " __stringify(drm_member) " and " __stringify(display_member) " members at invalid offsets")
  35. #endif