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.
90 /** @primary: Primary node */
91 struct drm_minor *primary;
93 /** @render: Render node */
94 struct drm_minor *render;
99 * Internally used by drm_dev_register() and drm_connector_register().
106 * Currently active master for this device.
107 * Protected by &master_mutex
109 struct drm_master *master;
112 * @driver_features: per-device driver features
114 * Drivers can clear specific flags here to disallow
115 * certain features on a per-device basis while still
116 * sharing a single &struct drm_driver instance across
124 * Flag to tell if the device has been unplugged.
125 * See drm_dev_enter() and drm_dev_is_unplugged().
129 /** @anon_inode: inode for private address-space */
130 struct inode *anon_inode;
132 /** @unique: Unique name of the device */
138 * Lock for others (not &drm_minor.master and &drm_file.is_master)
141 * Only drivers annotated with DRIVER_LEGACY should be using this.
143 struct mutex struct_mutex;
148 * Lock for &drm_minor.master and &drm_file.is_master
150 struct mutex master_mutex;
155 * Usage counter for outstanding files open,
156 * protected by drm_global_mutex
160 /** @filelist_mutex: Protects @filelist. */
161 struct mutex filelist_mutex;
165 * List of userspace clients, linked through &drm_file.lhead.
167 struct list_head filelist;
170 * @filelist_internal:
172 * List of open DRM files for in-kernel clients.
173 * Protected by &filelist_mutex.
175 struct list_head filelist_internal;
180 * Protects &clientlist access.
182 struct mutex clientlist_mutex;
187 * List of in-kernel clients. Protected by &clientlist_mutex.
189 struct list_head clientlist;
192 * @vblank_disable_immediate:
194 * If true, vblank interrupt will be disabled immediately when the
195 * refcount drops to zero, as opposed to via the vblank disable
198 * This can be set to true it the hardware has a working vblank counter
199 * with high-precision timestamping (otherwise there are races) and the
200 * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
201 * appropriately. See also @max_vblank_count and
202 * &drm_crtc_funcs.get_vblank_counter.
204 bool vblank_disable_immediate;
209 * Array of vblank tracking structures, one per &struct drm_crtc. For
210 * historical reasons (vblank support predates kernel modesetting) this
211 * is free-standing and not part of &struct drm_crtc itself. It must be
212 * initialized explicitly by calling drm_vblank_init().
214 struct drm_vblank_crtc *vblank;
219 * Protects vblank count and time updates during vblank enable/disable
221 spinlock_t vblank_time_lock;
223 * @vbl_lock: Top-level vblank references lock, wraps the low-level
231 * Maximum value of the vblank registers. This value +1 will result in a
232 * wrap-around of the vblank register. It is used by the vblank core to
233 * handle wrap-arounds.
235 * If set to zero the vblank core will try to guess the elapsed vblanks
236 * between times when the vblank interrupt is disabled through
237 * high-precision timestamps. That approach is suffering from small
238 * races and imprecision over longer time periods, hence exposing a
239 * hardware vblank counter is always recommended.
241 * This is the statically configured device wide maximum. The driver
242 * can instead choose to use a runtime configurable per-crtc value
243 * &drm_vblank_crtc.max_vblank_count, in which case @max_vblank_count
244 * must be left at zero. See drm_crtc_set_max_vblank_count() on how
245 * to use the per-crtc value.
247 * If non-zero, &drm_crtc_funcs.get_vblank_counter must be set.
249 u32 max_vblank_count;
251 /** @vblank_event_list: List of vblank events */
252 struct list_head vblank_event_list;
257 * Protects @vblank_event_list and event delivery in
258 * general. See drm_send_event() and drm_send_event_locked().
260 spinlock_t event_lock;
262 /** @num_crtcs: Number of CRTCs on this device */
263 unsigned int num_crtcs;
265 /** @mode_config: Current mode config */
266 struct drm_mode_config mode_config;
268 /** @object_name_lock: GEM information */
269 struct mutex object_name_lock;
271 /** @object_name_idr: GEM information */
272 struct idr object_name_idr;
274 /** @vma_offset_manager: GEM information */
275 struct drm_vma_offset_manager *vma_offset_manager;
277 /** @vram_mm: VRAM MM memory manager */
278 struct drm_vram_mm *vram_mm;
281 * @switch_power_state:
283 * Power state of the client.
284 * Used by drivers supporting the switcheroo driver.
285 * The state is maintained in the
286 * &vga_switcheroo_client_ops.set_gpu_state callback
288 enum switch_power_state switch_power_state;
293 * Pointer to the fbdev emulation structure.
294 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
296 struct drm_fb_helper *fb_helper;
298 /* Everything below here is for legacy driver, never use! */
300 #if IS_ENABLED(CONFIG_DRM_LEGACY)
301 /* List of devices per driver for stealth attach cleanup */
302 struct list_head legacy_dev_list;
305 /** @hose: PCI hose, only used on ALPHA platforms. */
306 struct pci_controller *hose;
310 struct drm_agp_head *agp;
312 /* Context handle management - linked list of context handles */
313 struct list_head ctxlist;
315 /* Context handle management - mutex for &ctxlist */
316 struct mutex ctxlist_mutex;
318 /* Context handle management */
321 /* Memory management - linked list of regions */
322 struct list_head maplist;
324 /* Memory management - user token hash table for maps */
325 struct drm_open_hash map_hash;
327 /* Context handle management - list of vmas (for debugging) */
328 struct list_head vmalist;
330 /* Optional pointer for DMA support */
331 struct drm_device_dma *dma;
333 /* Context swapping flag */
334 __volatile__ long context_flag;
336 /* Last current context */
339 /* Lock for &buf_use and a few other things. */
342 /* Usage counter for buffers in use -- cannot alloc */
345 /* Buffer allocation in progress */
350 struct drm_hw_lock *lock;
353 struct drm_local_map *agp_buffer_map;
354 unsigned int agp_buffer_token;
356 /* Scatter gather memory */
357 struct drm_sg_mem *sg;