Rev 1123 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1123 | 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. |
||
12 | * All rights reserved. |
||
13 | * |
||
14 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
15 | * copy of this software and associated documentation files (the "Software"), |
||
16 | * to deal in the Software without restriction, including without limitation |
||
17 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
18 | * and/or sell copies of the Software, and to permit persons to whom the |
||
19 | * Software is furnished to do so, subject to the following conditions: |
||
20 | * |
||
21 | * The above copyright notice and this permission notice (including the next |
||
22 | * paragraph) shall be included in all copies or substantial portions of the |
||
23 | * Software. |
||
24 | * |
||
25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
26 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
27 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
28 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
||
29 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
||
30 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||
31 | * OTHER DEALINGS IN THE SOFTWARE. |
||
32 | */ |
||
33 | |||
34 | #ifndef _DRM_P_H_ |
||
35 | #define _DRM_P_H_ |
||
36 | |||
37 | #include |
||
38 | #include |
||
39 | |||
40 | #include |
||
41 | #include |
||
42 | |||
43 | //#include |
||
44 | |||
45 | struct drm_file; |
||
46 | struct drm_device; |
||
47 | |||
48 | //#include "drm_os_linux.h" |
||
49 | //#include "drm_hashtab.h" |
||
50 | //#include "drm_mm.h" |
||
51 | |||
52 | #define DRM_UT_CORE 0x01 |
||
53 | #define DRM_UT_DRIVER 0x02 |
||
54 | #define DRM_UT_KMS 0x04 |
||
55 | #define DRM_UT_MODE 0x08 |
||
56 | |||
57 | #define KHZ2PICOS(a) (1000000000UL/(a)) |
||
58 | |||
59 | extern void drm_ut_debug_printk(unsigned int request_level, |
||
60 | const char *prefix, |
||
61 | const char *function_name, |
||
62 | const char *format, ...); |
||
63 | |||
64 | #define DRM_DEBUG_MODE(prefix, fmt, args...) \ |
||
65 | do { \ |
||
66 | dbgprintf("drm debug: %s" fmt, \ |
||
67 | __func__, ##args); \ |
||
68 | } while (0) |
||
69 | |||
1125 | serge | 70 | #define DRM_DEBUG(fmt, arg...) \ |
71 | printk("[" DRM_NAME ":%s] " fmt , __func__ , ##arg) |
||
72 | |||
1123 | serge | 73 | #if 0 |
74 | |||
75 | /***********************************************************************/ |
||
76 | /** \name DRM template customization defaults */ |
||
77 | /*@{*/ |
||
78 | |||
79 | /* driver capabilities and requirements mask */ |
||
80 | #define DRIVER_USE_AGP 0x1 |
||
81 | #define DRIVER_REQUIRE_AGP 0x2 |
||
82 | #define DRIVER_USE_MTRR 0x4 |
||
83 | #define DRIVER_PCI_DMA 0x8 |
||
84 | #define DRIVER_SG 0x10 |
||
85 | #define DRIVER_HAVE_DMA 0x20 |
||
86 | #define DRIVER_HAVE_IRQ 0x40 |
||
87 | #define DRIVER_IRQ_SHARED 0x80 |
||
88 | #define DRIVER_IRQ_VBL 0x100 |
||
89 | #define DRIVER_DMA_QUEUE 0x200 |
||
90 | #define DRIVER_FB_DMA 0x400 |
||
91 | #define DRIVER_IRQ_VBL2 0x800 |
||
92 | #define DRIVER_GEM 0x1000 |
||
93 | #define DRIVER_MODESET 0x2000 |
||
94 | |||
95 | /***********************************************************************/ |
||
96 | /** \name Begin the DRM... */ |
||
97 | /*@{*/ |
||
98 | |||
99 | #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then |
||
100 | also include looping detection. */ |
||
101 | |||
102 | #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */ |
||
103 | #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */ |
||
104 | #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */ |
||
105 | #define DRM_LOOPING_LIMIT 5000000 |
||
106 | #define DRM_TIME_SLICE (HZ/20) /**< Time slice for GLXContexts */ |
||
107 | #define DRM_LOCK_SLICE 1 /**< Time slice for lock, in jiffies */ |
||
108 | |||
109 | #define DRM_FLAG_DEBUG 0x01 |
||
110 | |||
111 | #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) |
||
112 | #define DRM_MAP_HASH_OFFSET 0x10000000 |
||
113 | |||
114 | /*@}*/ |
||
115 | |||
116 | /***********************************************************************/ |
||
117 | /** \name Macros to make printk easier */ |
||
118 | /*@{*/ |
||
119 | |||
120 | /** |
||
121 | * Error output. |
||
122 | * |
||
123 | * \param fmt printf() like format string. |
||
124 | * \param arg arguments |
||
125 | */ |
||
126 | #define DRM_ERROR(fmt, arg...) \ |
||
127 | printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg) |
||
128 | |||
129 | /** |
||
130 | * Memory error output. |
||
131 | * |
||
132 | * \param area memory area where the error occurred. |
||
133 | * \param fmt printf() like format string. |
||
134 | * \param arg arguments |
||
135 | */ |
||
136 | #define DRM_MEM_ERROR(area, fmt, arg...) \ |
||
137 | printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __func__, \ |
||
138 | drm_mem_stats[area].name , ##arg) |
||
139 | |||
140 | #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg) |
||
141 | |||
142 | /** |
||
143 | * Debug output. |
||
144 | * |
||
145 | * \param fmt printf() like format string. |
||
146 | * \param arg arguments |
||
147 | */ |
||
148 | #if DRM_DEBUG_CODE |
||
149 | #define DRM_DEBUG(fmt, args...) \ |
||
150 | do { \ |
||
151 | drm_ut_debug_printk(DRM_UT_CORE, DRM_NAME, \ |
||
152 | __func__, fmt, ##args); \ |
||
153 | } while (0) |
||
154 | |||
155 | #define DRM_DEBUG_DRIVER(prefix, fmt, args...) \ |
||
156 | do { \ |
||
157 | drm_ut_debug_printk(DRM_UT_DRIVER, prefix, \ |
||
158 | __func__, fmt, ##args); \ |
||
159 | } while (0) |
||
160 | #define DRM_DEBUG_KMS(prefix, fmt, args...) \ |
||
161 | do { \ |
||
162 | drm_ut_debug_printk(DRM_UT_KMS, prefix, \ |
||
163 | __func__, fmt, ##args); \ |
||
164 | } while (0) |
||
165 | #define DRM_DEBUG_MODE(prefix, fmt, args...) \ |
||
166 | do { \ |
||
167 | drm_ut_debug_printk(DRM_UT_MODE, prefix, \ |
||
168 | __func__, fmt, ##args); \ |
||
169 | } while (0) |
||
170 | #define DRM_LOG(fmt, args...) \ |
||
171 | do { \ |
||
172 | drm_ut_debug_printk(DRM_UT_CORE, NULL, \ |
||
173 | NULL, fmt, ##args); \ |
||
174 | } while (0) |
||
175 | #define DRM_LOG_KMS(fmt, args...) \ |
||
176 | do { \ |
||
177 | drm_ut_debug_printk(DRM_UT_KMS, NULL, \ |
||
178 | NULL, fmt, ##args); \ |
||
179 | } while (0) |
||
180 | #define DRM_LOG_MODE(fmt, args...) \ |
||
181 | do { \ |
||
182 | drm_ut_debug_printk(DRM_UT_MODE, NULL, \ |
||
183 | NULL, fmt, ##args); \ |
||
184 | } while (0) |
||
185 | #define DRM_LOG_DRIVER(fmt, args...) \ |
||
186 | do { \ |
||
187 | drm_ut_debug_printk(DRM_UT_DRIVER, NULL, \ |
||
188 | NULL, fmt, ##args); \ |
||
189 | } while (0) |
||
190 | #else |
||
191 | #define DRM_DEBUG_DRIVER(prefix, fmt, args...) do { } while (0) |
||
192 | #define DRM_DEBUG_KMS(prefix, fmt, args...) do { } while (0) |
||
193 | #define DRM_DEBUG_MODE(prefix, fmt, args...) do { } while (0) |
||
194 | #define DRM_DEBUG(fmt, arg...) do { } while (0) |
||
195 | #define DRM_LOG(fmt, arg...) do { } while (0) |
||
196 | #define DRM_LOG_KMS(fmt, args...) do { } while (0) |
||
197 | #define DRM_LOG_MODE(fmt, arg...) do { } while (0) |
||
198 | #define DRM_LOG_DRIVER(fmt, arg...) do { } while (0) |
||
199 | |||
200 | #endif |
||
201 | |||
202 | #define DRM_PROC_LIMIT (PAGE_SIZE-80) |
||
203 | |||
204 | #define DRM_PROC_PRINT(fmt, arg...) \ |
||
205 | len += sprintf(&buf[len], fmt , ##arg); \ |
||
206 | if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; } |
||
207 | |||
208 | #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \ |
||
209 | len += sprintf(&buf[len], fmt , ##arg); \ |
||
210 | if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; } |
||
211 | |||
212 | /*@}*/ |
||
213 | |||
214 | /***********************************************************************/ |
||
215 | /** \name Internal types and structures */ |
||
216 | /*@{*/ |
||
217 | |||
218 | #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x) |
||
219 | |||
220 | #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1)) |
||
221 | #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x)) |
||
222 | #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist) |
||
223 | |||
224 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
||
225 | /** |
||
226 | * Get the private SAREA mapping. |
||
227 | * |
||
228 | * \param _dev DRM device. |
||
229 | * \param _ctx context number. |
||
230 | * \param _map output mapping. |
||
231 | */ |
||
232 | #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \ |
||
233 | (_map) = (_dev)->context_sareas[_ctx]; \ |
||
234 | } while(0) |
||
235 | |||
236 | /** |
||
237 | * Test that the hardware lock is held by the caller, returning otherwise. |
||
238 | * |
||
239 | * \param dev DRM device. |
||
240 | * \param filp file pointer of the caller. |
||
241 | */ |
||
242 | #define LOCK_TEST_WITH_RETURN( dev, _file_priv ) \ |
||
243 | do { \ |
||
244 | if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) || \ |
||
245 | _file_priv->master->lock.file_priv != _file_priv) { \ |
||
246 | DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ |
||
247 | __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\ |
||
248 | _file_priv->master->lock.file_priv, _file_priv); \ |
||
249 | return -EINVAL; \ |
||
250 | } \ |
||
251 | } while (0) |
||
252 | |||
253 | /** |
||
254 | * Copy and IOCTL return string to user space |
||
255 | */ |
||
256 | #define DRM_COPY( name, value ) \ |
||
257 | len = strlen( value ); \ |
||
258 | if ( len > name##_len ) len = name##_len; \ |
||
259 | name##_len = strlen( value ); \ |
||
260 | if ( len && name ) { \ |
||
261 | if ( copy_to_user( name, value, len ) ) \ |
||
262 | return -EFAULT; \ |
||
263 | } |
||
264 | |||
265 | /** |
||
266 | * Ioctl function type. |
||
267 | * |
||
268 | * \param inode device inode. |
||
269 | * \param file_priv DRM file private pointer. |
||
270 | * \param cmd command. |
||
271 | * \param arg argument. |
||
272 | */ |
||
273 | typedef int drm_ioctl_t(struct drm_device *dev, void *data, |
||
274 | struct drm_file *file_priv); |
||
275 | |||
276 | typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, |
||
277 | unsigned long arg); |
||
278 | |||
279 | #define DRM_AUTH 0x1 |
||
280 | #define DRM_MASTER 0x2 |
||
281 | #define DRM_ROOT_ONLY 0x4 |
||
282 | #define DRM_CONTROL_ALLOW 0x8 |
||
283 | |||
284 | struct drm_ioctl_desc { |
||
285 | unsigned int cmd; |
||
286 | int flags; |
||
287 | drm_ioctl_t *func; |
||
288 | }; |
||
289 | |||
290 | /** |
||
291 | * Creates a driver or general drm_ioctl_desc array entry for the given |
||
292 | * ioctl, for use by drm_ioctl(). |
||
293 | */ |
||
294 | #define DRM_IOCTL_DEF(ioctl, _func, _flags) \ |
||
295 | [DRM_IOCTL_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags} |
||
296 | |||
297 | struct drm_magic_entry { |
||
298 | struct list_head head; |
||
299 | struct drm_hash_item hash_item; |
||
300 | struct drm_file *priv; |
||
301 | }; |
||
302 | |||
303 | struct drm_vma_entry { |
||
304 | struct list_head head; |
||
305 | struct vm_area_struct *vma; |
||
306 | pid_t pid; |
||
307 | }; |
||
308 | |||
309 | /** |
||
310 | * DMA buffer. |
||
311 | */ |
||
312 | struct drm_buf { |
||
313 | int idx; /**< Index into master buflist */ |
||
314 | int total; /**< Buffer size */ |
||
315 | int order; /**< log-base-2(total) */ |
||
316 | int used; /**< Amount of buffer in use (for DMA) */ |
||
317 | unsigned long offset; /**< Byte offset (used internally) */ |
||
318 | void *address; /**< Address of buffer */ |
||
319 | unsigned long bus_address; /**< Bus address of buffer */ |
||
320 | struct drm_buf *next; /**< Kernel-only: used for free list */ |
||
321 | __volatile__ int waiting; /**< On kernel DMA queue */ |
||
322 | __volatile__ int pending; /**< On hardware DMA queue */ |
||
323 | wait_queue_head_t dma_wait; /**< Processes waiting */ |
||
324 | struct drm_file *file_priv; /**< Private of holding file descr */ |
||
325 | int context; /**< Kernel queue for this buffer */ |
||
326 | int while_locked; /**< Dispatch this buffer while locked */ |
||
327 | enum { |
||
328 | DRM_LIST_NONE = 0, |
||
329 | DRM_LIST_FREE = 1, |
||
330 | DRM_LIST_WAIT = 2, |
||
331 | DRM_LIST_PEND = 3, |
||
332 | DRM_LIST_PRIO = 4, |
||
333 | DRM_LIST_RECLAIM = 5 |
||
334 | } list; /**< Which list we're on */ |
||
335 | |||
336 | int dev_priv_size; /**< Size of buffer private storage */ |
||
337 | void *dev_private; /**< Per-buffer private storage */ |
||
338 | }; |
||
339 | |||
340 | /** bufs is one longer than it has to be */ |
||
341 | struct drm_waitlist { |
||
342 | int count; /**< Number of possible buffers */ |
||
343 | struct drm_buf **bufs; /**< List of pointers to buffers */ |
||
344 | struct drm_buf **rp; /**< Read pointer */ |
||
345 | struct drm_buf **wp; /**< Write pointer */ |
||
346 | struct drm_buf **end; /**< End pointer */ |
||
347 | spinlock_t read_lock; |
||
348 | spinlock_t write_lock; |
||
349 | }; |
||
350 | |||
351 | struct drm_freelist { |
||
352 | int initialized; /**< Freelist in use */ |
||
353 | atomic_t count; /**< Number of free buffers */ |
||
354 | struct drm_buf *next; /**< End pointer */ |
||
355 | |||
356 | wait_queue_head_t waiting; /**< Processes waiting on free bufs */ |
||
357 | int low_mark; /**< Low water mark */ |
||
358 | int high_mark; /**< High water mark */ |
||
359 | atomic_t wfh; /**< If waiting for high mark */ |
||
360 | spinlock_t lock; |
||
361 | }; |
||
362 | |||
363 | typedef struct drm_dma_handle { |
||
364 | dma_addr_t busaddr; |
||
365 | void *vaddr; |
||
366 | size_t size; |
||
367 | } drm_dma_handle_t; |
||
368 | |||
369 | /** |
||
370 | * Buffer entry. There is one of this for each buffer size order. |
||
371 | */ |
||
372 | struct drm_buf_entry { |
||
373 | int buf_size; /**< size */ |
||
374 | int buf_count; /**< number of buffers */ |
||
375 | struct drm_buf *buflist; /**< buffer list */ |
||
376 | int seg_count; |
||
377 | int page_order; |
||
378 | struct drm_dma_handle **seglist; |
||
379 | |||
380 | struct drm_freelist freelist; |
||
381 | }; |
||
382 | |||
383 | /** File private data */ |
||
384 | struct drm_file { |
||
385 | int authenticated; |
||
386 | pid_t pid; |
||
387 | uid_t uid; |
||
388 | drm_magic_t magic; |
||
389 | unsigned long ioctl_count; |
||
390 | struct list_head lhead; |
||
391 | struct drm_minor *minor; |
||
392 | unsigned long lock_count; |
||
393 | |||
394 | /** Mapping of mm object handles to object pointers. */ |
||
395 | struct idr object_idr; |
||
396 | /** Lock for synchronization of access to object_idr. */ |
||
397 | spinlock_t table_lock; |
||
398 | |||
399 | struct file *filp; |
||
400 | void *driver_priv; |
||
401 | |||
402 | int is_master; /* this file private is a master for a minor */ |
||
403 | struct drm_master *master; /* master this node is currently associated with |
||
404 | N.B. not always minor->master */ |
||
405 | struct list_head fbs; |
||
406 | }; |
||
407 | |||
408 | /** Wait queue */ |
||
409 | struct drm_queue { |
||
410 | atomic_t use_count; /**< Outstanding uses (+1) */ |
||
411 | atomic_t finalization; /**< Finalization in progress */ |
||
412 | atomic_t block_count; /**< Count of processes waiting */ |
||
413 | atomic_t block_read; /**< Queue blocked for reads */ |
||
414 | wait_queue_head_t read_queue; /**< Processes waiting on block_read */ |
||
415 | atomic_t block_write; /**< Queue blocked for writes */ |
||
416 | wait_queue_head_t write_queue; /**< Processes waiting on block_write */ |
||
417 | atomic_t total_queued; /**< Total queued statistic */ |
||
418 | atomic_t total_flushed; /**< Total flushes statistic */ |
||
419 | atomic_t total_locks; /**< Total locks statistics */ |
||
420 | enum drm_ctx_flags flags; /**< Context preserving and 2D-only */ |
||
421 | struct drm_waitlist waitlist; /**< Pending buffers */ |
||
422 | wait_queue_head_t flush_queue; /**< Processes waiting until flush */ |
||
423 | }; |
||
424 | |||
425 | /** |
||
426 | * Lock data. |
||
427 | */ |
||
428 | struct drm_lock_data { |
||
429 | struct drm_hw_lock *hw_lock; /**< Hardware lock */ |
||
430 | /** Private of lock holder's file (NULL=kernel) */ |
||
431 | struct drm_file *file_priv; |
||
432 | wait_queue_head_t lock_queue; /**< Queue of blocked processes */ |
||
433 | unsigned long lock_time; /**< Time of last lock in jiffies */ |
||
434 | spinlock_t spinlock; |
||
435 | uint32_t kernel_waiters; |
||
436 | uint32_t user_waiters; |
||
437 | int idle_has_lock; |
||
438 | }; |
||
439 | |||
440 | /** |
||
441 | * DMA data. |
||
442 | */ |
||
443 | struct drm_device_dma { |
||
444 | |||
445 | struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */ |
||
446 | int buf_count; /**< total number of buffers */ |
||
447 | struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */ |
||
448 | int seg_count; |
||
449 | int page_count; /**< number of pages */ |
||
450 | unsigned long *pagelist; /**< page list */ |
||
451 | unsigned long byte_count; |
||
452 | enum { |
||
453 | _DRM_DMA_USE_AGP = 0x01, |
||
454 | _DRM_DMA_USE_SG = 0x02, |
||
455 | _DRM_DMA_USE_FB = 0x04, |
||
456 | _DRM_DMA_USE_PCI_RO = 0x08 |
||
457 | } flags; |
||
458 | |||
459 | }; |
||
460 | |||
461 | /** |
||
462 | * AGP memory entry. Stored as a doubly linked list. |
||
463 | */ |
||
464 | struct drm_agp_mem { |
||
465 | unsigned long handle; /**< handle */ |
||
466 | DRM_AGP_MEM *memory; |
||
467 | unsigned long bound; /**< address */ |
||
468 | int pages; |
||
469 | struct list_head head; |
||
470 | }; |
||
471 | |||
472 | /** |
||
473 | * AGP data. |
||
474 | * |
||
475 | * \sa drm_agp_init() and drm_device::agp. |
||
476 | */ |
||
477 | struct drm_agp_head { |
||
478 | DRM_AGP_KERN agp_info; /**< AGP device information */ |
||
479 | struct list_head memory; |
||
480 | unsigned long mode; /**< AGP mode */ |
||
481 | struct agp_bridge_data *bridge; |
||
482 | int enabled; /**< whether the AGP bus as been enabled */ |
||
483 | int acquired; /**< whether the AGP device has been acquired */ |
||
484 | unsigned long base; |
||
485 | int agp_mtrr; |
||
486 | int cant_use_aperture; |
||
487 | unsigned long page_mask; |
||
488 | }; |
||
489 | |||
490 | /** |
||
491 | * Scatter-gather memory. |
||
492 | */ |
||
493 | struct drm_sg_mem { |
||
494 | unsigned long handle; |
||
495 | void *virtual; |
||
496 | int pages; |
||
497 | struct page **pagelist; |
||
498 | dma_addr_t *busaddr; |
||
499 | }; |
||
500 | |||
501 | struct drm_sigdata { |
||
502 | int context; |
||
503 | struct drm_hw_lock *lock; |
||
504 | }; |
||
505 | |||
506 | |||
507 | /** |
||
508 | * Kernel side of a mapping |
||
509 | */ |
||
510 | struct drm_local_map { |
||
511 | resource_size_t offset; /**< Requested physical address (0 for SAREA)*/ |
||
512 | unsigned long size; /**< Requested physical size (bytes) */ |
||
513 | enum drm_map_type type; /**< Type of memory to map */ |
||
514 | enum drm_map_flags flags; /**< Flags */ |
||
515 | void *handle; /**< User-space: "Handle" to pass to mmap() */ |
||
516 | /**< Kernel-space: kernel-virtual address */ |
||
517 | int mtrr; /**< MTRR slot used */ |
||
518 | }; |
||
519 | |||
520 | typedef struct drm_local_map drm_local_map_t; |
||
521 | |||
522 | /** |
||
523 | * Mappings list |
||
524 | */ |
||
525 | struct drm_map_list { |
||
526 | struct list_head head; /**< list head */ |
||
527 | struct drm_hash_item hash; |
||
528 | struct drm_local_map *map; /**< mapping */ |
||
529 | uint64_t user_token; |
||
530 | struct drm_master *master; |
||
531 | struct drm_mm_node *file_offset_node; /**< fake offset */ |
||
532 | }; |
||
533 | |||
534 | /** |
||
535 | * Context handle list |
||
536 | */ |
||
537 | struct drm_ctx_list { |
||
538 | struct list_head head; /**< list head */ |
||
539 | drm_context_t handle; /**< context handle */ |
||
540 | struct drm_file *tag; /**< associated fd private data */ |
||
541 | }; |
||
542 | |||
543 | /* location of GART table */ |
||
544 | #define DRM_ATI_GART_MAIN 1 |
||
545 | #define DRM_ATI_GART_FB 2 |
||
546 | |||
547 | #define DRM_ATI_GART_PCI 1 |
||
548 | #define DRM_ATI_GART_PCIE 2 |
||
549 | #define DRM_ATI_GART_IGP 3 |
||
550 | |||
551 | struct drm_ati_pcigart_info { |
||
552 | int gart_table_location; |
||
553 | int gart_reg_if; |
||
554 | void *addr; |
||
555 | dma_addr_t bus_addr; |
||
556 | dma_addr_t table_mask; |
||
557 | struct drm_dma_handle *table_handle; |
||
558 | struct drm_local_map mapping; |
||
559 | int table_size; |
||
560 | }; |
||
561 | |||
562 | /** |
||
563 | * GEM specific mm private for tracking GEM objects |
||
564 | */ |
||
565 | struct drm_gem_mm { |
||
566 | struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */ |
||
567 | struct drm_open_hash offset_hash; /**< User token hash table for maps */ |
||
568 | }; |
||
569 | |||
570 | /** |
||
571 | * This structure defines the drm_mm memory object, which will be used by the |
||
572 | * DRM for its buffer objects. |
||
573 | */ |
||
574 | struct drm_gem_object { |
||
575 | /** Reference count of this object */ |
||
576 | struct kref refcount; |
||
577 | |||
578 | /** Handle count of this object. Each handle also holds a reference */ |
||
579 | struct kref handlecount; |
||
580 | |||
581 | /** Related drm device */ |
||
582 | struct drm_device *dev; |
||
583 | |||
584 | /** File representing the shmem storage */ |
||
585 | struct file *filp; |
||
586 | |||
587 | /* Mapping info for this object */ |
||
588 | struct drm_map_list map_list; |
||
589 | |||
590 | /** |
||
591 | * Size of the object, in bytes. Immutable over the object's |
||
592 | * lifetime. |
||
593 | */ |
||
594 | size_t size; |
||
595 | |||
596 | /** |
||
597 | * Global name for this object, starts at 1. 0 means unnamed. |
||
598 | * Access is covered by the object_name_lock in the related drm_device |
||
599 | */ |
||
600 | int name; |
||
601 | |||
602 | /** |
||
603 | * Memory domains. These monitor which caches contain read/write data |
||
604 | * related to the object. When transitioning from one set of domains |
||
605 | * to another, the driver is called to ensure that caches are suitably |
||
606 | * flushed and invalidated |
||
607 | */ |
||
608 | uint32_t read_domains; |
||
609 | uint32_t write_domain; |
||
610 | |||
611 | /** |
||
612 | * While validating an exec operation, the |
||
613 | * new read/write domain values are computed here. |
||
614 | * They will be transferred to the above values |
||
615 | * at the point that any cache flushing occurs |
||
616 | */ |
||
617 | uint32_t pending_read_domains; |
||
618 | uint32_t pending_write_domain; |
||
619 | |||
620 | void *driver_private; |
||
621 | }; |
||
622 | |||
623 | #include "drm_crtc.h" |
||
624 | |||
625 | /* per-master structure */ |
||
626 | struct drm_master { |
||
627 | |||
628 | struct kref refcount; /* refcount for this master */ |
||
629 | |||
630 | struct list_head head; /**< each minor contains a list of masters */ |
||
631 | struct drm_minor *minor; /**< link back to minor we are a master for */ |
||
632 | |||
633 | char *unique; /**< Unique identifier: e.g., busid */ |
||
634 | int unique_len; /**< Length of unique field */ |
||
635 | int unique_size; /**< amount allocated */ |
||
636 | |||
637 | int blocked; /**< Blocked due to VC switch? */ |
||
638 | |||
639 | /** \name Authentication */ |
||
640 | /*@{ */ |
||
641 | struct drm_open_hash magiclist; |
||
642 | struct list_head magicfree; |
||
643 | /*@} */ |
||
644 | |||
645 | struct drm_lock_data lock; /**< Information on hardware lock */ |
||
646 | |||
647 | void *driver_priv; /**< Private structure for driver to use */ |
||
648 | }; |
||
649 | |||
650 | /** |
||
651 | * DRM driver structure. This structure represent the common code for |
||
652 | * a family of cards. There will one drm_device for each card present |
||
653 | * in this family |
||
654 | */ |
||
655 | struct drm_driver { |
||
656 | int (*load) (struct drm_device *, unsigned long flags); |
||
657 | int (*firstopen) (struct drm_device *); |
||
658 | int (*open) (struct drm_device *, struct drm_file *); |
||
659 | void (*preclose) (struct drm_device *, struct drm_file *file_priv); |
||
660 | void (*postclose) (struct drm_device *, struct drm_file *); |
||
661 | void (*lastclose) (struct drm_device *); |
||
662 | int (*unload) (struct drm_device *); |
||
663 | int (*suspend) (struct drm_device *, pm_message_t state); |
||
664 | int (*resume) (struct drm_device *); |
||
665 | int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); |
||
666 | void (*dma_ready) (struct drm_device *); |
||
667 | int (*dma_quiescent) (struct drm_device *); |
||
668 | int (*context_ctor) (struct drm_device *dev, int context); |
||
669 | int (*context_dtor) (struct drm_device *dev, int context); |
||
670 | int (*kernel_context_switch) (struct drm_device *dev, int old, |
||
671 | int new); |
||
672 | void (*kernel_context_switch_unlock) (struct drm_device *dev); |
||
673 | |||
674 | /** |
||
675 | * get_vblank_counter - get raw hardware vblank counter |
||
676 | * @dev: DRM device |
||
677 | * @crtc: counter to fetch |
||
678 | * |
||
679 | * Driver callback for fetching a raw hardware vblank counter |
||
680 | * for @crtc. If a device doesn't have a hardware counter, the |
||
681 | * driver can simply return the value of drm_vblank_count and |
||
682 | * make the enable_vblank() and disable_vblank() hooks into no-ops, |
||
683 | * leaving interrupts enabled at all times. |
||
684 | * |
||
685 | * Wraparound handling and loss of events due to modesetting is dealt |
||
686 | * with in the DRM core code. |
||
687 | * |
||
688 | * RETURNS |
||
689 | * Raw vblank counter value. |
||
690 | */ |
||
691 | u32 (*get_vblank_counter) (struct drm_device *dev, int crtc); |
||
692 | |||
693 | /** |
||
694 | * enable_vblank - enable vblank interrupt events |
||
695 | * @dev: DRM device |
||
696 | * @crtc: which irq to enable |
||
697 | * |
||
698 | * Enable vblank interrupts for @crtc. If the device doesn't have |
||
699 | * a hardware vblank counter, this routine should be a no-op, since |
||
700 | * interrupts will have to stay on to keep the count accurate. |
||
701 | * |
||
702 | * RETURNS |
||
703 | * Zero on success, appropriate errno if the given @crtc's vblank |
||
704 | * interrupt cannot be enabled. |
||
705 | */ |
||
706 | int (*enable_vblank) (struct drm_device *dev, int crtc); |
||
707 | |||
708 | /** |
||
709 | * disable_vblank - disable vblank interrupt events |
||
710 | * @dev: DRM device |
||
711 | * @crtc: which irq to enable |
||
712 | * |
||
713 | * Disable vblank interrupts for @crtc. If the device doesn't have |
||
714 | * a hardware vblank counter, this routine should be a no-op, since |
||
715 | * interrupts will have to stay on to keep the count accurate. |
||
716 | */ |
||
717 | void (*disable_vblank) (struct drm_device *dev, int crtc); |
||
718 | |||
719 | /** |
||
720 | * Called by \c drm_device_is_agp. Typically used to determine if a |
||
721 | * card is really attached to AGP or not. |
||
722 | * |
||
723 | * \param dev DRM device handle |
||
724 | * |
||
725 | * \returns |
||
726 | * One of three values is returned depending on whether or not the |
||
727 | * card is absolutely \b not AGP (return of 0), absolutely \b is AGP |
||
728 | * (return of 1), or may or may not be AGP (return of 2). |
||
729 | */ |
||
730 | int (*device_is_agp) (struct drm_device *dev); |
||
731 | |||
732 | /* these have to be filled in */ |
||
733 | |||
734 | irqreturn_t(*irq_handler) (DRM_IRQ_ARGS); |
||
735 | void (*irq_preinstall) (struct drm_device *dev); |
||
736 | int (*irq_postinstall) (struct drm_device *dev); |
||
737 | void (*irq_uninstall) (struct drm_device *dev); |
||
738 | void (*reclaim_buffers) (struct drm_device *dev, |
||
739 | struct drm_file * file_priv); |
||
740 | void (*reclaim_buffers_locked) (struct drm_device *dev, |
||
741 | struct drm_file *file_priv); |
||
742 | void (*reclaim_buffers_idlelocked) (struct drm_device *dev, |
||
743 | struct drm_file *file_priv); |
||
744 | resource_size_t (*get_map_ofs) (struct drm_local_map * map); |
||
745 | resource_size_t (*get_reg_ofs) (struct drm_device *dev); |
||
746 | void (*set_version) (struct drm_device *dev, |
||
747 | struct drm_set_version *sv); |
||
748 | |||
749 | /* Master routines */ |
||
750 | int (*master_create)(struct drm_device *dev, struct drm_master *master); |
||
751 | void (*master_destroy)(struct drm_device *dev, struct drm_master *master); |
||
752 | |||
753 | int (*proc_init)(struct drm_minor *minor); |
||
754 | void (*proc_cleanup)(struct drm_minor *minor); |
||
755 | int (*debugfs_init)(struct drm_minor *minor); |
||
756 | void (*debugfs_cleanup)(struct drm_minor *minor); |
||
757 | |||
758 | /** |
||
759 | * Driver-specific constructor for drm_gem_objects, to set up |
||
760 | * obj->driver_private. |
||
761 | * |
||
762 | * Returns 0 on success. |
||
763 | */ |
||
764 | int (*gem_init_object) (struct drm_gem_object *obj); |
||
765 | void (*gem_free_object) (struct drm_gem_object *obj); |
||
766 | |||
767 | /* Driver private ops for this object */ |
||
768 | struct vm_operations_struct *gem_vm_ops; |
||
769 | |||
770 | int major; |
||
771 | int minor; |
||
772 | int patchlevel; |
||
773 | char *name; |
||
774 | char *desc; |
||
775 | char *date; |
||
776 | |||
777 | u32 driver_features; |
||
778 | int dev_priv_size; |
||
779 | struct drm_ioctl_desc *ioctls; |
||
780 | int num_ioctls; |
||
781 | struct file_operations fops; |
||
782 | struct pci_driver pci_driver; |
||
783 | /* List of devices hanging off this driver */ |
||
784 | struct list_head device_list; |
||
785 | }; |
||
786 | |||
787 | #define DRM_MINOR_UNASSIGNED 0 |
||
788 | #define DRM_MINOR_LEGACY 1 |
||
789 | #define DRM_MINOR_CONTROL 2 |
||
790 | #define DRM_MINOR_RENDER 3 |
||
791 | |||
792 | |||
793 | /** |
||
794 | * debugfs node list. This structure represents a debugfs file to |
||
795 | * be created by the drm core |
||
796 | */ |
||
797 | struct drm_debugfs_list { |
||
798 | const char *name; /** file name */ |
||
799 | int (*show)(struct seq_file*, void*); /** show callback */ |
||
800 | u32 driver_features; /**< Required driver features for this entry */ |
||
801 | }; |
||
802 | |||
803 | /** |
||
804 | * debugfs node structure. This structure represents a debugfs file. |
||
805 | */ |
||
806 | struct drm_debugfs_node { |
||
807 | struct list_head list; |
||
808 | struct drm_minor *minor; |
||
809 | struct drm_debugfs_list *debugfs_ent; |
||
810 | struct dentry *dent; |
||
811 | }; |
||
812 | |||
813 | /** |
||
814 | * Info file list entry. This structure represents a debugfs or proc file to |
||
815 | * be created by the drm core |
||
816 | */ |
||
817 | struct drm_info_list { |
||
818 | const char *name; /** file name */ |
||
819 | int (*show)(struct seq_file*, void*); /** show callback */ |
||
820 | u32 driver_features; /**< Required driver features for this entry */ |
||
821 | void *data; |
||
822 | }; |
||
823 | |||
824 | /** |
||
825 | * debugfs node structure. This structure represents a debugfs file. |
||
826 | */ |
||
827 | struct drm_info_node { |
||
828 | struct list_head list; |
||
829 | struct drm_minor *minor; |
||
830 | struct drm_info_list *info_ent; |
||
831 | struct dentry *dent; |
||
832 | }; |
||
833 | |||
834 | /** |
||
835 | * DRM minor structure. This structure represents a drm minor number. |
||
836 | */ |
||
837 | struct drm_minor { |
||
838 | int index; /**< Minor device number */ |
||
839 | int type; /**< Control or render */ |
||
840 | dev_t device; /**< Device number for mknod */ |
||
841 | struct device kdev; /**< Linux device */ |
||
842 | struct drm_device *dev; |
||
843 | |||
844 | struct proc_dir_entry *proc_root; /**< proc directory entry */ |
||
845 | struct drm_info_node proc_nodes; |
||
846 | struct dentry *debugfs_root; |
||
847 | struct drm_info_node debugfs_nodes; |
||
848 | |||
849 | struct drm_master *master; /* currently active master for this node */ |
||
850 | struct list_head master_list; |
||
851 | struct drm_mode_group mode_group; |
||
852 | }; |
||
853 | |||
854 | |||
855 | |||
856 | |||
857 | #endif |
||
858 | |||
859 | |||
860 | /** |
||
861 | * DRM device structure. This structure represent a complete card that |
||
862 | * may contain multiple heads. |
||
863 | */ |
||
864 | struct drm_device { |
||
865 | struct list_head driver_item; /**< list of devices per driver */ |
||
866 | char *devname; /**< For /proc/interrupts */ |
||
867 | int if_version; /**< Highest interface version set */ |
||
868 | |||
869 | /** \name Locks */ |
||
870 | /*@{ */ |
||
871 | // spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ |
||
872 | // struct mutex struct_mutex; /**< For others */ |
||
873 | /*@} */ |
||
874 | |||
875 | /** \name Usage Counters */ |
||
876 | /*@{ */ |
||
877 | int open_count; /**< Outstanding files open */ |
||
878 | // atomic_t ioctl_count; /**< Outstanding IOCTLs pending */ |
||
879 | // atomic_t vma_count; /**< Outstanding vma areas open */ |
||
880 | int buf_use; /**< Buffers in use -- cannot alloc */ |
||
881 | // atomic_t buf_alloc; /**< Buffer allocation in progress */ |
||
882 | /*@} */ |
||
883 | |||
884 | /** \name Performance counters */ |
||
885 | /*@{ */ |
||
886 | unsigned long counters; |
||
887 | // enum drm_stat_type types[15]; |
||
888 | // atomic_t counts[15]; |
||
889 | /*@} */ |
||
890 | |||
891 | struct list_head filelist; |
||
892 | |||
893 | /** \name Memory management */ |
||
894 | /*@{ */ |
||
895 | struct list_head maplist; /**< Linked list of regions */ |
||
896 | int map_count; /**< Number of mappable regions */ |
||
897 | // struct drm_open_hash map_hash; /**< User token hash table for maps */ |
||
898 | |||
899 | /** \name Context handle management */ |
||
900 | /*@{ */ |
||
901 | struct list_head ctxlist; /**< Linked list of context handles */ |
||
902 | int ctx_count; /**< Number of context handles */ |
||
903 | // struct mutex ctxlist_mutex; /**< For ctxlist */ |
||
904 | |||
905 | // struct idr ctx_idr; |
||
906 | |||
907 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
||
908 | |||
909 | /*@} */ |
||
910 | |||
911 | /** \name DMA queues (contexts) */ |
||
912 | /*@{ */ |
||
913 | int queue_count; /**< Number of active DMA queues */ |
||
914 | int queue_reserved; /**< Number of reserved DMA queues */ |
||
915 | int queue_slots; /**< Actual length of queuelist */ |
||
916 | // struct drm_queue **queuelist; /**< Vector of pointers to DMA queues */ |
||
917 | // struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
||
918 | /*@} */ |
||
919 | |||
920 | /** \name Context support */ |
||
921 | /*@{ */ |
||
922 | int irq_enabled; /**< True if irq handler is enabled */ |
||
923 | __volatile__ long context_flag; /**< Context swapping flag */ |
||
924 | __volatile__ long interrupt_flag; /**< Interruption handler flag */ |
||
925 | __volatile__ long dma_flag; /**< DMA dispatch flag */ |
||
926 | // struct timer_list timer; /**< Timer for delaying ctx switch */ |
||
927 | // wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */ |
||
928 | int last_checked; /**< Last context checked for DMA */ |
||
929 | int last_context; /**< Last current context */ |
||
930 | unsigned long last_switch; /**< jiffies at last context switch */ |
||
931 | /*@} */ |
||
932 | |||
933 | // struct work_struct work; |
||
934 | /** \name VBLANK IRQ support */ |
||
935 | /*@{ */ |
||
936 | |||
937 | /* |
||
938 | * At load time, disabling the vblank interrupt won't be allowed since |
||
939 | * old clients may not call the modeset ioctl and therefore misbehave. |
||
940 | * Once the modeset ioctl *has* been called though, we can safely |
||
941 | * disable them when unused. |
||
942 | */ |
||
943 | int vblank_disable_allowed; |
||
944 | |||
945 | // wait_queue_head_t *vbl_queue; /**< VBLANK wait queue */ |
||
946 | // atomic_t *_vblank_count; /**< number of VBLANK interrupts (driver must alloc the right number of counters) */ |
||
947 | // spinlock_t vbl_lock; |
||
948 | // atomic_t *vblank_refcount; /* number of users of vblank interruptsper crtc */ |
||
949 | u32 *last_vblank; /* protected by dev->vbl_lock, used */ |
||
950 | /* for wraparound handling */ |
||
951 | int *vblank_enabled; /* so we don't call enable more than |
||
952 | once per disable */ |
||
953 | int *vblank_inmodeset; /* Display driver is setting mode */ |
||
954 | u32 *last_vblank_wait; /* Last vblank seqno waited per CRTC */ |
||
955 | // struct timer_list vblank_disable_timer; |
||
956 | |||
957 | u32 max_vblank_count; /**< size of vblank counter register */ |
||
958 | |||
959 | /*@} */ |
||
960 | // cycles_t ctx_start; |
||
961 | // cycles_t lck_start; |
||
962 | |||
963 | // struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */ |
||
964 | // wait_queue_head_t buf_readers; /**< Processes waiting to read */ |
||
965 | // wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */ |
||
966 | |||
967 | // struct drm_agp_head *agp; /**< AGP data */ |
||
968 | |||
969 | struct pci_dev *pdev; /**< PCI device structure */ |
||
970 | int pci_vendor; /**< PCI vendor id */ |
||
971 | int pci_device; /**< PCI device id */ |
||
972 | // struct drm_sg_mem *sg; /**< Scatter gather memory */ |
||
973 | int num_crtcs; /**< Number of CRTCs on this device */ |
||
974 | void *dev_private; /**< device private data */ |
||
975 | void *mm_private; |
||
976 | // struct address_space *dev_mapping; |
||
977 | // struct drm_sigdata sigdata; /**< For block_all_signals */ |
||
978 | // sigset_t sigmask; |
||
979 | |||
980 | // struct drm_driver *driver; |
||
981 | // struct drm_local_map *agp_buffer_map; |
||
982 | // unsigned int agp_buffer_token; |
||
983 | // struct drm_minor *control; /**< Control node for card */ |
||
984 | // struct drm_minor *primary; /**< render type primary screen head */ |
||
985 | |||
986 | /** \name Drawable information */ |
||
987 | /*@{ */ |
||
988 | // spinlock_t drw_lock; |
||
989 | // struct idr drw_idr; |
||
990 | /*@} */ |
||
991 | |||
992 | struct drm_mode_config mode_config; /**< Current mode config */ |
||
993 | |||
994 | /** \name GEM information */ |
||
995 | /*@{ */ |
||
996 | // spinlock_t object_name_lock; |
||
997 | // struct idr object_name_idr; |
||
998 | // atomic_t object_count; |
||
999 | // atomic_t object_memory; |
||
1000 | // atomic_t pin_count; |
||
1001 | // atomic_t pin_memory; |
||
1002 | // atomic_t gtt_count; |
||
1003 | // atomic_t gtt_memory; |
||
1004 | // uint32_t gtt_total; |
||
1005 | uint32_t invalidate_domains; /* domains pending invalidation */ |
||
1006 | uint32_t flush_domains; /* domains pending flush */ |
||
1007 | /*@} */ |
||
1008 | |||
1009 | }; |
||
1010 | |||
1011 | |||
1012 | #if 0 |
||
1013 | static inline int drm_dev_to_irq(struct drm_device *dev) |
||
1014 | { |
||
1015 | return dev->pdev->irq; |
||
1016 | } |
||
1017 | |||
1018 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
||
1019 | int feature) |
||
1020 | { |
||
1021 | return ((dev->driver->driver_features & feature) ? 1 : 0); |
||
1022 | } |
||
1023 | |||
1024 | #ifdef __alpha__ |
||
1025 | #define drm_get_pci_domain(dev) dev->hose->index |
||
1026 | #else |
||
1027 | #define drm_get_pci_domain(dev) 0 |
||
1028 | #endif |
||
1029 | |||
1030 | #if __OS_HAS_AGP |
||
1031 | static inline int drm_core_has_AGP(struct drm_device *dev) |
||
1032 | { |
||
1033 | return drm_core_check_feature(dev, DRIVER_USE_AGP); |
||
1034 | } |
||
1035 | #else |
||
1036 | #define drm_core_has_AGP(dev) (0) |
||
1037 | #endif |
||
1038 | |||
1039 | #if __OS_HAS_MTRR |
||
1040 | static inline int drm_core_has_MTRR(struct drm_device *dev) |
||
1041 | { |
||
1042 | return drm_core_check_feature(dev, DRIVER_USE_MTRR); |
||
1043 | } |
||
1044 | |||
1045 | #define DRM_MTRR_WC MTRR_TYPE_WRCOMB |
||
1046 | |||
1047 | static inline int drm_mtrr_add(unsigned long offset, unsigned long size, |
||
1048 | unsigned int flags) |
||
1049 | { |
||
1050 | return mtrr_add(offset, size, flags, 1); |
||
1051 | } |
||
1052 | |||
1053 | static inline int drm_mtrr_del(int handle, unsigned long offset, |
||
1054 | unsigned long size, unsigned int flags) |
||
1055 | { |
||
1056 | return mtrr_del(handle, offset, size); |
||
1057 | } |
||
1058 | |||
1059 | #else |
||
1060 | #define drm_core_has_MTRR(dev) (0) |
||
1061 | |||
1062 | #define DRM_MTRR_WC 0 |
||
1063 | |||
1064 | static inline int drm_mtrr_add(unsigned long offset, unsigned long size, |
||
1065 | unsigned int flags) |
||
1066 | { |
||
1067 | return 0; |
||
1068 | } |
||
1069 | |||
1070 | static inline int drm_mtrr_del(int handle, unsigned long offset, |
||
1071 | unsigned long size, unsigned int flags) |
||
1072 | { |
||
1073 | return 0; |
||
1074 | } |
||
1075 | #endif |
||
1076 | |||
1077 | /******************************************************************/ |
||
1078 | /** \name Internal function definitions */ |
||
1079 | /*@{*/ |
||
1080 | |||
1081 | /* Driver support (drm_drv.h) */ |
||
1082 | extern int drm_init(struct drm_driver *driver); |
||
1083 | extern void drm_exit(struct drm_driver *driver); |
||
1084 | extern int drm_ioctl(struct inode *inode, struct file *filp, |
||
1085 | unsigned int cmd, unsigned long arg); |
||
1086 | extern long drm_compat_ioctl(struct file *filp, |
||
1087 | unsigned int cmd, unsigned long arg); |
||
1088 | extern int drm_lastclose(struct drm_device *dev); |
||
1089 | |||
1090 | /* Device support (drm_fops.h) */ |
||
1091 | extern int drm_open(struct inode *inode, struct file *filp); |
||
1092 | extern int drm_stub_open(struct inode *inode, struct file *filp); |
||
1093 | extern int drm_fasync(int fd, struct file *filp, int on); |
||
1094 | extern int drm_release(struct inode *inode, struct file *filp); |
||
1095 | |||
1096 | /* Mapping support (drm_vm.h) */ |
||
1097 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); |
||
1098 | extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); |
||
1099 | extern void drm_vm_open_locked(struct vm_area_struct *vma); |
||
1100 | extern resource_size_t drm_core_get_map_ofs(struct drm_local_map * map); |
||
1101 | extern resource_size_t drm_core_get_reg_ofs(struct drm_device *dev); |
||
1102 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
||
1103 | |||
1104 | /* Memory management support (drm_memory.h) */ |
||
1105 | #include "drm_memory.h" |
||
1106 | extern void drm_mem_init(void); |
||
1107 | extern int drm_mem_info(char *buf, char **start, off_t offset, |
||
1108 | int request, int *eof, void *data); |
||
1109 | extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area); |
||
1110 | |||
1111 | extern DRM_AGP_MEM *drm_alloc_agp(struct drm_device *dev, int pages, u32 type); |
||
1112 | extern int drm_free_agp(DRM_AGP_MEM * handle, int pages); |
||
1113 | extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); |
||
1114 | extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, |
||
1115 | struct page **pages, |
||
1116 | unsigned long num_pages, |
||
1117 | uint32_t gtt_offset, |
||
1118 | uint32_t type); |
||
1119 | extern int drm_unbind_agp(DRM_AGP_MEM * handle); |
||
1120 | |||
1121 | /* Misc. IOCTL support (drm_ioctl.h) */ |
||
1122 | extern int drm_irq_by_busid(struct drm_device *dev, void *data, |
||
1123 | struct drm_file *file_priv); |
||
1124 | extern int drm_getunique(struct drm_device *dev, void *data, |
||
1125 | struct drm_file *file_priv); |
||
1126 | extern int drm_setunique(struct drm_device *dev, void *data, |
||
1127 | struct drm_file *file_priv); |
||
1128 | extern int drm_getmap(struct drm_device *dev, void *data, |
||
1129 | struct drm_file *file_priv); |
||
1130 | extern int drm_getclient(struct drm_device *dev, void *data, |
||
1131 | struct drm_file *file_priv); |
||
1132 | extern int drm_getstats(struct drm_device *dev, void *data, |
||
1133 | struct drm_file *file_priv); |
||
1134 | extern int drm_setversion(struct drm_device *dev, void *data, |
||
1135 | struct drm_file *file_priv); |
||
1136 | extern int drm_noop(struct drm_device *dev, void *data, |
||
1137 | struct drm_file *file_priv); |
||
1138 | |||
1139 | /* Context IOCTL support (drm_context.h) */ |
||
1140 | extern int drm_resctx(struct drm_device *dev, void *data, |
||
1141 | struct drm_file *file_priv); |
||
1142 | extern int drm_addctx(struct drm_device *dev, void *data, |
||
1143 | struct drm_file *file_priv); |
||
1144 | extern int drm_modctx(struct drm_device *dev, void *data, |
||
1145 | struct drm_file *file_priv); |
||
1146 | extern int drm_getctx(struct drm_device *dev, void *data, |
||
1147 | struct drm_file *file_priv); |
||
1148 | extern int drm_switchctx(struct drm_device *dev, void *data, |
||
1149 | struct drm_file *file_priv); |
||
1150 | extern int drm_newctx(struct drm_device *dev, void *data, |
||
1151 | struct drm_file *file_priv); |
||
1152 | extern int drm_rmctx(struct drm_device *dev, void *data, |
||
1153 | struct drm_file *file_priv); |
||
1154 | |||
1155 | extern int drm_ctxbitmap_init(struct drm_device *dev); |
||
1156 | extern void drm_ctxbitmap_cleanup(struct drm_device *dev); |
||
1157 | extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); |
||
1158 | |||
1159 | extern int drm_setsareactx(struct drm_device *dev, void *data, |
||
1160 | struct drm_file *file_priv); |
||
1161 | extern int drm_getsareactx(struct drm_device *dev, void *data, |
||
1162 | struct drm_file *file_priv); |
||
1163 | |||
1164 | /* Drawable IOCTL support (drm_drawable.h) */ |
||
1165 | extern int drm_adddraw(struct drm_device *dev, void *data, |
||
1166 | struct drm_file *file_priv); |
||
1167 | extern int drm_rmdraw(struct drm_device *dev, void *data, |
||
1168 | struct drm_file *file_priv); |
||
1169 | extern int drm_update_drawable_info(struct drm_device *dev, void *data, |
||
1170 | struct drm_file *file_priv); |
||
1171 | extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev, |
||
1172 | drm_drawable_t id); |
||
1173 | extern void drm_drawable_free_all(struct drm_device *dev); |
||
1174 | |||
1175 | /* Authentication IOCTL support (drm_auth.h) */ |
||
1176 | extern int drm_getmagic(struct drm_device *dev, void *data, |
||
1177 | struct drm_file *file_priv); |
||
1178 | extern int drm_authmagic(struct drm_device *dev, void *data, |
||
1179 | struct drm_file *file_priv); |
||
1180 | |||
1181 | /* Cache management (drm_cache.c) */ |
||
1182 | void drm_clflush_pages(struct page *pages[], unsigned long num_pages); |
||
1183 | |||
1184 | /* Locking IOCTL support (drm_lock.h) */ |
||
1185 | extern int drm_lock(struct drm_device *dev, void *data, |
||
1186 | struct drm_file *file_priv); |
||
1187 | extern int drm_unlock(struct drm_device *dev, void *data, |
||
1188 | struct drm_file *file_priv); |
||
1189 | extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context); |
||
1190 | extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); |
||
1191 | extern void drm_idlelock_take(struct drm_lock_data *lock_data); |
||
1192 | extern void drm_idlelock_release(struct drm_lock_data *lock_data); |
||
1193 | |||
1194 | /* |
||
1195 | * These are exported to drivers so that they can implement fencing using |
||
1196 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
||
1197 | */ |
||
1198 | |||
1199 | extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv); |
||
1200 | |||
1201 | /* Buffer management support (drm_bufs.h) */ |
||
1202 | extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); |
||
1203 | extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request); |
||
1204 | extern int drm_addmap(struct drm_device *dev, resource_size_t offset, |
||
1205 | unsigned int size, enum drm_map_type type, |
||
1206 | enum drm_map_flags flags, struct drm_local_map **map_ptr); |
||
1207 | extern int drm_addmap_ioctl(struct drm_device *dev, void *data, |
||
1208 | struct drm_file *file_priv); |
||
1209 | extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map); |
||
1210 | extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map); |
||
1211 | extern int drm_rmmap_ioctl(struct drm_device *dev, void *data, |
||
1212 | struct drm_file *file_priv); |
||
1213 | extern int drm_addbufs(struct drm_device *dev, void *data, |
||
1214 | struct drm_file *file_priv); |
||
1215 | extern int drm_infobufs(struct drm_device *dev, void *data, |
||
1216 | struct drm_file *file_priv); |
||
1217 | extern int drm_markbufs(struct drm_device *dev, void *data, |
||
1218 | struct drm_file *file_priv); |
||
1219 | extern int drm_freebufs(struct drm_device *dev, void *data, |
||
1220 | struct drm_file *file_priv); |
||
1221 | extern int drm_mapbufs(struct drm_device *dev, void *data, |
||
1222 | struct drm_file *file_priv); |
||
1223 | extern int drm_order(unsigned long size); |
||
1224 | extern resource_size_t drm_get_resource_start(struct drm_device *dev, |
||
1225 | unsigned int resource); |
||
1226 | extern resource_size_t drm_get_resource_len(struct drm_device *dev, |
||
1227 | unsigned int resource); |
||
1228 | |||
1229 | /* DMA support (drm_dma.h) */ |
||
1230 | extern int drm_dma_setup(struct drm_device *dev); |
||
1231 | extern void drm_dma_takedown(struct drm_device *dev); |
||
1232 | extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); |
||
1233 | extern void drm_core_reclaim_buffers(struct drm_device *dev, |
||
1234 | struct drm_file *filp); |
||
1235 | |||
1236 | /* IRQ support (drm_irq.h) */ |
||
1237 | extern int drm_control(struct drm_device *dev, void *data, |
||
1238 | struct drm_file *file_priv); |
||
1239 | extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS); |
||
1240 | extern int drm_irq_install(struct drm_device *dev); |
||
1241 | extern int drm_irq_uninstall(struct drm_device *dev); |
||
1242 | extern void drm_driver_irq_preinstall(struct drm_device *dev); |
||
1243 | extern void drm_driver_irq_postinstall(struct drm_device *dev); |
||
1244 | extern void drm_driver_irq_uninstall(struct drm_device *dev); |
||
1245 | |||
1246 | extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); |
||
1247 | extern int drm_wait_vblank(struct drm_device *dev, void *data, |
||
1248 | struct drm_file *filp); |
||
1249 | extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); |
||
1250 | extern u32 drm_vblank_count(struct drm_device *dev, int crtc); |
||
1251 | extern void drm_handle_vblank(struct drm_device *dev, int crtc); |
||
1252 | extern int drm_vblank_get(struct drm_device *dev, int crtc); |
||
1253 | extern void drm_vblank_put(struct drm_device *dev, int crtc); |
||
1254 | extern void drm_vblank_cleanup(struct drm_device *dev); |
||
1255 | /* Modesetting support */ |
||
1256 | extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); |
||
1257 | extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); |
||
1258 | extern int drm_modeset_ctl(struct drm_device *dev, void *data, |
||
1259 | struct drm_file *file_priv); |
||
1260 | |||
1261 | /* AGP/GART support (drm_agpsupport.h) */ |
||
1262 | extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); |
||
1263 | extern int drm_agp_acquire(struct drm_device *dev); |
||
1264 | extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, |
||
1265 | struct drm_file *file_priv); |
||
1266 | extern int drm_agp_release(struct drm_device *dev); |
||
1267 | extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, |
||
1268 | struct drm_file *file_priv); |
||
1269 | extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); |
||
1270 | extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, |
||
1271 | struct drm_file *file_priv); |
||
1272 | extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); |
||
1273 | extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, |
||
1274 | struct drm_file *file_priv); |
||
1275 | extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); |
||
1276 | extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, |
||
1277 | struct drm_file *file_priv); |
||
1278 | extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); |
||
1279 | extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, |
||
1280 | struct drm_file *file_priv); |
||
1281 | extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); |
||
1282 | extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, |
||
1283 | struct drm_file *file_priv); |
||
1284 | extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); |
||
1285 | extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, |
||
1286 | struct drm_file *file_priv); |
||
1287 | extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size_t pages, u32 type); |
||
1288 | extern int drm_agp_free_memory(DRM_AGP_MEM * handle); |
||
1289 | extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start); |
||
1290 | extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle); |
||
1291 | extern void drm_agp_chipset_flush(struct drm_device *dev); |
||
1292 | |||
1293 | /* Stub support (drm_stub.h) */ |
||
1294 | extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, |
||
1295 | struct drm_file *file_priv); |
||
1296 | extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, |
||
1297 | struct drm_file *file_priv); |
||
1298 | struct drm_master *drm_master_create(struct drm_minor *minor); |
||
1299 | extern struct drm_master *drm_master_get(struct drm_master *master); |
||
1300 | extern void drm_master_put(struct drm_master **master); |
||
1301 | extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, |
||
1302 | struct drm_driver *driver); |
||
1303 | extern void drm_put_dev(struct drm_device *dev); |
||
1304 | extern int drm_put_minor(struct drm_minor **minor); |
||
1305 | extern unsigned int drm_debug; |
||
1306 | |||
1307 | extern struct class *drm_class; |
||
1308 | extern struct proc_dir_entry *drm_proc_root; |
||
1309 | extern struct dentry *drm_debugfs_root; |
||
1310 | |||
1311 | extern struct idr drm_minors_idr; |
||
1312 | |||
1313 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); |
||
1314 | |||
1315 | /* Proc support (drm_proc.h) */ |
||
1316 | extern int drm_proc_init(struct drm_minor *minor, int minor_id, |
||
1317 | struct proc_dir_entry *root); |
||
1318 | extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root); |
||
1319 | |||
1320 | /* Debugfs support */ |
||
1321 | #if defined(CONFIG_DEBUG_FS) |
||
1322 | extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
||
1323 | struct dentry *root); |
||
1324 | extern int drm_debugfs_create_files(struct drm_info_list *files, int count, |
||
1325 | struct dentry *root, struct drm_minor *minor); |
||
1326 | extern int drm_debugfs_remove_files(struct drm_info_list *files, int count, |
||
1327 | struct drm_minor *minor); |
||
1328 | extern int drm_debugfs_cleanup(struct drm_minor *minor); |
||
1329 | #endif |
||
1330 | |||
1331 | /* Info file support */ |
||
1332 | extern int drm_name_info(struct seq_file *m, void *data); |
||
1333 | extern int drm_vm_info(struct seq_file *m, void *data); |
||
1334 | extern int drm_queues_info(struct seq_file *m, void *data); |
||
1335 | extern int drm_bufs_info(struct seq_file *m, void *data); |
||
1336 | extern int drm_vblank_info(struct seq_file *m, void *data); |
||
1337 | extern int drm_clients_info(struct seq_file *m, void* data); |
||
1338 | extern int drm_gem_name_info(struct seq_file *m, void *data); |
||
1339 | extern int drm_gem_object_info(struct seq_file *m, void* data); |
||
1340 | |||
1341 | #if DRM_DEBUG_CODE |
||
1342 | extern int drm_vma_info(struct seq_file *m, void *data); |
||
1343 | #endif |
||
1344 | |||
1345 | /* Scatter Gather Support (drm_scatter.h) */ |
||
1346 | extern void drm_sg_cleanup(struct drm_sg_mem * entry); |
||
1347 | extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, |
||
1348 | struct drm_file *file_priv); |
||
1349 | extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); |
||
1350 | extern int drm_sg_free(struct drm_device *dev, void *data, |
||
1351 | struct drm_file *file_priv); |
||
1352 | |||
1353 | /* ATI PCIGART support (ati_pcigart.h) */ |
||
1354 | extern int drm_ati_pcigart_init(struct drm_device *dev, |
||
1355 | struct drm_ati_pcigart_info * gart_info); |
||
1356 | extern int drm_ati_pcigart_cleanup(struct drm_device *dev, |
||
1357 | struct drm_ati_pcigart_info * gart_info); |
||
1358 | |||
1359 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, |
||
1360 | size_t align, dma_addr_t maxaddr); |
||
1361 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
||
1362 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
||
1363 | |||
1364 | /* sysfs support (drm_sysfs.c) */ |
||
1365 | struct drm_sysfs_class; |
||
1366 | extern struct class *drm_sysfs_create(struct module *owner, char *name); |
||
1367 | extern void drm_sysfs_destroy(void); |
||
1368 | extern int drm_sysfs_device_add(struct drm_minor *minor); |
||
1369 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
||
1370 | extern void drm_sysfs_device_remove(struct drm_minor *minor); |
||
1371 | extern char *drm_get_connector_status_name(enum drm_connector_status status); |
||
1372 | extern int drm_sysfs_connector_add(struct drm_connector *connector); |
||
1373 | extern void drm_sysfs_connector_remove(struct drm_connector *connector); |
||
1374 | |||
1375 | /* Graphics Execution Manager library functions (drm_gem.c) */ |
||
1376 | int drm_gem_init(struct drm_device *dev); |
||
1377 | void drm_gem_destroy(struct drm_device *dev); |
||
1378 | void drm_gem_object_free(struct kref *kref); |
||
1379 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, |
||
1380 | size_t size); |
||
1381 | void drm_gem_object_handle_free(struct kref *kref); |
||
1382 | void drm_gem_vm_open(struct vm_area_struct *vma); |
||
1383 | void drm_gem_vm_close(struct vm_area_struct *vma); |
||
1384 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); |
||
1385 | |||
1386 | static inline void |
||
1387 | drm_gem_object_reference(struct drm_gem_object *obj) |
||
1388 | { |
||
1389 | kref_get(&obj->refcount); |
||
1390 | } |
||
1391 | |||
1392 | static inline void |
||
1393 | drm_gem_object_unreference(struct drm_gem_object *obj) |
||
1394 | { |
||
1395 | if (obj == NULL) |
||
1396 | return; |
||
1397 | |||
1398 | kref_put(&obj->refcount, drm_gem_object_free); |
||
1399 | } |
||
1400 | |||
1401 | int drm_gem_handle_create(struct drm_file *file_priv, |
||
1402 | struct drm_gem_object *obj, |
||
1403 | int *handlep); |
||
1404 | |||
1405 | static inline void |
||
1406 | drm_gem_object_handle_reference(struct drm_gem_object *obj) |
||
1407 | { |
||
1408 | drm_gem_object_reference(obj); |
||
1409 | kref_get(&obj->handlecount); |
||
1410 | } |
||
1411 | |||
1412 | static inline void |
||
1413 | drm_gem_object_handle_unreference(struct drm_gem_object *obj) |
||
1414 | { |
||
1415 | if (obj == NULL) |
||
1416 | return; |
||
1417 | |||
1418 | /* |
||
1419 | * Must bump handle count first as this may be the last |
||
1420 | * ref, in which case the object would disappear before we |
||
1421 | * checked for a name |
||
1422 | */ |
||
1423 | kref_put(&obj->handlecount, drm_gem_object_handle_free); |
||
1424 | drm_gem_object_unreference(obj); |
||
1425 | } |
||
1426 | |||
1427 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, |
||
1428 | struct drm_file *filp, |
||
1429 | int handle); |
||
1430 | int drm_gem_close_ioctl(struct drm_device *dev, void *data, |
||
1431 | struct drm_file *file_priv); |
||
1432 | int drm_gem_flink_ioctl(struct drm_device *dev, void *data, |
||
1433 | struct drm_file *file_priv); |
||
1434 | int drm_gem_open_ioctl(struct drm_device *dev, void *data, |
||
1435 | struct drm_file *file_priv); |
||
1436 | void drm_gem_open(struct drm_device *dev, struct drm_file *file_private); |
||
1437 | void drm_gem_release(struct drm_device *dev, struct drm_file *file_private); |
||
1438 | |||
1439 | extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev); |
||
1440 | extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev); |
||
1441 | extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev); |
||
1442 | |||
1443 | static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, |
||
1444 | unsigned int token) |
||
1445 | { |
||
1446 | struct drm_map_list *_entry; |
||
1447 | list_for_each_entry(_entry, &dev->maplist, head) |
||
1448 | if (_entry->user_token == token) |
||
1449 | return _entry->map; |
||
1450 | return NULL; |
||
1451 | } |
||
1452 | |||
1453 | static __inline__ int drm_device_is_agp(struct drm_device *dev) |
||
1454 | { |
||
1455 | if (dev->driver->device_is_agp != NULL) { |
||
1456 | int err = (*dev->driver->device_is_agp) (dev); |
||
1457 | |||
1458 | if (err != 2) { |
||
1459 | return err; |
||
1460 | } |
||
1461 | } |
||
1462 | |||
1463 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); |
||
1464 | } |
||
1465 | |||
1466 | static __inline__ int drm_device_is_pcie(struct drm_device *dev) |
||
1467 | { |
||
1468 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); |
||
1469 | } |
||
1470 | |||
1471 | static __inline__ void drm_core_dropmap(struct drm_local_map *map) |
||
1472 | { |
||
1473 | } |
||
1474 | |||
1475 | |||
1476 | static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) |
||
1477 | { |
||
1478 | if (size * nmemb <= PAGE_SIZE) |
||
1479 | return kcalloc(nmemb, size, GFP_KERNEL); |
||
1480 | |||
1481 | if (size != 0 && nmemb > ULONG_MAX / size) |
||
1482 | return NULL; |
||
1483 | |||
1484 | return __vmalloc(size * nmemb, |
||
1485 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); |
||
1486 | } |
||
1487 | |||
1488 | static __inline void drm_free_large(void *ptr) |
||
1489 | { |
||
1490 | if (!is_vmalloc_addr(ptr)) |
||
1491 | return kfree(ptr); |
||
1492 | |||
1493 | vfree(ptr); |
||
1494 | } |
||
1495 | /*@}*/ |
||
1496 | |||
1497 | #endif |
||
1498 | |||
1499 | |||
1500 | #endif=>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>>>>>>> |