aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg2009-11-17 10:14:54 -0600
committerKristian Høgsberg2009-11-17 10:15:06 -0600
commit4f57abfe66091281c9f59c14e6ea27b524b55d5b (patch)
treef00d1022cf208b381b93aa5c96858164e6a3f602 /xf86mm.h
parent9dd3613073aa2491cef440725fdfa0cf1e8f1a42 (diff)
downloadlibdrm-4f57abfe66091281c9f59c14e6ea27b524b55d5b.tar.gz
libdrm-4f57abfe66091281c9f59c14e6ea27b524b55d5b.tar.xz
libdrm-4f57abfe66091281c9f59c14e6ea27b524b55d5b.zip
Move libdrm/ up one level
Diffstat (limited to 'xf86mm.h')
-rw-r--r--xf86mm.h198
1 files changed, 198 insertions, 0 deletions
diff --git a/xf86mm.h b/xf86mm.h
new file mode 100644
index 00000000..a31de424
--- /dev/null
+++ b/xf86mm.h
@@ -0,0 +1,198 @@
1/**************************************************************************
2 *
3 * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 *
26 *
27 **************************************************************************/
28
29#ifndef _XF86MM_H_
30#define _XF86MM_H_
31#include <stddef.h>
32#include <stdint.h>
33#include "drm.h"
34
35/*
36 * Note on multithreaded applications using this interface.
37 * Libdrm is not threadsafe, so common buffer, TTM, and fence objects need to
38 * be protected using an external mutex.
39 *
40 * Note: Don't protect the following functions, as it may lead to deadlocks:
41 * drmBOUnmap().
42 * The kernel is synchronizing and refcounting buffer maps.
43 * User space only needs to refcount object usage within the same application.
44 */
45
46
47/*
48 * List macros heavily inspired by the Linux kernel
49 * list handling. No list looping yet.
50 */
51
52typedef struct _drmMMListHead
53{
54 struct _drmMMListHead *prev;
55 struct _drmMMListHead *next;
56} drmMMListHead;
57
58#define DRMINITLISTHEAD(__item) \
59 do{ \
60 (__item)->prev = (__item); \
61 (__item)->next = (__item); \
62 } while (0)
63
64#define DRMLISTADD(__item, __list) \
65 do { \
66 (__item)->prev = (__list); \
67 (__item)->next = (__list)->next; \
68 (__list)->next->prev = (__item); \
69 (__list)->next = (__item); \
70 } while (0)
71
72#define DRMLISTADDTAIL(__item, __list) \
73 do { \
74 (__item)->next = (__list); \
75 (__item)->prev = (__list)->prev; \
76 (__list)->prev->next = (__item); \
77 (__list)->prev = (__item); \
78 } while(0)
79
80#define DRMLISTDEL(__item) \
81 do { \
82 (__item)->prev->next = (__item)->next; \
83 (__item)->next->prev = (__item)->prev; \
84 } while(0)
85
86#define DRMLISTDELINIT(__item) \
87 do { \
88 (__item)->prev->next = (__item)->next; \
89 (__item)->next->prev = (__item)->prev; \
90 (__item)->next = (__item); \
91 (__item)->prev = (__item); \
92 } while(0)
93
94#define DRMLISTENTRY(__type, __item, __field) \
95 ((__type *)(((char *) (__item)) - offsetof(__type, __field)))
96
97#define DRMLISTEMPTY(__item) ((__item)->next == (__item))
98
99#define DRMLISTFOREACHSAFE(__item, __temp, __list) \
100 for ((__item) = (__list)->next, (__temp) = (__item)->next; \
101 (__item) != (__list); \
102 (__item) = (__temp), (__temp) = (__item)->next)
103
104#define DRMLISTFOREACHSAFEREVERSE(__item, __temp, __list) \
105 for ((__item) = (__list)->prev, (__temp) = (__item)->prev; \
106 (__item) != (__list); \
107 (__item) = (__temp), (__temp) = (__item)->prev)
108
109typedef struct _drmFence
110{
111 unsigned handle;
112 int fence_class;
113 unsigned type;
114 unsigned flags;
115 unsigned signaled;
116 uint32_t sequence;
117 unsigned pad[4]; /* for future expansion */
118} drmFence;
119
120typedef struct _drmBO
121{
122 unsigned handle;
123 uint64_t mapHandle;
124 uint64_t flags;
125 uint64_t proposedFlags;
126 unsigned mapFlags;
127 unsigned long size;
128 unsigned long offset;
129 unsigned long start;
130 unsigned replyFlags;
131 unsigned fenceFlags;
132 unsigned pageAlignment;
133 unsigned tileInfo;
134 unsigned hwTileStride;
135 unsigned desiredTileStride;
136 void *virtual;
137 void *mapVirtual;
138 int mapCount;
139 unsigned pad[8]; /* for future expansion */
140} drmBO;
141
142/*
143 * Fence functions.
144 */
145
146extern int drmFenceCreate(int fd, unsigned flags, int fence_class,
147 unsigned type, drmFence *fence);
148extern int drmFenceReference(int fd, unsigned handle, drmFence *fence);
149extern int drmFenceUnreference(int fd, const drmFence *fence);
150extern int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type);
151extern int drmFenceSignaled(int fd, drmFence *fence,
152 unsigned fenceType, int *signaled);
153extern int drmFenceWait(int fd, unsigned flags, drmFence *fence,
154 unsigned flush_type);
155extern int drmFenceEmit(int fd, unsigned flags, drmFence *fence,
156 unsigned emit_type);
157extern int drmFenceBuffers(int fd, unsigned flags, uint32_t fence_class, drmFence *fence);
158
159
160/*
161 * Buffer object functions.
162 */
163
164extern int drmBOCreate(int fd, unsigned long size,
165 unsigned pageAlignment, void *user_buffer,
166 uint64_t mask, unsigned hint, drmBO *buf);
167extern int drmBOReference(int fd, unsigned handle, drmBO *buf);
168extern int drmBOUnreference(int fd, drmBO *buf);
169extern int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
170 void **address);
171extern int drmBOUnmap(int fd, drmBO *buf);
172extern int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle);
173extern int drmBOInfo(int fd, drmBO *buf);
174extern int drmBOBusy(int fd, drmBO *buf, int *busy);
175
176extern int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint);
177
178/*
179 * Initialization functions.
180 */
181
182extern int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize,
183 unsigned memType);
184extern int drmMMTakedown(int fd, unsigned memType);
185extern int drmMMLock(int fd, unsigned memType, int lockBM, int ignoreNoEvict);
186extern int drmMMUnlock(int fd, unsigned memType, int unlockBM);
187extern int drmMMInfo(int fd, unsigned memType, uint64_t *size);
188extern int drmBOSetStatus(int fd, drmBO *buf,
189 uint64_t flags, uint64_t mask,
190 unsigned int hint,
191 unsigned int desired_tile_stride,
192 unsigned int tile_info);
193extern int drmBOVersion(int fd, unsigned int *major,
194 unsigned int *minor,
195 unsigned int *patchlevel);
196
197
198#endif