[Openchrome-devel] Fix for non-dri build.

Owain Ainsworth zerooa
Thu Jan 8 15:22:38 PST 2009


Hi,

This patch results from OpenBSD's effort to transition to using kernel
DRM headers instead of providing them with libdrm  -- thus avoiding
header mismatches if one isn't updated. We don't have the via drm module,
and won't until there's time to write it with memory management, so
obviously we also lack via_drm.h in the kernel.

Now, if you have an xserver with dri enabled (so XF86DRI is defined in
the headers), but you build openchrom with --disable-dri you will still
have the XF86DRI defined, and thus the build will fail. In order to
solve this, the following diff switches XF86DRI to CHROMEDRI, to avoid
overloading the aforementioned define.

Any comments would be much welcome.

-- 
Cheers,
-0-

(OpenBSD DRM maintainer and Secondary X maintainer)
-------------- next part --------------
Index: configure.ac
===================================================================
--- configure.ac	(revision 713)
+++ configure.ac	(working copy)
@@ -110,8 +110,8 @@
 AM_CONDITIONAL(DRI, test x$DRI = xyes)
 if test "$DRI" = yes; then
         PKG_CHECK_MODULES(DRI, [libdrm xf86driproto])
-        AC_DEFINE(XF86DRI,1,[Enable DRI driver support])
-        AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
+        AC_DEFINE(CHROMEDRI,1,[Enable DRI driver support])
+        AC_DEFINE(CHROMEDRI_DEVEL,1,[Enable developmental DRI driver support])
         case "$host_cpu" in
             i*86)
                 XVMC=yes ;;
Index: src/via_video.c
===================================================================
--- src/via_video.c	(revision 713)
+++ src/via_video.c	(working copy)
@@ -513,7 +513,7 @@
 
     DBG_DD(ErrorF(" via_video.c : viaExitVideo : \n"));
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     ViaCleanupXVMC(pScrn, viaAdaptPtr, XV_ADAPT_NUM);
 #endif
 
