1 /* drm.h -- Header for Direct Rendering Manager -*- linux-c -*-
2 * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
3 * Revised: Mon Dec 6 17:11:19 1999 by faith@precisioninsight.com
5 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
27 * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h,v 1.46 1999/08/20 20:00:53 faith Exp $
28 * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h,v 1.2 1999/12/14 01:33:56 robin Exp $
31 * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg.
38 #include <asm/ioctl.h> /* For _IO* macros */
40 #define DRM_PROC_DEVICES "/proc/devices"
41 #define DRM_PROC_MISC "/proc/misc"
42 #define DRM_PROC_DRM "/proc/drm"
43 #define DRM_DEV_DRM "/dev/drm"
44 #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
49 #define DRM_NAME "drm" /* Name in kernel, /dev, and /proc */
50 #define DRM_MIN_ORDER 5 /* At least 2^5 bytes = 32 bytes */
51 #define DRM_MAX_ORDER 22 /* Up to 2^22 bytes = 4MB */
52 #define DRM_RAM_PERCENT 10 /* How much system ram can we lock? */
54 #define _DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */
55 #define _DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */
56 #define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
57 #define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
58 #define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
60 typedef unsigned long drm_handle_t;
61 typedef unsigned int drm_context_t;
62 typedef unsigned int drm_drawable_t;
63 typedef unsigned int drm_magic_t;
66 typedef struct drm_version {
67 int version_major; /* Major version */
68 int version_minor; /* Minor version */
69 int version_patchlevel;/* Patch level */
70 size_t name_len; /* Length of name buffer */
71 char *name; /* Name of driver */
72 size_t date_len; /* Length of date buffer */
73 char *date; /* User-space buffer to hold date */
74 size_t desc_len; /* Length of desc buffer */
75 char *desc; /* User-space buffer to hold desc */
78 typedef struct drm_unique {
79 size_t unique_len; /* Length of unique */
80 char *unique; /* Unique name for driver instantiation */
83 typedef struct drm_list {
84 int count; /* Length of user-space structures */
85 drm_version_t *version;
88 typedef struct drm_block {
92 typedef struct drm_control {
102 typedef enum drm_map_type {
103 _DRM_FRAME_BUFFER = 0, /* WC (no caching), no core dump */
104 _DRM_REGISTERS = 1, /* no caching, no core dump */
105 _DRM_SHM = 2 /* shared, cached */
108 typedef enum drm_map_flags {
109 _DRM_RESTRICTED = 0x01, /* Cannot be mapped to user-virtual */
110 _DRM_READ_ONLY = 0x02,
111 _DRM_LOCKED = 0x04, /* shared, cached, locked */
112 _DRM_KERNEL = 0x08, /* kernel requires access */
113 _DRM_WRITE_COMBINING = 0x10, /* use write-combining if available */
114 _DRM_CONTAINS_LOCK = 0x20 /* SHM page that contains lock */
117 typedef struct drm_map {
118 unsigned long offset; /* Requested physical address (0 for SAREA)*/
119 unsigned long size; /* Requested physical size (bytes) */
120 drm_map_type_t type; /* Type of memory to map */
121 drm_map_flags_t flags; /* Flags */
122 void *handle; /* User-space: "Handle" to pass to mmap */
123 /* Kernel-space: kernel-virtual address */
124 int mtrr; /* MTRR slot used */
128 typedef enum drm_lock_flags {
129 _DRM_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */
130 _DRM_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */
131 _DRM_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */
132 _DRM_LOCK_FLUSH_ALL = 0x08, /* Flush all DMA queues first */
133 /* These *HALT* flags aren't supported yet
134 -- they will be used to support the
135 full-screen DGA-like mode. */
136 _DRM_HALT_ALL_QUEUES = 0x10, /* Halt all current and future queues */
137 _DRM_HALT_CUR_QUEUES = 0x20 /* Halt all current queues */
140 typedef struct drm_lock {
142 drm_lock_flags_t flags;
145 typedef enum drm_dma_flags { /* These values *MUST* match xf86drm.h */
146 /* Flags for DMA buffer dispatch */
147 _DRM_DMA_BLOCK = 0x01, /* Block until buffer dispatched.
148 Note, the buffer may not yet have
149 been processed by the hardware --
150 getting a hardware lock with the
151 hardware quiescent will ensure
152 that the buffer has been
154 _DRM_DMA_WHILE_LOCKED = 0x02, /* Dispatch while lock held */
155 _DRM_DMA_PRIORITY = 0x04, /* High priority dispatch */
157 /* Flags for DMA buffer request */
158 _DRM_DMA_WAIT = 0x10, /* Wait for free buffers */
159 _DRM_DMA_SMALLER_OK = 0x20, /* Smaller-than-requested buffers ok */
160 _DRM_DMA_LARGER_OK = 0x40 /* Larger-than-requested buffers ok */
163 typedef struct drm_buf_desc {
164 int count; /* Number of buffers of this size */
165 int size; /* Size in bytes */
166 int low_mark; /* Low water mark */
167 int high_mark; /* High water mark */
169 DRM_PAGE_ALIGN = 0x01 /* Align on page boundaries for DMA */
173 typedef struct drm_buf_info {
174 int count; /* Entries in list */
175 drm_buf_desc_t *list;
178 typedef struct drm_buf_free {
183 typedef struct drm_buf_pub {
184 int idx; /* Index into master buflist */
185 int total; /* Buffer size */
186 int used; /* Amount of buffer in use (for DMA) */
187 void *address; /* Address of buffer */
190 typedef struct drm_buf_map {
191 int count; /* Length of buflist */
192 void *virtual; /* Mmaped area in user-virtual */
193 drm_buf_pub_t *list; /* Buffer information */
196 typedef struct drm_dma {
197 /* Indices here refer to the offset into
198 buflist in drm_buf_get_t. */
199 int context; /* Context handle */
200 int send_count; /* Number of buffers to send */
201 int *send_indices; /* List of handles to buffers */
202 int *send_sizes; /* Lengths of data to send */
203 drm_dma_flags_t flags; /* Flags */
204 int request_count; /* Number of buffers requested */
205 int request_size; /* Desired size for buffers */
206 int *request_indices; /* Buffer information */
208 int granted_count; /* Number of buffers granted */
212 _DRM_CONTEXT_PRESERVED = 0x01,
213 _DRM_CONTEXT_2DONLY = 0x02
216 typedef struct drm_ctx {
217 drm_context_t handle;
218 drm_ctx_flags_t flags;
221 typedef struct drm_ctx_res {
226 typedef struct drm_draw {
227 drm_drawable_t handle;
230 typedef struct drm_auth {
234 typedef struct drm_irq_busid {
241 #define DRM_IOCTL_BASE 'd'
242 #define DRM_IOCTL_NR(n) _IOC_NR(n)
243 #define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
244 #define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size)
245 #define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size)
246 #define DRM_IOWR(nr,size) _IOWR(DRM_IOCTL_BASE,nr,size)
249 #define DRM_IOCTL_VERSION DRM_IOWR(0x00, drm_version_t)
250 #define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm_unique_t)
251 #define DRM_IOCTL_GET_MAGIC DRM_IOW( 0x02, drm_auth_t)
252 #define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, drm_irq_busid_t)
254 #define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t)
255 #define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, drm_auth_t)
256 #define DRM_IOCTL_BLOCK DRM_IOWR(0x12, drm_block_t)
257 #define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, drm_block_t)
258 #define DRM_IOCTL_CONTROL DRM_IOW( 0x14, drm_control_t)
259 #define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, drm_map_t)
260 #define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, drm_buf_desc_t)
261 #define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, drm_buf_desc_t)
262 #define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm_buf_info_t)
263 #define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm_buf_map_t)
264 #define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm_buf_free_t)
266 #define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t)
267 #define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t)
268 #define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, drm_ctx_t)
269 #define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, drm_ctx_t)
270 #define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, drm_ctx_t)
271 #define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, drm_ctx_t)
272 #define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, drm_ctx_res_t)
273 #define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, drm_draw_t)
274 #define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, drm_draw_t)
275 #define DRM_IOCTL_DMA DRM_IOWR(0x29, drm_dma_t)
276 #define DRM_IOCTL_LOCK DRM_IOW( 0x2a, drm_lock_t)
277 #define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, drm_lock_t)
278 #define DRM_IOCTL_FINISH DRM_IOW( 0x2c, drm_lock_t)