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