4 #include <linux/list.h>
5 #include <linux/kref.h>
6 #include <linux/mutex.h>
9 #include <drm/drm_legacy.h>
10 #include <drm/drm_mode_config.h>
15 struct drm_vblank_crtc;
16 struct drm_vma_offset_manager;
23 struct pci_controller;
27 * enum switch_power_state - power state of drm device
30 enum switch_power_state {
31 /** @DRM_SWITCH_POWER_ON: Power state is ON */
32 DRM_SWITCH_POWER_ON = 0,
34 /** @DRM_SWITCH_POWER_OFF: Power state is OFF */
35 DRM_SWITCH_POWER_OFF = 1,
37 /** @DRM_SWITCH_POWER_CHANGING: Power state is changing */
38 DRM_SWITCH_POWER_CHANGING = 2,
40 /** @DRM_SWITCH_POWER_DYNAMIC_OFF: Suspended */
41 DRM_SWITCH_POWER_DYNAMIC_OFF = 3,
45 * struct drm_device - DRM device structure
47 * This structure represent a complete card that
48 * may contain multiple heads.
51 /** @if_version: Highest interface version set */
54 /** @ref: Object ref-count */
57 /** @dev: Device structure of bus-device */
63 * Managed resources linked to the lifetime of this &drm_device as
67 /** @managed.resources: managed resources list */
68 struct list_head resources;
69 /** @managed.final_kfree: pointer for final kfree() call */
71 /** @managed.lock: protects @managed.resources */
75 /** @driver: DRM driver managing the device */
76 const struct drm_driver *driver;
81 * DRM driver private data. This is deprecated and should be left set to
84 * Instead of using this pointer it is recommended that drivers use
85 * devm_drm_dev_alloc() and embed struct &drm_device in their larger
86 * per-device structure.
93 * Primary node. Drivers should not interact with this
94 * directly. debugfs interfaces can be registered with
95 * drm_debugfs_add_file(), and sysfs should be directly added on the
96 * hardware (and not character device node) struct device @dev.
98 struct drm_minor *primary;
103 * Render node. Drivers should not interact with this directly ever.
104 * Drivers should not expose any additional interfaces in debugfs or
105 * sysfs on this node.
107 struct drm_minor *render;
109 /** @accel: Compute Acceleration node */
110 struct drm_minor *accel;
115 * Internally used by drm_dev_register() and drm_connector_register().
122 * Currently active master for this device.
123 * Protected by &master_mutex
125 struct drm_master *master;
128 * @driver_features: per-device driver features
130 * Drivers can clear specific flags here to disallow
131 * certain features on a per-device basis while still
132 * sharing a single &struct drm_driver instance across
140 * Flag to tell if the device has been unplugged.
141 * See drm_dev_enter() and drm_dev_is_unplugged().
145 /** @anon_inode: inode for private address-space */
146 struct inode *anon_inode;
148 /** @unique: Unique name of the device */
154 * Lock for others (not &drm_minor.master and &drm_file.is_master)
157 * Only drivers annotated with DRIVER_LEGACY should be using this.
159 struct mutex struct_mutex;
164 * Lock for &drm_minor.master and &drm_file.is_master
166 struct mutex master_mutex;
171 * Usage counter for outstanding files open,
172 * protected by drm_global_mutex
176 /** @filelist_mutex: Protects @filelist. */
177 struct mutex filelist_mutex;
181 * List of userspace clients, linked through &drm_file.lhead.
183 struct list_head filelist;
186 * @filelist_internal:
188 * List of open DRM files for in-kernel clients.
189 * Protected by &filelist_mutex.
191 struct list_head filelist_internal;
196 * Protects &clientlist access.
198 struct mutex clientlist_mutex;
203 * List of in-kernel clients. Protected by &clientlist_mutex.
205 struct list_head clientlist;
208 * @vblank_disable_immediate:
210 * If true, vblank interrupt will be disabled immediately when the
211 * refcount drops to zero, as opposed to via the vblank disable
214 * This can be set to true it the hardware has a working vblank counter
215 * with high-precision timestamping (otherwise there are races) and the
216 * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
217 * appropriately. See also @max_vblank_count and
218 * &drm_crtc_funcs.get_vblank_counter.
220 bool vblank_disable_immediate;
225 * Array of vblank tracking structures, one per &struct drm_crtc. For
226 * historical reasons (vblank support predates kernel modesetting) this
227 * is free-standing and not part of &struct drm_crtc itself. It must be
228 * initialized explicitly by calling drm_vblank_init().
230 struct drm_vblank_crtc *vblank;
235 * Protects vblank count and time updates during vblank enable/disable
237 spinlock_t vblank_time_lock;
239 * @vbl_lock: Top-level vblank references lock, wraps the low-level
247 * Maximum value of the vblank registers. This value +1 will result in a
248 * wrap-around of the vblank register. It is used by the vblank core to
249 * handle wrap-arounds.
251 * If set to zero the vblank core will try to guess the elapsed vblanks
252 * between times when the vblank interrupt is disabled through
253 * high-precision timestamps. That approach is suffering from small
254 * races and imprecision over longer time periods, hence exposing a
255 * hardware vblank counter is always recommended.
257 * This is the statically configured device wide maximum. The driver
258 * can instead choose to use a runtime configurable per-crtc value
259 * &drm_vblank_crtc.max_vblank_count, in which case @max_vblank_count
260 * must be left at zero. See drm_crtc_set_max_vblank_count() on how
261 * to use the per-crtc value.
263 * If non-zero, &drm_crtc_funcs.get_vblank_counter must be set.
265 u32 max_vblank_count;
267 /** @vblank_event_list: List of vblank events */
268 struct list_head vblank_event_list;
273 * Protects @vblank_event_list and event delivery in
274 * general. See drm_send_event() and drm_send_event_locked().
276 spinlock_t event_lock;
278 /** @num_crtcs: Number of CRTCs on this device */
279 unsigned int num_crtcs;
281 /** @mode_config: Current mode config */
282 struct drm_mode_config mode_config;
284 /** @object_name_lock: GEM information */
285 struct mutex object_name_lock;
287 /** @object_name_idr: GEM information */
288 struct idr object_name_idr;
290 /** @vma_offset_manager: GEM information */
291 struct drm_vma_offset_manager *vma_offset_manager;
293 /** @vram_mm: VRAM MM memory manager */
294 struct drm_vram_mm *vram_mm;
297 * @switch_power_state:
299 * Power state of the client.
300 * Used by drivers supporting the switcheroo driver.
301 * The state is maintained in the
302 * &vga_switcheroo_client_ops.set_gpu_state callback
304 enum switch_power_state switch_power_state;
309 * Pointer to the fbdev emulation structure.
310 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
312 struct drm_fb_helper *fb_helper;
317 * Protects &debugfs_list access.
319 struct mutex debugfs_mutex;
324 * List of debugfs files to be created by the DRM device. The files
325 * must be added during drm_dev_register().
327 struct list_head debugfs_list;
329 /* Everything below here is for legacy driver, never use! */
331 #if IS_ENABLED(CONFIG_DRM_LEGACY)
332 /* List of devices per driver for stealth attach cleanup */
333 struct list_head legacy_dev_list;
336 /** @hose: PCI hose, only used on ALPHA platforms. */
337 struct pci_controller *hose;
341 struct drm_agp_head *agp;
343 /* Context handle management - linked list of context handles */
344 struct list_head ctxlist;
346 /* Context handle management - mutex for &ctxlist */
347 struct mutex ctxlist_mutex;
349 /* Context handle management */
352 /* Memory management - linked list of regions */
353 struct list_head maplist;
355 /* Memory management - user token hash table for maps */
356 struct drm_open_hash map_hash;
358 /* Context handle management - list of vmas (for debugging) */
359 struct list_head vmalist;
361 /* Optional pointer for DMA support */
362 struct drm_device_dma *dma;
364 /* Context swapping flag */
365 __volatile__ long context_flag;
367 /* Last current context */
370 /* Lock for &buf_use and a few other things. */
373 /* Usage counter for buffers in use -- cannot alloc */
376 /* Buffer allocation in progress */
381 struct drm_hw_lock *lock;
384 struct drm_local_map *agp_buffer_map;
385 unsigned int agp_buffer_token;
387 /* Scatter gather memory */
388 struct drm_sg_mem *sg;