summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c')
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c125
1 files changed, 71 insertions, 54 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c
index 9acce4b54..babeeeb5c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c,v 1.12 2000/03/02 16:07:47 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c,v 1.18 2000/06/23 23:43:43 alanh Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -40,11 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xf86PciInfo.h"
#include "xf86Pci.h"
-#define PSZ 8
-#include "cfb.h"
-#undef PSZ
-#include "cfb16.h"
-#include "cfb32.h"
+#include "fb.h"
#include "miline.h"
@@ -61,18 +57,7 @@ static void GLINTDestroyContext(ScreenPtr pScreen, drmContext hwContext,
DRIContextType contextStore);
static int
-GLINTDRIControlInitSingleMX(int drmSubFD, int irq)
-{
-
- int retcode;
-
- /* Perhaps add flag to for single mx here? */
- if ((retcode = drmCtlInstHandler(drmSubFD, irq))) return 1;
- return 0;
-}
-
-static int
-GLINTDRIControlInitDualMX(int drmSubFD, int irq)
+GLINTDRIControlInit(int drmSubFD, int irq)
{
int retcode;
@@ -351,13 +336,28 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
GLINTDRIPtr pGlintDRI;
int dmabufs = 0;
-#if XFree86LOADER
/* Check that the GLX, DRI, and DRM modules have been loaded by testing
for canonical symbols in each module. */
- if (!LoaderSymbol("GlxSetVisualConfigs")) return FALSE;
- if (!LoaderSymbol("DRIScreenInit")) return FALSE;
- if (!LoaderSymbol("drmAvailable")) return FALSE;
-#endif
+ if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE;
+ if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIQueryVersion")) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "GLINTDRIScreenInit failed (libdri.a too old)\n");
+ return FALSE;
+ }
+
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ DRIQueryVersion(&major, &minor, &patch);
+ if (major != 3 || minor != 0 || patch < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "GLINTDRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n",
+ major, minor, patch);
+ return FALSE;
+ }
+ }
if (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_GAMMA) return FALSE;
@@ -377,9 +377,9 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
((pciConfigPtr)pGlint->PciInfo->thisCard)->busnum,
((pciConfigPtr)pGlint->PciInfo->thisCard)->devnum,
((pciConfigPtr)pGlint->PciInfo->thisCard)->funcnum);
- pDRIInfo->ddxDriverMajorVersion = 0;
- pDRIInfo->ddxDriverMinorVersion = 1;
- pDRIInfo->ddxDriverPatchVersion = 0;
+ pDRIInfo->ddxDriverMajorVersion = GLINT_MAJOR_VERSION;
+ pDRIInfo->ddxDriverMinorVersion = GLINT_MINOR_VERSION;
+ pDRIInfo->ddxDriverPatchVersion = GLINT_PATCHLEVEL;
pDRIInfo->frameBufferPhysicalAddress = pGlint->FbAddress;
pDRIInfo->frameBufferSize = pGlint->FbMapSize;
pDRIInfo->frameBufferStride =
@@ -412,6 +412,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
DRIDestroyInfoRec(pGlint->pDRIInfo);
return FALSE;
}
+
pDRIInfo->devPrivate = pGlintDRI;
pDRIInfo->devPrivateSize = sizeof(GLINTDRIRec);
pDRIInfo->contextSize = sizeof(GLINTDRIContextRec);
@@ -430,6 +431,32 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
return FALSE;
}
+ /* Check the GLINT DRM version */
+ {
+ drmVersionPtr version = drmGetVersion(pGlint->drmSubFD);
+ if (version) {
+ if (version->version_major != 1 ||
+ version->version_minor != 0 ||
+ version->version_patchlevel < 0) {
+ /* incompatible drm version */
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "GLINTDRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel);
+ GLINTDRICloseScreen(pScreen);
+ drmFreeVersion(version);
+ return FALSE;
+ }
+ drmFreeVersion(version);
+ }
+ }
+
+ /* Tell the client driver how many MX's we have */
+ pGlintDRI->numMXDevices = pGlint->numMXDevices;
+ /* Tell the client about our screen size setup */
+ pGlintDRI->pprod = pGlint->pprod;
+
/* setup device specific direct rendering memory maps */
/* pci region 0: control regs, first 4k page, priveledged writes */
@@ -510,6 +537,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
if ((bufs = drmAddBufs(pGlint->drmSubFD,
xf86ConfigDRI.bufs[i].count,
xf86ConfigDRI.bufs[i].size,
+ 0,
0 /* flags */)) <= 0) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"[drm] failure adding %d %d byte DMA buffers\n",
@@ -530,6 +558,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
if ((bufs = drmAddBufs(pGlint->drmSubFD,
GLINT_DRI_BUF_COUNT,
GLINT_DRI_BUF_SIZE,
+ 0,
0 /* flags */)) <= 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"[drm] failure adding %d %d byte DMA buffers\n",
@@ -567,26 +596,13 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
->thisCard)->funcnum);
}
- if (pGlint->numMXDevices == 2) {
- if ( (pGlint->irq <= 0) ||
- GLINTDRIControlInitDualMX(pGlint->drmSubFD, pGlint->irq) ) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] cannot initialize dma with IRQ %d\n",
- pGlint->irq);
- DRICloseScreen(pScreen);
- return FALSE;
- }
- }
-
- if (pGlint->numMXDevices == 1) {
- if ( (pGlint->irq <= 0) ||
- GLINTDRIControlInitSingleMX(pGlint->drmSubFD, pGlint->irq) ) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] cannot initialize dma with IRQ %d\n",
- pGlint->irq);
- DRICloseScreen(pScreen);
- return FALSE;
- }
+ if ( (pGlint->irq <= 0) ||
+ GLINTDRIControlInit(pGlint->drmSubFD, pGlint->irq) ) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "[drm] cannot initialize dma with IRQ %d\n",
+ pGlint->irq);
+ DRICloseScreen(pScreen);
+ return FALSE;
}
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -634,7 +650,8 @@ Bool
GLINTCreateContext(ScreenPtr pScreen,
VisualPtr visual,
drmContext hwContext,
- void *pVisualConfigPriv)
+ void *pVisualConfigPriv,
+ DRIContextType contextStore)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
GLINTPtr pGlint = GLINTPTR(pScrn);
@@ -646,7 +663,7 @@ GLINTCreateContext(ScreenPtr pScreen,
if (!pGlintConfig)
return TRUE; /* no GLX driver private support, yet */
-#if 1
+#if 0
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"[GLINTCreateContext] context priv index = %d\n",
pGlintConfig->index);
@@ -730,9 +747,9 @@ GLINTDRISwapContext(
ScreenPtr pScreen,
DRISyncType syncType,
DRIContextType readContextType,
- void** readContextStore,
+ void *readContextStore,
DRIContextType writeContextType,
- void** writeContextStore)
+ void *writeContextStore)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
GLINTPtr pGlint = GLINTPTR(pScrn);
@@ -1125,7 +1142,7 @@ GLINTDRISwapContext(
/* send gamma the context dump command */
GLINT_WAIT(3);
- if (pGlint->numMXDevices > 1)
+ if (pGlint->numMXDevices == 2)
GLINT_WRITE_REG(1, BroadcastMask);
GLINT_WRITE_REG(3<<14, FilterMode); /* context bits on gamma */
GLINT_WRITE_REG(GLINT_GAMMA_CONTEXT_MASK, ContextDump);
@@ -1170,7 +1187,7 @@ dumpIndex,readValue);
/* send context restore command */
GLINT_WAIT(1);
- if (pGlint->numMXDevices > 1)
+ if (pGlint->numMXDevices == 2)
GLINT_WRITE_REG(1, BroadcastMask);
GLINT_WAIT(3);
@@ -1199,7 +1216,7 @@ dumpIndex,pWC->Gamma[dumpIndex]);
pGlint->AccelInfoRec->NeedToSync = TRUE;
/* finally the MX portions */
- if (pGlint->numMXDevices > 1)
+ if (pGlint->numMXDevices == 2)
GLINT_SLOW_WRITE_REG(1, BroadcastMask);
GLINT_SLOW_WRITE_REG(pWC->MX1.CSStart, SStart);
GLINT_SLOW_WRITE_REG(pWC->MX1.CdSdx, dSdx);
@@ -1452,7 +1469,7 @@ dumpIndex,pWC->Gamma[dumpIndex]);
/* restore the 2D portion of the new context */
/* Restore MX1's registers */
- if (pGlint->numMXDevices > 1)
+ if (pGlint->numMXDevices == 2)
GLINT_SLOW_WRITE_REG(1, BroadcastMask);
GLINT_SLOW_WRITE_REG(pWC->MX1.CStartXDom, StartXDom);
GLINT_SLOW_WRITE_REG(pWC->MX1.CdXDom, dXDom);