drmP.h 36 KB

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