@@ -563,7 +563,7 @@
     num_new = 0;
 
     pVia->useDmaBlit = FALSE;
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     pVia->useDmaBlit = pVia->directRenderingEnabled &&
     ((pVia->Chipset == VIA_CLE266) ||
         (pVia->Chipset == VIA_KM400) ||
@@ -617,7 +617,7 @@
 
     if (num_adaptors) {
         xf86XVScreenInit(pScreen, allAdaptors, num_adaptors);
-#ifdef XF86DRI
+#ifdef CHROMEDRI
         ViaInitXVMC(pScreen);
 #endif
         viaSetColorSpace(pVia, 0, 0, 0, 0, TRUE);
@@ -900,7 +900,7 @@
         }
         usedPorts += j;
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
         viaXvMCInitXv(pScrn, viaAdaptPtr[i]);
 #endif
 
@@ -1118,7 +1118,7 @@
             src + w * h, w >> 1, w >> 1, dstPitch, h >> 1);
 }
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 
 static int
 viaDmaBlitImage(VIAPtr pVia,
@@ -1316,7 +1316,7 @@
                 dstPitch = pVia->swov.SWDevice.dwPitch;
 
                 if (pVia->useDmaBlit) {
-#ifdef XF86DRI
+#ifdef CHROMEDRI
                     if (viaDmaBlitImage(pVia, pPriv, buf,
                         (unsigned char *)pVia->swov.SWDevice.
                         lpSWOverlaySurface[pVia->dwFrameNum & 1] -
@@ -1513,7 +1513,7 @@
             break;
         case FOURCC_XVMC:
             *h = (*h + 1) & ~1;
-#ifdef XF86DRI
+#ifdef CHROMEDRI
             size = viaXvMCPutImageSize(pScrn);
 #else
             size = 0;
Index: src/via_driver.c
===================================================================
--- src/via_driver.c	(revision 713)
+++ src/via_driver.c	(working copy)
@@ -42,7 +42,7 @@
 #include "via_video.h"
 #include "via.h"
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 #include "dri.h"
 #endif
 #include "via_vgahw.h"
@@ -394,7 +394,7 @@
 #endif
 
 #ifdef XFree86LOADER
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 static const char *drmSymbols[] = {
     "drmAddBufs",
     "drmAddMap",
@@ -497,7 +497,7 @@
                           vbeSymbols,
                           i2cSymbols,
                           ddcSymbols,
-#ifdef XF86DRI
+#ifdef CHROMEDRI
                           drmSymbols,
                           driSymbols,
 #endif
@@ -785,7 +785,7 @@
 } /* VIAProbe */
 #endif /* !XSERVER_LIBPCIACCESS */
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 static void
 kickVblank(ScrnInfoPtr pScrn)
 {
@@ -1903,7 +1903,7 @@
     if (!pVia->IsSecondary)
         viaRestoreVideo(pScrn);
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
         kickVblank(pScrn);
         VIADRIRingBufferInit(pScrn);
@@ -1919,7 +1919,7 @@
         viaAccelSyncMarker(pScrn);
     }
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
         DRIUnlock(screenInfo.screens[scrnIndex]);
     }
@@ -1938,7 +1938,7 @@
 
     DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIALeaveVT\n"));
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
         volatile drm_via_sarea_t *saPriv = (drm_via_sarea_t *)
                 DRIGetSAREAPrivate(pScrn->pScreen);
@@ -1954,7 +1954,7 @@
     if (pVia->Chipset != VIA_K8M890 && pVia->Chipset != VIA_P4M900 && pVia->Chipset != VIA_VX800)
         hwp->writeSeq(hwp, 0x1A, pVia->SavedReg.SR1A | 0x40);
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
         VIADRIRingBufferCleanup(pScrn);
         viaDRIOffscreenSave(pScrn);
@@ -2729,7 +2729,7 @@
             return FALSE;
     }
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     pVia->directRenderingEnabled = VIADRIScreenInit(pScreen);
 #endif
 
@@ -2810,7 +2810,7 @@
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- Color maps etc. set up\n"));
     pVia->agpDMA = FALSE;
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled)
         pVia->directRenderingEnabled = VIADRIFinishScreenInit(pScreen);
 
@@ -2829,14 +2829,14 @@
     if (pVia->NoAccel) {
         memset(pVia->FBBase, 0x00, pVia->videoRambytes);
     } else {
-#ifdef XF86DRI
+#ifdef CHROMEDRI
         if (pVia->directRenderingEnabled)
             DRILock(screenInfo.screens[scrnIndex], 0);
 #endif
         viaAccelFillRect(pScrn, pScrn->frameX0, pScrn->frameY0,
                          pScrn->displayWidth, pScrn->virtualY, 0x00000000);
         viaAccelSyncMarker(pScrn);
-#ifdef XF86DRI
+#ifdef CHROMEDRI
         if (pVia->directRenderingEnabled)
             DRIUnlock(screenInfo.screens[scrnIndex]);
 #endif
@@ -2987,7 +2987,7 @@
 
     /* Enable the graphics engine. */
     if (!pVia->NoAccel) {
-#if defined(XF86DRI) || defined(VIA_HAVE_EXA)
+#if defined(CHROMEDRI) || defined(VIA_HAVE_EXA)
         VIAInitialize3DEngine(pScrn);
 #endif
         viaInitialize2DEngine(pScrn);
@@ -3009,7 +3009,7 @@
 
     /* Is the display currently visible? */
     if (pScrn->vtSema) {
-#ifdef XF86DRI
+#ifdef CHROMEDRI
         if (pVia->directRenderingEnabled)
             DRILock(screenInfo.screens[scrnIndex], 0);
 #endif
@@ -3031,7 +3031,7 @@
         if (pVia->VQEnable)
             viaDisableVQ(pScrn);
     }
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled)
         VIADRICloseScreen(pScreen);
 #endif
@@ -3120,14 +3120,14 @@
 
     DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIASwitchMode\n"));
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled)
         DRILock(screenInfo.screens[scrnIndex], 0);
 #endif
 
     viaAccelSync(pScrn);
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled)
         VIADRIRingBufferCleanup(pScrn);
 #endif
@@ -3137,7 +3137,7 @@
 
     ret = VIAWriteMode(pScrn, mode);
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
         kickVblank(pScrn);
         VIADRIRingBufferInit(pScrn);
@@ -3207,7 +3207,7 @@
 
 }
 
-#if defined(XF86DRI) || defined(VIA_HAVE_EXA)
+#if defined(CHROMEDRI) || defined(VIA_HAVE_EXA)
 void
 VIAInitialize3DEngine(ScrnInfoPtr pScrn)
 {
Index: src/via_swov.c
===================================================================
--- src/via_swov.c	(revision 713)
+++ src/via_swov.c	(working copy)
@@ -32,14 +32,14 @@
 #include "xf86fbman.h"
 
 #include "via.h"
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 #include "xf86drm.h"
 #endif
 
 #include "via_driver.h"
 #include "via_priv.h"
 #include "via_swov.h"
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 #include "via_drm.h"
 #endif
 #include "via_vgahw.h"
Index: src/via_driver.h
===================================================================
--- src/via_driver.h	(revision 713)
+++ src/via_driver.h	(working copy)
@@ -71,7 +71,7 @@
 #include <pciaccess.h>
 #endif
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 #define _XF86DRI_SERVER_
 #include "sarea.h"
 #include "dri.h"
@@ -135,7 +135,7 @@
     Bool b3DRegsInitialized;
 } ViaSharedRec, *ViaSharedPtr;
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 
 #define VIA_XVMC_MAX_BUFFERS 2
 #define VIA_XVMC_MAX_CONTEXTS 4
