1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
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:
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.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
27 **************************************************************************/
35 * List macros heavily inspired by the Linux kernel
36 * list handling. No list looping yet.
39 typedef struct _drmMMListHead
41 struct _drmMMListHead *prev;
42 struct _drmMMListHead *next;
45 #define DRMINITLISTHEAD(__item) \
47 (__item)->prev = (__item); \
48 (__item)->next = (__item); \
51 #define DRMLISTADD(__item, __list) \
53 (__item)->prev = (__list); \
54 (__item)->next = (__list)->next; \
55 (__list)->next->prev = (__item); \
56 (__list)->next = (__item); \
59 #define DRMLISTADDTAIL(__item, __list) \
61 (__item)->next = (__list); \
62 (__item)->prev = (__list)->prev; \
63 (__list)->prev->next = (__item); \
64 (__list)->prev = (__item); \
67 #define DRMLISTDEL(__item) \
69 (__item)->prev->next = (__item)->next; \
70 (__item)->next->prev = (__item)->prev; \
73 #define DRMLISTDELINIT(__item) \
75 (__item)->prev->next = (__item)->next; \
76 (__item)->next->prev = (__item)->prev; \
77 (__item)->next = (__item); \
78 (__item)->prev = (__item); \
81 #define DRMLISTENTRY(__type, __item, __field) \
82 ((__type *)(((char *) (__item)) - offsetof(__type, __field)))
85 typedef struct _drmBO{
88 drm_handle_t mapHandle;
104 typedef struct _drmBONode {
112 typedef struct _drmBOList {
125 extern int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size,
127 extern int drmTTMDestroy(int fd, const drmTTM *ttm);
128 extern int drmTTMReference(int fd, unsigned handle, drmTTM *ttm);
129 extern int drmTTMUnreference(int fd, const drmTTM *ttm);
130 extern drm_handle_t drmTTMMapHandle(int fd, const drmTTM *ttm);
133 * Buffer object list functions.
136 extern void drmBOFreeList(drmBOList *list);
137 extern int drmBOResetList(drmBOList *list);
138 extern void *drmBOListIterator(drmBOList *list);
139 extern void *drmBOListNext(drmBOList *list, void *iterator);
140 extern drmBO *drmBOListBuf(void *iterator);
141 extern int drmBOCreateList(int numTarget, drmBOList *list);
144 * Buffer object functions.
147 extern int drmBOCreate(int fd, drmTTM *ttm, unsigned long start, unsigned long size,
148 void *user_buffer, drm_bo_type_t type, unsigned mask,
149 unsigned hint, drmBO *buf);
150 extern int drmBODestroy(int fd, drmBO *buf);
151 extern int drmBOReference(int fd, unsigned handle, drmBO *buf);
152 extern int drmBOUnReference(int fd, drmBO *buf);
153 extern int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
155 extern int drmBOUnmap(int fd, drmBO *buf);
156 extern int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask,
158 extern int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle);
159 extern int drmBOInfo(int fd, drmBO *buf);
160 extern int drmBufBusy(int fd, drmBO *buf, int *busy);
163 extern int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags,
166 extern int drmBOValidateList(int fd, drmBOList *list);
167 extern int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle);
171 * Initialization functions.
174 extern int drmMMInit(int fd, unsigned long vramPOffset, unsigned long vramPSize,
175 unsigned long ttPOffset, unsigned long ttPSize);
176 extern int drmMMTakedown(int fd);