diff options
author | Luc Verhaegen <libv@skynet.be> | 2006-04-20 05:09:19 +0200 |
---|---|---|
committer | Luc Verhaegen <libv@skynet.be> | 2006-04-20 05:09:19 +0200 |
commit | 67b741b1ba4eb4f29bff5779dd4aa6a80ce5ec5a (patch) | |
tree | ff55336cb7b2594077b994d5afc595521a12e5b4 /src | |
parent | 0c4962d7ffeb4bb2c0569d3ffdece061d354954d (diff) |
Remove some trivial ugliness from atividmem.c
Diffstat (limited to 'src')
-rw-r--r-- | src/aticonsole.c | 4 | ||||
-rw-r--r-- | src/atipreinit.c | 34 | ||||
-rw-r--r-- | src/atistruct.h | 2 | ||||
-rw-r--r-- | src/atividmem.c | 146 | ||||
-rw-r--r-- | src/atividmem.h | 6 |
5 files changed, 61 insertions, 131 deletions
diff --git a/src/aticonsole.c b/src/aticonsole.c index 18a36c6..38275a9 100644 --- a/src/aticonsole.c +++ b/src/aticonsole.c @@ -539,7 +539,7 @@ ATIEnterGraphics ) { /* Map apertures */ - if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI)) + if (!Mach64AperturesMap(pATI)) return FALSE; /* Unlock device */ @@ -635,7 +635,7 @@ ATILeaveGraphics #endif /* AVOID_DGA */ - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); SetTimeSinceLastInputEvent(); } diff --git a/src/atipreinit.c b/src/atipreinit.c index 60290c4..aa2faf0 100644 --- a/src/atipreinit.c +++ b/src/atipreinit.c @@ -1827,7 +1827,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Adapter has not been initialised.\n"); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -1838,7 +1838,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) "Adapters found to be in VGA mode on server entry are not" " supported by the MMIO-only version of this driver.\n"); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -1957,7 +1957,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) "A linear aperture is not available.\n"); ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -1976,7 +1976,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) { ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -1993,7 +1993,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) (int)pScreenInfo->weight.blue, pScreenInfo->depth); ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -2005,7 +2005,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) { ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -2020,7 +2020,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) pScreenInfo->depth); ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -2030,7 +2030,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) if (!xf86SetGamma(pScreenInfo, defaultGamma)) { ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -2083,7 +2083,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) "VGA is not available through this adapter.\n"); ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } } @@ -2097,7 +2097,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) else if (!Mach64PanelInfoGet(pATI)) { ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } else if (pATI->OptionCRTDisplay) xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Using digital flat " @@ -2291,7 +2291,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) "Linear aperture not available.\n"); ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -2345,8 +2345,8 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) * remapping fails. */ ATILock(pATI); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); - if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI)) + Mach64AperturesUnmap(pATI); + if (!Mach64AperturesMap(pATI)) return FALSE; ATIUnlock(pATI); @@ -2483,7 +2483,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) { ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -2764,7 +2764,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) { ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -2785,7 +2785,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) { ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return FALSE; } @@ -2830,7 +2830,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + Mach64AperturesUnmap(pATI); return TRUE; } diff --git a/src/atistruct.h b/src/atistruct.h index 3078aaf..b4a3c6d 100644 --- a/src/atistruct.h +++ b/src/atistruct.h @@ -447,7 +447,7 @@ typedef struct _ATIRec /* * State flags. */ - CARD8 Unlocked, Mapped, Closeable; + CARD8 Unlocked, Closeable; CARD8 MMIOInLinear; /* diff --git a/src/atividmem.c b/src/atividmem.c index bbbca0f..2c02602 100644 --- a/src/atividmem.c +++ b/src/atividmem.c @@ -73,21 +73,15 @@ const char *ATIMemoryTypeNames_264xT[] = #ifndef AVOID_CPIO /* - * ATIUnmapVGA -- * - * Unmap VGA aperture. */ static void -ATIUnmapVGA -( - int iScreen, - ATIPtr pATI -) +Mach64VGAUnmap(ATIPtr pATI) { if (!pATI->pBank) return; - xf86UnMapVidMem(iScreen, pATI->pBank, 0x00010000U); + xf86UnMapVidMem(pATI->scrnIndex, pATI->pBank, 0x00010000U); pATI->pBank = pATI->BankInfo.pBankA = pATI->BankInfo.pBankB = NULL; } @@ -95,16 +89,10 @@ ATIUnmapVGA #endif /* AVOID_CPIO */ /* - * ATIUnmapLinear -- * - * Unmap linear aperture. */ static void -ATIUnmapLinear -( - int iScreen, - ATIPtr pATI -) +Mach64FBUnmap(ATIPtr pATI) { #ifdef AVOID_CPIO @@ -119,12 +107,12 @@ ATIUnmapLinear #endif /* AVOID_CPIO */ { - xf86UnMapVidMem(iScreen, pATI->pMemory, pATI->LinearSize); + xf86UnMapVidMem(pATI->scrnIndex, pATI->pMemory, pATI->LinearSize); #if X_BYTE_ORDER != X_LITTLE_ENDIAN if (pATI->pMemoryLE) - xf86UnMapVidMem(iScreen, pATI->pMemoryLE, pATI->LinearSize); + xf86UnMapVidMem(pATI->scrnIndex, pATI->pMemoryLE, pATI->LinearSize); #endif /* X_BYTE_ORDER */ @@ -134,26 +122,19 @@ ATIUnmapLinear } /* - * ATIUnmapCursor -- * - * Unmap hardware cursor image area. */ static void -ATIUnmapCursor -( - int iScreen, - ATIPtr pATI -) +Mach64CursorUnmap(ATIPtr pATI) { if (pATI->pCursorPage) - xf86UnMapVidMem(iScreen, pATI->pCursorPage, getpagesize()); + xf86UnMapVidMem(pATI->scrnIndex, pATI->pCursorPage, getpagesize()); pATI->pCursorPage = pATI->pCursorImage = NULL; } /* * - * */ Bool Mach64MMIOMap(ATIPtr pATI) @@ -175,6 +156,9 @@ Mach64MMIOMap(ATIPtr pATI) return TRUE; } +/* + * + */ static void Mach64MMIOUnmap(ATIPtr pATI) { @@ -184,21 +168,30 @@ Mach64MMIOUnmap(ATIPtr pATI) pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL; } +/* + * + */ +void +Mach64AperturesUnmap(ATIPtr pATI) +{ + Mach64CursorUnmap(pATI); + Mach64MMIOUnmap(pATI); + Mach64FBUnmap(pATI); + +#ifndef AVOID_CPIO + Mach64VGAUnmap(pATI); +#endif +} /* - * ATIMapApertures -- * - * This function maps all apertures used by the driver. */ Bool -ATIMapApertures(int iScreen, ATIPtr pATI) +Mach64AperturesMap(ATIPtr pATI) { PCITAG Tag = ((pciConfigPtr)(pATI->PCIInfo->thisCard))->tag; unsigned long PageSize = getpagesize(); - if (pATI->Mapped) - return TRUE; - #ifndef AVOID_CPIO if (!pATI->IsVGA) #endif /* AVOID_CPIO */ @@ -207,13 +200,13 @@ ATIMapApertures(int iScreen, ATIPtr pATI) #ifndef AVOID_CPIO /* Map VGA aperture */ - if (pATI->IsVGA) { + if (pATI->IsVGA && !pATI->pBank) { /* * No relocation, resizing, caching or write-combining of this * aperture is supported. Hence, the hard-coded values here... */ - pATI->pBank = xf86MapPciMem(iScreen, VIDMEM_MMIO, Tag, 0x000A0000U, - 0x00010000U); + pATI->pBank = xf86MapPciMem(pATI->scrnIndex, VIDMEM_MMIO, Tag, + 0x000A0000U, 0x00010000U); if (!pATI->pBank) return FALSE; @@ -221,27 +214,20 @@ ATIMapApertures(int iScreen, ATIPtr pATI) pATI->pMemory = pATI->BankInfo.pBankA = pATI->BankInfo.pBankB = pATI->pBank; - - pATI->Mapped = TRUE; } #endif /* AVOID_CPIO */ /* Map linear aperture */ - if (pATI->LinearBase) { - pATI->pMemory = xf86MapPciMem(iScreen, VIDMEM_FRAMEBUFFER, + if (pATI->LinearBase && !pATI->pMemory) { + pATI->pMemory = xf86MapPciMem(pATI->scrnIndex, VIDMEM_FRAMEBUFFER, Tag, pATI->LinearBase, pATI->LinearSize); if (!pATI->pMemory) { -#ifndef AVOID_CPIO - ATIUnmapVGA(iScreen, pATI); -#endif /* AVOID_CPIO */ - pATI->Mapped = FALSE; + Mach64AperturesUnmap(pATI); return FALSE; } - pATI->Mapped = TRUE; - #if X_BYTE_ORDER == X_LITTLE_ENDIAN if ((pATI->CursorBase >= pATI->LinearBase) && @@ -256,35 +242,21 @@ ATIMapApertures(int iScreen, ATIPtr pATI) * Map the little-endian aperture (used for video, etc.). Note that * caching of this area is _not_ wanted. */ - pATI->pMemoryLE = xf86MapPciMem(iScreen, VIDMEM_MMIO, Tag, + pATI->pMemoryLE = xf86MapPciMem(pATI->scrnIndex, VIDMEM_MMIO, Tag, pATI->LinearBase - 0x00800000U, pATI->LinearSize); - if (!pATI->pMemoryLE) { - ATIUnmapLinear(iScreen, pATI); - -#ifndef AVOID_CPIO - ATIUnmapVGA(iScreen, pATI); -#endif /* AVOID_CPIO */ - - pATI->Mapped = FALSE; + if (!pATI->pMemoryLE){ + Mach64AperturesUnmap(pATI); return FALSE; } #endif /* X_BYTE_ORDER */ } /* Map MMIO aperture */ - if (!pATI->pMMIO && !Mach64MMIOMap(pATI)) { - ATIUnmapCursor(iScreen, pATI); - ATIUnmapLinear(iScreen, pATI); - -#ifndef AVOID_CPIO - ATIUnmapVGA(iScreen, pATI); -#endif /* AVOID_CPIO */ - - pATI->Mapped = FALSE; + if (!pATI->pMMIO && !Mach64MMIOMap(pATI)){ + Mach64AperturesUnmap(pATI); return FALSE; } - pATI->Mapped = TRUE; /* * Try to stick the cursor in the vicinity of the MMIO address. @@ -302,18 +274,10 @@ ATIMapApertures(int iScreen, ATIPtr pATI) if (pATI->CursorBase && !pATI->pCursorImage) { unsigned long CursorBase = pATI->CursorBase & ~(PageSize - 1); - pATI->pCursorPage = xf86MapPciMem(iScreen, VIDMEM_FRAMEBUFFER, + pATI->pCursorPage = xf86MapPciMem(pATI->scrnIndex, VIDMEM_FRAMEBUFFER, Tag, CursorBase, PageSize); if (!pATI->pCursorPage) { - ATIUnmapCursor(iScreen, pATI); - Mach64MMIOUnmap(pATI); - ATIUnmapLinear(iScreen, pATI); - -#ifndef AVOID_CPIO - ATIUnmapVGA(iScreen, pATI); -#endif /* AVOID_CPIO */ - - pATI->Mapped = FALSE; + Mach64AperturesUnmap(pATI); return FALSE; } @@ -323,37 +287,3 @@ ATIMapApertures(int iScreen, ATIPtr pATI) return TRUE; } - -/* - * ATIUnmapApertures -- - * - * This function unmaps all apertures used by the driver. - */ -void -ATIUnmapApertures -( - int iScreen, - ATIPtr pATI -) -{ - if (!pATI->Mapped) - return; - pATI->Mapped = FALSE; - - /* Unmap hardware cursor image area */ - ATIUnmapCursor(iScreen, pATI); - - /* Unmap MMIO area */ - Mach64MMIOUnmap(pATI); - - /* Unmap linear aperture */ - ATIUnmapLinear(iScreen, pATI); - -#ifndef AVOID_CPIO - - /* Unmap VGA aperture */ - ATIUnmapVGA(iScreen, pATI); - -#endif /* AVOID_CPIO */ - -} diff --git a/src/atividmem.h b/src/atividmem.h index 10dc126..205c408 100644 --- a/src/atividmem.h +++ b/src/atividmem.h @@ -68,8 +68,8 @@ typedef enum } ATI264MemoryType; extern const char *ATIMemoryTypeNames_264xT[]; -extern Bool ATIMapApertures(int, ATIPtr); -extern void ATIUnmapApertures(int, ATIPtr); -extern Bool Mach64MMIOMap(ATIPtr pATI); +Bool Mach64AperturesMap(ATIPtr pATI); +void Mach64AperturesUnmap(ATIPtr pATI); +Bool Mach64MMIOMap(ATIPtr pATI); #endif /* ___ATIVIDMEM_H___ */ |