drop hacks for ancient pre-libpciaccess Xservers

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-12-18 15:28:41 +01:00
parent e4d2670eb7
commit f490217b1d
9 changed files with 1 additions and 506 deletions

View File

@@ -109,18 +109,7 @@ if test "x$DRI" = xyes; then
AC_DEFINE(MGADRI_DEVEL,1,[Enable developmental DRI driver support])
fi
save_CFLAGS="$CFLAGS"
CFLAGS="$XORG_CFLAGS"
AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
[XSERVER_LIBPCIACCESS=yes], [XSERVER_LIBPCIACCESS=no],
[#include "xorg-server.h"])
CFLAGS="$save_CFLAGS"
if test "x$XSERVER_LIBPCIACCESS" = xyes; then
PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
fi
AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
# Properly handle EXA.
AC_MSG_CHECKING([whether to enable EXA support])

View File

@@ -13,9 +13,7 @@
#ifndef MGA_H
#define MGA_H
#ifdef XSERVER_LIBPCIACCESS
#include <pciaccess.h>
#endif
#include <string.h>
#include <stdio.h>
@@ -462,13 +460,7 @@ typedef struct {
EntityInfoPtr pEnt;
struct mga_bios_values bios;
CARD8 BiosOutputMode;
#ifdef XSERVER_LIBPCIACCESS
struct pci_device * PciInfo;
#else
pciVideoPtr PciInfo;
PCITAG PciTag;
xf86AccessRec Access;
#endif
const struct mga_device_attributes * chip_attribs;
int Chipset;
int ChipRev;
@@ -511,12 +503,6 @@ typedef struct {
*/
int iload_bar;
#ifndef XSERVER_LIBPCIACCESS
unsigned long IOAddress;
unsigned long ILOADAddress;
unsigned long BiosAddress;
MessageType BiosFrom;
#endif
unsigned long FbAddress;
void * IOBase;
unsigned char * FbBase;

View File

@@ -271,9 +271,6 @@ Bool mga_read_and_process_bios( ScrnInfoPtr pScrn )
CARD8 bios_data[0x20000];
unsigned offset;
MGAPtr pMga = MGAPTR(pScrn);
#ifndef XSERVER_LIBPCIACCESS
Bool pciBIOS = TRUE;
#endif
static const unsigned expected_length[] = { 0, 64, 64, 64, 128, 128 };
unsigned version;
unsigned pins_len;
@@ -308,27 +305,7 @@ Bool mga_read_and_process_bios( ScrnInfoPtr pScrn )
* might be controlled by the PCI config space.
*/
#ifdef XSERVER_LIBPCIACCESS
err = pci_device_read_rom(pMga->PciInfo, bios_data);
#else
if (pMga->BiosFrom == X_DEFAULT) {
pciBIOS = FALSE;
}
else if (pMga->BiosFrom == X_CONFIG && pMga->BiosAddress < 0x100000) {
pciBIOS = TRUE;
}
if (pciBIOS) {
rlen = xf86ReadPciBIOS(0, pMga->PciTag, pMga->framebuffer_bar,
bios_data, sizeof(bios_data));
}
else {
rlen = xf86ReadDomainMemory(pMga->PciTag, pMga->BiosAddress,
sizeof(bios_data), bios_data);
}
err = rlen < (bios_data[2] << 9);
#endif
if (err) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,

View File

@@ -723,13 +723,8 @@ MGA3026Restore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
for (i = 0; i < 6; i++)
OUTREG16(0x1FDE, (mgaReg->ExtVga[i] << 8) | i);
#ifdef XSERVER_LIBPCIACCESS
pci_device_cfg_write_bits(pMga->PciInfo, OPTION_MASK, mgaReg->Option,
PCI_OPTION_REG);
#else
pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, OPTION_MASK,
mgaReg->Option);
#endif
/* select pixel clock PLL as clock source */
outTi3026(TVP3026_CLK_SEL, 0, mgaReg->DacRegs[3]);
@@ -840,16 +835,12 @@ MGA3026Save(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
for (i = 0; i < DACREGSIZE; i++)
mgaReg->DacRegs[i] = inTi3026(MGADACregs[i]);
#ifdef XSERVER_LIBPCIACCESS
{
uint32_t Option;
pci_device_cfg_read_u32(pMga->PciInfo, & Option,
PCI_OPTION_REG);
mgaReg->Option = Option;
}
#else
mgaReg->Option = pciReadLong(pMga->PciTag, PCI_OPTION_REG);
#endif
#ifdef DEBUG
ErrorF("read: %02X %02X %02X %02X %02X %02X %08X\n",

View File

@@ -1653,7 +1653,6 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
if (!MGAISGx50(pMga)) {
/* restore pci_option register */
#ifdef XSERVER_LIBPCIACCESS
pci_device_cfg_write_bits(pMga->PciInfo, optionMask,
mgaReg->Option, PCI_OPTION_REG);
@@ -1668,17 +1667,6 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
PCI_MGA_OPTION3);
}
}
#else
/* restore pci_option register */
pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, optionMask,
mgaReg->Option);
if (pMga->Chipset != PCI_CHIP_MGA1064)
pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION2, OPTION2_MASK,
mgaReg->Option2);
if (pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550)
pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION3, OPTION3_MASK,
mgaReg->Option3);
#endif
}
if (pMga->is_G200ER) {
@@ -1860,23 +1848,13 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
mgaReg->PIXPLLCSaved = TRUE;
#ifdef XSERVER_LIBPCIACCESS
pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option,
PCI_OPTION_REG);
pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option2,
PCI_MGA_OPTION2);
#else
mgaReg->Option = pciReadLong(pMga->PciTag, PCI_OPTION_REG);
mgaReg->Option2 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION2);
#endif
if (pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550)
#ifdef XSERVER_LIBPCIACCESS
pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option3,
PCI_MGA_OPTION3);
#else
mgaReg->Option3 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION3);
#endif
for (i = 0; i < 6; i++)
{

View File

@@ -583,16 +583,10 @@ static void MGADRIIrqInit(MGAPtr pMga, ScreenPtr pScreen)
if (!pMga->irq) {
pMga->irq = drmGetInterruptFromBusID(pMga->drmFD,
#ifdef XSERVER_LIBPCIACCESS
((pMga->PciInfo->domain << 8) |
pMga->PciInfo->bus),
pMga->PciInfo->dev,
pMga->PciInfo->func
#else
((pciConfigPtr)pMga->PciInfo->thisCard)->busnum,
((pciConfigPtr)pMga->PciInfo->thisCard)->devnum,
((pciConfigPtr)pMga->PciInfo->thisCard)->funcnum
#endif
);
if((drmCtlInstHandler(pMga->drmFD, pMga->irq)) != 0) {
@@ -708,14 +702,8 @@ Bool MGADRIScreenInit( ScreenPtr pScreen )
} else {
pDRIInfo->busIdString = malloc(64);
sprintf( pDRIInfo->busIdString, "PCI:%d:%d:%d",
#ifdef XSERVER_LIBPCIACCESS
((pMga->PciInfo->domain << 8) | pMga->PciInfo->bus),
pMga->PciInfo->dev, pMga->PciInfo->func
#else
((pciConfigPtr)pMga->PciInfo->thisCard)->busnum,
((pciConfigPtr)pMga->PciInfo->thisCard)->devnum,
((pciConfigPtr)pMga->PciInfo->thisCard)->funcnum
#endif
);
}
pDRIInfo->ddxDriverMajorVersion = PACKAGE_VERSION_MAJOR;

View File

@@ -55,11 +55,6 @@
#include "compiler.h"
/* Drivers that need to access the PCI config space directly need this */
#ifndef XSERVER_LIBPCIACCESS
#include "xf86Pci.h"
#endif
/* All drivers initialising the SW cursor need this */
#include "mipointer.h"
@@ -94,12 +89,8 @@
/* Mandatory functions */
static const OptionInfoRec * MGAAvailableOptions(int chipid, int busid);
static void MGAIdentify(int flags);
#ifdef XSERVER_LIBPCIACCESS
static Bool MGAPciProbe(DriverPtr drv, int entity_num,
struct pci_device * dev, intptr_t match_data);
#else
static Bool MGAProbe(DriverPtr drv, int flags);
#endif
static Bool MGAPreInit(ScrnInfoPtr pScrn, int flags);
static Bool MGAScreenInit(SCREEN_INIT_ARGS_DECL);
static Bool MGAEnterVT(VT_FUNC_ARGS_DECL);
@@ -428,7 +419,6 @@ static const struct mga_device_attributes attribs[] = {
}
};
#ifdef XSERVER_LIBPCIACCESS
#define MGA_DEVICE_MATCH(d, i) \
{ 0x102B, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) }
#define MGA_SUBDEVICE_MATCH(d, s, i) \
@@ -463,7 +453,6 @@ static const struct pci_id_match mga_device_match[] = {
{ 0, 0, 0 },
};
#endif
/* Supported chipsets */
static SymTabRec MGAChipsets[] = {
@@ -530,20 +519,13 @@ _X_EXPORT DriverRec MGA_C_NAME = {
MGA_VERSION,
MGA_DRIVER_NAME,
MGAIdentify,
#ifdef XSERVER_LIBPCIACCESS
NULL,
#else
MGAProbe,
#endif
MGAAvailableOptions,
NULL,
0,
NULL,
#ifdef XSERVER_LIBPCIACCESS
mga_device_match,
MGAPciProbe
#endif
};
@@ -674,8 +656,6 @@ MGAIdentify(int flags)
xf86PrintChipsets(MGA_NAME, "driver for Matrox chipsets", MGAChipsets);
}
#ifdef XSERVER_LIBPCIACCESS
Bool
MGAPciProbe(DriverPtr drv, int entity_num, struct pci_device * dev,
intptr_t match_data)
@@ -768,230 +748,6 @@ MGAPciProbe(DriverPtr drv, int entity_num, struct pci_device * dev,
return (pScrn != NULL);
}
#else
/* Mandatory */
static Bool
MGAProbe(DriverPtr drv, int flags)
{
int i;
GDevPtr *devSections;
int *usedChips = NULL;
int numDevSections;
int numUsed;
Bool foundScreen = FALSE;
/*
* The aim here is to find all cards that this driver can handle,
* and for the ones not already claimed by another driver, claim the
* slot, and allocate a ScrnInfoRec.
*
* This should be a minimal probe, and it should under no circumstances
* change the state of the hardware. Because a device is found, don't
* assume that it will be used. Don't do any initialisations other than
* the required ScrnInfoRec initialisations. Don't allocate any new
* data structures.
*/
/*
* Check if there has been a chipset override in the config file.
* For this we must find out if there is an active device section which
* is relevant, i.e., which has no driver specified or has THIS driver
* specified.
*/
if ((numDevSections = xf86MatchDevice(MGA_DRIVER_NAME,
&devSections)) <= 0) {
/*
* There's no matching device section in the config file, so quit
* now.
*/
return FALSE;
}
/*
* We need to probe the hardware first. We then need to see how this
* fits in with what is given in the config file, and allow the config
* file info to override any contradictions.
*/
/*
* All of the cards this driver supports are PCI, so the "probing" just
* amounts to checking the PCI data that the server has already collected.
*/
if (xf86GetPciVideoInfo() == NULL) {
/*
* We won't let anything in the config file override finding no
* PCI video cards at all. This seems reasonable now, but we'll see.
*/
return FALSE;
}
numUsed = xf86MatchPciInstances(MGA_NAME, PCI_VENDOR_MATROX,
MGAChipsets, MGAPciChipsets, devSections,
numDevSections, drv, &usedChips);
/* Free it since we don't need that list after this */
free(devSections);
if (numUsed <= 0)
return FALSE;
if (flags & PROBE_DETECT)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
ScrnInfoPtr pScrn = NULL;
EntityInfoPtr pEnt;
int attrib_no;
/* Allocate a ScrnInfoRec and claim the slot */
pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[i],
MGAPciChipsets, NULL, NULL,
NULL, NULL, NULL);
if (pScrn != NULL) {
MGAPtr pMga;
/* Fill in what we can of the ScrnInfoRec */
pScrn->driverVersion = MGA_VERSION;
pScrn->driverName = MGA_DRIVER_NAME;
pScrn->name = MGA_NAME;
pScrn->Probe = MGAProbe;
pScrn->PreInit = MGAPreInit;
pScrn->ScreenInit = MGAScreenInit;
pScrn->SwitchMode = MGASwitchMode;
pScrn->AdjustFrame = MGAAdjustFrame;
pScrn->EnterVT = MGAEnterVT;
pScrn->LeaveVT = MGALeaveVT;
pScrn->FreeScreen = MGAFreeScreen;
pScrn->ValidMode = MGAValidMode;
foundScreen = TRUE;
/* Allocate the MGARec driverPrivate */
if (!MGAGetRec(pScrn)) {
return FALSE;
}
pMga = MGAPTR(pScrn);
/*
* For cards that can do dual head per entity, mark the entity
* as shareable.
*/
pEnt = xf86GetEntityInfo(usedChips[i]);
switch (pEnt->chipset) {
case PCI_CHIP_MGA2064:
attrib_no = 0;
break;
case PCI_CHIP_MGA1064:
attrib_no = 1;
break;
case PCI_CHIP_MGA2164:
attrib_no = 2;
break;
case PCI_CHIP_MGA2164_AGP:
attrib_no = 3;
break;
case PCI_CHIP_MGAG100:
attrib_no = 4;
break;
case PCI_CHIP_MGAG100_PCI:
attrib_no = 5;
break;
case PCI_CHIP_MGAG200:
attrib_no = 6;
break;
case PCI_CHIP_MGAG200_PCI:
attrib_no = 7;
break;
case PCI_CHIP_MGAG400:
attrib_no = 8;
break;
case PCI_CHIP_MGAG550:
attrib_no = 9;
break;
case PCI_CHIP_MGAG200_SE_A_PCI:
attrib_no = 10;
break;
case PCI_CHIP_MGAG200_SE_B_PCI:
attrib_no = 11;
break;
case PCI_CHIP_MGAG200_EV_PCI:
attrib_no = 12;
break;
case PCI_CHIP_MGAG200_WINBOND_PCI:
attrib_no = 13;
break;
case PCI_CHIP_MGAG200_EH_PCI:
attrib_no = 14;
break;
case PCI_CHIP_MGAG200_ER_PCI:
attrib_no = 15;
break;
case PCI_CHIP_MGAG200_EW3_PCI:
attrib_no = 16;
break;
case PCI_CHIP_MGAG200_EH3_PCI:
attrib_no = 17;
break;
default:
return FALSE;
}
pMga->chip_attribs = & attribs[attrib_no];
if (pMga->chip_attribs->dual_head_possible) {
MGAEntPtr pMgaEnt = NULL;
DevUnion *pPriv;
xf86SetEntitySharable(usedChips[i]);
/* Allocate an entity private if necessary */
if (MGAEntityIndex < 0)
MGAEntityIndex = xf86AllocateEntityPrivateIndex();
pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
if (!pPriv->ptr) {
pPriv->ptr = XNFcallocarray(sizeof(MGAEntRec), 1);
pMgaEnt = pPriv->ptr;
pMgaEnt->lastInstance = -1;
} else {
pMgaEnt = pPriv->ptr;
}
/*
* Set the entity instance for this instance of the driver. For
* dual head per card, instance 0 is the "master" instance, driving
* the primary head, and instance 1 is the "slave".
*/
pMgaEnt->lastInstance++;
xf86SetEntityInstanceForScreen(pScrn, pScrn->entityList[0],
pMgaEnt->lastInstance);
}
}
}
free(usedChips);
return foundScreen;
}
#endif
/*
* MGASoftReset --
*
@@ -1054,12 +810,8 @@ MGACountRam(ScrnInfoPtr pScrn)
it. At least, my cards don't advertise the documented
values (my 8 and 16 Meg G200s have the same values) */
if (pMga->Primary) { /* can only trust this for primary cards */
#ifdef XSERVER_LIBPCIACCESS
pci_device_cfg_read_u32(pMga->PciInfo, & biosInfo,
PCI_OPTION_REG);
#else
biosInfo = pciReadLong(pMga->PciTag, PCI_OPTION_REG);
#endif
}
#endif
@@ -1145,14 +897,9 @@ MGACountRam(ScrnInfoPtr pScrn)
if (pMga->is_G200WB) {
uint32_t Option, MaxMapSize;
#ifdef XSERVER_LIBPCIACCESS
pci_device_cfg_read_u32(pMga->PciInfo, &Option,
PCI_OPTION_REG);
MaxMapSize = pMga->PciInfo->regions[0].size;
#else
Option = pciReadLong(pMga->PciTag, PCI_OPTION_REG);
MaxMapSize = 1UL << pMga->PciInfo->size[0];
#endif
Option = (Option & 0x3000000) >> 24 ;
if (Option == 2)
@@ -1500,20 +1247,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
if (!vgaHWGetHWRec(pScrn))
return FALSE;
#ifndef XSERVER_LIBPCIACCESS
/* Find the PCI info for this screen */
pMga->PciInfo = xf86GetPciInfoForEntity(pMga->pEnt->index);
pMga->PciTag = pciTag(pMga->PciInfo->bus, pMga->PciInfo->device,
pMga->PciInfo->func);
#endif
pMga->Primary = xf86IsPrimaryPci(pMga->PciInfo);
#ifndef XSERVER_LIBPCIACCESS
xf86SetOperatingState(resVgaIo, pMga->pEnt->index, ResUnusedOpr);
xf86SetOperatingState(resVgaMem, pMga->pEnt->index, ResDisableOpr);
#endif
/* Set pScrn->monitor */
pScrn->monitor = pScrn->confScreen->monitor;
@@ -1713,69 +1448,20 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
break;
}
#ifdef XSERVER_LIBPCIACCESS
pMga->FbAddress = pMga->PciInfo->regions[pMga->framebuffer_bar].base_addr;
#else
pMga->FbAddress = pMga->PciInfo->memBase[pMga->framebuffer_bar] & 0xff800000;
#endif
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Linear framebuffer at 0x%lX\n",
(unsigned long)pMga->FbAddress);
#ifdef XSERVER_LIBPCIACCESS
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "MMIO registers at 0x%lX\n",
(unsigned long) pMga->PciInfo->regions[pMga->io_bar].base_addr);
#else
pMga->IOAddress = pMga->PciInfo->memBase[pMga->io_bar] & 0xffffc000;
xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at 0x%lX\n",
(unsigned long)pMga->IOAddress);
#endif
if (pMga->iload_bar != -1) {
#ifdef XSERVER_LIBPCIACCESS
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
"Pseudo-DMA transfer window at 0x%lX\n",
(unsigned long) pMga->PciInfo->regions[pMga->iload_bar].base_addr);
#else
if (pMga->PciInfo->memBase[2] != 0) {
pMga->ILOADAddress = pMga->PciInfo->memBase[2] & 0xffffc000;
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
"Pseudo-DMA transfer window at 0x%lX\n",
(unsigned long)pMga->ILOADAddress);
}
#endif
}
#ifndef XSERVER_LIBPCIACCESS
/*
* Find the BIOS base. Get it from the PCI config if possible. Otherwise
* use the VGA default.
*/
/* details: rombase sdk pp 4-15 */
if (pMga->PciInfo->biosBase != 0) {
pMga->BiosAddress = pMga->PciInfo->biosBase & 0xffff0000;
pMga->BiosFrom = X_PROBED;
} else if (pMga->Primary) {
pMga->BiosAddress = 0xc0000;
pMga->BiosFrom = X_DEFAULT;
}
if (pMga->BiosAddress) {
xf86DrvMsg(pScrn->scrnIndex, pMga->BiosFrom, "BIOS at 0x%lX\n",
(unsigned long)pMga->BiosAddress);
}
#endif
#ifndef XSERVER_LIBPCIACCESS
if (xf86RegisterResources(pMga->pEnt->index, NULL, ResExclusive)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"xf86RegisterResources() found resource conflicts\n");
MGAFreeRec(pScrn);
return FALSE;
}
#endif
/*
* The first thing we should figure out is the depth, bpp, etc.
* Our default depth is 8, so pass it to the helper function.
@@ -1866,13 +1552,9 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
if (pMga->is_G200SE) {
/* Disable MTRR support on PCIe systems */
#ifdef XSERVER_LIBPCIACCESS
uint32_t temp;
pci_device_cfg_read_u32(pMga->PciInfo, & temp, 0xDC);
#else
CARD32 temp = pciReadLong(pMga->PciTag, 0xDC);
#endif
if ((temp & 0x0000FF00) != 0x0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling MTRR support.\n");
@@ -2091,23 +1773,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
break;
}
/*
* Read the BIOS data struct
*/
#if defined(__alpha__) && !defined(XSERVER_LIBPCIACCESS)
/*
* Some old Digital-OEMed Matrox Millennium I cards have a VGA
* disable switch. If the disable is on, we can't read the BIOS,
* and pMga->BiosAddress = 0x0. The disable switch is needed to
* allow multi-head operation with brain-dead console code... ;-}
*/
if ((pMga->BiosAddress == 0) && !xf86IsPrimaryPci(pMga->PciInfo))
xf86DrvMsg(pScrn->scrnIndex, pMga->BiosFrom,
"BIOS not found, skipping read\n");
else
#endif
mga_read_and_process_bios( pScrn );
@@ -2433,12 +2098,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
&& pMga->chip_attribs->probe_for_sdram) {
uint32_t option_reg;
#ifdef XSERVER_LIBPCIACCESS
pci_device_cfg_read_u32(pMga->PciInfo, & option_reg,
PCI_OPTION_REG);
#else
option_reg = pciReadLong(pMga->PciTag, PCI_OPTION_REG);
#endif
pMga->HasSDRAM = ((option_reg & (1 << 14)) == 0);
}
else {
@@ -2618,15 +2279,11 @@ static Bool
MGAMapMem(ScrnInfoPtr pScrn)
{
MGAPtr pMga = MGAPTR(pScrn);
#ifdef XSERVER_LIBPCIACCESS
struct pci_device *const dev = pMga->PciInfo;
struct pci_mem_region *region;
int err;
#endif
if (!pMga->FBDev) {
#ifdef XSERVER_LIBPCIACCESS
pciaddr_t fbaddr = pMga->FbAddress;
pciaddr_t fbsize = pMga->FbMapSize;
err = pci_device_map_range(dev,
@@ -2670,34 +2327,6 @@ MGAMapMem(ScrnInfoPtr pScrn)
if(pMga->entityPrivate != NULL)
pMga->entityPrivate->mappedIOUsage ++;
#else
/*
* For Alpha, we need to map SPARSE memory, since we need
* byte/short access. This is taken care of automatically by the
* os-support layer.
*/
pMga->IOBase = xf86MapPciMem(pScrn->scrnIndex,
VIDMEM_MMIO | VIDMEM_READSIDEEFFECT,
pMga->PciTag, pMga->IOAddress, 0x4000);
if (pMga->IOBase == NULL)
return FALSE;
if (pMga->is_G200ER)
{
pMga->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
pMga->PciTag, pMga->FbAddress,
pMga->FbMapSize);
}
else
{
pMga->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
pMga->PciTag, pMga->FbAddress,
pMga->FbMapSize);
}
if (pMga->FbBase == NULL)
return FALSE;
#endif
}
else {
pMga->FbBase = fbdevHWMapVidmem(pScrn);
@@ -2719,7 +2348,6 @@ MGAMapMem(ScrnInfoPtr pScrn)
pMga->ILOADBase = NULL;
if (pMga->iload_bar != -1) {
#ifdef XSERVER_LIBPCIACCESS
region = &dev->regions[pMga->iload_bar];
if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedILOADUsage == 0) {
@@ -2742,16 +2370,8 @@ MGAMapMem(ScrnInfoPtr pScrn)
if(pMga->entityPrivate != NULL)
pMga->entityPrivate->mappedILOADUsage ++;
#else
pMga->ILOADBase = xf86MapPciMem(pScrn->scrnIndex,
VIDMEM_MMIO | VIDMEM_MMIO_32BIT |
VIDMEM_READSIDEEFFECT,
pMga->PciTag, pMga->ILOADAddress,
0x800000);
#endif
}
return TRUE;
}
@@ -2764,13 +2384,9 @@ static Bool
MGAUnmapMem(ScrnInfoPtr pScrn)
{
MGAPtr pMga = MGAPTR(pScrn);
#ifdef XSERVER_LIBPCIACCESS
struct pci_device * const dev = pMga->PciInfo;
#endif
if (!pMga->FBDev) {
#ifdef XSERVER_LIBPCIACCESS
if(pMga->entityPrivate != NULL)
pMga->entityPrivate->mappedIOUsage--;
@@ -2785,10 +2401,6 @@ MGAUnmapMem(ScrnInfoPtr pScrn)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "UNMAPPING framebuffer 0x%08llX, 0x%llX.\n", (long long)(uintptr_t)pMga->FbBase, (long long)pMga->FbMapSize);
pci_device_unmap_range(dev, pMga->FbBase,
pMga->FbMapSize);
#else
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->IOBase, 0x4000);
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->FbBase, pMga->FbMapSize);
#endif
}
else {
fbdevHWUnmapVidmem(pScrn);
@@ -2796,7 +2408,6 @@ MGAUnmapMem(ScrnInfoPtr pScrn)
}
if ((pMga->iload_bar != -1) && (pMga->ILOADBase != NULL)) {
#ifdef XSERVER_LIBPCIACCESS
if(pMga->entityPrivate != NULL)
pMga->entityPrivate->mappedILOADUsage--;
@@ -2807,10 +2418,6 @@ MGAUnmapMem(ScrnInfoPtr pScrn)
if(pMga->entityPrivate != NULL)
pMga->entityPrivate->mappedILOADBase = NULL;
}
#else
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->ILOADBase, 0x800000);
#endif
}
pMga->IOBase = NULL;
@@ -3223,12 +2830,8 @@ MGAScreenInit(SCREEN_INIT_ARGS_DECL)
else {
fbdevHWSave(pScrn);
/* Disable VGA core, and leave memory access on */
#ifdef XSERVER_LIBPCIACCESS
pci_device_cfg_write_bits(pMga->PciInfo, 0x00000100, 0x00000000,
PCI_OPTION_REG);
#else
pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, 0x100, 0x000);
#endif
if (!fbdevHWModeInit(pScrn, pScrn->currentMode))
return FALSE;

