Rev 6936 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6936 | Rev 7143 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Internal Header for the Direct Rendering Manager |
2 | * Internal Header for the Direct Rendering Manager |
3 | * |
3 | * |
4 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
4 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
5 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
5 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
6 | * Copyright (c) 2009-2010, Code Aurora Forum. |
6 | * Copyright (c) 2009-2010, Code Aurora Forum. |
7 | * All rights reserved. |
7 | * All rights reserved. |
8 | * |
8 | * |
9 | * Author: Rickard E. (Rik) Faith |
9 | * Author: Rickard E. (Rik) Faith |
10 | * Author: Gareth Hughes |
10 | * Author: Gareth Hughes |
11 | * |
11 | * |
12 | * Permission is hereby granted, free of charge, to any person obtaining a |
12 | * Permission is hereby granted, free of charge, to any person obtaining a |
13 | * copy of this software and associated documentation files (the "Software"), |
13 | * copy of this software and associated documentation files (the "Software"), |
14 | * to deal in the Software without restriction, including without limitation |
14 | * to deal in the Software without restriction, including without limitation |
15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
16 | * and/or sell copies of the Software, and to permit persons to whom the |
16 | * and/or sell copies of the Software, and to permit persons to whom the |
17 | * Software is furnished to do so, subject to the following conditions: |
17 | * Software is furnished to do so, subject to the following conditions: |
18 | * |
18 | * |
19 | * The above copyright notice and this permission notice (including the next |
19 | * The above copyright notice and this permission notice (including the next |
20 | * paragraph) shall be included in all copies or substantial portions of the |
20 | * paragraph) shall be included in all copies or substantial portions of the |
21 | * Software. |
21 | * Software. |
22 | * |
22 | * |
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
26 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
26 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
27 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
27 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
28 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
28 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
29 | * OTHER DEALINGS IN THE SOFTWARE. |
29 | * OTHER DEALINGS IN THE SOFTWARE. |
30 | */ |
30 | */ |
31 | 31 | ||
32 | #ifndef _DRM_P_H_ |
32 | #ifndef _DRM_P_H_ |
33 | #define _DRM_P_H_ |
33 | #define _DRM_P_H_ |
34 | 34 | ||
35 | #include |
35 | #include |
36 | #include |
36 | #include |
37 | 37 | ||
38 | #include |
38 | #include |
39 | #include |
39 | #include |
40 | #include |
40 | #include |
41 | #include |
41 | #include |
42 | #include |
42 | #include |
43 | #include |
43 | #include |
44 | #include |
44 | #include |
45 | #include |
45 | #include |
46 | #include |
46 | #include |
47 | #include |
47 | #include |
48 | - | ||
49 | #include |
- | |
50 | #include |
48 | #include |
51 | #include |
49 | #include |
52 | #include |
50 | #include |
53 | #include |
51 | #include |
54 | 52 | ||
55 | #include |
53 | #include |
56 | #include |
54 | #include |
57 | 55 | ||
58 | 56 | ||
59 | #include |
57 | #include |
60 | #include |
58 | #include |
61 | #include |
59 | #include |
62 | #include |
60 | #include |
63 | #include |
61 | #include |
- | 62 | ||
- | 63 | #include |
|
64 | 64 | ||
65 | #include |
65 | #include |
66 | #include |
66 | #include |
67 | 67 | ||
68 | #include |
68 | #include |
69 | #include |
69 | #include |
70 | #include |
70 | #include |
71 | #include |
71 | #include |
72 | #include |
72 | #include |
73 | #include |
73 | #include |
74 | #include |
74 | #include |
75 | #include |
75 | #include |
76 | #include |
76 | #include |
77 | 77 | ||
78 | struct module; |
78 | struct module; |
79 | 79 | ||
80 | struct drm_file; |
80 | struct drm_file; |
81 | struct drm_device; |
81 | struct drm_device; |
82 | struct drm_agp_head; |
82 | struct drm_agp_head; |
83 | struct drm_local_map; |
83 | struct drm_local_map; |
84 | struct drm_device_dma; |
84 | struct drm_device_dma; |
85 | struct drm_dma_handle; |
85 | struct drm_dma_handle; |
86 | struct drm_gem_object; |
86 | struct drm_gem_object; |
87 | 87 | ||
88 | struct device_node; |
88 | struct device_node; |
89 | struct videomode; |
89 | struct videomode; |
90 | struct reservation_object; |
90 | struct reservation_object; |
91 | struct dma_buf_attachment; |
91 | struct dma_buf_attachment; |
92 | 92 | ||
93 | struct inode; |
93 | struct inode; |
94 | struct poll_table_struct; |
94 | struct poll_table_struct; |
95 | struct sg_table; |
95 | struct sg_table; |
96 | 96 | ||
97 | #define KHZ2PICOS(a) (1000000000UL/(a)) |
97 | #define KHZ2PICOS(a) (1000000000UL/(a)) |
98 | 98 | ||
99 | /* |
99 | /* |
100 | * 4 debug categories are defined: |
100 | * 4 debug categories are defined: |
101 | * |
101 | * |
102 | * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... |
102 | * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... |
103 | * This is the category used by the DRM_DEBUG() macro. |
103 | * This is the category used by the DRM_DEBUG() macro. |
104 | * |
104 | * |
105 | * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... |
105 | * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... |
106 | * This is the category used by the DRM_DEBUG_DRIVER() macro. |
106 | * This is the category used by the DRM_DEBUG_DRIVER() macro. |
107 | * |
107 | * |
108 | * KMS: used in the modesetting code. |
108 | * KMS: used in the modesetting code. |
109 | * This is the category used by the DRM_DEBUG_KMS() macro. |
109 | * This is the category used by the DRM_DEBUG_KMS() macro. |
110 | * |
110 | * |
111 | * PRIME: used in the prime code. |
111 | * PRIME: used in the prime code. |
112 | * This is the category used by the DRM_DEBUG_PRIME() macro. |
112 | * This is the category used by the DRM_DEBUG_PRIME() macro. |
113 | * |
113 | * |
114 | * ATOMIC: used in the atomic code. |
114 | * ATOMIC: used in the atomic code. |
115 | * This is the category used by the DRM_DEBUG_ATOMIC() macro. |
115 | * This is the category used by the DRM_DEBUG_ATOMIC() macro. |
116 | * |
116 | * |
117 | * VBL: used for verbose debug message in the vblank code |
117 | * VBL: used for verbose debug message in the vblank code |
118 | * This is the category used by the DRM_DEBUG_VBL() macro. |
118 | * This is the category used by the DRM_DEBUG_VBL() macro. |
119 | * |
119 | * |
120 | * Enabling verbose debug messages is done through the drm.debug parameter, |
120 | * Enabling verbose debug messages is done through the drm.debug parameter, |
121 | * each category being enabled by a bit. |
121 | * each category being enabled by a bit. |
122 | * |
122 | * |
123 | * drm.debug=0x1 will enable CORE messages |
123 | * drm.debug=0x1 will enable CORE messages |
124 | * drm.debug=0x2 will enable DRIVER messages |
124 | * drm.debug=0x2 will enable DRIVER messages |
125 | * drm.debug=0x3 will enable CORE and DRIVER messages |
125 | * drm.debug=0x3 will enable CORE and DRIVER messages |
126 | * ... |
126 | * ... |
127 | * drm.debug=0x3f will enable all messages |
127 | * drm.debug=0x3f will enable all messages |
128 | * |
128 | * |
129 | * An interesting feature is that it's possible to enable verbose logging at |
129 | * An interesting feature is that it's possible to enable verbose logging at |
130 | * run-time by echoing the debug value in its sysfs node: |
130 | * run-time by echoing the debug value in its sysfs node: |
131 | * # echo 0xf > /sys/module/drm/parameters/debug |
131 | * # echo 0xf > /sys/module/drm/parameters/debug |
132 | */ |
132 | */ |
133 | #define DRM_UT_CORE 0x01 |
133 | #define DRM_UT_CORE 0x01 |
134 | #define DRM_UT_DRIVER 0x02 |
134 | #define DRM_UT_DRIVER 0x02 |
135 | #define DRM_UT_KMS 0x04 |
135 | #define DRM_UT_KMS 0x04 |
136 | #define DRM_UT_PRIME 0x08 |
136 | #define DRM_UT_PRIME 0x08 |
137 | #define DRM_UT_ATOMIC 0x10 |
137 | #define DRM_UT_ATOMIC 0x10 |
138 | #define DRM_UT_VBL 0x20 |
138 | #define DRM_UT_VBL 0x20 |
139 | 139 | ||
140 | extern __printf(2, 3) |
140 | extern __printf(2, 3) |
141 | void drm_ut_debug_printk(const char *function_name, |
141 | void drm_ut_debug_printk(const char *function_name, |
142 | const char *format, ...); |
142 | const char *format, ...); |
143 | extern __printf(1, 2) |
143 | extern __printf(1, 2) |
144 | void drm_err(const char *format, ...); |
144 | void drm_err(const char *format, ...); |
145 | 145 | ||
146 | /***********************************************************************/ |
146 | /***********************************************************************/ |
147 | /** \name DRM template customization defaults */ |
147 | /** \name DRM template customization defaults */ |
148 | /*@{*/ |
148 | /*@{*/ |
149 | 149 | ||
150 | /* driver capabilities and requirements mask */ |
150 | /* driver capabilities and requirements mask */ |
151 | #define DRIVER_USE_AGP 0x1 |
151 | #define DRIVER_USE_AGP 0x1 |
152 | #define DRIVER_PCI_DMA 0x8 |
152 | #define DRIVER_PCI_DMA 0x8 |
153 | #define DRIVER_SG 0x10 |
153 | #define DRIVER_SG 0x10 |
154 | #define DRIVER_HAVE_DMA 0x20 |
154 | #define DRIVER_HAVE_DMA 0x20 |
155 | #define DRIVER_HAVE_IRQ 0x40 |
155 | #define DRIVER_HAVE_IRQ 0x40 |
156 | #define DRIVER_IRQ_SHARED 0x80 |
156 | #define DRIVER_IRQ_SHARED 0x80 |
157 | #define DRIVER_GEM 0x1000 |
157 | #define DRIVER_GEM 0x1000 |
158 | #define DRIVER_MODESET 0x2000 |
158 | #define DRIVER_MODESET 0x2000 |
159 | #define DRIVER_PRIME 0x4000 |
159 | #define DRIVER_PRIME 0x4000 |
160 | #define DRIVER_RENDER 0x8000 |
160 | #define DRIVER_RENDER 0x8000 |
161 | #define DRIVER_ATOMIC 0x10000 |
161 | #define DRIVER_ATOMIC 0x10000 |
162 | #define DRIVER_KMS_LEGACY_CONTEXT 0x20000 |
162 | #define DRIVER_KMS_LEGACY_CONTEXT 0x20000 |
163 | 163 | ||
164 | /***********************************************************************/ |
164 | /***********************************************************************/ |
165 | /** \name Macros to make printk easier */ |
165 | /** \name Macros to make printk easier */ |
166 | /*@{*/ |
166 | /*@{*/ |
167 | 167 | ||
168 | /** |
168 | /** |
169 | * Error output. |
169 | * Error output. |
170 | * |
170 | * |
171 | * \param fmt printf() like format string. |
171 | * \param fmt printf() like format string. |
172 | * \param arg arguments |
172 | * \param arg arguments |
173 | */ |
173 | */ |
174 | #define DRM_ERROR(fmt, ...) \ |
174 | #define DRM_ERROR(fmt, ...) \ |
175 | printk("DRM Error" fmt, ##__VA_ARGS__) |
175 | printk("DRM Error " fmt, ##__VA_ARGS__) |
176 | 176 | ||
177 | /** |
177 | /** |
178 | * Rate limited error output. Like DRM_ERROR() but won't flood the log. |
178 | * Rate limited error output. Like DRM_ERROR() but won't flood the log. |
179 | * |
179 | * |
180 | * \param fmt printf() like format string. |
180 | * \param fmt printf() like format string. |
181 | * \param arg arguments |
181 | * \param arg arguments |
182 | */ |
182 | */ |
183 | #define DRM_ERROR_RATELIMITED(fmt, ...) \ |
183 | #define DRM_ERROR_RATELIMITED(fmt, ...) \ |
184 | ({ \ |
184 | ({ \ |
185 | static DEFINE_RATELIMIT_STATE(_rs, \ |
185 | static DEFINE_RATELIMIT_STATE(_rs, \ |
186 | DEFAULT_RATELIMIT_INTERVAL, \ |
186 | DEFAULT_RATELIMIT_INTERVAL, \ |
187 | DEFAULT_RATELIMIT_BURST); \ |
187 | DEFAULT_RATELIMIT_BURST); \ |
188 | \ |
188 | \ |
189 | if (__ratelimit(&_rs)) \ |
189 | if (__ratelimit(&_rs)) \ |
190 | drm_err(fmt, ##__VA_ARGS__); \ |
190 | drm_err(fmt, ##__VA_ARGS__); \ |
191 | }) |
191 | }) |
- | 192 | ||
- | 193 | #if DRM_DEBUG_CODE |
|
192 | 194 | ||
193 | #define DRM_INFO(fmt, ...) \ |
195 | #define DRM_INFO(fmt, ...) \ |
194 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) |
196 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) |
195 | 197 | ||
196 | #define DRM_INFO_ONCE(fmt, ...) \ |
198 | #define DRM_INFO_ONCE(fmt, ...) \ |
197 | printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) |
199 | printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) |
198 | 200 | ||
199 | /** |
201 | /** |
200 | * Debug output. |
202 | * Debug output. |
201 | * |
203 | * |
202 | * \param fmt printf() like format string. |
204 | * \param fmt printf() like format string. |
203 | * \param arg arguments |
205 | * \param arg arguments |
204 | */ |
206 | */ |
205 | #if DRM_DEBUG_CODE |
- | |
206 | #define DRM_DEBUG(fmt, args...) \ |
207 | #define DRM_DEBUG(fmt, args...) \ |
207 | do { \ |
208 | do { \ |
208 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
209 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
209 | } while (0) |
210 | } while (0) |
210 | 211 | ||
211 | #define DRM_DEBUG_DRIVER(fmt, args...) \ |
212 | #define DRM_DEBUG_DRIVER(fmt, args...) \ |
212 | do { \ |
213 | do { \ |
213 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
214 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
214 | } while (0) |
215 | } while (0) |
215 | #define DRM_DEBUG_KMS(fmt, args...) \ |
216 | #define DRM_DEBUG_KMS(fmt, args...) \ |
216 | do { \ |
217 | do { \ |
217 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
218 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
218 | } while (0) |
219 | } while (0) |
219 | #define DRM_DEBUG_PRIME(fmt, args...) \ |
220 | #define DRM_DEBUG_PRIME(fmt, args...) \ |
220 | do { \ |
221 | do { \ |
221 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
222 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
222 | } while (0) |
223 | } while (0) |
223 | #define DRM_DEBUG_ATOMIC(fmt, args...) \ |
224 | #define DRM_DEBUG_ATOMIC(fmt, args...) \ |
224 | do { \ |
225 | do { \ |
225 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
226 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
226 | } while (0) |
227 | } while (0) |
227 | #define DRM_DEBUG_VBL(fmt, args...) \ |
228 | #define DRM_DEBUG_VBL(fmt, args...) \ |
228 | do { \ |
229 | do { \ |
229 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
230 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
230 | } while (0) |
231 | } while (0) |
231 | 232 | ||
232 | #else |
233 | #else |
- | 234 | #define DRM_INFO(fmt, ...) do { } while (0) |
|
233 | #define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0) |
235 | #define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0) |
234 | #define DRM_DEBUG_KMS(fmt, args...) do { } while (0) |
236 | #define DRM_DEBUG_KMS(fmt, args...) do { } while (0) |
235 | #define DRM_DEBUG_PRIME(fmt, args...) do { } while (0) |
237 | #define DRM_DEBUG_PRIME(fmt, args...) do { } while (0) |
236 | #define DRM_DEBUG(fmt, arg...) do { } while (0) |
238 | #define DRM_DEBUG(fmt, arg...) do { } while (0) |
237 | #define DRM_DEBUG_ATOMIC(fmt, args...) do { } while (0) |
239 | #define DRM_DEBUG_ATOMIC(fmt, args...) do { } while (0) |
238 | #define DRM_DEBUG_VBL(fmt, args...) do { } while (0) |
240 | #define DRM_DEBUG_VBL(fmt, args...) do { } while (0) |
239 | #endif |
241 | #endif |
240 | /*@}*/ |
242 | /*@}*/ |
241 | 243 | ||
242 | /***********************************************************************/ |
244 | /***********************************************************************/ |
243 | /** \name Internal types and structures */ |
245 | /** \name Internal types and structures */ |
244 | /*@{*/ |
246 | /*@{*/ |
245 | 247 | ||
246 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
248 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
247 | 249 | ||
248 | /** |
250 | /** |
249 | * Ioctl function type. |
251 | * Ioctl function type. |
250 | * |
252 | * |
251 | * \param inode device inode. |
253 | * \param inode device inode. |
252 | * \param file_priv DRM file private pointer. |
254 | * \param file_priv DRM file private pointer. |
253 | * \param cmd command. |
255 | * \param cmd command. |
254 | * \param arg argument. |
256 | * \param arg argument. |
255 | */ |
257 | */ |
256 | typedef int drm_ioctl_t(struct drm_device *dev, void *data, |
258 | typedef int drm_ioctl_t(struct drm_device *dev, void *data, |
257 | struct drm_file *file_priv); |
259 | struct drm_file *file_priv); |
258 | 260 | ||
259 | typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, |
261 | typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, |
260 | unsigned long arg); |
262 | unsigned long arg); |
261 | 263 | ||
262 | #define DRM_IOCTL_NR(n) _IOC_NR(n) |
264 | #define DRM_IOCTL_NR(n) _IOC_NR(n) |
263 | #define DRM_MAJOR 226 |
265 | #define DRM_MAJOR 226 |
264 | 266 | ||
265 | #define DRM_AUTH 0x1 |
267 | #define DRM_AUTH 0x1 |
266 | #define DRM_MASTER 0x2 |
268 | #define DRM_MASTER 0x2 |
267 | #define DRM_ROOT_ONLY 0x4 |
269 | #define DRM_ROOT_ONLY 0x4 |
268 | #define DRM_CONTROL_ALLOW 0x8 |
270 | #define DRM_CONTROL_ALLOW 0x8 |
269 | #define DRM_UNLOCKED 0x10 |
271 | #define DRM_UNLOCKED 0x10 |
270 | #define DRM_RENDER_ALLOW 0x20 |
272 | #define DRM_RENDER_ALLOW 0x20 |
271 | 273 | ||
272 | struct drm_ioctl_desc { |
274 | struct drm_ioctl_desc { |
273 | unsigned int cmd; |
275 | unsigned int cmd; |
274 | int flags; |
276 | int flags; |
275 | drm_ioctl_t *func; |
277 | drm_ioctl_t *func; |
276 | const char *name; |
278 | const char *name; |
277 | }; |
279 | }; |
278 | 280 | ||
279 | /** |
281 | /** |
280 | * Creates a driver or general drm_ioctl_desc array entry for the given |
282 | * Creates a driver or general drm_ioctl_desc array entry for the given |
281 | * ioctl, for use by drm_ioctl(). |
283 | * ioctl, for use by drm_ioctl(). |
282 | */ |
284 | */ |
283 | 285 | ||
284 | #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ |
286 | #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ |
285 | [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \ |
287 | [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \ |
286 | .cmd = DRM_IOCTL_##ioctl, \ |
288 | .cmd = DRM_IOCTL_##ioctl, \ |
287 | .func = _func, \ |
289 | .func = _func, \ |
288 | .flags = _flags, \ |
290 | .flags = _flags, \ |
289 | .name = #ioctl \ |
291 | .name = #ioctl \ |
290 | } |
292 | } |
291 | 293 | ||
292 | /* Event queued up for userspace to read */ |
294 | /* Event queued up for userspace to read */ |
293 | struct drm_pending_event { |
295 | struct drm_pending_event { |
294 | struct drm_event *event; |
296 | struct drm_event *event; |
295 | struct list_head link; |
297 | struct list_head link; |
- | 298 | struct list_head pending_link; |
|
296 | struct drm_file *file_priv; |
299 | struct drm_file *file_priv; |
297 | pid_t pid; /* pid of requester, no guarantee it's valid by the time |
300 | pid_t pid; /* pid of requester, no guarantee it's valid by the time |
298 | we deliver the event, for tracing only */ |
301 | we deliver the event, for tracing only */ |
299 | void (*destroy)(struct drm_pending_event *event); |
302 | void (*destroy)(struct drm_pending_event *event); |
300 | }; |
303 | }; |
301 | 304 | ||
302 | /* initial implementaton using a linked list - todo hashtab */ |
305 | /* initial implementaton using a linked list - todo hashtab */ |
303 | struct drm_prime_file_private { |
306 | struct drm_prime_file_private { |
304 | struct list_head head; |
307 | struct list_head head; |
305 | struct mutex lock; |
308 | struct mutex lock; |
306 | }; |
309 | }; |
307 | 310 | ||
308 | /** File private data */ |
311 | /** File private data */ |
309 | struct drm_file { |
312 | struct drm_file { |
310 | unsigned authenticated :1; |
313 | unsigned authenticated :1; |
311 | /* Whether we're master for a minor. Protected by master_mutex */ |
314 | /* Whether we're master for a minor. Protected by master_mutex */ |
312 | unsigned is_master :1; |
315 | unsigned is_master :1; |
313 | /* true when the client has asked us to expose stereo 3D mode flags */ |
316 | /* true when the client has asked us to expose stereo 3D mode flags */ |
314 | unsigned stereo_allowed :1; |
317 | unsigned stereo_allowed :1; |
315 | /* |
318 | /* |
316 | * true if client understands CRTC primary planes and cursor planes |
319 | * true if client understands CRTC primary planes and cursor planes |
317 | * in the plane list |
320 | * in the plane list |
318 | */ |
321 | */ |
319 | unsigned universal_planes:1; |
322 | unsigned universal_planes:1; |
320 | /* true if client understands atomic properties */ |
323 | /* true if client understands atomic properties */ |
321 | unsigned atomic:1; |
324 | unsigned atomic:1; |
322 | /* |
325 | /* |
323 | * This client is allowed to gain master privileges for @master. |
326 | * This client is allowed to gain master privileges for @master. |
324 | * Protected by struct drm_device::master_mutex. |
327 | * Protected by struct drm_device::master_mutex. |
325 | */ |
328 | */ |
326 | unsigned allowed_master:1; |
329 | unsigned allowed_master:1; |
327 | struct list_head lhead; |
330 | struct list_head lhead; |
328 | struct drm_minor *minor; |
331 | struct drm_minor *minor; |
329 | unsigned long lock_count; |
332 | unsigned long lock_count; |
330 | 333 | ||
331 | /** Mapping of mm object handles to object pointers. */ |
334 | /** Mapping of mm object handles to object pointers. */ |
332 | struct idr object_idr; |
335 | struct idr object_idr; |
333 | /** Lock for synchronization of access to object_idr. */ |
336 | /** Lock for synchronization of access to object_idr. */ |
334 | spinlock_t table_lock; |
337 | spinlock_t table_lock; |
335 | 338 | ||
336 | void *driver_priv; |
339 | void *driver_priv; |
337 | 340 | ||
338 | struct drm_master *master; /* master this node is currently associated with |
341 | struct drm_master *master; /* master this node is currently associated with |
339 | N.B. not always minor->master */ |
342 | N.B. not always minor->master */ |
340 | /** |
343 | /** |
341 | * fbs - List of framebuffers associated with this file. |
344 | * fbs - List of framebuffers associated with this file. |
342 | * |
345 | * |
343 | * Protected by fbs_lock. Note that the fbs list holds a reference on |
346 | * Protected by fbs_lock. Note that the fbs list holds a reference on |
344 | * the fb object to prevent it from untimely disappearing. |
347 | * the fb object to prevent it from untimely disappearing. |
345 | */ |
348 | */ |
346 | struct list_head fbs; |
349 | struct list_head fbs; |
347 | struct mutex fbs_lock; |
350 | struct mutex fbs_lock; |
348 | 351 | ||
349 | /** User-created blob properties; this retains a reference on the |
352 | /** User-created blob properties; this retains a reference on the |
350 | * property. */ |
353 | * property. */ |
351 | struct list_head blobs; |
354 | struct list_head blobs; |
352 | 355 | ||
353 | wait_queue_head_t event_wait; |
356 | wait_queue_head_t event_wait; |
- | 357 | struct list_head pending_event_list; |
|
354 | struct list_head event_list; |
358 | struct list_head event_list; |
355 | int event_space; |
359 | int event_space; |
- | 360 | ||
- | 361 | struct mutex event_read_lock; |
|
356 | }; |
362 | }; |
357 | 363 | ||
358 | /** |
364 | /** |
359 | * Lock data. |
365 | * Lock data. |
360 | */ |
366 | */ |
361 | struct drm_lock_data { |
367 | struct drm_lock_data { |
362 | struct drm_hw_lock *hw_lock; /**< Hardware lock */ |
368 | struct drm_hw_lock *hw_lock; /**< Hardware lock */ |
363 | /** Private of lock holder's file (NULL=kernel) */ |
369 | /** Private of lock holder's file (NULL=kernel) */ |
364 | struct drm_file *file_priv; |
370 | struct drm_file *file_priv; |
365 | wait_queue_head_t lock_queue; /**< Queue of blocked processes */ |
371 | wait_queue_head_t lock_queue; /**< Queue of blocked processes */ |
366 | unsigned long lock_time; /**< Time of last lock in jiffies */ |
372 | unsigned long lock_time; /**< Time of last lock in jiffies */ |
367 | spinlock_t spinlock; |
373 | spinlock_t spinlock; |
368 | uint32_t kernel_waiters; |
374 | uint32_t kernel_waiters; |
369 | uint32_t user_waiters; |
375 | uint32_t user_waiters; |
370 | int idle_has_lock; |
376 | int idle_has_lock; |
371 | }; |
377 | }; |
372 | 378 | ||
373 | /** |
379 | /** |
374 | * struct drm_master - drm master structure |
380 | * struct drm_master - drm master structure |
375 | * |
381 | * |
376 | * @refcount: Refcount for this master object. |
382 | * @refcount: Refcount for this master object. |
377 | * @minor: Link back to minor char device we are master for. Immutable. |
383 | * @minor: Link back to minor char device we are master for. Immutable. |
378 | * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex. |
384 | * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex. |
379 | * @unique_len: Length of unique field. Protected by drm_global_mutex. |
385 | * @unique_len: Length of unique field. Protected by drm_global_mutex. |
380 | * @magic_map: Map of used authentication tokens. Protected by struct_mutex. |
386 | * @magic_map: Map of used authentication tokens. Protected by struct_mutex. |
381 | * @lock: DRI lock information. |
387 | * @lock: DRI lock information. |
382 | * @driver_priv: Pointer to driver-private information. |
388 | * @driver_priv: Pointer to driver-private information. |
383 | */ |
389 | */ |
384 | struct drm_master { |
390 | struct drm_master { |
385 | struct kref refcount; |
391 | struct kref refcount; |
386 | struct drm_minor *minor; |
392 | struct drm_minor *minor; |
387 | char *unique; |
393 | char *unique; |
388 | int unique_len; |
394 | int unique_len; |
389 | struct idr magic_map; |
395 | struct idr magic_map; |
390 | struct drm_lock_data lock; |
396 | struct drm_lock_data lock; |
391 | void *driver_priv; |
397 | void *driver_priv; |
392 | }; |
398 | }; |
393 | 399 | ||
394 | /* Size of ringbuffer for vblank timestamps. Just double-buffer |
400 | /* Size of ringbuffer for vblank timestamps. Just double-buffer |
395 | * in initial implementation. |
401 | * in initial implementation. |
396 | */ |
402 | */ |
397 | #define DRM_VBLANKTIME_RBSIZE 2 |
403 | #define DRM_VBLANKTIME_RBSIZE 2 |
398 | 404 | ||
399 | /* Flags and return codes for get_vblank_timestamp() driver function. */ |
405 | /* Flags and return codes for get_vblank_timestamp() driver function. */ |
400 | #define DRM_CALLED_FROM_VBLIRQ 1 |
406 | #define DRM_CALLED_FROM_VBLIRQ 1 |
401 | #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) |
407 | #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) |
402 | #define DRM_VBLANKTIME_IN_VBLANK (1 << 1) |
408 | #define DRM_VBLANKTIME_IN_VBLANK (1 << 1) |
403 | 409 | ||
404 | /* get_scanout_position() return flags */ |
410 | /* get_scanout_position() return flags */ |
405 | #define DRM_SCANOUTPOS_VALID (1 << 0) |
411 | #define DRM_SCANOUTPOS_VALID (1 << 0) |
406 | #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1) |
412 | #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1) |
407 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
413 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
408 | 414 | ||
409 | /** |
415 | /** |
410 | * DRM driver structure. This structure represent the common code for |
416 | * DRM driver structure. This structure represent the common code for |
411 | * a family of cards. There will one drm_device for each card present |
417 | * a family of cards. There will one drm_device for each card present |
412 | * in this family |
418 | * in this family |
413 | */ |
419 | */ |
414 | struct drm_driver { |
420 | struct drm_driver { |
415 | int (*load) (struct drm_device *, unsigned long flags); |
421 | int (*load) (struct drm_device *, unsigned long flags); |
416 | int (*open) (struct drm_device *, struct drm_file *); |
422 | int (*open) (struct drm_device *, struct drm_file *); |
417 | 423 | ||
418 | /** |
424 | /** |
419 | * get_vblank_counter - get raw hardware vblank counter |
425 | * get_vblank_counter - get raw hardware vblank counter |
420 | * @dev: DRM device |
426 | * @dev: DRM device |
421 | * @pipe: counter to fetch |
427 | * @pipe: counter to fetch |
422 | * |
428 | * |
423 | * Driver callback for fetching a raw hardware vblank counter for @crtc. |
429 | * Driver callback for fetching a raw hardware vblank counter for @crtc. |
424 | * If a device doesn't have a hardware counter, the driver can simply |
430 | * If a device doesn't have a hardware counter, the driver can simply |
425 | * return the value of drm_vblank_count. The DRM core will account for |
431 | * return the value of drm_vblank_count. The DRM core will account for |
426 | * missed vblank events while interrupts where disabled based on system |
432 | * missed vblank events while interrupts where disabled based on system |
427 | * timestamps. |
433 | * timestamps. |
428 | * |
434 | * |
429 | * Wraparound handling and loss of events due to modesetting is dealt |
435 | * Wraparound handling and loss of events due to modesetting is dealt |
430 | * with in the DRM core code. |
436 | * with in the DRM core code. |
431 | * |
437 | * |
432 | * RETURNS |
438 | * RETURNS |
433 | * Raw vblank counter value. |
439 | * Raw vblank counter value. |
434 | */ |
440 | */ |
435 | u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe); |
441 | u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe); |
436 | 442 | ||
437 | /** |
443 | /** |
438 | * enable_vblank - enable vblank interrupt events |
444 | * enable_vblank - enable vblank interrupt events |
439 | * @dev: DRM device |
445 | * @dev: DRM device |
440 | * @pipe: which irq to enable |
446 | * @pipe: which irq to enable |
441 | * |
447 | * |
442 | * Enable vblank interrupts for @crtc. If the device doesn't have |
448 | * Enable vblank interrupts for @crtc. If the device doesn't have |
443 | * a hardware vblank counter, this routine should be a no-op, since |
449 | * a hardware vblank counter, this routine should be a no-op, since |
444 | * interrupts will have to stay on to keep the count accurate. |
450 | * interrupts will have to stay on to keep the count accurate. |
445 | * |
451 | * |
446 | * RETURNS |
452 | * RETURNS |
447 | * Zero on success, appropriate errno if the given @crtc's vblank |
453 | * Zero on success, appropriate errno if the given @crtc's vblank |
448 | * interrupt cannot be enabled. |
454 | * interrupt cannot be enabled. |
449 | */ |
455 | */ |
450 | int (*enable_vblank) (struct drm_device *dev, unsigned int pipe); |
456 | int (*enable_vblank) (struct drm_device *dev, unsigned int pipe); |
451 | 457 | ||
452 | /** |
458 | /** |
453 | * disable_vblank - disable vblank interrupt events |
459 | * disable_vblank - disable vblank interrupt events |
454 | * @dev: DRM device |
460 | * @dev: DRM device |
455 | * @pipe: which irq to enable |
461 | * @pipe: which irq to enable |
456 | * |
462 | * |
457 | * Disable vblank interrupts for @crtc. If the device doesn't have |
463 | * Disable vblank interrupts for @crtc. If the device doesn't have |
458 | * a hardware vblank counter, this routine should be a no-op, since |
464 | * a hardware vblank counter, this routine should be a no-op, since |
459 | * interrupts will have to stay on to keep the count accurate. |
465 | * interrupts will have to stay on to keep the count accurate. |
460 | */ |
466 | */ |
461 | void (*disable_vblank) (struct drm_device *dev, unsigned int pipe); |
467 | void (*disable_vblank) (struct drm_device *dev, unsigned int pipe); |
462 | 468 | ||
463 | /** |
469 | /** |
464 | * Called by \c drm_device_is_agp. Typically used to determine if a |
470 | * Called by \c drm_device_is_agp. Typically used to determine if a |
465 | * card is really attached to AGP or not. |
471 | * card is really attached to AGP or not. |
466 | * |
472 | * |
467 | * \param dev DRM device handle |
473 | * \param dev DRM device handle |
468 | * |
474 | * |
469 | * \returns |
475 | * \returns |
470 | * One of three values is returned depending on whether or not the |
476 | * One of three values is returned depending on whether or not the |
471 | * card is absolutely \b not AGP (return of 0), absolutely \b is AGP |
477 | * card is absolutely \b not AGP (return of 0), absolutely \b is AGP |
472 | * (return of 1), or may or may not be AGP (return of 2). |
478 | * (return of 1), or may or may not be AGP (return of 2). |
473 | */ |
479 | */ |
474 | int (*device_is_agp) (struct drm_device *dev); |
480 | int (*device_is_agp) (struct drm_device *dev); |
475 | 481 | ||
476 | /** |
482 | /** |
477 | * Called by vblank timestamping code. |
483 | * Called by vblank timestamping code. |
478 | * |
484 | * |
479 | * Return the current display scanout position from a crtc, and an |
485 | * Return the current display scanout position from a crtc, and an |
480 | * optional accurate ktime_get timestamp of when position was measured. |
486 | * optional accurate ktime_get timestamp of when position was measured. |
481 | * |
487 | * |
482 | * \param dev DRM device. |
488 | * \param dev DRM device. |
483 | * \param pipe Id of the crtc to query. |
489 | * \param pipe Id of the crtc to query. |
484 | * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0). |
490 | * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0). |
485 | * \param *vpos Target location for current vertical scanout position. |
491 | * \param *vpos Target location for current vertical scanout position. |
486 | * \param *hpos Target location for current horizontal scanout position. |
492 | * \param *hpos Target location for current horizontal scanout position. |
487 | * \param *stime Target location for timestamp taken immediately before |
493 | * \param *stime Target location for timestamp taken immediately before |
488 | * scanout position query. Can be NULL to skip timestamp. |
494 | * scanout position query. Can be NULL to skip timestamp. |
489 | * \param *etime Target location for timestamp taken immediately after |
495 | * \param *etime Target location for timestamp taken immediately after |
490 | * scanout position query. Can be NULL to skip timestamp. |
496 | * scanout position query. Can be NULL to skip timestamp. |
491 | * \param mode Current display timings. |
497 | * \param mode Current display timings. |
492 | * |
498 | * |
493 | * Returns vpos as a positive number while in active scanout area. |
499 | * Returns vpos as a positive number while in active scanout area. |
494 | * Returns vpos as a negative number inside vblank, counting the number |
500 | * Returns vpos as a negative number inside vblank, counting the number |
495 | * of scanlines to go until end of vblank, e.g., -1 means "one scanline |
501 | * of scanlines to go until end of vblank, e.g., -1 means "one scanline |
496 | * until start of active scanout / end of vblank." |
502 | * until start of active scanout / end of vblank." |
497 | * |
503 | * |
498 | * \return Flags, or'ed together as follows: |
504 | * \return Flags, or'ed together as follows: |
499 | * |
505 | * |
500 | * DRM_SCANOUTPOS_VALID = Query successful. |
506 | * DRM_SCANOUTPOS_VALID = Query successful. |
501 | * DRM_SCANOUTPOS_INVBL = Inside vblank. |
507 | * DRM_SCANOUTPOS_INVBL = Inside vblank. |
502 | * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of |
508 | * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of |
503 | * this flag means that returned position may be offset by a constant |
509 | * this flag means that returned position may be offset by a constant |
504 | * but unknown small number of scanlines wrt. real scanout position. |
510 | * but unknown small number of scanlines wrt. real scanout position. |
505 | * |
511 | * |
506 | */ |
512 | */ |
507 | int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe, |
513 | int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe, |
508 | unsigned int flags, int *vpos, int *hpos, |
514 | unsigned int flags, int *vpos, int *hpos, |
509 | ktime_t *stime, ktime_t *etime, |
515 | ktime_t *stime, ktime_t *etime, |
510 | const struct drm_display_mode *mode); |
516 | const struct drm_display_mode *mode); |
511 | 517 | ||
512 | /** |
518 | /** |
513 | * Called by \c drm_get_last_vbltimestamp. Should return a precise |
519 | * Called by \c drm_get_last_vbltimestamp. Should return a precise |
514 | * timestamp when the most recent VBLANK interval ended or will end. |
520 | * timestamp when the most recent VBLANK interval ended or will end. |
515 | * |
521 | * |
516 | * Specifically, the timestamp in @vblank_time should correspond as |
522 | * Specifically, the timestamp in @vblank_time should correspond as |
517 | * closely as possible to the time when the first video scanline of |
523 | * closely as possible to the time when the first video scanline of |
518 | * the video frame after the end of VBLANK will start scanning out, |
524 | * the video frame after the end of VBLANK will start scanning out, |
519 | * the time immediately after end of the VBLANK interval. If the |
525 | * the time immediately after end of the VBLANK interval. If the |
520 | * @crtc is currently inside VBLANK, this will be a time in the future. |
526 | * @crtc is currently inside VBLANK, this will be a time in the future. |
521 | * If the @crtc is currently scanning out a frame, this will be the |
527 | * If the @crtc is currently scanning out a frame, this will be the |
522 | * past start time of the current scanout. This is meant to adhere |
528 | * past start time of the current scanout. This is meant to adhere |
523 | * to the OpenML OML_sync_control extension specification. |
529 | * to the OpenML OML_sync_control extension specification. |
524 | * |
530 | * |
525 | * \param dev dev DRM device handle. |
531 | * \param dev dev DRM device handle. |
526 | * \param pipe crtc for which timestamp should be returned. |
532 | * \param pipe crtc for which timestamp should be returned. |
527 | * \param *max_error Maximum allowable timestamp error in nanoseconds. |
533 | * \param *max_error Maximum allowable timestamp error in nanoseconds. |
528 | * Implementation should strive to provide timestamp |
534 | * Implementation should strive to provide timestamp |
529 | * with an error of at most *max_error nanoseconds. |
535 | * with an error of at most *max_error nanoseconds. |
530 | * Returns true upper bound on error for timestamp. |
536 | * Returns true upper bound on error for timestamp. |
531 | * \param *vblank_time Target location for returned vblank timestamp. |
537 | * \param *vblank_time Target location for returned vblank timestamp. |
532 | * \param flags 0 = Defaults, no special treatment needed. |
538 | * \param flags 0 = Defaults, no special treatment needed. |
533 | * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank |
539 | * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank |
534 | * irq handler. Some drivers need to apply some workarounds |
540 | * irq handler. Some drivers need to apply some workarounds |
535 | * for gpu-specific vblank irq quirks if flag is set. |
541 | * for gpu-specific vblank irq quirks if flag is set. |
536 | * |
542 | * |
537 | * \returns |
543 | * \returns |
538 | * Zero if timestamping isn't supported in current display mode or a |
544 | * Zero if timestamping isn't supported in current display mode or a |
539 | * negative number on failure. A positive status code on success, |
545 | * negative number on failure. A positive status code on success, |
540 | * which describes how the vblank_time timestamp was computed. |
546 | * which describes how the vblank_time timestamp was computed. |
541 | */ |
547 | */ |
542 | int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe, |
548 | int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe, |
543 | int *max_error, |
549 | int *max_error, |
544 | struct timeval *vblank_time, |
550 | struct timeval *vblank_time, |
545 | unsigned flags); |
551 | unsigned flags); |
546 | 552 | ||
547 | /* these have to be filled in */ |
553 | /* these have to be filled in */ |
548 | 554 | ||
549 | irqreturn_t(*irq_handler) (int irq, void *arg); |
555 | irqreturn_t(*irq_handler) (int irq, void *arg); |
550 | void (*irq_preinstall) (struct drm_device *dev); |
556 | void (*irq_preinstall) (struct drm_device *dev); |
551 | int (*irq_postinstall) (struct drm_device *dev); |
557 | int (*irq_postinstall) (struct drm_device *dev); |
552 | void (*irq_uninstall) (struct drm_device *dev); |
558 | void (*irq_uninstall) (struct drm_device *dev); |
553 | 559 | ||
554 | /** |
560 | /** |
555 | * Driver-specific constructor for drm_gem_objects, to set up |
561 | * Driver-specific constructor for drm_gem_objects, to set up |
556 | * obj->driver_private. |
562 | * obj->driver_private. |
557 | * |
563 | * |
558 | * Returns 0 on success. |
564 | * Returns 0 on success. |
559 | */ |
565 | */ |
560 | void (*gem_free_object) (struct drm_gem_object *obj); |
566 | void (*gem_free_object) (struct drm_gem_object *obj); |
561 | int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); |
567 | int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); |
562 | void (*gem_close_object) (struct drm_gem_object *, struct drm_file *); |
568 | void (*gem_close_object) (struct drm_gem_object *, struct drm_file *); |
563 | u32 driver_features; |
569 | u32 driver_features; |
564 | int dev_priv_size; |
570 | int dev_priv_size; |
565 | }; |
571 | }; |
566 | 572 | ||
567 | enum drm_minor_type { |
573 | enum drm_minor_type { |
568 | DRM_MINOR_LEGACY, |
574 | DRM_MINOR_LEGACY, |
569 | DRM_MINOR_CONTROL, |
575 | DRM_MINOR_CONTROL, |
570 | DRM_MINOR_RENDER, |
576 | DRM_MINOR_RENDER, |
571 | DRM_MINOR_CNT, |
577 | DRM_MINOR_CNT, |
572 | }; |
578 | }; |
573 | 579 | ||
574 | /** |
580 | /** |
575 | * Info file list entry. This structure represents a debugfs or proc file to |
581 | * Info file list entry. This structure represents a debugfs or proc file to |
576 | * be created by the drm core |
582 | * be created by the drm core |
577 | */ |
583 | */ |
578 | struct drm_info_list { |
584 | struct drm_info_list { |
579 | const char *name; /** file name */ |
585 | const char *name; /** file name */ |
580 | // int (*show)(struct seq_file*, void*); /** show callback */ |
586 | // int (*show)(struct seq_file*, void*); /** show callback */ |
581 | u32 driver_features; /**< Required driver features for this entry */ |
587 | u32 driver_features; /**< Required driver features for this entry */ |
582 | void *data; |
588 | void *data; |
583 | }; |
589 | }; |
584 | 590 | ||
585 | /** |
591 | /** |
586 | * debugfs node structure. This structure represents a debugfs file. |
592 | * debugfs node structure. This structure represents a debugfs file. |
587 | */ |
593 | */ |
588 | struct drm_info_node { |
594 | struct drm_info_node { |
589 | struct list_head list; |
595 | struct list_head list; |
590 | struct drm_minor *minor; |
596 | struct drm_minor *minor; |
591 | const struct drm_info_list *info_ent; |
597 | const struct drm_info_list *info_ent; |
592 | struct dentry *dent; |
598 | struct dentry *dent; |
593 | }; |
599 | }; |
594 | 600 | ||
595 | /** |
601 | /** |
596 | * DRM minor structure. This structure represents a drm minor number. |
602 | * DRM minor structure. This structure represents a drm minor number. |
597 | */ |
603 | */ |
598 | struct drm_minor { |
604 | struct drm_minor { |
599 | int index; /**< Minor device number */ |
605 | int index; /**< Minor device number */ |
600 | int type; /**< Control or render */ |
606 | int type; /**< Control or render */ |
601 | struct device *kdev; /**< Linux device */ |
607 | struct device *kdev; /**< Linux device */ |
602 | struct drm_device *dev; |
608 | struct drm_device *dev; |
603 | 609 | ||
604 | struct dentry *debugfs_root; |
610 | struct dentry *debugfs_root; |
605 | 611 | ||
606 | struct list_head debugfs_list; |
612 | struct list_head debugfs_list; |
607 | struct mutex debugfs_lock; /* Protects debugfs_list. */ |
613 | struct mutex debugfs_lock; /* Protects debugfs_list. */ |
608 | 614 | ||
609 | /* currently active master for this node. Protected by master_mutex */ |
615 | /* currently active master for this node. Protected by master_mutex */ |
610 | struct drm_master *master; |
616 | struct drm_master *master; |
611 | }; |
617 | }; |
612 | 618 | ||
613 | 619 | ||
614 | struct drm_pending_vblank_event { |
620 | struct drm_pending_vblank_event { |
615 | struct drm_pending_event base; |
621 | struct drm_pending_event base; |
616 | unsigned int pipe; |
622 | unsigned int pipe; |
617 | struct drm_event_vblank event; |
623 | struct drm_event_vblank event; |
618 | }; |
624 | }; |
619 | 625 | ||
620 | struct drm_vblank_crtc { |
626 | struct drm_vblank_crtc { |
621 | struct drm_device *dev; /* pointer to the drm_device */ |
627 | struct drm_device *dev; /* pointer to the drm_device */ |
622 | wait_queue_head_t queue; /**< VBLANK wait queue */ |
628 | wait_queue_head_t queue; /**< VBLANK wait queue */ |
623 | struct timer_list disable_timer; /* delayed disable timer */ |
629 | struct timer_list disable_timer; /* delayed disable timer */ |
624 | 630 | ||
625 | /* vblank counter, protected by dev->vblank_time_lock for writes */ |
631 | /* vblank counter, protected by dev->vblank_time_lock for writes */ |
626 | u32 count; |
632 | u32 count; |
627 | /* vblank timestamps, protected by dev->vblank_time_lock for writes */ |
633 | /* vblank timestamps, protected by dev->vblank_time_lock for writes */ |
628 | struct timeval time[DRM_VBLANKTIME_RBSIZE]; |
634 | struct timeval time[DRM_VBLANKTIME_RBSIZE]; |
629 | 635 | ||
630 | atomic_t refcount; /* number of users of vblank interruptsper crtc */ |
636 | atomic_t refcount; /* number of users of vblank interruptsper crtc */ |
631 | u32 last; /* protected by dev->vbl_lock, used */ |
637 | u32 last; /* protected by dev->vbl_lock, used */ |
632 | /* for wraparound handling */ |
638 | /* for wraparound handling */ |
633 | u32 last_wait; /* Last vblank seqno waited per CRTC */ |
639 | u32 last_wait; /* Last vblank seqno waited per CRTC */ |
634 | unsigned int inmodeset; /* Display driver is setting mode */ |
640 | unsigned int inmodeset; /* Display driver is setting mode */ |
635 | unsigned int pipe; /* crtc index */ |
641 | unsigned int pipe; /* crtc index */ |
636 | int framedur_ns; /* frame/field duration in ns */ |
642 | int framedur_ns; /* frame/field duration in ns */ |
637 | int linedur_ns; /* line duration in ns */ |
643 | int linedur_ns; /* line duration in ns */ |
638 | bool enabled; /* so we don't call enable more than |
644 | bool enabled; /* so we don't call enable more than |
639 | once per disable */ |
645 | once per disable */ |
640 | }; |
646 | }; |
641 | 647 | ||
642 | /** |
648 | /** |
643 | * DRM device structure. This structure represent a complete card that |
649 | * DRM device structure. This structure represent a complete card that |
644 | * may contain multiple heads. |
650 | * may contain multiple heads. |
645 | */ |
651 | */ |
646 | struct drm_device { |
652 | struct drm_device { |
647 | struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ |
653 | struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ |
648 | int if_version; /**< Highest interface version set */ |
654 | int if_version; /**< Highest interface version set */ |
649 | 655 | ||
650 | /** \name Lifetime Management */ |
656 | /** \name Lifetime Management */ |
651 | /*@{ */ |
657 | /*@{ */ |
652 | struct kref ref; /**< Object ref-count */ |
658 | struct kref ref; /**< Object ref-count */ |
653 | struct device *dev; /**< Device structure of bus-device */ |
659 | struct device *dev; /**< Device structure of bus-device */ |
654 | struct drm_driver *driver; /**< DRM driver managing the device */ |
660 | struct drm_driver *driver; /**< DRM driver managing the device */ |
655 | void *dev_private; /**< DRM driver private data */ |
661 | void *dev_private; /**< DRM driver private data */ |
656 | struct drm_minor *control; /**< Control node */ |
662 | struct drm_minor *control; /**< Control node */ |
657 | struct drm_minor *primary; /**< Primary node */ |
663 | struct drm_minor *primary; /**< Primary node */ |
658 | struct drm_minor *render; /**< Render node */ |
664 | struct drm_minor *render; /**< Render node */ |
659 | atomic_t unplugged; /**< Flag whether dev is dead */ |
665 | atomic_t unplugged; /**< Flag whether dev is dead */ |
660 | /** \name Locks */ |
666 | /** \name Locks */ |
661 | /*@{ */ |
667 | /*@{ */ |
662 | struct mutex struct_mutex; /**< For others */ |
668 | struct mutex struct_mutex; /**< For others */ |
663 | struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */ |
669 | struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */ |
664 | /*@} */ |
670 | /*@} */ |
665 | 671 | ||
666 | /** \name Usage Counters */ |
672 | /** \name Usage Counters */ |
667 | /*@{ */ |
673 | /*@{ */ |
668 | int open_count; /**< Outstanding files open, protected by drm_global_mutex. */ |
674 | int open_count; /**< Outstanding files open, protected by drm_global_mutex. */ |
669 | spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */ |
675 | spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */ |
670 | int buf_use; /**< Buffers in use -- cannot alloc */ |
676 | int buf_use; /**< Buffers in use -- cannot alloc */ |
671 | atomic_t buf_alloc; /**< Buffer allocation in progress */ |
677 | atomic_t buf_alloc; /**< Buffer allocation in progress */ |
672 | /*@} */ |
678 | /*@} */ |
673 | 679 | ||
674 | struct list_head filelist; |
680 | struct list_head filelist; |
675 | 681 | ||
676 | /** \name Memory management */ |
682 | /** \name Memory management */ |
677 | /*@{ */ |
683 | /*@{ */ |
678 | struct list_head maplist; /**< Linked list of regions */ |
684 | struct list_head maplist; /**< Linked list of regions */ |
679 | 685 | ||
680 | /** \name Context handle management */ |
686 | /** \name Context handle management */ |
681 | /*@{ */ |
687 | /*@{ */ |
682 | struct list_head ctxlist; /**< Linked list of context handles */ |
688 | struct list_head ctxlist; /**< Linked list of context handles */ |
683 | struct mutex ctxlist_mutex; /**< For ctxlist */ |
689 | struct mutex ctxlist_mutex; /**< For ctxlist */ |
684 | 690 | ||
685 | struct idr ctx_idr; |
691 | struct idr ctx_idr; |
686 | 692 | ||
687 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
693 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
688 | 694 | ||
689 | /*@} */ |
695 | /*@} */ |
690 | 696 | ||
691 | /** \name DMA support */ |
697 | /** \name DMA support */ |
692 | /*@{ */ |
698 | /*@{ */ |
693 | // struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
699 | // struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
694 | /*@} */ |
700 | /*@} */ |
695 | 701 | ||
696 | /** \name Context support */ |
702 | /** \name Context support */ |
697 | /*@{ */ |
703 | /*@{ */ |
698 | 704 | ||
699 | __volatile__ long context_flag; /**< Context swapping flag */ |
705 | __volatile__ long context_flag; /**< Context swapping flag */ |
700 | int last_context; /**< Last current context */ |
706 | int last_context; /**< Last current context */ |
701 | /*@} */ |
707 | /*@} */ |
702 | 708 | ||
703 | /** \name VBLANK IRQ support */ |
709 | /** \name VBLANK IRQ support */ |
704 | /*@{ */ |
710 | /*@{ */ |
705 | bool irq_enabled; |
711 | bool irq_enabled; |
706 | int irq; |
712 | int irq; |
707 | 713 | ||
708 | /* |
714 | /* |
709 | * At load time, disabling the vblank interrupt won't be allowed since |
715 | * At load time, disabling the vblank interrupt won't be allowed since |
710 | * old clients may not call the modeset ioctl and therefore misbehave. |
716 | * old clients may not call the modeset ioctl and therefore misbehave. |
711 | * Once the modeset ioctl *has* been called though, we can safely |
717 | * Once the modeset ioctl *has* been called though, we can safely |
712 | * disable them when unused. |
718 | * disable them when unused. |
713 | */ |
719 | */ |
714 | bool vblank_disable_allowed; |
720 | bool vblank_disable_allowed; |
715 | 721 | ||
716 | /* |
722 | /* |
717 | * If true, vblank interrupt will be disabled immediately when the |
723 | * If true, vblank interrupt will be disabled immediately when the |
718 | * refcount drops to zero, as opposed to via the vblank disable |
724 | * refcount drops to zero, as opposed to via the vblank disable |
719 | * timer. |
725 | * timer. |
720 | * This can be set to true it the hardware has a working vblank |
726 | * This can be set to true it the hardware has a working vblank |
721 | * counter and the driver uses drm_vblank_on() and drm_vblank_off() |
727 | * counter and the driver uses drm_vblank_on() and drm_vblank_off() |
722 | * appropriately. |
728 | * appropriately. |
723 | */ |
729 | */ |
724 | bool vblank_disable_immediate; |
730 | bool vblank_disable_immediate; |
725 | 731 | ||
726 | /* array of size num_crtcs */ |
732 | /* array of size num_crtcs */ |
727 | struct drm_vblank_crtc *vblank; |
733 | struct drm_vblank_crtc *vblank; |
728 | 734 | ||
729 | spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ |
735 | spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ |
730 | spinlock_t vbl_lock; |
736 | spinlock_t vbl_lock; |
731 | 737 | ||
732 | u32 max_vblank_count; /**< size of vblank counter register */ |
738 | u32 max_vblank_count; /**< size of vblank counter register */ |
733 | 739 | ||
734 | /** |
740 | /** |
735 | * List of events |
741 | * List of events |
736 | */ |
742 | */ |
737 | struct list_head vblank_event_list; |
743 | struct list_head vblank_event_list; |
738 | spinlock_t event_lock; |
744 | spinlock_t event_lock; |
739 | 745 | ||
740 | /*@} */ |
746 | /*@} */ |
741 | 747 | ||
742 | // struct drm_agp_head *agp; /**< AGP data */ |
748 | // struct drm_agp_head *agp; /**< AGP data */ |
743 | 749 | ||
744 | struct pci_dev *pdev; /**< PCI device structure */ |
750 | struct pci_dev *pdev; /**< PCI device structure */ |
745 | #ifdef __alpha__ |
751 | #ifdef __alpha__ |
746 | struct pci_controller *hose; |
752 | struct pci_controller *hose; |
747 | #endif |
753 | #endif |
748 | 754 | ||
749 | unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
755 | unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
750 | 756 | ||
751 | struct { |
757 | struct { |
752 | int context; |
758 | int context; |
753 | struct drm_hw_lock *lock; |
759 | struct drm_hw_lock *lock; |
754 | } sigdata; |
760 | } sigdata; |
755 | 761 | ||
756 | struct drm_mode_config mode_config; /**< Current mode config */ |
762 | struct drm_mode_config mode_config; /**< Current mode config */ |
757 | 763 | ||
758 | /** \name GEM information */ |
764 | /** \name GEM information */ |
759 | /*@{ */ |
765 | /*@{ */ |
760 | struct mutex object_name_lock; |
766 | struct mutex object_name_lock; |
761 | struct idr object_name_idr; |
767 | struct idr object_name_idr; |
762 | struct drm_vma_offset_manager *vma_offset_manager; |
768 | struct drm_vma_offset_manager *vma_offset_manager; |
763 | /*@} */ |
769 | /*@} */ |
764 | int switch_power_state; |
770 | int switch_power_state; |
765 | }; |
771 | }; |
766 | 772 | ||
767 | #define DRM_SWITCH_POWER_ON 0 |
773 | #define DRM_SWITCH_POWER_ON 0 |
768 | #define DRM_SWITCH_POWER_OFF 1 |
774 | #define DRM_SWITCH_POWER_OFF 1 |
769 | #define DRM_SWITCH_POWER_CHANGING 2 |
775 | #define DRM_SWITCH_POWER_CHANGING 2 |
770 | #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 |
776 | #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 |
771 | 777 | ||
772 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
778 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
773 | int feature) |
779 | int feature) |
774 | { |
780 | { |
775 | return ((dev->driver->driver_features & feature) ? 1 : 0); |
781 | return ((dev->driver->driver_features & feature) ? 1 : 0); |
776 | } |
782 | } |
777 | 783 | ||
778 | static inline void drm_device_set_unplugged(struct drm_device *dev) |
784 | static inline void drm_device_set_unplugged(struct drm_device *dev) |
779 | { |
785 | { |
780 | smp_wmb(); |
786 | smp_wmb(); |
781 | atomic_set(&dev->unplugged, 1); |
787 | atomic_set(&dev->unplugged, 1); |
782 | } |
788 | } |
783 | 789 | ||
784 | static inline int drm_device_is_unplugged(struct drm_device *dev) |
790 | static inline int drm_device_is_unplugged(struct drm_device *dev) |
785 | { |
791 | { |
786 | int ret = atomic_read(&dev->unplugged); |
792 | int ret = atomic_read(&dev->unplugged); |
787 | smp_rmb(); |
793 | smp_rmb(); |
788 | return ret; |
794 | return ret; |
789 | } |
795 | } |
790 | 796 | ||
791 | 797 | ||
792 | /******************************************************************/ |
798 | /******************************************************************/ |
793 | /** \name Internal function definitions */ |
799 | /** \name Internal function definitions */ |
794 | /*@{*/ |
800 | /*@{*/ |
795 | 801 | ||
796 | /* Driver support (drm_drv.h) */ |
802 | /* Driver support (drm_drv.h) */ |
797 | extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv); |
803 | extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv); |
798 | extern long drm_ioctl(struct file *filp, |
804 | extern long drm_ioctl(struct file *filp, |
799 | unsigned int cmd, unsigned long arg); |
805 | unsigned int cmd, unsigned long arg); |
800 | extern long drm_compat_ioctl(struct file *filp, |
806 | extern long drm_compat_ioctl(struct file *filp, |
801 | unsigned int cmd, unsigned long arg); |
807 | unsigned int cmd, unsigned long arg); |
802 | extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags); |
808 | extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags); |
803 | 809 | ||
804 | /* Device support (drm_fops.h) */ |
810 | /* File Operations (drm_fops.c) */ |
805 | extern int drm_open(struct inode *inode, struct file *filp); |
811 | int drm_open(struct inode *inode, struct file *filp); |
806 | extern ssize_t drm_read(struct file *filp, char __user *buffer, |
812 | ssize_t drm_read(struct file *filp, char __user *buffer, |
807 | size_t count, loff_t *offset); |
813 | size_t count, loff_t *offset); |
808 | extern int drm_release(struct inode *inode, struct file *filp); |
814 | int drm_release(struct inode *inode, struct file *filp); |
809 | extern int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv); |
- | |
- | 815 | int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv); |
|
- | 816 | unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
|
- | 817 | int drm_event_reserve_init_locked(struct drm_device *dev, |
|
- | 818 | struct drm_file *file_priv, |
|
810 | 819 | struct drm_pending_event *p, |
|
- | 820 | struct drm_event *e); |
|
- | 821 | int drm_event_reserve_init(struct drm_device *dev, |
|
- | 822 | struct drm_file *file_priv, |
|
- | 823 | struct drm_pending_event *p, |
|
- | 824 | struct drm_event *e); |
|
- | 825 | void drm_event_cancel_free(struct drm_device *dev, |
|
811 | /* Mapping support (drm_vm.h) */ |
826 | struct drm_pending_event *p); |
- | 827 | void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e); |
|
812 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
828 | void drm_send_event(struct drm_device *dev, struct drm_pending_event *e); |
813 | 829 | ||
814 | /* Misc. IOCTL support (drm_ioctl.c) */ |
830 | /* Misc. IOCTL support (drm_ioctl.c) */ |
815 | int drm_noop(struct drm_device *dev, void *data, |
831 | int drm_noop(struct drm_device *dev, void *data, |
816 | struct drm_file *file_priv); |
832 | struct drm_file *file_priv); |
817 | int drm_invalid_op(struct drm_device *dev, void *data, |
833 | int drm_invalid_op(struct drm_device *dev, void *data, |
818 | struct drm_file *file_priv); |
834 | struct drm_file *file_priv); |
819 | 835 | ||
820 | /* Cache management (drm_cache.c) */ |
836 | /* Cache management (drm_cache.c) */ |
821 | void drm_clflush_pages(struct page *pages[], unsigned long num_pages); |
837 | void drm_clflush_pages(struct page *pages[], unsigned long num_pages); |
822 | void drm_clflush_sg(struct sg_table *st); |
838 | void drm_clflush_sg(struct sg_table *st); |
823 | void drm_clflush_virt_range(void *addr, unsigned long length); |
839 | void drm_clflush_virt_range(void *addr, unsigned long length); |
824 | 840 | ||
825 | /* |
841 | /* |
826 | * These are exported to drivers so that they can implement fencing using |
842 | * These are exported to drivers so that they can implement fencing using |
827 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
843 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
828 | */ |
844 | */ |
829 | 845 | ||
830 | /* IRQ support (drm_irq.h) */ |
846 | /* IRQ support (drm_irq.h) */ |
831 | extern int drm_irq_install(struct drm_device *dev, int irq); |
847 | extern int drm_irq_install(struct drm_device *dev, int irq); |
832 | extern int drm_irq_uninstall(struct drm_device *dev); |
848 | extern int drm_irq_uninstall(struct drm_device *dev); |
833 | 849 | ||
834 | extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs); |
850 | extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs); |
835 | extern int drm_wait_vblank(struct drm_device *dev, void *data, |
851 | extern int drm_wait_vblank(struct drm_device *dev, void *data, |
836 | struct drm_file *filp); |
852 | struct drm_file *filp); |
837 | extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe); |
853 | extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe); |
838 | extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc); |
854 | extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc); |
839 | extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe, |
855 | extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe, |
840 | struct timeval *vblanktime); |
856 | struct timeval *vblanktime); |
841 | extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc, |
857 | extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc, |
842 | struct timeval *vblanktime); |
858 | struct timeval *vblanktime); |
843 | extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe, |
859 | extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe, |
844 | struct drm_pending_vblank_event *e); |
860 | struct drm_pending_vblank_event *e); |
845 | extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc, |
861 | extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc, |
846 | struct drm_pending_vblank_event *e); |
862 | struct drm_pending_vblank_event *e); |
847 | extern void drm_arm_vblank_event(struct drm_device *dev, unsigned int pipe, |
863 | extern void drm_arm_vblank_event(struct drm_device *dev, unsigned int pipe, |
848 | struct drm_pending_vblank_event *e); |
864 | struct drm_pending_vblank_event *e); |
849 | extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc, |
865 | extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc, |
850 | struct drm_pending_vblank_event *e); |
866 | struct drm_pending_vblank_event *e); |
851 | extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe); |
867 | extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe); |
852 | extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc); |
868 | extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc); |
853 | extern int drm_vblank_get(struct drm_device *dev, unsigned int pipe); |
869 | extern int drm_vblank_get(struct drm_device *dev, unsigned int pipe); |
854 | extern void drm_vblank_put(struct drm_device *dev, unsigned int pipe); |
870 | extern void drm_vblank_put(struct drm_device *dev, unsigned int pipe); |
855 | extern int drm_crtc_vblank_get(struct drm_crtc *crtc); |
871 | extern int drm_crtc_vblank_get(struct drm_crtc *crtc); |
856 | extern void drm_crtc_vblank_put(struct drm_crtc *crtc); |
872 | extern void drm_crtc_vblank_put(struct drm_crtc *crtc); |
857 | extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe); |
873 | extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe); |
858 | extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc); |
874 | extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc); |
859 | extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe); |
875 | extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe); |
860 | extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe); |
876 | extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe); |
861 | extern void drm_crtc_vblank_off(struct drm_crtc *crtc); |
877 | extern void drm_crtc_vblank_off(struct drm_crtc *crtc); |
862 | extern void drm_crtc_vblank_reset(struct drm_crtc *crtc); |
878 | extern void drm_crtc_vblank_reset(struct drm_crtc *crtc); |
863 | extern void drm_crtc_vblank_on(struct drm_crtc *crtc); |
879 | extern void drm_crtc_vblank_on(struct drm_crtc *crtc); |
864 | extern void drm_vblank_cleanup(struct drm_device *dev); |
880 | extern void drm_vblank_cleanup(struct drm_device *dev); |
865 | extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe); |
881 | extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe); |
866 | 882 | ||
867 | extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, |
883 | extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, |
868 | unsigned int pipe, int *max_error, |
884 | unsigned int pipe, int *max_error, |
869 | struct timeval *vblank_time, |
885 | struct timeval *vblank_time, |
870 | unsigned flags, |
886 | unsigned flags, |
871 | const struct drm_display_mode *mode); |
887 | const struct drm_display_mode *mode); |
872 | extern void drm_calc_timestamping_constants(struct drm_crtc *crtc, |
888 | extern void drm_calc_timestamping_constants(struct drm_crtc *crtc, |
873 | const struct drm_display_mode *mode); |
889 | const struct drm_display_mode *mode); |
874 | 890 | ||
875 | /** |
891 | /** |
876 | * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC |
892 | * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC |
877 | * @crtc: which CRTC's vblank waitqueue to retrieve |
893 | * @crtc: which CRTC's vblank waitqueue to retrieve |
878 | * |
894 | * |
879 | * This function returns a pointer to the vblank waitqueue for the CRTC. |
895 | * This function returns a pointer to the vblank waitqueue for the CRTC. |
880 | * Drivers can use this to implement vblank waits using wait_event() & co. |
896 | * Drivers can use this to implement vblank waits using wait_event() & co. |
881 | */ |
897 | */ |
882 | static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc) |
898 | static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc) |
883 | { |
899 | { |
884 | return &crtc->dev->vblank[drm_crtc_index(crtc)].queue; |
900 | return &crtc->dev->vblank[drm_crtc_index(crtc)].queue; |
885 | } |
901 | } |
886 | 902 | ||
887 | /* Modesetting support */ |
903 | /* Modesetting support */ |
888 | extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe); |
904 | extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe); |
889 | extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe); |
905 | extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe); |
890 | 906 | ||
891 | /* Stub support (drm_stub.h) */ |
907 | /* Stub support (drm_stub.h) */ |
892 | extern struct drm_master *drm_master_get(struct drm_master *master); |
908 | extern struct drm_master *drm_master_get(struct drm_master *master); |
893 | extern void drm_master_put(struct drm_master **master); |
909 | extern void drm_master_put(struct drm_master **master); |
894 | 910 | ||
895 | extern void drm_put_dev(struct drm_device *dev); |
911 | extern void drm_put_dev(struct drm_device *dev); |
896 | extern void drm_unplug_dev(struct drm_device *dev); |
912 | extern void drm_unplug_dev(struct drm_device *dev); |
897 | extern unsigned int drm_debug; |
913 | extern unsigned int drm_debug; |
898 | extern bool drm_atomic; |
914 | extern bool drm_atomic; |
899 | 915 | ||
900 | /* Debugfs support */ |
916 | /* Debugfs support */ |
901 | #if defined(CONFIG_DEBUG_FS) |
917 | #if defined(CONFIG_DEBUG_FS) |
902 | extern int drm_debugfs_create_files(const struct drm_info_list *files, |
918 | extern int drm_debugfs_create_files(const struct drm_info_list *files, |
903 | int count, struct dentry *root, |
919 | int count, struct dentry *root, |
904 | struct drm_minor *minor); |
920 | struct drm_minor *minor); |
905 | extern int drm_debugfs_remove_files(const struct drm_info_list *files, |
921 | extern int drm_debugfs_remove_files(const struct drm_info_list *files, |
906 | int count, struct drm_minor *minor); |
922 | int count, struct drm_minor *minor); |
907 | #else |
923 | #else |
908 | static inline int drm_debugfs_create_files(const struct drm_info_list *files, |
924 | static inline int drm_debugfs_create_files(const struct drm_info_list *files, |
909 | int count, struct dentry *root, |
925 | int count, struct dentry *root, |
910 | struct drm_minor *minor) |
926 | struct drm_minor *minor) |
911 | { |
927 | { |
912 | return 0; |
928 | return 0; |
913 | } |
929 | } |
914 | 930 | ||
915 | static inline int drm_debugfs_remove_files(const struct drm_info_list *files, |
931 | static inline int drm_debugfs_remove_files(const struct drm_info_list *files, |
916 | int count, struct drm_minor *minor) |
932 | int count, struct drm_minor *minor) |
917 | { |
933 | { |
918 | return 0; |
934 | return 0; |
919 | } |
935 | } |
920 | #endif |
936 | #endif |
921 | 937 | ||
922 | extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, |
938 | extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, |
923 | struct drm_gem_object *obj, int flags); |
939 | struct drm_gem_object *obj, int flags); |
924 | extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, |
940 | extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, |
925 | struct drm_file *file_priv, uint32_t handle, uint32_t flags, |
941 | struct drm_file *file_priv, uint32_t handle, uint32_t flags, |
926 | int *prime_fd); |
942 | int *prime_fd); |
927 | extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, |
943 | extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, |
928 | struct dma_buf *dma_buf); |
944 | struct dma_buf *dma_buf); |
929 | extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, |
945 | extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, |
930 | struct drm_file *file_priv, int prime_fd, uint32_t *handle); |
946 | struct drm_file *file_priv, int prime_fd, uint32_t *handle); |
931 | extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf); |
947 | extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf); |
932 | 948 | ||
933 | extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, |
949 | extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, |
934 | dma_addr_t *addrs, int max_pages); |
950 | dma_addr_t *addrs, int max_pages); |
935 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages); |
951 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages); |
936 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); |
952 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); |
937 | 953 | ||
938 | 954 | ||
939 | extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, |
955 | extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, |
940 | size_t align); |
956 | size_t align); |
941 | extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah); |
957 | extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah); |
942 | 958 | ||
943 | /* sysfs support (drm_sysfs.c) */ |
959 | /* sysfs support (drm_sysfs.c) */ |
944 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
960 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
945 | 961 | ||
946 | 962 | ||
947 | struct drm_device *drm_dev_alloc(struct drm_driver *driver, |
963 | struct drm_device *drm_dev_alloc(struct drm_driver *driver, |
948 | struct device *parent); |
964 | struct device *parent); |
949 | void drm_dev_ref(struct drm_device *dev); |
965 | void drm_dev_ref(struct drm_device *dev); |
950 | void drm_dev_unref(struct drm_device *dev); |
966 | void drm_dev_unref(struct drm_device *dev); |
951 | int drm_dev_register(struct drm_device *dev, unsigned long flags); |
967 | int drm_dev_register(struct drm_device *dev, unsigned long flags); |
952 | void drm_dev_unregister(struct drm_device *dev); |
968 | void drm_dev_unregister(struct drm_device *dev); |
953 | int drm_dev_set_unique(struct drm_device *dev, const char *name); |
969 | int drm_dev_set_unique(struct drm_device *dev, const char *name); |
954 | 970 | ||
955 | struct drm_minor *drm_minor_acquire(unsigned int minor_id); |
971 | struct drm_minor *drm_minor_acquire(unsigned int minor_id); |
956 | void drm_minor_release(struct drm_minor *minor); |
972 | void drm_minor_release(struct drm_minor *minor); |
957 | 973 | ||
958 | /*@}*/ |
974 | /*@}*/ |
959 | 975 | ||
960 | /* PCI section */ |
976 | /* PCI section */ |
961 | static __inline__ int drm_pci_device_is_agp(struct drm_device *dev) |
977 | static __inline__ int drm_pci_device_is_agp(struct drm_device *dev) |
962 | { |
978 | { |
963 | 979 | ||
964 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); |
980 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); |
965 | } |
981 | } |
966 | void drm_pci_agp_destroy(struct drm_device *dev); |
982 | void drm_pci_agp_destroy(struct drm_device *dev); |
967 | 983 | ||
968 | #if 0 |
984 | #if 0 |
969 | extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); |
985 | extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); |
970 | extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); |
986 | extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); |
971 | extern int drm_get_pci_dev(struct pci_dev *pdev, |
987 | extern int drm_get_pci_dev(struct pci_dev *pdev, |
972 | const struct pci_device_id *ent, |
988 | const struct pci_device_id *ent, |
973 | struct drm_driver *driver); |
989 | struct drm_driver *driver); |
974 | static inline int drm_pci_set_busid(struct drm_device *dev, |
990 | static inline int drm_pci_set_busid(struct drm_device *dev, |
975 | struct drm_master *master) |
991 | struct drm_master *master) |
976 | { |
992 | { |
977 | return -ENOSYS; |
993 | return -ENOSYS; |
978 | } |
994 | } |
979 | #endif |
995 | #endif |
980 | 996 | ||
981 | #define DRM_PCIE_SPEED_25 1 |
997 | #define DRM_PCIE_SPEED_25 1 |
982 | #define DRM_PCIE_SPEED_50 2 |
998 | #define DRM_PCIE_SPEED_50 2 |
983 | #define DRM_PCIE_SPEED_80 4 |
999 | #define DRM_PCIE_SPEED_80 4 |
984 | 1000 | ||
985 | extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); |
1001 | extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); |
986 | extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw); |
1002 | extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw); |
987 | 1003 | ||
988 | /* platform section */ |
1004 | /* platform section */ |
989 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); |
1005 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); |
990 | extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m); |
1006 | extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m); |
991 | 1007 | ||
992 | /* returns true if currently okay to sleep */ |
1008 | /* returns true if currently okay to sleep */ |
993 | static __inline__ bool drm_can_sleep(void) |
1009 | static __inline__ bool drm_can_sleep(void) |
994 | { |
1010 | { |
995 | return true; |
1011 | return true; |
996 | } |
1012 | } |
997 | 1013 | ||
998 | /* helper for handling conditionals in various for_each macros */ |
1014 | /* helper for handling conditionals in various for_each macros */ |
999 | #define for_each_if(condition) if (!(condition)) {} else |
1015 | #define for_each_if(condition) if (!(condition)) {} else |
1000 | 1016 | ||
1001 | static __inline__ int drm_device_is_pcie(struct drm_device *dev) |
1017 | static __inline__ int drm_device_is_pcie(struct drm_device *dev) |
1002 | { |
1018 | { |
1003 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); |
1019 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); |
1004 | } |
1020 | } |
1005 | 1021 | ||
1006 | #define LFB_SIZE 0x1000000 |
1022 | #define LFB_SIZE 0x1000000 |
1007 | extern struct drm_device *main_device; |
1023 | extern struct drm_device *main_device; |
1008 | extern struct drm_file *drm_file_handlers[256]; |
1024 | extern struct drm_file *drm_file_handlers[256]; |
1009 | 1025 | ||
1010 | #endif>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>><>><>><>><>>>>><> |
1026 | #endif>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>><>><>><>><>>>>><> |