Linux 4.16.11
[linux/fpc-iii.git] / include / drm / drm_device.h
blob7c4fa32f3fc6fb151c25a3f44d96f04ac71a86fc
1 #ifndef _DRM_DEVICE_H_
2 #define _DRM_DEVICE_H_
4 #include <linux/list.h>
5 #include <linux/kref.h>
6 #include <linux/mutex.h>
7 #include <linux/idr.h>
9 #include <drm/drm_hashtab.h>
10 #include <drm/drm_mode_config.h>
12 struct drm_driver;
13 struct drm_minor;
14 struct drm_master;
15 struct drm_device_dma;
16 struct drm_vblank_crtc;
17 struct drm_sg_mem;
18 struct drm_local_map;
19 struct drm_vma_offset_manager;
20 struct drm_fb_helper;
22 struct inode;
24 struct pci_dev;
25 struct pci_controller;
27 /**
28 * DRM device structure. This structure represent a complete card that
29 * may contain multiple heads.
31 struct drm_device {
32 struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
33 int if_version; /**< Highest interface version set */
35 /** \name Lifetime Management */
36 /*@{ */
37 struct kref ref; /**< Object ref-count */
38 struct device *dev; /**< Device structure of bus-device */
39 struct drm_driver *driver; /**< DRM driver managing the device */
40 void *dev_private; /**< DRM driver private data */
41 struct drm_minor *control; /**< Control node */
42 struct drm_minor *primary; /**< Primary node */
43 struct drm_minor *render; /**< Render node */
44 bool registered;
46 /* currently active master for this device. Protected by master_mutex */
47 struct drm_master *master;
49 atomic_t unplugged; /**< Flag whether dev is dead */
50 struct inode *anon_inode; /**< inode for private address-space */
51 char *unique; /**< unique name of the device */
52 /*@} */
54 /** \name Locks */
55 /*@{ */
56 struct mutex struct_mutex; /**< For others */
57 struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
58 /*@} */
60 /** \name Usage Counters */
61 /*@{ */
62 int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
63 spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
64 int buf_use; /**< Buffers in use -- cannot alloc */
65 atomic_t buf_alloc; /**< Buffer allocation in progress */
66 /*@} */
68 struct mutex filelist_mutex;
69 struct list_head filelist;
71 /** \name Memory management */
72 /*@{ */
73 struct list_head maplist; /**< Linked list of regions */
74 struct drm_open_hash map_hash; /**< User token hash table for maps */
76 /** \name Context handle management */
77 /*@{ */
78 struct list_head ctxlist; /**< Linked list of context handles */
79 struct mutex ctxlist_mutex; /**< For ctxlist */
81 struct idr ctx_idr;
83 struct list_head vmalist; /**< List of vmas (for debugging) */
85 /*@} */
87 /** \name DMA support */
88 /*@{ */
89 struct drm_device_dma *dma; /**< Optional pointer for DMA support */
90 /*@} */
92 /** \name Context support */
93 /*@{ */
95 __volatile__ long context_flag; /**< Context swapping flag */
96 int last_context; /**< Last current context */
97 /*@} */
99 /**
100 * @irq_enabled:
102 * Indicates that interrupt handling is enabled, specifically vblank
103 * handling. Drivers which don't use drm_irq_install() need to set this
104 * to true manually.
106 bool irq_enabled;
107 int irq;
110 * @vblank_disable_immediate:
112 * If true, vblank interrupt will be disabled immediately when the
113 * refcount drops to zero, as opposed to via the vblank disable
114 * timer.
116 * This can be set to true it the hardware has a working vblank counter
117 * with high-precision timestamping (otherwise there are races) and the
118 * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
119 * appropriately. See also @max_vblank_count and
120 * &drm_crtc_funcs.get_vblank_counter.
122 bool vblank_disable_immediate;
125 * @vblank:
127 * Array of vblank tracking structures, one per &struct drm_crtc. For
128 * historical reasons (vblank support predates kernel modesetting) this
129 * is free-standing and not part of &struct drm_crtc itself. It must be
130 * initialized explicitly by calling drm_vblank_init().
132 struct drm_vblank_crtc *vblank;
134 spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
135 spinlock_t vbl_lock;
138 * @max_vblank_count:
140 * Maximum value of the vblank registers. This value +1 will result in a
141 * wrap-around of the vblank register. It is used by the vblank core to
142 * handle wrap-arounds.
144 * If set to zero the vblank core will try to guess the elapsed vblanks
145 * between times when the vblank interrupt is disabled through
146 * high-precision timestamps. That approach is suffering from small
147 * races and imprecision over longer time periods, hence exposing a
148 * hardware vblank counter is always recommended.
150 * If non-zeor, &drm_crtc_funcs.get_vblank_counter must be set.
152 u32 max_vblank_count; /**< size of vblank counter register */
155 * List of events
157 struct list_head vblank_event_list;
158 spinlock_t event_lock;
160 /*@} */
162 struct drm_agp_head *agp; /**< AGP data */
164 struct pci_dev *pdev; /**< PCI device structure */
165 #ifdef __alpha__
166 struct pci_controller *hose;
167 #endif
169 struct drm_sg_mem *sg; /**< Scatter gather memory */
170 unsigned int num_crtcs; /**< Number of CRTCs on this device */
172 struct {
173 int context;
174 struct drm_hw_lock *lock;
175 } sigdata;
177 struct drm_local_map *agp_buffer_map;
178 unsigned int agp_buffer_token;
180 struct drm_mode_config mode_config; /**< Current mode config */
182 /** \name GEM information */
183 /*@{ */
184 struct mutex object_name_lock;
185 struct idr object_name_idr;
186 struct drm_vma_offset_manager *vma_offset_manager;
187 /*@} */
188 int switch_power_state;
191 * @fb_helper:
193 * Pointer to the fbdev emulation structure.
194 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
196 struct drm_fb_helper *fb_helper;
199 #endif