View File

@@ -1,19 +1,11 @@
#ifndef _MGA_MACROS_H_
#define _MGA_MACROS_H_
#ifdef XSERVER_LIBPCIACCESS
#define MGA_IO_ADDRESS(p) (p)->PciInfo->regions[(p)->io_bar].base_addr
#define VENDOR_ID(p) (p)->vendor_id
#define DEVICE_ID(p) (p)->device_id
#define SUBSYS_ID(p) (p)->subdevice_id
#define CHIP_REVISION(p) (p)->revision
#else
#define MGA_IO_ADDRESS(p) (p)->IOAddress
#define VENDOR_ID(p) (p)->vendor
#define DEVICE_ID(p) (p)->chipType
#define SUBSYS_ID(p) (p)->subsysCard
#define CHIP_REVISION(p) (p)->chipRev
#endif
#define RGBEQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff))

View File

@@ -259,9 +259,6 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
return TRUE;
}
#ifndef XSERVER_LIBPCIACCESS
pMga->PciTag = pMga1->PciTag;
#endif
pMga->Primary = pMga1->Primary;
/* Set pScrn->monitor */
@@ -364,12 +361,6 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
pMga->FbAddress = pMga1->FbAddress;
pMga->PciInfo = pMga1->PciInfo;
#ifndef XSERVER_LIBPCIACCESS
pMga->IOAddress = pMga1->IOAddress;
pMga->ILOADAddress = pMga1->ILOADAddress;
pMga->BiosFrom = pMga1->BiosFrom;
pMga->BiosAddress = pMga1->BiosAddress;
#endif
/*
* Read the BIOS data struct