@@ -287,7 +287,7 @@
     int                 exaScratchSize;
     char *              scratchAddr;
     Bool                noComposite;
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     drm_via_mem_t       scratchAGPBuffer;
     drm_via_mem_t       texAGPBuffer;
     unsigned            texOffset;
@@ -321,7 +321,7 @@
     Bool                HasSecondary;
     Bool                SAMM;
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     Bool		directRenderingEnabled;
     Bool                XvMCEnabled;
     DRIInfoPtr		pDRIInfo;
@@ -428,7 +428,7 @@
 } VIAEntRec, *VIAEntPtr;
 
 /* Prototypes. */
-#if defined(XF86DRI) || defined(VIA_HAVE_EXA)
+#if defined(CHROMEDRI) || defined(VIA_HAVE_EXA)
 void VIAInitialize3DEngine(ScrnInfoPtr pScrn);
 #endif 
 
@@ -486,7 +486,7 @@
 
 /* In via_xwmc.c */
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 /* Basic init and exit functions */
 void ViaInitXVMC(ScreenPtr pScreen);    
 void ViaCleanupXVMC(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr *XvAdaptors, int XvAdaptorCount);
@@ -502,7 +502,7 @@
 /* via_i2c.c */
 void ViaI2CInit(ScrnInfoPtr pScrn);
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 Bool VIADRIScreenInit(ScreenPtr pScreen);
 void VIADRICloseScreen(ScreenPtr pScreen);
 Bool VIADRIFinishScreenInit(ScreenPtr pScreen);
@@ -511,6 +511,6 @@
 void viaDRIOffscreenRestore(ScrnInfoPtr pScrn);
 void viaDRIOffscreenSave(ScrnInfoPtr pScrn);
 
-#endif /* XF86DRI */
+#endif /* CHROMEDRI */
 
 #endif /* _VIA_DRIVER_H_ */
Index: src/via_accel.c
===================================================================
--- src/via_accel.c	(revision 713)
+++ src/via_accel.c	(working copy)
@@ -215,7 +215,7 @@
     buf->has3dState = FALSE;
 }
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 /*
  * Flush the command buffer using DRM. If in PCI mode, we can bypass DRM,
  * but not for command buffers that contain 3D engine state, since then
@@ -268,7 +268,7 @@
 int
 viaSetupCBuffer(ScrnInfoPtr pScrn, ViaCommandBuffer * buf, unsigned size)
 {
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     VIAPtr pVia = VIAPTR(pScrn);
 #endif
 
@@ -284,7 +284,7 @@
     buf->rindex = 0;
     buf->has3dState = FALSE;
     buf->flushFunc = viaFlushPCI;
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
         buf->flushFunc = viaFlushDRIEnabled;
     }
@@ -1357,7 +1357,7 @@
     forceUpload = (pVia->lastToUpload != v3d);
     pVia->lastToUpload = v3d;
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
         volatile drm_via_sarea_t *saPriv = (drm_via_sarea_t *)
                 DRIGetSAREAPrivate(pScrn->pScreen);
@@ -1654,7 +1654,7 @@
             formatType == PICT_TYPE_ABGR || formatType == PICT_TYPE_ARGB);
 }
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 
 static int
 viaAccelDMADownload(ScrnInfoPtr pScrn, unsigned long fbOffset,
@@ -1978,7 +1978,7 @@
     return (err == 0);
 }
 
-#endif /* XF86DRI */
+#endif /* CHROMEDRI */
 
 static Bool
 viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
@@ -2100,7 +2100,7 @@
 static Bool
 viaIsAGP(VIAPtr pVia, PixmapPtr pPix, unsigned long *offset)
 {
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     unsigned long offs;
 
     if (pVia->directRenderingEnabled && !pVia->IsPCI) {
@@ -2287,7 +2287,7 @@
     pExa->Copy = viaExaCopy;
     pExa->DoneCopy = viaExaDoneSolidCopy;
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
 #ifdef linux
         if ((pVia->drmVerMajor > 2) ||
@@ -2305,7 +2305,7 @@
                 break;
         }
     }
-#endif /* XF86DRI */
+#endif /* CHROMEDRI */
 
     pExa->UploadToScratch = viaExaUploadToScratch;
 
@@ -2362,7 +2362,7 @@
     pExa->accel.Copy = viaExaCopy;
     pExa->accel.DoneCopy = viaExaDoneSolidCopy;
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
 #ifdef linux
         if ((pVia->drmVerMajor > 2) ||
@@ -2375,7 +2375,7 @@
         if (pVia->Chipset == VIA_K8M800)
             pExa->accel.UploadToScreen = viaExaTexUploadToScreen;
     }
-#endif /* XF86DRI */
+#endif /* CHROMEDRI */
 
     pExa->accel.UploadToScratch = viaExaUploadToScratch;
 
@@ -2442,7 +2442,7 @@
      */
 
     nPOTSupported = TRUE;
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     nPOTSupported = ((!pVia->directRenderingEnabled) ||
                      (pVia->drmVerMajor > 2) ||
                      ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor >= 11)));
