summaryrefslogtreecommitdiff
path: root/driver/xf86-video-mga/src/mga_driver.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2014-10-19 19:11:00 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2014-10-19 19:11:00 +0000
commit9b4c34afd70b0d24a4592f66d9b29226cc5a6b2d (patch)
treeba365fc0c77ffb4fd3005a136eb4bae8ec76d09e /driver/xf86-video-mga/src/mga_driver.c
parentfb747bcfd2fb9b9d5a8755dcbf28461577fe1297 (diff)
Update to xf86-video-mga 1.6.3
Diffstat (limited to 'driver/xf86-video-mga/src/mga_driver.c')
-rw-r--r--driver/xf86-video-mga/src/mga_driver.c202
1 files changed, 144 insertions, 58 deletions
diff --git a/driver/xf86-video-mga/src/mga_driver.c b/driver/xf86-video-mga/src/mga_driver.c
index 864f7743c..2b4a867b5 100644
--- a/driver/xf86-video-mga/src/mga_driver.c
+++ b/driver/xf86-video-mga/src/mga_driver.c
@@ -676,12 +676,22 @@ MGAPciProbe(DriverPtr drv, int entity_num, struct pci_device * dev,
#endif
if (pci_device_has_kernel_driver(dev)) {
- xf86DrvMsg(0, X_ERROR,
- "mga: The PCI device 0x%x at %2.2d@%2.2d:%2.2d:%1.1d has a kernel module claiming it.\n",
- dev->device_id, dev->bus, dev->domain, dev->dev, dev->func);
- xf86DrvMsg(0, X_ERROR,
- "mga: This driver cannot operate until it has been unloaded.\n");
- return FALSE;
+ /* If it's a G200 server chip, it's probably on KMS, so bail; if not,
+ * it might be using matroxfb, which is ok. */
+ switch (dev->device_id) {
+ case PCI_CHIP_MGAG200_SE_A_PCI:
+ case PCI_CHIP_MGAG200_SE_B_PCI:
+ case PCI_CHIP_MGAG200_EV_PCI:
+ case PCI_CHIP_MGAG200_ER_PCI:
+ case PCI_CHIP_MGAG200_WINBOND_PCI:
+ case PCI_CHIP_MGAG200_EH_PCI:
+ xf86DrvMsg(0, X_ERROR,
+ "mga: The PCI device 0x%x at %2.2d@%2.2d:%2.2d:%1.1d has a kernel module claiming it.\n",
+ dev->device_id, dev->bus, dev->domain, dev->dev, dev->func);
+ xf86DrvMsg(0, X_ERROR,
+ "mga: This driver cannot operate until it has been unloaded.\n");
+ return FALSE;
+ }
}
/* Allocate a ScrnInfoRec and claim the slot */
@@ -1670,6 +1680,43 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
}
/*
+ * Disable HW cursor by default on G200 server chips as these
+ * chips are often used with a remote graphics link which cannot
+ * display the HW cursor.
+ */
+ switch (pMga->Chipset) {
+ case PCI_CHIP_MGAG200_SE_A_PCI:
+ case PCI_CHIP_MGAG200_SE_B_PCI:
+ case PCI_CHIP_MGAG200_EV_PCI:
+ case PCI_CHIP_MGAG200_ER_PCI:
+ case PCI_CHIP_MGAG200_WINBOND_PCI:
+ case PCI_CHIP_MGAG200_EH_PCI:
+ pMga->HWCursor = FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "HW cursor is not supported with video redirection on"
+ "G200 server chips.\n If you don't intend to use video "
+ "redirection enable with Option \"HWCursor\" \"On\"\n");
+ break;
+ default:
+ pMga->HWCursor = TRUE;
+ }
+ from = X_DEFAULT;
+
+ /*
+ * The preferred method is to use the "hw cursor" option as a tri-state
+ * option, with the default set above.
+ */
+ if (xf86GetOptValBool(pMga->Options, OPTION_HW_CURSOR, &pMga->HWCursor))
+ from = X_CONFIG;
+
+ /* For compatibility, accept this too (as an override) */
+ if (xf86ReturnOptValBool(pMga->Options, OPTION_SW_CURSOR, FALSE)) {
+ from = X_CONFIG;
+ pMga->HWCursor = FALSE;
+ }
+
+ pMga->SecondCrtc = FALSE;
+ /*
* In case of DualHead, we need to determine if we are the 'master' head
* or the 'slave' head. In order to do that, at the end of the first
* initialisation, PrimInit is set as DONE to the shared entity. So that
@@ -1681,13 +1728,12 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
if (xf86IsEntityShared(pScrn->entityList[0])) { /* dual-head mode */
if (!xf86IsPrimInitDone(pScrn->entityList[0])) { /* Is it the first initialisation? */
/* First CRTC */
- pMga->SecondCrtc = FALSE;
- pMga->HWCursor = TRUE;
pMgaEnt->pScrn_1 = pScrn;
} else if (pMga->DualHeadEnabled) {
/* Second CRTC */
pMga->SecondCrtc = TRUE;
pMga->HWCursor = FALSE;
+ from = X_DEFAULT;
pMgaEnt->pScrn_2 = pScrn;
pScrn->AdjustFrame = MGAAdjustFrameCrtc2;
/*
@@ -1706,14 +1752,15 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
}
+ xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
+ pMga->HWCursor ? "HW" : "SW");
+
if (pMga->DualHeadEnabled) {
#ifdef MGADRI
pMga->GetQuiescence = MGAGetQuiescenceShared;
#endif
} else { /* single-head mode */
- pMga->SecondCrtc = FALSE;
- pMga->HWCursor = TRUE;
#ifdef MGADRI
pMga->GetQuiescence = MGAGetQuiescence;
#endif
@@ -1977,24 +2024,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
}
#endif
- from = X_DEFAULT;
-
- /*
- * The preferred method is to use the "hw cursor" option as a tri-state
- * option, with the default set above.
- */
- if (xf86GetOptValBool(pMga->Options, OPTION_HW_CURSOR, &pMga->HWCursor)) {
- from = X_CONFIG;
- }
-
- /* For compatibility, accept this too (as an override) */
- if (xf86ReturnOptValBool(pMga->Options, OPTION_SW_CURSOR, FALSE)) {
- from = X_CONFIG;
- pMga->HWCursor = FALSE;
- }
- xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
- pMga->HWCursor ? "HW" : "SW");
-
if (xf86ReturnOptValBool(pMga->Options, OPTION_NOACCEL, FALSE)) {
pMga->NoAccel = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n");
@@ -2679,30 +2708,55 @@ MGAMapMem(ScrnInfoPtr pScrn)
#ifdef XSERVER_LIBPCIACCESS
struct pci_device *const dev = pMga->PciInfo;
struct pci_mem_region *region;
- void **memory[2];
int i, err;
#endif
if (!pMga->FBDev) {
#ifdef XSERVER_LIBPCIACCESS
- memory[pMga->io_bar] = &pMga->IOBase;
- memory[pMga->framebuffer_bar] = &pMga->FbBase;
+ pciaddr_t fbaddr = pMga->FbAddress;
+ pciaddr_t fbsize = pMga->FbMapSize;
+ err = pci_device_map_range(dev,
+ fbaddr, fbsize,
+ PCI_DEV_MAP_FLAG_WRITABLE,
+ (void **)&pMga->FbBase);
- for (i = 0; i < 2; i++) {
- region = &dev->regions[i];
- err = pci_device_map_range(dev,
- region->base_addr, region->size,
- PCI_DEV_MAP_FLAG_WRITABLE,
- memory[i]);
+ if (err) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Unable to map Framebuffer %08llX %llx. %s (%d)\n",
+ (long long)fbaddr, (long long)fbsize,
+ strerror(err), err);
+ return FALSE;
+ }
+ else
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "MAPPED Framebuffer %08llX %llx to %08llX.\n",
+ (long long)fbaddr, (long long)fbsize,
+ (long long)pMga->FbBase);
+
+ if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedIOUsage == 0) {
+ region = &dev->regions[pMga->io_bar];
+ err = pci_device_map_range(dev,
+ region->base_addr, region->size,
+ PCI_DEV_MAP_FLAG_WRITABLE,
+ &pMga->IOBase);
+
+ if (err) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Unable to map IO Region %i. %s (%d)\n",
+ pMga->io_bar, strerror(err), err);
+ return FALSE;
+ }
+
+ if(pMga->entityPrivate != NULL)
+ pMga->entityPrivate->mappedIOBase = pMga->IOBase;
+ }
+ else
+ pMga->IOBase = pMga->entityPrivate->mappedIOBase;
+
+ if(pMga->entityPrivate != NULL)
+ pMga->entityPrivate->mappedIOUsage ++;
- if (err) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Unable to map BAR %i. %s (%d)\n",
- i, strerror(err), err);
- return FALSE;
- }
- }
#else
/*
* For Alpha, we need to map SPARSE memory, since we need
@@ -2753,16 +2807,27 @@ MGAMapMem(ScrnInfoPtr pScrn)
if (pMga->iload_bar != -1) {
#ifdef XSERVER_LIBPCIACCESS
region = &dev->regions[pMga->iload_bar];
- err = pci_device_map_range(dev,
- region->base_addr, region->size,
- PCI_DEV_MAP_FLAG_WRITABLE,
- (void *) &pMga->ILOADBase);
- if (err) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Unable to map BAR 2 (ILOAD region). %s (%d)\n",
- strerror(err), err);
- return FALSE;
+
+ if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedILOADUsage == 0) {
+ err = pci_device_map_range(dev,
+ region->base_addr, region->size,
+ PCI_DEV_MAP_FLAG_WRITABLE,
+ (void *) &pMga->ILOADBase);
+ if (err) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Unable to map BAR 2 (ILOAD region). %s (%d)\n",
+ strerror(err), err);
+ return FALSE;
+ }
+
+ if(pMga->entityPrivate != NULL)
+ pMga->entityPrivate->mappedILOADBase = pMga->ILOADBase;
}
+ else
+ pMga->ILOADBase = pMga->entityPrivate->mappedILOADBase;
+
+ if(pMga->entityPrivate != NULL)
+ pMga->entityPrivate->mappedILOADUsage ++;
#else
pMga->ILOADBase = xf86MapPciMem(pScrn->scrnIndex,
VIDMEM_MMIO | VIDMEM_MMIO_32BIT |
@@ -2792,10 +2857,20 @@ MGAUnmapMem(ScrnInfoPtr pScrn)
if (!pMga->FBDev) {
#ifdef XSERVER_LIBPCIACCESS
- pci_device_unmap_range(dev, pMga->IOBase,
- dev->regions[pMga->io_bar].size);
+ if(pMga->entityPrivate != NULL)
+ pMga->entityPrivate->mappedIOUsage--;
+
+ if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedIOUsage == 0) {
+ pci_device_unmap_range(dev, pMga->IOBase,
+ dev->regions[pMga->io_bar].size);
+
+ if(pMga->entityPrivate != NULL)
+ pMga->entityPrivate->mappedIOBase = NULL;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "UNMAPPING framebuffer 0x%08llX, 0x%llX.\n", (long long)pMga->FbBase, (long long)pMga->FbMapSize);
pci_device_unmap_range(dev, pMga->FbBase,
- dev->regions[pMga->framebuffer_bar].size);
+ pMga->FbMapSize);
#else
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->IOBase, 0x4000);
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->FbBase, pMga->FbMapSize);
@@ -2808,8 +2883,17 @@ MGAUnmapMem(ScrnInfoPtr pScrn)
if ((pMga->iload_bar != -1) && (pMga->ILOADBase != NULL)) {
#ifdef XSERVER_LIBPCIACCESS
- pci_device_unmap_range(dev, pMga->ILOADBase,
- dev->regions[pMga->iload_bar].size);
+ if(pMga->entityPrivate != NULL)
+ pMga->entityPrivate->mappedILOADUsage--;
+
+ if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedILOADUsage == 0) {
+ pci_device_unmap_range(dev, pMga->ILOADBase,
+ dev->regions[pMga->iload_bar].size);
+
+ if(pMga->entityPrivate != NULL)
+ pMga->entityPrivate->mappedILOADBase = NULL;
+ }
+
#else
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->ILOADBase, 0x800000);
#endif
@@ -3114,11 +3198,13 @@ MGACrtc2FillStrip(ScrnInfoPtr pScrn)
(pScrn->bitsPerPixel >> 3) * pScrn->displayWidth * pScrn->virtualY);
} else {
xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex);
+#ifdef HAVE_XAA_H
pMga->RestoreAccelState(pScrn);
pMga->SetupForSolidFill(pScrn, 0, GXcopy, 0xFFFFFFFF);
pMga->SubsequentSolidFillRect(pScrn, pScrn->virtualX, 0,
pScrn->displayWidth - pScrn->virtualX,
pScrn->virtualY);
+#endif
MGAStormSync(pScrn);
}
}