dri.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. /**************************************************************************
  2. Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
  3. All Rights Reserved.
  4. Permission is hereby granted, free of charge, to any person obtaining a
  5. copy of this software and associated documentation files (the
  6. "Software"), to deal in the Software without restriction, including
  7. without limitation the rights to use, copy, modify, merge, publish,
  8. distribute, sub license, and/or sell copies of the Software, and to
  9. permit persons to whom the Software is furnished to do so, subject to
  10. the following conditions:
  11. The above copyright notice and this permission notice (including the
  12. next paragraph) shall be included in all copies or substantial portions
  13. of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  17. IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
  18. ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  19. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  20. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. **************************************************************************/
  22. /*
  23. * Authors:
  24. * Jens Owen <jens@tungstengraphics.com>
  25. *
  26. */
  27. /* Prototypes for DRI functions */
  28. #ifndef _DRI_H_
  29. #include <pciaccess.h>
  30. #include "scrnintstr.h"
  31. #include "xf86dri.h"
  32. typedef int DRISyncType;
  33. #define DRI_NO_SYNC 0
  34. #define DRI_2D_SYNC 1
  35. #define DRI_3D_SYNC 2
  36. typedef int DRIContextType;
  37. typedef struct _DRIContextPrivRec DRIContextPrivRec, *DRIContextPrivPtr;
  38. typedef enum _DRIContextFlags {
  39. DRI_CONTEXT_2DONLY = 0x01,
  40. DRI_CONTEXT_PRESERVED = 0x02,
  41. DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */
  42. } DRIContextFlags;
  43. #define DRI_NO_CONTEXT 0
  44. #define DRI_2D_CONTEXT 1
  45. #define DRI_3D_CONTEXT 2
  46. typedef int DRISwapMethod;
  47. #define DRI_HIDE_X_CONTEXT 0
  48. #define DRI_SERVER_SWAP 1
  49. #define DRI_KERNEL_SWAP 2
  50. typedef int DRIWindowRequests;
  51. #define DRI_NO_WINDOWS 0
  52. #define DRI_3D_WINDOWS_ONLY 1
  53. #define DRI_ALL_WINDOWS 2
  54. typedef void (*ClipNotifyPtr) (WindowPtr, int, int);
  55. typedef void (*AdjustFramePtr) (ScrnInfoPtr pScrn, int x, int y);
  56. /*
  57. * These functions can be wrapped by the DRI. Each of these have
  58. * generic default funcs (initialized in DRICreateInfoRec) and can be
  59. * overridden by the driver in its [driver]DRIScreenInit function.
  60. */
  61. typedef struct {
  62. ScreenWakeupHandlerProcPtr WakeupHandler;
  63. ScreenBlockHandlerProcPtr BlockHandler;
  64. WindowExposuresProcPtr WindowExposures;
  65. CopyWindowProcPtr CopyWindow;
  66. ValidateTreeProcPtr ValidateTree;
  67. PostValidateTreeProcPtr PostValidateTree;
  68. ClipNotifyProcPtr ClipNotify;
  69. AdjustFramePtr AdjustFrame;
  70. } DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
  71. /*
  72. * Prior to Xorg 6.8.99.8, the DRIInfoRec structure was implicitly versioned
  73. * by the XF86DRI_*_VERSION defines in xf86dristr.h. These numbers were also
  74. * being used to version the XFree86-DRI protocol. Bugs #3066 and #3163
  75. * showed that this was inadequate. The DRIInfoRec structure is now versioned
  76. * by the DRIINFO_*_VERSION defines in this file. - ajax, 2005-05-18.
  77. *
  78. * Revision history:
  79. * 4.1.0 and earlier: DRIQueryVersion returns XF86DRI_*_VERSION.
  80. * 4.2.0: DRIQueryVersion begins returning DRIINFO_*_VERSION.
  81. * 5.0.0: frameBufferPhysicalAddress changed from CARD32 to pointer.
  82. */
  83. #define DRIINFO_MAJOR_VERSION 5
  84. #define DRIINFO_MINOR_VERSION 4
  85. #define DRIINFO_PATCH_VERSION 0
  86. typedef unsigned long long (*DRITexOffsetStartProcPtr) (PixmapPtr pPix);
  87. typedef void (*DRITexOffsetFinishProcPtr) (PixmapPtr pPix);
  88. typedef struct {
  89. /* driver call back functions
  90. *
  91. * New fields should be added at the end for backwards compatibility.
  92. * Bump the DRIINFO patch number to indicate bugfixes.
  93. * Bump the DRIINFO minor number to indicate new fields.
  94. * Bump the DRIINFO major number to indicate binary-incompatible changes.
  95. */
  96. Bool (*CreateContext) (ScreenPtr pScreen,
  97. VisualPtr visual,
  98. drm_context_t hHWContext,
  99. void *pVisualConfigPriv, DRIContextType context);
  100. void (*DestroyContext) (ScreenPtr pScreen,
  101. drm_context_t hHWContext, DRIContextType context);
  102. void (*SwapContext) (ScreenPtr pScreen,
  103. DRISyncType syncType,
  104. DRIContextType readContextType,
  105. void *readContextStore,
  106. DRIContextType writeContextType,
  107. void *writeContextStore);
  108. void (*InitBuffers) (WindowPtr pWin, RegionPtr prgn, CARD32 indx);
  109. void (*MoveBuffers) (WindowPtr pWin,
  110. DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 indx);
  111. void (*TransitionTo3d) (ScreenPtr pScreen);
  112. void (*TransitionTo2d) (ScreenPtr pScreen);
  113. void (*SetDrawableIndex) (WindowPtr pWin, CARD32 indx);
  114. Bool (*OpenFullScreen) (ScreenPtr pScreen);
  115. Bool (*CloseFullScreen) (ScreenPtr pScreen);
  116. /* wrapped functions */
  117. DRIWrappedFuncsRec wrap;
  118. /* device info */
  119. char *drmDriverName;
  120. char *clientDriverName;
  121. char *busIdString;
  122. int ddxDriverMajorVersion;
  123. int ddxDriverMinorVersion;
  124. int ddxDriverPatchVersion;
  125. void *frameBufferPhysicalAddress;
  126. long frameBufferSize;
  127. long frameBufferStride;
  128. long SAREASize;
  129. int maxDrawableTableEntry;
  130. int ddxDrawableTableEntry;
  131. long contextSize;
  132. DRISwapMethod driverSwapMethod;
  133. DRIWindowRequests bufferRequests;
  134. int devPrivateSize;
  135. void *devPrivate;
  136. Bool createDummyCtx;
  137. Bool createDummyCtxPriv;
  138. /* New with DRI version 4.1.0 */
  139. void (*TransitionSingleToMulti3D) (ScreenPtr pScreen);
  140. void (*TransitionMultiToSingle3D) (ScreenPtr pScreen);
  141. /* New with DRI version 5.1.0 */
  142. void (*ClipNotify) (ScreenPtr pScreen, WindowPtr *ppWin, int num);
  143. /* New with DRI version 5.2.0 */
  144. Bool allocSarea;
  145. Bool keepFDOpen;
  146. /* New with DRI version 5.3.0 */
  147. DRITexOffsetStartProcPtr texOffsetStart;
  148. DRITexOffsetFinishProcPtr texOffsetFinish;
  149. /* New with DRI version 5.4.0 */
  150. int dontMapFrameBuffer;
  151. drm_handle_t hFrameBuffer; /* Handle to framebuffer, either
  152. * mapped by DDX driver or DRI */
  153. } DRIInfoRec, *DRIInfoPtr;
  154. extern _X_EXPORT Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn,
  155. unsigned long sAreaSize,
  156. const char *busID,
  157. const char *drmDriverName);
  158. extern _X_EXPORT Bool DRIScreenInit(ScreenPtr pScreen,
  159. DRIInfoPtr pDRIInfo, int *pDRMFD);
  160. extern _X_EXPORT void DRICloseScreen(ScreenPtr pScreen);
  161. extern Bool DRIExtensionInit(void);
  162. extern _X_EXPORT void DRIReset(void);
  163. extern _X_EXPORT Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen,
  164. Bool *isCapable);
  165. extern _X_EXPORT Bool DRIOpenConnection(ScreenPtr pScreen,
  166. drm_handle_t * hSAREA,
  167. char **busIdString);
  168. extern _X_EXPORT Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic);
  169. extern _X_EXPORT Bool DRICloseConnection(ScreenPtr pScreen);
  170. extern _X_EXPORT Bool DRIGetClientDriverName(ScreenPtr pScreen,
  171. int *ddxDriverMajorVersion,
  172. int *ddxDriverMinorVersion,
  173. int *ddxDriverPatchVersion,
  174. char **clientDriverName);
  175. extern _X_EXPORT Bool DRICreateContext(ScreenPtr pScreen,
  176. VisualPtr visual,
  177. XID context, drm_context_t * pHWContext);
  178. extern _X_EXPORT Bool DRIDestroyContext(ScreenPtr pScreen, XID context);
  179. extern _X_EXPORT Bool DRIContextPrivDelete(void *pResource, XID id);
  180. extern _X_EXPORT Bool DRICreateDrawable(ScreenPtr pScreen,
  181. ClientPtr client,
  182. DrawablePtr pDrawable,
  183. drm_drawable_t * hHWDrawable);
  184. extern _X_EXPORT Bool DRIDestroyDrawable(ScreenPtr pScreen,
  185. ClientPtr client,
  186. DrawablePtr pDrawable);
  187. extern _X_EXPORT Bool DRIDrawablePrivDelete(void *pResource, XID id);
  188. extern _X_EXPORT Bool DRIGetDrawableInfo(ScreenPtr pScreen,
  189. DrawablePtr pDrawable,
  190. unsigned int *indx,
  191. unsigned int *stamp,
  192. int *X,
  193. int *Y,
  194. int *W,
  195. int *H,
  196. int *numClipRects,
  197. drm_clip_rect_t ** pClipRects,
  198. int *backX,
  199. int *backY,
  200. int *numBackClipRects,
  201. drm_clip_rect_t ** pBackClipRects);
  202. extern _X_EXPORT Bool DRIGetDeviceInfo(ScreenPtr pScreen,
  203. drm_handle_t * hFrameBuffer,
  204. int *fbOrigin,
  205. int *fbSize,
  206. int *fbStride,
  207. int *devPrivateSize, void **pDevPrivate);
  208. extern _X_EXPORT DRIInfoPtr DRICreateInfoRec(void);
  209. extern _X_EXPORT void DRIDestroyInfoRec(DRIInfoPtr DRIInfo);
  210. extern _X_EXPORT Bool DRIFinishScreenInit(ScreenPtr pScreen);
  211. extern _X_EXPORT void DRIWakeupHandler(void *wakeupData,
  212. int result, void *pReadmask);
  213. extern _X_EXPORT void DRIBlockHandler(void *blockData,
  214. OSTimePtr pTimeout, void *pReadmask);
  215. extern _X_EXPORT void DRIDoWakeupHandler(ScreenPtr pScreen,
  216. unsigned long result,
  217. void *pReadmask);
  218. extern _X_EXPORT void DRIDoBlockHandler(ScreenPtr pScreen,
  219. void *pTimeout, void *pReadmask);
  220. extern _X_EXPORT void DRISwapContext(int drmFD, void *oldctx, void *newctx);
  221. extern _X_EXPORT void *DRIGetContextStore(DRIContextPrivPtr context);
  222. extern _X_EXPORT void DRIWindowExposures(WindowPtr pWin,
  223. RegionPtr prgn, RegionPtr bsreg);
  224. extern _X_EXPORT Bool DRIDestroyWindow(WindowPtr pWin);
  225. extern _X_EXPORT void DRICopyWindow(WindowPtr pWin,
  226. DDXPointRec ptOldOrg, RegionPtr prgnSrc);
  227. extern _X_EXPORT int DRIValidateTree(WindowPtr pParent,
  228. WindowPtr pChild, VTKind kind);
  229. extern _X_EXPORT void DRIPostValidateTree(WindowPtr pParent,
  230. WindowPtr pChild, VTKind kind);
  231. extern _X_EXPORT void DRIClipNotify(WindowPtr pWin, int dx, int dy);
  232. extern _X_EXPORT CARD32 DRIGetDrawableIndex(WindowPtr pWin);
  233. extern _X_EXPORT void DRIPrintDrawableLock(ScreenPtr pScreen, char *msg);
  234. extern _X_EXPORT void DRILock(ScreenPtr pScreen, int flags);
  235. extern _X_EXPORT void DRIUnlock(ScreenPtr pScreen);
  236. extern _X_EXPORT DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen);
  237. extern _X_EXPORT void *DRIGetSAREAPrivate(ScreenPtr pScreen);
  238. extern _X_EXPORT unsigned int DRIGetDrawableStamp(ScreenPtr pScreen,
  239. CARD32 drawable_index);
  240. extern _X_EXPORT DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen,
  241. drm_context_t *
  242. pHWContext,
  243. DRIContextFlags flags);
  244. extern _X_EXPORT DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr
  245. pScreen,
  246. drm_context_t
  247. hHWContext,
  248. DRIContextFlags
  249. flags);
  250. extern _X_EXPORT Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv);
  251. extern _X_EXPORT drm_context_t DRIGetContext(ScreenPtr pScreen);
  252. extern _X_EXPORT void DRIQueryVersion(int *majorVersion,
  253. int *minorVersion, int *patchVersion);
  254. extern _X_EXPORT void DRIAdjustFrame(ScrnInfoPtr pScrn, int x, int y);
  255. extern _X_EXPORT void DRIMoveBuffersHelper(ScreenPtr pScreen,
  256. int dx,
  257. int dy,
  258. int *xdir, int *ydir, RegionPtr reg);
  259. extern _X_EXPORT char *DRICreatePCIBusID(const struct pci_device *PciInfo);
  260. #if 0
  261. extern _X_EXPORT int drmInstallSIGIOHandler(int fd,
  262. void (*f) (int, void *, void *));
  263. extern _X_EXPORT int drmRemoveSIGIOHandler(int fd);
  264. #endif
  265. extern _X_EXPORT int DRIMasterFD(ScrnInfoPtr pScrn);
  266. extern _X_EXPORT void *DRIMasterSareaPointer(ScrnInfoPtr pScrn);
  267. extern _X_EXPORT drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn);
  268. extern _X_EXPORT void DRIGetTexOffsetFuncs(ScreenPtr pScreen,
  269. DRITexOffsetStartProcPtr *
  270. texOffsetStartFunc,
  271. DRITexOffsetFinishProcPtr *
  272. texOffsetFinishFunc);
  273. #define _DRI_H_
  274. #endif