1 /* 2 * Internal Header for the Direct Rendering Manager 3 * 4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 6 * Copyright (c) 2009-2010, Code Aurora Forum. 7 * All rights reserved. 8 * 9 * Author: Rickard E. (Rik) Faith <faith@valinux.com> 10 * Author: Gareth Hughes <gareth@valinux.com> 11 * 12 * Permission is hereby granted, free of charge, to any person obtaining a 13 * copy of this software and associated documentation files (the "Software"), 14 * to deal in the Software without restriction, including without limitation 15 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 16 * and/or sell copies of the Software, and to permit persons to whom the 17 * Software is furnished to do so, subject to the following conditions: 18 * 19 * The above copyright notice and this permission notice (including the next 20 * paragraph) shall be included in all copies or substantial portions of the 21 * Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 27 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 28 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 29 * OTHER DEALINGS IN THE SOFTWARE. 30 */ 31 32 #ifndef _DRM_P_H_ 33 #define _DRM_P_H_ 34 35 #if defined(_KERNEL) || defined(__KERNEL__) 36 37 #include <sys/param.h> 38 #include <sys/queue.h> 39 #include <sys/malloc.h> 40 #include <sys/kernel.h> 41 #include <sys/ktr.h> 42 #include <sys/module.h> 43 #include <sys/systm.h> 44 #include <sys/device.h> 45 #include <sys/sglist.h> 46 #include <sys/stat.h> 47 #include <sys/priv.h> 48 #include <sys/proc.h> 49 #include <sys/lock.h> 50 #include <sys/spinlock.h> 51 #include <sys/spinlock2.h> 52 #include <sys/fcntl.h> 53 #include <sys/uio.h> 54 #include <sys/filio.h> 55 #include <sys/sysctl.h> 56 #include <sys/bus.h> 57 #include <sys/queue.h> 58 #include <sys/signalvar.h> 59 #include <sys/poll.h> 60 #include <linux/highmem.h> 61 #include <sys/sbuf.h> 62 #include <sys/taskqueue.h> 63 #include <sys/tree.h> 64 #include <vm/vm.h> 65 #include <vm/pmap.h> 66 #include <vm/vm_extern.h> 67 #include <vm/vm_kern.h> 68 #include <vm/vm_map.h> 69 #include <vm/vm_object.h> 70 #include <vm/vm_page2.h> 71 #include <vm/vm_pager.h> 72 #include <vm/vm_param.h> 73 #include <machine/param.h> 74 #include <machine/pmap.h> 75 #ifdef __x86_64__ 76 #include <machine/specialreg.h> 77 #endif 78 #include <machine/sysarch.h> 79 #include <sys/endian.h> 80 #include <sys/mman.h> 81 #include <sys/rman.h> 82 #include <sys/memrange.h> 83 #include <sys/mutex.h> 84 85 #include <linux/atomic.h> 86 #include <linux/bug.h> 87 #include <linux/dma-mapping.h> 88 #include <linux/capability.h> 89 #include <linux/err.h> 90 #include <linux/idr.h> 91 #include <linux/pci.h> 92 #include <linux/jiffies.h> 93 #include <linux/kernel.h> 94 #include <linux/fs.h> 95 #include <linux/kref.h> 96 #include <linux/list.h> 97 #include <linux/mm.h> 98 #include <linux/moduleparam.h> 99 #include <linux/mutex.h> 100 #include <linux/slab.h> 101 #include <linux/scatterlist.h> 102 #include <linux/timer.h> 103 #include <asm/io.h> 104 #include <linux/seq_file.h> 105 #include <linux/types.h> 106 #include <linux/vmalloc.h> 107 #include <linux/wait.h> 108 #include <linux/workqueue.h> 109 110 #include <asm/uaccess.h> 111 112 #include <uapi_drm/drm.h> 113 #include <uapi_drm/drm_mode.h> 114 115 #include <drm/drm_agpsupport.h> 116 #include <drm/drm_crtc.h> 117 #include <drm/drm_global.h> 118 #include <drm/drm_hashtab.h> 119 #include <drm/drm_mem_util.h> 120 #include <drm/drm_mm.h> 121 #include <drm/drm_os_linux.h> 122 #include <uapi_drm/drm_sarea.h> 123 #include <drm/drm_vma_manager.h> 124 125 struct drm_file; 126 struct drm_device; 127 struct drm_agp_head; 128 struct drm_local_map; 129 struct drm_device_dma; 130 struct drm_dma_handle; 131 struct drm_gem_object; 132 133 struct device_node; 134 #ifdef CONFIG_VIDEOMODE_HELPERS 135 struct videomode; /* XXX empty struct in videomode.h ? */ 136 #endif 137 struct reservation_object; 138 struct dma_buf_attachment; 139 140 /* 141 * 4 debug categories are defined: 142 * 143 * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... 144 * This is the category used by the DRM_DEBUG() macro. 145 * 146 * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... 147 * This is the category used by the DRM_DEBUG_DRIVER() macro. 148 * 149 * KMS: used in the modesetting code. 150 * This is the category used by the DRM_DEBUG_KMS() macro. 151 * 152 * PRIME: used in the prime code. 153 * This is the category used by the DRM_DEBUG_PRIME() macro. 154 * 155 * ATOMIC: used in the atomic code. 156 * This is the category used by the DRM_DEBUG_ATOMIC() macro. 157 * 158 * 159 * PID: used as modifier to include PID number in messages. 160 * This is the category used by the all debug macros. 161 * 162 * FIOCTL: used in failed ioctl debugging. 163 * This is the category used by the DRM_DEBUG_FIOCTL() macro. 164 * 165 * IOCTL: used in ioctl debugging. 166 * This is the category used by the DRM_DEBUG_IOCTL() macro. 167 * 168 * VBLANK: used in vblank debugging. 169 * This is the category used by the DRM_DEBUG_VBLANK() macro. 170 * 171 * Enabling verbose debug messages is done through the drm.debug parameter, 172 * each category being enabled by a bit. 173 * 174 * drm.debug=0x1 will enable CORE messages 175 * drm.debug=0x2 will enable DRIVER messages 176 * drm.debug=0x3 will enable CORE and DRIVER messages 177 * ... 178 * drm.debug=0xf will enable all messages 179 * 180 * An interesting feature is that it's possible to enable verbose logging at 181 * run-time by using hw.drm.debug sysctl variable: 182 * # sysctl hw.drm.debug=0xfff 183 */ 184 #define DRM_UT_CORE 0x01 185 #define DRM_UT_DRIVER 0x02 186 #define DRM_UT_KMS 0x04 187 #define DRM_UT_PRIME 0x08 188 #define DRM_UT_ATOMIC 0x10 189 /* Extra DragonFly debug categories */ 190 #ifdef __DragonFly__ 191 #define DRM_UT_RES6 0x20 /* reserved for future expansion */ 192 #define DRM_UT_RES7 0x40 /* reserved for future expansion */ 193 #define DRM_UT_RES8 0x80 /* reserved for future expansion */ 194 #define DRM_UT_PID 0x100 195 #define DRM_UT_FIOCTL 0x200 196 #define DRM_UT_IOCTL 0x400 197 #define DRM_UT_VBLANK 0x800 198 #endif 199 200 extern __printflike(2, 3) 201 void drm_ut_debug_printk(const char *function_name, 202 const char *format, ...); 203 extern __printflike(2, 3) 204 void drm_err(const char *func, const char *format, ...); 205 206 /***********************************************************************/ 207 /** \name DRM template customization defaults */ 208 /*@{*/ 209 210 /* driver capabilities and requirements mask */ 211 #define DRIVER_USE_AGP 0x1 212 #define DRIVER_PCI_DMA 0x8 213 #define DRIVER_SG 0x10 214 #define DRIVER_HAVE_DMA 0x20 215 #define DRIVER_HAVE_IRQ 0x40 216 #define DRIVER_IRQ_SHARED 0x80 217 #define DRIVER_GEM 0x1000 218 #define DRIVER_MODESET 0x2000 219 #define DRIVER_PRIME 0x4000 220 #define DRIVER_RENDER 0x8000 221 #define DRIVER_ATOMIC 0x10000 222 #define DRIVER_KMS_LEGACY_CONTEXT 0x20000 223 224 #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */ 225 226 /***********************************************************************/ 227 /** \name Macros to make printk easier */ 228 /*@{*/ 229 230 /** 231 * Error output. 232 * 233 * \param fmt printf() like format string. 234 * \param arg arguments 235 */ 236 #define DRM_ERROR(fmt, ...) \ 237 drm_err(__func__, fmt, ##__VA_ARGS__) 238 239 /** 240 * Rate limited error output. Like DRM_ERROR() but won't flood the log. 241 * 242 * \param fmt printf() like format string. 243 * \param arg arguments 244 */ 245 #define DRM_ERROR_RATELIMITED(fmt, ...) \ 246 ({ \ 247 static struct krate krate_derr = { .freq = 1, .count = -16 }; \ 248 \ 249 krateprintf(&krate_derr, "error: [" DRM_NAME ":%s] *ERROR* " \ 250 fmt, __func__, ##__VA_ARGS__); \ 251 }) 252 253 #define DRM_INFO(fmt, ...) \ 254 printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) 255 256 #define DRM_INFO_ONCE(fmt, ...) \ 257 printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) 258 259 /** 260 * Debug output. 261 * 262 * \param fmt printf() like format string. 263 * \param arg arguments 264 */ 265 #define DRM_DEBUG(fmt, args...) \ 266 do { \ 267 if (unlikely(drm_debug & DRM_UT_CORE)) \ 268 drm_ut_debug_printk(__func__, fmt, ##args); \ 269 } while (0) 270 271 #define DRM_DEBUG_DRIVER(fmt, args...) \ 272 do { \ 273 if (unlikely(drm_debug & DRM_UT_DRIVER)) \ 274 drm_ut_debug_printk(__func__, fmt, ##args); \ 275 } while (0) 276 #define DRM_DEBUG_KMS(fmt, args...) \ 277 do { \ 278 if (unlikely(drm_debug & DRM_UT_KMS)) \ 279 drm_ut_debug_printk(__func__, fmt, ##args); \ 280 } while (0) 281 #define DRM_DEBUG_PRIME(fmt, args...) \ 282 do { \ 283 if (unlikely(drm_debug & DRM_UT_PRIME)) \ 284 drm_ut_debug_printk(__func__, fmt, ##args); \ 285 } while (0) 286 #define DRM_DEBUG_ATOMIC(fmt, args...) \ 287 do { \ 288 if (unlikely(drm_debug & DRM_UT_ATOMIC)) \ 289 drm_ut_debug_printk(__func__, fmt, ##args); \ 290 } while (0) 291 292 #ifdef __DragonFly__ 293 #define DRM_DEBUG_FIOCTL(fmt, args...) \ 294 do { \ 295 if (unlikely(drm_debug & DRM_UT_FIOCTL)) \ 296 drm_ut_debug_printk(__func__, fmt, ##args); \ 297 } while (0) 298 #define DRM_DEBUG_IOCTL(fmt, args...) \ 299 do { \ 300 if (unlikely(drm_debug & DRM_UT_IOCTL)) \ 301 drm_ut_debug_printk(__func__, fmt, ##args); \ 302 } while (0) 303 #define DRM_DEBUG_VBLANK(fmt, args...) \ 304 do { \ 305 if (unlikely(drm_debug & DRM_UT_VBLANK)) \ 306 drm_ut_debug_printk(__func__, fmt, ##args); \ 307 } while (0) 308 #endif 309 310 /*@}*/ 311 312 /***********************************************************************/ 313 /** \name Internal types and structures */ 314 /*@{*/ 315 316 SYSCTL_DECL(_hw_drm); 317 318 #define DRM_MAX(a,b) ((a)>(b)?(a):(b)) 319 320 #define DRM_IF_VERSION(maj, min) (maj << 16 | min) 321 322 #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) 323 #define DRM_DEV_UID UID_ROOT 324 #define DRM_DEV_GID GID_WHEEL 325 326 #define DRM_CURPROC curthread 327 #define DRM_STRUCTPROC struct thread 328 #define DRM_LOCK(dev) lockmgr(&(dev)->struct_mutex, LK_EXCLUSIVE) 329 #define DRM_UNLOCK(dev) lockmgr(&(dev)->struct_mutex, LK_RELEASE) 330 #define DRM_LOCK_SLEEP(dev, chan, flags, msg, timeout) \ 331 (lksleep((chan), &(dev)->struct_mutex, (flags), (msg), (timeout))) 332 #if defined(INVARIANTS) 333 #define DRM_LOCK_ASSERT(dev) KKASSERT(lockstatus(&(dev)->struct_mutex, curthread) != 0); 334 #define DRM_UNLOCK_ASSERT(dev) KKASSERT(lockstatus(&(dev)->struct_mutex, curthread) == 0); 335 #else 336 #define DRM_LOCK_ASSERT(d) 337 #define DRM_UNLOCK_ASSERT(d) 338 #endif 339 340 #define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS) 341 342 typedef void irqreturn_t; 343 #define IRQ_HANDLED /* nothing */ 344 #define IRQ_NONE /* nothing */ 345 346 #define drm_get_device_from_kdev(_kdev) (_kdev->si_drv1) 347 348 #define DRM_MTRR_WC MDF_WRITECOMBINE 349 350 int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end, 351 vm_memattr_t memattr); 352 void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end); 353 vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa); 354 355 /* drm_memory.c */ 356 int drm_mtrr_add(unsigned long offset, size_t size, int flags); 357 int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags); 358 359 typedef struct drm_pci_id_list 360 { 361 int vendor; 362 int device; 363 long driver_private; 364 char *name; 365 } drm_pci_id_list_t; 366 367 /** 368 * Ioctl function type. 369 * 370 * \param inode device inode. 371 * \param file_priv DRM file private pointer. 372 * \param cmd command. 373 * \param arg argument. 374 */ 375 typedef int drm_ioctl_t(struct drm_device *dev, void *data, 376 struct drm_file *file_priv); 377 378 typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, 379 unsigned long arg); 380 381 #define DRM_IOCTL_NR(n) ((n) & 0xff) 382 383 #define DRM_AUTH 0x1 384 #define DRM_MASTER 0x2 385 #define DRM_ROOT_ONLY 0x4 386 #define DRM_CONTROL_ALLOW 0x8 387 #define DRM_UNLOCKED 0x10 388 #define DRM_RENDER_ALLOW 0x20 389 390 struct drm_ioctl_desc { 391 unsigned int cmd; 392 int flags; 393 drm_ioctl_t *func; 394 unsigned int cmd_drv; 395 const char *name; 396 }; 397 398 /** 399 * Creates a driver or general drm_ioctl_desc array entry for the given 400 * ioctl, for use by drm_ioctl(). 401 */ 402 403 #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ 404 [DRM_IOCTL_NR(DRM_##ioctl)] = { \ 405 .cmd = DRM_##ioctl, \ 406 .func = _func, \ 407 .flags = _flags, \ 408 .cmd_drv = DRM_IOCTL_##ioctl, \ 409 .name = #ioctl \ 410 } 411 412 typedef struct drm_magic_entry { 413 struct list_head head; 414 struct drm_hash_item hash_item; 415 struct drm_file *priv; 416 struct drm_magic_entry *next; 417 } drm_magic_entry_t; 418 419 /* Event queued up for userspace to read */ 420 struct drm_pending_event { 421 struct drm_event *event; 422 struct list_head link; 423 struct drm_file *file_priv; 424 pid_t pid; /* pid of requester, no guarantee it's valid by the time 425 we deliver the event, for tracing only */ 426 void (*destroy)(struct drm_pending_event *event); 427 }; 428 429 /* initial implementaton using a linked list - todo hashtab */ 430 struct drm_prime_file_private { 431 struct list_head head; 432 #ifdef DUMBBELL_WIP 433 struct mutex lock; 434 #endif /* DUMBBELL_WIP */ 435 }; 436 437 /** File private data */ 438 struct drm_file { 439 int authenticated; 440 struct drm_device *dev; 441 int master; 442 443 /* true when the client has asked us to expose stereo 3D mode flags */ 444 bool stereo_allowed; 445 /* 446 * true if client understands CRTC primary planes and cursor planes 447 * in the plane list 448 */ 449 unsigned universal_planes:1; 450 /* true if client understands atomic properties */ 451 unsigned atomic:1; 452 453 pid_t pid; 454 uid_t uid; 455 drm_magic_t magic; 456 unsigned long ioctl_count; 457 struct list_head lhead; 458 struct kqinfo dkq; 459 460 /** Mapping of mm object handles to object pointers. */ 461 struct idr object_idr; 462 /** Lock for synchronization of access to object_idr. */ 463 struct lock table_lock; 464 465 void *driver_priv; 466 467 int is_master; 468 struct drm_master *masterp; 469 470 /** 471 * fbs - List of framebuffers associated with this file. 472 * 473 * Protected by fbs_lock. Note that the fbs list holds a reference on 474 * the fb object to prevent it from untimely disappearing. 475 */ 476 struct list_head fbs; 477 struct lock fbs_lock; 478 479 /** User-created blob properties; this retains a reference on the 480 * property. */ 481 struct list_head blobs; 482 483 wait_queue_head_t event_wait; 484 struct list_head event_list; 485 int event_space; 486 487 struct drm_prime_file_private prime; 488 }; 489 490 /** 491 * Lock data. 492 */ 493 struct drm_lock_data { 494 struct drm_hw_lock *hw_lock; /**< Hardware lock */ 495 /** Private of lock holder's file (NULL=kernel) */ 496 struct drm_file *file_priv; 497 wait_queue_head_t lock_queue; /**< Queue of blocked processes */ 498 unsigned long lock_time; /**< Time of last lock in jiffies */ 499 }; 500 501 /** 502 * GEM specific mm private for tracking GEM objects 503 */ 504 struct drm_gem_mm { 505 struct drm_vma_offset_manager vma_manager; 506 struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */ 507 struct drm_open_hash offset_hash; /**< User token hash table for maps */ 508 struct unrhdr *idxunr; 509 }; 510 511 /** 512 * struct drm_master - drm master structure 513 * 514 * @refcount: Refcount for this master object. 515 * @minor: Link back to minor char device we are master for. Immutable. 516 * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex. 517 * @unique_len: Length of unique field. Protected by drm_global_mutex. 518 * @unique_size: Amount allocated. Protected by drm_global_mutex. 519 * @magiclist: Hash of used authentication tokens. Protected by struct_mutex. 520 * @magicfree: List of used authentication tokens. Protected by struct_mutex. 521 * @lock: DRI lock information. 522 * @driver_priv: Pointer to driver-private information. 523 */ 524 struct drm_master { 525 struct kref refcount; /* refcount for this master */ 526 struct list_head head; /**< each minor contains a list of masters */ 527 struct drm_minor *minor; /**< link back to minor we are a master for */ 528 char *unique; /**< Unique identifier: e.g., busid */ 529 int unique_len; /**< Length of unique field */ 530 int unique_size; /**< amount allocated */ 531 int blocked; /**< Blocked due to VC switch? */ 532 struct drm_open_hash magiclist; 533 struct list_head magicfree; 534 struct drm_lock_data lock; 535 void *driver_priv; 536 }; 537 538 /* Size of ringbuffer for vblank timestamps. Just double-buffer 539 * in initial implementation. 540 */ 541 #define DRM_VBLANKTIME_RBSIZE 2 542 543 /* Flags and return codes for get_vblank_timestamp() driver function. */ 544 #define DRM_CALLED_FROM_VBLIRQ 1 545 #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) 546 #define DRM_VBLANKTIME_IN_VBLANK (1 << 1) 547 548 /* get_scanout_position() return flags */ 549 #define DRM_SCANOUTPOS_VALID (1 << 0) 550 #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1) 551 #define DRM_SCANOUTPOS_ACCURATE (1 << 2) 552 553 /** 554 * DRM driver structure. This structure represent the common code for 555 * a family of cards. There will one drm_device for each card present 556 * in this family 557 */ 558 struct drm_driver { 559 int (*load) (struct drm_device *, unsigned long flags); 560 int (*use_msi) (struct drm_device *, unsigned long flags); 561 int (*firstopen) (struct drm_device *); 562 int (*open) (struct drm_device *, struct drm_file *); 563 void (*preclose) (struct drm_device *, struct drm_file *file_priv); 564 void (*postclose) (struct drm_device *, struct drm_file *); 565 void (*lastclose) (struct drm_device *); 566 int (*unload) (struct drm_device *); 567 void (*reclaim_buffers_locked) (struct drm_device *, 568 struct drm_file *file_priv); 569 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); 570 int (*dma_quiescent) (struct drm_device *); 571 int (*context_ctor) (struct drm_device *dev, int context); 572 int (*context_dtor) (struct drm_device *dev, int context); 573 574 /** 575 * get_vblank_counter - get raw hardware vblank counter 576 * @dev: DRM device 577 * @crtc: counter to fetch 578 * 579 * Driver callback for fetching a raw hardware vblank counter for @crtc. 580 * If a device doesn't have a hardware counter, the driver can simply 581 * return the value of drm_vblank_count. The DRM core will account for 582 * missed vblank events while interrupts where disabled based on system 583 * timestamps. 584 * 585 * Wraparound handling and loss of events due to modesetting is dealt 586 * with in the DRM core code. 587 * 588 * RETURNS 589 * Raw vblank counter value. 590 */ 591 u32 (*get_vblank_counter) (struct drm_device *dev, int crtc); 592 593 /** 594 * enable_vblank - enable vblank interrupt events 595 * @dev: DRM device 596 * @crtc: which irq to enable 597 * 598 * Enable vblank interrupts for @crtc. If the device doesn't have 599 * a hardware vblank counter, this routine should be a no-op, since 600 * interrupts will have to stay on to keep the count accurate. 601 * 602 * RETURNS 603 * Zero on success, appropriate errno if the given @crtc's vblank 604 * interrupt cannot be enabled. 605 */ 606 int (*enable_vblank) (struct drm_device *dev, int crtc); 607 608 /** 609 * disable_vblank - disable vblank interrupt events 610 * @dev: DRM device 611 * @crtc: which irq to enable 612 * 613 * Disable vblank interrupts for @crtc. If the device doesn't have 614 * a hardware vblank counter, this routine should be a no-op, since 615 * interrupts will have to stay on to keep the count accurate. 616 */ 617 void (*disable_vblank) (struct drm_device *dev, int crtc); 618 619 /** 620 * Called by \c drm_device_is_agp. Typically used to determine if a 621 * card is really attached to AGP or not. 622 * 623 * \param dev DRM device handle 624 * 625 * \returns 626 * One of three values is returned depending on whether or not the 627 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP 628 * (return of 1), or may or may not be AGP (return of 2). 629 */ 630 int (*device_is_agp) (struct drm_device *dev); 631 632 /** 633 * Called by vblank timestamping code. 634 * 635 * Return the current display scanout position from a crtc, and an 636 * optional accurate ktime_get timestamp of when position was measured. 637 * 638 * \param dev DRM device. 639 * \param crtc Id of the crtc to query. 640 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0). 641 * \param *vpos Target location for current vertical scanout position. 642 * \param *hpos Target location for current horizontal scanout position. 643 * \param *stime Target location for timestamp taken immediately before 644 * scanout position query. Can be NULL to skip timestamp. 645 * \param *etime Target location for timestamp taken immediately after 646 * scanout position query. Can be NULL to skip timestamp. 647 * 648 * Returns vpos as a positive number while in active scanout area. 649 * Returns vpos as a negative number inside vblank, counting the number 650 * of scanlines to go until end of vblank, e.g., -1 means "one scanline 651 * until start of active scanout / end of vblank." 652 * 653 * \return Flags, or'ed together as follows: 654 * 655 * DRM_SCANOUTPOS_VALID = Query successful. 656 * DRM_SCANOUTPOS_INVBL = Inside vblank. 657 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of 658 * this flag means that returned position may be offset by a constant 659 * but unknown small number of scanlines wrt. real scanout position. 660 * 661 */ 662 int (*get_scanout_position) (struct drm_device *dev, int crtc, 663 unsigned int flags, 664 int *vpos, int *hpos, ktime_t *stime, 665 ktime_t *etime); 666 667 /** 668 * Called by \c drm_get_last_vbltimestamp. Should return a precise 669 * timestamp when the most recent VBLANK interval ended or will end. 670 * 671 * Specifically, the timestamp in @vblank_time should correspond as 672 * closely as possible to the time when the first video scanline of 673 * the video frame after the end of VBLANK will start scanning out, 674 * the time immediately after end of the VBLANK interval. If the 675 * @crtc is currently inside VBLANK, this will be a time in the future. 676 * If the @crtc is currently scanning out a frame, this will be the 677 * past start time of the current scanout. This is meant to adhere 678 * to the OpenML OML_sync_control extension specification. 679 * 680 * \param dev dev DRM device handle. 681 * \param crtc crtc for which timestamp should be returned. 682 * \param *max_error Maximum allowable timestamp error in nanoseconds. 683 * Implementation should strive to provide timestamp 684 * with an error of at most *max_error nanoseconds. 685 * Returns true upper bound on error for timestamp. 686 * \param *vblank_time Target location for returned vblank timestamp. 687 * \param flags 0 = Defaults, no special treatment needed. 688 * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank 689 * irq handler. Some drivers need to apply some workarounds 690 * for gpu-specific vblank irq quirks if flag is set. 691 * 692 * \returns 693 * Zero if timestamping isn't supported in current display mode or a 694 * negative number on failure. A positive status code on success, 695 * which describes how the vblank_time timestamp was computed. 696 */ 697 int (*get_vblank_timestamp) (struct drm_device *dev, int crtc, 698 int *max_error, 699 struct timeval *vblank_time, 700 unsigned flags); 701 702 /* these have to be filled in */ 703 704 void (*irq_handler) (void *arg); 705 void (*irq_preinstall) (struct drm_device *dev); 706 int (*irq_postinstall) (struct drm_device *dev); 707 void (*irq_uninstall) (struct drm_device *dev); 708 709 /** 710 * Driver-specific constructor for drm_gem_objects, to set up 711 * obj->driver_private. 712 * 713 * Returns 0 on success. 714 */ 715 void (*gem_free_object) (struct drm_gem_object *obj); 716 int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); 717 void (*gem_close_object) (struct drm_gem_object *, struct drm_file *); 718 719 int (*sysctl_init) (struct drm_device *dev, 720 struct sysctl_ctx_list *ctx, struct sysctl_oid *top); 721 void (*sysctl_cleanup) (struct drm_device *dev); 722 723 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ 724 725 /* dumb alloc support */ 726 int (*dumb_create)(struct drm_file *file_priv, 727 struct drm_device *dev, 728 struct drm_mode_create_dumb *args); 729 int (*dumb_map_offset)(struct drm_file *file_priv, 730 struct drm_device *dev, uint32_t handle, 731 uint64_t *offset); 732 int (*dumb_destroy)(struct drm_file *file_priv, 733 struct drm_device *dev, 734 uint32_t handle); 735 736 /* Driver private ops for this object */ 737 struct cdev_pager_ops *gem_pager_ops; 738 739 int major; 740 int minor; 741 int patchlevel; 742 const char *name; /* Simple driver name */ 743 const char *desc; /* Longer driver name */ 744 const char *date; /* Date of last major changes. */ 745 746 u32 driver_features; 747 int dev_priv_size; 748 const struct drm_ioctl_desc *ioctls; 749 int num_ioctls; 750 }; 751 752 /** 753 * Info file list entry. This structure represents a debugfs or proc file to 754 * be created by the drm core 755 */ 756 struct drm_info_list { 757 const char *name; /** file name */ 758 int (*show)(struct seq_file*, void*); /** show callback */ 759 u32 driver_features; /**< Required driver features for this entry */ 760 void *data; 761 }; 762 763 /** 764 * debugfs node structure. This structure represents a debugfs file. 765 */ 766 struct drm_info_node { 767 struct list_head list; 768 struct drm_minor *minor; 769 const struct drm_info_list *info_ent; 770 struct dentry *dent; 771 }; 772 773 /** 774 * DRM minor structure. This structure represents a drm minor number. 775 */ 776 struct drm_minor { 777 int index; /**< Minor device number */ 778 int type; /**< Control or render */ 779 device_t kdev; /**< OS device */ 780 struct drm_device *dev; 781 782 struct drm_master *master; /* currently active master for this node */ 783 struct list_head master_list; 784 struct drm_mode_group mode_group; 785 }; 786 787 struct drm_pending_vblank_event { 788 struct drm_pending_event base; 789 unsigned int pipe; 790 struct drm_event_vblank event; 791 }; 792 793 struct drm_vblank_crtc { 794 struct drm_device *dev; /* pointer to the drm_device */ 795 wait_queue_head_t queue; /**< VBLANK wait queue */ 796 struct timer_list disable_timer; /* delayed disable timer */ 797 798 /* vblank counter, protected by dev->vblank_time_lock for writes */ 799 unsigned long count; 800 /* vblank timestamps, protected by dev->vblank_time_lock for writes */ 801 struct timeval time[DRM_VBLANKTIME_RBSIZE]; 802 803 atomic_t refcount; /* number of users of vblank interruptsper crtc */ 804 u32 last; /* protected by dev->vbl_lock, used */ 805 /* for wraparound handling */ 806 u32 last_wait; /* Last vblank seqno waited per CRTC */ 807 unsigned int inmodeset; /* Display driver is setting mode */ 808 unsigned int pipe; /* crtc index */ 809 bool enabled; /* so we don't call enable more than 810 once per disable */ 811 }; 812 813 struct drm_sysctl_info { 814 struct sysctl_ctx_list ctx; 815 char name[2]; 816 }; 817 818 /* Length for the array of resource pointers for drm_get_resource_*. */ 819 #define DRM_MAX_PCI_RESOURCE 6 820 821 /** 822 * DRM device structure. This structure represent a complete card that 823 * may contain multiple heads. 824 */ 825 struct drm_device { 826 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ 827 828 char *unique; /* Unique identifier: e.g., busid */ 829 int unique_len; /* Length of unique field */ 830 struct cdev *devnode; /* Device number for mknod */ 831 int if_version; /* Highest interface version set */ 832 833 int flags; /* Flags to open(2) */ 834 835 /* Locks */ 836 struct spinlock dma_lock; /* protects dev->dma */ 837 struct lwkt_serialize irq_lock; /* protects irq condition checks */ 838 struct lock dev_lock; /* protects everything else */ 839 840 /** \name Locks */ 841 /*@{ */ 842 struct lock struct_mutex; /**< For others */ 843 struct lock master_mutex; /**< For drm_minor::master */ 844 /*@} */ 845 846 /** \name Usage Counters */ 847 /*@{ */ 848 int open_count; /**< Outstanding files open, protected by drm_global_mutex. */ 849 struct spinlock buf_lock; /**< For drm_device::buf_use and a few other things. */ 850 int buf_use; /**< Buffers in use -- cannot alloc */ 851 atomic_t buf_alloc; /**< Buffer allocation in progress */ 852 /*@} */ 853 854 855 /** \name Performance counters */ 856 /*@{ */ 857 unsigned long counters; 858 enum drm_stat_type types[15]; 859 atomic_t counts[15]; 860 /*@} */ 861 862 /* Authentication */ 863 struct drm_open_hash magiclist; /**< magic hash table */ 864 struct list_head magicfree; 865 866 struct list_head filelist; 867 868 /** \name Memory management */ 869 /*@{ */ 870 struct list_head maplist; /**< Linked list of regions */ 871 int map_count; /**< Number of mappable regions */ 872 struct drm_open_hash map_hash; /**< User token hash table for maps */ 873 874 /** \name Context handle management */ 875 /*@{ */ 876 struct list_head ctxlist; /**< Linked list of context handles */ 877 int ctx_count; /**< Number of context handles */ 878 struct lock ctxlist_mutex; /**< For ctxlist */ 879 880 struct idr ctx_idr; 881 882 /*@} */ 883 884 struct drm_lock_data lock; /* Information on hardware lock */ 885 886 /** \name DMA support */ 887 /*@{ */ 888 struct drm_device_dma *dma; /**< Optional pointer for DMA support */ 889 /*@} */ 890 891 int irq_type; /* IRQ type (MSI enabled or not) */ 892 int irqrid; /* Interrupt used by board */ 893 struct resource *irqr; /* Resource for interrupt used by board */ 894 void *irqh; /* Handle from bus_setup_intr */ 895 896 /* Storage of resource pointers for drm_get_resource_* */ 897 struct resource *pcir[DRM_MAX_PCI_RESOURCE]; 898 int pcirid[DRM_MAX_PCI_RESOURCE]; 899 900 int pci_domain; 901 int pci_bus; 902 int pci_slot; 903 int pci_func; 904 905 /** \name Context support */ 906 /*@{ */ 907 908 __volatile__ long context_flag; /**< Context swapping flag */ 909 __volatile__ long interrupt_flag; /**< Interruption handler flag */ 910 __volatile__ long dma_flag; /**< DMA dispatch flag */ 911 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */ 912 int last_checked; /**< Last context checked for DMA */ 913 int last_context; /**< Last current context */ 914 unsigned long last_switch; /**< jiffies at last context switch */ 915 /*@} */ 916 917 /** \name VBLANK IRQ support */ 918 /*@{ */ 919 int irq_enabled; /**< True if irq handler is enabled */ 920 int irq; /* Interrupt used by board */ 921 922 /* 923 * At load time, disabling the vblank interrupt won't be allowed since 924 * old clients may not call the modeset ioctl and therefore misbehave. 925 * Once the modeset ioctl *has* been called though, we can safely 926 * disable them when unused. 927 */ 928 bool vblank_disable_allowed; 929 930 /* 931 * If true, vblank interrupt will be disabled immediately when the 932 * refcount drops to zero, as opposed to via the vblank disable 933 * timer. 934 * This can be set to true it the hardware has a working vblank 935 * counter and the driver uses drm_vblank_on() and drm_vblank_off() 936 * appropriately. 937 */ 938 bool vblank_disable_immediate; 939 940 /* array of size num_crtcs */ 941 struct drm_vblank_crtc *vblank; 942 943 struct lock vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ 944 struct lock vbl_lock; 945 struct timer_list vblank_disable_timer; 946 947 u32 max_vblank_count; /**< size of vblank counter register */ 948 949 /** 950 * List of events 951 */ 952 struct list_head vblank_event_list; 953 struct lock event_lock; 954 955 /*@} */ 956 957 struct sigio *buf_sigio; /* Processes waiting for SIGIO */ 958 959 /* Sysctl support */ 960 struct drm_sysctl_info *sysctl; 961 962 963 struct drm_sg_mem *sg; /**< Scatter gather memory */ 964 unsigned int num_crtcs; /**< Number of CRTCs on this device */ 965 966 unsigned long *ctx_bitmap; 967 void *dev_private; 968 969 void *drm_ttm_bdev; 970 971 /*@} */ 972 973 struct drm_agp_head *agp; /**< AGP data */ 974 975 struct device *dev; /**< Device structure */ 976 struct pci_dev *pdev; /**< PCI device structure */ 977 978 struct drm_driver *driver; 979 struct drm_local_map *agp_buffer_map; 980 unsigned int agp_buffer_token; 981 struct drm_minor *control; /**< Control node for card */ 982 struct drm_minor *primary; /**< render type primary screen head */ 983 984 struct drm_mode_config mode_config; /**< Current mode config */ 985 986 /** \name GEM information */ 987 /*@{ */ 988 struct lock object_name_lock; 989 struct idr object_name_idr; 990 /*@} */ 991 void *mm_private; 992 993 void *sysctl_private; 994 char busid_str[128]; 995 int modesetting; 996 997 int switch_power_state; 998 999 atomic_t unplugged; /* device has been unplugged or gone away */ 1000 }; 1001 1002 #define DRM_SWITCH_POWER_ON 0 1003 #define DRM_SWITCH_POWER_OFF 1 1004 #define DRM_SWITCH_POWER_CHANGING 2 1005 #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 1006 1007 static __inline__ int drm_core_check_feature(struct drm_device *dev, 1008 int feature) 1009 { 1010 return ((dev->driver->driver_features & feature) ? 1 : 0); 1011 } 1012 1013 static inline void drm_device_set_unplugged(struct drm_device *dev) 1014 { 1015 smp_wmb(); 1016 atomic_set(&dev->unplugged, 1); 1017 } 1018 1019 static inline int drm_device_is_unplugged(struct drm_device *dev) 1020 { 1021 int ret = atomic_read(&dev->unplugged); 1022 smp_rmb(); 1023 return ret; 1024 } 1025 1026 static inline bool drm_is_primary_client(const struct drm_file *file_priv) 1027 { 1028 return 0 /* file_priv->minor->type == DRM_MINOR_LEGACY */; 1029 } 1030 1031 /** 1032 * drm_is_master() - Check whether a DRM open-file is DRM-Master 1033 * @file: DRM open-file context 1034 * 1035 * This checks whether a DRM open-file context is owner of the master context 1036 * attached to it. If a file owns a master context, it's called DRM-Master. 1037 * Per DRM device, only one such file can be DRM-Master at a time. 1038 * 1039 * Returns: True if the file is DRM-Master, otherwise false. 1040 */ 1041 static inline bool drm_is_master(const struct drm_file *file) 1042 { 1043 #if 0 1044 return file->master && file->master == file->minor->master; 1045 #else 1046 return true; 1047 #endif 1048 } 1049 1050 /******************************************************************/ 1051 /** \name Internal function definitions */ 1052 /*@{*/ 1053 1054 /* Driver support (drm_drv.h) */ 1055 extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv); 1056 int drm_probe(device_t kdev, drm_pci_id_list_t *idlist); 1057 int drm_attach(device_t kdev, drm_pci_id_list_t *idlist); 1058 int drm_create_cdevs(device_t kdev); 1059 d_ioctl_t drm_ioctl; 1060 extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags); 1061 1062 /* Device support (drm_fops.h) */ 1063 d_open_t drm_open; 1064 d_close_t drm_close; 1065 d_read_t drm_read; 1066 d_kqfilter_t drm_kqfilter; 1067 int drm_release(device_t kdev); 1068 1069 d_mmap_t drm_mmap; 1070 d_mmap_single_t drm_mmap_single; 1071 1072 void drm_cdevpriv_dtor(void *cd); 1073 1074 int drm_add_busid_modesetting(struct drm_device *dev, 1075 struct sysctl_ctx_list *ctx, struct sysctl_oid *top); 1076 1077 /* File operations helpers (drm_fops.c) */ 1078 extern int drm_open_helper(struct cdev *kdev, int flags, int fmt, 1079 DRM_STRUCTPROC *p, 1080 struct drm_device *dev, 1081 struct file *fp); 1082 1083 /* Misc. IOCTL support (drm_ioctl.c) */ 1084 int drm_noop(struct drm_device *dev, void *data, 1085 struct drm_file *file_priv); 1086 1087 /* Cache management (drm_cache.c) */ 1088 void drm_clflush_pages(struct vm_page *pages[], unsigned long num_pages); 1089 void drm_clflush_sg(struct sg_table *st); 1090 void drm_clflush_virt_range(void *addr, unsigned long length); 1091 1092 /* 1093 * These are exported to drivers so that they can implement fencing using 1094 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. 1095 */ 1096 1097 unsigned long drm_get_resource_start(struct drm_device *dev, 1098 unsigned int resource); 1099 unsigned long drm_get_resource_len(struct drm_device *dev, 1100 unsigned int resource); 1101 1102 /* IRQ support (drm_irq.h) */ 1103 extern int drm_irq_install(struct drm_device *dev, int irq); 1104 extern int drm_irq_uninstall(struct drm_device *dev); 1105 1106 extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs); 1107 extern int drm_wait_vblank(struct drm_device *dev, void *data, 1108 struct drm_file *filp); 1109 extern u32 drm_vblank_count(struct drm_device *dev, int pipe); 1110 extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc); 1111 extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe, 1112 struct timeval *vblanktime); 1113 extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe, 1114 struct drm_pending_vblank_event *e); 1115 extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc, 1116 struct drm_pending_vblank_event *e); 1117 extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe); 1118 extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc); 1119 extern int drm_vblank_get(struct drm_device *dev, unsigned int pipe); 1120 extern void drm_vblank_put(struct drm_device *dev, unsigned int pipe); 1121 extern int drm_crtc_vblank_get(struct drm_crtc *crtc); 1122 extern void drm_crtc_vblank_put(struct drm_crtc *crtc); 1123 extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe); 1124 extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc); 1125 extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe); 1126 extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe); 1127 extern void drm_crtc_vblank_off(struct drm_crtc *crtc); 1128 extern void drm_crtc_vblank_reset(struct drm_crtc *crtc); 1129 extern void drm_crtc_vblank_on(struct drm_crtc *crtc); 1130 extern void drm_vblank_cleanup(struct drm_device *dev); 1131 1132 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, 1133 unsigned int pipe, int *max_error, 1134 struct timeval *vblank_time, 1135 unsigned flags, 1136 const struct drm_crtc *refcrtc, 1137 const struct drm_display_mode *mode); 1138 extern void drm_calc_timestamping_constants(struct drm_crtc *crtc, 1139 const struct drm_display_mode *mode); 1140 1141 /** 1142 * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC 1143 * @crtc: which CRTC's vblank waitqueue to retrieve 1144 * 1145 * This function returns a pointer to the vblank waitqueue for the CRTC. 1146 * Drivers can use this to implement vblank waits using wait_event() & co. 1147 */ 1148 static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc) 1149 { 1150 return &crtc->dev->vblank[drm_crtc_index(crtc)].queue; 1151 } 1152 1153 /* Modesetting support */ 1154 extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe); 1155 extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe); 1156 1157 /* Stub support (drm_stub.h) */ 1158 1159 extern void drm_put_dev(struct drm_device *dev); 1160 extern void drm_unplug_dev(struct drm_device *dev); 1161 extern unsigned int drm_debug; 1162 extern bool drm_atomic; 1163 1164 /* consistent PCI memory functions (drm_pci.c) */ 1165 extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, 1166 size_t align); 1167 extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah); 1168 1169 /* sysfs support (drm_sysfs.c) */ 1170 extern void drm_sysfs_hotplug_event(struct drm_device *dev); 1171 1172 /* sysctl support (drm_sysctl.h) */ 1173 extern int drm_sysctl_init(struct drm_device *dev); 1174 extern int drm_sysctl_cleanup(struct drm_device *dev); 1175 1176 /* XXX: These are here only because of drm_sysctl.c */ 1177 extern int drm_vblank_offdelay; 1178 extern unsigned int drm_timestamp_precision; 1179 1180 int drm_gem_mmap_single(struct drm_device *dev, vm_ooffset_t *offset, 1181 vm_size_t size, struct vm_object **obj_res, int nprot); 1182 1183 struct ttm_bo_device; 1184 int ttm_bo_mmap_single(struct ttm_bo_device *bdev, vm_ooffset_t *offset, 1185 vm_size_t size, struct vm_object **obj_res, int nprot); 1186 struct ttm_buffer_object; 1187 void ttm_bo_release_mmap(struct ttm_buffer_object *bo); 1188 1189 /* simplified version of kvasnrprintf() for drm needs. */ 1190 char *drm_vasprintf(int flags, const char *format, __va_list ap) __printflike(2, 0); 1191 char *drm_asprintf(int flags, const char *format, ...) __printflike(2, 3); 1192 1193 /* XXX glue logic, should be done in drm_pci_init(), pending drm update */ 1194 void drm_init_pdev(struct device *dev, struct pci_dev **pdev); 1195 void drm_fini_pdev(struct pci_dev **pdev); 1196 void drm_print_pdev(struct pci_dev *pdev); 1197 1198 /* Inline drm_free() helper for area kfree() */ 1199 static __inline__ void 1200 drm_free(void *pt, struct malloc_type *area) 1201 { 1202 /* kfree is special!!! */ 1203 if (pt != NULL) 1204 (kfree)(pt, area); 1205 } 1206 1207 struct drm_device *drm_dev_alloc(struct drm_driver *driver, 1208 struct device *parent); 1209 void drm_dev_ref(struct drm_device *dev); 1210 void drm_dev_unref(struct drm_device *dev); 1211 int drm_dev_register(struct drm_device *dev, unsigned long flags); 1212 void drm_dev_unregister(struct drm_device *dev); 1213 int drm_dev_set_unique(struct drm_device *dev, const char *fmt, ...); 1214 1215 1216 /* PCI section */ 1217 static __inline__ int drm_pci_device_is_agp(struct drm_device *dev) 1218 { 1219 if (dev->driver->device_is_agp != NULL) { 1220 int err = (*dev->driver->device_is_agp) (dev); 1221 1222 if (err != 2) { 1223 return err; 1224 } 1225 } 1226 1227 return (pci_find_extcap(dev->dev, PCIY_AGP, NULL) == 0); 1228 } 1229 1230 #define DRM_PCIE_SPEED_25 1 1231 #define DRM_PCIE_SPEED_50 2 1232 #define DRM_PCIE_SPEED_80 4 1233 1234 extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); 1235 1236 /* XXX bad */ 1237 #define drm_can_sleep() (HZ & 1) 1238 1239 #endif /* __KERNEL__ */ 1240 #endif /* _DRM_P_H_ */ 1241