dristruct.h revision 05b261ec
1/**************************************************************************
2
3Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
4All Rights Reserved.
5
6Permission is hereby granted, free of charge, to any person obtaining a
7copy of this software and associated documentation files (the
8"Software"), to deal in the Software without restriction, including
9without limitation the rights to use, copy, modify, merge, publish,
10distribute, sub license, and/or sell copies of the Software, and to
11permit persons to whom the Software is furnished to do so, subject to
12the following conditions:
13
14The above copyright notice and this permission notice (including the
15next paragraph) shall be included in all copies or substantial portions
16of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
22ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26**************************************************************************/
27
28/*
29 * Authors:
30 *   Jens Owen <jens@tungstengraphics.com>
31 *
32 */
33
34#ifndef DRI_STRUCT_H
35#define DRI_STRUCT_H
36
37#include "xf86drm.h"
38
39
40#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \
41    ((DRIWindowPrivIndex < 0) ? \
42     NULL : \
43     ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr)))
44
45#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \
46    ((DRIPixmapPrivIndex < 0) ? \
47     NULL : \
48     ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIWindowPrivIndex].ptr)))
49
50typedef struct _DRIDrawablePrivRec
51{
52    drm_drawable_t		hwDrawable;
53    int			drawableIndex;
54    ScreenPtr		pScreen;
55    int 		refCount;
56    int 		nrects;
57} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
58
59struct _DRIContextPrivRec
60{
61    drm_context_t		hwContext;
62    ScreenPtr		pScreen;
63    Bool     		valid3D;
64    DRIContextFlags     flags;
65    void**     		pContextStore;
66};
67
68#define DRI_SCREEN_PRIV(pScreen) \
69    ((DRIScreenPrivIndex < 0) ? \
70     NULL : \
71     ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr)))
72
73#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
74    (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
75
76#define DRI_ENT_PRIV(pScrn)  \
77    ((DRIEntPrivIndex < 0) ? \
78     NULL:		     \
79     ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \
80					   DRIEntPrivIndex)->ptr)))
81
82typedef struct _DRIScreenPrivRec
83{
84    Bool		directRenderingSupport;
85    int			drmFD;	      /* File descriptor for /dev/video/?   */
86    drm_handle_t   	hSAREA;	      /* Handle to SAREA, for mapping       */
87    XF86DRISAREAPtr	pSAREA;	      /* Mapped pointer to SAREA            */
88    drm_context_t          myContext;    /* DDX Driver's context               */
89    DRIContextPrivPtr   myContextPriv;/* Pointer to server's private area   */
90    DRIContextPrivPtr   lastPartial3DContext;  /* last one partially saved  */
91    void**		hiddenContextStore;    /* hidden X context          */
92    void**		partial3DContextStore; /* parital 3D context        */
93    DRIInfoPtr		pDriverInfo;
94    int                 nrWindows;
95    int                 nrWindowsVisible;
96    int                 nrWalked;
97    drm_clip_rect_t  private_buffer_rect; /* management of private buffers */
98    DrawablePtr         fullscreen; /* pointer to fullscreen drawable */
99    drm_clip_rect_t  fullscreen_rect; /* fake rect for fullscreen mode */
100    DRIWrappedFuncsRec	wrap;
101    DestroyWindowProcPtr DestroyWindow;
102    DrawablePtr		DRIDrawables[SAREA_MAX_DRAWABLES];
103    DRIContextPrivPtr   dummyCtxPriv; /* Pointer to dummy context */
104    Bool		createDummyCtx;
105    Bool		createDummyCtxPriv;
106    Bool		grabbedDRILock;
107    Bool		drmSIGIOHandlerInstalled;
108    Bool		wrapped;
109    Bool		windowsTouched;
110    int			lockRefCount;
111    drm_handle_t        hLSAREA;      /* Handle to SAREA containing lock, for mapping */
112    XF86DRILSAREAPtr    pLSAREA;      /* Mapped pointer to SAREA containing lock */
113    int*                pLockRefCount;
114    int*                pLockingContext;
115} DRIScreenPrivRec, *DRIScreenPrivPtr;
116
117
118typedef struct _DRIEntPrivRec {
119    int drmFD;
120    Bool drmOpened;
121    Bool sAreaGrabbed;
122    drm_handle_t hLSAREA;
123    XF86DRILSAREAPtr pLSAREA;
124    unsigned long sAreaSize;
125    int lockRefCount;
126    int lockingContext;
127    ScreenPtr resOwner;
128    Bool keepFDOpen;
129    int refCount;
130} DRIEntPrivRec, *DRIEntPrivPtr;
131
132#endif /* DRI_STRUCT_H */
133