4 #include <linux/list.h>
5 #include <linux/kref.h>
6 #include <linux/mutex.h>
9 #include <drm/drm_mode_config.h>
14 struct drm_vblank_crtc;
15 struct drm_vma_offset_manager;
22 struct pci_controller;
26 * enum switch_power_state - power state of drm device
29 enum switch_power_state {
30 /** @DRM_SWITCH_POWER_ON: Power state is ON */
31 DRM_SWITCH_POWER_ON = 0,
33 /** @DRM_SWITCH_POWER_OFF: Power state is OFF */
34 DRM_SWITCH_POWER_OFF = 1,
36 /** @DRM_SWITCH_POWER_CHANGING: Power state is changing */
37 DRM_SWITCH_POWER_CHANGING = 2,
39 /** @DRM_SWITCH_POWER_DYNAMIC_OFF: Suspended */
40 DRM_SWITCH_POWER_DYNAMIC_OFF = 3,
44 * struct drm_device - DRM device structure
46 * This structure represent a complete card that
47 * may contain multiple heads.
50 /** @if_version: Highest interface version set */
53 /** @ref: Object ref-count */
56 /** @dev: Device structure of bus-device */
62 * Managed resources linked to the lifetime of this &drm_device as
66 /** @managed.resources: managed resources list */
67 struct list_head resources;
68 /** @managed.final_kfree: pointer for final kfree() call */
70 /** @managed.lock: protects @managed.resources */
74 /** @driver: DRM driver managing the device */
75 const struct drm_driver *driver;
80 * DRM driver private data. This is deprecated and should be left set to
83 * Instead of using this pointer it is recommended that drivers use
84 * devm_drm_dev_alloc() and embed struct &drm_device in their larger
85 * per-device structure.
92 * Primary node. Drivers should not interact with this
93 * directly. debugfs interfaces can be registered with
94 * drm_debugfs_add_file(), and sysfs should be directly added on the
95 * hardware (and not character device node) struct device @dev.
97 struct drm_minor *primary;
102 * Render node. Drivers should not interact with this directly ever.
103 * Drivers should not expose any additional interfaces in debugfs or
104 * sysfs on this node.
106 struct drm_minor *render;
108 /** @accel: Compute Acceleration node */
109 struct drm_minor *accel;
114 * Internally used by drm_dev_register() and drm_connector_register().
121 * Currently active master for this device.
122 * Protected by &master_mutex
124 struct drm_master *master;
127 * @driver_features: per-device driver features
129 * Drivers can clear specific flags here to disallow
130 * certain features on a per-device basis while still
131 * sharing a single &struct drm_driver instance across
139 * Flag to tell if the device has been unplugged.
140 * See drm_dev_enter() and drm_dev_is_unplugged().
144 /** @anon_inode: inode for private address-space */
145 struct inode *anon_inode;
147 /** @unique: Unique name of the device */
153 * Lock for others (not &drm_minor.master and &drm_file.is_master)
155 * TODO: This lock used to be the BKL of the DRM subsystem. Move the
156 * lock into i915, which is the only remaining user.
158 struct mutex struct_mutex;
163 * Lock for &drm_minor.master and &drm_file.is_master
165 struct mutex master_mutex;
170 * Usage counter for outstanding files open,
171 * protected by drm_global_mutex
175 /** @filelist_mutex: Protects @filelist. */
176 struct mutex filelist_mutex;
180 * List of userspace clients, linked through &drm_file.lhead.
182 struct list_head filelist;
185 * @filelist_internal:
187 * List of open DRM files for in-kernel clients.
188 * Protected by &filelist_mutex.
190 struct list_head filelist_internal;
195 * Protects &clientlist access.
197 struct mutex clientlist_mutex;
202 * List of in-kernel clients. Protected by &clientlist_mutex.
204 struct list_head clientlist;
207 * @vblank_disable_immediate:
209 * If true, vblank interrupt will be disabled immediately when the
210 * refcount drops to zero, as opposed to via the vblank disable
213 * This can be set to true it the hardware has a working vblank counter
214 * with high-precision timestamping (otherwise there are races) and the
215 * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
216 * appropriately. See also @max_vblank_count and
217 * &drm_crtc_funcs.get_vblank_counter.
219 bool vblank_disable_immediate;
224 * Array of vblank tracking structures, one per &struct drm_crtc. For
225 * historical reasons (vblank support predates kernel modesetting) this
226 * is free-standing and not part of &struct drm_crtc itself. It must be
227 * initialized explicitly by calling drm_vblank_init().
229 struct drm_vblank_crtc *vblank;
234 * Protects vblank count and time updates during vblank enable/disable
236 spinlock_t vblank_time_lock;
238 * @vbl_lock: Top-level vblank references lock, wraps the low-level
246 * Maximum value of the vblank registers. This value +1 will result in a
247 * wrap-around of the vblank register. It is used by the vblank core to
248 * handle wrap-arounds.
250 * If set to zero the vblank core will try to guess the elapsed vblanks
251 * between times when the vblank interrupt is disabled through
252 * high-precision timestamps. That approach is suffering from small
253 * races and imprecision over longer time periods, hence exposing a
254 * hardware vblank counter is always recommended.
256 * This is the statically configured device wide maximum. The driver
257 * can instead choose to use a runtime configurable per-crtc value
258 * &drm_vblank_crtc.max_vblank_count, in which case @max_vblank_count
259 * must be left at zero. See drm_crtc_set_max_vblank_count() on how
260 * to use the per-crtc value.
262 * If non-zero, &drm_crtc_funcs.get_vblank_counter must be set.
264 u32 max_vblank_count;
266 /** @vblank_event_list: List of vblank events */
267 struct list_head vblank_event_list;
272 * Protects @vblank_event_list and event delivery in
273 * general. See drm_send_event() and drm_send_event_locked().
275 spinlock_t event_lock;
277 /** @num_crtcs: Number of CRTCs on this device */
278 unsigned int num_crtcs;
280 /** @mode_config: Current mode config */
281 struct drm_mode_config mode_config;
283 /** @object_name_lock: GEM information */
284 struct mutex object_name_lock;
286 /** @object_name_idr: GEM information */
287 struct idr object_name_idr;
289 /** @vma_offset_manager: GEM information */
290 struct drm_vma_offset_manager *vma_offset_manager;
292 /** @vram_mm: VRAM MM memory manager */
293 struct drm_vram_mm *vram_mm;
296 * @switch_power_state:
298 * Power state of the client.
299 * Used by drivers supporting the switcheroo driver.
300 * The state is maintained in the
301 * &vga_switcheroo_client_ops.set_gpu_state callback
303 enum switch_power_state switch_power_state;
308 * Pointer to the fbdev emulation structure.
309 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
311 struct drm_fb_helper *fb_helper;
316 * Root directory for debugfs files.
318 struct dentry *debugfs_root;