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;
25 struct pci_controller;
29 * enum drm_switch_power - power state of drm device
32 enum switch_power_state {
33 /** @DRM_SWITCH_POWER_ON: Power state is ON */
34 DRM_SWITCH_POWER_ON = 0,
36 /** @DRM_SWITCH_POWER_OFF: Power state is OFF */
37 DRM_SWITCH_POWER_OFF = 1,
39 /** @DRM_SWITCH_POWER_CHANGING: Power state is changing */
40 DRM_SWITCH_POWER_CHANGING = 2,
42 /** @DRM_SWITCH_POWER_DYNAMIC_OFF: Suspended */
43 DRM_SWITCH_POWER_DYNAMIC_OFF = 3,
47 * struct drm_device - DRM device structure
49 * This structure represent a complete card that
50 * may contain multiple heads.
56 * List of devices per driver for stealth attach cleanup
58 struct list_head legacy_dev_list;
60 /** @if_version: Highest interface version set */
63 /** @ref: Object ref-count */
66 /** @dev: Device structure of bus-device */
69 /** @driver: DRM driver managing the device */
70 struct drm_driver *driver;
75 * DRM driver private data. Instead of using this pointer it is
76 * recommended that drivers use drm_dev_init() and embed struct
77 * &drm_device in their larger per-device structure.
81 /** @primary: Primary node */
82 struct drm_minor *primary;
84 /** @render: Render node */
85 struct drm_minor *render;
90 * Internally used by drm_dev_register() and drm_connector_register().
97 * Currently active master for this device.
98 * Protected by &master_mutex
100 struct drm_master *master;
103 * @driver_features: per-device driver features
105 * Drivers can clear specific flags here to disallow
106 * certain features on a per-device basis while still
107 * sharing a single &struct drm_driver instance across
115 * Flag to tell if the device has been unplugged.
116 * See drm_dev_enter() and drm_dev_is_unplugged().
120 /** @anon_inode: inode for private address-space */
121 struct inode *anon_inode;
123 /** @unique: Unique name of the device */
129 * Lock for others (not &drm_minor.master and &drm_file.is_master)
131 struct mutex struct_mutex;
136 * Lock for &drm_minor.master and &drm_file.is_master
138 struct mutex master_mutex;
143 * Usage counter for outstanding files open,
144 * protected by drm_global_mutex
148 /** @filelist_mutex: Protects @filelist. */
149 struct mutex filelist_mutex;
153 * List of userspace clients, linked through &drm_file.lhead.
155 struct list_head filelist;
158 * @filelist_internal:
160 * List of open DRM files for in-kernel clients.
161 * Protected by &filelist_mutex.
163 struct list_head filelist_internal;
168 * Protects &clientlist access.
170 struct mutex clientlist_mutex;
175 * List of in-kernel clients. Protected by &clientlist_mutex.
177 struct list_head clientlist;
182 * Indicates that interrupt handling is enabled, specifically vblank
183 * handling. Drivers which don't use drm_irq_install() need to set this
189 * @irq: Used by the drm_irq_install() and drm_irq_unistall() helpers.
194 * @vblank_disable_immediate:
196 * If true, vblank interrupt will be disabled immediately when the
197 * refcount drops to zero, as opposed to via the vblank disable
200 * This can be set to true it the hardware has a working vblank counter
201 * with high-precision timestamping (otherwise there are races) and the
202 * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
203 * appropriately. See also @max_vblank_count and
204 * &drm_crtc_funcs.get_vblank_counter.
206 bool vblank_disable_immediate;
211 * Array of vblank tracking structures, one per &struct drm_crtc. For
212 * historical reasons (vblank support predates kernel modesetting) this
213 * is free-standing and not part of &struct drm_crtc itself. It must be
214 * initialized explicitly by calling drm_vblank_init().
216 struct drm_vblank_crtc *vblank;
221 * Protects vblank count and time updates during vblank enable/disable
223 spinlock_t vblank_time_lock;
225 * @vbl_lock: Top-level vblank references lock, wraps the low-level
233 * Maximum value of the vblank registers. This value +1 will result in a
234 * wrap-around of the vblank register. It is used by the vblank core to
235 * handle wrap-arounds.
237 * If set to zero the vblank core will try to guess the elapsed vblanks
238 * between times when the vblank interrupt is disabled through
239 * high-precision timestamps. That approach is suffering from small
240 * races and imprecision over longer time periods, hence exposing a
241 * hardware vblank counter is always recommended.
243 * This is the statically configured device wide maximum. The driver
244 * can instead choose to use a runtime configurable per-crtc value
245 * &drm_vblank_crtc.max_vblank_count, in which case @max_vblank_count
246 * must be left at zero. See drm_crtc_set_max_vblank_count() on how
247 * to use the per-crtc value.
249 * If non-zero, &drm_crtc_funcs.get_vblank_counter must be set.
251 u32 max_vblank_count;
253 /** @vblank_event_list: List of vblank events */
254 struct list_head vblank_event_list;
259 * Protects @vblank_event_list and event delivery in
260 * general. See drm_send_event() and drm_send_event_locked().
262 spinlock_t event_lock;
264 /** @agp: AGP data */
265 struct drm_agp_head *agp;
267 /** @pdev: PCI device structure */
268 struct pci_dev *pdev;
271 /** @hose: PCI hose, only used on ALPHA platforms. */
272 struct pci_controller *hose;
274 /** @num_crtcs: Number of CRTCs on this device */
275 unsigned int num_crtcs;
277 /** @mode_config: Current mode config */
278 struct drm_mode_config mode_config;
280 /** @object_name_lock: GEM information */
281 struct mutex object_name_lock;
283 /** @object_name_idr: GEM information */
284 struct idr object_name_idr;
286 /** @vma_offset_manager: GEM information */
287 struct drm_vma_offset_manager *vma_offset_manager;
290 * @switch_power_state:
292 * Power state of the client.
293 * Used by drivers supporting the switcheroo driver.
294 * The state is maintained in the
295 * &vga_switcheroo_client_ops.set_gpu_state callback
297 enum switch_power_state switch_power_state;
302 * Pointer to the fbdev emulation structure.
303 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
305 struct drm_fb_helper *fb_helper;
307 /* Everything below here is for legacy driver, never use! */
309 #if IS_ENABLED(CONFIG_DRM_LEGACY)
310 /* Context handle management - linked list of context handles */
311 struct list_head ctxlist;
313 /* Context handle management - mutex for &ctxlist */
314 struct mutex ctxlist_mutex;
316 /* Context handle management */
319 /* Memory management - linked list of regions */
320 struct list_head maplist;
322 /* Memory management - user token hash table for maps */
323 struct drm_open_hash map_hash;
325 /* Context handle management - list of vmas (for debugging) */
326 struct list_head vmalist;
328 /* Optional pointer for DMA support */
329 struct drm_device_dma *dma;
331 /* Context swapping flag */
332 __volatile__ long context_flag;
334 /* Last current context */
337 /* Lock for &buf_use and a few other things. */
340 /* Usage counter for buffers in use -- cannot alloc */
343 /* Buffer allocation in progress */
348 struct drm_hw_lock *lock;
351 struct drm_local_map *agp_buffer_map;
352 unsigned int agp_buffer_token;
354 /* Scatter gather memory */
355 struct drm_sg_mem *sg;