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