Merge tag 'acpi-4.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux/fpc-iii.git] / include / drm / drm_device.h
blobf9c6e0e3aec7d049ab63315108ba816c15e47a18
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 *primary; /**< Primary node */
42 struct drm_minor *render; /**< Render node */
43 bool registered;
45 /* currently active master for this device. Protected by master_mutex */
46 struct drm_master *master;
48 /**
49 * @unplugged:
51 * Flag to tell if the device has been unplugged.
52 * See drm_dev_enter() and drm_dev_is_unplugged().
54 bool unplugged;
56 struct inode *anon_inode; /**< inode for private address-space */
57 char *unique; /**< unique name of the device */
58 /*@} */
60 /** \name Locks */
61 /*@{ */
62 struct mutex struct_mutex; /**< For others */
63 struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
64 /*@} */
66 /** \name Usage Counters */
67 /*@{ */
68 int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
69 spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
70 int buf_use; /**< Buffers in use -- cannot alloc */
71 atomic_t buf_alloc; /**< Buffer allocation in progress */
72 /*@} */
74 struct mutex filelist_mutex;
75 struct list_head filelist;
77 /**
78 * @filelist_internal:
80 * List of open DRM files for in-kernel clients. Protected by @filelist_mutex.
82 struct list_head filelist_internal;
84 /**
85 * @clientlist_mutex:
87 * Protects @clientlist access.
89 struct mutex clientlist_mutex;
91 /**
92 * @clientlist:
94 * List of in-kernel clients. Protected by @clientlist_mutex.
96 struct list_head clientlist;
98 /** \name Memory management */
99 /*@{ */
100 struct list_head maplist; /**< Linked list of regions */
101 struct drm_open_hash map_hash; /**< User token hash table for maps */
103 /** \name Context handle management */
104 /*@{ */
105 struct list_head ctxlist; /**< Linked list of context handles */
106 struct mutex ctxlist_mutex; /**< For ctxlist */
108 struct idr ctx_idr;
110 struct list_head vmalist; /**< List of vmas (for debugging) */
112 /*@} */
114 /** \name DMA support */
115 /*@{ */
116 struct drm_device_dma *dma; /**< Optional pointer for DMA support */
117 /*@} */
119 /** \name Context support */
120 /*@{ */
122 __volatile__ long context_flag; /**< Context swapping flag */
123 int last_context; /**< Last current context */
124 /*@} */
127 * @irq_enabled:
129 * Indicates that interrupt handling is enabled, specifically vblank
130 * handling. Drivers which don't use drm_irq_install() need to set this
131 * to true manually.
133 bool irq_enabled;
134 int irq;
137 * @vblank_disable_immediate:
139 * If true, vblank interrupt will be disabled immediately when the
140 * refcount drops to zero, as opposed to via the vblank disable
141 * timer.
143 * This can be set to true it the hardware has a working vblank counter
144 * with high-precision timestamping (otherwise there are races) and the
145 * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
146 * appropriately. See also @max_vblank_count and
147 * &drm_crtc_funcs.get_vblank_counter.
149 bool vblank_disable_immediate;
152 * @vblank:
154 * Array of vblank tracking structures, one per &struct drm_crtc. For
155 * historical reasons (vblank support predates kernel modesetting) this
156 * is free-standing and not part of &struct drm_crtc itself. It must be
157 * initialized explicitly by calling drm_vblank_init().
159 struct drm_vblank_crtc *vblank;
161 spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
162 spinlock_t vbl_lock;
165 * @max_vblank_count:
167 * Maximum value of the vblank registers. This value +1 will result in a
168 * wrap-around of the vblank register. It is used by the vblank core to
169 * handle wrap-arounds.
171 * If set to zero the vblank core will try to guess the elapsed vblanks
172 * between times when the vblank interrupt is disabled through
173 * high-precision timestamps. That approach is suffering from small
174 * races and imprecision over longer time periods, hence exposing a
175 * hardware vblank counter is always recommended.
177 * If non-zeor, &drm_crtc_funcs.get_vblank_counter must be set.
179 u32 max_vblank_count; /**< size of vblank counter register */
182 * List of events
184 struct list_head vblank_event_list;
185 spinlock_t event_lock;
187 /*@} */
189 struct drm_agp_head *agp; /**< AGP data */
191 struct pci_dev *pdev; /**< PCI device structure */
192 #ifdef __alpha__
193 struct pci_controller *hose;
194 #endif
196 struct drm_sg_mem *sg; /**< Scatter gather memory */
197 unsigned int num_crtcs; /**< Number of CRTCs on this device */
199 struct {
200 int context;
201 struct drm_hw_lock *lock;
202 } sigdata;
204 struct drm_local_map *agp_buffer_map;
205 unsigned int agp_buffer_token;
207 struct drm_mode_config mode_config; /**< Current mode config */
209 /** \name GEM information */
210 /*@{ */
211 struct mutex object_name_lock;
212 struct idr object_name_idr;
213 struct drm_vma_offset_manager *vma_offset_manager;
214 /*@} */
215 int switch_power_state;
218 * @fb_helper:
220 * Pointer to the fbdev emulation structure.
221 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
223 struct drm_fb_helper *fb_helper;
226 #endif