105b261ecSmrg/************************************************************************** 205b261ecSmrg 305b261ecSmrgCopyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. 405b261ecSmrgAll Rights Reserved. 505b261ecSmrg 605b261ecSmrgPermission is hereby granted, free of charge, to any person obtaining a 705b261ecSmrgcopy of this software and associated documentation files (the 805b261ecSmrg"Software"), to deal in the Software without restriction, including 905b261ecSmrgwithout limitation the rights to use, copy, modify, merge, publish, 1005b261ecSmrgdistribute, sub license, and/or sell copies of the Software, and to 1105b261ecSmrgpermit persons to whom the Software is furnished to do so, subject to 1205b261ecSmrgthe following conditions: 1305b261ecSmrg 1405b261ecSmrgThe above copyright notice and this permission notice (including the 1505b261ecSmrgnext paragraph) shall be included in all copies or substantial portions 1605b261ecSmrgof the Software. 1705b261ecSmrg 1805b261ecSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1905b261ecSmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2005b261ecSmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 2105b261ecSmrgIN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 2205b261ecSmrgANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 2305b261ecSmrgTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 2405b261ecSmrgSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2505b261ecSmrg 2605b261ecSmrg**************************************************************************/ 2705b261ecSmrg 2805b261ecSmrg/* 2905b261ecSmrg * Authors: 3005b261ecSmrg * Jens Owen <jens@tungstengraphics.com> 3105b261ecSmrg * 3205b261ecSmrg */ 3305b261ecSmrg 3405b261ecSmrg/* Prototypes for DRI functions */ 3505b261ecSmrg 3605b261ecSmrg#ifndef _DRI_H_ 3705b261ecSmrg 384642e01fSmrg#include <pciaccess.h> 394642e01fSmrg 4005b261ecSmrg#include "scrnintstr.h" 4105b261ecSmrg#include "xf86dri.h" 4205b261ecSmrg 4305b261ecSmrgtypedef int DRISyncType; 4405b261ecSmrg 4505b261ecSmrg#define DRI_NO_SYNC 0 4605b261ecSmrg#define DRI_2D_SYNC 1 4705b261ecSmrg#define DRI_3D_SYNC 2 4805b261ecSmrg 4905b261ecSmrgtypedef int DRIContextType; 5005b261ecSmrg 5105b261ecSmrgtypedef struct _DRIContextPrivRec DRIContextPrivRec, *DRIContextPrivPtr; 5205b261ecSmrg 5335c4bbdfSmrgtypedef enum _DRIContextFlags { 5435c4bbdfSmrg DRI_CONTEXT_2DONLY = 0x01, 5505b261ecSmrg DRI_CONTEXT_PRESERVED = 0x02, 5635c4bbdfSmrg DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */ 5705b261ecSmrg} DRIContextFlags; 5805b261ecSmrg 5905b261ecSmrg#define DRI_NO_CONTEXT 0 6005b261ecSmrg#define DRI_2D_CONTEXT 1 6105b261ecSmrg#define DRI_3D_CONTEXT 2 6205b261ecSmrg 6305b261ecSmrgtypedef int DRISwapMethod; 6405b261ecSmrg 6505b261ecSmrg#define DRI_HIDE_X_CONTEXT 0 6605b261ecSmrg#define DRI_SERVER_SWAP 1 6705b261ecSmrg#define DRI_KERNEL_SWAP 2 6805b261ecSmrg 6905b261ecSmrgtypedef int DRIWindowRequests; 7005b261ecSmrg 7105b261ecSmrg#define DRI_NO_WINDOWS 0 7205b261ecSmrg#define DRI_3D_WINDOWS_ONLY 1 7305b261ecSmrg#define DRI_ALL_WINDOWS 2 7405b261ecSmrg 7535c4bbdfSmrgtypedef void (*ClipNotifyPtr) (WindowPtr, int, int); 7635c4bbdfSmrgtypedef void (*AdjustFramePtr) (ScrnInfoPtr pScrn, int x, int y); 7705b261ecSmrg 7805b261ecSmrg/* 7905b261ecSmrg * These functions can be wrapped by the DRI. Each of these have 8005b261ecSmrg * generic default funcs (initialized in DRICreateInfoRec) and can be 8105b261ecSmrg * overridden by the driver in its [driver]DRIScreenInit function. 8205b261ecSmrg */ 8305b261ecSmrgtypedef struct { 8435c4bbdfSmrg ScreenWakeupHandlerProcPtr WakeupHandler; 8535c4bbdfSmrg ScreenBlockHandlerProcPtr BlockHandler; 8635c4bbdfSmrg WindowExposuresProcPtr WindowExposures; 8735c4bbdfSmrg CopyWindowProcPtr CopyWindow; 8835c4bbdfSmrg ClipNotifyProcPtr ClipNotify; 8935c4bbdfSmrg AdjustFramePtr AdjustFrame; 9005b261ecSmrg} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr; 9105b261ecSmrg 9205b261ecSmrg/* 9305b261ecSmrg * Prior to Xorg 6.8.99.8, the DRIInfoRec structure was implicitly versioned 9405b261ecSmrg * by the XF86DRI_*_VERSION defines in xf86dristr.h. These numbers were also 9505b261ecSmrg * being used to version the XFree86-DRI protocol. Bugs #3066 and #3163 9605b261ecSmrg * showed that this was inadequate. The DRIInfoRec structure is now versioned 9705b261ecSmrg * by the DRIINFO_*_VERSION defines in this file. - ajax, 2005-05-18. 9805b261ecSmrg * 9905b261ecSmrg * Revision history: 10005b261ecSmrg * 4.1.0 and earlier: DRIQueryVersion returns XF86DRI_*_VERSION. 10105b261ecSmrg * 4.2.0: DRIQueryVersion begins returning DRIINFO_*_VERSION. 10205b261ecSmrg * 5.0.0: frameBufferPhysicalAddress changed from CARD32 to pointer. 10305b261ecSmrg */ 10405b261ecSmrg 10505b261ecSmrg#define DRIINFO_MAJOR_VERSION 5 10605b261ecSmrg#define DRIINFO_MINOR_VERSION 4 10705b261ecSmrg#define DRIINFO_PATCH_VERSION 0 10805b261ecSmrg 10935c4bbdfSmrgtypedef unsigned long long (*DRITexOffsetStartProcPtr) (PixmapPtr pPix); 11035c4bbdfSmrgtypedef void (*DRITexOffsetFinishProcPtr) (PixmapPtr pPix); 11105b261ecSmrg 11205b261ecSmrgtypedef struct { 11305b261ecSmrg /* driver call back functions 11405b261ecSmrg * 11505b261ecSmrg * New fields should be added at the end for backwards compatibility. 11605b261ecSmrg * Bump the DRIINFO patch number to indicate bugfixes. 11705b261ecSmrg * Bump the DRIINFO minor number to indicate new fields. 11805b261ecSmrg * Bump the DRIINFO major number to indicate binary-incompatible changes. 11905b261ecSmrg */ 12035c4bbdfSmrg Bool (*CreateContext) (ScreenPtr pScreen, 12135c4bbdfSmrg VisualPtr visual, 12235c4bbdfSmrg drm_context_t hHWContext, 12335c4bbdfSmrg void *pVisualConfigPriv, DRIContextType context); 12435c4bbdfSmrg void (*DestroyContext) (ScreenPtr pScreen, 12535c4bbdfSmrg drm_context_t hHWContext, DRIContextType context); 12635c4bbdfSmrg void (*SwapContext) (ScreenPtr pScreen, 12735c4bbdfSmrg DRISyncType syncType, 12835c4bbdfSmrg DRIContextType readContextType, 12935c4bbdfSmrg void *readContextStore, 13035c4bbdfSmrg DRIContextType writeContextType, 13135c4bbdfSmrg void *writeContextStore); 13235c4bbdfSmrg void (*InitBuffers) (WindowPtr pWin, RegionPtr prgn, CARD32 indx); 13335c4bbdfSmrg void (*MoveBuffers) (WindowPtr pWin, 13435c4bbdfSmrg DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 indx); 13535c4bbdfSmrg void (*TransitionTo3d) (ScreenPtr pScreen); 13635c4bbdfSmrg void (*TransitionTo2d) (ScreenPtr pScreen); 13735c4bbdfSmrg 13835c4bbdfSmrg void (*SetDrawableIndex) (WindowPtr pWin, CARD32 indx); 13935c4bbdfSmrg Bool (*OpenFullScreen) (ScreenPtr pScreen); 14035c4bbdfSmrg Bool (*CloseFullScreen) (ScreenPtr pScreen); 14105b261ecSmrg 14205b261ecSmrg /* wrapped functions */ 14335c4bbdfSmrg DRIWrappedFuncsRec wrap; 14405b261ecSmrg 14505b261ecSmrg /* device info */ 14635c4bbdfSmrg char *drmDriverName; 14735c4bbdfSmrg char *clientDriverName; 14835c4bbdfSmrg char *busIdString; 14935c4bbdfSmrg int ddxDriverMajorVersion; 15035c4bbdfSmrg int ddxDriverMinorVersion; 15135c4bbdfSmrg int ddxDriverPatchVersion; 15235c4bbdfSmrg void *frameBufferPhysicalAddress; 15335c4bbdfSmrg long frameBufferSize; 15435c4bbdfSmrg long frameBufferStride; 15535c4bbdfSmrg long SAREASize; 15635c4bbdfSmrg int maxDrawableTableEntry; 15735c4bbdfSmrg int ddxDrawableTableEntry; 15835c4bbdfSmrg long contextSize; 15935c4bbdfSmrg DRISwapMethod driverSwapMethod; 16035c4bbdfSmrg DRIWindowRequests bufferRequests; 16135c4bbdfSmrg int devPrivateSize; 16235c4bbdfSmrg void *devPrivate; 16335c4bbdfSmrg Bool createDummyCtx; 16435c4bbdfSmrg Bool createDummyCtxPriv; 16505b261ecSmrg 16605b261ecSmrg /* New with DRI version 4.1.0 */ 16735c4bbdfSmrg void (*TransitionSingleToMulti3D) (ScreenPtr pScreen); 16835c4bbdfSmrg void (*TransitionMultiToSingle3D) (ScreenPtr pScreen); 16905b261ecSmrg 17005b261ecSmrg /* New with DRI version 5.1.0 */ 17135c4bbdfSmrg void (*ClipNotify) (ScreenPtr pScreen, WindowPtr *ppWin, int num); 17205b261ecSmrg 17305b261ecSmrg /* New with DRI version 5.2.0 */ 17435c4bbdfSmrg Bool allocSarea; 17535c4bbdfSmrg Bool keepFDOpen; 17605b261ecSmrg 17705b261ecSmrg /* New with DRI version 5.3.0 */ 17835c4bbdfSmrg DRITexOffsetStartProcPtr texOffsetStart; 17905b261ecSmrg DRITexOffsetFinishProcPtr texOffsetFinish; 18005b261ecSmrg 18105b261ecSmrg /* New with DRI version 5.4.0 */ 18235c4bbdfSmrg int dontMapFrameBuffer; 18335c4bbdfSmrg drm_handle_t hFrameBuffer; /* Handle to framebuffer, either 18435c4bbdfSmrg * mapped by DDX driver or DRI */ 18505b261ecSmrg 18635c4bbdfSmrg} DRIInfoRec, *DRIInfoPtr; 18705b261ecSmrg 18835c4bbdfSmrgextern _X_EXPORT Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, 18935c4bbdfSmrg unsigned long sAreaSize, 19035c4bbdfSmrg const char *busID, 19135c4bbdfSmrg const char *drmDriverName); 19205b261ecSmrg 1936747b715Smrgextern _X_EXPORT Bool DRIScreenInit(ScreenPtr pScreen, 19435c4bbdfSmrg DRIInfoPtr pDRIInfo, int *pDRMFD); 19505b261ecSmrg 1966747b715Smrgextern _X_EXPORT void DRICloseScreen(ScreenPtr pScreen); 19705b261ecSmrg 19835c4bbdfSmrgextern Bool DRIExtensionInit(void); 19905b261ecSmrg 2006747b715Smrgextern _X_EXPORT void DRIReset(void); 20105b261ecSmrg 2026747b715Smrgextern _X_EXPORT Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, 20335c4bbdfSmrg Bool *isCapable); 20405b261ecSmrg 2056747b715Smrgextern _X_EXPORT Bool DRIOpenConnection(ScreenPtr pScreen, 20635c4bbdfSmrg drm_handle_t * hSAREA, 20735c4bbdfSmrg char **busIdString); 20805b261ecSmrg 2096747b715Smrgextern _X_EXPORT Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic); 21005b261ecSmrg 2116747b715Smrgextern _X_EXPORT Bool DRICloseConnection(ScreenPtr pScreen); 21205b261ecSmrg 2136747b715Smrgextern _X_EXPORT Bool DRIGetClientDriverName(ScreenPtr pScreen, 21435c4bbdfSmrg int *ddxDriverMajorVersion, 21535c4bbdfSmrg int *ddxDriverMinorVersion, 21635c4bbdfSmrg int *ddxDriverPatchVersion, 21735c4bbdfSmrg char **clientDriverName); 21805b261ecSmrg 2196747b715Smrgextern _X_EXPORT Bool DRICreateContext(ScreenPtr pScreen, 22035c4bbdfSmrg VisualPtr visual, 22135c4bbdfSmrg XID context, drm_context_t * pHWContext); 22205b261ecSmrg 2236747b715Smrgextern _X_EXPORT Bool DRIDestroyContext(ScreenPtr pScreen, XID context); 22405b261ecSmrg 22535c4bbdfSmrgextern _X_EXPORT Bool DRIContextPrivDelete(void *pResource, XID id); 22605b261ecSmrg 2276747b715Smrgextern _X_EXPORT Bool DRICreateDrawable(ScreenPtr pScreen, 22835c4bbdfSmrg ClientPtr client, 22935c4bbdfSmrg DrawablePtr pDrawable, 23035c4bbdfSmrg drm_drawable_t * hHWDrawable); 23105b261ecSmrg 2326747b715Smrgextern _X_EXPORT Bool DRIDestroyDrawable(ScreenPtr pScreen, 23335c4bbdfSmrg ClientPtr client, 23435c4bbdfSmrg DrawablePtr pDrawable); 23505b261ecSmrg 23635c4bbdfSmrgextern _X_EXPORT Bool DRIDrawablePrivDelete(void *pResource, XID id); 23705b261ecSmrg 2386747b715Smrgextern _X_EXPORT Bool DRIGetDrawableInfo(ScreenPtr pScreen, 23935c4bbdfSmrg DrawablePtr pDrawable, 24035c4bbdfSmrg unsigned int *indx, 24135c4bbdfSmrg unsigned int *stamp, 24235c4bbdfSmrg int *X, 24335c4bbdfSmrg int *Y, 24435c4bbdfSmrg int *W, 24535c4bbdfSmrg int *H, 24635c4bbdfSmrg int *numClipRects, 24735c4bbdfSmrg drm_clip_rect_t ** pClipRects, 24835c4bbdfSmrg int *backX, 24935c4bbdfSmrg int *backY, 25035c4bbdfSmrg int *numBackClipRects, 25135c4bbdfSmrg drm_clip_rect_t ** pBackClipRects); 25205b261ecSmrg 2536747b715Smrgextern _X_EXPORT Bool DRIGetDeviceInfo(ScreenPtr pScreen, 25435c4bbdfSmrg drm_handle_t * hFrameBuffer, 25535c4bbdfSmrg int *fbOrigin, 25635c4bbdfSmrg int *fbSize, 25735c4bbdfSmrg int *fbStride, 25835c4bbdfSmrg int *devPrivateSize, void **pDevPrivate); 25905b261ecSmrg 2606747b715Smrgextern _X_EXPORT DRIInfoPtr DRICreateInfoRec(void); 26105b261ecSmrg 2626747b715Smrgextern _X_EXPORT void DRIDestroyInfoRec(DRIInfoPtr DRIInfo); 26305b261ecSmrg 2646747b715Smrgextern _X_EXPORT Bool DRIFinishScreenInit(ScreenPtr pScreen); 26505b261ecSmrg 2661b5d61b8Smrgextern _X_EXPORT void DRIWakeupHandler(void *wakeupData, int result); 26705b261ecSmrg 2681b5d61b8Smrgextern _X_EXPORT void DRIBlockHandler(void *blockData, void *timeout); 26905b261ecSmrg 2701b5d61b8Smrgextern _X_EXPORT void DRIDoWakeupHandler(ScreenPtr pScreen, int result); 27105b261ecSmrg 2721b5d61b8Smrgextern _X_EXPORT void DRIDoBlockHandler(ScreenPtr pScreen, void *timeout); 27305b261ecSmrg 27435c4bbdfSmrgextern _X_EXPORT void DRISwapContext(int drmFD, void *oldctx, void *newctx); 27505b261ecSmrg 2766747b715Smrgextern _X_EXPORT void *DRIGetContextStore(DRIContextPrivPtr context); 27705b261ecSmrg 27835c4bbdfSmrgextern _X_EXPORT void DRIWindowExposures(WindowPtr pWin, RegionPtr prgn); 27905b261ecSmrg 2806747b715Smrgextern _X_EXPORT Bool DRIDestroyWindow(WindowPtr pWin); 28105b261ecSmrg 2826747b715Smrgextern _X_EXPORT void DRICopyWindow(WindowPtr pWin, 28335c4bbdfSmrg DDXPointRec ptOldOrg, RegionPtr prgnSrc); 28405b261ecSmrg 28535c4bbdfSmrgextern _X_EXPORT void DRIClipNotify(WindowPtr pWin, int dx, int dy); 28605b261ecSmrg 2876747b715Smrgextern _X_EXPORT CARD32 DRIGetDrawableIndex(WindowPtr pWin); 28805b261ecSmrg 2896747b715Smrgextern _X_EXPORT void DRIPrintDrawableLock(ScreenPtr pScreen, char *msg); 29005b261ecSmrg 2916747b715Smrgextern _X_EXPORT void DRILock(ScreenPtr pScreen, int flags); 29205b261ecSmrg 2936747b715Smrgextern _X_EXPORT void DRIUnlock(ScreenPtr pScreen); 29405b261ecSmrg 2956747b715Smrgextern _X_EXPORT DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen); 29605b261ecSmrg 2976747b715Smrgextern _X_EXPORT void *DRIGetSAREAPrivate(ScreenPtr pScreen); 29805b261ecSmrg 2996747b715Smrgextern _X_EXPORT unsigned int DRIGetDrawableStamp(ScreenPtr pScreen, 30035c4bbdfSmrg CARD32 drawable_index); 30105b261ecSmrg 3026747b715Smrgextern _X_EXPORT DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen, 30335c4bbdfSmrg drm_context_t * 30435c4bbdfSmrg pHWContext, 30505b261ecSmrg DRIContextFlags flags); 30605b261ecSmrg 30735c4bbdfSmrgextern _X_EXPORT DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr 30835c4bbdfSmrg pScreen, 30935c4bbdfSmrg drm_context_t 31035c4bbdfSmrg hHWContext, 31135c4bbdfSmrg DRIContextFlags 31235c4bbdfSmrg flags); 31335c4bbdfSmrg 3146747b715Smrgextern _X_EXPORT Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv); 31505b261ecSmrg 3166747b715Smrgextern _X_EXPORT drm_context_t DRIGetContext(ScreenPtr pScreen); 31705b261ecSmrg 3186747b715Smrgextern _X_EXPORT void DRIQueryVersion(int *majorVersion, 31935c4bbdfSmrg int *minorVersion, int *patchVersion); 32005b261ecSmrg 32135c4bbdfSmrgextern _X_EXPORT void DRIAdjustFrame(ScrnInfoPtr pScrn, int x, int y); 32205b261ecSmrg 3236747b715Smrgextern _X_EXPORT void DRIMoveBuffersHelper(ScreenPtr pScreen, 32435c4bbdfSmrg int dx, 32535c4bbdfSmrg int dy, 32635c4bbdfSmrg int *xdir, int *ydir, RegionPtr reg); 32705b261ecSmrg 3286747b715Smrgextern _X_EXPORT int DRIMasterFD(ScrnInfoPtr pScrn); 32905b261ecSmrg 3306747b715Smrgextern _X_EXPORT void *DRIMasterSareaPointer(ScrnInfoPtr pScrn); 33105b261ecSmrg 3326747b715Smrgextern _X_EXPORT drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn); 33305b261ecSmrg 3346747b715Smrgextern _X_EXPORT void DRIGetTexOffsetFuncs(ScreenPtr pScreen, 33535c4bbdfSmrg DRITexOffsetStartProcPtr * 33635c4bbdfSmrg texOffsetStartFunc, 33735c4bbdfSmrg DRITexOffsetFinishProcPtr * 33835c4bbdfSmrg texOffsetFinishFunc); 33905b261ecSmrg 34005b261ecSmrg#define _DRI_H_ 34105b261ecSmrg 34205b261ecSmrg#endif 343