4 #include <linux/list.h>
5 #include <linux/kref.h>
6 #include <linux/mutex.h>
9 #include <drm/drm_hashtab.h>
10 #include <drm/drm_mode_config.h>
15 struct drm_device_dma;
16 struct drm_vblank_crtc;
19 struct drm_vma_offset_manager;
26 struct pci_controller;
30 * enum drm_switch_power - power state of drm device
33 enum switch_power_state {
34 /** @DRM_SWITCH_POWER_ON: Power state is ON */
35 DRM_SWITCH_POWER_ON = 0,
37 /** @DRM_SWITCH_POWER_OFF: Power state is OFF */
38 DRM_SWITCH_POWER_OFF = 1,
40 /** @DRM_SWITCH_POWER_CHANGING: Power state is changing */
41 DRM_SWITCH_POWER_CHANGING = 2,
43 /** @DRM_SWITCH_POWER_DYNAMIC_OFF: Suspended */
44 DRM_SWITCH_POWER_DYNAMIC_OFF = 3,
48 * struct drm_device - DRM device structure
50 * This structure represent a complete card that
51 * may contain multiple heads.
57 * List of devices per driver for stealth attach cleanup
59 struct list_head legacy_dev_list;
61 /** @if_version: Highest interface version set */
64 /** @ref: Object ref-count */
67 /** @dev: Device structure of bus-device */
73 * Managed resources linked to the lifetime of this &drm_device as
77 /** @managed.resources: managed resources list */
78 struct list_head resources;
79 /** @managed.final_kfree: pointer for final kfree() call */
81 /** @managed.lock: protects @managed.resources */
85 /** @driver: DRM driver managing the device */
86 struct drm_driver *driver;
91 * DRM driver private data. This is deprecated and should be left set to
94 * Instead of using this pointer it is recommended that drivers use
95 * devm_drm_dev_alloc() and embed struct &drm_device in their larger
96 * per-device structure.
100 /** @primary: Primary node */
101 struct drm_minor *primary;
103 /** @render: Render node */
104 struct drm_minor *render;
109 * Internally used by drm_dev_register() and drm_connector_register().
116 * Currently active master for this device.
117 * Protected by &master_mutex
119 struct drm_master *master;
122 * @driver_features: per-device driver features
124 * Drivers can clear specific flags here to disallow
125 * certain features on a per-device basis while still
126 * sharing a single &struct drm_driver instance across
134 * Flag to tell if the device has been unplugged.
135 * See drm_dev_enter() and drm_dev_is_unplugged().
139 /** @anon_inode: inode for private address-space */
140 struct inode *anon_inode;
142 /** @unique: Unique name of the device */
148 * Lock for others (not &drm_minor.master and &drm_file.is_master)
151 * Only drivers annotated with DRIVER_LEGACY should be using this.
153 struct mutex struct_mutex;
158 * Lock for &drm_minor.master and &drm_file.is_master
160 struct mutex master_mutex;
165 * Usage counter for outstanding files open,
166 * protected by drm_global_mutex
170 /** @filelist_mutex: Protects @filelist. */
171 struct mutex filelist_mutex;
175 * List of userspace clients, linked through &drm_file.lhead.
177 struct list_head filelist;
180 * @filelist_internal:
182 * List of open DRM files for in-kernel clients.
183 * Protected by &filelist_mutex.
185 struct list_head filelist_internal;
190 * Protects &clientlist access.
192 struct mutex clientlist_mutex;
197 * List of in-kernel clients. Protected by &clientlist_mutex.
199 struct list_head clientlist;
204 * Indicates that interrupt handling is enabled, specifically vblank
205 * handling. Drivers which don't use drm_irq_install() need to set this
211 * @irq: Used by the drm_irq_install() and drm_irq_unistall() helpers.
216 * @vblank_disable_immediate:
218 * If true, vblank interrupt will be disabled immediately when the
219 * refcount drops to zero, as opposed to via the vblank disable
222 * This can be set to true it the hardware has a working vblank counter
223 * with high-precision timestamping (otherwise there are races) and the
224 * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
225 * appropriately. See also @max_vblank_count and
226 * &drm_crtc_funcs.get_vblank_counter.
228 bool vblank_disable_immediate;
233 * Array of vblank tracking structures, one per &struct drm_crtc. For
234 * historical reasons (vblank support predates kernel modesetting) this
235 * is free-standing and not part of &struct drm_crtc itself. It must be
236 * initialized explicitly by calling drm_vblank_init().
238 struct drm_vblank_crtc *vblank;
243 * Protects vblank count and time updates during vblank enable/disable
245 spinlock_t vblank_time_lock;
247 * @vbl_lock: Top-level vblank references lock, wraps the low-level
255 * Maximum value of the vblank registers. This value +1 will result in a
256 * wrap-around of the vblank register. It is used by the vblank core to
257 * handle wrap-arounds.
259 * If set to zero the vblank core will try to guess the elapsed vblanks
260 * between times when the vblank interrupt is disabled through
261 * high-precision timestamps. That approach is suffering from small
262 * races and imprecision over longer time periods, hence exposing a
263 * hardware vblank counter is always recommended.
265 * This is the statically configured device wide maximum. The driver
266 * can instead choose to use a runtime configurable per-crtc value
267 * &drm_vblank_crtc.max_vblank_count, in which case @max_vblank_count
268 * must be left at zero. See drm_crtc_set_max_vblank_count() on how
269 * to use the per-crtc value.
271 * If non-zero, &drm_crtc_funcs.get_vblank_counter must be set.
273 u32 max_vblank_count;
275 /** @vblank_event_list: List of vblank events */
276 struct list_head vblank_event_list;
281 * Protects @vblank_event_list and event delivery in
282 * general. See drm_send_event() and drm_send_event_locked().
284 spinlock_t event_lock;
286 /** @agp: AGP data */
287 struct drm_agp_head *agp;
289 /** @pdev: PCI device structure */
290 struct pci_dev *pdev;
293 /** @hose: PCI hose, only used on ALPHA platforms. */
294 struct pci_controller *hose;
296 /** @num_crtcs: Number of CRTCs on this device */
297 unsigned int num_crtcs;
299 /** @mode_config: Current mode config */
300 struct drm_mode_config mode_config;
302 /** @object_name_lock: GEM information */
303 struct mutex object_name_lock;
305 /** @object_name_idr: GEM information */
306 struct idr object_name_idr;
308 /** @vma_offset_manager: GEM information */
309 struct drm_vma_offset_manager *vma_offset_manager;
311 /** @vram_mm: VRAM MM memory manager */
312 struct drm_vram_mm *vram_mm;
315 * @switch_power_state:
317 * Power state of the client.
318 * Used by drivers supporting the switcheroo driver.
319 * The state is maintained in the
320 * &vga_switcheroo_client_ops.set_gpu_state callback
322 enum switch_power_state switch_power_state;
327 * Pointer to the fbdev emulation structure.
328 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
330 struct drm_fb_helper *fb_helper;
332 /* Everything below here is for legacy driver, never use! */
334 #if IS_ENABLED(CONFIG_DRM_LEGACY)
335 /* Context handle management - linked list of context handles */
336 struct list_head ctxlist;
338 /* Context handle management - mutex for &ctxlist */
339 struct mutex ctxlist_mutex;
341 /* Context handle management */
344 /* Memory management - linked list of regions */
345 struct list_head maplist;
347 /* Memory management - user token hash table for maps */
348 struct drm_open_hash map_hash;
350 /* Context handle management - list of vmas (for debugging) */
351 struct list_head vmalist;
353 /* Optional pointer for DMA support */
354 struct drm_device_dma *dma;
356 /* Context swapping flag */
357 __volatile__ long context_flag;
359 /* Last current context */
362 /* Lock for &buf_use and a few other things. */
365 /* Usage counter for buffers in use -- cannot alloc */
368 /* Buffer allocation in progress */
373 struct drm_hw_lock *lock;
376 struct drm_local_map *agp_buffer_map;
377 unsigned int agp_buffer_token;
379 /* Scatter gather memory */
380 struct drm_sg_mem *sg;