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/* Prototypes for DRI functions */ 35 36#ifndef _DRI_H_ 37 38#include <pciaccess.h> 39 40#include "scrnintstr.h" 41#include "xf86dri.h" 42 43typedef int DRISyncType; 44 45#define DRI_NO_SYNC 0 46#define DRI_2D_SYNC 1 47#define DRI_3D_SYNC 2 48 49typedef int DRIContextType; 50 51typedef struct _DRIContextPrivRec DRIContextPrivRec, *DRIContextPrivPtr; 52 53typedef enum _DRIContextFlags { 54 DRI_CONTEXT_2DONLY = 0x01, 55 DRI_CONTEXT_PRESERVED = 0x02, 56 DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */ 57} DRIContextFlags; 58 59#define DRI_NO_CONTEXT 0 60#define DRI_2D_CONTEXT 1 61#define DRI_3D_CONTEXT 2 62 63typedef int DRISwapMethod; 64 65#define DRI_HIDE_X_CONTEXT 0 66#define DRI_SERVER_SWAP 1 67#define DRI_KERNEL_SWAP 2 68 69typedef int DRIWindowRequests; 70 71#define DRI_NO_WINDOWS 0 72#define DRI_3D_WINDOWS_ONLY 1 73#define DRI_ALL_WINDOWS 2 74 75typedef void (*ClipNotifyPtr) (WindowPtr, int, int); 76typedef void (*AdjustFramePtr) (ScrnInfoPtr pScrn, int x, int y); 77 78/* 79 * These functions can be wrapped by the DRI. Each of these have 80 * generic default funcs (initialized in DRICreateInfoRec) and can be 81 * overridden by the driver in its [driver]DRIScreenInit function. 82 */ 83typedef struct { 84 ScreenWakeupHandlerProcPtr WakeupHandler; 85 ScreenBlockHandlerProcPtr BlockHandler; 86 WindowExposuresProcPtr WindowExposures; 87 CopyWindowProcPtr CopyWindow; 88 ClipNotifyProcPtr ClipNotify; 89 AdjustFramePtr AdjustFrame; 90} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr; 91 92/* 93 * Prior to Xorg 6.8.99.8, the DRIInfoRec structure was implicitly versioned 94 * by the XF86DRI_*_VERSION defines in xf86dristr.h. These numbers were also 95 * being used to version the XFree86-DRI protocol. Bugs #3066 and #3163 96 * showed that this was inadequate. The DRIInfoRec structure is now versioned 97 * by the DRIINFO_*_VERSION defines in this file. - ajax, 2005-05-18. 98 * 99 * Revision history: 100 * 4.1.0 and earlier: DRIQueryVersion returns XF86DRI_*_VERSION. 101 * 4.2.0: DRIQueryVersion begins returning DRIINFO_*_VERSION. 102 * 5.0.0: frameBufferPhysicalAddress changed from CARD32 to pointer. 103 */ 104 105#define DRIINFO_MAJOR_VERSION 5 106#define DRIINFO_MINOR_VERSION 4 107#define DRIINFO_PATCH_VERSION 0 108 109typedef unsigned long long (*DRITexOffsetStartProcPtr) (PixmapPtr pPix); 110typedef void (*DRITexOffsetFinishProcPtr) (PixmapPtr pPix); 111 112typedef struct { 113 /* driver call back functions 114 * 115 * New fields should be added at the end for backwards compatibility. 116 * Bump the DRIINFO patch number to indicate bugfixes. 117 * Bump the DRIINFO minor number to indicate new fields. 118 * Bump the DRIINFO major number to indicate binary-incompatible changes. 119 */ 120 Bool (*CreateContext) (ScreenPtr pScreen, 121 VisualPtr visual, 122 drm_context_t hHWContext, 123 void *pVisualConfigPriv, DRIContextType context); 124 void (*DestroyContext) (ScreenPtr pScreen, 125 drm_context_t hHWContext, DRIContextType context); 126 void (*SwapContext) (ScreenPtr pScreen, 127 DRISyncType syncType, 128 DRIContextType readContextType, 129 void *readContextStore, 130 DRIContextType writeContextType, 131 void *writeContextStore); 132 void (*InitBuffers) (WindowPtr pWin, RegionPtr prgn, CARD32 indx); 133 void (*MoveBuffers) (WindowPtr pWin, 134 DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 indx); 135 void (*TransitionTo3d) (ScreenPtr pScreen); 136 void (*TransitionTo2d) (ScreenPtr pScreen); 137 138 void (*SetDrawableIndex) (WindowPtr pWin, CARD32 indx); 139 Bool (*OpenFullScreen) (ScreenPtr pScreen); 140 Bool (*CloseFullScreen) (ScreenPtr pScreen); 141 142 /* wrapped functions */ 143 DRIWrappedFuncsRec wrap; 144 145 /* device info */ 146 char *drmDriverName; 147 char *clientDriverName; 148 char *busIdString; 149 int ddxDriverMajorVersion; 150 int ddxDriverMinorVersion; 151 int ddxDriverPatchVersion; 152 void *frameBufferPhysicalAddress; 153 long frameBufferSize; 154 long frameBufferStride; 155 long SAREASize; 156 int maxDrawableTableEntry; 157 int ddxDrawableTableEntry; 158 long contextSize; 159 DRISwapMethod driverSwapMethod; 160 DRIWindowRequests bufferRequests; 161 int devPrivateSize; 162 void *devPrivate; 163 Bool createDummyCtx; 164 Bool createDummyCtxPriv; 165 166 /* New with DRI version 4.1.0 */ 167 void (*TransitionSingleToMulti3D) (ScreenPtr pScreen); 168 void (*TransitionMultiToSingle3D) (ScreenPtr pScreen); 169 170 /* New with DRI version 5.1.0 */ 171 void (*ClipNotify) (ScreenPtr pScreen, WindowPtr *ppWin, int num); 172 173 /* New with DRI version 5.2.0 */ 174 Bool allocSarea; 175 Bool keepFDOpen; 176 177 /* New with DRI version 5.3.0 */ 178 DRITexOffsetStartProcPtr texOffsetStart; 179 DRITexOffsetFinishProcPtr texOffsetFinish; 180 181 /* New with DRI version 5.4.0 */ 182 int dontMapFrameBuffer; 183 drm_handle_t hFrameBuffer; /* Handle to framebuffer, either 184 * mapped by DDX driver or DRI */ 185 186} DRIInfoRec, *DRIInfoPtr; 187 188extern _X_EXPORT Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, 189 unsigned long sAreaSize, 190 const char *busID, 191 const char *drmDriverName); 192 193extern _X_EXPORT Bool DRIScreenInit(ScreenPtr pScreen, 194 DRIInfoPtr pDRIInfo, int *pDRMFD); 195 196extern _X_EXPORT void DRICloseScreen(ScreenPtr pScreen); 197 198extern Bool DRIExtensionInit(void); 199 200extern _X_EXPORT void DRIReset(void); 201 202extern _X_EXPORT Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, 203 Bool *isCapable); 204 205extern _X_EXPORT Bool DRIOpenConnection(ScreenPtr pScreen, 206 drm_handle_t * hSAREA, 207 char **busIdString); 208 209extern _X_EXPORT Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic); 210 211extern _X_EXPORT Bool DRICloseConnection(ScreenPtr pScreen); 212 213extern _X_EXPORT Bool DRIGetClientDriverName(ScreenPtr pScreen, 214 int *ddxDriverMajorVersion, 215 int *ddxDriverMinorVersion, 216 int *ddxDriverPatchVersion, 217 char **clientDriverName); 218 219extern _X_EXPORT Bool DRICreateContext(ScreenPtr pScreen, 220 VisualPtr visual, 221 XID context, drm_context_t * pHWContext); 222 223extern _X_EXPORT Bool DRIDestroyContext(ScreenPtr pScreen, XID context); 224 225extern _X_EXPORT Bool DRIContextPrivDelete(void *pResource, XID id); 226 227extern _X_EXPORT Bool DRICreateDrawable(ScreenPtr pScreen, 228 ClientPtr client, 229 DrawablePtr pDrawable, 230 drm_drawable_t * hHWDrawable); 231 232extern _X_EXPORT Bool DRIDestroyDrawable(ScreenPtr pScreen, 233 ClientPtr client, 234 DrawablePtr pDrawable); 235 236extern _X_EXPORT Bool DRIDrawablePrivDelete(void *pResource, XID id); 237 238extern _X_EXPORT Bool DRIGetDrawableInfo(ScreenPtr pScreen, 239 DrawablePtr pDrawable, 240 unsigned int *indx, 241 unsigned int *stamp, 242 int *X, 243 int *Y, 244 int *W, 245 int *H, 246 int *numClipRects, 247 drm_clip_rect_t ** pClipRects, 248 int *backX, 249 int *backY, 250 int *numBackClipRects, 251 drm_clip_rect_t ** pBackClipRects); 252 253extern _X_EXPORT Bool DRIGetDeviceInfo(ScreenPtr pScreen, 254 drm_handle_t * hFrameBuffer, 255 int *fbOrigin, 256 int *fbSize, 257 int *fbStride, 258 int *devPrivateSize, void **pDevPrivate); 259 260extern _X_EXPORT DRIInfoPtr DRICreateInfoRec(void); 261 262extern _X_EXPORT void DRIDestroyInfoRec(DRIInfoPtr DRIInfo); 263 264extern _X_EXPORT Bool DRIFinishScreenInit(ScreenPtr pScreen); 265 266extern _X_EXPORT void DRIWakeupHandler(void *wakeupData, int result); 267 268extern _X_EXPORT void DRIBlockHandler(void *blockData, void *timeout); 269 270extern _X_EXPORT void DRIDoWakeupHandler(ScreenPtr pScreen, int result); 271 272extern _X_EXPORT void DRIDoBlockHandler(ScreenPtr pScreen, void *timeout); 273 274extern _X_EXPORT void DRISwapContext(int drmFD, void *oldctx, void *newctx); 275 276extern _X_EXPORT void *DRIGetContextStore(DRIContextPrivPtr context); 277 278extern _X_EXPORT void DRIWindowExposures(WindowPtr pWin, RegionPtr prgn); 279 280extern _X_EXPORT Bool DRIDestroyWindow(WindowPtr pWin); 281 282extern _X_EXPORT void DRICopyWindow(WindowPtr pWin, 283 DDXPointRec ptOldOrg, RegionPtr prgnSrc); 284 285extern _X_EXPORT void DRIClipNotify(WindowPtr pWin, int dx, int dy); 286 287extern _X_EXPORT CARD32 DRIGetDrawableIndex(WindowPtr pWin); 288 289extern _X_EXPORT void DRIPrintDrawableLock(ScreenPtr pScreen, char *msg); 290 291extern _X_EXPORT void DRILock(ScreenPtr pScreen, int flags); 292 293extern _X_EXPORT void DRIUnlock(ScreenPtr pScreen); 294 295extern _X_EXPORT DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen); 296 297extern _X_EXPORT void *DRIGetSAREAPrivate(ScreenPtr pScreen); 298 299extern _X_EXPORT unsigned int DRIGetDrawableStamp(ScreenPtr pScreen, 300 CARD32 drawable_index); 301 302extern _X_EXPORT DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen, 303 drm_context_t * 304 pHWContext, 305 DRIContextFlags flags); 306 307extern _X_EXPORT DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr 308 pScreen, 309 drm_context_t 310 hHWContext, 311 DRIContextFlags 312 flags); 313 314extern _X_EXPORT Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv); 315 316extern _X_EXPORT drm_context_t DRIGetContext(ScreenPtr pScreen); 317 318extern _X_EXPORT void DRIQueryVersion(int *majorVersion, 319 int *minorVersion, int *patchVersion); 320 321extern _X_EXPORT void DRIAdjustFrame(ScrnInfoPtr pScrn, int x, int y); 322 323extern _X_EXPORT void DRIMoveBuffersHelper(ScreenPtr pScreen, 324 int dx, 325 int dy, 326 int *xdir, int *ydir, RegionPtr reg); 327 328extern _X_EXPORT int DRIMasterFD(ScrnInfoPtr pScrn); 329 330extern _X_EXPORT void *DRIMasterSareaPointer(ScrnInfoPtr pScrn); 331 332extern _X_EXPORT drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn); 333 334extern _X_EXPORT void DRIGetTexOffsetFuncs(ScreenPtr pScreen, 335 DRITexOffsetStartProcPtr * 336 texOffsetStartFunc, 337 DRITexOffsetFinishProcPtr * 338 texOffsetFinishFunc); 339 340#define _DRI_H_ 341 342#endif 343