Rev 4559 | Rev 5178 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4559 | Rev 5056 | ||
---|---|---|---|
1 | /** |
1 | /** |
2 | * \file drmP.h |
2 | * \file drmP.h |
3 | * Private header for Direct Rendering Manager |
3 | * Private header for Direct Rendering Manager |
4 | * |
4 | * |
5 | * \author Rickard E. (Rik) Faith |
5 | * \author Rickard E. (Rik) Faith |
6 | * \author Gareth Hughes |
6 | * \author Gareth Hughes |
7 | */ |
7 | */ |
8 | 8 | ||
9 | /* |
9 | /* |
10 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
10 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
11 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
11 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
12 | * Copyright (c) 2009-2010, Code Aurora Forum. |
12 | * Copyright (c) 2009-2010, Code Aurora Forum. |
13 | * All rights reserved. |
13 | * All rights reserved. |
14 | * |
14 | * |
15 | * Permission is hereby granted, free of charge, to any person obtaining a |
15 | * Permission is hereby granted, free of charge, to any person obtaining a |
16 | * copy of this software and associated documentation files (the "Software"), |
16 | * copy of this software and associated documentation files (the "Software"), |
17 | * to deal in the Software without restriction, including without limitation |
17 | * to deal in the Software without restriction, including without limitation |
18 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
18 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
19 | * and/or sell copies of the Software, and to permit persons to whom the |
19 | * and/or sell copies of the Software, and to permit persons to whom the |
20 | * Software is furnished to do so, subject to the following conditions: |
20 | * Software is furnished to do so, subject to the following conditions: |
21 | * |
21 | * |
22 | * The above copyright notice and this permission notice (including the next |
22 | * The above copyright notice and this permission notice (including the next |
23 | * paragraph) shall be included in all copies or substantial portions of the |
23 | * paragraph) shall be included in all copies or substantial portions of the |
24 | * Software. |
24 | * Software. |
25 | * |
25 | * |
26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
27 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
27 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
29 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
29 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
30 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
30 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
31 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
31 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
32 | * OTHER DEALINGS IN THE SOFTWARE. |
32 | * OTHER DEALINGS IN THE SOFTWARE. |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #ifndef _DRM_P_H_ |
35 | #ifndef _DRM_P_H_ |
36 | #define _DRM_P_H_ |
36 | #define _DRM_P_H_ |
37 | 37 | ||
38 | #define iowrite32(v, addr) writel((v), (addr)) |
38 | #define iowrite32(v, addr) writel((v), (addr)) |
39 | 39 | ||
40 | #ifdef __KERNEL__ |
40 | #ifdef __KERNEL__ |
41 | #ifdef __alpha__ |
41 | #ifdef __alpha__ |
42 | /* add include of current.h so that "current" is defined |
42 | /* add include of current.h so that "current" is defined |
43 | * before static inline funcs in wait.h. Doing this so we |
43 | * before static inline funcs in wait.h. Doing this so we |
44 | * can build the DRM (part of PI DRI). 4/21/2000 S + B */ |
44 | * can build the DRM (part of PI DRI). 4/21/2000 S + B */ |
45 | #include |
45 | #include |
46 | #endif /* __alpha__ */ |
46 | #endif /* __alpha__ */ |
47 | 47 | ||
48 | #include |
48 | #include |
49 | 49 | ||
50 | #include |
50 | #include |
51 | #include |
51 | #include |
52 | #include |
52 | #include |
53 | #include |
53 | #include |
54 | #include |
54 | #include |
55 | #include |
55 | #include |
56 | #include |
56 | #include |
57 | #include |
57 | #include |
58 | 58 | ||
59 | #include |
59 | #include |
60 | #include |
60 | #include |
61 | 61 | ||
62 | #include |
62 | #include |
63 | //#include |
63 | //#include |
64 | #include |
64 | #include |
65 | #include |
65 | #include |
66 | #include |
66 | #include |
- | 67 | #include |
|
- | 68 | ||
67 | #include |
69 | #include |
68 | //#include |
- | |
69 | //#include |
- | |
70 | #include |
70 | #include |
71 | //#include |
71 | //#include |
72 | //#include |
72 | #include |
- | 73 | ||
73 | //#include |
74 | //#include |
74 | //#include |
75 | //#include |
75 | //#include |
76 | //#include |
76 | //#include |
77 | //#include |
- | 78 | ||
77 | 79 | #include |
|
78 | #include |
80 | #include |
79 | 81 | ||
80 | 82 | ||
81 | #include |
83 | #include |
82 | #include |
84 | #include |
83 | 85 | ||
84 | #include |
86 | #include |
85 | 87 | ||
86 | #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) |
88 | #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) |
87 | 89 | ||
88 | struct module; |
90 | struct module; |
89 | 91 | ||
90 | struct drm_file; |
92 | struct drm_file; |
91 | struct drm_device; |
93 | struct drm_device; |
92 | 94 | ||
93 | struct device_node; |
95 | struct device_node; |
94 | struct videomode; |
96 | struct videomode; |
- | 97 | struct reservation_object; |
|
95 | 98 | ||
96 | struct inode; |
99 | struct inode; |
97 | struct poll_table_struct; |
100 | struct poll_table_struct; |
98 | struct drm_lock_data; |
101 | struct drm_lock_data; |
99 | 102 | ||
100 | struct sg_table; |
103 | struct sg_table; |
101 | struct dma_buf; |
104 | struct dma_buf; |
102 | 105 | ||
103 | //#include |
106 | //#include |
104 | #include |
107 | #include |
105 | #include |
108 | #include |
106 | 109 | ||
107 | #define KHZ2PICOS(a) (1000000000UL/(a)) |
110 | #define KHZ2PICOS(a) (1000000000UL/(a)) |
108 | 111 | ||
109 | /* Flags and return codes for get_vblank_timestamp() driver function. */ |
112 | /* Flags and return codes for get_vblank_timestamp() driver function. */ |
110 | #define DRM_CALLED_FROM_VBLIRQ 1 |
113 | #define DRM_CALLED_FROM_VBLIRQ 1 |
111 | #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) |
114 | #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) |
112 | #define DRM_VBLANKTIME_INVBL (1 << 1) |
115 | #define DRM_VBLANKTIME_INVBL (1 << 1) |
113 | 116 | ||
114 | 117 | ||
115 | /* get_scanout_position() return flags */ |
118 | /* get_scanout_position() return flags */ |
116 | #define DRM_SCANOUTPOS_VALID (1 << 0) |
119 | #define DRM_SCANOUTPOS_VALID (1 << 0) |
117 | #define DRM_SCANOUTPOS_INVBL (1 << 1) |
120 | #define DRM_SCANOUTPOS_INVBL (1 << 1) |
118 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
121 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
119 | 122 | ||
- | 123 | /* |
|
120 | 124 | * 4 debug categories are defined: |
|
- | 125 | * |
|
- | 126 | * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... |
|
- | 127 | * This is the category used by the DRM_DEBUG() macro. |
|
- | 128 | * |
|
- | 129 | * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... |
|
- | 130 | * This is the category used by the DRM_DEBUG_DRIVER() macro. |
|
- | 131 | * |
|
- | 132 | * KMS: used in the modesetting code. |
|
- | 133 | * This is the category used by the DRM_DEBUG_KMS() macro. |
|
- | 134 | * |
|
- | 135 | * PRIME: used in the prime code. |
|
- | 136 | * This is the category used by the DRM_DEBUG_PRIME() macro. |
|
- | 137 | * |
|
- | 138 | * Enabling verbose debug messages is done through the drm.debug parameter, |
|
- | 139 | * each category being enabled by a bit. |
|
- | 140 | * |
|
- | 141 | * drm.debug=0x1 will enable CORE messages |
|
- | 142 | * drm.debug=0x2 will enable DRIVER messages |
|
- | 143 | * drm.debug=0x3 will enable CORE and DRIVER messages |
|
- | 144 | * ... |
|
- | 145 | * drm.debug=0xf will enable all messages |
|
- | 146 | * |
|
- | 147 | * An interesting feature is that it's possible to enable verbose logging at |
|
- | 148 | * run-time by echoing the debug value in its sysfs node: |
|
- | 149 | * # echo 0xf > /sys/module/drm/parameters/debug |
|
121 | 150 | */ |
|
122 | #define DRM_UT_CORE 0x01 |
151 | #define DRM_UT_CORE 0x01 |
123 | #define DRM_UT_DRIVER 0x02 |
152 | #define DRM_UT_DRIVER 0x02 |
124 | #define DRM_UT_KMS 0x04 |
153 | #define DRM_UT_KMS 0x04 |
125 | #define DRM_UT_PRIME 0x08 |
154 | #define DRM_UT_PRIME 0x08 |
126 | /* |
- | |
127 | * Three debug levels are defined. |
- | |
128 | * drm_core, drm_driver, drm_kms |
- | |
129 | * drm_core level can be used in the generic drm code. For example: |
- | |
130 | * drm_ioctl, drm_mm, drm_memory |
- | |
131 | * The macro definition of DRM_DEBUG is used. |
- | |
132 | * DRM_DEBUG(fmt, args...) |
- | |
133 | * The debug info by using the DRM_DEBUG can be obtained by adding |
- | |
134 | * the boot option of "drm.debug=1". |
- | |
135 | * |
- | |
136 | * drm_driver level can be used in the specific drm driver. It is used |
- | |
137 | * to add the debug info related with the drm driver. For example: |
- | |
138 | * i915_drv, i915_dma, i915_gem, radeon_drv, |
- | |
139 | * The macro definition of DRM_DEBUG_DRIVER can be used. |
- | |
140 | * DRM_DEBUG_DRIVER(fmt, args...) |
- | |
141 | * The debug info by using the DRM_DEBUG_DRIVER can be obtained by |
- | |
142 | * adding the boot option of "drm.debug=0x02" |
- | |
143 | * |
- | |
144 | * drm_kms level can be used in the KMS code related with specific drm driver. |
- | |
145 | * It is used to add the debug info related with KMS mode. For example: |
- | |
146 | * the connector/crtc , |
- | |
147 | * The macro definition of DRM_DEBUG_KMS can be used. |
- | |
148 | * DRM_DEBUG_KMS(fmt, args...) |
- | |
149 | * The debug info by using the DRM_DEBUG_KMS can be obtained by |
- | |
150 | * adding the boot option of "drm.debug=0x04" |
- | |
151 | * |
- | |
152 | * If we add the boot option of "drm.debug=0x06", we can get the debug info by |
- | |
153 | * using the DRM_DEBUG_KMS and DRM_DEBUG_DRIVER. |
- | |
154 | * If we add the boot option of "drm.debug=0x05", we can get the debug info by |
- | |
155 | * using the DRM_DEBUG_KMS and DRM_DEBUG. |
- | |
156 | */ |
- | |
157 | 155 | ||
158 | extern __printf(4, 5) |
156 | extern __printf(2, 3) |
159 | void drm_ut_debug_printk(unsigned int request_level, |
157 | void drm_ut_debug_printk(const char *function_name, |
160 | const char *prefix, |
- | |
161 | const char *function_name, |
- | |
162 | const char *format, ...); |
158 | const char *format, ...); |
163 | extern __printf(2, 3) |
159 | extern __printf(2, 3) |
164 | int drm_err(const char *func, const char *format, ...); |
160 | int drm_err(const char *func, const char *format, ...); |
165 | 161 | ||
166 | /***********************************************************************/ |
162 | /***********************************************************************/ |
167 | /** \name DRM template customization defaults */ |
163 | /** \name DRM template customization defaults */ |
168 | /*@{*/ |
164 | /*@{*/ |
169 | 165 | ||
170 | /* driver capabilities and requirements mask */ |
166 | /* driver capabilities and requirements mask */ |
171 | #define DRIVER_USE_AGP 0x1 |
167 | #define DRIVER_USE_AGP 0x1 |
172 | #define DRIVER_PCI_DMA 0x8 |
168 | #define DRIVER_PCI_DMA 0x8 |
173 | #define DRIVER_SG 0x10 |
169 | #define DRIVER_SG 0x10 |
174 | #define DRIVER_HAVE_DMA 0x20 |
170 | #define DRIVER_HAVE_DMA 0x20 |
175 | #define DRIVER_HAVE_IRQ 0x40 |
171 | #define DRIVER_HAVE_IRQ 0x40 |
176 | #define DRIVER_IRQ_SHARED 0x80 |
172 | #define DRIVER_IRQ_SHARED 0x80 |
177 | #define DRIVER_GEM 0x1000 |
173 | #define DRIVER_GEM 0x1000 |
178 | #define DRIVER_MODESET 0x2000 |
174 | #define DRIVER_MODESET 0x2000 |
179 | #define DRIVER_PRIME 0x4000 |
175 | #define DRIVER_PRIME 0x4000 |
180 | #define DRIVER_RENDER 0x8000 |
176 | #define DRIVER_RENDER 0x8000 |
181 | 177 | ||
182 | #define DRIVER_BUS_PCI 0x1 |
178 | #define DRIVER_BUS_PCI 0x1 |
183 | #define DRIVER_BUS_PLATFORM 0x2 |
179 | #define DRIVER_BUS_PLATFORM 0x2 |
184 | #define DRIVER_BUS_USB 0x3 |
180 | #define DRIVER_BUS_USB 0x3 |
185 | #define DRIVER_BUS_HOST1X 0x4 |
181 | #define DRIVER_BUS_HOST1X 0x4 |
186 | 182 | ||
187 | /***********************************************************************/ |
183 | /***********************************************************************/ |
188 | /** \name Begin the DRM... */ |
184 | /** \name Begin the DRM... */ |
189 | /*@{*/ |
185 | /*@{*/ |
190 | 186 | ||
191 | #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then |
187 | #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then |
192 | also include looping detection. */ |
188 | also include looping detection. */ |
193 | 189 | ||
194 | #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */ |
190 | #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */ |
195 | #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */ |
- | |
196 | #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */ |
- | |
197 | 191 | ||
198 | #define DRM_MAP_HASH_OFFSET 0x10000000 |
192 | #define DRM_MAP_HASH_OFFSET 0x10000000 |
199 | 193 | ||
200 | /*@}*/ |
194 | /*@}*/ |
201 | 195 | ||
202 | /***********************************************************************/ |
196 | /***********************************************************************/ |
203 | /** \name Macros to make printk easier */ |
197 | /** \name Macros to make printk easier */ |
204 | /*@{*/ |
198 | /*@{*/ |
205 | 199 | ||
206 | /** |
200 | /** |
207 | * Error output. |
201 | * Error output. |
208 | * |
202 | * |
209 | * \param fmt printf() like format string. |
203 | * \param fmt printf() like format string. |
210 | * \param arg arguments |
204 | * \param arg arguments |
211 | */ |
205 | */ |
212 | #define DRM_ERROR(fmt, ...) \ |
206 | #define DRM_ERROR(fmt, ...) \ |
213 | drm_err(__func__, fmt, ##__VA_ARGS__) |
207 | drm_err(__func__, fmt, ##__VA_ARGS__) |
214 | 208 | ||
215 | /** |
209 | /** |
216 | * Rate limited error output. Like DRM_ERROR() but won't flood the log. |
210 | * Rate limited error output. Like DRM_ERROR() but won't flood the log. |
217 | * |
211 | * |
218 | * \param fmt printf() like format string. |
212 | * \param fmt printf() like format string. |
219 | * \param arg arguments |
213 | * \param arg arguments |
220 | */ |
214 | */ |
221 | #define DRM_ERROR_RATELIMITED(fmt, ...) \ |
215 | #define DRM_ERROR_RATELIMITED(fmt, ...) \ |
222 | ({ \ |
216 | ({ \ |
223 | static DEFINE_RATELIMIT_STATE(_rs, \ |
217 | static DEFINE_RATELIMIT_STATE(_rs, \ |
224 | DEFAULT_RATELIMIT_INTERVAL, \ |
218 | DEFAULT_RATELIMIT_INTERVAL, \ |
225 | DEFAULT_RATELIMIT_BURST); \ |
219 | DEFAULT_RATELIMIT_BURST); \ |
226 | \ |
220 | \ |
227 | if (__ratelimit(&_rs)) \ |
221 | if (__ratelimit(&_rs)) \ |
228 | drm_err(__func__, fmt, ##__VA_ARGS__); \ |
222 | drm_err(__func__, fmt, ##__VA_ARGS__); \ |
229 | }) |
223 | }) |
230 | 224 | ||
231 | #define DRM_INFO(fmt, ...) \ |
225 | #define DRM_INFO(fmt, ...) \ |
232 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) |
226 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) |
- | 227 | ||
- | 228 | #define DRM_INFO_ONCE(fmt, ...) \ |
|
- | 229 | printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) |
|
233 | 230 | ||
234 | /** |
231 | /** |
235 | * Debug output. |
232 | * Debug output. |
236 | * |
233 | * |
237 | * \param fmt printf() like format string. |
234 | * \param fmt printf() like format string. |
238 | * \param arg arguments |
235 | * \param arg arguments |
239 | */ |
236 | */ |
240 | #if DRM_DEBUG_CODE |
237 | #if DRM_DEBUG_CODE |
241 | #define DRM_DEBUG(fmt, ...) \ |
238 | #define DRM_DEBUG(fmt, args...) \ |
242 | do { \ |
239 | do { \ |
243 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
240 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
244 | } while (0) |
241 | } while (0) |
245 | - | ||
246 | #define DRM_DEBUG_DRIVER(fmt, ...) \ |
- | |
247 | do { \ |
- | |
248 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
- | |
249 | } while (0) |
242 | |
250 | #define DRM_DEBUG_KMS(fmt, ...) \ |
- | |
251 | do { \ |
- | |
252 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
- | |
253 | } while (0) |
- | |
254 | #define DRM_DEBUG_PRIME(fmt, ...) \ |
243 | #define DRM_DEBUG_DRIVER(fmt, args...) \ |
255 | do { \ |
244 | do { \ |
256 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
245 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
257 | } while (0) |
246 | } while (0) |
258 | #define DRM_LOG(fmt, ...) \ |
247 | #define DRM_DEBUG_KMS(fmt, args...) \ |
259 | do { \ |
248 | do { \ |
260 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
249 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
261 | } while (0) |
250 | } while (0) |
262 | #define DRM_LOG_KMS(fmt, ...) \ |
251 | #define DRM_DEBUG_PRIME(fmt, args...) \ |
263 | do { \ |
252 | do { \ |
264 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
- | |
265 | } while (0) |
- | |
266 | #define DRM_LOG_MODE(fmt, ...) \ |
- | |
267 | do { \ |
- | |
268 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
- | |
269 | } while (0) |
- | |
270 | #define DRM_LOG_DRIVER(fmt, ...) \ |
- | |
271 | do { \ |
- | |
272 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
253 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \ |
273 | } while (0) |
254 | } while (0) |
274 | #else |
255 | #else |
275 | #define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0) |
256 | #define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0) |
276 | #define DRM_DEBUG_KMS(fmt, args...) do { } while (0) |
257 | #define DRM_DEBUG_KMS(fmt, args...) do { } while (0) |
277 | #define DRM_DEBUG_PRIME(fmt, args...) do { } while (0) |
258 | #define DRM_DEBUG_PRIME(fmt, args...) do { } while (0) |
278 | #define DRM_DEBUG(fmt, arg...) do { } while (0) |
259 | #define DRM_DEBUG(fmt, arg...) do { } while (0) |
279 | #define DRM_LOG(fmt, arg...) do { } while (0) |
- | |
280 | #define DRM_LOG_KMS(fmt, args...) do { } while (0) |
- | |
281 | #define DRM_LOG_MODE(fmt, arg...) do { } while (0) |
- | |
282 | #define DRM_LOG_DRIVER(fmt, arg...) do { } while (0) |
- | |
283 | - | ||
284 | #endif |
260 | #endif |
285 | 261 | ||
286 | /*@}*/ |
262 | /*@}*/ |
287 | 263 | ||
288 | /***********************************************************************/ |
264 | /***********************************************************************/ |
289 | /** \name Internal types and structures */ |
265 | /** \name Internal types and structures */ |
290 | /*@{*/ |
266 | /*@{*/ |
291 | 267 | ||
292 | #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x) |
268 | #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x) |
293 | 269 | ||
294 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
270 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
295 | 271 | ||
296 | /** |
272 | /** |
297 | * Test that the hardware lock is held by the caller, returning otherwise. |
273 | * Test that the hardware lock is held by the caller, returning otherwise. |
298 | * |
274 | * |
299 | * \param dev DRM device. |
275 | * \param dev DRM device. |
300 | * \param filp file pointer of the caller. |
276 | * \param filp file pointer of the caller. |
301 | */ |
277 | */ |
302 | #define LOCK_TEST_WITH_RETURN( dev, _file_priv ) \ |
278 | #define LOCK_TEST_WITH_RETURN( dev, _file_priv ) \ |
303 | do { \ |
279 | do { \ |
304 | if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) || \ |
280 | if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) || \ |
305 | _file_priv->master->lock.file_priv != _file_priv) { \ |
281 | _file_priv->master->lock.file_priv != _file_priv) { \ |
306 | DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ |
282 | DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ |
307 | __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\ |
283 | __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\ |
308 | _file_priv->master->lock.file_priv, _file_priv); \ |
284 | _file_priv->master->lock.file_priv, _file_priv); \ |
309 | return -EINVAL; \ |
285 | return -EINVAL; \ |
310 | } \ |
286 | } \ |
311 | } while (0) |
287 | } while (0) |
312 | - | ||
313 | #if 0 |
288 | |
314 | /** |
289 | /** |
315 | * Ioctl function type. |
290 | * Ioctl function type. |
316 | * |
291 | * |
317 | * \param inode device inode. |
292 | * \param inode device inode. |
318 | * \param file_priv DRM file private pointer. |
293 | * \param file_priv DRM file private pointer. |
319 | * \param cmd command. |
294 | * \param cmd command. |
320 | * \param arg argument. |
295 | * \param arg argument. |
321 | */ |
296 | */ |
322 | typedef int drm_ioctl_t(struct drm_device *dev, void *data, |
297 | typedef int drm_ioctl_t(struct drm_device *dev, void *data, |
323 | struct drm_file *file_priv); |
298 | struct drm_file *file_priv); |
324 | 299 | ||
325 | typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, |
300 | typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, |
326 | unsigned long arg); |
301 | unsigned long arg); |
327 | 302 | ||
328 | #define DRM_IOCTL_NR(n) _IOC_NR(n) |
303 | #define DRM_IOCTL_NR(n) _IOC_NR(n) |
329 | #define DRM_MAJOR 226 |
304 | #define DRM_MAJOR 226 |
330 | 305 | ||
331 | #define DRM_AUTH 0x1 |
306 | #define DRM_AUTH 0x1 |
332 | #define DRM_MASTER 0x2 |
307 | #define DRM_MASTER 0x2 |
333 | #define DRM_ROOT_ONLY 0x4 |
308 | #define DRM_ROOT_ONLY 0x4 |
334 | #define DRM_CONTROL_ALLOW 0x8 |
309 | #define DRM_CONTROL_ALLOW 0x8 |
335 | #define DRM_UNLOCKED 0x10 |
310 | #define DRM_UNLOCKED 0x10 |
336 | #define DRM_RENDER_ALLOW 0x20 |
311 | #define DRM_RENDER_ALLOW 0x20 |
337 | 312 | ||
338 | struct drm_ioctl_desc { |
313 | struct drm_ioctl_desc { |
339 | unsigned int cmd; |
314 | unsigned int cmd; |
340 | int flags; |
315 | int flags; |
341 | drm_ioctl_t *func; |
316 | drm_ioctl_t *func; |
342 | unsigned int cmd_drv; |
317 | unsigned int cmd_drv; |
343 | const char *name; |
318 | const char *name; |
344 | }; |
319 | }; |
345 | 320 | ||
346 | /** |
321 | /** |
347 | * Creates a driver or general drm_ioctl_desc array entry for the given |
322 | * Creates a driver or general drm_ioctl_desc array entry for the given |
348 | * ioctl, for use by drm_ioctl(). |
323 | * ioctl, for use by drm_ioctl(). |
349 | */ |
324 | */ |
350 | 325 | ||
351 | #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ |
326 | #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ |
352 | [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl} |
327 | [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl} |
- | 328 | ||
353 | 329 | #if 0 |
|
354 | struct drm_magic_entry { |
330 | struct drm_magic_entry { |
355 | struct list_head head; |
331 | struct list_head head; |
356 | struct drm_hash_item hash_item; |
332 | struct drm_hash_item hash_item; |
357 | struct drm_file *priv; |
333 | struct drm_file *priv; |
358 | }; |
334 | }; |
359 | 335 | ||
360 | struct drm_vma_entry { |
336 | struct drm_vma_entry { |
361 | struct list_head head; |
337 | struct list_head head; |
362 | struct vm_area_struct *vma; |
338 | struct vm_area_struct *vma; |
363 | pid_t pid; |
339 | pid_t pid; |
364 | }; |
340 | }; |
365 | 341 | ||
366 | /** |
342 | /** |
367 | * DMA buffer. |
343 | * DMA buffer. |
368 | */ |
344 | */ |
369 | struct drm_buf { |
345 | struct drm_buf { |
370 | int idx; /**< Index into master buflist */ |
346 | int idx; /**< Index into master buflist */ |
371 | int total; /**< Buffer size */ |
347 | int total; /**< Buffer size */ |
372 | int order; /**< log-base-2(total) */ |
348 | int order; /**< log-base-2(total) */ |
373 | int used; /**< Amount of buffer in use (for DMA) */ |
349 | int used; /**< Amount of buffer in use (for DMA) */ |
374 | unsigned long offset; /**< Byte offset (used internally) */ |
350 | unsigned long offset; /**< Byte offset (used internally) */ |
375 | void *address; /**< Address of buffer */ |
351 | void *address; /**< Address of buffer */ |
376 | unsigned long bus_address; /**< Bus address of buffer */ |
352 | unsigned long bus_address; /**< Bus address of buffer */ |
377 | struct drm_buf *next; /**< Kernel-only: used for free list */ |
353 | struct drm_buf *next; /**< Kernel-only: used for free list */ |
378 | __volatile__ int waiting; /**< On kernel DMA queue */ |
354 | __volatile__ int waiting; /**< On kernel DMA queue */ |
379 | __volatile__ int pending; /**< On hardware DMA queue */ |
355 | __volatile__ int pending; /**< On hardware DMA queue */ |
380 | struct drm_file *file_priv; /**< Private of holding file descr */ |
356 | struct drm_file *file_priv; /**< Private of holding file descr */ |
381 | int context; /**< Kernel queue for this buffer */ |
357 | int context; /**< Kernel queue for this buffer */ |
382 | int while_locked; /**< Dispatch this buffer while locked */ |
358 | int while_locked; /**< Dispatch this buffer while locked */ |
383 | enum { |
359 | enum { |
384 | DRM_LIST_NONE = 0, |
360 | DRM_LIST_NONE = 0, |
385 | DRM_LIST_FREE = 1, |
361 | DRM_LIST_FREE = 1, |
386 | DRM_LIST_WAIT = 2, |
362 | DRM_LIST_WAIT = 2, |
387 | DRM_LIST_PEND = 3, |
363 | DRM_LIST_PEND = 3, |
388 | DRM_LIST_PRIO = 4, |
364 | DRM_LIST_PRIO = 4, |
389 | DRM_LIST_RECLAIM = 5 |
365 | DRM_LIST_RECLAIM = 5 |
390 | } list; /**< Which list we're on */ |
366 | } list; /**< Which list we're on */ |
391 | 367 | ||
392 | int dev_priv_size; /**< Size of buffer private storage */ |
368 | int dev_priv_size; /**< Size of buffer private storage */ |
393 | void *dev_private; /**< Per-buffer private storage */ |
369 | void *dev_private; /**< Per-buffer private storage */ |
394 | }; |
370 | }; |
395 | 371 | ||
396 | /** bufs is one longer than it has to be */ |
372 | /** bufs is one longer than it has to be */ |
397 | struct drm_waitlist { |
373 | struct drm_waitlist { |
398 | int count; /**< Number of possible buffers */ |
374 | int count; /**< Number of possible buffers */ |
399 | struct drm_buf **bufs; /**< List of pointers to buffers */ |
375 | struct drm_buf **bufs; /**< List of pointers to buffers */ |
400 | struct drm_buf **rp; /**< Read pointer */ |
376 | struct drm_buf **rp; /**< Read pointer */ |
401 | struct drm_buf **wp; /**< Write pointer */ |
377 | struct drm_buf **wp; /**< Write pointer */ |
402 | struct drm_buf **end; /**< End pointer */ |
378 | struct drm_buf **end; /**< End pointer */ |
403 | spinlock_t read_lock; |
379 | spinlock_t read_lock; |
404 | spinlock_t write_lock; |
380 | spinlock_t write_lock; |
405 | }; |
381 | }; |
406 | #endif |
382 | #endif |
407 | - | ||
408 | struct drm_freelist { |
- | |
409 | int initialized; /**< Freelist in use */ |
- | |
410 | atomic_t count; /**< Number of free buffers */ |
- | |
411 | struct drm_buf *next; /**< End pointer */ |
- | |
412 | - | ||
413 | wait_queue_head_t waiting; /**< Processes waiting on free bufs */ |
- | |
414 | int low_mark; /**< Low water mark */ |
- | |
415 | int high_mark; /**< High water mark */ |
- | |
416 | atomic_t wfh; /**< If waiting for high mark */ |
- | |
417 | spinlock_t lock; |
- | |
418 | }; |
383 | |
419 | 384 | ||
420 | typedef struct drm_dma_handle { |
385 | typedef struct drm_dma_handle { |
421 | dma_addr_t busaddr; |
386 | dma_addr_t busaddr; |
422 | void *vaddr; |
387 | void *vaddr; |
423 | size_t size; |
388 | size_t size; |
424 | } drm_dma_handle_t; |
389 | } drm_dma_handle_t; |
425 | 390 | ||
426 | /** |
391 | /** |
427 | * Buffer entry. There is one of this for each buffer size order. |
392 | * Buffer entry. There is one of this for each buffer size order. |
428 | */ |
393 | */ |
429 | struct drm_buf_entry { |
394 | struct drm_buf_entry { |
430 | int buf_size; /**< size */ |
395 | int buf_size; /**< size */ |
431 | int buf_count; /**< number of buffers */ |
396 | int buf_count; /**< number of buffers */ |
432 | struct drm_buf *buflist; /**< buffer list */ |
397 | struct drm_buf *buflist; /**< buffer list */ |
433 | int seg_count; |
398 | int seg_count; |
434 | int page_order; |
399 | int page_order; |
435 | struct drm_dma_handle **seglist; |
400 | struct drm_dma_handle **seglist; |
436 | 401 | ||
- | 402 | int low_mark; /**< Low water mark */ |
|
437 | struct drm_freelist freelist; |
403 | int high_mark; /**< High water mark */ |
438 | }; |
404 | }; |
439 | 405 | ||
440 | /* Event queued up for userspace to read */ |
406 | /* Event queued up for userspace to read */ |
441 | struct drm_pending_event { |
407 | struct drm_pending_event { |
442 | struct drm_event *event; |
408 | struct drm_event *event; |
443 | struct list_head link; |
409 | struct list_head link; |
444 | struct drm_file *file_priv; |
410 | struct drm_file *file_priv; |
445 | pid_t pid; /* pid of requester, no guarantee it's valid by the time |
411 | pid_t pid; /* pid of requester, no guarantee it's valid by the time |
446 | we deliver the event, for tracing only */ |
412 | we deliver the event, for tracing only */ |
447 | void (*destroy)(struct drm_pending_event *event); |
413 | void (*destroy)(struct drm_pending_event *event); |
448 | }; |
414 | }; |
449 | 415 | ||
450 | /* initial implementaton using a linked list - todo hashtab */ |
416 | /* initial implementaton using a linked list - todo hashtab */ |
451 | struct drm_prime_file_private { |
417 | struct drm_prime_file_private { |
452 | struct list_head head; |
418 | struct list_head head; |
453 | struct mutex lock; |
419 | struct mutex lock; |
454 | }; |
420 | }; |
455 | 421 | ||
456 | /** File private data */ |
422 | /** File private data */ |
457 | struct drm_file { |
423 | struct drm_file { |
458 | unsigned always_authenticated :1; |
- | |
459 | unsigned authenticated :1; |
424 | unsigned authenticated :1; |
460 | unsigned is_master :1; /* this file private is a master for a minor */ |
425 | /* Whether we're master for a minor. Protected by master_mutex */ |
- | 426 | unsigned is_master :1; |
|
461 | /* true when the client has asked us to expose stereo 3D mode flags */ |
427 | /* true when the client has asked us to expose stereo 3D mode flags */ |
462 | unsigned stereo_allowed :1; |
428 | unsigned stereo_allowed :1; |
- | 429 | /* |
|
- | 430 | * true if client understands CRTC primary planes and cursor planes |
|
- | 431 | * in the plane list |
|
- | 432 | */ |
|
- | 433 | unsigned universal_planes:1; |
|
463 | struct list_head lhead; |
434 | struct list_head lhead; |
464 | unsigned long lock_count; |
435 | unsigned long lock_count; |
465 | 436 | ||
466 | /** Mapping of mm object handles to object pointers. */ |
437 | /** Mapping of mm object handles to object pointers. */ |
467 | struct idr object_idr; |
438 | struct idr object_idr; |
468 | /** Lock for synchronization of access to object_idr. */ |
439 | /** Lock for synchronization of access to object_idr. */ |
469 | spinlock_t table_lock; |
440 | spinlock_t table_lock; |
470 | 441 | ||
471 | void *driver_priv; |
442 | void *driver_priv; |
- | 443 | ||
- | 444 | struct drm_master *master; /* master this node is currently associated with |
|
- | 445 | N.B. not always minor->master */ |
|
- | 446 | /** |
|
- | 447 | * fbs - List of framebuffers associated with this file. |
|
- | 448 | * |
|
- | 449 | * Protected by fbs_lock. Note that the fbs list holds a reference on |
|
- | 450 | * the fb object to prevent it from untimely disappearing. |
|
472 | 451 | */ |
|
- | 452 | struct list_head fbs; |
|
473 | struct list_head fbs; |
453 | struct mutex fbs_lock; |
474 | 454 | ||
475 | wait_queue_head_t event_wait; |
455 | wait_queue_head_t event_wait; |
476 | struct list_head event_list; |
456 | struct list_head event_list; |
477 | int event_space; |
457 | int event_space; |
478 | }; |
458 | }; |
479 | 459 | ||
480 | #if 0 |
460 | #if 0 |
481 | /** Wait queue */ |
- | |
482 | struct drm_queue { |
- | |
483 | atomic_t use_count; /**< Outstanding uses (+1) */ |
- | |
484 | atomic_t finalization; /**< Finalization in progress */ |
- | |
485 | atomic_t block_count; /**< Count of processes waiting */ |
- | |
486 | atomic_t block_read; /**< Queue blocked for reads */ |
- | |
487 | wait_queue_head_t read_queue; /**< Processes waiting on block_read */ |
- | |
488 | atomic_t block_write; /**< Queue blocked for writes */ |
- | |
489 | wait_queue_head_t write_queue; /**< Processes waiting on block_write */ |
- | |
490 | atomic_t total_queued; /**< Total queued statistic */ |
- | |
491 | atomic_t total_flushed; /**< Total flushes statistic */ |
- | |
492 | atomic_t total_locks; /**< Total locks statistics */ |
- | |
493 | enum drm_ctx_flags flags; /**< Context preserving and 2D-only */ |
- | |
494 | struct drm_waitlist waitlist; /**< Pending buffers */ |
- | |
495 | wait_queue_head_t flush_queue; /**< Processes waiting until flush */ |
- | |
496 | }; |
- | |
497 | - | ||
498 | /** |
461 | /** |
499 | * Lock data. |
462 | * Lock data. |
500 | */ |
463 | */ |
501 | struct drm_lock_data { |
464 | struct drm_lock_data { |
502 | struct drm_hw_lock *hw_lock; /**< Hardware lock */ |
465 | struct drm_hw_lock *hw_lock; /**< Hardware lock */ |
503 | /** Private of lock holder's file (NULL=kernel) */ |
466 | /** Private of lock holder's file (NULL=kernel) */ |
504 | struct drm_file *file_priv; |
467 | struct drm_file *file_priv; |
505 | wait_queue_head_t lock_queue; /**< Queue of blocked processes */ |
468 | wait_queue_head_t lock_queue; /**< Queue of blocked processes */ |
506 | unsigned long lock_time; /**< Time of last lock in jiffies */ |
469 | unsigned long lock_time; /**< Time of last lock in jiffies */ |
507 | spinlock_t spinlock; |
470 | spinlock_t spinlock; |
508 | uint32_t kernel_waiters; |
471 | uint32_t kernel_waiters; |
509 | uint32_t user_waiters; |
472 | uint32_t user_waiters; |
510 | int idle_has_lock; |
473 | int idle_has_lock; |
511 | }; |
474 | }; |
512 | 475 | ||
513 | /** |
476 | /** |
514 | * DMA data. |
477 | * DMA data. |
515 | */ |
478 | */ |
516 | struct drm_device_dma { |
479 | struct drm_device_dma { |
517 | 480 | ||
518 | struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */ |
481 | struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */ |
519 | int buf_count; /**< total number of buffers */ |
482 | int buf_count; /**< total number of buffers */ |
520 | struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */ |
483 | struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */ |
521 | int seg_count; |
484 | int seg_count; |
522 | int page_count; /**< number of pages */ |
485 | int page_count; /**< number of pages */ |
523 | unsigned long *pagelist; /**< page list */ |
486 | unsigned long *pagelist; /**< page list */ |
524 | unsigned long byte_count; |
487 | unsigned long byte_count; |
525 | enum { |
488 | enum { |
526 | _DRM_DMA_USE_AGP = 0x01, |
489 | _DRM_DMA_USE_AGP = 0x01, |
527 | _DRM_DMA_USE_SG = 0x02, |
490 | _DRM_DMA_USE_SG = 0x02, |
528 | _DRM_DMA_USE_FB = 0x04, |
491 | _DRM_DMA_USE_FB = 0x04, |
529 | _DRM_DMA_USE_PCI_RO = 0x08 |
492 | _DRM_DMA_USE_PCI_RO = 0x08 |
530 | } flags; |
493 | } flags; |
531 | 494 | ||
532 | }; |
495 | }; |
533 | 496 | ||
534 | /** |
497 | /** |
535 | * AGP memory entry. Stored as a doubly linked list. |
498 | * AGP memory entry. Stored as a doubly linked list. |
536 | */ |
499 | */ |
537 | struct drm_agp_mem { |
500 | struct drm_agp_mem { |
538 | unsigned long handle; /**< handle */ |
501 | unsigned long handle; /**< handle */ |
539 | struct agp_memory *memory; |
502 | struct agp_memory *memory; |
540 | unsigned long bound; /**< address */ |
503 | unsigned long bound; /**< address */ |
541 | int pages; |
504 | int pages; |
542 | struct list_head head; |
505 | struct list_head head; |
543 | }; |
506 | }; |
544 | 507 | ||
545 | /** |
508 | /** |
546 | * AGP data. |
509 | * AGP data. |
547 | * |
510 | * |
548 | * \sa drm_agp_init() and drm_device::agp. |
511 | * \sa drm_agp_init() and drm_device::agp. |
549 | */ |
512 | */ |
550 | struct drm_agp_head { |
513 | struct drm_agp_head { |
551 | struct agp_kern_info agp_info; /**< AGP device information */ |
514 | struct agp_kern_info agp_info; /**< AGP device information */ |
552 | struct list_head memory; |
515 | struct list_head memory; |
553 | unsigned long mode; /**< AGP mode */ |
516 | unsigned long mode; /**< AGP mode */ |
554 | struct agp_bridge_data *bridge; |
517 | struct agp_bridge_data *bridge; |
555 | int enabled; /**< whether the AGP bus as been enabled */ |
518 | int enabled; /**< whether the AGP bus as been enabled */ |
556 | int acquired; /**< whether the AGP device has been acquired */ |
519 | int acquired; /**< whether the AGP device has been acquired */ |
557 | unsigned long base; |
520 | unsigned long base; |
558 | int agp_mtrr; |
521 | int agp_mtrr; |
559 | int cant_use_aperture; |
522 | int cant_use_aperture; |
560 | unsigned long page_mask; |
523 | unsigned long page_mask; |
561 | }; |
524 | }; |
562 | 525 | ||
563 | /** |
526 | /** |
564 | * Scatter-gather memory. |
527 | * Scatter-gather memory. |
565 | */ |
528 | */ |
566 | struct drm_sg_mem { |
529 | struct drm_sg_mem { |
567 | unsigned long handle; |
530 | unsigned long handle; |
568 | void *virtual; |
531 | void *virtual; |
569 | int pages; |
532 | int pages; |
570 | struct page **pagelist; |
533 | struct page **pagelist; |
571 | dma_addr_t *busaddr; |
534 | dma_addr_t *busaddr; |
572 | }; |
535 | }; |
573 | 536 | ||
574 | struct drm_sigdata { |
537 | struct drm_sigdata { |
575 | int context; |
538 | int context; |
576 | struct drm_hw_lock *lock; |
539 | struct drm_hw_lock *lock; |
577 | }; |
540 | }; |
578 | 541 | ||
579 | #endif |
542 | #endif |
580 | - | ||
581 | 543 | ||
582 | /** |
544 | /** |
583 | * Kernel side of a mapping |
545 | * Kernel side of a mapping |
584 | */ |
546 | */ |
585 | struct drm_local_map { |
547 | struct drm_local_map { |
586 | resource_size_t offset; /**< Requested physical address (0 for SAREA)*/ |
548 | resource_size_t offset; /**< Requested physical address (0 for SAREA)*/ |
587 | unsigned long size; /**< Requested physical size (bytes) */ |
549 | unsigned long size; /**< Requested physical size (bytes) */ |
588 | enum drm_map_type type; /**< Type of memory to map */ |
550 | enum drm_map_type type; /**< Type of memory to map */ |
589 | enum drm_map_flags flags; /**< Flags */ |
551 | enum drm_map_flags flags; /**< Flags */ |
590 | void *handle; /**< User-space: "Handle" to pass to mmap() */ |
552 | void *handle; /**< User-space: "Handle" to pass to mmap() */ |
591 | /**< Kernel-space: kernel-virtual address */ |
553 | /**< Kernel-space: kernel-virtual address */ |
592 | int mtrr; /**< MTRR slot used */ |
554 | int mtrr; /**< MTRR slot used */ |
593 | }; |
555 | }; |
594 | 556 | ||
595 | typedef struct drm_local_map drm_local_map_t; |
557 | typedef struct drm_local_map drm_local_map_t; |
596 | 558 | ||
597 | /** |
559 | /** |
598 | * Mappings list |
560 | * Mappings list |
599 | */ |
561 | */ |
600 | struct drm_map_list { |
562 | struct drm_map_list { |
601 | struct list_head head; /**< list head */ |
563 | struct list_head head; /**< list head */ |
602 | struct drm_hash_item hash; |
564 | struct drm_hash_item hash; |
603 | struct drm_local_map *map; /**< mapping */ |
565 | struct drm_local_map *map; /**< mapping */ |
604 | uint64_t user_token; |
566 | uint64_t user_token; |
605 | struct drm_master *master; |
567 | struct drm_master *master; |
606 | }; |
568 | }; |
607 | - | ||
608 | /** |
- | |
609 | * Context handle list |
- | |
610 | */ |
- | |
611 | struct drm_ctx_list { |
- | |
612 | struct list_head head; /**< list head */ |
- | |
613 | drm_context_t handle; /**< context handle */ |
- | |
614 | struct drm_file *tag; /**< associated fd private data */ |
- | |
615 | }; |
- | |
616 | 569 | ||
617 | /* location of GART table */ |
570 | /* location of GART table */ |
618 | #define DRM_ATI_GART_MAIN 1 |
571 | #define DRM_ATI_GART_MAIN 1 |
619 | #define DRM_ATI_GART_FB 2 |
572 | #define DRM_ATI_GART_FB 2 |
620 | 573 | ||
621 | #define DRM_ATI_GART_PCI 1 |
574 | #define DRM_ATI_GART_PCI 1 |
622 | #define DRM_ATI_GART_PCIE 2 |
575 | #define DRM_ATI_GART_PCIE 2 |
623 | #define DRM_ATI_GART_IGP 3 |
576 | #define DRM_ATI_GART_IGP 3 |
624 | 577 | ||
625 | struct drm_ati_pcigart_info { |
578 | struct drm_ati_pcigart_info { |
626 | int gart_table_location; |
579 | int gart_table_location; |
627 | int gart_reg_if; |
580 | int gart_reg_if; |
628 | void *addr; |
581 | void *addr; |
629 | dma_addr_t bus_addr; |
582 | dma_addr_t bus_addr; |
630 | dma_addr_t table_mask; |
583 | dma_addr_t table_mask; |
631 | struct drm_dma_handle *table_handle; |
584 | struct drm_dma_handle *table_handle; |
632 | struct drm_local_map mapping; |
585 | struct drm_local_map mapping; |
633 | int table_size; |
586 | int table_size; |
634 | }; |
587 | }; |
635 | 588 | ||
636 | /** |
589 | /** |
637 | * This structure defines the drm_mm memory object, which will be used by the |
590 | * This structure defines the drm_mm memory object, which will be used by the |
638 | * DRM for its buffer objects. |
591 | * DRM for its buffer objects. |
639 | */ |
592 | */ |
640 | struct drm_gem_object { |
593 | struct drm_gem_object { |
641 | /** Reference count of this object */ |
594 | /** Reference count of this object */ |
642 | struct kref refcount; |
595 | struct kref refcount; |
643 | 596 | ||
644 | /** |
597 | /** |
645 | * handle_count - gem file_priv handle count of this object |
598 | * handle_count - gem file_priv handle count of this object |
646 | * |
599 | * |
647 | * Each handle also holds a reference. Note that when the handle_count |
600 | * Each handle also holds a reference. Note that when the handle_count |
648 | * drops to 0 any global names (e.g. the id in the flink namespace) will |
601 | * drops to 0 any global names (e.g. the id in the flink namespace) will |
649 | * be cleared. |
602 | * be cleared. |
650 | * |
603 | * |
651 | * Protected by dev->object_name_lock. |
604 | * Protected by dev->object_name_lock. |
652 | * */ |
605 | * */ |
653 | unsigned handle_count; |
606 | unsigned handle_count; |
654 | 607 | ||
655 | /** Related drm device */ |
608 | /** Related drm device */ |
656 | struct drm_device *dev; |
609 | struct drm_device *dev; |
657 | 610 | ||
658 | /** File representing the shmem storage */ |
611 | /** File representing the shmem storage */ |
659 | struct file *filp; |
612 | struct file *filp; |
660 | 613 | ||
661 | /* Mapping info for this object */ |
614 | /* Mapping info for this object */ |
662 | struct drm_vma_offset_node vma_node; |
615 | struct drm_vma_offset_node vma_node; |
663 | 616 | ||
664 | /** |
617 | /** |
665 | * Size of the object, in bytes. Immutable over the object's |
618 | * Size of the object, in bytes. Immutable over the object's |
666 | * lifetime. |
619 | * lifetime. |
667 | */ |
620 | */ |
668 | size_t size; |
621 | size_t size; |
669 | 622 | ||
670 | /** |
623 | /** |
671 | * Global name for this object, starts at 1. 0 means unnamed. |
624 | * Global name for this object, starts at 1. 0 means unnamed. |
672 | * Access is covered by the object_name_lock in the related drm_device |
625 | * Access is covered by the object_name_lock in the related drm_device |
673 | */ |
626 | */ |
674 | int name; |
627 | int name; |
675 | 628 | ||
676 | /** |
629 | /** |
677 | * Memory domains. These monitor which caches contain read/write data |
630 | * Memory domains. These monitor which caches contain read/write data |
678 | * related to the object. When transitioning from one set of domains |
631 | * related to the object. When transitioning from one set of domains |
679 | * to another, the driver is called to ensure that caches are suitably |
632 | * to another, the driver is called to ensure that caches are suitably |
680 | * flushed and invalidated |
633 | * flushed and invalidated |
681 | */ |
634 | */ |
682 | uint32_t read_domains; |
635 | uint32_t read_domains; |
683 | uint32_t write_domain; |
636 | uint32_t write_domain; |
684 | 637 | ||
685 | /** |
638 | /** |
686 | * While validating an exec operation, the |
639 | * While validating an exec operation, the |
687 | * new read/write domain values are computed here. |
640 | * new read/write domain values are computed here. |
688 | * They will be transferred to the above values |
641 | * They will be transferred to the above values |
689 | * at the point that any cache flushing occurs |
642 | * at the point that any cache flushing occurs |
690 | */ |
643 | */ |
691 | uint32_t pending_read_domains; |
644 | uint32_t pending_read_domains; |
692 | uint32_t pending_write_domain; |
645 | uint32_t pending_write_domain; |
- | 646 | ||
- | 647 | /** |
|
- | 648 | * dma_buf - dma buf associated with this GEM object |
|
- | 649 | * |
|
- | 650 | * Pointer to the dma-buf associated with this gem object (either |
|
- | 651 | * through importing or exporting). We break the resulting reference |
|
- | 652 | * loop when the last gem handle for this object is released. |
|
- | 653 | * |
|
- | 654 | * Protected by obj->object_name_lock |
|
- | 655 | */ |
|
693 | 656 | struct dma_buf *dma_buf; |
|
694 | 657 | ||
695 | }; |
658 | }; |
696 | 659 | ||
697 | #include |
660 | #include |
- | 661 | ||
698 | 662 | /** |
|
- | 663 | * struct drm_master - drm master structure |
|
- | 664 | * |
|
- | 665 | * @refcount: Refcount for this master object. |
|
- | 666 | * @minor: Link back to minor char device we are master for. Immutable. |
|
- | 667 | * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex. |
|
- | 668 | * @unique_len: Length of unique field. Protected by drm_global_mutex. |
|
- | 669 | * @unique_size: Amount allocated. Protected by drm_global_mutex. |
|
- | 670 | * @magiclist: Hash of used authentication tokens. Protected by struct_mutex. |
|
- | 671 | * @magicfree: List of used authentication tokens. Protected by struct_mutex. |
|
- | 672 | * @lock: DRI lock information. |
|
- | 673 | * @driver_priv: Pointer to driver-private information. |
|
699 | /* per-master structure */ |
674 | */ |
700 | struct drm_master { |
- | |
701 | 675 | struct drm_master { |
|
702 | struct kref refcount; /* refcount for this master */ |
- | |
703 | - | ||
704 | struct list_head head; /**< each minor contains a list of masters */ |
676 | struct kref refcount; |
705 | struct drm_minor *minor; /**< link back to minor we are a master for */ |
- | |
706 | 677 | struct drm_minor *minor; |
|
707 | char *unique; /**< Unique identifier: e.g., busid */ |
678 | char *unique; |
708 | int unique_len; /**< Length of unique field */ |
679 | int unique_len; |
709 | int unique_size; /**< amount allocated */ |
- | |
710 | - | ||
711 | int blocked; /**< Blocked due to VC switch? */ |
- | |
712 | - | ||
713 | /** \name Authentication */ |
- | |
714 | /*@{ */ |
680 | int unique_size; |
715 | // struct drm_open_hash magiclist; |
681 | // struct drm_open_hash magiclist; |
716 | // struct list_head magicfree; |
- | |
717 | /*@} */ |
- | |
718 | 682 | // struct list_head magicfree; |
|
719 | // struct drm_lock_data lock; /**< Information on hardware lock */ |
- | |
720 | 683 | // struct drm_lock_data lock; |
|
721 | void *driver_priv; /**< Private structure for driver to use */ |
684 | void *driver_priv; |
722 | }; |
- | |
723 | - | ||
724 | #if 0 |
685 | }; |
725 | 686 | ||
726 | /* Size of ringbuffer for vblank timestamps. Just double-buffer |
687 | /* Size of ringbuffer for vblank timestamps. Just double-buffer |
727 | * in initial implementation. |
688 | * in initial implementation. |
728 | */ |
689 | */ |
729 | #define DRM_VBLANKTIME_RBSIZE 2 |
690 | #define DRM_VBLANKTIME_RBSIZE 2 |
730 | 691 | ||
731 | /* Flags and return codes for get_vblank_timestamp() driver function. */ |
692 | /* Flags and return codes for get_vblank_timestamp() driver function. */ |
732 | #define DRM_CALLED_FROM_VBLIRQ 1 |
693 | #define DRM_CALLED_FROM_VBLIRQ 1 |
733 | #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) |
694 | #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) |
734 | #define DRM_VBLANKTIME_INVBL (1 << 1) |
695 | #define DRM_VBLANKTIME_INVBL (1 << 1) |
735 | 696 | ||
736 | /* get_scanout_position() return flags */ |
697 | /* get_scanout_position() return flags */ |
737 | #define DRM_SCANOUTPOS_VALID (1 << 0) |
698 | #define DRM_SCANOUTPOS_VALID (1 << 0) |
738 | #define DRM_SCANOUTPOS_INVBL (1 << 1) |
699 | #define DRM_SCANOUTPOS_INVBL (1 << 1) |
739 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
700 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
740 | 701 | ||
741 | struct drm_bus { |
702 | struct drm_bus { |
742 | int bus_type; |
- | |
743 | int (*get_irq)(struct drm_device *dev); |
- | |
744 | const char *(*get_name)(struct drm_device *dev); |
- | |
745 | int (*set_busid)(struct drm_device *dev, struct drm_master *master); |
703 | int (*set_busid)(struct drm_device *dev, struct drm_master *master); |
746 | int (*set_unique)(struct drm_device *dev, struct drm_master *master, |
- | |
747 | struct drm_unique *unique); |
- | |
748 | int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p); |
- | |
749 | }; |
704 | }; |
750 | #endif |
- | |
751 | - | ||
752 | #define DRM_IRQ_ARGS int irq, void *arg |
- | |
753 | 705 | ||
754 | /** |
706 | /** |
755 | * DRM driver structure. This structure represent the common code for |
707 | * DRM driver structure. This structure represent the common code for |
756 | * a family of cards. There will one drm_device for each card present |
708 | * a family of cards. There will one drm_device for each card present |
757 | * in this family |
709 | * in this family |
758 | */ |
710 | */ |
759 | struct drm_driver { |
711 | struct drm_driver { |
760 | int (*load) (struct drm_device *, unsigned long flags); |
712 | int (*load) (struct drm_device *, unsigned long flags); |
761 | int (*open) (struct drm_device *, struct drm_file *); |
713 | int (*open) (struct drm_device *, struct drm_file *); |
762 | 714 | ||
763 | /** |
715 | /** |
764 | * get_vblank_counter - get raw hardware vblank counter |
716 | * get_vblank_counter - get raw hardware vblank counter |
765 | * @dev: DRM device |
717 | * @dev: DRM device |
766 | * @crtc: counter to fetch |
718 | * @crtc: counter to fetch |
767 | * |
719 | * |
768 | * Driver callback for fetching a raw hardware vblank counter for @crtc. |
720 | * Driver callback for fetching a raw hardware vblank counter for @crtc. |
769 | * If a device doesn't have a hardware counter, the driver can simply |
721 | * If a device doesn't have a hardware counter, the driver can simply |
770 | * return the value of drm_vblank_count. The DRM core will account for |
722 | * return the value of drm_vblank_count. The DRM core will account for |
771 | * missed vblank events while interrupts where disabled based on system |
723 | * missed vblank events while interrupts where disabled based on system |
772 | * timestamps. |
724 | * timestamps. |
773 | * |
725 | * |
774 | * Wraparound handling and loss of events due to modesetting is dealt |
726 | * Wraparound handling and loss of events due to modesetting is dealt |
775 | * with in the DRM core code. |
727 | * with in the DRM core code. |
776 | * |
728 | * |
777 | * RETURNS |
729 | * RETURNS |
778 | * Raw vblank counter value. |
730 | * Raw vblank counter value. |
779 | */ |
731 | */ |
780 | u32 (*get_vblank_counter) (struct drm_device *dev, int crtc); |
732 | u32 (*get_vblank_counter) (struct drm_device *dev, int crtc); |
781 | 733 | ||
782 | /** |
734 | /** |
783 | * enable_vblank - enable vblank interrupt events |
735 | * enable_vblank - enable vblank interrupt events |
784 | * @dev: DRM device |
736 | * @dev: DRM device |
785 | * @crtc: which irq to enable |
737 | * @crtc: which irq to enable |
786 | * |
738 | * |
787 | * Enable vblank interrupts for @crtc. If the device doesn't have |
739 | * Enable vblank interrupts for @crtc. If the device doesn't have |
788 | * a hardware vblank counter, this routine should be a no-op, since |
740 | * a hardware vblank counter, this routine should be a no-op, since |
789 | * interrupts will have to stay on to keep the count accurate. |
741 | * interrupts will have to stay on to keep the count accurate. |
790 | * |
742 | * |
791 | * RETURNS |
743 | * RETURNS |
792 | * Zero on success, appropriate errno if the given @crtc's vblank |
744 | * Zero on success, appropriate errno if the given @crtc's vblank |
793 | * interrupt cannot be enabled. |
745 | * interrupt cannot be enabled. |
794 | */ |
746 | */ |
795 | int (*enable_vblank) (struct drm_device *dev, int crtc); |
747 | int (*enable_vblank) (struct drm_device *dev, int crtc); |
796 | 748 | ||
797 | /** |
749 | /** |
798 | * disable_vblank - disable vblank interrupt events |
750 | * disable_vblank - disable vblank interrupt events |
799 | * @dev: DRM device |
751 | * @dev: DRM device |
800 | * @crtc: which irq to enable |
752 | * @crtc: which irq to enable |
801 | * |
753 | * |
802 | * Disable vblank interrupts for @crtc. If the device doesn't have |
754 | * Disable vblank interrupts for @crtc. If the device doesn't have |
803 | * a hardware vblank counter, this routine should be a no-op, since |
755 | * a hardware vblank counter, this routine should be a no-op, since |
804 | * interrupts will have to stay on to keep the count accurate. |
756 | * interrupts will have to stay on to keep the count accurate. |
805 | */ |
757 | */ |
806 | void (*disable_vblank) (struct drm_device *dev, int crtc); |
758 | void (*disable_vblank) (struct drm_device *dev, int crtc); |
807 | /** |
759 | /** |
808 | * Called by vblank timestamping code. |
760 | * Called by vblank timestamping code. |
809 | * |
761 | * |
810 | * Return the current display scanout position from a crtc, and an |
762 | * Return the current display scanout position from a crtc, and an |
811 | * optional accurate ktime_get timestamp of when position was measured. |
763 | * optional accurate ktime_get timestamp of when position was measured. |
812 | * |
764 | * |
813 | * \param dev DRM device. |
765 | * \param dev DRM device. |
814 | * \param crtc Id of the crtc to query. |
766 | * \param crtc Id of the crtc to query. |
815 | * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0). |
767 | * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0). |
816 | * \param *vpos Target location for current vertical scanout position. |
768 | * \param *vpos Target location for current vertical scanout position. |
817 | * \param *hpos Target location for current horizontal scanout position. |
769 | * \param *hpos Target location for current horizontal scanout position. |
818 | * \param *stime Target location for timestamp taken immediately before |
770 | * \param *stime Target location for timestamp taken immediately before |
819 | * scanout position query. Can be NULL to skip timestamp. |
771 | * scanout position query. Can be NULL to skip timestamp. |
820 | * \param *etime Target location for timestamp taken immediately after |
772 | * \param *etime Target location for timestamp taken immediately after |
821 | * scanout position query. Can be NULL to skip timestamp. |
773 | * scanout position query. Can be NULL to skip timestamp. |
822 | * |
774 | * |
823 | * Returns vpos as a positive number while in active scanout area. |
775 | * Returns vpos as a positive number while in active scanout area. |
824 | * Returns vpos as a negative number inside vblank, counting the number |
776 | * Returns vpos as a negative number inside vblank, counting the number |
825 | * of scanlines to go until end of vblank, e.g., -1 means "one scanline |
777 | * of scanlines to go until end of vblank, e.g., -1 means "one scanline |
826 | * until start of active scanout / end of vblank." |
778 | * until start of active scanout / end of vblank." |
827 | * |
779 | * |
828 | * \return Flags, or'ed together as follows: |
780 | * \return Flags, or'ed together as follows: |
829 | * |
781 | * |
830 | * DRM_SCANOUTPOS_VALID = Query successful. |
782 | * DRM_SCANOUTPOS_VALID = Query successful. |
831 | * DRM_SCANOUTPOS_INVBL = Inside vblank. |
783 | * DRM_SCANOUTPOS_INVBL = Inside vblank. |
832 | * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of |
784 | * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of |
833 | * this flag means that returned position may be offset by a constant |
785 | * this flag means that returned position may be offset by a constant |
834 | * but unknown small number of scanlines wrt. real scanout position. |
786 | * but unknown small number of scanlines wrt. real scanout position. |
835 | * |
787 | * |
836 | */ |
788 | */ |
837 | int (*get_scanout_position) (struct drm_device *dev, int crtc, |
789 | int (*get_scanout_position) (struct drm_device *dev, int crtc, |
838 | unsigned int flags, |
790 | unsigned int flags, |
839 | int *vpos, int *hpos, void *stime, |
791 | int *vpos, int *hpos, void *stime, |
840 | void *etime); |
792 | void *etime); |
841 | 793 | ||
842 | /** |
794 | /** |
843 | * Called by \c drm_get_last_vbltimestamp. Should return a precise |
795 | * Called by \c drm_get_last_vbltimestamp. Should return a precise |
844 | * timestamp when the most recent VBLANK interval ended or will end. |
796 | * timestamp when the most recent VBLANK interval ended or will end. |
845 | * |
797 | * |
846 | * Specifically, the timestamp in @vblank_time should correspond as |
798 | * Specifically, the timestamp in @vblank_time should correspond as |
847 | * closely as possible to the time when the first video scanline of |
799 | * closely as possible to the time when the first video scanline of |
848 | * the video frame after the end of VBLANK will start scanning out, |
800 | * the video frame after the end of VBLANK will start scanning out, |
849 | * the time immediately after end of the VBLANK interval. If the |
801 | * the time immediately after end of the VBLANK interval. If the |
850 | * @crtc is currently inside VBLANK, this will be a time in the future. |
802 | * @crtc is currently inside VBLANK, this will be a time in the future. |
851 | * If the @crtc is currently scanning out a frame, this will be the |
803 | * If the @crtc is currently scanning out a frame, this will be the |
852 | * past start time of the current scanout. This is meant to adhere |
804 | * past start time of the current scanout. This is meant to adhere |
853 | * to the OpenML OML_sync_control extension specification. |
805 | * to the OpenML OML_sync_control extension specification. |
854 | * |
806 | * |
855 | * \param dev dev DRM device handle. |
807 | * \param dev dev DRM device handle. |
856 | * \param crtc crtc for which timestamp should be returned. |
808 | * \param crtc crtc for which timestamp should be returned. |
857 | * \param *max_error Maximum allowable timestamp error in nanoseconds. |
809 | * \param *max_error Maximum allowable timestamp error in nanoseconds. |
858 | * Implementation should strive to provide timestamp |
810 | * Implementation should strive to provide timestamp |
859 | * with an error of at most *max_error nanoseconds. |
811 | * with an error of at most *max_error nanoseconds. |
860 | * Returns true upper bound on error for timestamp. |
812 | * Returns true upper bound on error for timestamp. |
861 | * \param *vblank_time Target location for returned vblank timestamp. |
813 | * \param *vblank_time Target location for returned vblank timestamp. |
862 | * \param flags 0 = Defaults, no special treatment needed. |
814 | * \param flags 0 = Defaults, no special treatment needed. |
863 | * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank |
815 | * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank |
864 | * irq handler. Some drivers need to apply some workarounds |
816 | * irq handler. Some drivers need to apply some workarounds |
865 | * for gpu-specific vblank irq quirks if flag is set. |
817 | * for gpu-specific vblank irq quirks if flag is set. |
866 | * |
818 | * |
867 | * \returns |
819 | * \returns |
868 | * Zero if timestamping isn't supported in current display mode or a |
820 | * Zero if timestamping isn't supported in current display mode or a |
869 | * negative number on failure. A positive status code on success, |
821 | * negative number on failure. A positive status code on success, |
870 | * which describes how the vblank_time timestamp was computed. |
822 | * which describes how the vblank_time timestamp was computed. |
871 | */ |
823 | */ |
872 | int (*get_vblank_timestamp) (struct drm_device *dev, int crtc, |
824 | int (*get_vblank_timestamp) (struct drm_device *dev, int crtc, |
873 | int *max_error, |
825 | int *max_error, |
874 | struct timeval *vblank_time, |
826 | struct timeval *vblank_time, |
875 | unsigned flags); |
827 | unsigned flags); |
876 | 828 | ||
877 | /* these have to be filled in */ |
829 | /* these have to be filled in */ |
878 | 830 | ||
879 | irqreturn_t(*irq_handler) (DRM_IRQ_ARGS); |
831 | irqreturn_t(*irq_handler) (int irq, void *arg); |
880 | void (*irq_preinstall) (struct drm_device *dev); |
832 | void (*irq_preinstall) (struct drm_device *dev); |
881 | int (*irq_postinstall) (struct drm_device *dev); |
833 | int (*irq_postinstall) (struct drm_device *dev); |
882 | void (*irq_uninstall) (struct drm_device *dev); |
834 | void (*irq_uninstall) (struct drm_device *dev); |
883 | 835 | ||
884 | /** |
836 | /** |
885 | * Driver-specific constructor for drm_gem_objects, to set up |
837 | * Driver-specific constructor for drm_gem_objects, to set up |
886 | * obj->driver_private. |
838 | * obj->driver_private. |
887 | * |
839 | * |
888 | * Returns 0 on success. |
840 | * Returns 0 on success. |
889 | */ |
841 | */ |
890 | void (*gem_free_object) (struct drm_gem_object *obj); |
842 | void (*gem_free_object) (struct drm_gem_object *obj); |
891 | int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); |
843 | int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); |
892 | void (*gem_close_object) (struct drm_gem_object *, struct drm_file *); |
844 | void (*gem_close_object) (struct drm_gem_object *, struct drm_file *); |
893 | u32 driver_features; |
845 | u32 driver_features; |
- | 846 | int dev_priv_size; |
|
894 | }; |
847 | }; |
895 | 848 | ||
896 | #define DRM_MINOR_UNASSIGNED 0 |
849 | enum drm_minor_type { |
897 | #define DRM_MINOR_LEGACY 1 |
850 | DRM_MINOR_LEGACY, |
898 | #define DRM_MINOR_CONTROL 2 |
851 | DRM_MINOR_CONTROL, |
- | 852 | DRM_MINOR_RENDER, |
|
- | 853 | DRM_MINOR_CNT, |
|
899 | #define DRM_MINOR_RENDER 3 |
854 | }; |
900 | 855 | ||
901 | /** |
856 | /** |
902 | * Info file list entry. This structure represents a debugfs or proc file to |
857 | * Info file list entry. This structure represents a debugfs or proc file to |
903 | * be created by the drm core |
858 | * be created by the drm core |
904 | */ |
859 | */ |
905 | struct drm_info_list { |
860 | struct drm_info_list { |
906 | const char *name; /** file name */ |
861 | const char *name; /** file name */ |
907 | // int (*show)(struct seq_file*, void*); /** show callback */ |
862 | // int (*show)(struct seq_file*, void*); /** show callback */ |
908 | u32 driver_features; /**< Required driver features for this entry */ |
863 | u32 driver_features; /**< Required driver features for this entry */ |
909 | void *data; |
864 | void *data; |
910 | }; |
865 | }; |
911 | 866 | ||
912 | /** |
867 | /** |
913 | * debugfs node structure. This structure represents a debugfs file. |
868 | * debugfs node structure. This structure represents a debugfs file. |
914 | */ |
869 | */ |
915 | struct drm_info_node { |
870 | struct drm_info_node { |
916 | struct list_head list; |
871 | struct list_head list; |
917 | struct drm_minor *minor; |
872 | struct drm_minor *minor; |
918 | const struct drm_info_list *info_ent; |
873 | const struct drm_info_list *info_ent; |
919 | struct dentry *dent; |
874 | struct dentry *dent; |
920 | }; |
875 | }; |
921 | 876 | ||
922 | /** |
877 | /** |
923 | * DRM minor structure. This structure represents a drm minor number. |
878 | * DRM minor structure. This structure represents a drm minor number. |
924 | */ |
879 | */ |
925 | struct drm_minor { |
880 | struct drm_minor { |
926 | int index; /**< Minor device number */ |
881 | int index; /**< Minor device number */ |
927 | int type; /**< Control or render */ |
882 | int type; /**< Control or render */ |
928 | // dev_t device; /**< Device number for mknod */ |
- | |
929 | // struct device kdev; /**< Linux device */ |
883 | // struct device kdev; /**< Linux device */ |
930 | struct drm_device *dev; |
884 | struct drm_device *dev; |
931 | - | ||
932 | // struct proc_dir_entry *proc_root; /**< proc directory entry */ |
- | |
933 | // struct drm_info_node proc_nodes; |
885 | |
934 | // struct dentry *debugfs_root; |
- | |
935 | // struct drm_info_node debugfs_nodes; |
886 | struct dentry *debugfs_root; |
936 | - | ||
937 | struct drm_master *master; /* currently active master for this node */ |
887 | |
938 | // struct list_head master_list; |
888 | struct list_head debugfs_list; |
939 | // struct drm_mode_group mode_group; |
- | |
940 | }; |
889 | struct mutex debugfs_lock; /* Protects debugfs_list. */ |
941 | 890 | ||
942 | /* mode specified on the command line */ |
891 | /* currently active master for this node. Protected by master_mutex */ |
943 | struct drm_cmdline_mode { |
- | |
944 | bool specified; |
- | |
945 | bool refresh_specified; |
- | |
946 | bool bpp_specified; |
- | |
947 | int xres, yres; |
- | |
948 | int bpp; |
- | |
949 | int refresh; |
- | |
950 | bool rb; |
- | |
951 | bool interlace; |
- | |
952 | bool cvt; |
- | |
953 | bool margins; |
892 | struct drm_master *master; |
954 | enum drm_connector_force force; |
893 | struct drm_mode_group mode_group; |
955 | }; |
894 | }; |
956 | 895 | ||
957 | 896 | ||
958 | 897 | ||
959 | /** |
898 | /** |
960 | * DRM device structure. This structure represent a complete card that |
899 | * DRM device structure. This structure represent a complete card that |
961 | * may contain multiple heads. |
900 | * may contain multiple heads. |
962 | */ |
901 | */ |
963 | struct drm_device { |
902 | struct drm_device { |
964 | struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ |
903 | struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ |
965 | char *devname; /**< For /proc/interrupts */ |
- | |
966 | int if_version; /**< Highest interface version set */ |
904 | int if_version; /**< Highest interface version set */ |
- | 905 | ||
- | 906 | struct device *dev; /**< Device structure of bus-device */ |
|
- | 907 | struct drm_driver *driver; /**< DRM driver managing the device */ |
|
- | 908 | void *dev_private; /**< DRM driver private data */ |
|
- | 909 | struct drm_minor *primary; /**< Primary node */ |
|
967 | 910 | atomic_t unplugged; /**< Flag whether dev is dead */ |
|
968 | /** \name Locks */ |
911 | /** \name Locks */ |
969 | /*@{ */ |
- | |
970 | spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ |
912 | /*@{ */ |
- | 913 | struct mutex struct_mutex; /**< For others */ |
|
971 | struct mutex struct_mutex; /**< For others */ |
914 | struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */ |
972 | /*@} */ |
915 | /*@} */ |
973 | 916 | ||
974 | /** \name Usage Counters */ |
917 | /** \name Usage Counters */ |
975 | /*@{ */ |
918 | /*@{ */ |
976 | int open_count; /**< Outstanding files open */ |
919 | int open_count; /**< Outstanding files open, protected by drm_global_mutex. */ |
- | 920 | spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */ |
|
977 | int buf_use; /**< Buffers in use -- cannot alloc */ |
921 | int buf_use; /**< Buffers in use -- cannot alloc */ |
978 | atomic_t buf_alloc; /**< Buffer allocation in progress */ |
922 | atomic_t buf_alloc; /**< Buffer allocation in progress */ |
979 | /*@} */ |
923 | /*@} */ |
980 | 924 | ||
981 | struct list_head filelist; |
925 | struct list_head filelist; |
982 | 926 | ||
983 | /** \name Memory management */ |
927 | /** \name Memory management */ |
984 | /*@{ */ |
928 | /*@{ */ |
985 | struct list_head maplist; /**< Linked list of regions */ |
929 | struct list_head maplist; /**< Linked list of regions */ |
986 | 930 | ||
987 | /** \name Context handle management */ |
931 | /** \name Context handle management */ |
988 | /*@{ */ |
932 | /*@{ */ |
989 | struct list_head ctxlist; /**< Linked list of context handles */ |
933 | struct list_head ctxlist; /**< Linked list of context handles */ |
990 | struct mutex ctxlist_mutex; /**< For ctxlist */ |
934 | struct mutex ctxlist_mutex; /**< For ctxlist */ |
991 | 935 | ||
992 | struct idr ctx_idr; |
936 | struct idr ctx_idr; |
993 | 937 | ||
994 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
938 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
995 | 939 | ||
996 | /*@} */ |
940 | /*@} */ |
997 | 941 | ||
998 | /** \name DMA support */ |
942 | /** \name DMA support */ |
999 | /*@{ */ |
943 | /*@{ */ |
1000 | // struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
944 | // struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
1001 | /*@} */ |
945 | /*@} */ |
1002 | 946 | ||
1003 | /** \name Context support */ |
947 | /** \name Context support */ |
1004 | /*@{ */ |
948 | /*@{ */ |
1005 | bool irq_enabled; /**< True if irq handler is enabled */ |
949 | bool irq_enabled; /**< True if irq handler is enabled */ |
- | 950 | int irq; |
|
- | 951 | ||
1006 | __volatile__ long context_flag; /**< Context swapping flag */ |
952 | __volatile__ long context_flag; /**< Context swapping flag */ |
1007 | int last_context; /**< Last current context */ |
953 | int last_context; /**< Last current context */ |
1008 | /*@} */ |
954 | /*@} */ |
1009 | 955 | ||
1010 | /** \name VBLANK IRQ support */ |
956 | /** \name VBLANK IRQ support */ |
1011 | /*@{ */ |
957 | /*@{ */ |
1012 | 958 | ||
1013 | /* |
959 | /* |
1014 | * At load time, disabling the vblank interrupt won't be allowed since |
960 | * At load time, disabling the vblank interrupt won't be allowed since |
1015 | * old clients may not call the modeset ioctl and therefore misbehave. |
961 | * old clients may not call the modeset ioctl and therefore misbehave. |
1016 | * Once the modeset ioctl *has* been called though, we can safely |
962 | * Once the modeset ioctl *has* been called though, we can safely |
1017 | * disable them when unused. |
963 | * disable them when unused. |
1018 | */ |
964 | */ |
1019 | bool vblank_disable_allowed; |
965 | bool vblank_disable_allowed; |
- | 966 | ||
- | 967 | /* array of size num_crtcs */ |
|
- | 968 | struct drm_vblank_crtc *vblank; |
|
- | 969 | ||
- | 970 | spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ |
|
1020 | 971 | spinlock_t vbl_lock; |
|
1021 | 972 | ||
1022 | u32 max_vblank_count; /**< size of vblank counter register */ |
973 | u32 max_vblank_count; /**< size of vblank counter register */ |
1023 | 974 | ||
1024 | /** |
975 | /** |
1025 | * List of events |
976 | * List of events |
1026 | */ |
977 | */ |
1027 | struct list_head vblank_event_list; |
978 | struct list_head vblank_event_list; |
1028 | spinlock_t event_lock; |
979 | spinlock_t event_lock; |
1029 | 980 | ||
1030 | /*@} */ |
981 | /*@} */ |
1031 | 982 | ||
1032 | // struct drm_agp_head *agp; /**< AGP data */ |
983 | // struct drm_agp_head *agp; /**< AGP data */ |
1033 | - | ||
1034 | struct device *dev; /**< Device structure */ |
984 | |
1035 | struct pci_dev *pdev; /**< PCI device structure */ |
- | |
1036 | int pci_vendor; /**< PCI vendor id */ |
- | |
- | 985 | struct pci_dev *pdev; /**< PCI device structure */ |
|
1037 | int pci_device; /**< PCI device id */ |
986 | |
1038 | unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
- | |
1039 | void *dev_private; /**< device private data */ |
- | |
1040 | struct address_space *dev_mapping; |
- | |
1041 | // struct drm_sigdata sigdata; /**< For block_all_signals */ |
- | |
1042 | // sigset_t sigmask; |
987 | unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
1043 | - | ||
1044 | struct drm_driver *driver; |
- | |
1045 | // struct drm_local_map *agp_buffer_map; |
- | |
1046 | // unsigned int agp_buffer_token; |
- | |
1047 | // struct drm_minor *control; /**< Control node for card */ |
- | |
1048 | struct drm_minor *primary; /**< render type primary screen head */ |
988 | |
1049 | 989 | ||
1050 | struct drm_mode_config mode_config; /**< Current mode config */ |
990 | struct drm_mode_config mode_config; /**< Current mode config */ |
1051 | 991 | ||
1052 | /** \name GEM information */ |
992 | /** \name GEM information */ |
1053 | /*@{ */ |
993 | /*@{ */ |
1054 | struct mutex object_name_lock; |
994 | struct mutex object_name_lock; |
1055 | struct idr object_name_idr; |
995 | struct idr object_name_idr; |
1056 | struct drm_vma_offset_manager *vma_offset_manager; |
996 | struct drm_vma_offset_manager *vma_offset_manager; |
1057 | /*@} */ |
997 | /*@} */ |
1058 | int switch_power_state; |
998 | int switch_power_state; |
1059 | - | ||
1060 | atomic_t unplugged; /* device has been unplugged or gone away */ |
- | |
1061 | }; |
999 | }; |
1062 | 1000 | ||
1063 | #define DRM_SWITCH_POWER_ON 0 |
1001 | #define DRM_SWITCH_POWER_ON 0 |
1064 | #define DRM_SWITCH_POWER_OFF 1 |
1002 | #define DRM_SWITCH_POWER_OFF 1 |
1065 | #define DRM_SWITCH_POWER_CHANGING 2 |
1003 | #define DRM_SWITCH_POWER_CHANGING 2 |
1066 | #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 |
1004 | #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 |
1067 | 1005 | ||
1068 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
1006 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
1069 | int feature) |
1007 | int feature) |
1070 | { |
1008 | { |
1071 | return ((dev->driver->driver_features & feature) ? 1 : 0); |
1009 | return ((dev->driver->driver_features & feature) ? 1 : 0); |
1072 | } |
1010 | } |
1073 | - | ||
1074 | static inline int drm_dev_to_irq(struct drm_device *dev) |
- | |
1075 | { |
- | |
1076 | return dev->pdev->irq; |
- | |
1077 | } |
- | |
1078 | 1011 | ||
1079 | static inline void drm_device_set_unplugged(struct drm_device *dev) |
1012 | static inline void drm_device_set_unplugged(struct drm_device *dev) |
1080 | { |
1013 | { |
1081 | smp_wmb(); |
1014 | smp_wmb(); |
1082 | atomic_set(&dev->unplugged, 1); |
1015 | atomic_set(&dev->unplugged, 1); |
1083 | } |
1016 | } |
1084 | 1017 | ||
1085 | static inline int drm_device_is_unplugged(struct drm_device *dev) |
1018 | static inline int drm_device_is_unplugged(struct drm_device *dev) |
1086 | { |
1019 | { |
1087 | int ret = atomic_read(&dev->unplugged); |
1020 | int ret = atomic_read(&dev->unplugged); |
1088 | smp_rmb(); |
1021 | smp_rmb(); |
1089 | return ret; |
1022 | return ret; |
1090 | } |
1023 | } |
1091 | - | ||
1092 | static inline bool drm_modeset_is_locked(struct drm_device *dev) |
- | |
1093 | { |
- | |
1094 | return mutex_is_locked(&dev->mode_config.mutex); |
- | |
1095 | } |
1024 | |
1096 | 1025 | ||
1097 | /******************************************************************/ |
1026 | /******************************************************************/ |
1098 | /** \name Internal function definitions */ |
1027 | /** \name Internal function definitions */ |
1099 | /*@{*/ |
1028 | /*@{*/ |
1100 | 1029 | ||
1101 | /* Driver support (drm_drv.h) */ |
1030 | /* Driver support (drm_drv.h) */ |
1102 | extern long drm_ioctl(struct file *filp, |
1031 | extern long drm_ioctl(struct file *filp, |
1103 | unsigned int cmd, unsigned long arg); |
1032 | unsigned int cmd, unsigned long arg); |
1104 | extern long drm_compat_ioctl(struct file *filp, |
1033 | extern long drm_compat_ioctl(struct file *filp, |
1105 | unsigned int cmd, unsigned long arg); |
1034 | unsigned int cmd, unsigned long arg); |
1106 | extern int drm_lastclose(struct drm_device *dev); |
1035 | extern int drm_lastclose(struct drm_device *dev); |
- | 1036 | extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags); |
|
1107 | 1037 | ||
1108 | /* Device support (drm_fops.h) */ |
1038 | /* Device support (drm_fops.h) */ |
1109 | extern struct mutex drm_global_mutex; |
1039 | extern struct mutex drm_global_mutex; |
1110 | extern int drm_open(struct inode *inode, struct file *filp); |
1040 | extern int drm_open(struct inode *inode, struct file *filp); |
1111 | extern int drm_stub_open(struct inode *inode, struct file *filp); |
- | |
1112 | extern ssize_t drm_read(struct file *filp, char __user *buffer, |
1041 | extern ssize_t drm_read(struct file *filp, char __user *buffer, |
1113 | size_t count, loff_t *offset); |
1042 | size_t count, loff_t *offset); |
1114 | extern int drm_release(struct inode *inode, struct file *filp); |
1043 | extern int drm_release(struct inode *inode, struct file *filp); |
1115 | 1044 | ||
1116 | /* Mapping support (drm_vm.h) */ |
1045 | /* Mapping support (drm_vm.h) */ |
1117 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); |
1046 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); |
1118 | extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); |
1047 | extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); |
1119 | extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma); |
1048 | extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma); |
1120 | extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma); |
1049 | extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma); |
1121 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
1050 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
1122 | 1051 | ||
1123 | /* Memory management support (drm_memory.h) */ |
1052 | /* Memory management support (drm_memory.h) */ |
1124 | #include |
1053 | #include |
1125 | 1054 | ||
1126 | 1055 | ||
1127 | /* Misc. IOCTL support (drm_ioctl.h) */ |
1056 | /* Misc. IOCTL support (drm_ioctl.h) */ |
1128 | extern int drm_irq_by_busid(struct drm_device *dev, void *data, |
1057 | extern int drm_irq_by_busid(struct drm_device *dev, void *data, |
1129 | struct drm_file *file_priv); |
1058 | struct drm_file *file_priv); |
1130 | extern int drm_getunique(struct drm_device *dev, void *data, |
1059 | extern int drm_getunique(struct drm_device *dev, void *data, |
1131 | struct drm_file *file_priv); |
1060 | struct drm_file *file_priv); |
1132 | extern int drm_setunique(struct drm_device *dev, void *data, |
1061 | extern int drm_setunique(struct drm_device *dev, void *data, |
1133 | struct drm_file *file_priv); |
1062 | struct drm_file *file_priv); |
1134 | extern int drm_getmap(struct drm_device *dev, void *data, |
1063 | extern int drm_getmap(struct drm_device *dev, void *data, |
1135 | struct drm_file *file_priv); |
1064 | struct drm_file *file_priv); |
1136 | extern int drm_getclient(struct drm_device *dev, void *data, |
1065 | extern int drm_getclient(struct drm_device *dev, void *data, |
1137 | struct drm_file *file_priv); |
1066 | struct drm_file *file_priv); |
1138 | extern int drm_getstats(struct drm_device *dev, void *data, |
1067 | extern int drm_getstats(struct drm_device *dev, void *data, |
1139 | struct drm_file *file_priv); |
1068 | struct drm_file *file_priv); |
1140 | extern int drm_getcap(struct drm_device *dev, void *data, |
1069 | extern int drm_getcap(struct drm_device *dev, void *data, |
1141 | struct drm_file *file_priv); |
1070 | struct drm_file *file_priv); |
1142 | extern int drm_setclientcap(struct drm_device *dev, void *data, |
1071 | extern int drm_setclientcap(struct drm_device *dev, void *data, |
1143 | struct drm_file *file_priv); |
1072 | struct drm_file *file_priv); |
1144 | extern int drm_setversion(struct drm_device *dev, void *data, |
1073 | extern int drm_setversion(struct drm_device *dev, void *data, |
1145 | struct drm_file *file_priv); |
1074 | struct drm_file *file_priv); |
1146 | extern int drm_noop(struct drm_device *dev, void *data, |
1075 | extern int drm_noop(struct drm_device *dev, void *data, |
1147 | struct drm_file *file_priv); |
1076 | struct drm_file *file_priv); |
1148 | - | ||
1149 | /* Context IOCTL support (drm_context.h) */ |
- | |
1150 | extern int drm_resctx(struct drm_device *dev, void *data, |
- | |
1151 | struct drm_file *file_priv); |
- | |
1152 | extern int drm_addctx(struct drm_device *dev, void *data, |
- | |
1153 | struct drm_file *file_priv); |
- | |
1154 | extern int drm_getctx(struct drm_device *dev, void *data, |
- | |
1155 | struct drm_file *file_priv); |
- | |
1156 | extern int drm_switchctx(struct drm_device *dev, void *data, |
- | |
1157 | struct drm_file *file_priv); |
- | |
1158 | extern int drm_newctx(struct drm_device *dev, void *data, |
- | |
1159 | struct drm_file *file_priv); |
- | |
1160 | extern int drm_rmctx(struct drm_device *dev, void *data, |
- | |
1161 | struct drm_file *file_priv); |
- | |
1162 | - | ||
1163 | extern int drm_ctxbitmap_init(struct drm_device *dev); |
- | |
1164 | extern void drm_ctxbitmap_cleanup(struct drm_device *dev); |
- | |
1165 | extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); |
- | |
1166 | - | ||
1167 | extern int drm_setsareactx(struct drm_device *dev, void *data, |
- | |
1168 | struct drm_file *file_priv); |
- | |
1169 | extern int drm_getsareactx(struct drm_device *dev, void *data, |
- | |
1170 | struct drm_file *file_priv); |
- | |
1171 | 1077 | ||
1172 | /* Authentication IOCTL support (drm_auth.h) */ |
1078 | /* Authentication IOCTL support (drm_auth.h) */ |
1173 | extern int drm_getmagic(struct drm_device *dev, void *data, |
1079 | extern int drm_getmagic(struct drm_device *dev, void *data, |
1174 | struct drm_file *file_priv); |
1080 | struct drm_file *file_priv); |
1175 | extern int drm_authmagic(struct drm_device *dev, void *data, |
1081 | extern int drm_authmagic(struct drm_device *dev, void *data, |
1176 | struct drm_file *file_priv); |
1082 | struct drm_file *file_priv); |
1177 | extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic); |
1083 | extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic); |
1178 | 1084 | ||
1179 | /* Cache management (drm_cache.c) */ |
1085 | /* Cache management (drm_cache.c) */ |
1180 | void drm_clflush_pages(struct page *pages[], unsigned long num_pages); |
1086 | void drm_clflush_pages(struct page *pages[], unsigned long num_pages); |
1181 | void drm_clflush_sg(struct sg_table *st); |
1087 | void drm_clflush_sg(struct sg_table *st); |
1182 | void drm_clflush_virt_range(char *addr, unsigned long length); |
1088 | void drm_clflush_virt_range(void *addr, unsigned long length); |
1183 | 1089 | ||
1184 | /* Locking IOCTL support (drm_lock.h) */ |
1090 | /* Locking IOCTL support (drm_lock.h) */ |
1185 | extern int drm_lock(struct drm_device *dev, void *data, |
1091 | extern int drm_lock(struct drm_device *dev, void *data, |
1186 | struct drm_file *file_priv); |
1092 | struct drm_file *file_priv); |
1187 | extern int drm_unlock(struct drm_device *dev, void *data, |
1093 | extern int drm_unlock(struct drm_device *dev, void *data, |
1188 | struct drm_file *file_priv); |
1094 | struct drm_file *file_priv); |
1189 | extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); |
1095 | extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); |
1190 | extern void drm_idlelock_take(struct drm_lock_data *lock_data); |
1096 | extern void drm_idlelock_take(struct drm_lock_data *lock_data); |
1191 | extern void drm_idlelock_release(struct drm_lock_data *lock_data); |
1097 | extern void drm_idlelock_release(struct drm_lock_data *lock_data); |
1192 | 1098 | ||
1193 | /* |
1099 | /* |
1194 | * These are exported to drivers so that they can implement fencing using |
1100 | * These are exported to drivers so that they can implement fencing using |
1195 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
1101 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
1196 | */ |
1102 | */ |
1197 | 1103 | ||
1198 | extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv); |
1104 | extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv); |
1199 | 1105 | ||
1200 | /* Buffer management support (drm_bufs.h) */ |
1106 | /* Buffer management support (drm_bufs.h) */ |
1201 | extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); |
1107 | extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); |
1202 | extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request); |
1108 | extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request); |
1203 | extern int drm_addmap(struct drm_device *dev, resource_size_t offset, |
1109 | extern int drm_addmap(struct drm_device *dev, resource_size_t offset, |
1204 | unsigned int size, enum drm_map_type type, |
1110 | unsigned int size, enum drm_map_type type, |
1205 | enum drm_map_flags flags, struct drm_local_map **map_ptr); |
1111 | enum drm_map_flags flags, struct drm_local_map **map_ptr); |
1206 | extern int drm_addmap_ioctl(struct drm_device *dev, void *data, |
1112 | extern int drm_addmap_ioctl(struct drm_device *dev, void *data, |
1207 | struct drm_file *file_priv); |
1113 | struct drm_file *file_priv); |
1208 | extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map); |
1114 | extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map); |
1209 | extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map); |
1115 | extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map); |
1210 | extern int drm_rmmap_ioctl(struct drm_device *dev, void *data, |
1116 | extern int drm_rmmap_ioctl(struct drm_device *dev, void *data, |
1211 | struct drm_file *file_priv); |
1117 | struct drm_file *file_priv); |
1212 | extern int drm_addbufs(struct drm_device *dev, void *data, |
1118 | extern int drm_addbufs(struct drm_device *dev, void *data, |
1213 | struct drm_file *file_priv); |
1119 | struct drm_file *file_priv); |
1214 | extern int drm_infobufs(struct drm_device *dev, void *data, |
1120 | extern int drm_infobufs(struct drm_device *dev, void *data, |
1215 | struct drm_file *file_priv); |
1121 | struct drm_file *file_priv); |
1216 | extern int drm_markbufs(struct drm_device *dev, void *data, |
1122 | extern int drm_markbufs(struct drm_device *dev, void *data, |
1217 | struct drm_file *file_priv); |
1123 | struct drm_file *file_priv); |
1218 | extern int drm_freebufs(struct drm_device *dev, void *data, |
1124 | extern int drm_freebufs(struct drm_device *dev, void *data, |
1219 | struct drm_file *file_priv); |
1125 | struct drm_file *file_priv); |
1220 | extern int drm_mapbufs(struct drm_device *dev, void *data, |
1126 | extern int drm_mapbufs(struct drm_device *dev, void *data, |
1221 | struct drm_file *file_priv); |
1127 | struct drm_file *file_priv); |
1222 | extern int drm_dma_ioctl(struct drm_device *dev, void *data, |
1128 | extern int drm_dma_ioctl(struct drm_device *dev, void *data, |
1223 | struct drm_file *file_priv); |
1129 | struct drm_file *file_priv); |
1224 | 1130 | ||
1225 | /* DMA support (drm_dma.h) */ |
1131 | /* DMA support (drm_dma.h) */ |
1226 | extern int drm_legacy_dma_setup(struct drm_device *dev); |
1132 | extern int drm_legacy_dma_setup(struct drm_device *dev); |
1227 | extern void drm_legacy_dma_takedown(struct drm_device *dev); |
1133 | extern void drm_legacy_dma_takedown(struct drm_device *dev); |
1228 | extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); |
1134 | extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); |
1229 | extern void drm_core_reclaim_buffers(struct drm_device *dev, |
1135 | extern void drm_core_reclaim_buffers(struct drm_device *dev, |
1230 | struct drm_file *filp); |
1136 | struct drm_file *filp); |
1231 | 1137 | ||
1232 | /* IRQ support (drm_irq.h) */ |
1138 | /* IRQ support (drm_irq.h) */ |
1233 | extern int drm_control(struct drm_device *dev, void *data, |
1139 | extern int drm_control(struct drm_device *dev, void *data, |
1234 | struct drm_file *file_priv); |
1140 | struct drm_file *file_priv); |
1235 | extern int drm_irq_install(struct drm_device *dev); |
1141 | extern int drm_irq_install(struct drm_device *dev, int irq); |
1236 | extern int drm_irq_uninstall(struct drm_device *dev); |
1142 | extern int drm_irq_uninstall(struct drm_device *dev); |
1237 | 1143 | ||
1238 | extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); |
1144 | extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); |
1239 | extern int drm_wait_vblank(struct drm_device *dev, void *data, |
1145 | extern int drm_wait_vblank(struct drm_device *dev, void *data, |
1240 | struct drm_file *filp); |
1146 | struct drm_file *filp); |
1241 | extern u32 drm_vblank_count(struct drm_device *dev, int crtc); |
1147 | extern u32 drm_vblank_count(struct drm_device *dev, int crtc); |
1242 | extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, |
1148 | extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, |
1243 | struct timeval *vblanktime); |
1149 | struct timeval *vblanktime); |
1244 | extern void drm_send_vblank_event(struct drm_device *dev, int crtc, |
1150 | extern void drm_send_vblank_event(struct drm_device *dev, int crtc, |
1245 | struct drm_pending_vblank_event *e); |
1151 | struct drm_pending_vblank_event *e); |
1246 | extern bool drm_handle_vblank(struct drm_device *dev, int crtc); |
1152 | extern bool drm_handle_vblank(struct drm_device *dev, int crtc); |
1247 | extern int drm_vblank_get(struct drm_device *dev, int crtc); |
1153 | extern int drm_vblank_get(struct drm_device *dev, int crtc); |
1248 | extern void drm_vblank_put(struct drm_device *dev, int crtc); |
1154 | extern void drm_vblank_put(struct drm_device *dev, int crtc); |
- | 1155 | extern int drm_crtc_vblank_get(struct drm_crtc *crtc); |
|
- | 1156 | extern void drm_crtc_vblank_put(struct drm_crtc *crtc); |
|
1249 | extern void drm_vblank_off(struct drm_device *dev, int crtc); |
1157 | extern void drm_vblank_off(struct drm_device *dev, int crtc); |
- | 1158 | extern void drm_vblank_on(struct drm_device *dev, int crtc); |
|
- | 1159 | extern void drm_crtc_vblank_off(struct drm_crtc *crtc); |
|
- | 1160 | extern void drm_crtc_vblank_on(struct drm_crtc *crtc); |
|
1250 | extern void drm_vblank_cleanup(struct drm_device *dev); |
1161 | extern void drm_vblank_cleanup(struct drm_device *dev); |
- | 1162 | ||
1251 | extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc, |
1163 | extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc, |
1252 | struct timeval *tvblank, unsigned flags); |
1164 | struct timeval *tvblank, unsigned flags); |
1253 | extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, |
1165 | extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, |
1254 | int crtc, int *max_error, |
1166 | int crtc, int *max_error, |
1255 | struct timeval *vblank_time, |
1167 | struct timeval *vblank_time, |
1256 | unsigned flags, |
1168 | unsigned flags, |
1257 | const struct drm_crtc *refcrtc, |
1169 | const struct drm_crtc *refcrtc, |
1258 | const struct drm_display_mode *mode); |
1170 | const struct drm_display_mode *mode); |
1259 | extern void drm_calc_timestamping_constants(struct drm_crtc *crtc, |
1171 | extern void drm_calc_timestamping_constants(struct drm_crtc *crtc, |
1260 | const struct drm_display_mode *mode); |
1172 | const struct drm_display_mode *mode); |
1261 | - | ||
1262 | extern bool |
- | |
1263 | drm_mode_parse_command_line_for_connector(const char *mode_option, |
- | |
1264 | struct drm_connector *connector, |
- | |
1265 | struct drm_cmdline_mode *mode); |
- | |
1266 | - | ||
1267 | extern struct drm_display_mode * |
- | |
1268 | drm_mode_create_from_cmdline_mode(struct drm_device *dev, |
- | |
1269 | struct drm_cmdline_mode *cmd); |
- | |
1270 | - | ||
1271 | extern int drm_display_mode_from_videomode(const struct videomode *vm, |
- | |
1272 | struct drm_display_mode *dmode); |
- | |
1273 | extern int of_get_drm_display_mode(struct device_node *np, |
- | |
1274 | struct drm_display_mode *dmode, |
- | |
1275 | int index); |
1173 | |
1276 | 1174 | ||
1277 | /* Modesetting support */ |
1175 | /* Modesetting support */ |
1278 | extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); |
1176 | extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); |
1279 | extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); |
1177 | extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); |
1280 | extern int drm_modeset_ctl(struct drm_device *dev, void *data, |
1178 | extern int drm_modeset_ctl(struct drm_device *dev, void *data, |
1281 | struct drm_file *file_priv); |
1179 | struct drm_file *file_priv); |
1282 | 1180 | ||
1283 | /* AGP/GART support (drm_agpsupport.h) */ |
1181 | /* AGP/GART support (drm_agpsupport.h) */ |
1284 | 1182 | ||
1285 | /* Stub support (drm_stub.h) */ |
1183 | /* Stub support (drm_stub.h) */ |
1286 | extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, |
1184 | extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, |
1287 | struct drm_file *file_priv); |
1185 | struct drm_file *file_priv); |
1288 | extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, |
1186 | extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, |
1289 | struct drm_file *file_priv); |
1187 | struct drm_file *file_priv); |
1290 | struct drm_master *drm_master_create(struct drm_minor *minor); |
1188 | struct drm_master *drm_master_create(struct drm_minor *minor); |
1291 | extern struct drm_master *drm_master_get(struct drm_master *master); |
1189 | extern struct drm_master *drm_master_get(struct drm_master *master); |
1292 | extern void drm_master_put(struct drm_master **master); |
1190 | extern void drm_master_put(struct drm_master **master); |
1293 | 1191 | ||
1294 | extern void drm_put_dev(struct drm_device *dev); |
1192 | extern void drm_put_dev(struct drm_device *dev); |
1295 | extern void drm_unplug_dev(struct drm_device *dev); |
1193 | extern void drm_unplug_dev(struct drm_device *dev); |
1296 | extern unsigned int drm_debug; |
1194 | extern unsigned int drm_debug; |
1297 | extern unsigned int drm_rnodes; |
- | |
1298 | 1195 | ||
1299 | #if 0 |
1196 | #if 0 |
1300 | extern unsigned int drm_vblank_offdelay; |
1197 | extern unsigned int drm_vblank_offdelay; |
1301 | extern unsigned int drm_timestamp_precision; |
1198 | extern unsigned int drm_timestamp_precision; |
1302 | extern unsigned int drm_timestamp_monotonic; |
1199 | extern unsigned int drm_timestamp_monotonic; |
1303 | 1200 | ||
1304 | extern struct class *drm_class; |
1201 | extern struct class *drm_class; |
1305 | extern struct dentry *drm_debugfs_root; |
- | |
1306 | - | ||
1307 | extern struct idr drm_minors_idr; |
- | |
1308 | 1202 | ||
1309 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); |
1203 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); |
1310 | 1204 | #endif |
|
1311 | /* Debugfs support */ |
1205 | /* Debugfs support */ |
1312 | #if defined(CONFIG_DEBUG_FS) |
1206 | #if defined(CONFIG_DEBUG_FS) |
1313 | extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
1207 | extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
1314 | struct dentry *root); |
1208 | struct dentry *root); |
1315 | extern int drm_debugfs_create_files(const struct drm_info_list *files, |
1209 | extern int drm_debugfs_create_files(const struct drm_info_list *files, |
1316 | int count, struct dentry *root, |
1210 | int count, struct dentry *root, |
1317 | struct drm_minor *minor); |
1211 | struct drm_minor *minor); |
1318 | extern int drm_debugfs_remove_files(const struct drm_info_list *files, |
1212 | extern int drm_debugfs_remove_files(const struct drm_info_list *files, |
1319 | int count, struct drm_minor *minor); |
1213 | int count, struct drm_minor *minor); |
1320 | extern int drm_debugfs_cleanup(struct drm_minor *minor); |
1214 | extern int drm_debugfs_cleanup(struct drm_minor *minor); |
- | 1215 | extern int drm_debugfs_connector_add(struct drm_connector *connector); |
|
- | 1216 | extern void drm_debugfs_connector_remove(struct drm_connector *connector); |
|
1321 | #else |
1217 | #else |
1322 | static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
1218 | static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
1323 | struct dentry *root) |
1219 | struct dentry *root) |
1324 | { |
1220 | { |
1325 | return 0; |
1221 | return 0; |
1326 | } |
1222 | } |
1327 | 1223 | ||
1328 | static inline int drm_debugfs_create_files(const struct drm_info_list *files, |
1224 | static inline int drm_debugfs_create_files(const struct drm_info_list *files, |
1329 | int count, struct dentry *root, |
1225 | int count, struct dentry *root, |
1330 | struct drm_minor *minor) |
1226 | struct drm_minor *minor) |
1331 | { |
1227 | { |
1332 | return 0; |
1228 | return 0; |
1333 | } |
1229 | } |
1334 | 1230 | ||
1335 | static inline int drm_debugfs_remove_files(const struct drm_info_list *files, |
1231 | static inline int drm_debugfs_remove_files(const struct drm_info_list *files, |
1336 | int count, struct drm_minor *minor) |
1232 | int count, struct drm_minor *minor) |
1337 | { |
1233 | { |
1338 | return 0; |
1234 | return 0; |
1339 | } |
1235 | } |
1340 | 1236 | ||
1341 | static inline int drm_debugfs_cleanup(struct drm_minor *minor) |
1237 | static inline int drm_debugfs_cleanup(struct drm_minor *minor) |
1342 | { |
1238 | { |
1343 | return 0; |
1239 | return 0; |
1344 | } |
1240 | } |
- | 1241 | ||
- | 1242 | static inline int drm_debugfs_connector_add(struct drm_connector *connector) |
|
- | 1243 | { |
|
- | 1244 | return 0; |
|
- | 1245 | } |
|
- | 1246 | static inline void drm_debugfs_connector_remove(struct drm_connector *connector) |
|
- | 1247 | { |
|
- | 1248 | } |
|
- | 1249 | ||
1345 | #endif |
1250 | #endif |
1346 | 1251 | ||
1347 | /* Info file support */ |
1252 | /* Info file support */ |
1348 | extern int drm_name_info(struct seq_file *m, void *data); |
1253 | extern int drm_name_info(struct seq_file *m, void *data); |
1349 | extern int drm_vm_info(struct seq_file *m, void *data); |
1254 | extern int drm_vm_info(struct seq_file *m, void *data); |
1350 | extern int drm_bufs_info(struct seq_file *m, void *data); |
1255 | extern int drm_bufs_info(struct seq_file *m, void *data); |
1351 | extern int drm_vblank_info(struct seq_file *m, void *data); |
1256 | extern int drm_vblank_info(struct seq_file *m, void *data); |
1352 | extern int drm_clients_info(struct seq_file *m, void* data); |
1257 | extern int drm_clients_info(struct seq_file *m, void* data); |
1353 | extern int drm_gem_name_info(struct seq_file *m, void *data); |
1258 | extern int drm_gem_name_info(struct seq_file *m, void *data); |
1354 | 1259 | ||
1355 | #if DRM_DEBUG_CODE |
1260 | #if DRM_DEBUG_CODE |
1356 | extern int drm_vma_info(struct seq_file *m, void *data); |
1261 | extern int drm_vma_info(struct seq_file *m, void *data); |
1357 | #endif |
1262 | #endif |
1358 | 1263 | ||
1359 | /* Scatter Gather Support (drm_scatter.h) */ |
1264 | /* Scatter Gather Support (drm_scatter.h) */ |
1360 | extern void drm_legacy_sg_cleanup(struct drm_device *dev); |
1265 | extern void drm_legacy_sg_cleanup(struct drm_device *dev); |
1361 | extern int drm_sg_alloc(struct drm_device *dev, void *data, |
1266 | extern int drm_sg_alloc(struct drm_device *dev, void *data, |
1362 | struct drm_file *file_priv); |
1267 | struct drm_file *file_priv); |
1363 | extern int drm_sg_free(struct drm_device *dev, void *data, |
1268 | extern int drm_sg_free(struct drm_device *dev, void *data, |
1364 | struct drm_file *file_priv); |
1269 | struct drm_file *file_priv); |
1365 | 1270 | ||
1366 | /* ATI PCIGART support (ati_pcigart.h) */ |
1271 | /* ATI PCIGART support (ati_pcigart.h) */ |
1367 | extern int drm_ati_pcigart_init(struct drm_device *dev, |
1272 | extern int drm_ati_pcigart_init(struct drm_device *dev, |
1368 | struct drm_ati_pcigart_info * gart_info); |
1273 | struct drm_ati_pcigart_info * gart_info); |
1369 | extern int drm_ati_pcigart_cleanup(struct drm_device *dev, |
1274 | extern int drm_ati_pcigart_cleanup(struct drm_device *dev, |
1370 | struct drm_ati_pcigart_info * gart_info); |
1275 | struct drm_ati_pcigart_info * gart_info); |
1371 | #endif |
- | |
1372 | 1276 | ||
1373 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, |
1277 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, |
1374 | size_t align); |
1278 | size_t align); |
1375 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
1279 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
1376 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
1280 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
1377 | 1281 | ||
1378 | #if 0 |
1282 | #if 0 |
1379 | /* sysfs support (drm_sysfs.c) */ |
1283 | /* sysfs support (drm_sysfs.c) */ |
1380 | struct drm_sysfs_class; |
1284 | struct drm_sysfs_class; |
1381 | extern struct class *drm_sysfs_create(struct module *owner, char *name); |
1285 | extern struct class *drm_sysfs_create(struct module *owner, char *name); |
1382 | extern void drm_sysfs_destroy(void); |
1286 | extern void drm_sysfs_destroy(void); |
1383 | extern int drm_sysfs_device_add(struct drm_minor *minor); |
1287 | extern struct device *drm_sysfs_minor_alloc(struct drm_minor *minor); |
1384 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
1288 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
1385 | extern void drm_sysfs_device_remove(struct drm_minor *minor); |
- | |
1386 | extern int drm_sysfs_connector_add(struct drm_connector *connector); |
1289 | extern int drm_sysfs_connector_add(struct drm_connector *connector); |
1387 | extern void drm_sysfs_connector_remove(struct drm_connector *connector); |
1290 | extern void drm_sysfs_connector_remove(struct drm_connector *connector); |
1388 | #endif |
1291 | #endif |
1389 | 1292 | ||
1390 | /* Graphics Execution Manager library functions (drm_gem.c) */ |
1293 | /* Graphics Execution Manager library functions (drm_gem.c) */ |
1391 | int drm_gem_init(struct drm_device *dev); |
1294 | int drm_gem_init(struct drm_device *dev); |
1392 | void drm_gem_destroy(struct drm_device *dev); |
1295 | void drm_gem_destroy(struct drm_device *dev); |
1393 | void drm_gem_object_release(struct drm_gem_object *obj); |
1296 | void drm_gem_object_release(struct drm_gem_object *obj); |
1394 | void drm_gem_object_free(struct kref *kref); |
1297 | void drm_gem_object_free(struct kref *kref); |
1395 | int drm_gem_object_init(struct drm_device *dev, |
1298 | int drm_gem_object_init(struct drm_device *dev, |
1396 | struct drm_gem_object *obj, size_t size); |
1299 | struct drm_gem_object *obj, size_t size); |
1397 | void drm_gem_private_object_init(struct drm_device *dev, |
1300 | void drm_gem_private_object_init(struct drm_device *dev, |
1398 | struct drm_gem_object *obj, size_t size); |
1301 | struct drm_gem_object *obj, size_t size); |
1399 | void drm_gem_vm_open(struct vm_area_struct *vma); |
1302 | void drm_gem_vm_open(struct vm_area_struct *vma); |
1400 | void drm_gem_vm_close(struct vm_area_struct *vma); |
1303 | void drm_gem_vm_close(struct vm_area_struct *vma); |
1401 | int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, |
1304 | int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, |
1402 | struct vm_area_struct *vma); |
1305 | struct vm_area_struct *vma); |
1403 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); |
1306 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); |
1404 | 1307 | ||
1405 | #include |
1308 | #include |
1406 | 1309 | ||
1407 | static inline void |
1310 | static inline void |
1408 | drm_gem_object_reference(struct drm_gem_object *obj) |
1311 | drm_gem_object_reference(struct drm_gem_object *obj) |
1409 | { |
1312 | { |
1410 | kref_get(&obj->refcount); |
1313 | kref_get(&obj->refcount); |
1411 | } |
1314 | } |
1412 | 1315 | ||
1413 | static inline void |
1316 | static inline void |
1414 | drm_gem_object_unreference(struct drm_gem_object *obj) |
1317 | drm_gem_object_unreference(struct drm_gem_object *obj) |
1415 | { |
1318 | { |
1416 | if (obj != NULL) |
1319 | if (obj != NULL) |
1417 | kref_put(&obj->refcount, drm_gem_object_free); |
1320 | kref_put(&obj->refcount, drm_gem_object_free); |
1418 | } |
1321 | } |
1419 | 1322 | ||
1420 | static inline void |
1323 | static inline void |
1421 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) |
1324 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) |
1422 | { |
1325 | { |
1423 | if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) { |
1326 | if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) { |
1424 | struct drm_device *dev = obj->dev; |
1327 | struct drm_device *dev = obj->dev; |
1425 | 1328 | ||
1426 | mutex_lock(&dev->struct_mutex); |
1329 | mutex_lock(&dev->struct_mutex); |
1427 | if (likely(atomic_dec_and_test(&obj->refcount.refcount))) |
1330 | if (likely(atomic_dec_and_test(&obj->refcount.refcount))) |
1428 | drm_gem_object_free(&obj->refcount); |
1331 | drm_gem_object_free(&obj->refcount); |
1429 | mutex_unlock(&dev->struct_mutex); |
1332 | mutex_unlock(&dev->struct_mutex); |
1430 | } |
1333 | } |
1431 | } |
1334 | } |
1432 | 1335 | ||
1433 | int drm_gem_handle_create_tail(struct drm_file *file_priv, |
1336 | int drm_gem_handle_create_tail(struct drm_file *file_priv, |
1434 | struct drm_gem_object *obj, |
1337 | struct drm_gem_object *obj, |
1435 | u32 *handlep); |
1338 | u32 *handlep); |
1436 | int drm_gem_handle_create(struct drm_file *file_priv, |
1339 | int drm_gem_handle_create(struct drm_file *file_priv, |
1437 | struct drm_gem_object *obj, |
1340 | struct drm_gem_object *obj, |
1438 | u32 *handlep); |
1341 | u32 *handlep); |
1439 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); |
1342 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); |
1440 | 1343 | ||
1441 | 1344 | ||
1442 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); |
1345 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); |
1443 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); |
1346 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); |
1444 | int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); |
1347 | int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); |
1445 | 1348 | ||
1446 | struct page **drm_gem_get_pages(struct drm_gem_object *obj, gfp_t gfpmask); |
1349 | struct page **drm_gem_get_pages(struct drm_gem_object *obj); |
1447 | void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, |
1350 | void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, |
1448 | bool dirty, bool accessed); |
1351 | bool dirty, bool accessed); |
1449 | 1352 | ||
1450 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, |
1353 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, |
1451 | struct drm_file *filp, |
1354 | struct drm_file *filp, |
1452 | u32 handle); |
1355 | u32 handle); |
1453 | int drm_gem_close_ioctl(struct drm_device *dev, void *data, |
1356 | int drm_gem_close_ioctl(struct drm_device *dev, void *data, |
1454 | struct drm_file *file_priv); |
1357 | struct drm_file *file_priv); |
1455 | int drm_gem_flink_ioctl(struct drm_device *dev, void *data, |
1358 | int drm_gem_flink_ioctl(struct drm_device *dev, void *data, |
1456 | struct drm_file *file_priv); |
1359 | struct drm_file *file_priv); |
1457 | int drm_gem_open_ioctl(struct drm_device *dev, void *data, |
1360 | int drm_gem_open_ioctl(struct drm_device *dev, void *data, |
1458 | struct drm_file *file_priv); |
1361 | struct drm_file *file_priv); |
1459 | void drm_gem_open(struct drm_device *dev, struct drm_file *file_private); |
1362 | void drm_gem_open(struct drm_device *dev, struct drm_file *file_private); |
1460 | void drm_gem_release(struct drm_device *dev, struct drm_file *file_private); |
1363 | void drm_gem_release(struct drm_device *dev, struct drm_file *file_private); |
1461 | 1364 | ||
1462 | extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev); |
1365 | extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev); |
1463 | extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev); |
1366 | extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev); |
1464 | extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev); |
1367 | extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev); |
1465 | 1368 | ||
1466 | static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, |
1369 | static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, |
1467 | unsigned int token) |
1370 | unsigned int token) |
1468 | { |
1371 | { |
1469 | struct drm_map_list *_entry; |
1372 | struct drm_map_list *_entry; |
1470 | list_for_each_entry(_entry, &dev->maplist, head) |
1373 | list_for_each_entry(_entry, &dev->maplist, head) |
1471 | if (_entry->user_token == token) |
1374 | if (_entry->user_token == token) |
1472 | return _entry->map; |
1375 | return _entry->map; |
1473 | return NULL; |
1376 | return NULL; |
1474 | } |
1377 | } |
1475 | 1378 | ||
1476 | static __inline__ void drm_core_dropmap(struct drm_local_map *map) |
1379 | static __inline__ void drm_core_dropmap(struct drm_local_map *map) |
1477 | { |
1380 | { |
1478 | } |
1381 | } |
1479 | 1382 | ||
1480 | //#include |
1383 | #include |
1481 | 1384 | ||
1482 | extern int drm_fill_in_dev(struct drm_device *dev, |
1385 | extern int drm_fill_in_dev(struct drm_device *dev, |
1483 | const struct pci_device_id *ent, |
1386 | const struct pci_device_id *ent, |
1484 | struct drm_driver *driver); |
1387 | struct drm_driver *driver); |
1485 | int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); |
1388 | int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); |
1486 | /*@}*/ |
1389 | /*@}*/ |
1487 | 1390 | ||
1488 | 1391 | ||
- | 1392 | #if 0 |
|
- | 1393 | extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); |
|
1489 | 1394 | extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); |
|
1490 | extern int drm_get_pci_dev(struct pci_dev *pdev, |
1395 | extern int drm_get_pci_dev(struct pci_dev *pdev, |
1491 | const struct pci_device_id *ent, |
1396 | const struct pci_device_id *ent, |
1492 | struct drm_driver *driver); |
1397 | struct drm_driver *driver); |
- | 1398 | #endif |
|
1493 | 1399 | ||
1494 | #define DRM_PCIE_SPEED_25 1 |
1400 | #define DRM_PCIE_SPEED_25 1 |
1495 | #define DRM_PCIE_SPEED_50 2 |
1401 | #define DRM_PCIE_SPEED_50 2 |
1496 | #define DRM_PCIE_SPEED_80 4 |
1402 | #define DRM_PCIE_SPEED_80 4 |
1497 | 1403 | ||
1498 | extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); |
1404 | extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); |
1499 | 1405 | ||
1500 | static __inline__ int drm_device_is_agp(struct drm_device *dev) |
1406 | static __inline__ int drm_device_is_agp(struct drm_device *dev) |
1501 | { |
1407 | { |
1502 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); |
1408 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); |
1503 | } |
1409 | } |
1504 | 1410 | ||
1505 | static __inline__ int drm_device_is_pcie(struct drm_device *dev) |
1411 | static __inline__ int drm_device_is_pcie(struct drm_device *dev) |
1506 | { |
1412 | { |
1507 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); |
1413 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); |
1508 | } |
1414 | } |
1509 | #endif /* __KERNEL__ */ |
1415 | #endif /* __KERNEL__ */ |
1510 | 1416 | ||
1511 | #define drm_sysfs_connector_add(connector) |
1417 | #define drm_sysfs_connector_add(connector) |
1512 | #define drm_sysfs_connector_remove(connector) |
1418 | #define drm_sysfs_connector_remove(connector) |
1513 | 1419 | ||
1514 | #define LFB_SIZE 0x1000000 |
1420 | #define LFB_SIZE 0x1000000 |
1515 | extern struct drm_device *main_device; |
1421 | extern struct drm_device *main_device; |
1516 | extern struct drm_file *drm_file_handlers[256]; |
1422 | extern struct drm_file *drm_file_handlers[256]; |
1517 | 1423 | ||
1518 | #endif>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>><>><>><>><>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>>>>>><>><>><>><>><> |
1424 | #endif>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>><>><>><>><>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>>>><>><>><>><>><> |