drmP.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  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. * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  10. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  11. * All rights reserved.
  12. *
  13. * Permission is hereby granted, free of charge, to any person obtaining a
  14. * copy of this software and associated documentation files (the "Software"),
  15. * to deal in the Software without restriction, including without limitation
  16. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  17. * and/or sell copies of the Software, and to permit persons to whom the
  18. * Software is furnished to do so, subject to the following conditions:
  19. *
  20. * The above copyright notice and this permission notice (including the next
  21. * paragraph) shall be included in all copies or substantial portions of the
  22. * Software.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  27. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  28. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  29. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  30. * OTHER DEALINGS IN THE SOFTWARE.
  31. */
  32. #ifndef _DRM_P_H_
  33. #define _DRM_P_H_
  34. /* If you want the memory alloc debug functionality, change define below */
  35. /* #define DEBUG_MEMORY */
  36. #ifdef __KERNEL__
  37. #ifdef __alpha__
  38. /* add include of current.h so that "current" is defined
  39. * before static inline funcs in wait.h. Doing this so we
  40. * can build the DRM (part of PI DRI). 4/21/2000 S + B */
  41. #include <asm/current.h>
  42. #endif /* __alpha__ */
  43. #include <linux/config.h>
  44. #include <linux/module.h>
  45. #include <linux/kernel.h>
  46. #include <linux/miscdevice.h>
  47. #include <linux/fs.h>
  48. #include <linux/proc_fs.h>
  49. #include <linux/init.h>
  50. #include <linux/file.h>
  51. #include <linux/pci.h>
  52. #include <linux/jiffies.h>
  53. #include <linux/smp_lock.h> /* For (un)lock_kernel */
  54. #include <linux/mm.h>
  55. #include <linux/cdev.h>
  56. #include <linux/mutex.h>
  57. #if defined(__alpha__) || defined(__powerpc__)
  58. #include <asm/pgtable.h> /* For pte_wrprotect */
  59. #endif
  60. #include <asm/io.h>
  61. #include <asm/mman.h>
  62. #include <asm/uaccess.h>
  63. #ifdef CONFIG_MTRR
  64. #include <asm/mtrr.h>
  65. #endif
  66. #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
  67. #include <linux/types.h>
  68. #include <linux/agp_backend.h>
  69. #endif
  70. #include <linux/workqueue.h>
  71. #include <linux/poll.h>
  72. #include <asm/pgalloc.h>
  73. #include "drm.h"
  74. #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
  75. #define __OS_HAS_MTRR (defined(CONFIG_MTRR))
  76. #include "drm_os_linux.h"
  77. /***********************************************************************/
  78. /** \name DRM template customization defaults */
  79. /*@{*/
  80. /* driver capabilities and requirements mask */
  81. #define DRIVER_USE_AGP 0x1
  82. #define DRIVER_REQUIRE_AGP 0x2
  83. #define DRIVER_USE_MTRR 0x4
  84. #define DRIVER_PCI_DMA 0x8
  85. #define DRIVER_SG 0x10
  86. #define DRIVER_HAVE_DMA 0x20
  87. #define DRIVER_HAVE_IRQ 0x40
  88. #define DRIVER_IRQ_SHARED 0x80
  89. #define DRIVER_IRQ_VBL 0x100
  90. #define DRIVER_DMA_QUEUE 0x200
  91. #define DRIVER_FB_DMA 0x400
  92. /***********************************************************************/
  93. /** \name Begin the DRM... */
  94. /*@{*/
  95. #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then
  96. also include looping detection. */
  97. #define DRM_HASH_SIZE 16 /**< Size of key hash table. Must be power of 2. */
  98. #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */
  99. #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */
  100. #define DRM_LOOPING_LIMIT 5000000
  101. #define DRM_TIME_SLICE (HZ/20) /**< Time slice for GLXContexts */
  102. #define DRM_LOCK_SLICE 1 /**< Time slice for lock, in jiffies */
  103. #define DRM_FLAG_DEBUG 0x01
  104. #define DRM_MEM_DMA 0
  105. #define DRM_MEM_SAREA 1
  106. #define DRM_MEM_DRIVER 2
  107. #define DRM_MEM_MAGIC 3
  108. #define DRM_MEM_IOCTLS 4
  109. #define DRM_MEM_MAPS 5
  110. #define DRM_MEM_VMAS 6
  111. #define DRM_MEM_BUFS 7
  112. #define DRM_MEM_SEGS 8
  113. #define DRM_MEM_PAGES 9
  114. #define DRM_MEM_FILES 10
  115. #define DRM_MEM_QUEUES 11
  116. #define DRM_MEM_CMDS 12
  117. #define DRM_MEM_MAPPINGS 13
  118. #define DRM_MEM_BUFLISTS 14
  119. #define DRM_MEM_AGPLISTS 15
  120. #define DRM_MEM_TOTALAGP 16
  121. #define DRM_MEM_BOUNDAGP 17
  122. #define DRM_MEM_CTXBITMAP 18
  123. #define DRM_MEM_STUB 19
  124. #define DRM_MEM_SGLISTS 20
  125. #define DRM_MEM_CTXLIST 21
  126. #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
  127. /*@}*/
  128. /***********************************************************************/
  129. /** \name Backward compatibility section */
  130. /*@{*/
  131. #define DRM_RPR_ARG(vma) vma,
  132. #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
  133. /*@}*/
  134. /***********************************************************************/
  135. /** \name Macros to make printk easier */
  136. /*@{*/
  137. /**
  138. * Error output.
  139. *
  140. * \param fmt printf() like format string.
  141. * \param arg arguments
  142. */
  143. #define DRM_ERROR(fmt, arg...) \
  144. printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg)
  145. /**
  146. * Memory error output.
  147. *
  148. * \param area memory area where the error occurred.
  149. * \param fmt printf() like format string.
  150. * \param arg arguments
  151. */
  152. #define DRM_MEM_ERROR(area, fmt, arg...) \
  153. printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \
  154. drm_mem_stats[area].name , ##arg)
  155. #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
  156. /**
  157. * Debug output.
  158. *
  159. * \param fmt printf() like format string.
  160. * \param arg arguments
  161. */
  162. #if DRM_DEBUG_CODE
  163. #define DRM_DEBUG(fmt, arg...) \
  164. do { \
  165. if ( drm_debug ) \
  166. printk(KERN_DEBUG \
  167. "[" DRM_NAME ":%s] " fmt , \
  168. __FUNCTION__ , ##arg); \
  169. } while (0)
  170. #else
  171. #define DRM_DEBUG(fmt, arg...) do { } while (0)
  172. #endif
  173. #define DRM_PROC_LIMIT (PAGE_SIZE-80)
  174. #define DRM_PROC_PRINT(fmt, arg...) \
  175. len += sprintf(&buf[len], fmt , ##arg); \
  176. if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }
  177. #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
  178. len += sprintf(&buf[len], fmt , ##arg); \
  179. if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
  180. /*@}*/
  181. /***********************************************************************/
  182. /** \name Internal types and structures */
  183. /*@{*/
  184. #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
  185. #define DRM_MIN(a,b) min(a,b)
  186. #define DRM_MAX(a,b) max(a,b)
  187. #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
  188. #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
  189. #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
  190. #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
  191. /**
  192. * Get the private SAREA mapping.
  193. *
  194. * \param _dev DRM device.
  195. * \param _ctx context number.
  196. * \param _map output mapping.
  197. */
  198. #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
  199. (_map) = (_dev)->context_sareas[_ctx]; \
  200. } while(0)
  201. /**
  202. * Test that the hardware lock is held by the caller, returning otherwise.
  203. *
  204. * \param dev DRM device.
  205. * \param filp file pointer of the caller.
  206. */
  207. #define LOCK_TEST_WITH_RETURN( dev, filp ) \
  208. do { \
  209. if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
  210. dev->lock.filp != filp ) { \
  211. DRM_ERROR( "%s called without lock held\n", \
  212. __FUNCTION__ ); \
  213. return -EINVAL; \
  214. } \
  215. } while (0)
  216. /**
  217. * Copy and IOCTL return string to user space
  218. */
  219. #define DRM_COPY( name, value ) \
  220. len = strlen( value ); \
  221. if ( len > name##_len ) len = name##_len; \
  222. name##_len = strlen( value ); \
  223. if ( len && name ) { \
  224. if ( copy_to_user( name, value, len ) ) \
  225. return -EFAULT; \
  226. }
  227. /**
  228. * Ioctl function type.
  229. *
  230. * \param inode device inode.
  231. * \param filp file pointer.
  232. * \param cmd command.
  233. * \param arg argument.
  234. */
  235. typedef int drm_ioctl_t(struct inode *inode, struct file *filp,
  236. unsigned int cmd, unsigned long arg);
  237. typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
  238. unsigned long arg);
  239. #define DRM_AUTH 0x1
  240. #define DRM_MASTER 0x2
  241. #define DRM_ROOT_ONLY 0x4
  242. typedef struct drm_ioctl_desc {
  243. drm_ioctl_t *func;
  244. int flags;
  245. } drm_ioctl_desc_t;
  246. typedef struct drm_devstate {
  247. pid_t owner; /**< X server pid holding x_lock */
  248. } drm_devstate_t;
  249. typedef struct drm_magic_entry {
  250. drm_magic_t magic;
  251. struct drm_file *priv;
  252. struct drm_magic_entry *next;
  253. } drm_magic_entry_t;
  254. typedef struct drm_magic_head {
  255. struct drm_magic_entry *head;
  256. struct drm_magic_entry *tail;
  257. } drm_magic_head_t;
  258. typedef struct drm_vma_entry {
  259. struct vm_area_struct *vma;
  260. struct drm_vma_entry *next;
  261. pid_t pid;
  262. } drm_vma_entry_t;
  263. /**
  264. * DMA buffer.
  265. */
  266. typedef struct drm_buf {
  267. int idx; /**< Index into master buflist */
  268. int total; /**< Buffer size */
  269. int order; /**< log-base-2(total) */
  270. int used; /**< Amount of buffer in use (for DMA) */
  271. unsigned long offset; /**< Byte offset (used internally) */
  272. void *address; /**< Address of buffer */
  273. unsigned long bus_address; /**< Bus address of buffer */
  274. struct drm_buf *next; /**< Kernel-only: used for free list */
  275. __volatile__ int waiting; /**< On kernel DMA queue */
  276. __volatile__ int pending; /**< On hardware DMA queue */
  277. wait_queue_head_t dma_wait; /**< Processes waiting */
  278. struct file *filp; /**< Pointer to holding file descr */
  279. int context; /**< Kernel queue for this buffer */
  280. int while_locked; /**< Dispatch this buffer while locked */
  281. enum {
  282. DRM_LIST_NONE = 0,
  283. DRM_LIST_FREE = 1,
  284. DRM_LIST_WAIT = 2,
  285. DRM_LIST_PEND = 3,
  286. DRM_LIST_PRIO = 4,
  287. DRM_LIST_RECLAIM = 5
  288. } list; /**< Which list we're on */
  289. int dev_priv_size; /**< Size of buffer private storage */
  290. void *dev_private; /**< Per-buffer private storage */
  291. } drm_buf_t;
  292. /** bufs is one longer than it has to be */
  293. typedef struct drm_waitlist {
  294. int count; /**< Number of possible buffers */
  295. drm_buf_t **bufs; /**< List of pointers to buffers */
  296. drm_buf_t **rp; /**< Read pointer */
  297. drm_buf_t **wp; /**< Write pointer */
  298. drm_buf_t **end; /**< End pointer */
  299. spinlock_t read_lock;
  300. spinlock_t write_lock;
  301. } drm_waitlist_t;
  302. typedef struct drm_freelist {
  303. int initialized; /**< Freelist in use */
  304. atomic_t count; /**< Number of free buffers */
  305. drm_buf_t *next; /**< End pointer */
  306. wait_queue_head_t waiting; /**< Processes waiting on free bufs */
  307. int low_mark; /**< Low water mark */
  308. int high_mark; /**< High water mark */
  309. atomic_t wfh; /**< If waiting for high mark */
  310. spinlock_t lock;
  311. } drm_freelist_t;
  312. /**
  313. * Buffer entry. There is one of this for each buffer size order.
  314. */
  315. typedef struct drm_buf_entry {
  316. int buf_size; /**< size */
  317. int buf_count; /**< number of buffers */
  318. drm_buf_t *buflist; /**< buffer list */
  319. int seg_count;
  320. int page_order;
  321. unsigned long *seglist;
  322. drm_freelist_t freelist;
  323. } drm_buf_entry_t;
  324. /** File private data */
  325. typedef struct drm_file {
  326. int authenticated;
  327. int master;
  328. int minor;
  329. pid_t pid;
  330. uid_t uid;
  331. drm_magic_t magic;
  332. unsigned long ioctl_count;
  333. struct drm_file *next;
  334. struct drm_file *prev;
  335. struct drm_head *head;
  336. int remove_auth_on_close;
  337. unsigned long lock_count;
  338. void *driver_priv;
  339. } drm_file_t;
  340. /** Wait queue */
  341. typedef struct drm_queue {
  342. atomic_t use_count; /**< Outstanding uses (+1) */
  343. atomic_t finalization; /**< Finalization in progress */
  344. atomic_t block_count; /**< Count of processes waiting */
  345. atomic_t block_read; /**< Queue blocked for reads */
  346. wait_queue_head_t read_queue; /**< Processes waiting on block_read */
  347. atomic_t block_write; /**< Queue blocked for writes */
  348. wait_queue_head_t write_queue; /**< Processes waiting on block_write */
  349. #if 1
  350. atomic_t total_queued; /**< Total queued statistic */
  351. atomic_t total_flushed; /**< Total flushes statistic */
  352. atomic_t total_locks; /**< Total locks statistics */
  353. #endif
  354. drm_ctx_flags_t flags; /**< Context preserving and 2D-only */
  355. drm_waitlist_t waitlist; /**< Pending buffers */
  356. wait_queue_head_t flush_queue; /**< Processes waiting until flush */
  357. } drm_queue_t;
  358. /**
  359. * Lock data.
  360. */
  361. typedef struct drm_lock_data {
  362. drm_hw_lock_t *hw_lock; /**< Hardware lock */
  363. struct file *filp; /**< File descr of lock holder (0=kernel) */
  364. wait_queue_head_t lock_queue; /**< Queue of blocked processes */
  365. unsigned long lock_time; /**< Time of last lock in jiffies */
  366. } drm_lock_data_t;
  367. /**
  368. * DMA data.
  369. */
  370. typedef struct drm_device_dma {
  371. drm_buf_entry_t bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */
  372. int buf_count; /**< total number of buffers */
  373. drm_buf_t **buflist; /**< Vector of pointers into drm_device_dma::bufs */
  374. int seg_count;
  375. int page_count; /**< number of pages */
  376. unsigned long *pagelist; /**< page list */
  377. unsigned long byte_count;
  378. enum {
  379. _DRM_DMA_USE_AGP = 0x01,
  380. _DRM_DMA_USE_SG = 0x02,
  381. _DRM_DMA_USE_FB = 0x04
  382. } flags;
  383. } drm_device_dma_t;
  384. /**
  385. * AGP memory entry. Stored as a doubly linked list.
  386. */
  387. typedef struct drm_agp_mem {
  388. unsigned long handle; /**< handle */
  389. DRM_AGP_MEM *memory;
  390. unsigned long bound; /**< address */
  391. int pages;
  392. struct drm_agp_mem *prev; /**< previous entry */
  393. struct drm_agp_mem *next; /**< next entry */
  394. } drm_agp_mem_t;
  395. /**
  396. * AGP data.
  397. *
  398. * \sa drm_agp_init() and drm_device::agp.
  399. */
  400. typedef struct drm_agp_head {
  401. DRM_AGP_KERN agp_info; /**< AGP device information */
  402. drm_agp_mem_t *memory; /**< memory entries */
  403. unsigned long mode; /**< AGP mode */
  404. struct agp_bridge_data *bridge;
  405. int enabled; /**< whether the AGP bus as been enabled */
  406. int acquired; /**< whether the AGP device has been acquired */
  407. unsigned long base;
  408. int agp_mtrr;
  409. int cant_use_aperture;
  410. unsigned long page_mask;
  411. } drm_agp_head_t;
  412. /**
  413. * Scatter-gather memory.
  414. */
  415. typedef struct drm_sg_mem {
  416. unsigned long handle;
  417. void *virtual;
  418. int pages;
  419. struct page **pagelist;
  420. dma_addr_t *busaddr;
  421. } drm_sg_mem_t;
  422. typedef struct drm_sigdata {
  423. int context;
  424. drm_hw_lock_t *lock;
  425. } drm_sigdata_t;
  426. typedef struct drm_dma_handle {
  427. dma_addr_t busaddr;
  428. void *vaddr;
  429. size_t size;
  430. } drm_dma_handle_t;
  431. /**
  432. * Mappings list
  433. */
  434. typedef struct drm_map_list {
  435. struct list_head head; /**< list head */
  436. drm_map_t *map; /**< mapping */
  437. unsigned int user_token;
  438. } drm_map_list_t;
  439. typedef drm_map_t drm_local_map_t;
  440. /**
  441. * Context handle list
  442. */
  443. typedef struct drm_ctx_list {
  444. struct list_head head; /**< list head */
  445. drm_context_t handle; /**< context handle */
  446. drm_file_t *tag; /**< associated fd private data */
  447. } drm_ctx_list_t;
  448. typedef struct drm_vbl_sig {
  449. struct list_head head;
  450. unsigned int sequence;
  451. struct siginfo info;
  452. struct task_struct *task;
  453. } drm_vbl_sig_t;
  454. /* location of GART table */
  455. #define DRM_ATI_GART_MAIN 1
  456. #define DRM_ATI_GART_FB 2
  457. typedef struct ati_pcigart_info {
  458. int gart_table_location;
  459. int is_pcie;
  460. void *addr;
  461. dma_addr_t bus_addr;
  462. drm_local_map_t mapping;
  463. } drm_ati_pcigart_info;
  464. /**
  465. * DRM driver structure. This structure represent the common code for
  466. * a family of cards. There will one drm_device for each card present
  467. * in this family
  468. */
  469. struct drm_device;
  470. struct drm_driver {
  471. int (*load) (struct drm_device *, unsigned long flags);
  472. int (*firstopen) (struct drm_device *);
  473. int (*open) (struct drm_device *, drm_file_t *);
  474. void (*preclose) (struct drm_device *, struct file * filp);
  475. void (*postclose) (struct drm_device *, drm_file_t *);
  476. void (*lastclose) (struct drm_device *);
  477. int (*unload) (struct drm_device *);
  478. int (*dma_ioctl) (DRM_IOCTL_ARGS);
  479. void (*dma_ready) (struct drm_device *);
  480. int (*dma_quiescent) (struct drm_device *);
  481. int (*context_ctor) (struct drm_device * dev, int context);
  482. int (*context_dtor) (struct drm_device * dev, int context);
  483. int (*kernel_context_switch) (struct drm_device * dev, int old,
  484. int new);
  485. void (*kernel_context_switch_unlock) (struct drm_device * dev,
  486. drm_lock_t *lock);
  487. int (*vblank_wait) (struct drm_device * dev, unsigned int *sequence);
  488. int (*dri_library_name) (struct drm_device *dev, char *buf);
  489. /**
  490. * Called by \c drm_device_is_agp. Typically used to determine if a
  491. * card is really attached to AGP or not.
  492. *
  493. * \param dev DRM device handle
  494. *
  495. * \returns
  496. * One of three values is returned depending on whether or not the
  497. * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
  498. * (return of 1), or may or may not be AGP (return of 2).
  499. */
  500. int (*device_is_agp) (struct drm_device * dev);
  501. /* these have to be filled in */
  502. irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
  503. void (*irq_preinstall) (struct drm_device * dev);
  504. void (*irq_postinstall) (struct drm_device * dev);
  505. void (*irq_uninstall) (struct drm_device * dev);
  506. void (*reclaim_buffers) (struct drm_device * dev, struct file * filp);
  507. void (*reclaim_buffers_locked) (struct drm_device *dev,
  508. struct file *filp);
  509. unsigned long (*get_map_ofs) (drm_map_t * map);
  510. unsigned long (*get_reg_ofs) (struct drm_device * dev);
  511. void (*set_version) (struct drm_device * dev, drm_set_version_t * sv);
  512. int major;
  513. int minor;
  514. int patchlevel;
  515. char *name;
  516. char *desc;
  517. char *date;
  518. u32 driver_features;
  519. int dev_priv_size;
  520. drm_ioctl_desc_t *ioctls;
  521. int num_ioctls;
  522. struct file_operations fops;
  523. struct pci_driver pci_driver;
  524. };
  525. /**
  526. * DRM head structure. This structure represent a video head on a card
  527. * that may contain multiple heads. Embed one per head of these in the
  528. * private drm_device structure.
  529. */
  530. typedef struct drm_head {
  531. int minor; /**< Minor device number */
  532. struct drm_device *dev;
  533. struct proc_dir_entry *dev_root; /**< proc directory entry */
  534. dev_t device; /**< Device number for mknod */
  535. struct class_device *dev_class;
  536. } drm_head_t;
  537. /**
  538. * DRM device structure. This structure represent a complete card that
  539. * may contain multiple heads.
  540. */
  541. typedef struct drm_device {
  542. char *unique; /**< Unique identifier: e.g., busid */
  543. int unique_len; /**< Length of unique field */
  544. char *devname; /**< For /proc/interrupts */
  545. int if_version; /**< Highest interface version set */
  546. int blocked; /**< Blocked due to VC switch? */
  547. /** \name Locks */
  548. /*@{ */
  549. spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
  550. struct mutex struct_mutex; /**< For others */
  551. /*@} */
  552. /** \name Usage Counters */
  553. /*@{ */
  554. int open_count; /**< Outstanding files open */
  555. atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
  556. atomic_t vma_count; /**< Outstanding vma areas open */
  557. int buf_use; /**< Buffers in use -- cannot alloc */
  558. atomic_t buf_alloc; /**< Buffer allocation in progress */
  559. /*@} */
  560. /** \name Performance counters */
  561. /*@{ */
  562. unsigned long counters;
  563. drm_stat_type_t types[15];
  564. atomic_t counts[15];
  565. /*@} */
  566. /** \name Authentication */
  567. /*@{ */
  568. drm_file_t *file_first; /**< file list head */
  569. drm_file_t *file_last; /**< file list tail */
  570. drm_magic_head_t magiclist[DRM_HASH_SIZE]; /**< magic hash table */
  571. /*@} */
  572. /** \name Memory management */
  573. /*@{ */
  574. drm_map_list_t *maplist; /**< Linked list of regions */
  575. int map_count; /**< Number of mappable regions */
  576. /** \name Context handle management */
  577. /*@{ */
  578. drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
  579. int ctx_count; /**< Number of context handles */
  580. struct mutex ctxlist_mutex; /**< For ctxlist */
  581. drm_map_t **context_sareas; /**< per-context SAREA's */
  582. int max_context;
  583. drm_vma_entry_t *vmalist; /**< List of vmas (for debugging) */
  584. drm_lock_data_t lock; /**< Information on hardware lock */
  585. /*@} */
  586. /** \name DMA queues (contexts) */
  587. /*@{ */
  588. int queue_count; /**< Number of active DMA queues */
  589. int queue_reserved; /**< Number of reserved DMA queues */
  590. int queue_slots; /**< Actual length of queuelist */
  591. drm_queue_t **queuelist; /**< Vector of pointers to DMA queues */
  592. drm_device_dma_t *dma; /**< Optional pointer for DMA support */
  593. /*@} */
  594. /** \name Context support */
  595. /*@{ */
  596. int irq; /**< Interrupt used by board */
  597. int irq_enabled; /**< True if irq handler is enabled */
  598. __volatile__ long context_flag; /**< Context swapping flag */
  599. __volatile__ long interrupt_flag; /**< Interruption handler flag */
  600. __volatile__ long dma_flag; /**< DMA dispatch flag */
  601. struct timer_list timer; /**< Timer for delaying ctx switch */
  602. wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
  603. int last_checked; /**< Last context checked for DMA */
  604. int last_context; /**< Last current context */
  605. unsigned long last_switch; /**< jiffies at last context switch */
  606. /*@} */
  607. struct work_struct work;
  608. /** \name VBLANK IRQ support */
  609. /*@{ */
  610. wait_queue_head_t vbl_queue; /**< VBLANK wait queue */
  611. atomic_t vbl_received;
  612. spinlock_t vbl_lock;
  613. drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */
  614. unsigned int vbl_pending;
  615. /*@} */
  616. cycles_t ctx_start;
  617. cycles_t lck_start;
  618. struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
  619. wait_queue_head_t buf_readers; /**< Processes waiting to read */
  620. wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
  621. drm_agp_head_t *agp; /**< AGP data */
  622. struct pci_dev *pdev; /**< PCI device structure */
  623. int pci_domain; /**< PCI bus domain number */
  624. int pci_bus; /**< PCI bus number */
  625. int pci_slot; /**< PCI slot number */
  626. int pci_func; /**< PCI function number */
  627. #ifdef __alpha__
  628. struct pci_controller *hose;
  629. #endif
  630. drm_sg_mem_t *sg; /**< Scatter gather memory */
  631. unsigned long *ctx_bitmap; /**< context bitmap */
  632. void *dev_private; /**< device private data */
  633. drm_sigdata_t sigdata; /**< For block_all_signals */
  634. sigset_t sigmask;
  635. struct drm_driver *driver;
  636. drm_local_map_t *agp_buffer_map;
  637. unsigned int agp_buffer_token;
  638. drm_head_t primary; /**< primary screen head */
  639. } drm_device_t;
  640. static __inline__ int drm_core_check_feature(struct drm_device *dev,
  641. int feature)
  642. {
  643. return ((dev->driver->driver_features & feature) ? 1 : 0);
  644. }
  645. #if __OS_HAS_AGP
  646. static inline int drm_core_has_AGP(struct drm_device *dev)
  647. {
  648. return drm_core_check_feature(dev, DRIVER_USE_AGP);
  649. }
  650. #else
  651. #define drm_core_has_AGP(dev) (0)
  652. #endif
  653. #if __OS_HAS_MTRR
  654. static inline int drm_core_has_MTRR(struct drm_device *dev)
  655. {
  656. return drm_core_check_feature(dev, DRIVER_USE_MTRR);
  657. }
  658. #define DRM_MTRR_WC MTRR_TYPE_WRCOMB
  659. static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
  660. unsigned int flags)
  661. {
  662. return mtrr_add(offset, size, flags, 1);
  663. }
  664. static inline int drm_mtrr_del(int handle, unsigned long offset,
  665. unsigned long size, unsigned int flags)
  666. {
  667. return mtrr_del(handle, offset, size);
  668. }
  669. #else
  670. #define drm_core_has_MTRR(dev) (0)
  671. #define DRM_MTRR_WC 0
  672. static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
  673. unsigned int flags)
  674. {
  675. return 0;
  676. }
  677. static inline int drm_mtrr_del(int handle, unsigned long offset,
  678. unsigned long size, unsigned int flags)
  679. {
  680. return 0;
  681. }
  682. #endif
  683. /******************************************************************/
  684. /** \name Internal function definitions */
  685. /*@{*/
  686. /* Driver support (drm_drv.h) */
  687. extern int drm_init(struct drm_driver *driver);
  688. extern void drm_exit(struct drm_driver *driver);
  689. extern int drm_ioctl(struct inode *inode, struct file *filp,
  690. unsigned int cmd, unsigned long arg);
  691. extern long drm_compat_ioctl(struct file *filp,
  692. unsigned int cmd, unsigned long arg);
  693. extern int drm_lastclose(drm_device_t *dev);
  694. /* Device support (drm_fops.h) */
  695. extern int drm_open(struct inode *inode, struct file *filp);
  696. extern int drm_stub_open(struct inode *inode, struct file *filp);
  697. extern int drm_fasync(int fd, struct file *filp, int on);
  698. extern int drm_release(struct inode *inode, struct file *filp);
  699. /* Mapping support (drm_vm.h) */
  700. extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
  701. extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
  702. /* Memory management support (drm_memory.h) */
  703. #include "drm_memory.h"
  704. extern void drm_mem_init(void);
  705. extern int drm_mem_info(char *buf, char **start, off_t offset,
  706. int request, int *eof, void *data);
  707. extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
  708. extern unsigned long drm_alloc_pages(int order, int area);
  709. extern void drm_free_pages(unsigned long address, int order, int area);
  710. extern void *drm_ioremap(unsigned long offset, unsigned long size,
  711. drm_device_t * dev);
  712. extern void *drm_ioremap_nocache(unsigned long offset, unsigned long size,
  713. drm_device_t * dev);
  714. extern void drm_ioremapfree(void *pt, unsigned long size, drm_device_t * dev);
  715. extern DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type);
  716. extern int drm_free_agp(DRM_AGP_MEM * handle, int pages);
  717. extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
  718. extern int drm_unbind_agp(DRM_AGP_MEM * handle);
  719. /* Misc. IOCTL support (drm_ioctl.h) */
  720. extern int drm_irq_by_busid(struct inode *inode, struct file *filp,
  721. unsigned int cmd, unsigned long arg);
  722. extern int drm_getunique(struct inode *inode, struct file *filp,
  723. unsigned int cmd, unsigned long arg);
  724. extern int drm_setunique(struct inode *inode, struct file *filp,
  725. unsigned int cmd, unsigned long arg);
  726. extern int drm_getmap(struct inode *inode, struct file *filp,
  727. unsigned int cmd, unsigned long arg);
  728. extern int drm_getclient(struct inode *inode, struct file *filp,
  729. unsigned int cmd, unsigned long arg);
  730. extern int drm_getstats(struct inode *inode, struct file *filp,
  731. unsigned int cmd, unsigned long arg);
  732. extern int drm_setversion(struct inode *inode, struct file *filp,
  733. unsigned int cmd, unsigned long arg);
  734. extern int drm_noop(struct inode *inode, struct file *filp,
  735. unsigned int cmd, unsigned long arg);
  736. /* Context IOCTL support (drm_context.h) */
  737. extern int drm_resctx(struct inode *inode, struct file *filp,
  738. unsigned int cmd, unsigned long arg);
  739. extern int drm_addctx(struct inode *inode, struct file *filp,
  740. unsigned int cmd, unsigned long arg);
  741. extern int drm_modctx(struct inode *inode, struct file *filp,
  742. unsigned int cmd, unsigned long arg);
  743. extern int drm_getctx(struct inode *inode, struct file *filp,
  744. unsigned int cmd, unsigned long arg);
  745. extern int drm_switchctx(struct inode *inode, struct file *filp,
  746. unsigned int cmd, unsigned long arg);
  747. extern int drm_newctx(struct inode *inode, struct file *filp,
  748. unsigned int cmd, unsigned long arg);
  749. extern int drm_rmctx(struct inode *inode, struct file *filp,
  750. unsigned int cmd, unsigned long arg);
  751. extern int drm_ctxbitmap_init(drm_device_t * dev);
  752. extern void drm_ctxbitmap_cleanup(drm_device_t * dev);
  753. extern void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle);
  754. extern int drm_setsareactx(struct inode *inode, struct file *filp,
  755. unsigned int cmd, unsigned long arg);
  756. extern int drm_getsareactx(struct inode *inode, struct file *filp,
  757. unsigned int cmd, unsigned long arg);
  758. /* Drawable IOCTL support (drm_drawable.h) */
  759. extern int drm_adddraw(struct inode *inode, struct file *filp,
  760. unsigned int cmd, unsigned long arg);
  761. extern int drm_rmdraw(struct inode *inode, struct file *filp,
  762. unsigned int cmd, unsigned long arg);
  763. /* Authentication IOCTL support (drm_auth.h) */
  764. extern int drm_getmagic(struct inode *inode, struct file *filp,
  765. unsigned int cmd, unsigned long arg);
  766. extern int drm_authmagic(struct inode *inode, struct file *filp,
  767. unsigned int cmd, unsigned long arg);
  768. /* Locking IOCTL support (drm_lock.h) */
  769. extern int drm_lock(struct inode *inode, struct file *filp,
  770. unsigned int cmd, unsigned long arg);
  771. extern int drm_unlock(struct inode *inode, struct file *filp,
  772. unsigned int cmd, unsigned long arg);
  773. extern int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context);
  774. extern int drm_lock_free(drm_device_t * dev,
  775. __volatile__ unsigned int *lock, unsigned int context);
  776. /* Buffer management support (drm_bufs.h) */
  777. extern int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request);
  778. extern int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request);
  779. extern int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request);
  780. extern int drm_addmap(drm_device_t * dev, unsigned int offset,
  781. unsigned int size, drm_map_type_t type,
  782. drm_map_flags_t flags, drm_local_map_t ** map_ptr);
  783. extern int drm_addmap_ioctl(struct inode *inode, struct file *filp,
  784. unsigned int cmd, unsigned long arg);
  785. extern int drm_rmmap(drm_device_t * dev, drm_local_map_t * map);
  786. extern int drm_rmmap_locked(drm_device_t * dev, drm_local_map_t * map);
  787. extern int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
  788. unsigned int cmd, unsigned long arg);
  789. extern int drm_order(unsigned long size);
  790. extern int drm_addbufs(struct inode *inode, struct file *filp,
  791. unsigned int cmd, unsigned long arg);
  792. extern int drm_infobufs(struct inode *inode, struct file *filp,
  793. unsigned int cmd, unsigned long arg);
  794. extern int drm_markbufs(struct inode *inode, struct file *filp,
  795. unsigned int cmd, unsigned long arg);
  796. extern int drm_freebufs(struct inode *inode, struct file *filp,
  797. unsigned int cmd, unsigned long arg);
  798. extern int drm_mapbufs(struct inode *inode, struct file *filp,
  799. unsigned int cmd, unsigned long arg);
  800. extern unsigned long drm_get_resource_start(drm_device_t * dev,
  801. unsigned int resource);
  802. extern unsigned long drm_get_resource_len(drm_device_t * dev,
  803. unsigned int resource);
  804. /* DMA support (drm_dma.h) */
  805. extern int drm_dma_setup(drm_device_t * dev);
  806. extern void drm_dma_takedown(drm_device_t * dev);
  807. extern void drm_free_buffer(drm_device_t * dev, drm_buf_t * buf);
  808. extern void drm_core_reclaim_buffers(drm_device_t * dev, struct file *filp);
  809. /* IRQ support (drm_irq.h) */
  810. extern int drm_control(struct inode *inode, struct file *filp,
  811. unsigned int cmd, unsigned long arg);
  812. extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
  813. extern int drm_irq_uninstall(drm_device_t * dev);
  814. extern void drm_driver_irq_preinstall(drm_device_t * dev);
  815. extern void drm_driver_irq_postinstall(drm_device_t * dev);
  816. extern void drm_driver_irq_uninstall(drm_device_t * dev);
  817. extern int drm_wait_vblank(struct inode *inode, struct file *filp,
  818. unsigned int cmd, unsigned long arg);
  819. extern int drm_vblank_wait(drm_device_t * dev, unsigned int *vbl_seq);
  820. extern void drm_vbl_send_signals(drm_device_t * dev);
  821. /* AGP/GART support (drm_agpsupport.h) */
  822. extern drm_agp_head_t *drm_agp_init(drm_device_t * dev);
  823. extern int drm_agp_acquire(drm_device_t * dev);
  824. extern int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp,
  825. unsigned int cmd, unsigned long arg);
  826. extern int drm_agp_release(drm_device_t * dev);
  827. extern int drm_agp_release_ioctl(struct inode *inode, struct file *filp,
  828. unsigned int cmd, unsigned long arg);
  829. extern int drm_agp_enable(drm_device_t * dev, drm_agp_mode_t mode);
  830. extern int drm_agp_enable_ioctl(struct inode *inode, struct file *filp,
  831. unsigned int cmd, unsigned long arg);
  832. extern int drm_agp_info(drm_device_t * dev, drm_agp_info_t * info);
  833. extern int drm_agp_info_ioctl(struct inode *inode, struct file *filp,
  834. unsigned int cmd, unsigned long arg);
  835. extern int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request);
  836. extern int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp,
  837. unsigned int cmd, unsigned long arg);
  838. extern int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request);
  839. extern int drm_agp_free_ioctl(struct inode *inode, struct file *filp,
  840. unsigned int cmd, unsigned long arg);
  841. extern int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request);
  842. extern int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp,
  843. unsigned int cmd, unsigned long arg);
  844. extern int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request);
  845. extern int drm_agp_bind_ioctl(struct inode *inode, struct file *filp,
  846. unsigned int cmd, unsigned long arg);
  847. extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge,
  848. size_t pages, u32 type);
  849. extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
  850. extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
  851. extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
  852. /* Stub support (drm_stub.h) */
  853. extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
  854. struct drm_driver *driver);
  855. extern int drm_put_dev(drm_device_t * dev);
  856. extern int drm_put_head(drm_head_t * head);
  857. extern unsigned int drm_debug;
  858. extern unsigned int drm_cards_limit;
  859. extern drm_head_t **drm_heads;
  860. extern struct drm_sysfs_class *drm_class;
  861. extern struct proc_dir_entry *drm_proc_root;
  862. /* Proc support (drm_proc.h) */
  863. extern int drm_proc_init(drm_device_t * dev,
  864. int minor,
  865. struct proc_dir_entry *root,
  866. struct proc_dir_entry **dev_root);
  867. extern int drm_proc_cleanup(int minor,
  868. struct proc_dir_entry *root,
  869. struct proc_dir_entry *dev_root);
  870. /* Scatter Gather Support (drm_scatter.h) */
  871. extern void drm_sg_cleanup(drm_sg_mem_t * entry);
  872. extern int drm_sg_alloc(struct inode *inode, struct file *filp,
  873. unsigned int cmd, unsigned long arg);
  874. extern int drm_sg_free(struct inode *inode, struct file *filp,
  875. unsigned int cmd, unsigned long arg);
  876. /* ATI PCIGART support (ati_pcigart.h) */
  877. extern int drm_ati_pcigart_init(drm_device_t * dev,
  878. drm_ati_pcigart_info * gart_info);
  879. extern int drm_ati_pcigart_cleanup(drm_device_t * dev,
  880. drm_ati_pcigart_info * gart_info);
  881. extern drm_dma_handle_t *drm_pci_alloc(drm_device_t * dev, size_t size,
  882. size_t align, dma_addr_t maxaddr);
  883. extern void __drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah);
  884. extern void drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah);
  885. /* sysfs support (drm_sysfs.c) */
  886. struct drm_sysfs_class;
  887. extern struct drm_sysfs_class *drm_sysfs_create(struct module *owner,
  888. char *name);
  889. extern void drm_sysfs_destroy(struct drm_sysfs_class *cs);
  890. extern struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
  891. drm_head_t *head);
  892. extern void drm_sysfs_device_remove(struct class_device *class_dev);
  893. /* Inline replacements for DRM_IOREMAP macros */
  894. static __inline__ void drm_core_ioremap(struct drm_map *map,
  895. struct drm_device *dev)
  896. {
  897. map->handle = drm_ioremap(map->offset, map->size, dev);
  898. }
  899. static __inline__ void drm_core_ioremap_nocache(struct drm_map *map,
  900. struct drm_device *dev)
  901. {
  902. map->handle = drm_ioremap_nocache(map->offset, map->size, dev);
  903. }
  904. static __inline__ void drm_core_ioremapfree(struct drm_map *map,
  905. struct drm_device *dev)
  906. {
  907. if (map->handle && map->size)
  908. drm_ioremapfree(map->handle, map->size, dev);
  909. }
  910. static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev,
  911. unsigned int token)
  912. {
  913. drm_map_list_t *_entry;
  914. list_for_each_entry(_entry, &dev->maplist->head, head)
  915. if (_entry->user_token == token)
  916. return _entry->map;
  917. return NULL;
  918. }
  919. static __inline__ int drm_device_is_agp(drm_device_t * dev)
  920. {
  921. if (dev->driver->device_is_agp != NULL) {
  922. int err = (*dev->driver->device_is_agp) (dev);
  923. if (err != 2) {
  924. return err;
  925. }
  926. }
  927. return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
  928. }
  929. static __inline__ int drm_device_is_pcie(drm_device_t * dev)
  930. {
  931. return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
  932. }
  933. static __inline__ void drm_core_dropmap(struct drm_map *map)
  934. {
  935. }
  936. #ifndef DEBUG_MEMORY
  937. /** Wrapper around kmalloc() */
  938. static __inline__ void *drm_alloc(size_t size, int area)
  939. {
  940. return kmalloc(size, GFP_KERNEL);
  941. }
  942. /** Wrapper around kfree() */
  943. static __inline__ void drm_free(void *pt, size_t size, int area)
  944. {
  945. kfree(pt);
  946. }
  947. /** Wrapper around kcalloc() */
  948. static __inline__ void *drm_calloc(size_t nmemb, size_t size, int area)
  949. {
  950. return kcalloc(nmemb, size, GFP_KERNEL);
  951. }
  952. #else
  953. extern void *drm_alloc(size_t size, int area);
  954. extern void drm_free(void *pt, size_t size, int area);
  955. extern void *drm_calloc(size_t nmemb, size_t size, int area);
  956. #endif
  957. /*@}*/
  958. extern unsigned long drm_core_get_map_ofs(drm_map_t * map);
  959. extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev);
  960. #ifndef pci_pretty_name
  961. #define pci_pretty_name(dev) ""
  962. #endif
  963. #endif /* __KERNEL__ */
  964. #endif