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