]>
Commit | Line | Data |
---|---|---|
e4672e55 DV |
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; | |
29ad20b2 | 20 | struct drm_fb_helper; |
e4672e55 DV |
21 | |
22 | struct inode; | |
23 | ||
24 | struct pci_dev; | |
25 | struct pci_controller; | |
26 | ||
27 | /** | |
28 | * DRM device structure. This structure represent a complete card that | |
29 | * may contain multiple heads. | |
30 | */ | |
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 */ | |
34 | ||
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 */ | |
e4672e55 DV |
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 | ||
bee330f3 NT |
48 | /** |
49 | * @unplugged: | |
50 | * | |
51 | * Flag to tell if the device has been unplugged. | |
52 | * See drm_dev_enter() and drm_dev_is_unplugged(). | |
53 | */ | |
54 | bool unplugged; | |
55 | ||
e4672e55 DV |
56 | struct inode *anon_inode; /**< inode for private address-space */ |
57 | char *unique; /**< unique name of the device */ | |
58 | /*@} */ | |
59 | ||
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 | /*@} */ | |
65 | ||
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 | /*@} */ | |
73 | ||
74 | struct mutex filelist_mutex; | |
75 | struct list_head filelist; | |
76 | ||
77 | /** \name Memory management */ | |
78 | /*@{ */ | |
79 | struct list_head maplist; /**< Linked list of regions */ | |
80 | struct drm_open_hash map_hash; /**< User token hash table for maps */ | |
81 | ||
82 | /** \name Context handle management */ | |
83 | /*@{ */ | |
84 | struct list_head ctxlist; /**< Linked list of context handles */ | |
85 | struct mutex ctxlist_mutex; /**< For ctxlist */ | |
86 | ||
87 | struct idr ctx_idr; | |
88 | ||
89 | struct list_head vmalist; /**< List of vmas (for debugging) */ | |
90 | ||
91 | /*@} */ | |
92 | ||
93 | /** \name DMA support */ | |
94 | /*@{ */ | |
95 | struct drm_device_dma *dma; /**< Optional pointer for DMA support */ | |
96 | /*@} */ | |
97 | ||
98 | /** \name Context support */ | |
99 | /*@{ */ | |
100 | ||
101 | __volatile__ long context_flag; /**< Context swapping flag */ | |
102 | int last_context; /**< Last current context */ | |
103 | /*@} */ | |
104 | ||
105 | /** | |
106 | * @irq_enabled: | |
107 | * | |
108 | * Indicates that interrupt handling is enabled, specifically vblank | |
109 | * handling. Drivers which don't use drm_irq_install() need to set this | |
110 | * to true manually. | |
111 | */ | |
112 | bool irq_enabled; | |
113 | int irq; | |
114 | ||
115 | /** | |
116 | * @vblank_disable_immediate: | |
117 | * | |
118 | * If true, vblank interrupt will be disabled immediately when the | |
119 | * refcount drops to zero, as opposed to via the vblank disable | |
120 | * timer. | |
121 | * | |
122 | * This can be set to true it the hardware has a working vblank counter | |
123 | * with high-precision timestamping (otherwise there are races) and the | |
124 | * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off() | |
125 | * appropriately. See also @max_vblank_count and | |
126 | * &drm_crtc_funcs.get_vblank_counter. | |
127 | */ | |
128 | bool vblank_disable_immediate; | |
129 | ||
130 | /** | |
131 | * @vblank: | |
132 | * | |
133 | * Array of vblank tracking structures, one per &struct drm_crtc. For | |
134 | * historical reasons (vblank support predates kernel modesetting) this | |
135 | * is free-standing and not part of &struct drm_crtc itself. It must be | |
136 | * initialized explicitly by calling drm_vblank_init(). | |
137 | */ | |
138 | struct drm_vblank_crtc *vblank; | |
139 | ||
140 | spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ | |
141 | spinlock_t vbl_lock; | |
142 | ||
143 | /** | |
144 | * @max_vblank_count: | |
145 | * | |
146 | * Maximum value of the vblank registers. This value +1 will result in a | |
147 | * wrap-around of the vblank register. It is used by the vblank core to | |
148 | * handle wrap-arounds. | |
149 | * | |
150 | * If set to zero the vblank core will try to guess the elapsed vblanks | |
151 | * between times when the vblank interrupt is disabled through | |
152 | * high-precision timestamps. That approach is suffering from small | |
153 | * races and imprecision over longer time periods, hence exposing a | |
154 | * hardware vblank counter is always recommended. | |
155 | * | |
156 | * If non-zeor, &drm_crtc_funcs.get_vblank_counter must be set. | |
157 | */ | |
158 | u32 max_vblank_count; /**< size of vblank counter register */ | |
159 | ||
160 | /** | |
161 | * List of events | |
162 | */ | |
163 | struct list_head vblank_event_list; | |
164 | spinlock_t event_lock; | |
165 | ||
166 | /*@} */ | |
167 | ||
168 | struct drm_agp_head *agp; /**< AGP data */ | |
169 | ||
170 | struct pci_dev *pdev; /**< PCI device structure */ | |
171 | #ifdef __alpha__ | |
172 | struct pci_controller *hose; | |
173 | #endif | |
174 | ||
175 | struct drm_sg_mem *sg; /**< Scatter gather memory */ | |
176 | unsigned int num_crtcs; /**< Number of CRTCs on this device */ | |
177 | ||
178 | struct { | |
179 | int context; | |
180 | struct drm_hw_lock *lock; | |
181 | } sigdata; | |
182 | ||
183 | struct drm_local_map *agp_buffer_map; | |
184 | unsigned int agp_buffer_token; | |
185 | ||
186 | struct drm_mode_config mode_config; /**< Current mode config */ | |
187 | ||
188 | /** \name GEM information */ | |
189 | /*@{ */ | |
190 | struct mutex object_name_lock; | |
191 | struct idr object_name_idr; | |
192 | struct drm_vma_offset_manager *vma_offset_manager; | |
193 | /*@} */ | |
194 | int switch_power_state; | |
29ad20b2 NT |
195 | |
196 | /** | |
197 | * @fb_helper: | |
198 | * | |
199 | * Pointer to the fbdev emulation structure. | |
200 | * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini(). | |
201 | */ | |
202 | struct drm_fb_helper *fb_helper; | |
e4672e55 DV |
203 | }; |
204 | ||
205 | #endif |