Rev 3391 | Rev 3747 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1408 | serge | 1 | /** |
2 | * \file drmP.h |
||
3 | * Private header for Direct Rendering Manager |
||
4 | * |
||
5 | * \author Rickard E. (Rik) Faith |
||
6 | * \author Gareth Hughes |
||
7 | */ |
||
8 | |||
9 | /* |
||
10 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
||
11 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
||
1964 | serge | 12 | * Copyright (c) 2009-2010, Code Aurora Forum. |
1408 | serge | 13 | * All rights reserved. |
14 | * |
||
15 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
16 | * copy of this software and associated documentation files (the "Software"), |
||
17 | * to deal in the Software without restriction, including without limitation |
||
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 |
||
20 | * Software is furnished to do so, subject to the following conditions: |
||
21 | * |
||
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 |
||
24 | * Software. |
||
25 | * |
||
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, |
||
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 |
||
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 |
||
32 | * OTHER DEALINGS IN THE SOFTWARE. |
||
33 | */ |
||
34 | |||
35 | #ifndef _DRM_P_H_ |
||
36 | #define _DRM_P_H_ |
||
37 | |||
38 | #ifdef __KERNEL__ |
||
3031 | serge | 39 | #ifdef __alpha__ |
40 | /* add include of current.h so that "current" is defined |
||
41 | * before static inline funcs in wait.h. Doing this so we |
||
42 | * can build the DRM (part of PI DRI). 4/21/2000 S + B */ |
||
43 | #include |
||
44 | #endif /* __alpha__ */ |
||
2967 | Serge | 45 | |
46 | #include |
||
47 | |||
1408 | serge | 48 | #include |
3031 | serge | 49 | #include |
2967 | Serge | 50 | #include |
1408 | serge | 51 | #include |
52 | #include |
||
2967 | Serge | 53 | #include |
3031 | serge | 54 | #include |
3391 | Serge | 55 | #include |
1408 | serge | 56 | |
57 | //#include |
||
58 | //#include |
||
59 | //#include |
||
60 | //#include |
||
61 | //#include |
||
62 | #include |
||
2967 | Serge | 63 | #include |
3243 | Serge | 64 | #include |
1408 | serge | 65 | //#include |
66 | //#include |
||
67 | //#include |
||
68 | //#include |
||
1630 | serge | 69 | #include |
1408 | serge | 70 | //#include |
71 | //#include |
||
72 | //#include |
||
73 | //#include |
||
74 | //#include |
||
75 | //#include |
||
76 | |||
3482 | Serge | 77 | #include |
78 | |||
79 | |||
1408 | serge | 80 | #include "drm.h" |
81 | |||
82 | #include |
||
83 | |||
84 | #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) |
||
85 | #define __OS_HAS_MTRR (defined(CONFIG_MTRR)) |
||
86 | |||
3031 | serge | 87 | struct module; |
1408 | serge | 88 | |
89 | struct drm_file; |
||
90 | struct drm_device; |
||
91 | |||
3391 | Serge | 92 | struct device_node; |
93 | struct videomode; |
||
3031 | serge | 94 | //#include |
95 | #include |
||
96 | #include |
||
1408 | serge | 97 | |
98 | #define KHZ2PICOS(a) (1000000000UL/(a)) |
||
99 | |||
1964 | serge | 100 | /* get_scanout_position() return flags */ |
101 | #define DRM_SCANOUTPOS_VALID (1 << 0) |
||
102 | #define DRM_SCANOUTPOS_INVBL (1 << 1) |
||
103 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
||
104 | |||
105 | |||
3031 | serge | 106 | |
107 | #define DRM_UT_CORE 0x01 |
||
108 | #define DRM_UT_DRIVER 0x02 |
||
109 | #define DRM_UT_KMS 0x04 |
||
110 | #define DRM_UT_PRIME 0x08 |
||
111 | /* |
||
112 | * Three debug levels are defined. |
||
113 | * drm_core, drm_driver, drm_kms |
||
114 | * drm_core level can be used in the generic drm code. For example: |
||
115 | * drm_ioctl, drm_mm, drm_memory |
||
116 | * The macro definition of DRM_DEBUG is used. |
||
117 | * DRM_DEBUG(fmt, args...) |
||
118 | * The debug info by using the DRM_DEBUG can be obtained by adding |
||
119 | * the boot option of "drm.debug=1". |
||
120 | * |
||
121 | * drm_driver level can be used in the specific drm driver. It is used |
||
122 | * to add the debug info related with the drm driver. For example: |
||
123 | * i915_drv, i915_dma, i915_gem, radeon_drv, |
||
124 | * The macro definition of DRM_DEBUG_DRIVER can be used. |
||
125 | * DRM_DEBUG_DRIVER(fmt, args...) |
||
126 | * The debug info by using the DRM_DEBUG_DRIVER can be obtained by |
||
127 | * adding the boot option of "drm.debug=0x02" |
||
128 | * |
||
129 | * drm_kms level can be used in the KMS code related with specific drm driver. |
||
130 | * It is used to add the debug info related with KMS mode. For example: |
||
131 | * the connector/crtc , |
||
132 | * The macro definition of DRM_DEBUG_KMS can be used. |
||
133 | * DRM_DEBUG_KMS(fmt, args...) |
||
134 | * The debug info by using the DRM_DEBUG_KMS can be obtained by |
||
135 | * adding the boot option of "drm.debug=0x04" |
||
136 | * |
||
137 | * If we add the boot option of "drm.debug=0x06", we can get the debug info by |
||
138 | * using the DRM_DEBUG_KMS and DRM_DEBUG_DRIVER. |
||
139 | * If we add the boot option of "drm.debug=0x05", we can get the debug info by |
||
140 | * using the DRM_DEBUG_KMS and DRM_DEBUG. |
||
141 | */ |
||
142 | |||
143 | extern __printf(4, 5) |
||
144 | void drm_ut_debug_printk(unsigned int request_level, |
||
1408 | serge | 145 | const char *prefix, |
146 | const char *function_name, |
||
147 | const char *format, ...); |
||
3031 | serge | 148 | extern __printf(2, 3) |
149 | int drm_err(const char *func, const char *format, ...); |
||
1408 | serge | 150 | |
151 | /***********************************************************************/ |
||
152 | /** \name DRM template customization defaults */ |
||
153 | /*@{*/ |
||
154 | |||
155 | /* driver capabilities and requirements mask */ |
||
156 | #define DRIVER_USE_AGP 0x1 |
||
157 | #define DRIVER_REQUIRE_AGP 0x2 |
||
158 | #define DRIVER_USE_MTRR 0x4 |
||
159 | #define DRIVER_PCI_DMA 0x8 |
||
160 | #define DRIVER_SG 0x10 |
||
161 | #define DRIVER_HAVE_DMA 0x20 |
||
162 | #define DRIVER_HAVE_IRQ 0x40 |
||
163 | #define DRIVER_IRQ_SHARED 0x80 |
||
164 | #define DRIVER_IRQ_VBL 0x100 |
||
165 | #define DRIVER_DMA_QUEUE 0x200 |
||
166 | #define DRIVER_FB_DMA 0x400 |
||
167 | #define DRIVER_IRQ_VBL2 0x800 |
||
168 | #define DRIVER_GEM 0x1000 |
||
169 | #define DRIVER_MODESET 0x2000 |
||
3031 | serge | 170 | #define DRIVER_PRIME 0x4000 |
1408 | serge | 171 | |
2967 | Serge | 172 | #define DRIVER_BUS_PCI 0x1 |
173 | #define DRIVER_BUS_PLATFORM 0x2 |
||
174 | #define DRIVER_BUS_USB 0x3 |
||
175 | |||
1408 | serge | 176 | /***********************************************************************/ |
177 | /** \name Begin the DRM... */ |
||
178 | /*@{*/ |
||
179 | |||
3391 | Serge | 180 | #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then |
1408 | serge | 181 | also include looping detection. */ |
182 | |||
183 | #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */ |
||
184 | #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */ |
||
185 | #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */ |
||
186 | #define DRM_LOOPING_LIMIT 5000000 |
||
187 | #define DRM_TIME_SLICE (HZ/20) /**< Time slice for GLXContexts */ |
||
188 | #define DRM_LOCK_SLICE 1 /**< Time slice for lock, in jiffies */ |
||
189 | |||
190 | #define DRM_FLAG_DEBUG 0x01 |
||
191 | |||
192 | #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) |
||
193 | #define DRM_MAP_HASH_OFFSET 0x10000000 |
||
194 | |||
195 | /*@}*/ |
||
196 | |||
197 | /***********************************************************************/ |
||
198 | /** \name Macros to make printk easier */ |
||
199 | /*@{*/ |
||
200 | |||
201 | /** |
||
202 | * Error output. |
||
203 | * |
||
204 | * \param fmt printf() like format string. |
||
205 | * \param arg arguments |
||
206 | */ |
||
3031 | serge | 207 | #define DRM_ERROR(fmt, ...) \ |
208 | drm_err(__func__, fmt, ##__VA_ARGS__) |
||
1408 | serge | 209 | |
3031 | serge | 210 | #define DRM_INFO(fmt, ...) \ |
211 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) |
||
1408 | serge | 212 | |
213 | /** |
||
214 | * Debug output. |
||
215 | * |
||
216 | * \param fmt printf() like format string. |
||
217 | * \param arg arguments |
||
218 | */ |
||
219 | #if DRM_DEBUG_CODE |
||
3031 | serge | 220 | #define DRM_DEBUG(fmt, ...) \ |
221 | do { \ |
||
222 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
||
1408 | serge | 223 | } while (0) |
224 | |||
3031 | serge | 225 | #define DRM_DEBUG_DRIVER(fmt, ...) \ |
226 | do { \ |
||
227 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
||
228 | } while (0) |
||
229 | #define DRM_DEBUG_KMS(fmt, ...) \ |
||
1408 | serge | 230 | do { \ |
3031 | serge | 231 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
1408 | serge | 232 | } while (0) |
3031 | serge | 233 | #define DRM_DEBUG_PRIME(fmt, ...) \ |
1408 | serge | 234 | do { \ |
3031 | serge | 235 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
1408 | serge | 236 | } while (0) |
3031 | serge | 237 | #define DRM_LOG(fmt, ...) \ |
1408 | serge | 238 | do { \ |
3031 | serge | 239 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
1408 | serge | 240 | } while (0) |
3031 | serge | 241 | #define DRM_LOG_KMS(fmt, ...) \ |
1408 | serge | 242 | do { \ |
3031 | serge | 243 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
1408 | serge | 244 | } while (0) |
3031 | serge | 245 | #define DRM_LOG_MODE(fmt, ...) \ |
1408 | serge | 246 | do { \ |
3031 | serge | 247 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
1408 | serge | 248 | } while (0) |
3031 | serge | 249 | #define DRM_LOG_DRIVER(fmt, ...) \ |
1408 | serge | 250 | do { \ |
3031 | serge | 251 | printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__); \ |
1408 | serge | 252 | } while (0) |
253 | #else |
||
254 | #define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0) |
||
255 | #define DRM_DEBUG_KMS(fmt, args...) do { } while (0) |
||
3031 | serge | 256 | #define DRM_DEBUG_PRIME(fmt, args...) do { } while (0) |
1408 | serge | 257 | #define DRM_DEBUG(fmt, arg...) do { } while (0) |
258 | #define DRM_LOG(fmt, arg...) do { } while (0) |
||
259 | #define DRM_LOG_KMS(fmt, args...) do { } while (0) |
||
260 | #define DRM_LOG_MODE(fmt, arg...) do { } while (0) |
||
261 | #define DRM_LOG_DRIVER(fmt, arg...) do { } while (0) |
||
262 | |||
263 | #endif |
||
264 | |||
265 | /*@}*/ |
||
266 | |||
267 | /***********************************************************************/ |
||
268 | /** \name Internal types and structures */ |
||
269 | /*@{*/ |
||
270 | |||
271 | #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x) |
||
272 | |||
273 | #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1)) |
||
274 | #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x)) |
||
275 | |||
276 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
||
277 | |||
278 | /** |
||
279 | * Test that the hardware lock is held by the caller, returning otherwise. |
||
280 | * |
||
281 | * \param dev DRM device. |
||
282 | * \param filp file pointer of the caller. |
||
283 | */ |
||
284 | #define LOCK_TEST_WITH_RETURN( dev, _file_priv ) \ |
||
285 | do { \ |
||
286 | if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) || \ |
||
287 | _file_priv->master->lock.file_priv != _file_priv) { \ |
||
288 | DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ |
||
289 | __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\ |
||
290 | _file_priv->master->lock.file_priv, _file_priv); \ |
||
291 | return -EINVAL; \ |
||
292 | } \ |
||
293 | } while (0) |
||
294 | |||
3031 | serge | 295 | #if 0 |
1408 | serge | 296 | /** |
297 | * Ioctl function type. |
||
298 | * |
||
299 | * \param inode device inode. |
||
300 | * \param file_priv DRM file private pointer. |
||
301 | * \param cmd command. |
||
302 | * \param arg argument. |
||
303 | */ |
||
304 | typedef int drm_ioctl_t(struct drm_device *dev, void *data, |
||
305 | struct drm_file *file_priv); |
||
306 | |||
307 | typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, |
||
308 | unsigned long arg); |
||
309 | |||
310 | #define DRM_IOCTL_NR(n) _IOC_NR(n) |
||
311 | #define DRM_MAJOR 226 |
||
312 | |||
313 | #define DRM_AUTH 0x1 |
||
314 | #define DRM_MASTER 0x2 |
||
315 | #define DRM_ROOT_ONLY 0x4 |
||
316 | #define DRM_CONTROL_ALLOW 0x8 |
||
317 | #define DRM_UNLOCKED 0x10 |
||
318 | |||
319 | struct drm_ioctl_desc { |
||
320 | unsigned int cmd; |
||
321 | int flags; |
||
322 | drm_ioctl_t *func; |
||
1964 | serge | 323 | unsigned int cmd_drv; |
1408 | serge | 324 | }; |
325 | |||
326 | /** |
||
327 | * Creates a driver or general drm_ioctl_desc array entry for the given |
||
328 | * ioctl, for use by drm_ioctl(). |
||
329 | */ |
||
330 | |||
1964 | serge | 331 | #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ |
332 | [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl} |
||
333 | |||
1408 | serge | 334 | struct drm_magic_entry { |
335 | struct list_head head; |
||
336 | struct drm_hash_item hash_item; |
||
337 | struct drm_file *priv; |
||
338 | }; |
||
339 | |||
340 | struct drm_vma_entry { |
||
341 | struct list_head head; |
||
342 | struct vm_area_struct *vma; |
||
343 | pid_t pid; |
||
344 | }; |
||
345 | |||
346 | /** |
||
347 | * DMA buffer. |
||
348 | */ |
||
349 | struct drm_buf { |
||
350 | int idx; /**< Index into master buflist */ |
||
351 | int total; /**< Buffer size */ |
||
352 | int order; /**< log-base-2(total) */ |
||
353 | int used; /**< Amount of buffer in use (for DMA) */ |
||
354 | unsigned long offset; /**< Byte offset (used internally) */ |
||
355 | void *address; /**< Address of buffer */ |
||
356 | unsigned long bus_address; /**< Bus address of buffer */ |
||
357 | struct drm_buf *next; /**< Kernel-only: used for free list */ |
||
358 | __volatile__ int waiting; /**< On kernel DMA queue */ |
||
359 | __volatile__ int pending; /**< On hardware DMA queue */ |
||
360 | struct drm_file *file_priv; /**< Private of holding file descr */ |
||
361 | int context; /**< Kernel queue for this buffer */ |
||
362 | int while_locked; /**< Dispatch this buffer while locked */ |
||
363 | enum { |
||
364 | DRM_LIST_NONE = 0, |
||
365 | DRM_LIST_FREE = 1, |
||
366 | DRM_LIST_WAIT = 2, |
||
367 | DRM_LIST_PEND = 3, |
||
368 | DRM_LIST_PRIO = 4, |
||
369 | DRM_LIST_RECLAIM = 5 |
||
370 | } list; /**< Which list we're on */ |
||
371 | |||
372 | int dev_priv_size; /**< Size of buffer private storage */ |
||
373 | void *dev_private; /**< Per-buffer private storage */ |
||
374 | }; |
||
375 | |||
376 | /** bufs is one longer than it has to be */ |
||
377 | struct drm_waitlist { |
||
378 | int count; /**< Number of possible buffers */ |
||
379 | struct drm_buf **bufs; /**< List of pointers to buffers */ |
||
380 | struct drm_buf **rp; /**< Read pointer */ |
||
381 | struct drm_buf **wp; /**< Write pointer */ |
||
382 | struct drm_buf **end; /**< End pointer */ |
||
383 | spinlock_t read_lock; |
||
384 | spinlock_t write_lock; |
||
385 | }; |
||
386 | |||
387 | struct drm_freelist { |
||
388 | int initialized; /**< Freelist in use */ |
||
389 | atomic_t count; /**< Number of free buffers */ |
||
390 | struct drm_buf *next; /**< End pointer */ |
||
391 | |||
392 | wait_queue_head_t waiting; /**< Processes waiting on free bufs */ |
||
393 | int low_mark; /**< Low water mark */ |
||
394 | int high_mark; /**< High water mark */ |
||
395 | atomic_t wfh; /**< If waiting for high mark */ |
||
396 | spinlock_t lock; |
||
397 | }; |
||
2967 | Serge | 398 | #endif |
1408 | serge | 399 | |
400 | typedef struct drm_dma_handle { |
||
401 | dma_addr_t busaddr; |
||
402 | void *vaddr; |
||
403 | size_t size; |
||
404 | } drm_dma_handle_t; |
||
405 | |||
2967 | Serge | 406 | #if 0 |
1408 | serge | 407 | /** |
408 | * Buffer entry. There is one of this for each buffer size order. |
||
409 | */ |
||
410 | struct drm_buf_entry { |
||
411 | int buf_size; /**< size */ |
||
412 | int buf_count; /**< number of buffers */ |
||
413 | struct drm_buf *buflist; /**< buffer list */ |
||
414 | int seg_count; |
||
415 | int page_order; |
||
416 | struct drm_dma_handle **seglist; |
||
417 | |||
418 | struct drm_freelist freelist; |
||
419 | }; |
||
420 | |||
421 | /* Event queued up for userspace to read */ |
||
422 | struct drm_pending_event { |
||
423 | struct drm_event *event; |
||
424 | struct list_head link; |
||
425 | struct drm_file *file_priv; |
||
1964 | serge | 426 | pid_t pid; /* pid of requester, no guarantee it's valid by the time |
427 | we deliver the event, for tracing only */ |
||
1408 | serge | 428 | void (*destroy)(struct drm_pending_event *event); |
429 | }; |
||
430 | |||
3031 | serge | 431 | /* initial implementaton using a linked list - todo hashtab */ |
432 | struct drm_prime_file_private { |
||
433 | struct list_head head; |
||
434 | struct mutex lock; |
||
435 | }; |
||
3255 | Serge | 436 | #endif |
3031 | serge | 437 | |
1408 | serge | 438 | /** File private data */ |
439 | struct drm_file { |
||
440 | struct list_head lhead; |
||
441 | unsigned long lock_count; |
||
442 | |||
443 | /** Mapping of mm object handles to object pointers. */ |
||
444 | struct idr object_idr; |
||
445 | /** Lock for synchronization of access to object_idr. */ |
||
446 | spinlock_t table_lock; |
||
447 | |||
448 | void *driver_priv; |
||
449 | |||
450 | struct list_head fbs; |
||
451 | |||
452 | wait_queue_head_t event_wait; |
||
453 | struct list_head event_list; |
||
454 | int event_space; |
||
455 | }; |
||
456 | |||
3255 | Serge | 457 | #if 0 |
1408 | serge | 458 | /** Wait queue */ |
459 | struct drm_queue { |
||
460 | atomic_t use_count; /**< Outstanding uses (+1) */ |
||
461 | atomic_t finalization; /**< Finalization in progress */ |
||
462 | atomic_t block_count; /**< Count of processes waiting */ |
||
463 | atomic_t block_read; /**< Queue blocked for reads */ |
||
464 | wait_queue_head_t read_queue; /**< Processes waiting on block_read */ |
||
465 | atomic_t block_write; /**< Queue blocked for writes */ |
||
466 | wait_queue_head_t write_queue; /**< Processes waiting on block_write */ |
||
467 | atomic_t total_queued; /**< Total queued statistic */ |
||
468 | atomic_t total_flushed; /**< Total flushes statistic */ |
||
469 | atomic_t total_locks; /**< Total locks statistics */ |
||
470 | enum drm_ctx_flags flags; /**< Context preserving and 2D-only */ |
||
471 | struct drm_waitlist waitlist; /**< Pending buffers */ |
||
472 | wait_queue_head_t flush_queue; /**< Processes waiting until flush */ |
||
473 | }; |
||
474 | |||
475 | /** |
||
476 | * Lock data. |
||
477 | */ |
||
478 | struct drm_lock_data { |
||
479 | struct drm_hw_lock *hw_lock; /**< Hardware lock */ |
||
480 | /** Private of lock holder's file (NULL=kernel) */ |
||
481 | struct drm_file *file_priv; |
||
482 | wait_queue_head_t lock_queue; /**< Queue of blocked processes */ |
||
483 | unsigned long lock_time; /**< Time of last lock in jiffies */ |
||
484 | spinlock_t spinlock; |
||
485 | uint32_t kernel_waiters; |
||
486 | uint32_t user_waiters; |
||
487 | int idle_has_lock; |
||
488 | }; |
||
489 | |||
490 | /** |
||
491 | * DMA data. |
||
492 | */ |
||
493 | struct drm_device_dma { |
||
494 | |||
495 | struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */ |
||
496 | int buf_count; /**< total number of buffers */ |
||
497 | struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */ |
||
498 | int seg_count; |
||
499 | int page_count; /**< number of pages */ |
||
500 | unsigned long *pagelist; /**< page list */ |
||
501 | unsigned long byte_count; |
||
502 | enum { |
||
503 | _DRM_DMA_USE_AGP = 0x01, |
||
504 | _DRM_DMA_USE_SG = 0x02, |
||
505 | _DRM_DMA_USE_FB = 0x04, |
||
506 | _DRM_DMA_USE_PCI_RO = 0x08 |
||
507 | } flags; |
||
508 | |||
509 | }; |
||
510 | |||
511 | /** |
||
512 | * AGP memory entry. Stored as a doubly linked list. |
||
513 | */ |
||
514 | struct drm_agp_mem { |
||
515 | unsigned long handle; /**< handle */ |
||
516 | DRM_AGP_MEM *memory; |
||
517 | unsigned long bound; /**< address */ |
||
518 | int pages; |
||
519 | struct list_head head; |
||
520 | }; |
||
521 | |||
522 | /** |
||
523 | * AGP data. |
||
524 | * |
||
525 | * \sa drm_agp_init() and drm_device::agp. |
||
526 | */ |
||
527 | struct drm_agp_head { |
||
528 | DRM_AGP_KERN agp_info; /**< AGP device information */ |
||
529 | struct list_head memory; |
||
530 | unsigned long mode; /**< AGP mode */ |
||
531 | struct agp_bridge_data *bridge; |
||
532 | int enabled; /**< whether the AGP bus as been enabled */ |
||
533 | int acquired; /**< whether the AGP device has been acquired */ |
||
534 | unsigned long base; |
||
535 | int agp_mtrr; |
||
536 | int cant_use_aperture; |
||
537 | unsigned long page_mask; |
||
538 | }; |
||
539 | |||
540 | /** |
||
541 | * Scatter-gather memory. |
||
542 | */ |
||
543 | struct drm_sg_mem { |
||
544 | unsigned long handle; |
||
545 | void *virtual; |
||
546 | int pages; |
||
547 | struct page **pagelist; |
||
548 | dma_addr_t *busaddr; |
||
549 | }; |
||
550 | |||
551 | struct drm_sigdata { |
||
552 | int context; |
||
553 | struct drm_hw_lock *lock; |
||
554 | }; |
||
555 | |||
2967 | Serge | 556 | #endif |
1408 | serge | 557 | |
2967 | Serge | 558 | |
1408 | serge | 559 | /** |
560 | * Kernel side of a mapping |
||
561 | */ |
||
562 | struct drm_local_map { |
||
563 | resource_size_t offset; /**< Requested physical address (0 for SAREA)*/ |
||
564 | unsigned long size; /**< Requested physical size (bytes) */ |
||
565 | enum drm_map_type type; /**< Type of memory to map */ |
||
566 | enum drm_map_flags flags; /**< Flags */ |
||
567 | void *handle; /**< User-space: "Handle" to pass to mmap() */ |
||
568 | /**< Kernel-space: kernel-virtual address */ |
||
569 | int mtrr; /**< MTRR slot used */ |
||
570 | }; |
||
571 | |||
572 | typedef struct drm_local_map drm_local_map_t; |
||
573 | |||
2967 | Serge | 574 | #if 0 |
1408 | serge | 575 | /** |
576 | * Mappings list |
||
577 | */ |
||
578 | struct drm_map_list { |
||
579 | struct list_head head; /**< list head */ |
||
580 | struct drm_hash_item hash; |
||
581 | struct drm_local_map *map; /**< mapping */ |
||
582 | uint64_t user_token; |
||
583 | struct drm_master *master; |
||
584 | struct drm_mm_node *file_offset_node; /**< fake offset */ |
||
585 | }; |
||
586 | |||
587 | /** |
||
588 | * Context handle list |
||
589 | */ |
||
590 | struct drm_ctx_list { |
||
591 | struct list_head head; /**< list head */ |
||
592 | drm_context_t handle; /**< context handle */ |
||
593 | struct drm_file *tag; /**< associated fd private data */ |
||
594 | }; |
||
595 | |||
596 | /* location of GART table */ |
||
597 | #define DRM_ATI_GART_MAIN 1 |
||
598 | #define DRM_ATI_GART_FB 2 |
||
599 | |||
600 | #define DRM_ATI_GART_PCI 1 |
||
601 | #define DRM_ATI_GART_PCIE 2 |
||
602 | #define DRM_ATI_GART_IGP 3 |
||
603 | |||
604 | struct drm_ati_pcigart_info { |
||
605 | int gart_table_location; |
||
606 | int gart_reg_if; |
||
607 | void *addr; |
||
608 | dma_addr_t bus_addr; |
||
609 | dma_addr_t table_mask; |
||
610 | struct drm_dma_handle *table_handle; |
||
611 | struct drm_local_map mapping; |
||
612 | int table_size; |
||
613 | }; |
||
614 | |||
615 | /** |
||
616 | * GEM specific mm private for tracking GEM objects |
||
617 | */ |
||
618 | struct drm_gem_mm { |
||
619 | struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */ |
||
620 | struct drm_open_hash offset_hash; /**< User token hash table for maps */ |
||
621 | }; |
||
622 | |||
1987 | serge | 623 | #endif |
624 | |||
1408 | serge | 625 | /** |
626 | * This structure defines the drm_mm memory object, which will be used by the |
||
627 | * DRM for its buffer objects. |
||
628 | */ |
||
629 | struct drm_gem_object { |
||
630 | /** Reference count of this object */ |
||
631 | struct kref refcount; |
||
632 | |||
633 | /** Handle count of this object. Each handle also holds a reference */ |
||
1964 | serge | 634 | atomic_t handle_count; /* number of handles on this object */ |
1408 | serge | 635 | |
636 | /** Related drm device */ |
||
637 | struct drm_device *dev; |
||
638 | |||
639 | /** File representing the shmem storage */ |
||
640 | struct file *filp; |
||
641 | |||
642 | /* Mapping info for this object */ |
||
643 | |||
644 | /** |
||
645 | * Size of the object, in bytes. Immutable over the object's |
||
646 | * lifetime. |
||
647 | */ |
||
648 | size_t size; |
||
649 | |||
650 | /** |
||
651 | * Global name for this object, starts at 1. 0 means unnamed. |
||
652 | * Access is covered by the object_name_lock in the related drm_device |
||
653 | */ |
||
654 | int name; |
||
655 | |||
656 | /** |
||
657 | * Memory domains. These monitor which caches contain read/write data |
||
658 | * related to the object. When transitioning from one set of domains |
||
659 | * to another, the driver is called to ensure that caches are suitably |
||
660 | * flushed and invalidated |
||
661 | */ |
||
662 | uint32_t read_domains; |
||
663 | uint32_t write_domain; |
||
664 | |||
665 | /** |
||
666 | * While validating an exec operation, the |
||
667 | * new read/write domain values are computed here. |
||
668 | * They will be transferred to the above values |
||
669 | * at the point that any cache flushing occurs |
||
670 | */ |
||
671 | uint32_t pending_read_domains; |
||
672 | uint32_t pending_write_domain; |
||
673 | |||
674 | void *driver_private; |
||
675 | }; |
||
676 | |||
3031 | serge | 677 | #include |
1408 | serge | 678 | |
679 | /* per-master structure */ |
||
680 | struct drm_master { |
||
681 | |||
682 | struct kref refcount; /* refcount for this master */ |
||
683 | |||
684 | struct list_head head; /**< each minor contains a list of masters */ |
||
685 | struct drm_minor *minor; /**< link back to minor we are a master for */ |
||
686 | |||
687 | char *unique; /**< Unique identifier: e.g., busid */ |
||
688 | int unique_len; /**< Length of unique field */ |
||
689 | int unique_size; /**< amount allocated */ |
||
690 | |||
691 | int blocked; /**< Blocked due to VC switch? */ |
||
692 | |||
693 | /** \name Authentication */ |
||
694 | /*@{ */ |
||
2967 | Serge | 695 | // struct drm_open_hash magiclist; |
696 | // struct list_head magicfree; |
||
1408 | serge | 697 | /*@} */ |
698 | |||
2967 | Serge | 699 | // struct drm_lock_data lock; /**< Information on hardware lock */ |
1408 | serge | 700 | |
701 | void *driver_priv; /**< Private structure for driver to use */ |
||
702 | }; |
||
703 | |||
2967 | Serge | 704 | #if 0 |
705 | |||
1964 | serge | 706 | /* Size of ringbuffer for vblank timestamps. Just double-buffer |
707 | * in initial implementation. |
||
708 | */ |
||
709 | #define DRM_VBLANKTIME_RBSIZE 2 |
||
710 | |||
711 | /* Flags and return codes for get_vblank_timestamp() driver function. */ |
||
712 | #define DRM_CALLED_FROM_VBLIRQ 1 |
||
713 | #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) |
||
714 | #define DRM_VBLANKTIME_INVBL (1 << 1) |
||
715 | |||
716 | /* get_scanout_position() return flags */ |
||
717 | #define DRM_SCANOUTPOS_VALID (1 << 0) |
||
718 | #define DRM_SCANOUTPOS_INVBL (1 << 1) |
||
719 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
||
720 | |||
721 | struct drm_bus { |
||
722 | int bus_type; |
||
723 | int (*get_irq)(struct drm_device *dev); |
||
724 | const char *(*get_name)(struct drm_device *dev); |
||
725 | int (*set_busid)(struct drm_device *dev, struct drm_master *master); |
||
726 | int (*set_unique)(struct drm_device *dev, struct drm_master *master, |
||
727 | struct drm_unique *unique); |
||
728 | int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p); |
||
729 | /* hooks that are for PCI */ |
||
730 | int (*agp_init)(struct drm_device *dev); |
||
731 | |||
732 | }; |
||
733 | |||
1408 | serge | 734 | /** |
735 | * DRM driver structure. This structure represent the common code for |
||
736 | * a family of cards. There will one drm_device for each card present |
||
737 | * in this family |
||
738 | */ |
||
739 | struct drm_driver { |
||
740 | int (*load) (struct drm_device *, unsigned long flags); |
||
741 | int (*firstopen) (struct drm_device *); |
||
742 | int (*open) (struct drm_device *, struct drm_file *); |
||
743 | void (*preclose) (struct drm_device *, struct drm_file *file_priv); |
||
744 | void (*postclose) (struct drm_device *, struct drm_file *); |
||
745 | void (*lastclose) (struct drm_device *); |
||
746 | int (*unload) (struct drm_device *); |
||
747 | int (*suspend) (struct drm_device *, pm_message_t state); |
||
748 | int (*resume) (struct drm_device *); |
||
749 | int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); |
||
750 | int (*dma_quiescent) (struct drm_device *); |
||
751 | int (*context_dtor) (struct drm_device *dev, int context); |
||
752 | |||
753 | /** |
||
754 | * get_vblank_counter - get raw hardware vblank counter |
||
755 | * @dev: DRM device |
||
756 | * @crtc: counter to fetch |
||
757 | * |
||
3031 | serge | 758 | * Driver callback for fetching a raw hardware vblank counter for @crtc. |
759 | * If a device doesn't have a hardware counter, the driver can simply |
||
760 | * return the value of drm_vblank_count. The DRM core will account for |
||
761 | * missed vblank events while interrupts where disabled based on system |
||
762 | * timestamps. |
||
1408 | serge | 763 | * |
764 | * Wraparound handling and loss of events due to modesetting is dealt |
||
765 | * with in the DRM core code. |
||
766 | * |
||
767 | * RETURNS |
||
768 | * Raw vblank counter value. |
||
769 | */ |
||
770 | u32 (*get_vblank_counter) (struct drm_device *dev, int crtc); |
||
771 | |||
772 | /** |
||
773 | * enable_vblank - enable vblank interrupt events |
||
774 | * @dev: DRM device |
||
775 | * @crtc: which irq to enable |
||
776 | * |
||
777 | * Enable vblank interrupts for @crtc. If the device doesn't have |
||
778 | * a hardware vblank counter, this routine should be a no-op, since |
||
779 | * interrupts will have to stay on to keep the count accurate. |
||
780 | * |
||
781 | * RETURNS |
||
782 | * Zero on success, appropriate errno if the given @crtc's vblank |
||
783 | * interrupt cannot be enabled. |
||
784 | */ |
||
785 | int (*enable_vblank) (struct drm_device *dev, int crtc); |
||
786 | |||
787 | /** |
||
788 | * disable_vblank - disable vblank interrupt events |
||
789 | * @dev: DRM device |
||
790 | * @crtc: which irq to enable |
||
791 | * |
||
792 | * Disable vblank interrupts for @crtc. If the device doesn't have |
||
793 | * a hardware vblank counter, this routine should be a no-op, since |
||
794 | * interrupts will have to stay on to keep the count accurate. |
||
795 | */ |
||
796 | void (*disable_vblank) (struct drm_device *dev, int crtc); |
||
797 | |||
798 | /** |
||
799 | * Called by \c drm_device_is_agp. Typically used to determine if a |
||
800 | * card is really attached to AGP or not. |
||
801 | * |
||
802 | * \param dev DRM device handle |
||
803 | * |
||
804 | * \returns |
||
805 | * One of three values is returned depending on whether or not the |
||
806 | * card is absolutely \b not AGP (return of 0), absolutely \b is AGP |
||
807 | * (return of 1), or may or may not be AGP (return of 2). |
||
808 | */ |
||
809 | int (*device_is_agp) (struct drm_device *dev); |
||
810 | |||
1964 | serge | 811 | /** |
812 | * Called by vblank timestamping code. |
||
813 | * |
||
814 | * Return the current display scanout position from a crtc. |
||
815 | * |
||
816 | * \param dev DRM device. |
||
817 | * \param crtc Id of the crtc to query. |
||
818 | * \param *vpos Target location for current vertical scanout position. |
||
819 | * \param *hpos Target location for current horizontal scanout position. |
||
820 | * |
||
821 | * Returns vpos as a positive number while in active scanout area. |
||
822 | * Returns vpos as a negative number inside vblank, counting the number |
||
823 | * of scanlines to go until end of vblank, e.g., -1 means "one scanline |
||
824 | * until start of active scanout / end of vblank." |
||
825 | * |
||
826 | * \return Flags, or'ed together as follows: |
||
827 | * |
||
828 | * DRM_SCANOUTPOS_VALID = Query successful. |
||
829 | * DRM_SCANOUTPOS_INVBL = Inside vblank. |
||
830 | * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of |
||
831 | * this flag means that returned position may be offset by a constant |
||
832 | * but unknown small number of scanlines wrt. real scanout position. |
||
833 | * |
||
834 | */ |
||
835 | int (*get_scanout_position) (struct drm_device *dev, int crtc, |
||
836 | int *vpos, int *hpos); |
||
837 | |||
838 | /** |
||
839 | * Called by \c drm_get_last_vbltimestamp. Should return a precise |
||
840 | * timestamp when the most recent VBLANK interval ended or will end. |
||
841 | * |
||
842 | * Specifically, the timestamp in @vblank_time should correspond as |
||
843 | * closely as possible to the time when the first video scanline of |
||
844 | * the video frame after the end of VBLANK will start scanning out, |
||
2967 | Serge | 845 | * the time immediately after end of the VBLANK interval. If the |
1964 | serge | 846 | * @crtc is currently inside VBLANK, this will be a time in the future. |
847 | * If the @crtc is currently scanning out a frame, this will be the |
||
848 | * past start time of the current scanout. This is meant to adhere |
||
849 | * to the OpenML OML_sync_control extension specification. |
||
850 | * |
||
851 | * \param dev dev DRM device handle. |
||
852 | * \param crtc crtc for which timestamp should be returned. |
||
853 | * \param *max_error Maximum allowable timestamp error in nanoseconds. |
||
854 | * Implementation should strive to provide timestamp |
||
855 | * with an error of at most *max_error nanoseconds. |
||
856 | * Returns true upper bound on error for timestamp. |
||
857 | * \param *vblank_time Target location for returned vblank timestamp. |
||
858 | * \param flags 0 = Defaults, no special treatment needed. |
||
859 | * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank |
||
860 | * irq handler. Some drivers need to apply some workarounds |
||
861 | * for gpu-specific vblank irq quirks if flag is set. |
||
862 | * |
||
863 | * \returns |
||
864 | * Zero if timestamping isn't supported in current display mode or a |
||
865 | * negative number on failure. A positive status code on success, |
||
866 | * which describes how the vblank_time timestamp was computed. |
||
867 | */ |
||
868 | int (*get_vblank_timestamp) (struct drm_device *dev, int crtc, |
||
869 | int *max_error, |
||
870 | struct timeval *vblank_time, |
||
871 | unsigned flags); |
||
872 | |||
1408 | serge | 873 | /* these have to be filled in */ |
874 | |||
875 | irqreturn_t(*irq_handler) (DRM_IRQ_ARGS); |
||
876 | void (*irq_preinstall) (struct drm_device *dev); |
||
877 | int (*irq_postinstall) (struct drm_device *dev); |
||
878 | void (*irq_uninstall) (struct drm_device *dev); |
||
879 | void (*set_version) (struct drm_device *dev, |
||
880 | struct drm_set_version *sv); |
||
881 | |||
882 | /* Master routines */ |
||
883 | int (*master_create)(struct drm_device *dev, struct drm_master *master); |
||
884 | void (*master_destroy)(struct drm_device *dev, struct drm_master *master); |
||
885 | /** |
||
886 | * master_set is called whenever the minor master is set. |
||
887 | * master_drop is called whenever the minor master is dropped. |
||
888 | */ |
||
889 | |||
890 | int (*master_set)(struct drm_device *dev, struct drm_file *file_priv, |
||
891 | bool from_open); |
||
892 | void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv, |
||
893 | bool from_release); |
||
894 | |||
895 | int (*debugfs_init)(struct drm_minor *minor); |
||
896 | void (*debugfs_cleanup)(struct drm_minor *minor); |
||
897 | |||
898 | /** |
||
899 | * Driver-specific constructor for drm_gem_objects, to set up |
||
900 | * obj->driver_private. |
||
901 | * |
||
902 | * Returns 0 on success. |
||
903 | */ |
||
904 | int (*gem_init_object) (struct drm_gem_object *obj); |
||
905 | void (*gem_free_object) (struct drm_gem_object *obj); |
||
2967 | Serge | 906 | int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); |
907 | void (*gem_close_object) (struct drm_gem_object *, struct drm_file *); |
||
1408 | serge | 908 | |
3031 | serge | 909 | /* prime: */ |
910 | /* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */ |
||
911 | int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv, |
||
912 | uint32_t handle, uint32_t flags, int *prime_fd); |
||
913 | /* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */ |
||
914 | int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv, |
||
915 | int prime_fd, uint32_t *handle); |
||
916 | /* export GEM -> dmabuf */ |
||
917 | struct dma_buf * (*gem_prime_export)(struct drm_device *dev, |
||
918 | struct drm_gem_object *obj, int flags); |
||
919 | /* import dmabuf -> GEM */ |
||
920 | struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, |
||
921 | struct dma_buf *dma_buf); |
||
922 | |||
1408 | serge | 923 | /* vga arb irq handler */ |
924 | void (*vgaarb_irq)(struct drm_device *dev, bool state); |
||
925 | |||
2967 | Serge | 926 | /* dumb alloc support */ |
927 | int (*dumb_create)(struct drm_file *file_priv, |
||
928 | struct drm_device *dev, |
||
929 | struct drm_mode_create_dumb *args); |
||
930 | int (*dumb_map_offset)(struct drm_file *file_priv, |
||
931 | struct drm_device *dev, uint32_t handle, |
||
932 | uint64_t *offset); |
||
933 | int (*dumb_destroy)(struct drm_file *file_priv, |
||
934 | struct drm_device *dev, |
||
935 | uint32_t handle); |
||
936 | |||
1408 | serge | 937 | /* Driver private ops for this object */ |
3031 | serge | 938 | const struct vm_operations_struct *gem_vm_ops; |
1408 | serge | 939 | |
940 | int major; |
||
941 | int minor; |
||
942 | int patchlevel; |
||
943 | char *name; |
||
944 | char *desc; |
||
945 | char *date; |
||
946 | |||
947 | u32 driver_features; |
||
948 | int dev_priv_size; |
||
949 | struct drm_ioctl_desc *ioctls; |
||
950 | int num_ioctls; |
||
2967 | Serge | 951 | const struct file_operations *fops; |
952 | union { |
||
953 | struct pci_driver *pci; |
||
954 | struct platform_device *platform_device; |
||
955 | struct usb_driver *usb; |
||
956 | } kdriver; |
||
957 | struct drm_bus *bus; |
||
958 | |||
1408 | serge | 959 | /* List of devices hanging off this driver */ |
960 | struct list_head device_list; |
||
961 | }; |
||
962 | |||
2967 | Serge | 963 | #endif |
964 | |||
3243 | Serge | 965 | #define DRM_IRQ_ARGS int irq, void *arg |
966 | |||
967 | struct drm_driver { |
||
3262 | Serge | 968 | int (*open) (struct drm_device *, struct drm_file *); |
969 | |||
3243 | Serge | 970 | irqreturn_t (*irq_handler) (DRM_IRQ_ARGS); |
971 | void (*irq_preinstall) (struct drm_device *dev); |
||
972 | int (*irq_postinstall) (struct drm_device *dev); |
||
3262 | Serge | 973 | |
974 | int (*gem_init_object) (struct drm_gem_object *obj); |
||
975 | void (*gem_free_object) (struct drm_gem_object *obj); |
||
3255 | Serge | 976 | int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); |
977 | void (*gem_close_object) (struct drm_gem_object *, struct drm_file *); |
||
3482 | Serge | 978 | u32 driver_features; |
3243 | Serge | 979 | }; |
980 | |||
981 | |||
1408 | serge | 982 | #define DRM_MINOR_UNASSIGNED 0 |
983 | #define DRM_MINOR_LEGACY 1 |
||
984 | #define DRM_MINOR_CONTROL 2 |
||
985 | #define DRM_MINOR_RENDER 3 |
||
986 | |||
987 | |||
988 | /** |
||
989 | * debugfs node list. This structure represents a debugfs file to |
||
990 | * be created by the drm core |
||
991 | */ |
||
992 | struct drm_debugfs_list { |
||
993 | const char *name; /** file name */ |
||
2967 | Serge | 994 | // int (*show)(struct seq_file*, void*); /** show callback */ |
1408 | serge | 995 | u32 driver_features; /**< Required driver features for this entry */ |
996 | }; |
||
997 | |||
998 | /** |
||
999 | * debugfs node structure. This structure represents a debugfs file. |
||
1000 | */ |
||
1001 | struct drm_debugfs_node { |
||
1002 | struct list_head list; |
||
1003 | struct drm_minor *minor; |
||
1004 | struct drm_debugfs_list *debugfs_ent; |
||
1005 | struct dentry *dent; |
||
1006 | }; |
||
1007 | |||
1008 | /** |
||
1009 | * Info file list entry. This structure represents a debugfs or proc file to |
||
1010 | * be created by the drm core |
||
1011 | */ |
||
1012 | struct drm_info_list { |
||
1013 | const char *name; /** file name */ |
||
2967 | Serge | 1014 | // int (*show)(struct seq_file*, void*); /** show callback */ |
1408 | serge | 1015 | u32 driver_features; /**< Required driver features for this entry */ |
1016 | void *data; |
||
1017 | }; |
||
1018 | |||
1019 | /** |
||
1020 | * debugfs node structure. This structure represents a debugfs file. |
||
1021 | */ |
||
1022 | struct drm_info_node { |
||
1023 | struct list_head list; |
||
1024 | struct drm_minor *minor; |
||
1025 | struct drm_info_list *info_ent; |
||
1026 | struct dentry *dent; |
||
1027 | }; |
||
1028 | |||
1029 | /** |
||
1030 | * DRM minor structure. This structure represents a drm minor number. |
||
1031 | */ |
||
1032 | struct drm_minor { |
||
1033 | int index; /**< Minor device number */ |
||
1034 | int type; /**< Control or render */ |
||
2967 | Serge | 1035 | // dev_t device; /**< Device number for mknod */ |
1036 | // struct device kdev; /**< Linux device */ |
||
1408 | serge | 1037 | struct drm_device *dev; |
1038 | |||
2967 | Serge | 1039 | // struct proc_dir_entry *proc_root; /**< proc directory entry */ |
1040 | // struct drm_info_node proc_nodes; |
||
1041 | // struct dentry *debugfs_root; |
||
1042 | // struct drm_info_node debugfs_nodes; |
||
1408 | serge | 1043 | |
2967 | Serge | 1044 | struct drm_master *master; /* currently active master for this node */ |
1045 | // struct list_head master_list; |
||
1046 | // struct drm_mode_group mode_group; |
||
1408 | serge | 1047 | }; |
1048 | |||
1964 | serge | 1049 | /* mode specified on the command line */ |
1050 | struct drm_cmdline_mode { |
||
1051 | bool specified; |
||
1052 | bool refresh_specified; |
||
1053 | bool bpp_specified; |
||
1054 | int xres, yres; |
||
1055 | int bpp; |
||
1056 | int refresh; |
||
1057 | bool rb; |
||
1058 | bool interlace; |
||
1059 | bool cvt; |
||
1060 | bool margins; |
||
1061 | enum drm_connector_force force; |
||
1062 | }; |
||
1408 | serge | 1063 | |
1064 | |||
1065 | |||
1066 | /** |
||
1067 | * DRM device structure. This structure represent a complete card that |
||
1068 | * may contain multiple heads. |
||
1069 | */ |
||
1070 | struct drm_device { |
||
1071 | struct list_head driver_item; /**< list of devices per driver */ |
||
1072 | char *devname; /**< For /proc/interrupts */ |
||
1073 | int if_version; /**< Highest interface version set */ |
||
1074 | |||
1075 | /** \name Locks */ |
||
1076 | /*@{ */ |
||
1077 | spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ |
||
1630 | serge | 1078 | struct mutex struct_mutex; /**< For others */ |
1408 | serge | 1079 | /*@} */ |
1080 | |||
1081 | /** \name Usage Counters */ |
||
1082 | /*@{ */ |
||
1083 | int open_count; /**< Outstanding files open */ |
||
1084 | atomic_t ioctl_count; /**< Outstanding IOCTLs pending */ |
||
1085 | atomic_t vma_count; /**< Outstanding vma areas open */ |
||
1086 | int buf_use; /**< Buffers in use -- cannot alloc */ |
||
1087 | atomic_t buf_alloc; /**< Buffer allocation in progress */ |
||
1088 | /*@} */ |
||
1089 | |||
1090 | /** \name Performance counters */ |
||
1091 | /*@{ */ |
||
1092 | unsigned long counters; |
||
1093 | // enum drm_stat_type types[15]; |
||
1094 | atomic_t counts[15]; |
||
1095 | /*@} */ |
||
1096 | |||
1097 | struct list_head filelist; |
||
1098 | |||
1099 | /** \name Memory management */ |
||
1100 | /*@{ */ |
||
1101 | struct list_head maplist; /**< Linked list of regions */ |
||
1102 | int map_count; /**< Number of mappable regions */ |
||
1103 | // struct drm_open_hash map_hash; /**< User token hash table for maps */ |
||
1104 | |||
1105 | /** \name Context handle management */ |
||
1106 | /*@{ */ |
||
1107 | struct list_head ctxlist; /**< Linked list of context handles */ |
||
1108 | int ctx_count; /**< Number of context handles */ |
||
1630 | serge | 1109 | struct mutex ctxlist_mutex; /**< For ctxlist */ |
1408 | serge | 1110 | |
1964 | serge | 1111 | struct idr ctx_idr; |
1408 | serge | 1112 | |
1113 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
||
1114 | |||
1115 | /*@} */ |
||
1116 | |||
3031 | serge | 1117 | /** \name DMA support */ |
1408 | serge | 1118 | /*@{ */ |
1119 | // struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
||
1120 | /*@} */ |
||
1121 | |||
1122 | /** \name Context support */ |
||
1123 | /*@{ */ |
||
1124 | int irq_enabled; /**< True if irq handler is enabled */ |
||
1125 | __volatile__ long context_flag; /**< Context swapping flag */ |
||
1126 | __volatile__ long interrupt_flag; /**< Interruption handler flag */ |
||
1127 | __volatile__ long dma_flag; /**< DMA dispatch flag */ |
||
1128 | // wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */ |
||
1129 | int last_checked; /**< Last context checked for DMA */ |
||
1130 | int last_context; /**< Last current context */ |
||
1131 | unsigned long last_switch; /**< jiffies at last context switch */ |
||
1132 | /*@} */ |
||
1133 | |||
1134 | // struct work_struct work; |
||
1135 | /** \name VBLANK IRQ support */ |
||
1136 | /*@{ */ |
||
1137 | |||
1138 | /* |
||
1139 | * At load time, disabling the vblank interrupt won't be allowed since |
||
1140 | * old clients may not call the modeset ioctl and therefore misbehave. |
||
1141 | * Once the modeset ioctl *has* been called though, we can safely |
||
1142 | * disable them when unused. |
||
1143 | */ |
||
1144 | int vblank_disable_allowed; |
||
1145 | |||
1146 | // wait_queue_head_t *vbl_queue; /**< VBLANK wait queue */ |
||
1147 | atomic_t *_vblank_count; /**< number of VBLANK interrupts (driver must alloc the right number of counters) */ |
||
1964 | serge | 1148 | struct timeval *_vblank_time; /**< timestamp of current vblank_count (drivers must alloc right number of fields) */ |
1149 | spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ |
||
1408 | serge | 1150 | spinlock_t vbl_lock; |
1151 | atomic_t *vblank_refcount; /* number of users of vblank interruptsper crtc */ |
||
1152 | u32 *last_vblank; /* protected by dev->vbl_lock, used */ |
||
1153 | /* for wraparound handling */ |
||
1154 | int *vblank_enabled; /* so we don't call enable more than |
||
1155 | once per disable */ |
||
1156 | int *vblank_inmodeset; /* Display driver is setting mode */ |
||
1157 | u32 *last_vblank_wait; /* Last vblank seqno waited per CRTC */ |
||
1158 | // struct timer_list vblank_disable_timer; |
||
1159 | |||
1160 | u32 max_vblank_count; /**< size of vblank counter register */ |
||
1161 | |||
1964 | serge | 1162 | /** |
1163 | * List of events |
||
1164 | */ |
||
1165 | struct list_head vblank_event_list; |
||
1166 | spinlock_t event_lock; |
||
1167 | |||
1408 | serge | 1168 | /*@} */ |
1169 | // cycles_t ctx_start; |
||
1170 | // cycles_t lck_start; |
||
1171 | |||
1172 | // struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */ |
||
1173 | // wait_queue_head_t buf_readers; /**< Processes waiting to read */ |
||
1174 | // wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */ |
||
1175 | |||
1176 | // struct drm_agp_head *agp; /**< AGP data */ |
||
1177 | |||
1964 | serge | 1178 | struct device *dev; /**< Device structure */ |
1408 | serge | 1179 | struct pci_dev *pdev; /**< PCI device structure */ |
1180 | int pci_vendor; /**< PCI vendor id */ |
||
1181 | int pci_device; /**< PCI device id */ |
||
1964 | serge | 1182 | unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
1408 | serge | 1183 | void *dev_private; /**< device private data */ |
1184 | void *mm_private; |
||
1185 | struct address_space *dev_mapping; |
||
1186 | // struct drm_sigdata sigdata; /**< For block_all_signals */ |
||
1187 | // sigset_t sigmask; |
||
1188 | |||
3243 | Serge | 1189 | struct drm_driver *driver; |
1408 | serge | 1190 | // struct drm_local_map *agp_buffer_map; |
1191 | // unsigned int agp_buffer_token; |
||
1192 | // struct drm_minor *control; /**< Control node for card */ |
||
2967 | Serge | 1193 | struct drm_minor *primary; /**< render type primary screen head */ |
1408 | serge | 1194 | |
1195 | struct drm_mode_config mode_config; /**< Current mode config */ |
||
1196 | |||
1197 | /** \name GEM information */ |
||
1198 | /*@{ */ |
||
1199 | spinlock_t object_name_lock; |
||
1964 | serge | 1200 | struct idr object_name_idr; |
1408 | serge | 1201 | /*@} */ |
1964 | serge | 1202 | int switch_power_state; |
3031 | serge | 1203 | |
1204 | atomic_t unplugged; /* device has been unplugged or gone away */ |
||
1408 | serge | 1205 | }; |
1206 | |||
1964 | serge | 1207 | #define DRM_SWITCH_POWER_ON 0 |
1208 | #define DRM_SWITCH_POWER_OFF 1 |
||
1209 | #define DRM_SWITCH_POWER_CHANGING 2 |
||
1210 | |||
3482 | Serge | 1211 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
1212 | int feature) |
||
1213 | { |
||
1214 | return ((dev->driver->driver_features & feature) ? 1 : 0); |
||
1215 | } |
||
1964 | serge | 1216 | |
1408 | serge | 1217 | static inline int drm_dev_to_irq(struct drm_device *dev) |
1218 | { |
||
1219 | return dev->pdev->irq; |
||
1220 | } |
||
1221 | |||
2967 | Serge | 1222 | #if 0 |
1408 | serge | 1223 | |
1224 | #ifdef __alpha__ |
||
1225 | #define drm_get_pci_domain(dev) dev->hose->index |
||
1226 | #else |
||
1227 | #define drm_get_pci_domain(dev) 0 |
||
1228 | #endif |
||
1229 | |||
1230 | #if __OS_HAS_AGP |
||
1231 | static inline int drm_core_has_AGP(struct drm_device *dev) |
||
1232 | { |
||
1233 | return drm_core_check_feature(dev, DRIVER_USE_AGP); |
||
1234 | } |
||
1235 | #else |
||
1236 | #define drm_core_has_AGP(dev) (0) |
||
1237 | #endif |
||
1238 | |||
1239 | #if __OS_HAS_MTRR |
||
1240 | static inline int drm_core_has_MTRR(struct drm_device *dev) |
||
1241 | { |
||
1242 | return drm_core_check_feature(dev, DRIVER_USE_MTRR); |
||
1243 | } |
||
1244 | |||
1245 | #define DRM_MTRR_WC MTRR_TYPE_WRCOMB |
||
1246 | |||
1247 | static inline int drm_mtrr_add(unsigned long offset, unsigned long size, |
||
1248 | unsigned int flags) |
||
1249 | { |
||
1250 | return mtrr_add(offset, size, flags, 1); |
||
1251 | } |
||
1252 | |||
1253 | static inline int drm_mtrr_del(int handle, unsigned long offset, |
||
1254 | unsigned long size, unsigned int flags) |
||
1255 | { |
||
1256 | return mtrr_del(handle, offset, size); |
||
1257 | } |
||
1258 | |||
1259 | #else |
||
1260 | #define drm_core_has_MTRR(dev) (0) |
||
1261 | |||
1262 | #define DRM_MTRR_WC 0 |
||
1263 | |||
1264 | static inline int drm_mtrr_add(unsigned long offset, unsigned long size, |
||
1265 | unsigned int flags) |
||
1266 | { |
||
1267 | return 0; |
||
1268 | } |
||
1269 | |||
1270 | static inline int drm_mtrr_del(int handle, unsigned long offset, |
||
1271 | unsigned long size, unsigned int flags) |
||
1272 | { |
||
1273 | return 0; |
||
1274 | } |
||
1275 | #endif |
||
1276 | |||
1277 | /******************************************************************/ |
||
1278 | /** \name Internal function definitions */ |
||
1279 | /*@{*/ |
||
1280 | |||
1281 | /* Driver support (drm_drv.h) */ |
||
1282 | extern long drm_ioctl(struct file *filp, |
||
1283 | unsigned int cmd, unsigned long arg); |
||
1284 | extern long drm_compat_ioctl(struct file *filp, |
||
1285 | unsigned int cmd, unsigned long arg); |
||
1286 | extern int drm_lastclose(struct drm_device *dev); |
||
1287 | |||
1288 | /* Device support (drm_fops.h) */ |
||
1964 | serge | 1289 | extern struct mutex drm_global_mutex; |
1408 | serge | 1290 | extern int drm_open(struct inode *inode, struct file *filp); |
1291 | extern int drm_stub_open(struct inode *inode, struct file *filp); |
||
1292 | extern int drm_fasync(int fd, struct file *filp, int on); |
||
1293 | extern ssize_t drm_read(struct file *filp, char __user *buffer, |
||
1294 | size_t count, loff_t *offset); |
||
1295 | extern int drm_release(struct inode *inode, struct file *filp); |
||
1296 | |||
1297 | /* Mapping support (drm_vm.h) */ |
||
1298 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); |
||
1299 | extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); |
||
3031 | serge | 1300 | extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma); |
1301 | extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma); |
||
1408 | serge | 1302 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
1303 | |||
1304 | /* Memory management support (drm_memory.h) */ |
||
3031 | serge | 1305 | #include |
1964 | serge | 1306 | extern void drm_free_agp(DRM_AGP_MEM * handle, int pages); |
1408 | serge | 1307 | extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); |
1308 | extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, |
||
1309 | struct page **pages, |
||
1310 | unsigned long num_pages, |
||
1311 | uint32_t gtt_offset, |
||
1312 | uint32_t type); |
||
1313 | extern int drm_unbind_agp(DRM_AGP_MEM * handle); |
||
1314 | |||
1315 | /* Misc. IOCTL support (drm_ioctl.h) */ |
||
1316 | extern int drm_irq_by_busid(struct drm_device *dev, void *data, |
||
1317 | struct drm_file *file_priv); |
||
1318 | extern int drm_getunique(struct drm_device *dev, void *data, |
||
1319 | struct drm_file *file_priv); |
||
1320 | extern int drm_setunique(struct drm_device *dev, void *data, |
||
1321 | struct drm_file *file_priv); |
||
1322 | extern int drm_getmap(struct drm_device *dev, void *data, |
||
1323 | struct drm_file *file_priv); |
||
1324 | extern int drm_getclient(struct drm_device *dev, void *data, |
||
1325 | struct drm_file *file_priv); |
||
1326 | extern int drm_getstats(struct drm_device *dev, void *data, |
||
1327 | struct drm_file *file_priv); |
||
1964 | serge | 1328 | extern int drm_getcap(struct drm_device *dev, void *data, |
1329 | struct drm_file *file_priv); |
||
1408 | serge | 1330 | extern int drm_setversion(struct drm_device *dev, void *data, |
1331 | struct drm_file *file_priv); |
||
1332 | extern int drm_noop(struct drm_device *dev, void *data, |
||
1333 | struct drm_file *file_priv); |
||
1334 | |||
1335 | /* Context IOCTL support (drm_context.h) */ |
||
1336 | extern int drm_resctx(struct drm_device *dev, void *data, |
||
1337 | struct drm_file *file_priv); |
||
1338 | extern int drm_addctx(struct drm_device *dev, void *data, |
||
1339 | struct drm_file *file_priv); |
||
1340 | extern int drm_modctx(struct drm_device *dev, void *data, |
||
1341 | struct drm_file *file_priv); |
||
1342 | extern int drm_getctx(struct drm_device *dev, void *data, |
||
1343 | struct drm_file *file_priv); |
||
1344 | extern int drm_switchctx(struct drm_device *dev, void *data, |
||
1345 | struct drm_file *file_priv); |
||
1346 | extern int drm_newctx(struct drm_device *dev, void *data, |
||
1347 | struct drm_file *file_priv); |
||
1348 | extern int drm_rmctx(struct drm_device *dev, void *data, |
||
1349 | struct drm_file *file_priv); |
||
1350 | |||
1351 | extern int drm_ctxbitmap_init(struct drm_device *dev); |
||
1352 | extern void drm_ctxbitmap_cleanup(struct drm_device *dev); |
||
1353 | extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); |
||
1354 | |||
1355 | extern int drm_setsareactx(struct drm_device *dev, void *data, |
||
1356 | struct drm_file *file_priv); |
||
1357 | extern int drm_getsareactx(struct drm_device *dev, void *data, |
||
1358 | struct drm_file *file_priv); |
||
1359 | |||
1360 | /* Authentication IOCTL support (drm_auth.h) */ |
||
1361 | extern int drm_getmagic(struct drm_device *dev, void *data, |
||
1362 | struct drm_file *file_priv); |
||
1363 | extern int drm_authmagic(struct drm_device *dev, void *data, |
||
1364 | struct drm_file *file_priv); |
||
2967 | Serge | 1365 | extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic); |
1408 | serge | 1366 | |
1367 | /* Cache management (drm_cache.c) */ |
||
1368 | void drm_clflush_pages(struct page *pages[], unsigned long num_pages); |
||
3031 | serge | 1369 | void drm_clflush_sg(struct sg_table *st); |
1370 | void drm_clflush_virt_range(char *addr, unsigned long length); |
||
1408 | serge | 1371 | |
1372 | /* Locking IOCTL support (drm_lock.h) */ |
||
1373 | extern int drm_lock(struct drm_device *dev, void *data, |
||
1374 | struct drm_file *file_priv); |
||
1375 | extern int drm_unlock(struct drm_device *dev, void *data, |
||
1376 | struct drm_file *file_priv); |
||
1377 | extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); |
||
1378 | extern void drm_idlelock_take(struct drm_lock_data *lock_data); |
||
1379 | extern void drm_idlelock_release(struct drm_lock_data *lock_data); |
||
1380 | |||
1381 | /* |
||
1382 | * These are exported to drivers so that they can implement fencing using |
||
1383 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
||
1384 | */ |
||
1385 | |||
1386 | extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv); |
||
1387 | |||
1388 | /* Buffer management support (drm_bufs.h) */ |
||
1389 | extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); |
||
1390 | extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request); |
||
1391 | extern int drm_addmap(struct drm_device *dev, resource_size_t offset, |
||
1392 | unsigned int size, enum drm_map_type type, |
||
1393 | enum drm_map_flags flags, struct drm_local_map **map_ptr); |
||
1394 | extern int drm_addmap_ioctl(struct drm_device *dev, void *data, |
||
1395 | struct drm_file *file_priv); |
||
1396 | extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map); |
||
1397 | extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map); |
||
1398 | extern int drm_rmmap_ioctl(struct drm_device *dev, void *data, |
||
1399 | struct drm_file *file_priv); |
||
1400 | extern int drm_addbufs(struct drm_device *dev, void *data, |
||
1401 | struct drm_file *file_priv); |
||
1402 | extern int drm_infobufs(struct drm_device *dev, void *data, |
||
1403 | struct drm_file *file_priv); |
||
1404 | extern int drm_markbufs(struct drm_device *dev, void *data, |
||
1405 | struct drm_file *file_priv); |
||
1406 | extern int drm_freebufs(struct drm_device *dev, void *data, |
||
1407 | struct drm_file *file_priv); |
||
1408 | extern int drm_mapbufs(struct drm_device *dev, void *data, |
||
1409 | struct drm_file *file_priv); |
||
1410 | extern int drm_order(unsigned long size); |
||
1411 | |||
1412 | /* DMA support (drm_dma.h) */ |
||
1413 | extern int drm_dma_setup(struct drm_device *dev); |
||
1414 | extern void drm_dma_takedown(struct drm_device *dev); |
||
1415 | extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); |
||
1416 | extern void drm_core_reclaim_buffers(struct drm_device *dev, |
||
1417 | struct drm_file *filp); |
||
1418 | |||
1419 | /* IRQ support (drm_irq.h) */ |
||
1420 | extern int drm_control(struct drm_device *dev, void *data, |
||
1421 | struct drm_file *file_priv); |
||
1422 | extern int drm_irq_install(struct drm_device *dev); |
||
1423 | extern int drm_irq_uninstall(struct drm_device *dev); |
||
1424 | |||
1425 | extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); |
||
1426 | extern int drm_wait_vblank(struct drm_device *dev, void *data, |
||
1427 | struct drm_file *filp); |
||
1428 | extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); |
||
1429 | extern u32 drm_vblank_count(struct drm_device *dev, int crtc); |
||
1964 | serge | 1430 | extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, |
1431 | struct timeval *vblanktime); |
||
3391 | Serge | 1432 | extern void drm_send_vblank_event(struct drm_device *dev, int crtc, |
1433 | struct drm_pending_vblank_event *e); |
||
1964 | serge | 1434 | extern bool drm_handle_vblank(struct drm_device *dev, int crtc); |
1408 | serge | 1435 | extern int drm_vblank_get(struct drm_device *dev, int crtc); |
1436 | extern void drm_vblank_put(struct drm_device *dev, int crtc); |
||
1437 | extern void drm_vblank_off(struct drm_device *dev, int crtc); |
||
1438 | extern void drm_vblank_cleanup(struct drm_device *dev); |
||
1964 | serge | 1439 | extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc, |
1440 | struct timeval *tvblank, unsigned flags); |
||
1441 | extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, |
||
1442 | int crtc, int *max_error, |
||
1443 | struct timeval *vblank_time, |
||
1444 | unsigned flags, |
||
1445 | struct drm_crtc *refcrtc); |
||
1446 | extern void drm_calc_timestamping_constants(struct drm_crtc *crtc); |
||
1447 | |||
1448 | extern bool |
||
1449 | drm_mode_parse_command_line_for_connector(const char *mode_option, |
||
1450 | struct drm_connector *connector, |
||
1451 | struct drm_cmdline_mode *mode); |
||
1452 | |||
1453 | extern struct drm_display_mode * |
||
1454 | drm_mode_create_from_cmdline_mode(struct drm_device *dev, |
||
1455 | struct drm_cmdline_mode *cmd); |
||
1456 | |||
3391 | Serge | 1457 | extern int drm_display_mode_from_videomode(const struct videomode *vm, |
1458 | struct drm_display_mode *dmode); |
||
1459 | extern int of_get_drm_display_mode(struct device_node *np, |
||
1460 | struct drm_display_mode *dmode, |
||
1461 | int index); |
||
1462 | |||
1408 | serge | 1463 | /* Modesetting support */ |
1464 | extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); |
||
1465 | extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); |
||
1466 | extern int drm_modeset_ctl(struct drm_device *dev, void *data, |
||
1467 | struct drm_file *file_priv); |
||
1468 | |||
1469 | /* AGP/GART support (drm_agpsupport.h) */ |
||
1470 | extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); |
||
1471 | extern int drm_agp_acquire(struct drm_device *dev); |
||
1472 | extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, |
||
1473 | struct drm_file *file_priv); |
||
1474 | extern int drm_agp_release(struct drm_device *dev); |
||
1475 | extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, |
||
1476 | struct drm_file *file_priv); |
||
1477 | extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); |
||
1478 | extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, |
||
1479 | struct drm_file *file_priv); |
||
1480 | extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); |
||
1481 | extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, |
||
1482 | struct drm_file *file_priv); |
||
1483 | extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); |
||
1484 | extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, |
||
1485 | struct drm_file *file_priv); |
||
1486 | extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); |
||
1487 | extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, |
||
1488 | struct drm_file *file_priv); |
||
1489 | extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); |
||
1490 | extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, |
||
1491 | struct drm_file *file_priv); |
||
1492 | extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); |
||
1493 | extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, |
||
1494 | struct drm_file *file_priv); |
||
1495 | |||
1496 | /* Stub support (drm_stub.h) */ |
||
1497 | extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, |
||
1498 | struct drm_file *file_priv); |
||
1499 | extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, |
||
1500 | struct drm_file *file_priv); |
||
1501 | struct drm_master *drm_master_create(struct drm_minor *minor); |
||
1502 | extern struct drm_master *drm_master_get(struct drm_master *master); |
||
1503 | extern void drm_master_put(struct drm_master **master); |
||
1964 | serge | 1504 | |
1408 | serge | 1505 | extern void drm_put_dev(struct drm_device *dev); |
1506 | extern int drm_put_minor(struct drm_minor **minor); |
||
3031 | serge | 1507 | extern void drm_unplug_dev(struct drm_device *dev); |
1508 | #endif |
||
1509 | |||
1408 | serge | 1510 | extern unsigned int drm_debug; |
1511 | |||
3031 | serge | 1512 | #if 0 |
1964 | serge | 1513 | extern unsigned int drm_vblank_offdelay; |
1514 | extern unsigned int drm_timestamp_precision; |
||
3192 | Serge | 1515 | extern unsigned int drm_timestamp_monotonic; |
1964 | serge | 1516 | |
1408 | serge | 1517 | extern struct class *drm_class; |
1518 | extern struct proc_dir_entry *drm_proc_root; |
||
1519 | extern struct dentry *drm_debugfs_root; |
||
1520 | |||
1521 | extern struct idr drm_minors_idr; |
||
1522 | |||
1523 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); |
||
1524 | |||
1525 | /* Proc support (drm_proc.h) */ |
||
1526 | extern int drm_proc_init(struct drm_minor *minor, int minor_id, |
||
1527 | struct proc_dir_entry *root); |
||
1528 | extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root); |
||
1529 | |||
1530 | /* Debugfs support */ |
||
1531 | #if defined(CONFIG_DEBUG_FS) |
||
1532 | extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
||
1533 | struct dentry *root); |
||
1534 | extern int drm_debugfs_create_files(struct drm_info_list *files, int count, |
||
1535 | struct dentry *root, struct drm_minor *minor); |
||
1536 | extern int drm_debugfs_remove_files(struct drm_info_list *files, int count, |
||
1537 | struct drm_minor *minor); |
||
1538 | extern int drm_debugfs_cleanup(struct drm_minor *minor); |
||
1539 | #endif |
||
1540 | |||
1541 | /* Info file support */ |
||
1542 | extern int drm_name_info(struct seq_file *m, void *data); |
||
1543 | extern int drm_vm_info(struct seq_file *m, void *data); |
||
1544 | extern int drm_bufs_info(struct seq_file *m, void *data); |
||
1545 | extern int drm_vblank_info(struct seq_file *m, void *data); |
||
1546 | extern int drm_clients_info(struct seq_file *m, void* data); |
||
1547 | extern int drm_gem_name_info(struct seq_file *m, void *data); |
||
1548 | |||
1549 | #if DRM_DEBUG_CODE |
||
1550 | extern int drm_vma_info(struct seq_file *m, void *data); |
||
1551 | #endif |
||
1552 | |||
1553 | /* Scatter Gather Support (drm_scatter.h) */ |
||
1554 | extern void drm_sg_cleanup(struct drm_sg_mem * entry); |
||
1555 | extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, |
||
1556 | struct drm_file *file_priv); |
||
1557 | extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); |
||
1558 | extern int drm_sg_free(struct drm_device *dev, void *data, |
||
1559 | struct drm_file *file_priv); |
||
1560 | |||
1561 | /* ATI PCIGART support (ati_pcigart.h) */ |
||
1562 | extern int drm_ati_pcigart_init(struct drm_device *dev, |
||
1563 | struct drm_ati_pcigart_info * gart_info); |
||
1564 | extern int drm_ati_pcigart_cleanup(struct drm_device *dev, |
||
1565 | struct drm_ati_pcigart_info * gart_info); |
||
3031 | serge | 1566 | #endif |
1408 | serge | 1567 | |
1568 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, |
||
1428 | serge | 1569 | size_t align); |
1408 | serge | 1570 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
1571 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
||
1572 | |||
3031 | serge | 1573 | #if 0 |
1408 | serge | 1574 | /* sysfs support (drm_sysfs.c) */ |
1575 | struct drm_sysfs_class; |
||
1576 | extern struct class *drm_sysfs_create(struct module *owner, char *name); |
||
1577 | extern void drm_sysfs_destroy(void); |
||
1578 | extern int drm_sysfs_device_add(struct drm_minor *minor); |
||
1579 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
||
1580 | extern void drm_sysfs_device_remove(struct drm_minor *minor); |
||
1581 | extern char *drm_get_connector_status_name(enum drm_connector_status status); |
||
1582 | |||
1583 | static inline int drm_sysfs_connector_add(struct drm_connector *connector) |
||
1584 | { return 0; }; |
||
1585 | |||
1586 | static inline void drm_sysfs_connector_remove(struct drm_connector *connector) |
||
1587 | { }; |
||
1588 | |||
2967 | Serge | 1589 | #endif |
1590 | |||
1408 | serge | 1591 | /* Graphics Execution Manager library functions (drm_gem.c) */ |
1592 | int drm_gem_init(struct drm_device *dev); |
||
1593 | void drm_gem_destroy(struct drm_device *dev); |
||
1964 | serge | 1594 | void drm_gem_object_release(struct drm_gem_object *obj); |
1408 | serge | 1595 | void drm_gem_object_free(struct kref *kref); |
1596 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, |
||
1597 | size_t size); |
||
1964 | serge | 1598 | int drm_gem_object_init(struct drm_device *dev, |
1599 | struct drm_gem_object *obj, size_t size); |
||
2967 | Serge | 1600 | int drm_gem_private_object_init(struct drm_device *dev, |
1601 | struct drm_gem_object *obj, size_t size); |
||
1964 | serge | 1602 | void drm_gem_object_handle_free(struct drm_gem_object *obj); |
1408 | serge | 1603 | void drm_gem_vm_open(struct vm_area_struct *vma); |
1604 | void drm_gem_vm_close(struct vm_area_struct *vma); |
||
1605 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); |
||
1606 | |||
2967 | Serge | 1607 | |
1408 | serge | 1608 | static inline void |
1609 | drm_gem_object_reference(struct drm_gem_object *obj) |
||
1610 | { |
||
1611 | kref_get(&obj->refcount); |
||
1612 | } |
||
1613 | |||
1614 | static inline void |
||
1615 | drm_gem_object_unreference(struct drm_gem_object *obj) |
||
1616 | { |
||
2967 | Serge | 1617 | if (obj != NULL) |
1618 | kref_put(&obj->refcount, drm_gem_object_free); |
||
1619 | } |
||
1408 | serge | 1620 | |
2967 | Serge | 1621 | static inline void |
1622 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) |
||
1623 | { |
||
1624 | if (obj != NULL) { |
||
1625 | struct drm_device *dev = obj->dev; |
||
1626 | mutex_lock(&dev->struct_mutex); |
||
1408 | serge | 1627 | kref_put(&obj->refcount, drm_gem_object_free); |
2967 | Serge | 1628 | mutex_unlock(&dev->struct_mutex); |
1629 | } |
||
1408 | serge | 1630 | } |
1631 | |||
1632 | int drm_gem_handle_create(struct drm_file *file_priv, |
||
1633 | struct drm_gem_object *obj, |
||
1634 | u32 *handlep); |
||
1987 | serge | 1635 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); |
1408 | serge | 1636 | |
1637 | static inline void |
||
1638 | drm_gem_object_handle_reference(struct drm_gem_object *obj) |
||
1639 | { |
||
1640 | drm_gem_object_reference(obj); |
||
1987 | serge | 1641 | atomic_inc(&obj->handle_count); |
1408 | serge | 1642 | } |
1643 | |||
1644 | static inline void |
||
1645 | drm_gem_object_handle_unreference(struct drm_gem_object *obj) |
||
1646 | { |
||
1647 | if (obj == NULL) |
||
1648 | return; |
||
1649 | |||
1987 | serge | 1650 | if (atomic_read(&obj->handle_count) == 0) |
1651 | return; |
||
1408 | serge | 1652 | /* |
1653 | * Must bump handle count first as this may be the last |
||
1654 | * ref, in which case the object would disappear before we |
||
1655 | * checked for a name |
||
1656 | */ |
||
2967 | Serge | 1657 | if (atomic_dec_and_test(&obj->handle_count)) |
1658 | drm_gem_object_handle_free(obj); |
||
1408 | serge | 1659 | drm_gem_object_unreference(obj); |
1660 | } |
||
1661 | |||
2967 | Serge | 1662 | static inline void |
1663 | drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj) |
||
1664 | { |
||
1665 | if (obj == NULL) |
||
1666 | return; |
||
1667 | |||
1668 | if (atomic_read(&obj->handle_count) == 0) |
||
1669 | return; |
||
1670 | |||
1671 | /* |
||
1672 | * Must bump handle count first as this may be the last |
||
1673 | * ref, in which case the object would disappear before we |
||
1674 | * checked for a name |
||
1675 | */ |
||
1676 | |||
1677 | if (atomic_dec_and_test(&obj->handle_count)) |
||
1678 | drm_gem_object_handle_free(obj); |
||
1679 | drm_gem_object_unreference_unlocked(obj); |
||
1680 | } |
||
1681 | |||
3192 | Serge | 1682 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); |
1683 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); |
||
2967 | Serge | 1684 | |
1408 | serge | 1685 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, |
1686 | struct drm_file *filp, |
||
1687 | u32 handle); |
||
1688 | int drm_gem_close_ioctl(struct drm_device *dev, void *data, |
||
1689 | struct drm_file *file_priv); |
||
1690 | int drm_gem_flink_ioctl(struct drm_device *dev, void *data, |
||
1691 | struct drm_file *file_priv); |
||
1692 | int drm_gem_open_ioctl(struct drm_device *dev, void *data, |
||
1693 | struct drm_file *file_priv); |
||
1694 | void drm_gem_open(struct drm_device *dev, struct drm_file *file_private); |
||
1695 | void drm_gem_release(struct drm_device *dev, struct drm_file *file_private); |
||
1696 | |||
1697 | extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev); |
||
1698 | extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev); |
||
1699 | extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev); |
||
1700 | |||
3255 | Serge | 1701 | #if 0 |
1702 | |||
1408 | serge | 1703 | static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, |
1704 | unsigned int token) |
||
1705 | { |
||
1706 | struct drm_map_list *_entry; |
||
1707 | list_for_each_entry(_entry, &dev->maplist, head) |
||
1708 | if (_entry->user_token == token) |
||
1709 | return _entry->map; |
||
1710 | return NULL; |
||
1711 | } |
||
1712 | |||
1713 | static __inline__ void drm_core_dropmap(struct drm_local_map *map) |
||
1714 | { |
||
1715 | } |
||
1716 | |||
1717 | |||
3031 | serge | 1718 | |
1408 | serge | 1719 | static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) |
1720 | { |
||
1721 | if (size * nmemb <= PAGE_SIZE) |
||
1722 | return kcalloc(nmemb, size, GFP_KERNEL); |
||
1723 | |||
1724 | if (size != 0 && nmemb > ULONG_MAX / size) |
||
1725 | return NULL; |
||
1726 | |||
1727 | return __vmalloc(size * nmemb, |
||
1728 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); |
||
1729 | } |
||
1730 | |||
1731 | static __inline void drm_free_large(void *ptr) |
||
1732 | { |
||
1733 | if (!is_vmalloc_addr(ptr)) |
||
1734 | return kfree(ptr); |
||
1735 | |||
1736 | vfree(ptr); |
||
1737 | } |
||
1738 | |||
1739 | #endif |
||
1740 | |||
3031 | serge | 1741 | #define DRM_PCIE_SPEED_25 1 |
1742 | #define DRM_PCIE_SPEED_50 2 |
||
1743 | #define DRM_PCIE_SPEED_80 4 |
||
1408 | serge | 1744 | |
3031 | serge | 1745 | extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); |
1746 | |||
2967 | Serge | 1747 | static __inline__ int drm_device_is_agp(struct drm_device *dev) |
1748 | { |
||
1749 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); |
||
1750 | } |
||
1751 | |||
1752 | static __inline__ int drm_device_is_pcie(struct drm_device *dev) |
||
1753 | { |
||
1754 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); |
||
1755 | } |
||
1408 | serge | 1756 | #endif /* __KERNEL__ */ |
3031 | serge | 1757 | |
1758 | #define drm_sysfs_connector_add(connector) |
||
1759 | #define drm_sysfs_connector_remove(connector) |
||
1760 | |||
3391 | Serge | 1761 | #define LFB_SIZE 0xC00000 |
1762 | |||
1408 | serge | 1763 | #endif=>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>><>><>><>><>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>>>>>>>><>><>><> |