dri2.h revision 4642e01f
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 (krh@redhat.com)
31 */
32
33#ifndef _DRI2_H_
34#define _DRI2_H_
35
36#include <X11/extensions/dri2tokens.h>
37
38typedef struct {
39    unsigned int attachment;
40    unsigned int name;
41    unsigned int pitch;
42    unsigned int cpp;
43    unsigned int flags;
44    void *driverPrivate;
45} DRI2BufferRec, *DRI2BufferPtr;
46
47typedef DRI2BufferPtr	(*DRI2CreateBuffersProcPtr)(DrawablePtr pDraw,
48						    unsigned int *attachments,
49						    int count);
50typedef void		(*DRI2DestroyBuffersProcPtr)(DrawablePtr pDraw,
51						     DRI2BufferPtr buffers,
52						     int count);
53typedef void		(*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
54						 RegionPtr pRegion,
55						 DRI2BufferPtr pDestBuffer,
56						 DRI2BufferPtr pSrcBuffer);
57
58typedef void		(*DRI2WaitProcPtr)(WindowPtr pWin,
59					   unsigned int sequence);
60
61typedef struct {
62    unsigned int version;	/* Version of this struct */
63    int fd;
64    const char *driverName;
65    const char *deviceName;
66
67    DRI2CreateBuffersProcPtr	CreateBuffers;
68    DRI2DestroyBuffersProcPtr	DestroyBuffers;
69    DRI2CopyRegionProcPtr	CopyRegion;
70    DRI2WaitProcPtr		Wait;
71
72}  DRI2InfoRec, *DRI2InfoPtr;
73
74Bool DRI2ScreenInit(ScreenPtr	pScreen,
75		    DRI2InfoPtr info);
76
77void DRI2CloseScreen(ScreenPtr pScreen);
78
79Bool DRI2Connect(ScreenPtr pScreen,
80		 unsigned int driverType,
81		 int *fd,
82		 const char **driverName,
83		 const char **deviceName);
84
85Bool DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic);
86
87int DRI2CreateDrawable(DrawablePtr pDraw);
88
89void DRI2DestroyDrawable(DrawablePtr pDraw);
90
91DRI2BufferPtr DRI2GetBuffers(DrawablePtr pDraw,
92			     int *width,
93			     int *height,
94			     unsigned int *attachments,
95			     int count,
96			     int *out_count);
97
98int DRI2CopyRegion(DrawablePtr pDraw,
99		   RegionPtr pRegion,
100		   unsigned int dest,
101		   unsigned int src);
102
103#endif
104