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 switch_power_state - 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.
54 /** @if_version: Highest interface version set */
57 /** @ref: Object ref-count */
60 /** @dev: Device structure of bus-device */
66 * Managed resources linked to the lifetime of this &drm_device as
70 /** @managed.resources: managed resources list */
71 struct list_head resources;
72 /** @managed.final_kfree: pointer for final kfree() call */
74 /** @managed.lock: protects @managed.resources */
78 /** @driver: DRM driver managing the device */
79 const struct drm_driver *driver;
84 * DRM driver private data. This is deprecated and should be left set to
87 * Instead of using this pointer it is recommended that drivers use
88 * devm_drm_dev_alloc() and embed struct &drm_device in their larger
89 * per-device structure.
93 /** @primary: Primary node */
94 struct drm_minor *primary;
96 /** @render: Render node */
97 struct drm_minor *render;
102 * Internally used by drm_dev_register() and drm_connector_register().
109 * Currently active master for this device.
110 * Protected by &master_mutex
112 struct drm_master *master;
115 * @driver_features: per-device driver features
117 * Drivers can clear specific flags here to disallow
118 * certain features on a per-device basis while still
119 * sharing a single &struct drm_driver instance across
127 * Flag to tell if the device has been unplugged.
128 * See drm_dev_enter() and drm_dev_is_unplugged().
132 /** @anon_inode: inode for private address-space */
133 struct inode *anon_inode;
135 /** @unique: Unique name of the device */
141 * Lock for others (not &drm_minor.master and &drm_file.is_master)
144 * Only drivers annotated with DRIVER_LEGACY should be using this.
146 struct mutex struct_mutex;
151 * Lock for &drm_minor.master and &drm_file.is_master
153 struct mutex master_mutex;
158 * Usage counter for outstanding files open,
159 * protected by drm_global_mutex
163 /** @filelist_mutex: Protects @filelist. */
164 struct mutex filelist_mutex;
168 * List of userspace clients, linked through &drm_file.lhead.
170 struct list_head filelist;
173 * @filelist_internal:
175 * List of open DRM files for in-kernel clients.
176 * Protected by &filelist_mutex.
178 struct list_head filelist_internal;
183 * Protects &clientlist access.
185 struct mutex clientlist_mutex;
190 * List of in-kernel clients. Protected by &clientlist_mutex.
192 struct list_head clientlist;
197 * Indicates that interrupt handling is enabled, specifically vblank
198 * handling. Drivers which don't use drm_irq_install() need to set this
204 * @irq: Used by the drm_irq_install() and drm_irq_unistall() helpers.
209 * @vblank_disable_immediate:
211 * If true, vblank interrupt will be disabled immediately when the
212 * refcount drops to zero, as opposed to via the vblank disable
215 * This can be set to true it the hardware has a working vblank counter
216 * with high-precision timestamping (otherwise there are races) and the
217 * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
218 * appropriately. See also @max_vblank_count and
219 * &drm_crtc_funcs.get_vblank_counter.
221 bool vblank_disable_immediate;
226 * Array of vblank tracking structures, one per &struct drm_crtc. For
227 * historical reasons (vblank support predates kernel modesetting) this
228 * is free-standing and not part of &struct drm_crtc itself. It must be
229 * initialized explicitly by calling drm_vblank_init().
231 struct drm_vblank_crtc *vblank;
236 * Protects vblank count and time updates during vblank enable/disable
238 spinlock_t vblank_time_lock;
240 * @vbl_lock: Top-level vblank references lock, wraps the low-level
248 * Maximum value of the vblank registers. This value +1 will result in a
249 * wrap-around of the vblank register. It is used by the vblank core to
250 * handle wrap-arounds.
252 * If set to zero the vblank core will try to guess the elapsed vblanks
253 * between times when the vblank interrupt is disabled through
254 * high-precision timestamps. That approach is suffering from small
255 * races and imprecision over longer time periods, hence exposing a
256 * hardware vblank counter is always recommended.
258 * This is the statically configured device wide maximum. The driver
259 * can instead choose to use a runtime configurable per-crtc value
260 * &drm_vblank_crtc.max_vblank_count, in which case @max_vblank_count
261 * must be left at zero. See drm_crtc_set_max_vblank_count() on how
262 * to use the per-crtc value.
264 * If non-zero, &drm_crtc_funcs.get_vblank_counter must be set.
266 u32 max_vblank_count;
268 /** @vblank_event_list: List of vblank events */
269 struct list_head vblank_event_list;
274 * Protects @vblank_event_list and event delivery in
275 * general. See drm_send_event() and drm_send_event_locked().
277 spinlock_t event_lock;
279 /** @num_crtcs: Number of CRTCs on this device */
280 unsigned int num_crtcs;
282 /** @mode_config: Current mode config */
283 struct drm_mode_config mode_config;
285 /** @object_name_lock: GEM information */
286 struct mutex object_name_lock;
288 /** @object_name_idr: GEM information */
289 struct idr object_name_idr;
291 /** @vma_offset_manager: GEM information */
292 struct drm_vma_offset_manager *vma_offset_manager;
294 /** @vram_mm: VRAM MM memory manager */
295 struct drm_vram_mm *vram_mm;
298 * @switch_power_state:
300 * Power state of the client.
301 * Used by drivers supporting the switcheroo driver.
302 * The state is maintained in the
303 * &vga_switcheroo_client_ops.set_gpu_state callback
305 enum switch_power_state switch_power_state;
310 * Pointer to the fbdev emulation structure.
311 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
313 struct drm_fb_helper *fb_helper;
315 /* Everything below here is for legacy driver, never use! */
317 #if IS_ENABLED(CONFIG_DRM_LEGACY)
318 /* List of devices per driver for stealth attach cleanup */
319 struct list_head legacy_dev_list;
322 /** @hose: PCI hose, only used on ALPHA platforms. */
323 struct pci_controller *hose;
327 struct drm_agp_head *agp;
329 /* Context handle management - linked list of context handles */
330 struct list_head ctxlist;
332 /* Context handle management - mutex for &ctxlist */
333 struct mutex ctxlist_mutex;
335 /* Context handle management */
338 /* Memory management - linked list of regions */
339 struct list_head maplist;
341 /* Memory management - user token hash table for maps */
342 struct drm_open_hash map_hash;
344 /* Context handle management - list of vmas (for debugging) */
345 struct list_head vmalist;
347 /* Optional pointer for DMA support */
348 struct drm_device_dma *dma;
350 /* Context swapping flag */
351 __volatile__ long context_flag;
353 /* Last current context */
356 /* Lock for &buf_use and a few other things. */
359 /* Usage counter for buffers in use -- cannot alloc */
362 /* Buffer allocation in progress */
367 struct drm_hw_lock *lock;
370 struct drm_local_map *agp_buffer_map;
371 unsigned int agp_buffer_token;
373 /* Scatter gather memory */
374 struct drm_sg_mem *sg;