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: Fri Aug 20 13:08:18 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/generic/drm.h,v 1.46 1999/08/20 20:00:53 faith Exp $
28 * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/generic/drm.h,v 1.2 1999/06/27 14:08:21 dawes Exp $
35 #include <asm/ioctl.h> /* For _IO* macros */
37 #define DRM_PROC_DEVICES "/proc/devices"
38 #define DRM_PROC_MISC "/proc/misc"
39 #define DRM_PROC_DRM "/proc/drm"
40 #define DRM_DEV_DRM "/dev/drm"
41 #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
46 #define DRM_NAME "drm" /* Name in kernel, /dev, and /proc */
47 #define DRM_MIN_ORDER 5 /* At least 2^5 bytes = 32 bytes */
48 #define DRM_MAX_ORDER 22 /* Up to 2^22 bytes = 4MB */
49 #define DRM_RAM_PERCENT 10 /* How much system ram can we lock? */
51 #define _DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */
52 #define _DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */
53 #define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
54 #define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
55 #define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
57 typedef unsigned long drm_handle_t
;
58 typedef unsigned int drm_context_t
;
59 typedef unsigned int drm_drawable_t
;
60 typedef unsigned int drm_magic_t
;
63 typedef struct drm_version
{
64 int version_major
; /* Major version */
65 int version_minor
; /* Minor version */
66 int version_patchlevel
;/* Patch level */
67 size_t name_len
; /* Length of name buffer */
68 char *name
; /* Name of driver */
69 size_t date_len
; /* Length of date buffer */
70 char *date
; /* User-space buffer to hold date */
71 size_t desc_len
; /* Length of desc buffer */
72 char *desc
; /* User-space buffer to hold desc */
75 typedef struct drm_unique
{
76 size_t unique_len
; /* Length of unique */
77 char *unique
; /* Unique name for driver instantiation */
80 typedef struct drm_list
{
81 int count
; /* Length of user-space structures */
82 drm_version_t
*version
;
85 typedef struct drm_block
{
89 typedef struct drm_control
{
99 typedef enum drm_map_type
{
100 _DRM_FRAME_BUFFER
= 0, /* WC (no caching), no core dump */
101 _DRM_REGISTERS
= 1, /* no caching, no core dump */
102 _DRM_SHM
= 2 /* shared, cached */
105 typedef enum drm_map_flags
{
106 _DRM_RESTRICTED
= 0x01, /* Cannot be mapped to user-virtual */
107 _DRM_READ_ONLY
= 0x02,
108 _DRM_LOCKED
= 0x04, /* shared, cached, locked */
109 _DRM_KERNEL
= 0x08, /* kernel requires access */
110 _DRM_WRITE_COMBINING
= 0x10, /* use write-combining if available */
111 _DRM_CONTAINS_LOCK
= 0x20 /* SHM page that contains lock */
114 typedef struct drm_map
{
115 unsigned long offset
; /* Requested physical address (0 for SAREA)*/
116 unsigned long size
; /* Requested physical size (bytes) */
117 drm_map_type_t type
; /* Type of memory to map */
118 drm_map_flags_t flags
; /* Flags */
119 void *handle
; /* User-space: "Handle" to pass to mmap */
120 /* Kernel-space: kernel-virtual address */
121 int mtrr
; /* MTRR slot used */
125 typedef enum drm_lock_flags
{
126 _DRM_LOCK_READY
= 0x01, /* Wait until hardware is ready for DMA */
127 _DRM_LOCK_QUIESCENT
= 0x02, /* Wait until hardware quiescent */
128 _DRM_LOCK_FLUSH
= 0x04, /* Flush this context's DMA queue first */
129 _DRM_LOCK_FLUSH_ALL
= 0x08, /* Flush all DMA queues first */
130 /* These *HALT* flags aren't supported yet
131 -- they will be used to support the
132 full-screen DGA-like mode. */
133 _DRM_HALT_ALL_QUEUES
= 0x10, /* Halt all current and future queues */
134 _DRM_HALT_CUR_QUEUES
= 0x20 /* Halt all current queues */
137 typedef struct drm_lock
{
139 drm_lock_flags_t flags
;
142 typedef enum drm_dma_flags
{ /* These values *MUST* match xf86drm.h */
143 /* Flags for DMA buffer dispatch */
144 _DRM_DMA_BLOCK
= 0x01, /* Block until buffer dispatched.
145 Note, the buffer may not yet have
146 been processed by the hardware --
147 getting a hardware lock with the
148 hardware quiescent will ensure
149 that the buffer has been
151 _DRM_DMA_WHILE_LOCKED
= 0x02, /* Dispatch while lock held */
152 _DRM_DMA_PRIORITY
= 0x04, /* High priority dispatch */
154 /* Flags for DMA buffer request */
155 _DRM_DMA_WAIT
= 0x10, /* Wait for free buffers */
156 _DRM_DMA_SMALLER_OK
= 0x20, /* Smaller-than-requested buffers ok */
157 _DRM_DMA_LARGER_OK
= 0x40 /* Larger-than-requested buffers ok */
160 typedef struct drm_buf_desc
{
161 int count
; /* Number of buffers of this size */
162 int size
; /* Size in bytes */
163 int low_mark
; /* Low water mark */
164 int high_mark
; /* High water mark */
166 DRM_PAGE_ALIGN
= 0x01 /* Align on page boundaries for DMA */
170 typedef struct drm_buf_info
{
171 int count
; /* Entries in list */
172 drm_buf_desc_t
*list
;
175 typedef struct drm_buf_free
{
180 typedef struct drm_buf_pub
{
181 int idx
; /* Index into master buflist */
182 int total
; /* Buffer size */
183 int used
; /* Amount of buffer in use (for DMA) */
184 void *address
; /* Address of buffer */
187 typedef struct drm_buf_map
{
188 int count
; /* Length of buflist */
189 void *virtual; /* Mmaped area in user-virtual */
190 drm_buf_pub_t
*list
; /* Buffer information */
193 typedef struct drm_dma
{
194 /* Indices here refer to the offset into
195 buflist in drm_buf_get_t. */
196 int context
; /* Context handle */
197 int send_count
; /* Number of buffers to send */
198 int *send_indices
; /* List of handles to buffers */
199 int *send_sizes
; /* Lengths of data to send */
200 drm_dma_flags_t flags
; /* Flags */
201 int request_count
; /* Number of buffers requested */
202 int request_size
; /* Desired size for buffers */
203 int *request_indices
; /* Buffer information */
205 int granted_count
; /* Number of buffers granted */
209 _DRM_CONTEXT_PRESERVED
= 0x01,
210 _DRM_CONTEXT_2DONLY
= 0x02
213 typedef struct drm_ctx
{
214 drm_context_t handle
;
215 drm_ctx_flags_t flags
;
218 typedef struct drm_ctx_res
{
223 typedef struct drm_draw
{
224 drm_drawable_t handle
;
227 typedef struct drm_auth
{
231 typedef struct drm_irq_busid
{
238 #define DRM_IOCTL_BASE 'd'
239 #define DRM_IOCTL_NR(n) _IOC_NR(n)
240 #define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
241 #define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size)
242 #define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size)
243 #define DRM_IOWR(nr,size) _IOWR(DRM_IOCTL_BASE,nr,size)
246 #define DRM_IOCTL_VERSION DRM_IOWR(0x00, drm_version_t)
247 #define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm_unique_t)
248 #define DRM_IOCTL_GET_MAGIC DRM_IOW( 0x02, drm_auth_t)
249 #define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, drm_irq_busid_t)
251 #define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t)
252 #define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, drm_auth_t)
253 #define DRM_IOCTL_BLOCK DRM_IOWR(0x12, drm_block_t)
254 #define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, drm_block_t)
255 #define DRM_IOCTL_CONTROL DRM_IOW( 0x14, drm_control_t)
256 #define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, drm_map_t)
257 #define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, drm_buf_desc_t)
258 #define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, drm_buf_desc_t)
259 #define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm_buf_info_t)
260 #define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm_buf_map_t)
261 #define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm_buf_free_t)
263 #define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t)
264 #define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t)
265 #define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, drm_ctx_t)
266 #define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, drm_ctx_t)
267 #define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, drm_ctx_t)
268 #define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, drm_ctx_t)
269 #define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, drm_ctx_res_t)
270 #define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, drm_draw_t)
271 #define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, drm_draw_t)
272 #define DRM_IOCTL_DMA DRM_IOWR(0x29, drm_dma_t)
273 #define DRM_IOCTL_LOCK DRM_IOW( 0x2a, drm_lock_t)
274 #define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, drm_lock_t)
275 #define DRM_IOCTL_FINISH DRM_IOW( 0x2c, drm_lock_t)