2 * Copyright © 2007 Red Hat, Inc.
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.
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.
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.
30 * Kristian Høgsberg (krh@redhat.com)
36 #include <X11/extensions/dri2tokens.h>
38 /* Version 2 structure (with format at the end) */
40 unsigned int attachment
;
47 } DRI2BufferRec
, *DRI2BufferPtr
;
49 extern CARD8 dri2_major
; /* version of DRI2 supported by DDX */
50 extern CARD8 dri2_minor
;
52 typedef DRI2BufferRec DRI2Buffer2Rec
, *DRI2Buffer2Ptr
;
53 typedef void (*DRI2SwapEventPtr
) (ClientPtr client
, void *data
, int type
,
54 CARD64 ust
, CARD64 msc
, CARD32 sbc
);
56 typedef DRI2BufferPtr(*DRI2CreateBuffersProcPtr
) (DrawablePtr pDraw
,
57 unsigned int *attachments
,
59 typedef void (*DRI2DestroyBuffersProcPtr
) (DrawablePtr pDraw
,
60 DRI2BufferPtr buffers
, int count
);
61 typedef void (*DRI2CopyRegionProcPtr
) (DrawablePtr pDraw
,
63 DRI2BufferPtr pDestBuffer
,
64 DRI2BufferPtr pSrcBuffer
);
65 typedef void (*DRI2WaitProcPtr
) (WindowPtr pWin
, unsigned int sequence
);
66 typedef int (*DRI2AuthMagicProcPtr
) (int fd
, uint32_t magic
);
67 typedef int (*DRI2AuthMagic2ProcPtr
) (ScreenPtr pScreen
, uint32_t magic
);
70 * Schedule a buffer swap
72 * This callback is used to support glXSwapBuffers and the OML_sync_control
73 * extension (see it for a description of the params).
75 * Drivers should queue an event for the frame count that satisfies the
76 * parameters passed in. If the event is in the future (i.e. the conditions
77 * aren't currently satisfied), the server may block the client at the next
78 * GLX request using DRI2WaitSwap. When the event arrives, drivers should call
79 * \c DRI2SwapComplete, which will handle waking the client and returning
80 * the appropriate data.
82 * The DDX is responsible for doing a flip, exchange, or blit of the swap
83 * when the corresponding event arrives. The \c DRI2CanFlip and
84 * \c DRI2CanExchange functions can be used as helpers for this purpose.
86 * \param client client pointer (used for block/unblock)
87 * \param pDraw drawable whose count we want
88 * \param pDestBuffer current front buffer
89 * \param pSrcBuffer current back buffer
90 * \param target_msc frame count to wait for
91 * \param divisor divisor for condition equation
92 * \param remainder remainder for division equation
93 * \param func function to call when the swap completes
94 * \param data data for the callback \p func.
96 typedef int (*DRI2ScheduleSwapProcPtr
) (ClientPtr client
,
98 DRI2BufferPtr pDestBuffer
,
99 DRI2BufferPtr pSrcBuffer
,
103 DRI2SwapEventPtr func
, void *data
);
104 typedef DRI2BufferPtr(*DRI2CreateBufferProcPtr
) (DrawablePtr pDraw
,
105 unsigned int attachment
,
106 unsigned int format
);
107 typedef void (*DRI2DestroyBufferProcPtr
) (DrawablePtr pDraw
,
108 DRI2BufferPtr buffer
);
110 * Notifies driver when DRI2GetBuffers reuses a dri2 buffer.
112 * Driver may rename the dri2 buffer in this notify if it is required.
114 * \param pDraw drawable whose count we want
115 * \param buffer buffer that will be returned to client
117 typedef void (*DRI2ReuseBufferNotifyProcPtr
) (DrawablePtr pDraw
,
118 DRI2BufferPtr buffer
);
120 * Get current media stamp counter values
122 * This callback is used to support the SGI_video_sync and OML_sync_control
125 * Drivers should return the current frame counter and the timestamp from
126 * when the returned frame count was last incremented.
128 * The count should correspond to the screen where the drawable is currently
129 * visible. If the drawable isn't visible (e.g. redirected), the server
130 * should return BadDrawable to the client, pending GLX spec updates to
131 * define this behavior.
133 * \param pDraw drawable whose count we want
134 * \param ust timestamp from when the count was last incremented.
135 * \param mst current frame count
137 typedef int (*DRI2GetMSCProcPtr
) (DrawablePtr pDraw
, CARD64
* ust
,
140 * Schedule a frame count related wait
142 * This callback is used to support the SGI_video_sync and OML_sync_control
143 * extensions. See those specifications for details on how to handle
144 * the divisor and remainder parameters.
146 * Drivers should queue an event for the frame count that satisfies the
147 * parameters passed in. If the event is in the future (i.e. the conditions
148 * aren't currently satisfied), the driver should block the client using
149 * \c DRI2BlockClient. When the event arrives, drivers should call
150 * \c DRI2WaitMSCComplete, which will handle waking the client and returning
151 * the appropriate data.
153 * \param client client pointer (used for block/unblock)
154 * \param pDraw drawable whose count we want
155 * \param target_msc frame count to wait for
156 * \param divisor divisor for condition equation
157 * \param remainder remainder for division equation
159 typedef int (*DRI2ScheduleWaitMSCProcPtr
) (ClientPtr client
,
162 CARD64 divisor
, CARD64 remainder
);
164 typedef void (*DRI2InvalidateProcPtr
) (DrawablePtr pDraw
, void *data
, XID id
);
167 * DRI2 calls this hook when ever swap_limit is going to be changed. Default
168 * implementation for the hook only accepts one as swap_limit. If driver can
169 * support other swap_limits it has to implement supported limits with this
172 * \param pDraw drawable whos swap_limit is going to be changed
173 * \param swap_limit new swap_limit that going to be set
174 * \return TRUE if limit is support, FALSE if not.
176 typedef Bool (*DRI2SwapLimitValidateProcPtr
) (DrawablePtr pDraw
,
179 typedef DRI2BufferPtr(*DRI2CreateBuffer2ProcPtr
) (ScreenPtr pScreen
,
181 unsigned int attachment
,
182 unsigned int format
);
183 typedef void (*DRI2DestroyBuffer2ProcPtr
) (ScreenPtr pScreen
, DrawablePtr pDraw
,
184 DRI2BufferPtr buffer
);
186 typedef void (*DRI2CopyRegion2ProcPtr
) (ScreenPtr pScreen
, DrawablePtr pDraw
,
188 DRI2BufferPtr pDestBuffer
,
189 DRI2BufferPtr pSrcBuffer
);
192 * \brief Get the value of a parameter.
194 * The parameter's \a value is looked up on the screen associated with
197 * \return \c Success or error code.
199 typedef int (*DRI2GetParamProcPtr
) (ClientPtr client
,
200 DrawablePtr pDrawable
,
202 BOOL
*is_param_recognized
,
206 * Version of the DRI2InfoRec structure defined in this header
208 #define DRI2INFOREC_VERSION 9
211 unsigned int version
; /**< Version of this struct */
213 const char *driverName
;
214 const char *deviceName
;
216 DRI2CreateBufferProcPtr CreateBuffer
;
217 DRI2DestroyBufferProcPtr DestroyBuffer
;
218 DRI2CopyRegionProcPtr CopyRegion
;
219 DRI2WaitProcPtr Wait
;
221 /* added in version 4 */
223 DRI2ScheduleSwapProcPtr ScheduleSwap
;
224 DRI2GetMSCProcPtr GetMSC
;
225 DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC
;
227 /* number of drivers in the driverNames array */
228 unsigned int numDrivers
;
229 /* array of driver names, indexed by DRI2Driver* driver types */
230 /* a name of NULL means that driver is not supported */
231 const char *const *driverNames
;
233 /* added in version 5 */
235 DRI2AuthMagicProcPtr AuthMagic
;
237 /* added in version 6 */
239 DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify
;
240 DRI2SwapLimitValidateProcPtr SwapLimitValidate
;
242 /* added in version 7 */
243 DRI2GetParamProcPtr GetParam
;
245 /* added in version 8 */
246 /* AuthMagic callback which passes extra context */
247 /* If this is NULL the AuthMagic callback is used */
248 /* If this is non-NULL the AuthMagic callback is ignored */
249 DRI2AuthMagic2ProcPtr AuthMagic2
;
251 /* added in version 9 */
252 DRI2CreateBuffer2ProcPtr CreateBuffer2
;
253 DRI2DestroyBuffer2ProcPtr DestroyBuffer2
;
254 DRI2CopyRegion2ProcPtr CopyRegion2
;
255 } DRI2InfoRec
, *DRI2InfoPtr
;
257 extern _X_EXPORT Bool
DRI2ScreenInit(ScreenPtr pScreen
, DRI2InfoPtr info
);
259 extern _X_EXPORT
void DRI2CloseScreen(ScreenPtr pScreen
);
261 extern _X_EXPORT Bool
DRI2HasSwapControl(ScreenPtr pScreen
);
263 extern _X_EXPORT Bool
DRI2Connect(ClientPtr client
, ScreenPtr pScreen
,
264 unsigned int driverType
,
266 const char **driverName
,
267 const char **deviceName
);
269 extern _X_EXPORT Bool
DRI2Authenticate(ClientPtr client
, ScreenPtr pScreen
, uint32_t magic
);
271 extern _X_EXPORT
int DRI2CreateDrawable(ClientPtr client
,
274 DRI2InvalidateProcPtr invalidate
,
277 extern _X_EXPORT
int DRI2CreateDrawable2(ClientPtr client
,
280 DRI2InvalidateProcPtr invalidate
,
284 extern _X_EXPORT DRI2BufferPtr
*DRI2GetBuffers(DrawablePtr pDraw
,
287 unsigned int *attachments
,
288 int count
, int *out_count
);
290 extern _X_EXPORT
int DRI2CopyRegion(DrawablePtr pDraw
,
292 unsigned int dest
, unsigned int src
);
295 * Determine the major and minor version of the DRI2 extension.
297 * Provides a mechanism to other modules (e.g., 2D drivers) to determine the
298 * version of the DRI2 extension. While it is possible to peek directly at
299 * the \c XF86ModuleData from a layered module, such a module will fail to
300 * load (due to an unresolved symbol) if the DRI2 extension is not loaded.
302 * \param major Location to store the major verion of the DRI2 extension
303 * \param minor Location to store the minor verion of the DRI2 extension
306 * This interface was added some time after the initial release of the DRI2
307 * module. Layered modules that wish to use this interface must first test
308 * its existance by calling \c xf86LoaderCheckSymbol.
310 extern _X_EXPORT
void DRI2Version(int *major
, int *minor
);
312 extern _X_EXPORT DRI2BufferPtr
*DRI2GetBuffersWithFormat(DrawablePtr pDraw
,
320 extern _X_EXPORT
void DRI2SwapInterval(DrawablePtr pDrawable
, int interval
);
321 extern _X_EXPORT Bool
DRI2SwapLimit(DrawablePtr pDraw
, int swap_limit
);
322 extern _X_EXPORT
int DRI2SwapBuffers(ClientPtr client
, DrawablePtr pDrawable
,
323 CARD64 target_msc
, CARD64 divisor
,
324 CARD64 remainder
, CARD64
* swap_target
,
325 DRI2SwapEventPtr func
, void *data
);
326 extern _X_EXPORT Bool
DRI2WaitSwap(ClientPtr client
, DrawablePtr pDrawable
);
328 extern _X_EXPORT
int DRI2GetMSC(DrawablePtr pDrawable
, CARD64
* ust
,
329 CARD64
* msc
, CARD64
* sbc
);
330 extern _X_EXPORT
int DRI2WaitMSC(ClientPtr client
, DrawablePtr pDrawable
,
331 CARD64 target_msc
, CARD64 divisor
,
333 extern _X_EXPORT
int ProcDRI2WaitMSCReply(ClientPtr client
, CARD64 ust
,
334 CARD64 msc
, CARD64 sbc
);
335 extern _X_EXPORT
int DRI2WaitSBC(ClientPtr client
, DrawablePtr pDraw
,
337 extern _X_EXPORT Bool
DRI2ThrottleClient(ClientPtr client
, DrawablePtr pDraw
);
339 extern _X_EXPORT Bool
DRI2CanFlip(DrawablePtr pDraw
);
341 extern _X_EXPORT Bool
DRI2CanExchange(DrawablePtr pDraw
);
343 /* Note: use *only* for MSC related waits */
344 extern _X_EXPORT
void DRI2BlockClient(ClientPtr client
, DrawablePtr pDraw
);
346 extern _X_EXPORT
void DRI2SwapComplete(ClientPtr client
, DrawablePtr pDraw
,
347 int frame
, unsigned int tv_sec
,
348 unsigned int tv_usec
, int type
,
349 DRI2SwapEventPtr swap_complete
,
351 extern _X_EXPORT
void DRI2WaitMSCComplete(ClientPtr client
, DrawablePtr pDraw
,
352 int frame
, unsigned int tv_sec
,
353 unsigned int tv_usec
);
355 extern _X_EXPORT
int DRI2GetParam(ClientPtr client
,
356 DrawablePtr pDrawable
,
358 BOOL
*is_param_recognized
,
361 extern _X_EXPORT DrawablePtr
DRI2UpdatePrime(DrawablePtr pDraw
, DRI2BufferPtr pDest
);