1 /*
2 * Copyright © 2007,2008 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 (krh@redhat.com)
31 */
33 #ifndef _DRI2_H_
34 #define _DRI2_H_
36 #include <X11/Xmd.h>
37 #include <X11/Xproto.h>
38 #include <X11/extensions/Xfixes.h>
39 #include <X11/extensions/extutil.h>
40 #include <X11/extensions/dri2tokens.h>
41 #include <drm.h>
43 typedef struct
44 {
45 unsigned int attachment;
46 unsigned int name;
47 unsigned int pitch;
48 unsigned int cpp;
49 unsigned int flags;
50 } DRI2Buffer;
52 typedef struct
53 {
54 Bool (*WireToEvent)(Display *dpy, XExtDisplayInfo *info, XEvent *event, xEvent *wire);
55 Status (*EventToWire)(Display *dpy, XExtDisplayInfo *info, XEvent *event, xEvent *wire);
56 int (*Error)(Display *dpy, xError *err, XExtCodes *codes, int *ret_code);
57 } DRI2EventOps;
59 /* Call this once per display to register event handling code.. if needed */
60 extern Bool
61 DRI2InitDisplay(Display * display, const DRI2EventOps * ops);
63 extern Bool
64 DRI2QueryExtension(Display * display, int *eventBase, int *errorBase);
66 extern Bool
67 DRI2QueryVersion(Display * display, int *major, int *minor);
69 extern Bool
70 DRI2Connect(Display * display, XID window,
71 char **driverName, char **deviceName);
73 extern Bool
74 DRI2Authenticate(Display * display, XID window, drm_magic_t magic);
76 extern void
77 DRI2CreateDrawable(Display * display, XID drawable);
79 extern void
80 DRI2DestroyDrawable(Display * display, XID handle);
82 extern DRI2Buffer*
83 DRI2GetBuffers(Display * dpy, XID drawable,
84 int *width, int *height,
85 unsigned int *attachments, int count,
86 int *outCount);
88 /**
89 * \note
90 * This function is only supported with DRI2 version 1.1 or later.
91 */
92 extern DRI2Buffer*
93 DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
94 int *width, int *height,
95 unsigned int *attachments,
96 int count, int *outCount);
98 extern void
99 DRI2CopyRegion(Display * dpy, XID drawable,
100 XserverRegion region,
101 CARD32 dest, CARD32 src);
103 extern void
104 DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
105 CARD64 remainder, CARD64 *count);
107 extern Bool
108 DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
110 extern Bool
111 DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
112 CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
114 extern Bool
115 DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
116 CARD64 *msc, CARD64 *sbc);
118 extern void
119 DRI2SwapInterval(Display *dpy, XID drawable, int interval);
121 #endif