diff options
author | Dave Airlie <airlied@redhat.com> | 2008-03-10 16:22:57 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2008-03-10 16:22:57 +1000 |
commit | 2b7d32a60ffa6c87fa7a89eb206ed8916a682d93 (patch) | |
tree | fa7090ddb3d066ddcd959f000e10f369bfbf8b93 | |
parent | 1e763626aaefa1ae0cf4d4896c0b7192955e5993 (diff) |
amd: initial pciaccess conversion
-rw-r--r-- | configure.ac | 11 | ||||
-rw-r--r-- | src/amd.h | 2 | ||||
-rw-r--r-- | src/amd_driver.c | 5 | ||||
-rw-r--r-- | src/amd_gx_driver.c | 29 | ||||
-rw-r--r-- | src/amd_lx_driver.c | 36 |
5 files changed, 78 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index c219e06..b13576f 100644 --- a/configure.ac +++ b/configure.ac @@ -86,10 +86,21 @@ PKG_CHECK_MODULES(XORG, [xorg-server xproto fontsproto $REQUIRED_MODULES]) sdkdir=$(pkg-config --variable=sdkdir xorg-server) # Checks for libraries. +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $XORG_CFLAGS" +AC_CHECK_DECL(XSERVER_LIBPCIACCESS, + [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no], + [#include "xorg-server.h"]) +CPPFLAGS="$SAVE_CPPFLAGS" # Checks for header files. AC_HEADER_STDC +if test "x$XSERVER_LIBPCIACCESS" = xyes; then + PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0]) + XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" +fi + AC_SUBST([XORG_CFLAGS]) AC_SUBST([moduledir]) AC_SUBST([AMD_CFLAGS]) @@ -28,6 +28,8 @@ #ifndef _AMD_GEODE_H_ #define _AMD_GEODE_H_ +#include "amd_pcirename.h" + #include "xaa.h" #include "exa.h" #include "xf86Cursor.h" diff --git a/src/amd_driver.c b/src/amd_driver.c index 42e49ba..b153295 100644 --- a/src/amd_driver.c +++ b/src/amd_driver.c @@ -419,7 +419,10 @@ AmdProbe(DriverPtr drv, int flags) } DEBUGMSG(1, (0, X_INFO, "AmdProbe: Before MatchPciInstances!\n")); /* PCI BUS */ - if (xf86GetPciVideoInfo()) { +#ifndef XSERVER_LIBPCIACCESS + if (xf86GetPciVideoInfo()) +#endif + { numUsed = xf86MatchPciInstances(AMD_NAME, PCI_VENDOR_ID_NS, GeodeChipsets, GeodePCIchipsets, devSections, numDevSections, drv, &usedChips); diff --git a/src/amd_gx_driver.c b/src/amd_gx_driver.c index da4fa0b..09ad47a 100644 --- a/src/amd_gx_driver.c +++ b/src/amd_gx_driver.c @@ -317,7 +317,27 @@ GXSaveScreen(ScreenPtr pScrn, int mode) /* Common function - used by the LX too */ - +#ifdef XSERVER_LIBPCIACCESS +static inline void * map_pci_mem(ScrnInfoPtr pScrni, int vram, + struct pci_device *dev, + int bar, int size) +{ + void *ptr; + void** result = (void**)&ptr; + int map_size = size ? size : dev->regions[bar].size; + + int err = pci_device_map_range(dev, + dev->regions[bar].base_addr + map_size, + PCI_DEV_MAP_FLAG_WRITABLE | + (vram ? PCI_DEV_MAP_FLAG_WRITE_COMBINE : 0), + result); + + if (err) + return NULL; + return ptr; +} +#endif extern unsigned long gfx_gx2_scratch_base; @@ -330,6 +350,7 @@ GXMapMem(ScrnInfoPtr pScrni) pciVideoRec *pci = xf86GetPciInfoForEntity(pGeode->pEnt->index); +#ifndef XSERVER_LIBPCIACCESS gfx_virt_regptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO, pci->memBase[2], pci->size[2]); @@ -341,6 +362,12 @@ GXMapMem(ScrnInfoPtr pScrni) gfx_virt_fbptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, pci->memBase[0], pGeode->FBAvail); +#else + gfx_virt_regptr = map_pci_mem(pScrni, 0, pci, 2, 0); + gfx_virt_gpptr = map_pci_mem(pScrni, 0, pci, 1, 0); + gfx_virt_vidptr = map_pci_mem(pScrni, 0, pci, 3, 0); + gfx_virt_fbptr = map_pci_mem(pScrni, 1, pci, 0, pGeode->FBAvail); +#endif gfx_gx2_scratch_base = pGeode->FBAvail - 0x4000; diff --git a/src/amd_lx_driver.c b/src/amd_lx_driver.c index a2db90e..09882de 100644 --- a/src/amd_lx_driver.c +++ b/src/amd_lx_driver.c @@ -391,6 +391,27 @@ LXWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi) LX_MSR_WRITE(addr, lo, hi); } +#ifdef XSERVER_LIBPCIACCESS +static inline void * map_pci_mem(ScrnInfoPtr pScrni, int vram, + struct pci_device *dev, + int bar, int size) +{ + void *ptr; + void** result = (void**)&ptr; + int map_size = size ? size : dev->regions[bar].size; + + int err = pci_device_map_range(dev, + dev->regions[bar].base_addr + map_size, + PCI_DEV_MAP_FLAG_WRITABLE | + (vram ? PCI_DEV_MAP_FLAG_WRITE_COMBINE : 0), + result); + + if (err) + return NULL; + return ptr; +} +#endif static Bool LXMapMem(ScrnInfoPtr pScrni) @@ -403,6 +424,7 @@ LXMapMem(ScrnInfoPtr pScrni) pciVideoRec *pci = xf86GetPciInfoForEntity(pGeode->pEnt->index); tag = pciTag(pci->bus, pci->device, pci->func); +#ifndef XSERVER_LIBPCIACCESS cim_gp_ptr = (unsigned char *)xf86MapPciMem(index, VIDMEM_MMIO, tag, pci->memBase[1], LX_GP_REG_SIZE); @@ -417,18 +439,26 @@ LXMapMem(ScrnInfoPtr pScrni) cim_fb_ptr = (unsigned char *)xf86MapPciMem(index, VIDMEM_FRAMEBUFFER, tag, pci->memBase[0], pGeode->FBAvail + CIM_CMD_BFR_SZ); +#else + cim_gp_ptr = map_pci_mem(pScrni, 0, pci, 1, LX_GP_REG_SIZE); + cim_vg_ptr = map_pci_mem(pScrni, 0, pci, 2, LX_VG_REG_SIZE); + cim_vid_ptr = map_pci_mem(pScrni, 0, pci, 3, LX_VID_REG_SIZE); + cim_vip_ptr = map_pci_mem(pScrni, 0, pci, 4, LX_VIP_REG_SIZE); + cim_fb_ptr = map_pci_mem(pScrni, 1, pci, 0, pGeode->FBAvail + CIM_CMD_BFR_SZ); +#endif if (pScrni->memPhysBase == 0) - pScrni->memPhysBase = pci->memBase[0]; + pScrni->memPhysBase = PCI_REGION_BASE(pci, 0, REGION_MEM); + - cmd_bfr_phys = pci->memBase[0] + pGeode->CmdBfrOffset; + cmd_bfr_phys = PCI_REGION_BASE(pci, 0, REGION_MEM) + pGeode->CmdBfrOffset; cim_cmd_base_ptr = cim_fb_ptr + pGeode->CmdBfrOffset; if (!cim_gp_ptr || !cim_vg_ptr || !cim_vid_ptr || !cim_fb_ptr || !cim_vip_ptr) return FALSE; - gp_set_frame_buffer_base(pci->memBase[0], pGeode->FBAvail); + gp_set_frame_buffer_base(PCI_REGION_BASE(pci, 0, REGION_MEM), pGeode->FBAvail); gp_set_command_buffer_base(cmd_bfr_phys, 0, pGeode->CmdBfrSize); XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000); |