1 | /*
|
---|
2 | * Copyright © 2007 Red Hat, Inc.
|
---|
3 | *
|
---|
4 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
5 | * copy of this software and associated documentation files (the "Soft-
|
---|
6 | * ware"), to deal in the Software without restriction, including without
|
---|
7 | * limitation the rights to use, copy, modify, merge, publish, distribute,
|
---|
8 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
9 | * Software is furnished to do so, provided that the above copyright
|
---|
10 | * notice(s) and this permission notice appear in all copies of the Soft-
|
---|
11 | * ware and that both the above copyright notice(s) and this permission
|
---|
12 | * notice appear in supporting documentation.
|
---|
13 | *
|
---|
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
---|
16 | * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
---|
17 | * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
---|
18 | * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
---|
19 | * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
---|
20 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
---|
21 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
|
---|
22 | * MANCE OF THIS SOFTWARE.
|
---|
23 | *
|
---|
24 | * Except as contained in this notice, the name of a copyright holder shall
|
---|
25 | * not be used in advertising or otherwise to promote the sale, use or
|
---|
26 | * other dealings in this Software without prior written authorization of
|
---|
27 | * the copyright holder.
|
---|
28 | *
|
---|
29 | * Authors:
|
---|
30 | * Kristian Høgsberg ([email protected])
|
---|
31 | */
|
---|
32 |
|
---|
33 | #ifndef _DRI2_H_
|
---|
34 | #define _DRI2_H_
|
---|
35 |
|
---|
36 | #include <X11/extensions/dri2tokens.h>
|
---|
37 |
|
---|
38 | /* Version 2 structure (with format at the end) */
|
---|
39 | typedef struct {
|
---|
40 | unsigned int attachment;
|
---|
41 | unsigned int name;
|
---|
42 | unsigned int pitch;
|
---|
43 | unsigned int cpp;
|
---|
44 | unsigned int flags;
|
---|
45 | unsigned int format;
|
---|
46 | void *driverPrivate;
|
---|
47 | } DRI2BufferRec, *DRI2BufferPtr;
|
---|
48 |
|
---|
49 | extern CARD8 dri2_major; /* version of DRI2 supported by DDX */
|
---|
50 | extern CARD8 dri2_minor;
|
---|
51 |
|
---|
52 | typedef DRI2BufferRec DRI2Buffer2Rec, *DRI2Buffer2Ptr;
|
---|
53 | typedef void (*DRI2SwapEventPtr)(ClientPtr client, void *data, int type,
|
---|
54 | CARD64 ust, CARD64 msc, CARD32 sbc);
|
---|
55 |
|
---|
56 |
|
---|
57 | typedef DRI2BufferPtr (*DRI2CreateBuffersProcPtr)(DrawablePtr pDraw,
|
---|
58 | unsigned int *attachments,
|
---|
59 | int count);
|
---|
60 | typedef void (*DRI2DestroyBuffersProcPtr)(DrawablePtr pDraw,
|
---|
61 | DRI2BufferPtr buffers,
|
---|
62 | int count);
|
---|
63 | typedef void (*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
|
---|
64 | RegionPtr pRegion,
|
---|
65 | DRI2BufferPtr pDestBuffer,
|
---|
66 | DRI2BufferPtr pSrcBuffer);
|
---|
67 | typedef void (*DRI2WaitProcPtr)(WindowPtr pWin,
|
---|
68 | unsigned int sequence);
|
---|
69 | typedef int (*DRI2AuthMagicProcPtr)(int fd, uint32_t magic);
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Schedule a buffer swap
|
---|
73 | *
|
---|
74 | * This callback is used to support glXSwapBuffers and the OML_sync_control
|
---|
75 | * extension (see it for a description of the params).
|
---|
76 | *
|
---|
77 | * Drivers should queue an event for the frame count that satisfies the
|
---|
78 | * parameters passed in. If the event is in the future (i.e. the conditions
|
---|
79 | * aren't currently satisfied), the server may block the client at the next
|
---|
80 | * GLX request using DRI2WaitSwap. When the event arrives, drivers should call
|
---|
81 | * \c DRI2SwapComplete, which will handle waking the client and returning
|
---|
82 | * the appropriate data.
|
---|
83 | *
|
---|
84 | * The DDX is responsible for doing a flip, exchange, or blit of the swap
|
---|
85 | * when the corresponding event arrives. The \c DRI2CanFlip and
|
---|
86 | * \c DRI2CanExchange functions can be used as helpers for this purpose.
|
---|
87 | *
|
---|
88 | * \param client client pointer (used for block/unblock)
|
---|
89 | * \param pDraw drawable whose count we want
|
---|
90 | * \param pDestBuffer current front buffer
|
---|
91 | * \param pSrcBuffer current back buffer
|
---|
92 | * \param target_msc frame count to wait for
|
---|
93 | * \param divisor divisor for condition equation
|
---|
94 | * \param remainder remainder for division equation
|
---|
95 | * \param func function to call when the swap completes
|
---|
96 | * \param data data for the callback \p func.
|
---|
97 | */
|
---|
98 | typedef int (*DRI2ScheduleSwapProcPtr)(ClientPtr client,
|
---|
99 | DrawablePtr pDraw,
|
---|
100 | DRI2BufferPtr pDestBuffer,
|
---|
101 | DRI2BufferPtr pSrcBuffer,
|
---|
102 | CARD64 *target_msc,
|
---|
103 | CARD64 divisor,
|
---|
104 | CARD64 remainder,
|
---|
105 | DRI2SwapEventPtr func,
|
---|
106 | void *data);
|
---|
107 | typedef DRI2BufferPtr (*DRI2CreateBufferProcPtr)(DrawablePtr pDraw,
|
---|
108 | unsigned int attachment,
|
---|
109 | unsigned int format);
|
---|
110 | typedef void (*DRI2DestroyBufferProcPtr)(DrawablePtr pDraw,
|
---|
111 | DRI2BufferPtr buffer);
|
---|
112 | /**
|
---|
113 | * Notifies driver when DRI2GetBuffers reuses a dri2 buffer.
|
---|
114 | *
|
---|
115 | * Driver may rename the dri2 buffer in this notify if it is required.
|
---|
116 | *
|
---|
117 | * \param pDraw drawable whose count we want
|
---|
118 | * \param buffer buffer that will be returned to client
|
---|
119 | */
|
---|
120 | typedef void (*DRI2ReuseBufferNotifyProcPtr)(DrawablePtr pDraw,
|
---|
121 | DRI2BufferPtr buffer);
|
---|
122 | /**
|
---|
123 | * Get current media stamp counter values
|
---|
124 | *
|
---|
125 | * This callback is used to support the SGI_video_sync and OML_sync_control
|
---|
126 | * extensions.
|
---|
127 | *
|
---|
128 | * Drivers should return the current frame counter and the timestamp from
|
---|
129 | * when the returned frame count was last incremented.
|
---|
130 | *
|
---|
131 | * The count should correspond to the screen where the drawable is currently
|
---|
132 | * visible. If the drawable isn't visible (e.g. redirected), the server
|
---|
133 | * should return BadDrawable to the client, pending GLX spec updates to
|
---|
134 | * define this behavior.
|
---|
135 | *
|
---|
136 | * \param pDraw drawable whose count we want
|
---|
137 | * \param ust timestamp from when the count was last incremented.
|
---|
138 | * \param mst current frame count
|
---|
139 | */
|
---|
140 | typedef int (*DRI2GetMSCProcPtr)(DrawablePtr pDraw, CARD64 *ust,
|
---|
141 | CARD64 *msc);
|
---|
142 | /**
|
---|
143 | * Schedule a frame count related wait
|
---|
144 | *
|
---|
145 | * This callback is used to support the SGI_video_sync and OML_sync_control
|
---|
146 | * extensions. See those specifications for details on how to handle
|
---|
147 | * the divisor and remainder parameters.
|
---|
148 | *
|
---|
149 | * Drivers should queue an event for the frame count that satisfies the
|
---|
150 | * parameters passed in. If the event is in the future (i.e. the conditions
|
---|
151 | * aren't currently satisfied), the driver should block the client using
|
---|
152 | * \c DRI2BlockClient. When the event arrives, drivers should call
|
---|
153 | * \c DRI2WaitMSCComplete, which will handle waking the client and returning
|
---|
154 | * the appropriate data.
|
---|
155 | *
|
---|
156 | * \param client client pointer (used for block/unblock)
|
---|
157 | * \param pDraw drawable whose count we want
|
---|
158 | * \param target_msc frame count to wait for
|
---|
159 | * \param divisor divisor for condition equation
|
---|
160 | * \param remainder remainder for division equation
|
---|
161 | */
|
---|
162 | typedef int (*DRI2ScheduleWaitMSCProcPtr)(ClientPtr client,
|
---|
163 | DrawablePtr pDraw,
|
---|
164 | CARD64 target_msc,
|
---|
165 | CARD64 divisor,
|
---|
166 | CARD64 remainder);
|
---|
167 |
|
---|
168 | typedef void (*DRI2InvalidateProcPtr)(DrawablePtr pDraw,
|
---|
169 | void *data,
|
---|
170 | XID id);
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * DRI2 calls this hook when ever swap_limit is going to be changed. Default
|
---|
174 | * implementation for the hook only accepts one as swap_limit. If driver can
|
---|
175 | * support other swap_limits it has to implement supported limits with this
|
---|
176 | * callback.
|
---|
177 | *
|
---|
178 | * \param pDraw drawable whos swap_limit is going to be changed
|
---|
179 | * \param swap_limit new swap_limit that going to be set
|
---|
180 | * \return TRUE if limit is support, FALSE if not.
|
---|
181 | */
|
---|
182 | typedef Bool (*DRI2SwapLimitValidateProcPtr)(DrawablePtr pDraw,
|
---|
183 | int swap_limit);
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * Version of the DRI2InfoRec structure defined in this header
|
---|
187 | */
|
---|
188 | #define DRI2INFOREC_VERSION 6
|
---|
189 |
|
---|
190 | typedef struct {
|
---|
191 | unsigned int version; /**< Version of this struct */
|
---|
192 | int fd;
|
---|
193 | const char *driverName;
|
---|
194 | const char *deviceName;
|
---|
195 |
|
---|
196 | DRI2CreateBufferProcPtr CreateBuffer;
|
---|
197 | DRI2DestroyBufferProcPtr DestroyBuffer;
|
---|
198 | DRI2CopyRegionProcPtr CopyRegion;
|
---|
199 | DRI2WaitProcPtr Wait;
|
---|
200 |
|
---|
201 | /* added in version 4 */
|
---|
202 |
|
---|
203 | DRI2ScheduleSwapProcPtr ScheduleSwap;
|
---|
204 | DRI2GetMSCProcPtr GetMSC;
|
---|
205 | DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
|
---|
206 |
|
---|
207 | /* number of drivers in the driverNames array */
|
---|
208 | unsigned int numDrivers;
|
---|
209 | /* array of driver names, indexed by DRI2Driver* driver types */
|
---|
210 | /* a name of NULL means that driver is not supported */
|
---|
211 | const char * const *driverNames;
|
---|
212 |
|
---|
213 | /* added in version 5 */
|
---|
214 |
|
---|
215 | DRI2AuthMagicProcPtr AuthMagic;
|
---|
216 |
|
---|
217 | /* added in version 6 */
|
---|
218 |
|
---|
219 | DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
|
---|
220 | DRI2SwapLimitValidateProcPtr SwapLimitValidate;
|
---|
221 | } DRI2InfoRec, *DRI2InfoPtr;
|
---|
222 |
|
---|
223 | extern _X_EXPORT int DRI2EventBase;
|
---|
224 |
|
---|
225 | extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen,
|
---|
226 | DRI2InfoPtr info);
|
---|
227 |
|
---|
228 | extern _X_EXPORT void DRI2CloseScreen(ScreenPtr pScreen);
|
---|
229 |
|
---|
230 | extern _X_EXPORT Bool DRI2HasSwapControl(ScreenPtr pScreen);
|
---|
231 |
|
---|
232 | extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen,
|
---|
233 | unsigned int driverType,
|
---|
234 | int *fd,
|
---|
235 | const char **driverName,
|
---|
236 | const char **deviceName);
|
---|
237 |
|
---|
238 | extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, uint32_t magic);
|
---|
239 |
|
---|
240 | extern _X_EXPORT int DRI2CreateDrawable(ClientPtr client,
|
---|
241 | DrawablePtr pDraw,
|
---|
242 | XID id,
|
---|
243 | DRI2InvalidateProcPtr invalidate,
|
---|
244 | void *priv);
|
---|
245 |
|
---|
246 | extern _X_EXPORT void DRI2DestroyDrawable(DrawablePtr pDraw);
|
---|
247 |
|
---|
248 | extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffers(DrawablePtr pDraw,
|
---|
249 | int *width,
|
---|
250 | int *height,
|
---|
251 | unsigned int *attachments,
|
---|
252 | int count,
|
---|
253 | int *out_count);
|
---|
254 |
|
---|
255 | extern _X_EXPORT int DRI2CopyRegion(DrawablePtr pDraw,
|
---|
256 | RegionPtr pRegion,
|
---|
257 | unsigned int dest,
|
---|
258 | unsigned int src);
|
---|
259 |
|
---|
260 | /**
|
---|
261 | * Determine the major and minor version of the DRI2 extension.
|
---|
262 | *
|
---|
263 | * Provides a mechanism to other modules (e.g., 2D drivers) to determine the
|
---|
264 | * version of the DRI2 extension. While it is possible to peek directly at
|
---|
265 | * the \c XF86ModuleData from a layered module, such a module will fail to
|
---|
266 | * load (due to an unresolved symbol) if the DRI2 extension is not loaded.
|
---|
267 | *
|
---|
268 | * \param major Location to store the major verion of the DRI2 extension
|
---|
269 | * \param minor Location to store the minor verion of the DRI2 extension
|
---|
270 | *
|
---|
271 | * \note
|
---|
272 | * This interface was added some time after the initial release of the DRI2
|
---|
273 | * module. Layered modules that wish to use this interface must first test
|
---|
274 | * its existance by calling \c xf86LoaderCheckSymbol.
|
---|
275 | */
|
---|
276 | extern _X_EXPORT void DRI2Version(int *major, int *minor);
|
---|
277 |
|
---|
278 | extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffersWithFormat(DrawablePtr pDraw,
|
---|
279 | int *width, int *height, unsigned int *attachments, int count,
|
---|
280 | int *out_count);
|
---|
281 |
|
---|
282 | extern _X_EXPORT void DRI2SwapInterval(DrawablePtr pDrawable, int interval);
|
---|
283 | extern _X_EXPORT Bool DRI2SwapLimit(DrawablePtr pDraw, int swap_limit);
|
---|
284 | extern _X_EXPORT int DRI2SwapBuffers(ClientPtr client, DrawablePtr pDrawable,
|
---|
285 | CARD64 target_msc, CARD64 divisor,
|
---|
286 | CARD64 remainder, CARD64 *swap_target,
|
---|
287 | DRI2SwapEventPtr func, void *data);
|
---|
288 | extern _X_EXPORT Bool DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable);
|
---|
289 |
|
---|
290 | extern _X_EXPORT int DRI2GetMSC(DrawablePtr pDrawable, CARD64 *ust,
|
---|
291 | CARD64 *msc, CARD64 *sbc);
|
---|
292 | extern _X_EXPORT int DRI2WaitMSC(ClientPtr client, DrawablePtr pDrawable,
|
---|
293 | CARD64 target_msc, CARD64 divisor,
|
---|
294 | CARD64 remainder);
|
---|
295 | extern _X_EXPORT int ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust,
|
---|
296 | CARD64 msc, CARD64 sbc);
|
---|
297 | extern _X_EXPORT int DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw,
|
---|
298 | CARD64 target_sbc);
|
---|
299 | extern _X_EXPORT Bool DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw);
|
---|
300 |
|
---|
301 | extern _X_EXPORT Bool DRI2CanFlip(DrawablePtr pDraw);
|
---|
302 |
|
---|
303 | extern _X_EXPORT Bool DRI2CanExchange(DrawablePtr pDraw);
|
---|
304 |
|
---|
305 | /* Note: use *only* for MSC related waits */
|
---|
306 | extern _X_EXPORT void DRI2BlockClient(ClientPtr client, DrawablePtr pDraw);
|
---|
307 |
|
---|
308 | extern _X_EXPORT void DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw,
|
---|
309 | int frame, unsigned int tv_sec,
|
---|
310 | unsigned int tv_usec, int type,
|
---|
311 | DRI2SwapEventPtr swap_complete,
|
---|
312 | void *swap_data);
|
---|
313 | extern _X_EXPORT void DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw,
|
---|
314 | int frame, unsigned int tv_sec,
|
---|
315 | unsigned int tv_usec);
|
---|
316 |
|
---|
317 | #endif
|
---|