diff options
author | George Sapountzis <gsap7@yahoo.gr> | 2008-01-08 18:15:47 +0200 |
---|---|---|
committer | George Sapountzis <gsap7@yahoo.gr> | 2008-01-11 15:31:17 +0200 |
commit | 80c9974b6cdc0147d777df6990b3f3aacd87969d (patch) | |
tree | 496132a74cb4fb0716e4f0b24d87aeeacff2946d /src | |
parent | cd4b39403d74f314e1c2cfa4cf0e4fe542891dc3 (diff) |
r128: pci-rework conversion
compile-tested only
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/r128.h | 6 | ||||
-rw-r--r-- | src/r128_cursor.c | 2 | ||||
-rw-r--r-- | src/r128_dri.c | 16 | ||||
-rw-r--r-- | src/r128_driver.c | 74 | ||||
-rw-r--r-- | src/r128_video.c | 8 |
6 files changed, 82 insertions, 28 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index f8847c14..0f96e1c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -99,16 +99,12 @@ atimisc_drv_la_SOURCES = \ atiload.c atimisc.c atimach64probe.c $(ATIMISC_CPIO_SOURCES) \ $(ATIMISC_DGA_SOURCES) $(ATIMISC_DRI_SRCS) $(ATIMISC_EXA_SOURCES) -if XSERVER_LIBPCIACCESS -# r128 has not been ported yet -else r128_drv_la_LTLIBRARIES = r128_drv.la r128_drv_la_LDFLAGS = -module -avoid-version r128_drv_ladir = @moduledir@/drivers r128_drv_la_SOURCES = \ r128_accel.c r128_cursor.c r128_dga.c r128_driver.c \ r128_video.c r128_misc.c r128_probe.c $(R128_DRI_SRCS) -endif radeon_drv_la_LTLIBRARIES = radeon_drv.la radeon_drv_la_LDFLAGS = -module -avoid-version @@ -63,6 +63,8 @@ #include "GL/glxint.h" #endif +#include "atipcirename.h" + #define R128_DEBUG 0 /* Turn off debugging output */ #define R128_IDLE_RETRY 32 /* Fall out of idle loops after this count */ #define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */ @@ -234,8 +236,8 @@ typedef struct { unsigned long MMIOAddr; /* MMIO region physical address */ unsigned long BIOSAddr; /* BIOS physical address */ - unsigned char *MMIO; /* Map of MMIO region */ - unsigned char *FB; /* Map of frame buffer */ + void *MMIO; /* Map of MMIO region */ + void *FB; /* Map of frame buffer */ CARD32 MemCntl; CARD32 BusCntl; diff --git a/src/r128_cursor.c b/src/r128_cursor.c index 908ddb98..83212843 100644 --- a/src/r128_cursor.c +++ b/src/r128_cursor.c @@ -133,7 +133,7 @@ static void R128LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image) R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; CARD32 *s = (pointer)image; - CARD32 *d = (pointer)(info->FB + info->cursor_start); + CARD32 *d = (pointer)((CARD8*)info->FB + info->cursor_start); int y; CARD32 save; diff --git a/src/r128_dri.c b/src/r128_dri.c index edb77bac..da201e3b 100644 --- a/src/r128_dri.c +++ b/src/r128_dri.c @@ -470,8 +470,8 @@ static Bool R128DRIAgpInit(R128InfoPtr info, ScreenPtr pScreen) xf86DrvMsg(pScreen->myNum, X_INFO, "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", mode, vendor, device, - info->PciInfo->vendor, - info->PciInfo->chipType); + PCI_DEV_VENDOR_ID(info->PciInfo), + PCI_DEV_DEVICE_ID(info->PciInfo)); if (drmAgpEnable(info->drmFD, mode) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n"); @@ -910,9 +910,9 @@ static void R128DRIIrqInit(R128InfoPtr info, ScreenPtr pScreen) if (!info->irq) { info->irq = drmGetInterruptFromBusID( info->drmFD, - ((pciConfigPtr)info->PciInfo->thisCard)->busnum, - ((pciConfigPtr)info->PciInfo->thisCard)->devnum, - ((pciConfigPtr)info->PciInfo->thisCard)->funcnum); + PCI_CFG_BUS(info->PciInfo), + PCI_CFG_DEV(info->PciInfo), + PCI_CFG_FUNC(info->PciInfo)); if((drmCtlInstHandler(info->drmFD, info->irq)) != 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -1029,9 +1029,9 @@ Bool R128DRIScreenInit(ScreenPtr pScreen) pDRIInfo->busIdString = xalloc(64); sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", - info->PciInfo->bus, - info->PciInfo->device, - info->PciInfo->func); + PCI_DEV_BUS(info->PciInfo), + PCI_DEV_DEV(info->PciInfo), + PCI_DEV_FUNC(info->PciInfo)); } pDRIInfo->ddxDriverMajorVersion = R128_VERSION_MAJOR; pDRIInfo->ddxDriverMinorVersion = R128_VERSION_MINOR; diff --git a/src/r128_driver.c b/src/r128_driver.c index 4fcaab31..45917cd0 100644 --- a/src/r128_driver.c +++ b/src/r128_driver.c @@ -238,11 +238,26 @@ static Bool R128MapMMIO(ScrnInfoPtr pScrn) if (info->FBDev) { info->MMIO = fbdevHWMapMMIO(pScrn); } else { +#ifndef XSERVER_LIBPCIACCESS info->MMIO = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, info->PciTag, info->MMIOAddr, R128_MMIOSIZE); +#else + int err = pci_device_map_range(info->PciInfo, + info->MMIOAddr, + R128_MMIOSIZE, + PCI_DEV_MAP_FLAG_WRITABLE, + &info->MMIO); + + if (err) { + xf86DrvMsg (pScrn->scrnIndex, X_ERROR, + "Unable to map MMIO aperture. %s (%d)\n", + strerror (err), err); + return FALSE; + } +#endif } if (!info->MMIO) return FALSE; @@ -258,7 +273,11 @@ static Bool R128UnmapMMIO(ScrnInfoPtr pScrn) if (info->FBDev) fbdevHWUnmapMMIO(pScrn); else { +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, info->MMIO, R128_MMIOSIZE); +#else + pci_device_unmap_range(info->PciInfo, info->MMIO, R128_MMIOSIZE); +#endif } info->MMIO = NULL; return TRUE; @@ -272,11 +291,27 @@ static Bool R128MapFB(ScrnInfoPtr pScrn) if (info->FBDev) { info->FB = fbdevHWMapVidmem(pScrn); } else { +#ifndef XSERVER_LIBPCIACCESS info->FB = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, info->PciTag, info->LinearAddr, info->FbMapSize); +#else + int err = pci_device_map_range(info->PciInfo, + info->LinearAddr, + info->FbMapSize, + PCI_DEV_MAP_FLAG_WRITABLE | + PCI_DEV_MAP_FLAG_WRITE_COMBINE, + &info->FB); + + if (err) { + xf86DrvMsg (pScrn->scrnIndex, X_ERROR, + "Unable to map FB aperture. %s (%d)\n", + strerror (err), err); + return FALSE; + } +#endif } if (!info->FB) return FALSE; @@ -291,7 +326,11 @@ static Bool R128UnmapFB(ScrnInfoPtr pScrn) if (info->FBDev) fbdevHWUnmapVidmem(pScrn); else +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, info->FB, info->FbMapSize); +#else + pci_device_unmap_range(info->PciInfo, info->FB, info->FbMapSize); +#endif info->FB = NULL; return TRUE; } @@ -452,7 +491,13 @@ static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) (info->VBIOS[(v) + 2] << 16) | \ (info->VBIOS[(v) + 3] << 24)) - if (!(info->VBIOS = xalloc(R128_VBIOS_SIZE))) { +#ifdef XSERVER_LIBPCIACCESS + info->VBIOS = xalloc(info->PciInfo->rom_size); +#else + info->VBIOS = xalloc(R128_VBIOS_SIZE); +#endif + + if (!info->VBIOS) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot allocate space for hold Video BIOS!\n"); return FALSE; @@ -463,6 +508,12 @@ static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) (void)memcpy(info->VBIOS, xf86int10Addr(pInt10, info->BIOSAddr), R128_VBIOS_SIZE); } else { +#ifdef XSERVER_LIBPCIACCESS + if (pci_device_read_rom(info->PciInfo, info->VBIOS)) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Failed to read PCI ROM!\n"); + } +#else xf86ReadPciBIOS(0, info->PciTag, 0, info->VBIOS, R128_VBIOS_SIZE); if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, @@ -472,6 +523,7 @@ static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) info->BIOSAddr = 0x000c0000; xf86ReadDomainMemory(info->PciTag, info->BIOSAddr, R128_VBIOS_SIZE, info->VBIOS); } +#endif } if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { info->BIOSAddr = 0x00000000; @@ -810,7 +862,7 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) info->Chipset = dev->chipID; from = X_CONFIG; } else { - info->Chipset = info->PciInfo->chipType; + info->Chipset = PCI_DEV_DEVICE_ID(info->PciInfo); } pScrn->chipset = (char *)xf86TokenToString(R128Chipsets, info->Chipset); @@ -834,7 +886,7 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) /* Framebuffer */ from = X_PROBED; - info->LinearAddr = info->PciInfo->memBase[0] & 0xfc000000; + info->LinearAddr = PCI_REGION_BASE(info->PciInfo, 0, REGION_MEM) & 0xfc000000; pScrn->memPhysBase = info->LinearAddr; if (dev->MemBase) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -853,7 +905,7 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) /* MMIO registers */ from = X_PROBED; - info->MMIOAddr = info->PciInfo->memBase[2] & 0xffffff00; + info->MMIOAddr = PCI_REGION_BASE(info->PciInfo, 2, REGION_MEM) & 0xffffff00; if (dev->IOBase) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "MMIO address override, using 0x%08lx instead of 0x%08lx\n", @@ -868,6 +920,7 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at 0x%08lx\n", info->MMIOAddr); +#ifndef XSERVER_LIBPCIACCESS /* BIOS */ from = X_PROBED; info->BIOSAddr = info->PciInfo->biosBase & 0xfffe0000; @@ -883,6 +936,7 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, from, "BIOS at 0x%08lx\n", info->BIOSAddr); } +#endif /* Flat panel (part 1) */ if (xf86GetOptValBool(info->Options, OPTION_PROG_FP_REGS, @@ -1904,15 +1958,15 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int flags) } info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index); - info->PciTag = pciTag(info->PciInfo->bus, - info->PciInfo->device, - info->PciInfo->func); + info->PciTag = pciTag(PCI_DEV_BUS(info->PciInfo), + PCI_DEV_DEV(info->PciInfo), + PCI_DEV_FUNC(info->PciInfo)); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PCI bus %d card %d func %d\n", - info->PciInfo->bus, - info->PciInfo->device, - info->PciInfo->func); + PCI_DEV_BUS(info->PciInfo), + PCI_DEV_DEV(info->PciInfo), + PCI_DEV_FUNC(info->PciInfo)); if (xf86RegisterResources(info->pEnt->index, 0, ResNone)) goto fail; if (xf86SetOperatingState(resVga, info->pEnt->index, ResUnusedOpr)) goto fail; diff --git a/src/r128_video.c b/src/r128_video.c index 0f715aab..8e833235 100644 --- a/src/r128_video.c +++ b/src/r128_video.c @@ -397,6 +397,7 @@ R128DMA( #define BUFSIZE (R128_BUFFER_SIZE - R128_HOSTDATA_BLIT_OFFSET) #define MAXPASSES (MAXHEIGHT/(BUFSIZE/(MAXWIDTH*2))+1) + unsigned char *fb = (CARD8*)info->FB; unsigned char *buf; int err=-1, i, idx, offset, hpass, passes, srcpassbytes, dstpassbytes; int sizes[MAXPASSES], list[MAXPASSES]; @@ -439,7 +440,7 @@ R128DMA( dstpassbytes = hpass*dstPitch; dstPitch /= 8; - for (i=0, offset=dst-info->FB; i<passes; i++, offset+=dstpassbytes) { + for (i=0, offset=dst-fb; i<passes; i++, offset+=dstpassbytes) { if (i == (passes-1) && (h % hpass) != 0) { hpass = h % hpass; srcpassbytes = w*hpass; @@ -775,6 +776,7 @@ R128PutImage( ){ R128InfoPtr info = R128PTR(pScrn); R128PortPrivPtr pPriv = (R128PortPrivPtr)data; + unsigned char *fb = (CARD8*)info->FB; INT32 xa, xb, ya, yb; int new_size, offset, s1offset, s2offset, s3offset; int srcPitch, srcPitch2, dstPitch; @@ -899,7 +901,7 @@ R128PutImage( nlines = ((((yb + 0xffff) >> 16) + 1) & ~1) - top; R128CopyData420(info, buf + s1offset, buf + s2offset, buf + s3offset, - info->FB+d1offset, info->FB+d2offset, info->FB+d3offset, + fb + d1offset, fb + d2offset, fb + d3offset, srcPitch, srcPitch2, dstPitch, nlines, npixels); break; case FOURCC_UYVY: @@ -914,7 +916,7 @@ R128PutImage( d3offset = 0; s1offset += (top * srcPitch) + left; nlines = ((yb + 0xffff) >> 16) - top; - R128CopyData422(info, buf + s1offset, info->FB + d1offset, + R128CopyData422(info, buf + s1offset, fb + d1offset, srcPitch, dstPitch, nlines, npixels); break; } |