1 /** 2 * \file drmP.h 3 * Private header for Direct Rendering Manager 4 * 5 * \author Rickard E. (Rik) Faith <faith@valinux.com> 6 * \author Gareth Hughes <gareth@valinux.com> 7 */ 8 9 /* 10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 12 * Copyright (c) 2009-2010, Code Aurora Forum. 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 #if defined(_KERNEL) || defined(__KERNEL__) 39 40 #include <sys/param.h> 41 #include <sys/queue.h> 42 #include <sys/malloc.h> 43 #include <sys/kernel.h> 44 #include <sys/ktr.h> 45 #include <sys/module.h> 46 #include <sys/systm.h> 47 #include <sys/device.h> 48 #include <sys/sglist.h> 49 #include <sys/stat.h> 50 #include <sys/priv.h> 51 #include <sys/proc.h> 52 #include <sys/lock.h> 53 #include <sys/spinlock.h> 54 #include <sys/spinlock2.h> 55 #include <sys/fcntl.h> 56 #include <sys/uio.h> 57 #include <sys/filio.h> 58 #include <sys/sysctl.h> 59 #include <sys/bus.h> 60 #include <sys/queue.h> 61 #include <sys/signalvar.h> 62 #include <sys/poll.h> 63 #include <sys/sbuf.h> 64 #include <sys/taskqueue.h> 65 #include <sys/tree.h> 66 #include <vm/vm.h> 67 #include <vm/pmap.h> 68 #include <vm/vm_extern.h> 69 #include <vm/vm_kern.h> 70 #include <vm/vm_map.h> 71 #include <vm/vm_object.h> 72 #include <vm/vm_page2.h> 73 #include <vm/vm_pager.h> 74 #include <vm/vm_param.h> 75 #include <machine/param.h> 76 #include <machine/pmap.h> 77 #if defined(__i386__) || defined(__amd64__) 78 #include <machine/specialreg.h> 79 #endif 80 #include <machine/sysarch.h> 81 #include <sys/endian.h> 82 #include <sys/mman.h> 83 #include <sys/rman.h> 84 #include <sys/memrange.h> 85 #include <dev/agp/agpvar.h> 86 #include <sys/agpio.h> 87 #include <sys/mutex.h> 88 89 MALLOC_DECLARE(M_DRM); 90 91 #include <uapi_drm/drm.h> 92 #include <uapi_drm/drm_sarea.h> 93 94 #include <linux/atomic.h> 95 #include <linux/bug.h> 96 #include <linux/err.h> 97 #include <linux/idr.h> 98 #include <linux/pci.h> 99 #include <linux/jiffies.h> 100 #include <linux/kernel.h> 101 #include <linux/kref.h> 102 #include <linux/list.h> 103 #include <linux/mm.h> 104 #include <linux/moduleparam.h> 105 #include <linux/mutex.h> 106 #include <linux/slab.h> 107 #include <linux/scatterlist.h> 108 #include <linux/timer.h> 109 #include <asm/io.h> 110 #include <linux/seq_file.h> 111 #include <linux/types.h> 112 #include <linux/wait.h> 113 #include <linux/workqueue.h> 114 115 #include <asm/uaccess.h> 116 117 #include <drm/drm_vma_manager.h> 118 119 struct drm_file; 120 struct drm_device; 121 122 struct device_node; 123 struct videomode; 124 125 #include <drm/drm_os_linux.h> 126 #include <drm/drm_hashtab.h> 127 #include <drm/drm_mm.h> 128 129 /* 130 * 4 debug categories are defined: 131 * 132 * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... 133 * This is the category used by the DRM_DEBUG() macro. 134 * 135 * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... 136 * This is the category used by the DRM_DEBUG_DRIVER() macro. 137 * 138 * KMS: used in the modesetting code. 139 * This is the category used by the DRM_DEBUG_KMS() macro. 140 * 141 * PRIME: used in the prime code. 142 * This is the category used by the DRM_DEBUG_PRIME() macro. 143 * 144 * Enabling verbose debug messages is done through the drm.debug parameter, 145 * each category being enabled by a bit. 146 * 147 * drm.debug=0x1 will enable CORE messages 148 * drm.debug=0x2 will enable DRIVER messages 149 * drm.debug=0x3 will enable CORE and DRIVER messages 150 * ... 151 * drm.debug=0xf will enable all messages 152 * 153 * An interesting feature is that it's possible to enable verbose logging at 154 * run-time by echoing the debug value in its sysfs node: 155 * # echo 0xf > /sys/module/drm/parameters/debug 156 */ 157 #define DRM_UT_CORE 0x01 158 #define DRM_UT_DRIVER 0x02 159 #define DRM_UT_KMS 0x04 160 #define DRM_UT_PRIME 0x08 161 162 #ifdef DRM_DEBUG 163 # if DRM_DEBUG>1 164 # define DRM_DEBUG_DEFAULT_ON 2 165 # else 166 # define DRM_DEBUG_DEFAULT_ON 1 167 # endif 168 #undef DRM_DEBUG 169 #endif /* DRM_DEBUG */ 170 171 #define DRM_DEBUGBITS_DEBUG 0x1 172 #define DRM_DEBUGBITS_KMS 0x2 173 #define DRM_DEBUGBITS_FAILED_IOCTL 0x4 174 #define DRM_DEBUGBITS_VERBOSE 0x8 175 176 void drm_ut_debug_printk(unsigned int request_level, 177 const char *prefix, 178 const char *function_name, 179 const char *format, ...); 180 181 int drm_err(const char *func, const char *format, ...); 182 183 /***********************************************************************/ 184 /** \name DRM template customization defaults */ 185 /*@{*/ 186 187 /* driver capabilities and requirements mask */ 188 #define DRIVER_USE_AGP 0x1 189 #define DRIVER_REQUIRE_AGP 0x2 190 #define DRIVER_PCI_DMA 0x8 191 #define DRIVER_SG 0x10 192 #define DRIVER_HAVE_DMA 0x20 193 #define DRIVER_HAVE_IRQ 0x40 194 #define DRIVER_IRQ_SHARED 0x80 195 #define DRIVER_DMA_QUEUE 0x200 196 #define DRIVER_GEM 0x1000 197 #define DRIVER_MODESET 0x2000 198 #define DRIVER_PRIME 0x4000 199 #define DRIVER_RENDER 0x8000 200 201 /***********************************************************************/ 202 /** \name Begin the DRM... */ 203 /*@{*/ 204 205 #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then 206 also include looping detection. */ 207 208 #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */ 209 #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */ 210 #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */ 211 212 #define DRM_MAP_HASH_OFFSET 0x10000000 213 214 #define DRM_GEM_MAPPING_MASK (3ULL << 62) 215 #define DRM_GEM_MAPPING_KEY (2ULL << 62) /* Non-canonical address form */ 216 #define DRM_GEM_MAX_IDX 0x3fffff 217 #define DRM_GEM_MAPPING_IDX(o) (((o) >> 40) & DRM_GEM_MAX_IDX) 218 #define DRM_GEM_MAPPING_OFF(i) (((uint64_t)(i)) << 40) 219 #define DRM_GEM_MAPPING_MAPOFF(o) \ 220 ((o) & ~(DRM_GEM_MAPPING_OFF(DRM_GEM_MAX_IDX) | DRM_GEM_MAPPING_KEY)) 221 222 SYSCTL_DECL(_hw_drm); 223 224 #define DRM_ARRAY_SIZE(x) NELEM(x) 225 #define DRM_MAX(a,b) ((a)>(b)?(a):(b)) 226 227 #define DRM_IF_VERSION(maj, min) (maj << 16 | min) 228 229 #define __OS_HAS_AGP 1 230 231 #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) 232 #define DRM_DEV_UID 0 233 #define DRM_DEV_GID 0 234 235 #define DRM_WAKEUP(w) wakeup((void *)w) 236 #define DRM_WAKEUP_INT(w) wakeup(w) 237 #define DRM_INIT_WAITQUEUE(queue) do {(void)(queue);} while (0) 238 239 #define DRM_CURPROC curthread 240 #define DRM_STRUCTPROC struct thread 241 #define DRM_CURRENTPID (curproc != NULL ? curproc->p_pid : -1) 242 #define DRM_LOCK(dev) lockmgr(&(dev)->struct_mutex, LK_EXCLUSIVE) 243 #define DRM_UNLOCK(dev) lockmgr(&(dev)->struct_mutex, LK_RELEASE) 244 #define DRM_LOCK_SLEEP(dev, chan, flags, msg, timeout) \ 245 (lksleep((chan), &(dev)->struct_mutex, (flags), (msg), (timeout))) 246 #if defined(INVARIANTS) 247 #define DRM_LOCK_ASSERT(dev) KKASSERT(lockstatus(&(dev)->struct_mutex, curthread) != 0); 248 #define DRM_UNLOCK_ASSERT(dev) KKASSERT(lockstatus(&(dev)->struct_mutex, curthread) == 0); 249 #else 250 #define DRM_LOCK_ASSERT(d) 251 #define DRM_UNLOCK_ASSERT(d) 252 #endif 253 254 #define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS) 255 256 #define DRM_IRQ_ARGS void *arg 257 typedef void irqreturn_t; 258 #define IRQ_HANDLED /* nothing */ 259 #define IRQ_NONE /* nothing */ 260 261 enum { 262 DRM_IS_NOT_AGP, 263 DRM_IS_AGP, 264 DRM_MIGHT_BE_AGP 265 }; 266 #define DRM_AGP_MEM struct agp_memory_info 267 268 #define drm_get_device_from_kdev(_kdev) (_kdev->si_drv1) 269 270 /* DRM_SUSER returns true if the user is superuser */ 271 #define DRM_SUSER(p) (priv_check(p, PRIV_DRIVER) == 0) 272 #define DRM_AGP_FIND_DEVICE() agp_find_device() 273 #define DRM_MTRR_WC MDF_WRITECOMBINE 274 275 /* DRM_READMEMORYBARRIER() prevents reordering of reads. 276 * DRM_WRITEMEMORYBARRIER() prevents reordering of writes. 277 * DRM_MEMORYBARRIER() prevents reordering of reads and writes. 278 */ 279 #define DRM_READMEMORYBARRIER() cpu_lfence() 280 #define DRM_WRITEMEMORYBARRIER() cpu_sfence() 281 #define DRM_MEMORYBARRIER() cpu_mfence() 282 283 #define DRM_VERIFYAREA_READ( uaddr, size ) \ 284 (!useracc(__DECONST(caddr_t, uaddr), size, VM_PROT_READ)) 285 286 #define DRM_COPY_TO_USER(user, kern, size) \ 287 copyout(kern, user, size) 288 #define DRM_COPY_FROM_USER(kern, user, size) \ 289 copyin(user, kern, size) 290 #define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \ 291 copyin(arg2, arg1, arg3) 292 #define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \ 293 copyout(arg2, arg1, arg3) 294 #define DRM_GET_USER_UNCHECKED(val, uaddr) \ 295 ((val) = fuword32(uaddr), 0) 296 297 #define drm_can_sleep() (DRM_HZ & 1) 298 299 #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \ 300 (_map) = (_dev)->context_sareas[_ctx]; \ 301 } while(0) 302 303 #define LOCK_TEST_WITH_RETURN(dev, file_priv) \ 304 do { \ 305 if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \ 306 dev->lock.file_priv != file_priv) { \ 307 DRM_ERROR("%s called without lock held\n", \ 308 __FUNCTION__); \ 309 return EINVAL; \ 310 } \ 311 } while (0) 312 313 /* Returns -errno to shared code */ 314 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ 315 for ( ret = 0 ; !ret && !(condition) ; ) { \ 316 DRM_UNLOCK(dev); \ 317 lwkt_serialize_enter(&dev->irq_lock); \ 318 if (!(condition)) { \ 319 tsleep_interlock(&(queue), PCATCH); \ 320 lwkt_serialize_exit(&dev->irq_lock); \ 321 ret = -tsleep(&(queue), PCATCH | PINTERLOCKED, \ 322 "drmwtq", (timeout)); \ 323 } else { \ 324 lwkt_serialize_exit(&dev->irq_lock); \ 325 } \ 326 DRM_LOCK(dev); \ 327 } 328 329 int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end, 330 vm_memattr_t memattr); 331 void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end); 332 vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa); 333 334 /***********************************************************************/ 335 /** \name Macros to make printk easier */ 336 /*@{*/ 337 338 /** 339 * Error output. 340 * 341 * \param fmt printf() like format string. 342 * \param arg arguments 343 */ 344 #define DRM_ERROR(fmt, ...) \ 345 kprintf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \ 346 DRM_CURRENTPID, __func__ , ##__VA_ARGS__) 347 348 #define DRM_INFO(fmt, ...) kprintf("info: [" DRM_NAME "] " fmt , ##__VA_ARGS__) 349 350 #define DRM_INFO_ONCE(fmt, ...) \ 351 printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) 352 353 #define DRM_DEBUG(fmt, ...) do { \ 354 if ((drm_debug & DRM_DEBUGBITS_DEBUG) != 0) \ 355 kprintf("[" DRM_NAME ":pid%d:%s] " fmt, DRM_CURRENTPID, \ 356 __func__ , ##__VA_ARGS__); \ 357 } while (0) 358 359 #define DRM_DEBUG_VERBOSE(fmt, ...) do { \ 360 if ((drm_debug & DRM_DEBUGBITS_VERBOSE) != 0) \ 361 kprintf("[" DRM_NAME ":pid%d:%s] " fmt, DRM_CURRENTPID, \ 362 __func__ , ##__VA_ARGS__); \ 363 } while (0) 364 365 #define DRM_DEBUG_KMS(fmt, ...) do { \ 366 if ((drm_debug & DRM_DEBUGBITS_KMS) != 0) \ 367 kprintf("[" DRM_NAME ":KMS:pid%d:%s] " fmt, DRM_CURRENTPID,\ 368 __func__ , ##__VA_ARGS__); \ 369 } while (0) 370 371 #define DRM_DEBUG_DRIVER(fmt, ...) do { \ 372 if ((drm_debug & DRM_DEBUGBITS_KMS) != 0) \ 373 kprintf("[" DRM_NAME ":KMS:pid%d:%s] " fmt, DRM_CURRENTPID,\ 374 __func__ , ##__VA_ARGS__); \ 375 } while (0) 376 377 #define DRM_LOG_KMS(fmt, ...) do { \ 378 kprintf("[" DRM_NAME ":KMS:pid%d:%s] " fmt, DRM_CURRENTPID, \ 379 __func__ , ##__VA_ARGS__); \ 380 } while (0) 381 382 #define dev_dbg(dev, fmt, ...) do { \ 383 if ((drm_debug& DRM_DEBUGBITS_KMS) != 0) { \ 384 device_printf((dev), "debug: " fmt, ## __VA_ARGS__); \ 385 } \ 386 } while (0) 387 388 typedef struct drm_pci_id_list 389 { 390 int vendor; 391 int device; 392 long driver_private; 393 char *name; 394 } drm_pci_id_list_t; 395 396 struct drm_msi_blacklist_entry 397 { 398 int vendor; 399 int device; 400 }; 401 402 /** 403 * Ioctl function type. 404 * 405 * \param inode device inode. 406 * \param file_priv DRM file private pointer. 407 * \param cmd command. 408 * \param arg argument. 409 */ 410 typedef int drm_ioctl_t(struct drm_device *dev, void *data, 411 struct drm_file *file_priv); 412 413 typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, 414 unsigned long arg); 415 416 #define DRM_IOCTL_NR(n) ((n) & 0xff) 417 418 #define DRM_AUTH 0x1 419 #define DRM_MASTER 0x2 420 #define DRM_ROOT_ONLY 0x4 421 #define DRM_CONTROL_ALLOW 0x8 422 #define DRM_UNLOCKED 0x10 423 #define DRM_RENDER_ALLOW 0x20 424 425 struct drm_ioctl_desc { 426 unsigned int cmd; 427 int flags; 428 drm_ioctl_t *func; 429 unsigned int cmd_drv; 430 const char *name; 431 }; 432 433 /** 434 * Creates a driver or general drm_ioctl_desc array entry for the given 435 * ioctl, for use by drm_ioctl(). 436 */ 437 #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ 438 [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl} 439 440 typedef struct drm_magic_entry { 441 struct list_head head; 442 struct drm_hash_item hash_item; 443 struct drm_file *priv; 444 struct drm_magic_entry *next; 445 } drm_magic_entry_t; 446 447 typedef struct drm_magic_head { 448 struct drm_magic_entry *head; 449 struct drm_magic_entry *tail; 450 } drm_magic_head_t; 451 452 typedef struct drm_buf { 453 int idx; /**< Index into master buflist */ 454 int total; /**< Buffer size */ 455 int order; /**< log-base-2(total) */ 456 int used; /**< Amount of buffer in use (for DMA) */ 457 unsigned long offset; /**< Byte offset (used internally) */ 458 void *address; /**< Address of buffer */ 459 unsigned long bus_address; /**< Bus address of buffer */ 460 struct drm_buf *next; /**< Kernel-only: used for free list */ 461 __volatile__ int waiting; /**< On kernel DMA queue */ 462 __volatile__ int pending; /**< On hardware DMA queue */ 463 struct drm_file *file_priv; /**< Private of holding file descr */ 464 int context; /**< Kernel queue for this buffer */ 465 int while_locked; /**< Dispatch this buffer while locked */ 466 enum { 467 DRM_LIST_NONE = 0, 468 DRM_LIST_FREE = 1, 469 DRM_LIST_WAIT = 2, 470 DRM_LIST_PEND = 3, 471 DRM_LIST_PRIO = 4, 472 DRM_LIST_RECLAIM = 5 473 } list; /**< Which list we're on */ 474 475 int dev_priv_size; /**< Size of buffer private storage */ 476 void *dev_private; /**< Per-buffer private storage */ 477 } drm_buf_t; 478 479 /** bufs is one longer than it has to be */ 480 struct drm_waitlist { 481 int count; /**< Number of possible buffers */ 482 struct drm_buf **bufs; /**< List of pointers to buffers */ 483 struct drm_buf **rp; /**< Read pointer */ 484 struct drm_buf **wp; /**< Write pointer */ 485 struct drm_buf **end; /**< End pointer */ 486 spinlock_t read_lock; 487 spinlock_t write_lock; 488 }; 489 490 struct drm_freelist { 491 int initialized; /* Freelist in use */ 492 atomic_t count; /* Number of free buffers */ 493 drm_buf_t *next; /* End pointer */ 494 495 wait_queue_head_t waiting; /**< Processes waiting on free bufs */ 496 int low_mark; /* Low water mark */ 497 int high_mark; /* High water mark */ 498 }; 499 500 typedef struct drm_dma_handle { 501 void *vaddr; 502 size_t size; 503 bus_addr_t busaddr; 504 bus_dma_tag_t tag; 505 bus_dmamap_t map; 506 } drm_dma_handle_t; 507 508 typedef struct drm_buf_entry { 509 int buf_size; 510 int buf_count; 511 drm_buf_t *buflist; 512 int seg_count; 513 drm_dma_handle_t **seglist; 514 int page_order; 515 516 struct drm_freelist freelist; 517 } drm_buf_entry_t; 518 519 /* Event queued up for userspace to read */ 520 struct drm_pending_event { 521 struct drm_event *event; 522 struct list_head link; 523 struct drm_file *file_priv; 524 pid_t pid; /* pid of requester, no guarantee it's valid by the time 525 we deliver the event, for tracing only */ 526 void (*destroy)(struct drm_pending_event *event); 527 }; 528 529 /* initial implementaton using a linked list - todo hashtab */ 530 struct drm_prime_file_private { 531 struct list_head head; 532 #ifdef DUMBBELL_WIP 533 struct mutex lock; 534 #endif /* DUMBBELL_WIP */ 535 }; 536 537 /** File private data */ 538 struct drm_file { 539 int authenticated; 540 struct drm_device *dev; 541 int master; 542 543 /* true when the client has asked us to expose stereo 3D mode flags */ 544 bool stereo_allowed; 545 /* 546 * true if client understands CRTC primary planes and cursor planes 547 * in the plane list 548 */ 549 unsigned universal_planes:1; 550 551 pid_t pid; 552 uid_t uid; 553 drm_magic_t magic; 554 unsigned long ioctl_count; 555 struct list_head lhead; 556 struct kqinfo dkq; 557 558 /** Mapping of mm object handles to object pointers. */ 559 struct idr object_idr; 560 /** Lock for synchronization of access to object_idr. */ 561 struct lock table_lock; 562 563 void *driver_priv; 564 565 int is_master; 566 struct drm_master *masterp; 567 568 /** 569 * fbs - List of framebuffers associated with this file. 570 * 571 * Protected by fbs_lock. Note that the fbs list holds a reference on 572 * the fb object to prevent it from untimely disappearing. 573 */ 574 struct list_head fbs; 575 struct lock fbs_lock; 576 577 wait_queue_head_t event_wait; 578 struct list_head event_list; 579 int event_space; 580 581 struct drm_prime_file_private prime; 582 }; 583 584 /** Wait queue */ 585 struct drm_queue { 586 atomic_t use_count; /**< Outstanding uses (+1) */ 587 atomic_t finalization; /**< Finalization in progress */ 588 atomic_t block_count; /**< Count of processes waiting */ 589 atomic_t block_read; /**< Queue blocked for reads */ 590 wait_queue_head_t read_queue; /**< Processes waiting on block_read */ 591 atomic_t block_write; /**< Queue blocked for writes */ 592 wait_queue_head_t write_queue; /**< Processes waiting on block_write */ 593 atomic_t total_queued; /**< Total queued statistic */ 594 atomic_t total_flushed; /**< Total flushes statistic */ 595 atomic_t total_locks; /**< Total locks statistics */ 596 enum drm_ctx_flags flags; /**< Context preserving and 2D-only */ 597 struct drm_waitlist waitlist; /**< Pending buffers */ 598 wait_queue_head_t flush_queue; /**< Processes waiting until flush */ 599 }; 600 601 /** 602 * Lock data. 603 */ 604 struct drm_lock_data { 605 struct drm_hw_lock *hw_lock; /**< Hardware lock */ 606 /** Private of lock holder's file (NULL=kernel) */ 607 struct drm_file *file_priv; 608 wait_queue_head_t lock_queue; /**< Queue of blocked processes */ 609 unsigned long lock_time; /**< Time of last lock in jiffies */ 610 }; 611 612 /* This structure, in the struct drm_device, is always initialized while the 613 * device 614 * is open. dev->dma_lock protects the incrementing of dev->buf_use, which 615 * when set marks that no further bufs may be allocated until device teardown 616 * occurs (when the last open of the device has closed). The high/low 617 * watermarks of bufs are only touched by the X Server, and thus not 618 * concurrently accessed, so no locking is needed. 619 */ 620 typedef struct drm_device_dma { 621 622 struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */ 623 int buf_count; /**< total number of buffers */ 624 struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */ 625 int seg_count; 626 int page_count; /**< number of pages */ 627 unsigned long *pagelist; /**< page list */ 628 unsigned long byte_count; 629 enum { 630 _DRM_DMA_USE_AGP = 0x01, 631 _DRM_DMA_USE_SG = 0x02, 632 _DRM_DMA_USE_FB = 0x04, 633 _DRM_DMA_USE_PCI_RO = 0x08 634 } flags; 635 636 } drm_device_dma_t; 637 638 typedef struct drm_agp_mem { 639 void *handle; 640 unsigned long bound; /* address */ 641 int pages; 642 struct drm_agp_mem *prev; 643 struct drm_agp_mem *next; 644 } drm_agp_mem_t; 645 646 typedef struct drm_agp_head { 647 device_t agpdev; 648 struct agp_info agp_info; 649 const char *chipset; 650 drm_agp_mem_t *memory; 651 unsigned long mode; 652 int enabled; 653 int acquired; 654 unsigned long base; 655 int agp_mtrr; 656 int cant_use_aperture; 657 unsigned long page_mask; 658 } drm_agp_head_t; 659 660 typedef struct drm_sg_mem { 661 vm_offset_t vaddr; 662 vm_paddr_t *busaddr; 663 vm_pindex_t pages; 664 } drm_sg_mem_t; 665 666 /** 667 * Kernel side of a mapping 668 */ 669 struct drm_local_map { 670 resource_size_t offset; /**< Requested physical address (0 for SAREA)*/ 671 unsigned long size; /**< Requested physical size (bytes) */ 672 enum drm_map_type type; /**< Type of memory to map */ 673 enum drm_map_flags flags; /**< Flags */ 674 void *handle; /**< User-space: "Handle" to pass to mmap() */ 675 /**< Kernel-space: kernel-virtual address */ 676 int mtrr; /**< MTRR slot used */ 677 }; 678 679 typedef struct drm_local_map drm_local_map_t; 680 681 /** 682 * Mappings list 683 */ 684 struct drm_map_list { 685 struct list_head head; /**< list head */ 686 struct drm_hash_item hash; 687 struct drm_local_map *map; /**< mapping */ 688 uint64_t user_token; 689 struct drm_master *master; 690 struct drm_mm_node *file_offset_node; /**< fake offset */ 691 }; 692 693 /** 694 * Context handle list 695 */ 696 struct drm_ctx_list { 697 struct list_head head; /**< list head */ 698 drm_context_t handle; /**< context handle */ 699 struct drm_file *tag; /**< associated fd private data */ 700 }; 701 702 /* location of GART table */ 703 #define DRM_ATI_GART_MAIN 1 704 #define DRM_ATI_GART_FB 2 705 706 #define DRM_ATI_GART_PCI 1 707 #define DRM_ATI_GART_PCIE 2 708 #define DRM_ATI_GART_IGP 3 709 710 struct drm_ati_pcigart_info { 711 int gart_table_location; 712 int gart_reg_if; 713 void *addr; 714 dma_addr_t bus_addr; 715 dma_addr_t table_mask; 716 dma_addr_t member_mask; 717 struct drm_dma_handle *table_handle; 718 drm_local_map_t mapping; 719 int table_size; 720 struct drm_dma_handle *dmah; /* handle for ATI PCIGART table */ 721 }; 722 723 /** 724 * GEM specific mm private for tracking GEM objects 725 */ 726 struct drm_gem_mm { 727 struct drm_vma_offset_manager vma_manager; 728 struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */ 729 struct drm_open_hash offset_hash; /**< User token hash table for maps */ 730 struct unrhdr *idxunr; 731 }; 732 733 struct drm_gem_object { 734 /** Reference count of this object */ 735 struct kref refcount; 736 737 /** 738 * handle_count - gem file_priv handle count of this object 739 * 740 * Each handle also holds a reference. Note that when the handle_count 741 * drops to 0 any global names (e.g. the id in the flink namespace) will 742 * be cleared. 743 * 744 * Protected by dev->object_name_lock. 745 * */ 746 unsigned handle_count; 747 748 /** Related drm device */ 749 struct drm_device *dev; 750 751 /** File representing the shmem storage: filp in Linux parlance */ 752 vm_object_t vm_obj; 753 754 /* Mapping info for this object */ 755 struct drm_vma_offset_node vma_node; 756 bool on_map; 757 struct drm_hash_item map_list; 758 759 /** 760 * Size of the object, in bytes. Immutable over the object's 761 * lifetime. 762 */ 763 size_t size; 764 765 /** 766 * Global name for this object, starts at 1. 0 means unnamed. 767 * Access is covered by the object_name_lock in the related drm_device 768 */ 769 int name; 770 771 /** 772 * Memory domains. These monitor which caches contain read/write data 773 * related to the object. When transitioning from one set of domains 774 * to another, the driver is called to ensure that caches are suitably 775 * flushed and invalidated 776 */ 777 uint32_t read_domains; 778 uint32_t write_domain; 779 780 /** 781 * While validating an exec operation, the 782 * new read/write domain values are computed here. 783 * They will be transferred to the above values 784 * at the point that any cache flushing occurs 785 */ 786 uint32_t pending_read_domains; 787 uint32_t pending_write_domain; 788 789 #ifdef DUMBBELL_WIP 790 /* dma buf exported from this GEM object */ 791 struct dma_buf *export_dma_buf; 792 793 /* dma buf attachment backing this object */ 794 struct dma_buf_attachment *import_attach; 795 #endif /* DUMBBELL_WIP */ 796 }; 797 798 #include "drm_crtc.h" 799 800 /** 801 * struct drm_master - drm master structure 802 * 803 * @refcount: Refcount for this master object. 804 * @minor: Link back to minor char device we are master for. Immutable. 805 * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex. 806 * @unique_len: Length of unique field. Protected by drm_global_mutex. 807 * @unique_size: Amount allocated. Protected by drm_global_mutex. 808 * @magiclist: Hash of used authentication tokens. Protected by struct_mutex. 809 * @magicfree: List of used authentication tokens. Protected by struct_mutex. 810 * @lock: DRI lock information. 811 * @driver_priv: Pointer to driver-private information. 812 */ 813 struct drm_master { 814 815 struct kref refcount; /* refcount for this master */ 816 817 struct list_head head; /**< each minor contains a list of masters */ 818 struct drm_minor *minor; /**< link back to minor we are a master for */ 819 820 char *unique; /**< Unique identifier: e.g., busid */ 821 int unique_len; /**< Length of unique field */ 822 int unique_size; /**< amount allocated */ 823 824 int blocked; /**< Blocked due to VC switch? */ 825 826 struct drm_open_hash magiclist; 827 struct list_head magicfree; 828 struct drm_lock_data lock; 829 void *driver_priv; 830 }; 831 832 /* Size of ringbuffer for vblank timestamps. Just double-buffer 833 * in initial implementation. 834 */ 835 #define DRM_VBLANKTIME_RBSIZE 2 836 837 /* Flags and return codes for get_vblank_timestamp() driver function. */ 838 #define DRM_CALLED_FROM_VBLIRQ 1 839 #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) 840 #define DRM_VBLANKTIME_INVBL (1 << 1) 841 842 /* get_scanout_position() return flags */ 843 #define DRM_SCANOUTPOS_VALID (1 << 0) 844 #define DRM_SCANOUTPOS_INVBL (1 << 1) 845 #define DRM_SCANOUTPOS_ACCURATE (1 << 2) 846 847 #ifndef DMA_BIT_MASK 848 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1) 849 #endif 850 851 #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) 852 853 /** 854 * DRM driver structure. This structure represent the common code for 855 * a family of cards. There will one drm_device for each card present 856 * in this family 857 */ 858 struct drm_driver { 859 int (*load)(struct drm_device *, unsigned long flags); 860 int (*use_msi)(struct drm_device *, unsigned long flags); 861 int (*firstopen)(struct drm_device *); 862 int (*open)(struct drm_device *, struct drm_file *); 863 void (*preclose)(struct drm_device *, struct drm_file *file_priv); 864 void (*postclose)(struct drm_device *, struct drm_file *); 865 void (*lastclose)(struct drm_device *); 866 int (*unload)(struct drm_device *); 867 void (*reclaim_buffers_locked)(struct drm_device *, 868 struct drm_file *file_priv); 869 int (*dma_ioctl)(struct drm_device *dev, void *data, 870 struct drm_file *file_priv); 871 void (*dma_ready)(struct drm_device *); 872 int (*dma_quiescent)(struct drm_device *); 873 int (*dma_flush_block_and_flush)(struct drm_device *, int context, 874 enum drm_lock_flags flags); 875 int (*dma_flush_unblock)(struct drm_device *, int context, 876 enum drm_lock_flags flags); 877 int (*context_ctor)(struct drm_device *dev, int context); 878 int (*context_dtor)(struct drm_device *dev, int context); 879 int (*kernel_context_switch)(struct drm_device *dev, int old, 880 int new); 881 int (*kernel_context_switch_unlock)(struct drm_device *dev); 882 void (*irq_preinstall)(struct drm_device *dev); 883 int (*irq_postinstall)(struct drm_device *dev); 884 void (*irq_uninstall)(struct drm_device *dev); 885 void (*irq_handler)(DRM_IRQ_ARGS); 886 887 u32 (*get_vblank_counter)(struct drm_device *dev, int crtc); 888 int (*enable_vblank)(struct drm_device *dev, int crtc); 889 void (*disable_vblank)(struct drm_device *dev, int crtc); 890 891 /** 892 * Called by vblank timestamping code. 893 * 894 * Return the current display scanout position from a crtc, and an 895 * optional accurate ktime_get timestamp of when position was measured. 896 * 897 * \param dev DRM device. 898 * \param crtc Id of the crtc to query. 899 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0). 900 * \param *vpos Target location for current vertical scanout position. 901 * \param *hpos Target location for current horizontal scanout position. 902 * \param *stime Target location for timestamp taken immediately before 903 * scanout position query. Can be NULL to skip timestamp. 904 * \param *etime Target location for timestamp taken immediately after 905 * scanout position query. Can be NULL to skip timestamp. 906 * 907 * Returns vpos as a positive number while in active scanout area. 908 * Returns vpos as a negative number inside vblank, counting the number 909 * of scanlines to go until end of vblank, e.g., -1 means "one scanline 910 * until start of active scanout / end of vblank." 911 * 912 * \return Flags, or'ed together as follows: 913 * 914 * DRM_SCANOUTPOS_VALID = Query successful. 915 * DRM_SCANOUTPOS_INVBL = Inside vblank. 916 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of 917 * this flag means that returned position may be offset by a constant 918 * but unknown small number of scanlines wrt. real scanout position. 919 * 920 */ 921 int (*get_scanout_position) (struct drm_device *dev, int crtc, 922 unsigned int flags, 923 int *vpos, int *hpos, ktime_t *stime, 924 ktime_t *etime); 925 926 int (*get_vblank_timestamp)(struct drm_device *dev, int crtc, 927 int *max_error, struct timeval *vblank_time, 928 unsigned flags); 929 930 void (*gem_free_object)(struct drm_gem_object *obj); 931 int (*gem_open_object)(struct drm_gem_object *, struct drm_file *); 932 void (*gem_close_object)(struct drm_gem_object *, struct drm_file *); 933 934 struct cdev_pager_ops *gem_pager_ops; 935 936 int (*dumb_create)(struct drm_file *file_priv, 937 struct drm_device *dev, struct drm_mode_create_dumb *args); 938 int (*dumb_map_offset)(struct drm_file *file_priv, 939 struct drm_device *dev, uint32_t handle, uint64_t *offset); 940 int (*dumb_destroy)(struct drm_file *file_priv, 941 struct drm_device *dev, uint32_t handle); 942 943 int (*sysctl_init)(struct drm_device *dev, 944 struct sysctl_ctx_list *ctx, struct sysctl_oid *top); 945 void (*sysctl_cleanup)(struct drm_device *dev); 946 947 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ 948 949 /** 950 * Called by \c drm_device_is_agp. Typically used to determine if a 951 * card is really attached to AGP or not. 952 * 953 * \param dev DRM device handle 954 * 955 * \returns 956 * One of three values is returned depending on whether or not the 957 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP 958 * (return of 1), or may or may not be AGP (return of 2). 959 */ 960 int (*device_is_agp) (struct drm_device * dev); 961 962 int major; 963 int minor; 964 int patchlevel; 965 const char *name; /* Simple driver name */ 966 const char *desc; /* Longer driver name */ 967 const char *date; /* Date of last major changes. */ 968 969 u32 driver_features; 970 int dev_priv_size; 971 struct drm_ioctl_desc *ioctls; 972 int num_ioctls; 973 }; 974 975 /** 976 * Info file list entry. This structure represents a debugfs or proc file to 977 * be created by the drm core 978 */ 979 struct drm_info_list { 980 const char *name; /** file name */ 981 int (*show)(struct seq_file*, void*); /** show callback */ 982 u32 driver_features; /**< Required driver features for this entry */ 983 void *data; 984 }; 985 986 /** 987 * debugfs node structure. This structure represents a debugfs file. 988 */ 989 struct drm_info_node { 990 struct list_head list; 991 struct drm_minor *minor; 992 const struct drm_info_list *info_ent; 993 struct dentry *dent; 994 }; 995 996 /** 997 * DRM minor structure. This structure represents a drm minor number. 998 */ 999 struct drm_minor { 1000 int index; /**< Minor device number */ 1001 int type; /**< Control or render */ 1002 device_t kdev; /**< OS device */ 1003 struct drm_device *dev; 1004 1005 struct drm_master *master; /* currently active master for this node */ 1006 struct list_head master_list; 1007 struct drm_mode_group mode_group; 1008 }; 1009 1010 struct drm_pending_vblank_event { 1011 struct drm_pending_event base; 1012 int pipe; 1013 struct drm_event_vblank event; 1014 }; 1015 1016 struct drm_sysctl_info { 1017 struct sysctl_ctx_list ctx; 1018 char name[2]; 1019 }; 1020 1021 /* Length for the array of resource pointers for drm_get_resource_*. */ 1022 #define DRM_MAX_PCI_RESOURCE 6 1023 1024 struct drm_vblank_crtc { 1025 struct drm_device *dev; /* pointer to the drm_device */ 1026 wait_queue_head_t queue; /**< VBLANK wait queue */ 1027 struct timeval time[DRM_VBLANKTIME_RBSIZE]; /**< timestamp of current count */ 1028 struct timer_list disable_timer; /* delayed disable timer */ 1029 atomic_t count; /**< number of VBLANK interrupts */ 1030 atomic_t refcount; /* number of users of vblank interruptsper crtc */ 1031 u32 last; /* protected by dev->vbl_lock, used */ 1032 /* for wraparound handling */ 1033 u32 last_wait; /* Last vblank seqno waited per CRTC */ 1034 unsigned int inmodeset; /* Display driver is setting mode */ 1035 int crtc; /* crtc index */ 1036 bool enabled; /* so we don't call enable more than 1037 once per disable */ 1038 }; 1039 1040 /** 1041 * DRM device structure. This structure represent a complete card that 1042 * may contain multiple heads. 1043 */ 1044 struct drm_device { 1045 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ 1046 1047 uint16_t pci_subdevice; /* PCI subsystem device id */ 1048 uint16_t pci_subvendor; /* PCI subsystem vendor id */ 1049 1050 char *unique; /* Unique identifier: e.g., busid */ 1051 int unique_len; /* Length of unique field */ 1052 struct cdev *devnode; /* Device number for mknod */ 1053 int if_version; /* Highest interface version set */ 1054 1055 int flags; /* Flags to open(2) */ 1056 1057 /* Locks */ 1058 struct spinlock dma_lock; /* protects dev->dma */ 1059 struct lwkt_serialize irq_lock; /* protects irq condition checks */ 1060 struct lock dev_lock; /* protects everything else */ 1061 1062 /** \name Locks */ 1063 /*@{ */ 1064 struct lock struct_mutex; /**< For others */ 1065 /*@} */ 1066 1067 /** \name Usage Counters */ 1068 /*@{ */ 1069 int open_count; /* Outstanding files open */ 1070 int buf_use; /* Buffers in use -- cannot alloc */ 1071 /*@} */ 1072 1073 1074 /** \name Performance counters */ 1075 /*@{ */ 1076 unsigned long counters; 1077 enum drm_stat_type types[15]; 1078 atomic_t counts[15]; 1079 /*@} */ 1080 1081 /* Authentication */ 1082 struct drm_open_hash magiclist; /**< magic hash table */ 1083 struct list_head magicfree; 1084 1085 struct list_head filelist; 1086 1087 /** \name Memory management */ 1088 /*@{ */ 1089 struct list_head maplist; /**< Linked list of regions */ 1090 int map_count; /**< Number of mappable regions */ 1091 struct drm_open_hash map_hash; /**< User token hash table for maps */ 1092 1093 /** \name Context handle management */ 1094 /*@{ */ 1095 struct list_head ctxlist; /**< Linked list of context handles */ 1096 int ctx_count; /**< Number of context handles */ 1097 struct lock ctxlist_mutex; /**< For ctxlist */ 1098 1099 struct idr ctx_idr; 1100 1101 /*@} */ 1102 1103 struct drm_lock_data lock; /* Information on hardware lock */ 1104 1105 /* DMA queues (contexts) */ 1106 drm_device_dma_t *dma; /* Optional pointer for DMA support */ 1107 1108 int irq; /* Interrupt used by board */ 1109 int irq_type; /* IRQ type (MSI enabled or not) */ 1110 int irqrid; /* Interrupt used by board */ 1111 struct resource *irqr; /* Resource for interrupt used by board */ 1112 void *irqh; /* Handle from bus_setup_intr */ 1113 1114 /* Storage of resource pointers for drm_get_resource_* */ 1115 struct resource *pcir[DRM_MAX_PCI_RESOURCE]; 1116 int pcirid[DRM_MAX_PCI_RESOURCE]; 1117 1118 int pci_domain; 1119 int pci_bus; 1120 int pci_slot; 1121 int pci_func; 1122 1123 /** \name Context support */ 1124 /*@{ */ 1125 int irq_enabled; /**< True if irq handler is enabled */ 1126 __volatile__ long context_flag; /**< Context swapping flag */ 1127 __volatile__ long interrupt_flag; /**< Interruption handler flag */ 1128 __volatile__ long dma_flag; /**< DMA dispatch flag */ 1129 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */ 1130 int last_checked; /**< Last context checked for DMA */ 1131 int last_context; /**< Last current context */ 1132 unsigned long last_switch; /**< jiffies at last context switch */ 1133 /*@} */ 1134 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 bool vblank_disable_allowed; 1145 1146 /* array of size num_crtcs */ 1147 struct drm_vblank_crtc *vblank; 1148 1149 struct lock vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ 1150 struct lock vbl_lock; 1151 struct timer_list vblank_disable_timer; 1152 1153 u32 max_vblank_count; /**< size of vblank counter register */ 1154 1155 /** 1156 * List of events 1157 */ 1158 struct list_head vblank_event_list; 1159 struct lock event_lock; 1160 1161 /*@} */ 1162 1163 struct sigio *buf_sigio; /* Processes waiting for SIGIO */ 1164 1165 /* Sysctl support */ 1166 struct drm_sysctl_info *sysctl; 1167 int sysctl_node_idx; 1168 1169 1170 drm_sg_mem_t *sg; /* Scatter gather memory */ 1171 unsigned int num_crtcs; /**< Number of CRTCs on this device */ 1172 1173 unsigned long *ctx_bitmap; 1174 void *dev_private; 1175 1176 void *drm_ttm_bdev; 1177 1178 /*@} */ 1179 1180 struct drm_agp_head *agp; /**< AGP data */ 1181 1182 struct device *dev; /**< Device structure */ 1183 struct pci_dev *pdev; /**< PCI device structure */ 1184 int pci_vendor; /**< PCI vendor id */ 1185 int pci_device; /**< PCI device id */ 1186 1187 struct drm_driver *driver; 1188 struct drm_local_map *agp_buffer_map; 1189 unsigned int agp_buffer_token; 1190 struct drm_minor *control; /**< Control node for card */ 1191 struct drm_minor *primary; /**< render type primary screen head */ 1192 1193 struct drm_mode_config mode_config; /**< Current mode config */ 1194 1195 /** \name GEM information */ 1196 /*@{ */ 1197 struct lock object_name_lock; 1198 struct idr object_name_idr; 1199 /*@} */ 1200 void *mm_private; 1201 1202 void *sysctl_private; 1203 char busid_str[128]; 1204 int modesetting; 1205 1206 int switch_power_state; 1207 1208 atomic_t unplugged; /* device has been unplugged or gone away */ 1209 }; 1210 1211 #define DRM_SWITCH_POWER_ON 0 1212 #define DRM_SWITCH_POWER_OFF 1 1213 #define DRM_SWITCH_POWER_CHANGING 2 1214 #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 1215 1216 static __inline__ int drm_core_check_feature(struct drm_device *dev, 1217 int feature) 1218 { 1219 return ((dev->driver->driver_features & feature) ? 1 : 0); 1220 } 1221 1222 static inline int drm_device_is_unplugged(struct drm_device *dev) 1223 { 1224 int ret = atomic_read(&dev->unplugged); 1225 smp_rmb(); 1226 return ret; 1227 } 1228 1229 static inline bool drm_is_primary_client(const struct drm_file *file_priv) 1230 { 1231 return 0 /* file_priv->minor->type == DRM_MINOR_LEGACY */; 1232 } 1233 1234 #if __OS_HAS_AGP 1235 static inline int drm_core_has_AGP(struct drm_device *dev) 1236 { 1237 return drm_core_check_feature(dev, DRIVER_USE_AGP); 1238 } 1239 #else 1240 #define drm_core_has_AGP(dev) (0) 1241 #endif 1242 1243 enum dmi_field { 1244 DMI_NONE, 1245 DMI_BIOS_VENDOR, 1246 DMI_BIOS_VERSION, 1247 DMI_BIOS_DATE, 1248 DMI_SYS_VENDOR, 1249 DMI_PRODUCT_NAME, 1250 DMI_PRODUCT_VERSION, 1251 DMI_PRODUCT_SERIAL, 1252 DMI_PRODUCT_UUID, 1253 DMI_BOARD_VENDOR, 1254 DMI_BOARD_NAME, 1255 DMI_BOARD_VERSION, 1256 DMI_BOARD_SERIAL, 1257 DMI_BOARD_ASSET_TAG, 1258 DMI_CHASSIS_VENDOR, 1259 DMI_CHASSIS_TYPE, 1260 DMI_CHASSIS_VERSION, 1261 DMI_CHASSIS_SERIAL, 1262 DMI_CHASSIS_ASSET_TAG, 1263 DMI_STRING_MAX, 1264 }; 1265 1266 struct dmi_strmatch { 1267 unsigned char slot; 1268 char substr[79]; 1269 }; 1270 1271 struct dmi_system_id { 1272 int (*callback)(const struct dmi_system_id *); 1273 const char *ident; 1274 struct dmi_strmatch matches[4]; 1275 }; 1276 #define DMI_MATCH(a, b) {(a), (b)} 1277 bool dmi_check_system(const struct dmi_system_id *); 1278 1279 extern int drm_notyet_flag; 1280 extern unsigned int drm_debug; 1281 extern unsigned int drm_rnodes; 1282 extern unsigned int drm_universal_planes; 1283 1284 extern unsigned int drm_vblank_offdelay; 1285 extern unsigned int drm_timestamp_precision; 1286 extern unsigned int drm_timestamp_monotonic; 1287 1288 /* Device setup support (drm_drv.c) */ 1289 int drm_probe(device_t kdev, drm_pci_id_list_t *idlist); 1290 int drm_attach(device_t kdev, drm_pci_id_list_t *idlist); 1291 int drm_create_cdevs(device_t kdev); 1292 1293 d_ioctl_t drm_ioctl; 1294 extern int drm_lastclose(struct drm_device *dev); 1295 1296 /* Device support (drm_fops.h) */ 1297 extern struct lock drm_global_mutex; 1298 d_open_t drm_open; 1299 d_close_t drm_close; 1300 d_read_t drm_read; 1301 d_kqfilter_t drm_kqfilter; 1302 int drm_release(device_t kdev); 1303 1304 d_mmap_t drm_mmap; 1305 d_mmap_single_t drm_mmap_single; 1306 extern drm_local_map_t *drm_getsarea(struct drm_device *dev); 1307 1308 void drm_cdevpriv_dtor(void *cd); 1309 1310 void drm_event_wakeup(struct drm_pending_event *e); 1311 1312 int drm_add_busid_modesetting(struct drm_device *dev, 1313 struct sysctl_ctx_list *ctx, struct sysctl_oid *top); 1314 1315 /* File operations helpers (drm_fops.c) */ 1316 extern int drm_open_helper(struct cdev *kdev, int flags, int fmt, 1317 DRM_STRUCTPROC *p, 1318 struct drm_device *dev, 1319 struct file *fp); 1320 extern struct drm_file *drm_find_file_by_proc(struct drm_device *dev, 1321 DRM_STRUCTPROC *p); 1322 1323 #ifdef DUMBBELL_WIP 1324 extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, 1325 struct drm_file *file_priv, uint32_t handle, uint32_t flags, 1326 int *prime_fd); 1327 extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, 1328 struct drm_file *file_priv, int prime_fd, uint32_t *handle); 1329 1330 extern int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data, 1331 struct drm_file *file_priv); 1332 extern int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data, 1333 struct drm_file *file_priv); 1334 1335 extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, vm_page_t *pages, 1336 dma_addr_t *addrs, int max_pages); 1337 #endif /* DUMBBELL_WIP */ 1338 extern struct sg_table *drm_prime_pages_to_sg(vm_page_t *pages, int nr_pages); 1339 extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); 1340 1341 int drm_gem_dumb_destroy(struct drm_file *file, 1342 struct drm_device *dev, 1343 uint32_t handle); 1344 1345 #ifdef DUMBBELL_WIP 1346 void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv); 1347 void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv); 1348 int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle); 1349 int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle); 1350 void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf); 1351 1352 int drm_prime_add_dma_buf(struct drm_device *dev, struct drm_gem_object *obj); 1353 int drm_prime_lookup_obj(struct drm_device *dev, struct dma_buf *buf, 1354 struct drm_gem_object **obj); 1355 #endif /* DUMBBELL_WIP */ 1356 1357 /* Memory management support (drm_memory.h) */ 1358 #include <drm/drm_memory.h> 1359 void drm_mem_init(void); 1360 void drm_mem_uninit(void); 1361 void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map); 1362 void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map); 1363 void drm_ioremapfree(drm_local_map_t *map); 1364 int drm_mtrr_add(unsigned long offset, size_t size, int flags); 1365 int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags); 1366 1367 int drm_ctxbitmap_init(struct drm_device *dev); 1368 void drm_ctxbitmap_cleanup(struct drm_device *dev); 1369 void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); 1370 1371 /* Locking IOCTL support (drm_lock.c) */ 1372 int drm_lock_take(struct drm_lock_data *lock_data, 1373 unsigned int context); 1374 int drm_lock_transfer(struct drm_lock_data *lock_data, 1375 unsigned int context); 1376 int drm_lock_free(struct drm_lock_data *lock_data, 1377 unsigned int context); 1378 1379 /* 1380 * These are exported to drivers so that they can implement fencing using 1381 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. 1382 */ 1383 1384 unsigned long drm_get_resource_start(struct drm_device *dev, 1385 unsigned int resource); 1386 unsigned long drm_get_resource_len(struct drm_device *dev, 1387 unsigned int resource); 1388 void drm_rmmap(struct drm_device *dev, drm_local_map_t *map); 1389 int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request); 1390 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 1395 /* DMA support (drm_dma.c) */ 1396 int drm_dma_setup(struct drm_device *dev); 1397 void drm_dma_takedown(struct drm_device *dev); 1398 void drm_free_buffer(struct drm_device *dev, drm_buf_t *buf); 1399 void drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv); 1400 #define drm_core_reclaim_buffers drm_reclaim_buffers 1401 1402 /* IRQ support (drm_irq.h) */ 1403 extern int drm_irq_install(struct drm_device *dev, int irq); 1404 int drm_irq_uninstall(struct drm_device *dev); 1405 void drm_driver_irq_preinstall(struct drm_device *dev); 1406 void drm_driver_irq_postinstall(struct drm_device *dev); 1407 void drm_driver_irq_uninstall(struct drm_device *dev); 1408 1409 extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); 1410 extern int drm_wait_vblank(struct drm_device *dev, void *data, 1411 struct drm_file *filp); 1412 extern u32 drm_vblank_count(struct drm_device *dev, int crtc); 1413 extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, 1414 struct timeval *vblanktime); 1415 extern void drm_send_vblank_event(struct drm_device *dev, int crtc, 1416 struct drm_pending_vblank_event *e); 1417 extern bool drm_handle_vblank(struct drm_device *dev, int crtc); 1418 extern int drm_vblank_get(struct drm_device *dev, int crtc); 1419 extern void drm_vblank_put(struct drm_device *dev, int crtc); 1420 extern int drm_crtc_vblank_get(struct drm_crtc *crtc); 1421 extern void drm_crtc_vblank_put(struct drm_crtc *crtc); 1422 extern void drm_vblank_off(struct drm_device *dev, int crtc); 1423 extern void drm_vblank_on(struct drm_device *dev, int crtc); 1424 extern void drm_crtc_vblank_off(struct drm_crtc *crtc); 1425 extern void drm_crtc_vblank_on(struct drm_crtc *crtc); 1426 extern void drm_vblank_cleanup(struct drm_device *dev); 1427 1428 extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc, 1429 struct timeval *tvblank, unsigned flags); 1430 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, 1431 int crtc, int *max_error, 1432 struct timeval *vblank_time, 1433 unsigned flags, 1434 const struct drm_crtc *refcrtc, 1435 const struct drm_display_mode *mode); 1436 extern void drm_calc_timestamping_constants(struct drm_crtc *crtc, 1437 const struct drm_display_mode *mode); 1438 1439 /* Modesetting support */ 1440 extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); 1441 extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); 1442 extern int drm_modeset_ctl(struct drm_device *dev, void *data, 1443 struct drm_file *file_priv); 1444 1445 /* AGP/PCI Express/GART support (drm_agpsupport.c) */ 1446 int drm_device_is_agp(struct drm_device *dev); 1447 int drm_device_is_pcie(struct drm_device *dev); 1448 drm_agp_head_t *drm_agp_init(void); 1449 int drm_agp_acquire(struct drm_device *dev); 1450 int drm_agp_release(struct drm_device *dev); 1451 int drm_agp_info(struct drm_device * dev, struct drm_agp_info *info); 1452 int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); 1453 void *drm_agp_allocate_memory(size_t pages, u32 type); 1454 int drm_agp_free_memory(void *handle); 1455 int drm_agp_bind_memory(void *handle, off_t start); 1456 int drm_agp_unbind_memory(void *handle); 1457 int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); 1458 int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); 1459 int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); 1460 int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); 1461 1462 /* Scatter Gather Support (drm_scatter.h) */ 1463 extern void drm_legacy_sg_cleanup(struct drm_device *dev); 1464 extern int drm_sg_alloc(struct drm_device *dev, void *data, 1465 struct drm_file *file_priv); 1466 1467 /* Scatter Gather Support (drm_scatter.c) */ 1468 void drm_sg_cleanup(drm_sg_mem_t *entry); 1469 1470 /* sysctl support (drm_sysctl.h) */ 1471 extern int drm_sysctl_init(struct drm_device *dev); 1472 extern int drm_sysctl_cleanup(struct drm_device *dev); 1473 1474 /* ATI PCIGART support (ati_pcigart.c) */ 1475 int drm_ati_pcigart_init(struct drm_device *dev, 1476 struct drm_ati_pcigart_info *gart_info); 1477 int drm_ati_pcigart_cleanup(struct drm_device *dev, 1478 struct drm_ati_pcigart_info *gart_info); 1479 1480 /* Cache management (drm_memory.c) */ 1481 void drm_clflush_pages(vm_page_t *pages, unsigned long num_pages); 1482 1483 /* Locking IOCTL support (drm_drv.c) */ 1484 int drm_lock(struct drm_device *dev, void *data, 1485 struct drm_file *file_priv); 1486 int drm_unlock(struct drm_device *dev, void *data, 1487 struct drm_file *file_priv); 1488 int drm_version(struct drm_device *dev, void *data, 1489 struct drm_file *file_priv); 1490 int drm_setversion(struct drm_device *dev, void *data, 1491 struct drm_file *file_priv); 1492 1493 /* Misc. IOCTL support (drm_ioctl.c) */ 1494 int drm_irq_by_busid(struct drm_device *dev, void *data, 1495 struct drm_file *file_priv); 1496 int drm_getunique(struct drm_device *dev, void *data, 1497 struct drm_file *file_priv); 1498 int drm_setunique(struct drm_device *dev, void *data, 1499 struct drm_file *file_priv); 1500 int drm_getmap(struct drm_device *dev, void *data, 1501 struct drm_file *file_priv); 1502 int drm_getclient(struct drm_device *dev, void *data, 1503 struct drm_file *file_priv); 1504 int drm_getstats(struct drm_device *dev, void *data, 1505 struct drm_file *file_priv); 1506 int drm_getcap(struct drm_device *dev, void *data, 1507 struct drm_file *file_priv); 1508 extern int drm_setclientcap(struct drm_device *dev, void *data, 1509 struct drm_file *file_priv); 1510 int drm_noop(struct drm_device *dev, void *data, 1511 struct drm_file *file_priv); 1512 1513 /* Context IOCTL support (drm_context.c) */ 1514 int drm_resctx(struct drm_device *dev, void *data, 1515 struct drm_file *file_priv); 1516 int drm_addctx(struct drm_device *dev, void *data, 1517 struct drm_file *file_priv); 1518 int drm_getctx(struct drm_device *dev, void *data, 1519 struct drm_file *file_priv); 1520 int drm_switchctx(struct drm_device *dev, void *data, 1521 struct drm_file *file_priv); 1522 int drm_newctx(struct drm_device *dev, void *data, 1523 struct drm_file *file_priv); 1524 int drm_rmctx(struct drm_device *dev, void *data, 1525 struct drm_file *file_priv); 1526 int drm_setsareactx(struct drm_device *dev, void *data, 1527 struct drm_file *file_priv); 1528 int drm_getsareactx(struct drm_device *dev, void *data, 1529 struct drm_file *file_priv); 1530 1531 /* Authentication IOCTL support (drm_auth.c) */ 1532 int drm_getmagic(struct drm_device *dev, void *data, 1533 struct drm_file *file_priv); 1534 int drm_authmagic(struct drm_device *dev, void *data, 1535 struct drm_file *file_priv); 1536 1537 /* Cache management (drm_cache.c) */ 1538 void drm_clflush_virt_range(void *addr, unsigned long length); 1539 1540 /* Buffer management support (drm_bufs.c) */ 1541 int drm_addmap_ioctl(struct drm_device *dev, void *data, 1542 struct drm_file *file_priv); 1543 int drm_rmmap_ioctl(struct drm_device *dev, void *data, 1544 struct drm_file *file_priv); 1545 int drm_addbufs(struct drm_device *dev, void *data, 1546 struct drm_file *file_priv); 1547 int drm_infobufs(struct drm_device *dev, void *data, 1548 struct drm_file *file_priv); 1549 int drm_markbufs(struct drm_device *dev, void *data, 1550 struct drm_file *file_priv); 1551 int drm_freebufs(struct drm_device *dev, void *data, 1552 struct drm_file *file_priv); 1553 int drm_mapbufs(struct drm_device *dev, void *data, 1554 struct drm_file *file_priv); 1555 1556 /* DMA support (drm_dma.c) */ 1557 int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv); 1558 1559 /* IRQ support (drm_irq.c) */ 1560 int drm_control(struct drm_device *dev, void *data, 1561 struct drm_file *file_priv); 1562 1563 /* AGP/GART support (drm_agpsupport.c) */ 1564 int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, 1565 struct drm_file *file_priv); 1566 int drm_agp_release_ioctl(struct drm_device *dev, void *data, 1567 struct drm_file *file_priv); 1568 int drm_agp_enable_ioctl(struct drm_device *dev, void *data, 1569 struct drm_file *file_priv); 1570 int drm_agp_info_ioctl(struct drm_device *dev, void *data, 1571 struct drm_file *file_priv); 1572 int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, 1573 struct drm_file *file_priv); 1574 int drm_agp_free_ioctl(struct drm_device *dev, void *data, 1575 struct drm_file *file_priv); 1576 int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, 1577 struct drm_file *file_priv); 1578 int drm_agp_bind_ioctl(struct drm_device *dev, void *data, 1579 struct drm_file *file_priv); 1580 1581 /* Stub support (drm_stub.h) */ 1582 extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, 1583 struct drm_file *file_priv); 1584 extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, 1585 struct drm_file *file_priv); 1586 1587 /* Scatter Gather Support (drm_scatter.c) */ 1588 int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, 1589 struct drm_file *file_priv); 1590 int drm_sg_free(struct drm_device *dev, void *data, 1591 struct drm_file *file_priv); 1592 1593 /* consistent PCI memory functions (drm_pci.c) */ 1594 extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, 1595 size_t align); 1596 void drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah); 1597 1598 /* sysfs support (drm_sysfs.c) */ 1599 struct drm_sysfs_class; 1600 extern struct class *drm_sysfs_create(struct module *owner, char *name); 1601 extern void drm_sysfs_destroy(void); 1602 extern int drm_sysfs_device_add(struct drm_minor *minor); 1603 extern void drm_sysfs_hotplug_event(struct drm_device *dev); 1604 extern void drm_sysfs_device_remove(struct drm_minor *minor); 1605 extern int drm_sysfs_connector_add(struct drm_connector *connector); 1606 extern void drm_sysfs_connector_remove(struct drm_connector *connector); 1607 1608 /* Graphics Execution Manager library functions (drm_gem.c) */ 1609 int drm_gem_init(struct drm_device *dev); 1610 void drm_gem_destroy(struct drm_device *dev); 1611 void drm_gem_object_release(struct drm_gem_object *obj); 1612 void drm_gem_object_free(struct kref *kref); 1613 int drm_gem_object_init(struct drm_device *dev, 1614 struct drm_gem_object *obj, size_t size); 1615 void drm_gem_private_object_init(struct drm_device *dev, 1616 struct drm_gem_object *obj, size_t size); 1617 void drm_gem_vm_open(struct vm_area_struct *vma); 1618 void drm_gem_vm_close(struct vm_area_struct *vma); 1619 int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, 1620 struct vm_area_struct *vma); 1621 int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); 1622 1623 int i915_gem_pager_ctor(void *handle, vm_ooffset_t size, vm_prot_t prot, 1624 vm_ooffset_t foff, struct ucred *cred, u_short *color); 1625 void i915_gem_pager_dtor(void * handle); 1626 1627 #include <drm/drm_global.h> 1628 1629 static inline void 1630 drm_gem_object_reference(struct drm_gem_object *obj) 1631 { 1632 kref_get(&obj->refcount); 1633 } 1634 1635 static inline void 1636 drm_gem_object_unreference(struct drm_gem_object *obj) 1637 { 1638 if (obj != NULL) 1639 kref_put(&obj->refcount, drm_gem_object_free); 1640 } 1641 1642 static inline void 1643 drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) 1644 { 1645 if (obj != NULL) { 1646 struct drm_device *dev = obj->dev; 1647 DRM_LOCK(dev); 1648 kref_put(&obj->refcount, drm_gem_object_free); 1649 DRM_UNLOCK(dev); 1650 } 1651 } 1652 1653 int drm_gem_handle_create_tail(struct drm_file *file_priv, 1654 struct drm_gem_object *obj, 1655 u32 *handlep); 1656 int drm_gem_handle_create(struct drm_file *file_priv, 1657 struct drm_gem_object *obj, 1658 u32 *handlep); 1659 int drm_gem_handle_delete(struct drm_file *filp, u32 handle); 1660 1661 struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, 1662 struct drm_file *filp, 1663 u32 handle); 1664 int drm_gem_close_ioctl(struct drm_device *dev, void *data, 1665 struct drm_file *file_priv); 1666 int drm_gem_flink_ioctl(struct drm_device *dev, void *data, 1667 struct drm_file *file_priv); 1668 int drm_gem_open_ioctl(struct drm_device *dev, void *data, 1669 struct drm_file *file_priv); 1670 void drm_gem_open(struct drm_device *dev, struct drm_file *file_priv); 1671 void drm_gem_release(struct drm_device *dev, struct drm_file *file_priv); 1672 1673 void drm_gem_free_mmap_offset(struct drm_gem_object *obj); 1674 int drm_gem_create_mmap_offset(struct drm_gem_object *obj); 1675 int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); 1676 1677 int drm_gem_mmap_single(struct drm_device *dev, vm_ooffset_t *offset, 1678 vm_size_t size, struct vm_object **obj_res, int nprot); 1679 void drm_gem_pager_dtr(void *obj); 1680 1681 struct ttm_bo_device; 1682 int ttm_bo_mmap_single(struct ttm_bo_device *bdev, vm_ooffset_t *offset, 1683 vm_size_t size, struct vm_object **obj_res, int nprot); 1684 struct ttm_buffer_object; 1685 void ttm_bo_release_mmap(struct ttm_buffer_object *bo); 1686 1687 void drm_device_lock_mtx(struct drm_device *dev); 1688 void drm_device_unlock_mtx(struct drm_device *dev); 1689 int drm_device_sleep_mtx(struct drm_device *dev, void *chan, int flags, 1690 const char *msg, int timeout); 1691 void drm_device_assert_mtx_locked(struct drm_device *dev); 1692 void drm_device_assert_mtx_unlocked(struct drm_device *dev); 1693 1694 void drm_device_lock_struct(struct drm_device *dev); 1695 void drm_device_unlock_struct(struct drm_device *dev); 1696 int drm_device_sleep_struct(struct drm_device *dev, void *chan, int flags, 1697 const char *msg, int timeout); 1698 void drm_device_assert_struct_locked(struct drm_device *dev); 1699 void drm_device_assert_struct_unlocked(struct drm_device *dev); 1700 1701 void drm_compat_locking_init(struct drm_device *dev); 1702 void drm_sleep_locking_init(struct drm_device *dev); 1703 1704 /* Inline replacements for drm_alloc and friends */ 1705 static __inline__ void * 1706 drm_alloc(size_t size, struct malloc_type *area) 1707 { 1708 return kmalloc(size, area, M_WAITOK | M_NULLOK); 1709 } 1710 1711 static __inline__ void * 1712 drm_calloc(size_t nmemb, size_t size, struct malloc_type *area) 1713 { 1714 return kmalloc(size * nmemb, area, M_WAITOK | M_NULLOK | M_ZERO); 1715 } 1716 1717 static __inline__ void 1718 drm_free(void *pt, struct malloc_type *area) 1719 { 1720 kfree(pt); 1721 } 1722 1723 static __inline__ void 1724 drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev) 1725 { 1726 map->handle = drm_ioremap_wc(dev, map); 1727 } 1728 static __inline__ void 1729 drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev) 1730 { 1731 map->handle = drm_ioremap(dev, map); 1732 } 1733 static __inline__ void 1734 drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev) 1735 { 1736 if ( map->handle && map->size ) 1737 drm_ioremapfree(map); 1738 } 1739 1740 static __inline__ struct drm_local_map * 1741 drm_core_findmap(struct drm_device *dev, unsigned long offset) 1742 { 1743 struct drm_map_list *_entry; 1744 1745 list_for_each_entry(_entry, &dev->maplist, head) { 1746 if (offset == (unsigned long)_entry->map->handle) 1747 return _entry->map; 1748 } 1749 return NULL; 1750 } 1751 1752 static __inline__ void drm_core_dropmap(struct drm_map *map) 1753 { 1754 } 1755 1756 #include <drm/drm_mem_util.h> 1757 1758 /* FreeBSD compatibility macros */ 1759 #define VM_OBJECT_WLOCK(object) VM_OBJECT_LOCK(object) 1760 #define VM_OBJECT_WUNLOCK(object) VM_OBJECT_UNLOCK(object) 1761 1762 #define DRM_PCIE_SPEED_25 1 1763 #define DRM_PCIE_SPEED_50 2 1764 #define DRM_PCIE_SPEED_80 4 1765 1766 extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); 1767 1768 #define drm_can_sleep() (DRM_HZ & 1) 1769 1770 #endif /* __KERNEL__ */ 1771 #endif /* _DRM_P_H_ */ 1772