@@ -2451,11 +2451,11 @@
     pVia->nPOT[1] = nPOTSupported;
 
 #ifdef VIA_HAVE_EXA
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     pVia->texAddr = NULL;
     pVia->dBounce = NULL;
     pVia->scratchAddr = NULL;
-#endif /* XF86DRI */
+#endif /* CHROMEDRI */
     if (pVia->useEXA) {
         pVia->exaDriverPtr = viaInitExa(pScreen);
         if (!pVia->exaDriverPtr) {
@@ -2495,7 +2495,7 @@
      * XAA may get slow for some undetermined reason. 
      */
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     if (pVia->directRenderingEnabled) {
         pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart) / 2;
         maxY = pScrn->virtualY + (pVia->driSize / pVia->Bpl);
@@ -2538,7 +2538,7 @@
 
 #ifdef VIA_HAVE_EXA
     if (pVia->useEXA) {
-#ifdef XF86DRI
+#ifdef CHROMEDRI
         if (pVia->directRenderingEnabled) {
             if (pVia->texAddr) {
                 drmCommandWrite(pVia->drmFD, DRM_VIA_FREEMEM,
@@ -2555,7 +2555,7 @@
         }
         if (pVia->dBounce)
             xfree(pVia->dBounce);
-#endif /* XF86DRI */
+#endif /* CHROMEDRI */
         if (pVia->scratchAddr) {
             exaOffscreenFree(pScreen, pVia->scratchFBBuffer);
             pVia->scratchAddr = NULL;
@@ -2586,7 +2586,7 @@
     VIAPtr pVia = VIAPTR(pScrn);
 
 #ifdef VIA_HAVE_EXA
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     int size, ret;
 
     if (pVia->directRenderingEnabled && pVia->useEXA) {
@@ -2643,7 +2643,7 @@
             }
         }
     }
-#endif /* XF86DRI */
+#endif /* CHROMEDRI */
     if (!pVia->scratchAddr && pVia->useEXA) {
 
         pVia->scratchFBBuffer =
Index: src/via_memory.c
===================================================================
--- src/via_memory.c	(revision 713)
+++ src/via_memory.c	(working copy)
@@ -31,14 +31,14 @@
 
 #include "via.h"
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 #include "xf86drm.h"
 #endif
 
 #include "via_driver.h"
 #include "via_priv.h"
 #include "via_swov.h"
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 #include "via_drm.h"
 #endif
 
@@ -88,7 +88,7 @@
             mem->pool = 0;
             return;
         case 2:
-#ifdef XF86DRI
+#ifdef CHROMEDRI
             if (drmCommandWrite(mem->drm_fd, DRM_VIA_FREEMEM,
                                 &mem->drm, sizeof(drm_via_mem_t)) < 0)
                 ErrorF("DRM module failed free.\n");
@@ -134,7 +134,7 @@
 int
 VIAAllocLinear(VIAMemPtr mem, ScrnInfoPtr pScrn, unsigned long size)
 {
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     VIAPtr pVia = VIAPTR(pScrn);
     int ret;
 
Index: src/via_xvmc.c
===================================================================
--- src/via_xvmc.c	(revision 713)
+++ src/via_xvmc.c	(working copy)
@@ -34,7 +34,7 @@
 #include "xf86fbman.h"
 #include "regionstr.h"
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 
 #include "via.h"
 #include "via_drm.h"
@@ -987,4 +987,4 @@
     return 0;
 }
 
-#endif /* XF86DRI */
+#endif /* CHROMEDRI */
Index: src/via_priv.h
===================================================================
--- src/via_priv.h	(revision 713)
+++ src/via_priv.h	(working copy)
@@ -26,7 +26,7 @@
 #ifndef _VIA_PRIV_H_
 #define _VIA_PRIV_H_ 1
 
-#ifdef XF86DRI
+#ifdef CHROMEDRI
 #include "via_drm.h"
 #endif
 #ifdef VIA_HAVE_EXA
@@ -141,7 +141,7 @@
 typedef struct {
     unsigned long   base;		/* Offset into fb */
     int    pool;			/* Pool we drew from */
-#ifdef XF86DRI
+#ifdef CHROMEDRI
     int    drm_fd;			/* Fd in DRM mode */
     drm_via_mem_t drm;			/* DRM management object */
 #endif



More information about the Openchrome-devel mailing list