diff options
author | George Sapountzis <gsap7@yahoo.gr> | 2007-02-05 19:16:51 +0200 |
---|---|---|
committer | George Sapountzis <gsap7@yahoo.gr> | 2007-02-05 19:16:51 +0200 |
commit | 9d77aabdff919360f0c9333105436c31f1f5749a (patch) | |
tree | fa0617724e538435cf2b04b7a63ef006fc73fe04 /src | |
parent | ff8ea19fcdce099732f9359e53cd62b9a04bfa6d (diff) | |
parent | 57822be75740f339445f2375d44632560f4bbe57 (diff) |
Merge branch 'mach64-pci-1'
Diffstat (limited to 'src')
49 files changed, 516 insertions, 6661 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index b1410f7..ee4911b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,7 +52,7 @@ ati_drv_la_LTLIBRARIES = ati_drv.la ati_drv_la_LDFLAGS = -module -avoid-version ati_drv_ladir = @moduledir@/drivers ati_drv_la_SOURCES = \ - ati.c atiadapter.c atibus.c atichip.c atiident.c atioption.c \ + ati.c atibus.c atichip.c atiident.c atioption.c \ atiprobe.c atividmem.c atimodule.c $(ATI_CPIO_SOURCES) \ radeon_probe.c r128_probe.c @@ -109,7 +109,6 @@ EXTRA_DIST = \ radeon_accelfuncs.c \ \ atiaccel.h \ - atiadapter.h \ atiadjust.h \ atiaudio.h \ atibank.h \ @@ -130,7 +129,6 @@ EXTRA_DIST = \ ati.h \ atii2c.h \ atiident.h \ - atiio.h \ atiload.h \ atilock.h \ atimach64accel.h \ @@ -142,7 +140,6 @@ EXTRA_DIST = \ atimach64xv.h \ atimode.h \ atimodule.h \ - atimono.h \ atioption.h \ atipreinit.h \ atiprint.h \ diff --git a/src/atiaccel.c b/src/atiaccel.c index 61cb864..11c39c7 100644 --- a/src/atiaccel.c +++ b/src/atiaccel.c @@ -28,7 +28,6 @@ #endif #include "atiaccel.h" -#include "atiadapter.h" #include "atimach64accel.h" #include "atistruct.h" @@ -52,14 +51,8 @@ ATIInitializeAcceleration if (!(pATI->pXAAInfo = XAACreateInfoRec())) return FALSE; - switch (pATI->Adapter) { - case ATI_ADAPTER_MACH64: ATIMach64AccelInit(pATI, pATI->pXAAInfo); - break; - - default: - break; } } diff --git a/src/atiadapter.c b/src/atiadapter.c deleted file mode 100644 index b0b5580..0000000 --- a/src/atiadapter.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of Marc Aurele La France not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Marc Aurele La France makes no representations - * about the suitability of this software for any purpose. It is provided - * "as-is" without express or implied warranty. - * - * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "atiadapter.h" - -/* - * Adapter-related definitions. - */ -const char *ATIAdapterNames[] = -{ - "Unknown", - -#ifndef AVOID_CPIO - - "ATI EGA Wonder800", - "ATI EGA Wonder800+", - "IBM VGA or compatible", - "ATI VGA Basic16", - "ATI VGA Wonder V3", - "ATI VGA Wonder V4", - "ATI VGA Wonder V5", - "ATI VGA Wonder+", - "ATI VGA Wonder XL or XL24", - "ATI VGA Wonder VLB or PCI", - "IBM 8514/A or compatible", - "ATI Mach8", - "ATI Mach32", - -#endif /* AVOID_CPIO */ - - "ATI Mach64", - "ATI Rage128", - "ATI Radeon" -}; diff --git a/src/atiadapter.h b/src/atiadapter.h deleted file mode 100644 index 66a5e99..0000000 --- a/src/atiadapter.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 1997 through 2003 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of Marc Aurele La France not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Marc Aurele La France makes no representations - * about the suitability of this software for any purpose. It is provided - * "as-is" without express or implied warranty. - * - * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef ___ATIADAPTER_H___ -#define ___ATIADAPTER_H___ 1 - -/* - * Adapter-related definitions. - */ -typedef enum -{ - ATI_ADAPTER_NONE = 0, - -#ifndef AVOID_CPIO - - ATI_ADAPTER_EGA, - ATI_ADAPTER_EGA_PLUS, - ATI_ADAPTER_VGA, - ATI_ADAPTER_BASIC, - ATI_ADAPTER_V3, - ATI_ADAPTER_V4, - ATI_ADAPTER_V5, - ATI_ADAPTER_PLUS, - ATI_ADAPTER_XL, - ATI_ADAPTER_NONISA, - ATI_ADAPTER_8514A, - ATI_ADAPTER_MACH8, - ATI_ADAPTER_MACH32, - -#endif /* AVOID_CPIO */ - - ATI_ADAPTER_MACH64, - ATI_ADAPTER_RAGE128, - ATI_ADAPTER_RADEON, - ATI_ADAPTER_MAX /* Must be last */ -} ATIAdapterType; - -extern const char *ATIAdapterNames[]; - -#endif /* ___ATIADAPTER_H___ */ diff --git a/src/atiadjust.c b/src/atiadjust.c index ef748e9..f01fee6 100644 --- a/src/atiadjust.c +++ b/src/atiadjust.c @@ -27,7 +27,6 @@ #include "ati.h" #include "atiadjust.h" #include "atichip.h" -#include "aticrtc.h" #include "atilock.h" #include "atimach64io.h" #include "atiwonderio.h" @@ -54,21 +53,6 @@ ATIAdjustPreInit { unsigned long MaxBase; -#ifndef AVOID_CPIO - - if ((pATI->CPIO_VGAWonder) && - (pATI->Chip <= ATI_CHIP_18800_1) && - (pATI->VideoRAM == 256) && - (pATI->depth >= 8)) - { - /* Strange, to say the least ... */ - pATI->AdjustDepth = (pATI->bitsPerPixel + 3) >> 2; - pATI->AdjustMask = (unsigned long)(-32); - } - else - -#endif /* AVOID_CPIO */ - { pATI->AdjustDepth = (pATI->bitsPerPixel + 7) >> 3; @@ -80,41 +64,8 @@ ATIAdjustPreInit 1); } - switch (pATI->NewHW.crtc) { - -#ifndef AVOID_CPIO - - case ATI_CRTC_VGA: - if (pATI->Chip >= ATI_CHIP_264CT) - { - pATI->AdjustMaxBase = MaxBits(CRTC_OFFSET_VGA) << 2; - if (pATI->depth <= 4) - pATI->AdjustMaxBase <<= 1; - } - else if (!pATI->CPIO_VGAWonder) - { - pATI->AdjustMaxBase = 0xFFFFU << 3; - } - else if (pATI->Chip <= ATI_CHIP_28800_6) - { - pATI->AdjustMaxBase = 0x03FFFFU << 3; - } - else /* Mach32 & Mach64 */ - { - pATI->AdjustMaxBase = 0x0FFFFFU << 3; - } - break; - -#endif /* AVOID_CPIO */ - - case ATI_CRTC_MACH64: pATI->AdjustMaxBase = MaxBits(CRTC_OFFSET) << 3; - break; - - default: - pATI->AdjustMaxBase = 0; - break; } MaxBase = (pATI->AdjustMaxBase / (unsigned long)pATI->AdjustDepth) | @@ -176,57 +127,7 @@ ATIAdjustFrame /* Unlock registers */ ATIUnlock(pATI); -#ifndef AVOID_CPIO - - if ((pATI->NewHW.crtc == ATI_CRTC_VGA) && (pATI->Chip < ATI_CHIP_264CT)) - { - PutReg(CRTX(pATI->CPIO_VGABase), 0x0CU, GetByte(Base, 1)); - PutReg(CRTX(pATI->CPIO_VGABase), 0x0DU, GetByte(Base, 0)); - - if (pATI->CPIO_VGAWonder) - { - if (pATI->Chip <= ATI_CHIP_18800_1) - ATIModifyExtReg(pATI, 0xB0U, -1, 0x3FU, Base >> 10); - else - { - ATIModifyExtReg(pATI, 0xB0U, -1, 0xBFU, Base >> 10); - ATIModifyExtReg(pATI, 0xA3U, -1, 0xEFU, Base >> 13); - - /* - * I don't know if this also applies to Mach64's, but give it a - * shot... - */ - if (pATI->Chip >= ATI_CHIP_68800) - ATIModifyExtReg(pATI, 0xADU, -1, 0xF3U, Base >> 16); - } - } - } - else - /* - * On integrated controllers, there is only one set of CRTC control bits, - * many of which are simultaneously accessible through both VGA and - * accelerator I/O ports. Given VGA's architectural limitations, setting - * the CRTC's offset register to more than 256k needs to be done through - * the accelerator port. - */ - if (pATI->depth <= 4) { - outr(CRTC_OFF_PITCH, SetBits(pATI->displayWidth >> 4, CRTC_PITCH) | - SetBits(Base, CRTC_OFFSET)); - } - else - -#endif /* AVOID_CPIO */ - - { - -#ifndef AVOID_CPIO - - if (pATI->NewHW.crtc == ATI_CRTC_VGA) - Base <<= 1; /* LSBit must be zero */ - -#endif /* AVOID_CPIO */ - outr(CRTC_OFF_PITCH, SetBits(pATI->displayWidth >> 3, CRTC_PITCH) | SetBits(Base, CRTC_OFFSET)); } diff --git a/src/atibank.c b/src/atibank.c index 446c55f..514a414 100644 --- a/src/atibank.c +++ b/src/atibank.c @@ -32,148 +32,6 @@ #ifndef AVOID_CPIO /* - * ATI VGA Wonder V3 adapters use an ATI 18800 chip and are single-banked. - * Bank selection is done with bits 0x1E of ATI extended VGA register index - * 0xB2. - */ - -/* - * ATIV3SetBank -- - * - * Set an ATI 18800's bank number. - */ -void -ATIV3SetBank -( - ATIPtr pATI, - unsigned int iBank -) -{ - ATIModifyExtReg(pATI, 0xB2U, -1, (CARD8)(~0x1EU), SetBits(iBank, 0x1EU)); -} - -/* - * ATIV3SetReadWrite -- - * - * Set an ATI 18800's bank number. - */ -int -ATIV3SetReadWrite -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); - - ATIModifyExtReg(pATI, 0xB2U, -1, (CARD8)(~0x1EU), SetBits(iBank, 0x1EU)); - return 0; -} - -/* - * ATI VGA Wonder V4 and V5 adapters use an ATI 18800-1 chip. Bank selection - * is done with ATI extended VGA register index 0xB2. The format is: - * - * 0xE0 - Read bank select bits 0x07 - * 0x1E - Write bank select bits 0x0F - * 0x01 - Read bank select bit 0x08. - */ - -/* - * ATIV4V5SetBank -- - * - * Set an ATI 18800-1's read and write bank numbers. - */ -void -ATIV4V5SetBank -( - ATIPtr pATI, - unsigned int iBank -) -{ - pATI->B2Reg = SetBits(iBank, 0x1EU) | SetBits(iBank, 0xE0U) | - SetBits(GetBits(iBank, 0x08U), 0x01U); - ATIPutExtReg(0xB2U, pATI->B2Reg); -} - -/* - * ATIV4V5SetRead -- - * - * Set an ATI 18800-1's read bank number. - */ -int -ATIV4V5SetRead -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); - CARD8 B2Reg = (pATI->B2Reg & 0x1EU) | SetBits(iBank, 0xE0U) | - SetBits(GetBits(iBank, 0x08U), 0x01U); - - if (B2Reg != pATI->B2Reg) - { - ATIPutExtReg(0xB2U, B2Reg); - pATI->B2Reg = B2Reg; - } - - return 0; -} - -/* - * ATIV4V5SetWrite -- - * - * Set an ATI 18800-1's write bank number. - */ -int -ATIV4V5SetWrite -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); - CARD8 B2Reg = (pATI->B2Reg & 0xE1U) | SetBits(iBank, 0x1EU); - - if (B2Reg != pATI->B2Reg) - { - ATIPutExtReg(0xB2U, B2Reg); - pATI->B2Reg = B2Reg; - } - return 0; -} - -/* - * ATIV4V5SetReadWrite -- - * - * Set an ATI 18800-1's read and write bank numbers. - */ -int -ATIV4V5SetReadWrite -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIV4V5SetBank(ATIPTR(XF86SCRNINFO(pScreen)), iBank); - return 0; -} - -/* - * In addition to ATI extended register index 0xB2, 28800's, 68800's and - * 88800's define banking bits in bits 0x0F of ATI extended VGA register index - * 0xAE. These are only needed for adapters with more than 1MB of video - * memory, and it is questionable whether or not they are actually implemented - * by 28800's and 88800's. ATI extended VGA register index 0xAE is defined as - * follows: - * - * 0xF0 - reserved - * 0x0C - read bank select bits 0x30 - * 0x03 - write bank select bits 0x30 - */ - -/* * ATIx8800SetBank -- * * Set an ATI 28800's, 68800's or 88800's read and write bank numbers. @@ -185,62 +43,10 @@ ATIx8800SetBank unsigned int iBank ) { - ATIV4V5SetBank(pATI, iBank); - iBank = GetBits(iBank, 0x30U); - ATIModifyExtReg(pATI, 0xAEU, -1, (CARD8)(~0x0FU), - SetBits(iBank, 0x03U) | SetBits(iBank, 0x0CU)); -} - -/* - * ATIx8800SetRead -- - * - * Set an ATI 28800's, 68800's or 88800's read bank numbers. - */ -int -ATIx8800SetRead -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - (void)ATIV4V5SetRead(pScreen, iBank); - ATIModifyExtReg(ATIPTR(XF86SCRNINFO(pScreen)), 0xAEU, -1, (CARD8)(~0x0CU), - SetBits(GetBits(iBank, 0x30U), 0x0CU)); - return 0; -} - -/* - * ATIx8800SetWrite -- - * - * Set an ATI 28800's, 68800's or 88800's write bank numbers. - */ -int -ATIx8800SetWrite -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - (void)ATIV4V5SetWrite(pScreen, iBank); - ATIModifyExtReg(ATIPTR(XF86SCRNINFO(pScreen)), 0xAEU, -1, (CARD8)(~0x03U), - SetBits(GetBits(iBank, 0x30U), 0x03U)); - return 0; -} + (void)iBank; /* always called with iBank = 0 */ -/* - * ATIx8800SetReadWrite -- - * - * Set an ATI 28800's, 68800's or 88800's read and write bank numbers. - */ -int -ATIx8800SetReadWrite -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIx8800SetBank(ATIPTR(XF86SCRNINFO(pScreen)), iBank); - return 0; + ATIPutExtReg(0xB2U, 0x00U); + ATIModifyExtReg(pATI, 0xAEU, -1, (CARD8)(~0x0FU), 0x00U); } /* @@ -277,58 +83,6 @@ ATIMach64SetBankPacked outr(MEM_VGA_WP_SEL, tmp); } -/* - * ATIMach64SetReadPacked -- - * - * Set read bank number for small dual paged apertures. - */ -int -ATIMach64SetReadPacked -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); - - outr(MEM_VGA_RP_SEL, ATIMach64MassagePackedBankNumber(iBank)); - return 0; -} - -/* - * ATIMach64SetWritePacked -- - * - * Set write bank number for small dual paged apertures. - */ -int -ATIMach64SetWritePacked -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); - - outr(MEM_VGA_WP_SEL, ATIMach64MassagePackedBankNumber(iBank)); - return 0; -} - -/* - * ATIMach64SetReadWritePacked -- - * - * Set read and write bank numbers for small dual paged apertures. - */ -int -ATIMach64SetReadWritePacked -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIMach64SetBankPacked(ATIPTR(XF86SCRNINFO(pScreen)), iBank); - return 0; -} - static CARD32 ATIMach64MassagePlanarBankNumber ( @@ -357,56 +111,4 @@ ATIMach64SetBankPlanar outr(MEM_VGA_WP_SEL, tmp); } -/* - * ATIMach64SetReadPlanar -- - * - * Set read bank number for small dual paged apertures. - */ -int -ATIMach64SetReadPlanar -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); - - outr(MEM_VGA_RP_SEL, ATIMach64MassagePlanarBankNumber(iBank)); - return 0; -} - -/* - * ATIMach64SetWritePlanar -- - * - * Set write bank number for small dual paged apertures. - */ -int -ATIMach64SetWritePlanar -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); - - outr(MEM_VGA_WP_SEL, ATIMach64MassagePlanarBankNumber(iBank)); - return 0; -} - -/* - * ATIMach64SetReadWritePlanar -- - * - * Set read and write bank numbers for small dual paged apertures. - */ -int -ATIMach64SetReadWritePlanar -( - ScreenPtr pScreen, - unsigned int iBank -) -{ - ATIMach64SetBankPlanar(ATIPTR(XF86SCRNINFO(pScreen)), iBank); - return 0; -} - #endif /* AVOID_CPIO */ diff --git a/src/atibank.h b/src/atibank.h index 49ffc54..d56da68 100644 --- a/src/atibank.h +++ b/src/atibank.h @@ -25,49 +25,9 @@ #include "atipriv.h" -#include "mibank.h" - #ifndef AVOID_CPIO /* - * Banking definitions. - */ - -/* - * Bank selection function for VGA Wonder V3 adapters (which are - * single-banked). - */ -#define ATIV3SetRead ATIV3SetReadWrite -#define ATIV3SetWrite ATIV3SetReadWrite -extern miBankProc ATIV3SetReadWrite; - -/* - * Bank selection functions for VGA Wonder V4 and V5 adapters. - */ -extern miBankProc ATIV4V5SetRead, - ATIV4V5SetWrite, - ATIV4V5SetReadWrite; - -/* - * Bank selection functions for 28800-x, 68800-x and 88800 based adapters. - */ -extern miBankProc ATIx8800SetRead, - ATIx8800SetWrite, - ATIx8800SetReadWrite; - -/* - * Bank selection functions used to simulate a banked VGA aperture with a - * Mach64's small dual paged apertures. There are two sets of these: one for - * packed modes, and one for planar modes. - */ -extern miBankProc ATIMach64SetReadPacked, - ATIMach64SetWritePacked, - ATIMach64SetReadWritePacked; -extern miBankProc ATIMach64SetReadPlanar, - ATIMach64SetWritePlanar, - ATIMach64SetReadWritePlanar; - -/* * The CRT save/restore code also needs a separate banking interface that can * used before ATIScreenInit() is called. */ @@ -75,9 +35,7 @@ extern miBankProc ATIMach64SetReadPlanar, typedef void ATIBankProc(ATIPtr, unsigned int); typedef ATIBankProc *ATIBankProcPtr; -extern ATIBankProc ATIV3SetBank, - ATIV4V5SetBank, - ATIx8800SetBank, +extern ATIBankProc ATIx8800SetBank, ATIMach64SetBankPacked, ATIMach64SetBankPlanar; diff --git a/src/atibus.c b/src/atibus.c index cf2969f..32f02b6 100644 --- a/src/atibus.c +++ b/src/atibus.c @@ -27,10 +27,9 @@ #include <string.h> #include "ati.h" -#include "atiadapter.h" #include "atibus.h" #include "atichip.h" -#include "atiio.h" +#include "atimach64io.h" #include "atistruct.h" #include "ativersion.h" @@ -40,13 +39,6 @@ const char *ATIBusNames[] = { - "16-Bit ISA", - "EISA", - "16-Bit MicroChannel", - "32-Bit MicroChannel", - "386SX Local Bus", - "386DX Local Bus", - "VESA Local Bus", "PCI", "AGP" }; @@ -67,14 +59,13 @@ ATIClaimResources Bool Active ) { - resPtr pResources; #ifndef AVOID_CPIO resRange Resources[2] = {{0, 0, 0}, _END}; /* Claim VGA and VGAWonder resources */ - if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) && (Active || !pATI->SharedVGA)) + if ((pATI->VGAAdapter) && (Active)) { /* * 18800-x's are the only ATI controllers that decode all ISA aliases @@ -82,23 +73,13 @@ ATIClaimResources * VGA aliases, but do decode VGA Wonder aliases whose most significant * nibble is zero. */ - xf86ClaimFixedResources( - (pATI->Chip <= ATI_CHIP_18800_1) ? - (pATI->SharedVGA ? resVgaSparseShared : resVgaSparseExclusive) : - (pATI->SharedVGA ? resVgaShared : resVgaExclusive), - pATI->iEntity); + xf86ClaimFixedResources(resVgaShared, pATI->iEntity); if (pATI->CPIO_VGAWonder) { - if (pATI->SharedVGA) - Resources[0].type = ResShrIoSparse | ResBus; - else - Resources[0].type = ResExcIoSparse | ResBus; + Resources[0].type = ResShrIoSparse | ResBus; Resources[0].rBase = pATI->CPIO_VGAWonder; - if (pATI->Chip <= ATI_CHIP_18800_1) - Resources[0].rMask = 0x03FEU; - else - Resources[0].rMask = 0xF3FEU; + Resources[0].rMask = 0xF3FEU; xf86ClaimFixedResources(Resources, pATI->iEntity); @@ -107,54 +88,21 @@ ATIClaimResources } } - if (!Active && pATI->SharedAccelerator) + if (!Active) return; - /* Claim 8514/A resources */ - if (pATI->ChipHasSUBSYS_CNTL) - xf86ClaimFixedResources( - pATI->SharedAccelerator ? res8514Shared : res8514Exclusive, - pATI->iEntity); - /* Claim Mach64 sparse I/O resources */ - if ((pATI->Adapter == ATI_ADAPTER_MACH64) && - (pATI->CPIODecoding == SPARSE_IO)) + if ((pATI->CPIODecoding == SPARSE_IO)) { - if (pATI->SharedAccelerator) - Resources[0].type = ResShrIoSparse | ResBus; - else - Resources[0].type = ResExcIoSparse | ResBus; + Resources[0].type = ResShrIoSparse | ResBus; Resources[0].rBase = pATI->CPIOBase; Resources[0].rMask = 0x03FCU; xf86ClaimFixedResources(Resources, pATI->iEntity); } - if (Active) - return; - -#else /* AVOID_CPIO */ - - if (pATI->SharedAccelerator) - return; - #endif /* AVOID_CPIO */ - /* Register unshared relocatable resources for inactive adapters */ - do - { - pResources = xf86RegisterResources(pATI->iEntity, NULL, ResExclusive); - if (!pResources) - return; - - pResources = xf86ReallocatePciResources(pATI->iEntity, pResources); - } while (!pResources); - - xf86Msg(X_WARNING, - ATI_NAME ": Unable to register the following resources for inactive" - " adapter:\n"); - xf86PrintResList(1, pResources); - xf86FreeResList(pResources); } /* @@ -165,22 +113,10 @@ ATIClaimResources int ATIClaimBusSlot ( - DriverPtr pDriver, - int Chipset, - GDevPtr pGDev, Bool Active, ATIPtr pATI ) { - pciVideoPtr pVideo = pATI->PCIInfo; - - if (pVideo) - pATI->iEntity = - xf86ClaimPciSlot(pVideo->bus, pVideo->device, pVideo->func, - pDriver, Chipset, pGDev, Active); - else - pATI->iEntity = xf86ClaimIsaSlot(pDriver, Chipset, pGDev, Active); - if (pATI->iEntity >= 0) ATIClaimResources(pATI, Active); diff --git a/src/atibus.h b/src/atibus.h index b719702..c5c676e 100644 --- a/src/atibus.h +++ b/src/atibus.h @@ -38,19 +38,13 @@ */ typedef enum { - ATI_BUS_ISA = 0, - ATI_BUS_EISA, - ATI_BUS_MCA16, - ATI_BUS_MCA32, - ATI_BUS_SXLB, - ATI_BUS_DXLB, - ATI_BUS_VLB, ATI_BUS_PCI, ATI_BUS_AGP } ATIBusType; extern const char *ATIBusNames[]; -extern int ATIClaimBusSlot(DriverPtr, int, GDevPtr, Bool, ATIPtr); +extern Bool ATIMach64ProbeIO(pciVideoPtr, ATIPtr); +extern int ATIClaimBusSlot(Bool, ATIPtr); #endif /* ___ATIBUS_H___ */ diff --git a/src/atichip.c b/src/atichip.c index 09d2cad..ddc7e0a 100644 --- a/src/atichip.c +++ b/src/atichip.c @@ -36,27 +36,6 @@ const char *ATIChipNames[] = { "Unknown", - -#ifndef AVOID_CPIO - - "IBM VGA or compatible", - "ATI 18800", - "ATI 18800-1", - "ATI 28800-2", - "ATI 28800-4", - "ATI 28800-5", - "ATI 28800-6", - "IBM 8514/A", - "Chips & Technologies 82C480", - "ATI 38800-1", - "ATI 68800", - "ATI 68800-3", - "ATI 68800-6", - "ATI 68800LX", - "ATI 68800AX", - -#endif /* AVOID_CPIO */ - "ATI 88800GX-C", "ATI 88800GX-D", "ATI 88800GX-E", @@ -122,52 +101,6 @@ const char *ATIChipNames[] = const char *ATIFoundryNames[] = { "SGS", "NEC", "KCS", "UMC", "TSMC", "5", "6", "UMC" }; -#ifndef AVOID_CPIO - -/* - * ATIMach32ChipID -- - * - * Set variables whose value is dependent upon an 68800's CHIP_ID register. - */ -void -ATIMach32ChipID -( - ATIPtr pATI -) -{ - CARD16 IOValue = inw(CHIP_ID); - pATI->ChipType = GetBits(IOValue, CHIP_CODE_0 | CHIP_CODE_1); - pATI->ChipClass = GetBits(IOValue, CHIP_CLASS); - pATI->ChipRevision = GetBits(IOValue, CHIP_REV); - pATI->ChipRev = pATI->ChipRevision; - if (IOValue == 0xFFFFU) - IOValue = 0; - switch (GetBits(IOValue, CHIP_CODE_0 | CHIP_CODE_1)) - { - case OldChipID('A', 'A'): - pATI->Chip = ATI_CHIP_68800_3; - break; - - case OldChipID('X', 'X'): - pATI->Chip = ATI_CHIP_68800_6; - break; - - case OldChipID('L', 'X'): - pATI->Chip = ATI_CHIP_68800LX; - break; - - case OldChipID('A', 'X'): - pATI->Chip = ATI_CHIP_68800AX; - break; - - default: - pATI->Chip = ATI_CHIP_68800; - break; - } -} - -#endif /* AVOID_CPIO */ - /* * ATIMach64ChipID -- * @@ -456,23 +389,6 @@ ATIChipID { switch (ChipID) { - -#ifndef AVOID_CPIO - - case OldChipID('A', 'A'): case NewChipID('A', 'A'): - return ATI_CHIP_68800_3; - - case OldChipID('X', 'X'): case NewChipID('X', 'X'): - return ATI_CHIP_68800_6; - - case OldChipID('L', 'X'): - return ATI_CHIP_68800LX; - - case OldChipID('A', 'X'): case NewChipID('A', 'X'): - return ATI_CHIP_68800AX; - -#endif /* AVOID_CPIO */ - case OldChipID('G', 'X'): case NewChipID('G', 'X'): switch (ChipRev) { diff --git a/src/atichip.h b/src/atichip.h index ee3e0cf..733c7b1 100644 --- a/src/atichip.h +++ b/src/atichip.h @@ -34,27 +34,6 @@ typedef enum { ATI_CHIP_NONE = 0, - -#ifndef AVOID_CPIO - - ATI_CHIP_VGA, /* Generic VGA */ - ATI_CHIP_18800, - ATI_CHIP_18800_1, - ATI_CHIP_28800_2, - ATI_CHIP_28800_4, - ATI_CHIP_28800_5, - ATI_CHIP_28800_6, - ATI_CHIP_8514A, /* 8514/A */ - ATI_CHIP_CT480, /* 8514/A clone */ - ATI_CHIP_38800_1, /* Mach8 */ - ATI_CHIP_68800, /* Mach32 */ - ATI_CHIP_68800_3, /* Mach32 */ - ATI_CHIP_68800_6, /* Mach32 */ - ATI_CHIP_68800LX, /* Mach32 */ - ATI_CHIP_68800AX, /* Mach32 */ - -#endif /* AVOID_CPIO */ - ATI_CHIP_88800GXC, /* Mach64 */ ATI_CHIP_88800GXD, /* Mach64 */ ATI_CHIP_88800GXE, /* Mach64 */ @@ -136,12 +115,6 @@ typedef enum extern const char *ATIFoundryNames[]; -#ifndef AVOID_CPIO - -extern void ATIMach32ChipID(ATIPtr); - -#endif /* AVOID_CPIO */ - extern void ATIMach64ChipID(ATIPtr, const CARD16); extern ATIChipType ATIChipID(const CARD16, const CARD8); diff --git a/src/aticlock.c b/src/aticlock.c index 548cb62..2aa65c4 100644 --- a/src/aticlock.c +++ b/src/aticlock.c @@ -21,157 +21,6 @@ */ /* - * Adapters prior to V5 use 4 crystals. Adapters V5 and later use a clock - * generator chip. V3 and V4 adapters differ when it comes to choosing clock - * frequencies. - * - * VGA Wonder V3/V4 Adapter Clock Frequencies - * R E G I S T E R S - * 1CE(*) 3C2 3C2 Frequency - * B2h/BEh - * Bit 6/4 Bit 3 Bit 2 (MHz) - * ------- ------- ------- ------- - * 0 0 0 50.000 - * 0 0 1 56.644 - * 0 1 0 Spare 1 - * 0 1 1 44.900 - * 1 0 0 44.900 - * 1 0 1 50.000 - * 1 1 0 Spare 2 - * 1 1 1 36.000 - * - * (*): V3 uses index B2h, bit 6; V4 uses index BEh, bit 4 - * - * V5, PLUS, XL and XL24 usually have an ATI 18810 clock generator chip, but - * some have an ATI 18811-0, and it's quite conceivable that some exist with - * ATI 18811-1's or ATI 18811-2's. Mach32 adapters are known to use any one of - * these clock generators. Mach32 adapters also use a different dot clock - * ordering. ATI says there is no reliable way for the driver to determine - * which clock generator is on the adapter, but this driver will do its best to - * do so anyway. - * - * VGA Wonder V5/PLUS/XL/XL24 Clock Frequencies - * R E G I S T E R S - * 1CE 1CE 3C2 3C2 Frequency - * B9h BEh (MHz) 18811-0 18811-1 - * Bit 1 Bit 4 Bit 3 Bit 2 18810 18812-0 18811-2 (*5) - * ------- ------- ------- ------- ------- ------- ------- ------- - * 0 0 0 0 30.240 30.240 135.000 75.000 - * 0 0 0 1 32.000 32.000 32.000 77.500 - * 0 0 1 0 37.500 110.000 110.000 80.000 - * 0 0 1 1 39.000 80.000 80.000 90.000 - * 0 1 0 0 42.954 42.954 100.000 25.175 - * 0 1 0 1 48.771 48.771 126.000 28.322 - * 0 1 1 0 (*1) 92.400 92.400 31.500 - * 0 1 1 1 36.000 36.000 36.000 36.000 - * 1 0 0 0 40.000 39.910 39.910 100.000 - * 1 0 0 1 (*4) 44.900 44.900 110.000 - * 1 0 1 0 75.000 75.000 75.000 126.000 - * 1 0 1 1 65.000 65.000 65.000 135.000 - * 1 1 0 0 50.350 50.350 50.350 40.000 - * 1 1 0 1 56.640 56.640 56.640 44.900 - * 1 1 1 0 (*2) (*3) (*3) 50.000 - * 1 1 1 1 44.900 44.900 44.900 65.000 - * - * (*1) External 0 (supposedly 16.657 Mhz) - * (*2) External 1 (supposedly 28.322 MHz) - * (*3) This setting doesn't seem to generate anything - * (*4) This setting is documented to be 56.644 MHz, but something close to 82 - * MHz has also been encountered. - * (*5) This setting is for Dell OmniPlex 590 systems, with a 68800AX on the - * motherboard, along with an AT&T21C498 DAC (which is reported as an - * STG1700) and ICS2494AM clock generator (a.k.a. ATI 18811-?). - * - * Mach32 Clock Frequencies - * R E G I S T E R S - * 1CE 1CE 3C2 3C2 Frequency - * B9h BEh (MHz) 18811-0 18811-1 - * Bit 1 Bit 4 Bit 3 Bit 2 18810 18812-0 18811-2 (*5) - * ------- ------- ------- ------- ------- ------- ------- ------- - * 0 0 0 0 42.954 42.954 100.000 25.175 - * 0 0 0 1 48.771 48.771 126.000 28.322 - * 0 0 1 0 (*1) 92.400 92.400 31.500 - * 0 0 1 1 36.000 36.000 36.000 36.000 - * 0 1 0 0 30.240 30.240 135.000 75.000 - * 0 1 0 1 32.000 32.000 32.000 77.500 - * 0 1 1 0 37.500 110.000 110.000 80.000 - * 0 1 1 1 39.000 80.000 80.000 90.000 - * 1 0 0 0 50.350 50.350 50.350 40.000 - * 1 0 0 1 56.640 56.640 56.640 44.900 - * 1 0 1 0 (*2) (*3) (*3) 50.000 - * 1 0 1 1 44.900 44.900 44.900 65.000 - * 1 1 0 0 40.000 39.910 39.910 100.000 - * 1 1 0 1 (*4) 44.900 44.900 110.000 - * 1 1 1 0 75.000 75.000 75.000 126.000 - * 1 1 1 1 65.000 65.000 65.000 135.000 - * - * (*1) External 0 (supposedly 16.657 Mhz) - * (*2) External 1 (supposedly 28.322 MHz) - * (*3) This setting doesn't seem to generate anything - * (*4) This setting is documented to be 56.644 MHz, but something close to 82 - * MHz has also been encountered. - * (*5) This setting is for Dell OmniPlex 590 systems, with a 68800AX on the - * motherboard, along with an AT&T21C498 DAC (which is reported as an - * STG1700) and ICS2494AM clock generator (a.k.a. ATI 18811-?). - * - * Note that, to reduce confusion, this driver masks out the different clock - * ordering. - * - * For all adapters, these frequencies can be divided by 1 or 2. For all - * adapters, except Mach32's and Mach64's, frequencies can also be divided by 3 - * or 4. - * - * Register 1CE, index B8h - * Bit 7 Bit 6 - * ------- ------- - * 0 0 Divide by 1 - * 0 1 Divide by 2 - * 1 0 Divide by 3 - * 1 1 Divide by 4 - * - * With respect to clocks, Mach64's are entirely different animals. - * - * The oldest Mach64's use one of the non-programmable clock generators - * described above. In this case, the driver will handle clocks in much the - * same way as it would for a Mach32. - * - * All other Mach64 adapters use a programmable clock generator. BIOS - * initialisation programmes an initial set of frequencies. Two of these are - * reserved to allow for the setting of modes that do not use a frequency from - * this initial set. One of these reserved slots is used by the BIOS mode set - * routine, the other by the particular accelerated driver used (MS-Windows, - * AutoCAD, etc.). The slots reserved in this way are dependent on the - * particular clock generator used by the adapter. - * - * If the driver does not support the adapter's clock generator, it will try to - * match the (probed or specified) clocks to one of the following sets. - * - * Mach64 Clock Frequencies for unsupported programmable clock generators - * R E G I S T E R S - * 1CE 1CE 3C2 3C2 Frequency - * B9h BEh (MHz) - * Bit 1 Bit 4 Bit 3 Bit 2 Set 1 Set 2 Set 3 - * ------- ------- ------- ------- ------- ------- ------- - * 0 0 0 0 50.350 25.180 25.180 - * 0 0 0 1 56.640 28.320 28.320 - * 0 0 1 0 63.000 31.500 0.000 - * 0 0 1 1 72.000 36.000 0.000 - * 0 1 0 0 0.000 0.000 0.000 - * 0 1 0 1 110.000 110.000 0.000 - * 0 1 1 0 126.000 126.000 0.000 - * 0 1 1 1 135.000 135.000 0.000 - * 1 0 0 0 40.000 40.000 0.000 - * 1 0 0 1 44.900 44.900 0.000 - * 1 0 1 0 49.500 49.500 0.000 - * 1 0 1 1 50.000 50.000 0.000 - * 1 1 0 0 0.000 0.000 0.000 - * 1 1 0 1 80.000 80.000 0.000 - * 1 1 1 0 75.000 75.000 0.000 - * 1 1 1 1 65.000 65.000 0.000 - * - * The driver will never select a setting of 0.000 MHz. The above comments on - * clock ordering and clock divider apply here also. - * * For all supported programmable clock generators, the driver will ignore any * XF86Config clock line and programme, as needed, the clock number reserved by * the BIOS for accelerated drivers. The driver's mode initialisation routine @@ -197,7 +46,6 @@ #include <stdlib.h> #include "ati.h" -#include "atiadapter.h" #include "atichip.h" #include "atidac.h" #include "atidsp.h" @@ -206,23 +54,6 @@ #include "atiwonderio.h" /* - * Definitions related to non-programmable clock generators. - */ -const char *ATIClockNames[] = -{ - "unknown", - "IBM VGA compatible", - "crystals", - "ATI 18810 or similar", - "ATI 18811-0 or similar", - "ATI 18811-1 or similar", - "ICS 2494-AM or similar", - "Programmable (BIOS setting 1)", - "Programmable (BIOS setting 2)", - "Programmable (BIOS setting 3)" -}; - -/* * Definitions related to programmable clock generators. */ static CARD16 ATIPostDividers[] = {1, 2, 4, 8, 16, 32, 64, 128}, @@ -274,264 +105,6 @@ ClockRec ATIClockDescriptors[] = }; /* - * XF86Config clocks line that start with the following will either be rejected - * for ATI adapters, or accepted for non-ATI adapters. - */ -static const int -ATIVGAClocks[] = -{ - 25175, 28322, - -1 -}; - -/* - * The driver will attempt to match fixed clocks to one of the following - * specifications. - */ -static const int -ATICrystalFrequencies[] = -{ - 50000, 56644, 0, 44900, 44900, 50000, 0, 36000, - -1 -}, -ATI18810Frequencies[] = -{ - 30240, 32000, 37500, 39000, 42954, 48771, 0, 36000, - 40000, 0, 75000, 65000, 50350, 56640, 0, 44900 -}, -ATI188110Frequencies[] = -{ - 30240, 32000, 110000, 80000, 42954, 48771, 92400, 36000, - 39910, 44900, 75000, 65000, 50350, 56640, 0, 44900 -}, -ATI188111Frequencies[] = -{ - 135000, 32000, 110000, 80000, 100000, 126000, 92400, 36000, - 39910, 44900, 75000, 65000, 50350, 56640, 0, 44900 -}, -ATI2494AMFrequencies[] = -{ - 75000, 77500, 80000, 90000, 25175, 28322, 31500, 36000, - 100000, 110000, 126000, 135000, 40000, 44900, 50000, 65000 -}, -ATIMach64AFrequencies[] = -{ - 0, 110000, 126000, 135000, 50350, 56640, 63000, 72000, - 0, 80000, 75000, 65000, 40000, 44900, 49500, 50000 -}, -ATIMach64BFrequencies[] = -{ - 0, 110000, 126000, 135000, 25180, 28320, 31500, 36000, - 0, 80000, 75000, 65000, 40000, 44900, 49500, 50000 -}, -ATIMach64CFrequencies[] = -{ - 0, 0, 0, 0, 25180, 28320, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}, -*SpecificationClockLine[] = -{ - NULL, - ATIVGAClocks, - ATICrystalFrequencies, - ATI18810Frequencies, - ATI188110Frequencies, - ATI188111Frequencies, - ATI2494AMFrequencies, - ATIMach64AFrequencies, - ATIMach64BFrequencies, - ATIMach64CFrequencies, - NULL -}; - -/* - * The driver will reject XF86Config clocks lines that start with, or are an - * initial subset of, one of the following. - */ -static const int -ATIPre_2_1_1_Clocks_A[] = /* Based on 18810 */ -{ - 18000, 22450, 25175, 28320, 36000, 44900, 50350, 56640, - 30240, 32000, 37500, 39000, 40000, 0, 75000, 65000, - -1 -}, -ATIPre_2_1_1_Clocks_B[] = /* Based on 18811-0 */ -{ - 18000, 22450, 25175, 28320, 36000, 44900, 50350, 56640, - 30240, 32000, 110000, 80000, 39910, 44900, 75000, 65000, - -1 -}, -ATIPre_2_1_1_Clocks_C[] = /* Based on 18811-1 (or -2) */ -{ - 18000, 22450, 25175, 28320, 36000, 44900, 50350, 56640, - 135000, 32000, 110000, 80000, 39910, 44900, 75000, 65000, - -1 -}, -ATIPre_2_1_1_Clocks_D[] = /* Based on ICS 2494AM */ -{ - 18000, 32500, 20000, 22450, 36000, 65000, 40000, 44900, - 75000, 77500, 80000, 90000, 100000, 110000, 126000, 135000, - -1 -}, -ATIPre_2_1_1_Clocks_E[] = /* Based on programmable setting 1 */ -{ - 36000, 25000, 20000, 22450, 72000, 50000, 40000, 44900, - 0, 110000, 126000, 135000, 0, 80000, 75000, 65000, - -1 -}, -ATIPre_2_1_1_Clocks_F[] = /* Based on programmable setting 2 */ -{ - 18000, 25000, 20000, 22450, 36000, 50000, 40000, 44900, - 0, 110000, 126000, 135000, 0, 80000, 75000, 65000, - -1 -}, -*InvalidClockLine[] = -{ - NULL, - ATIVGAClocks, - ATIPre_2_1_1_Clocks_A, - ATIPre_2_1_1_Clocks_B, - ATIPre_2_1_1_Clocks_C, - ATIPre_2_1_1_Clocks_D, - ATIPre_2_1_1_Clocks_E, - ATIPre_2_1_1_Clocks_F, - NULL -}; - -/* - * Clock maps. - */ -static const CARD8 ClockMaps[][4] = -{ - /* Null map */ - { 0, 1, 2, 3}, - /* VGA Wonder map <-> Mach{8,32,64} */ - { 1, 0, 3, 2}, - /* VGA Wonder map <-> Accelerator */ - { 0, 2, 1, 3}, - /* VGA -> Accelerator map */ - { 2, 0, 3, 1}, - /* Accelerator -> VGA map */ - { 1, 3, 0, 2} -}; -#define ATIVGAWonderClockMap ClockMaps[0] -#define ATIVGAWonderClockUnmap ATIVGAWonderClockMap -#define ATIMachVGAClockMap ClockMaps[1] -#define ATIMachVGAClockUnmap ATIMachVGAClockMap -#define ATIVGAProgrammableClockMap ClockMaps[2] -#define ATIVGAProgrammableClockUnmap ATIVGAProgrammableClockMap -#define ATIAcceleratorClockMap ClockMaps[3] -#define ATIAcceleratorClockUnmap ClockMaps[4] -#define ATIProgrammableClockMap ClockMaps[0] -#define ATIProgrammableClockUnmap ATIProgrammableClockMap -#define MapClockIndex(_ClockMap, _Index) \ - (SetBits((_ClockMap)[GetBits(_Index, 0x0CU)], 0x0CU) | \ - ((_Index) & ~0x0CU)) - -/* - * ATIMatchClockLine -- - * - * This function tries to match the XF86Config clocks to one of an array of - * clock lines. It returns a clock line number or 0. - */ -static int -ATIMatchClockLine -( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI, - const int **ClockLine, - const unsigned short int NumberOfClocks, - const int CalibrationClockNumber, - const int ClockMap -) -{ - int ClockChip = 0, ClockChipIndex = 0; - int NumberOfMatchingClocks = 0; - int MinimumGap = CLOCK_TOLERANCE + 1; - - /* For ATI adapters, reject generic VGA clocks */ - -#ifndef AVOID_CPIO - - if (pATI->Adapter != ATI_ADAPTER_VGA) - -#endif /* AVOID_CPIO */ - - { - if (ClockLine == SpecificationClockLine) - ClockChipIndex++; - } - - /* If checking for XF86Config clock order, skip crystals */ - if (ClockMap) - ClockChipIndex++; - - for (; ClockLine[++ClockChipIndex]; ) - { - int MaximumGap = 0, ClockCount = 0, ClockIndex = 0; - -#ifndef AVOID_CPIO - - /* Only Mach64's and later can have programmable clocks */ - if ((ClockChipIndex >= ATI_CLOCK_MACH64A) && - (pATI->Adapter < ATI_ADAPTER_MACH64)) - break; - -#endif /* AVOID_CPIO */ - - for (; ClockIndex < NumberOfClocks; ClockIndex++) - { - int Gap, XF86ConfigClock, SpecificationClock; - - SpecificationClock = ClockLine[ClockChipIndex] - [MapClockIndex(ClockMaps[ClockMap], ClockIndex)]; - if (SpecificationClock < 0) - break; - if (!SpecificationClock) - continue; - - XF86ConfigClock = pScreenInfo->clock[ClockIndex]; - if (!XF86ConfigClock) - continue; - - Gap = abs(XF86ConfigClock - SpecificationClock); - if (Gap >= MinimumGap) - goto SkipThisClockGenerator; - if (!Gap) - { - if (ClockIndex == CalibrationClockNumber) - continue; - } - else if (Gap > MaximumGap) - { - MaximumGap = Gap; - } - ClockCount++; - } - - if (ClockCount <= NumberOfMatchingClocks) - continue; - NumberOfMatchingClocks = ClockCount; - ClockChip = ClockChipIndex; - if (!(MinimumGap = MaximumGap)) - break; - -SkipThisClockGenerator:; - -#ifndef AVOID_CPIO - - /* For non-ATI adapters, only normalise standard VGA clocks */ - if (pATI->Adapter == ATI_ADAPTER_VGA) - break; - -#endif /* AVOID_CPIO */ - - } - - return ClockChip; -} - -/* * ATIClockPreInit -- * * This function is called by ATIPreInit() and handles the XF86Config clocks @@ -541,72 +114,16 @@ void ATIClockPreInit ( ScrnInfoPtr pScreenInfo, - ATIPtr pATI, - GDevPtr pGDev, - ClockRangePtr pRange + ATIPtr pATI ) { - double ScaleFactor; - unsigned short int NumberOfUndividedClocks; - unsigned short int NumberOfDividers, NumberOfClocks; - int CalibrationClockNumber, CalibrationClockValue; - int ClockIndex, SpecificationClock, ClockMap = 0, Index; - CARD8 CanDisableInterrupts; - -#ifndef AVOID_CPIO - - CARD8 genmo; - -#endif /* AVOID_CPIO */ - - /* - * Decide what to do about the XF86Config clocks for programmable clock - * generators. - */ - if (pATI->ProgrammableClock != ATI_CLOCK_FIXED) - { - /* Check for those that are not (yet) handled */ - if ((pATI->ProgrammableClock == ATI_CLOCK_UNKNOWN) || - (pATI->ProgrammableClock > NumberOf(ATIClockDescriptors))) - { - xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, - "Unknown programmable clock generator type (0x%02X)" - " detected.\n", pATI->ProgrammableClock); - } - else if (pATI->ClockDescriptor.MaxN <= 0) - { - xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, - "Unsupported programmable clock generator detected: %s.\n", - pATI->ClockDescriptor.ClockName); - } - else - { /* * Recognise supported clock generators. This involves telling the * rest of the server about it and (re-)initializing the XF86Config * clocks line. */ - pRange->clockIndex = -1; pScreenInfo->progClock = TRUE; - /* Set internal clock ordering */ - -#ifndef AVOID_CPIO - - if (pATI->NewHW.crtc == ATI_CRTC_VGA) - { - pATI->NewHW.ClockMap = ATIVGAProgrammableClockMap; - pATI->NewHW.ClockUnmap = ATIVGAProgrammableClockUnmap; - } - else - -#endif /* AVOID_CPIO */ - - { - pATI->NewHW.ClockMap = ATIProgrammableClockMap; - pATI->NewHW.ClockUnmap = ATIProgrammableClockUnmap; - } - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s programmable clock generator detected.\n", pATI->ClockDescriptor.ClockName); @@ -622,11 +139,6 @@ ATIClockPreInit (double)pATI->ReferenceNumerator / ((double)pATI->ReferenceDenominator * 1000.0)); - /* Clobber XF86Config clocks line */ - if (pGDev->numclocks) - xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "XF86Config clocks specification ignored.\n"); - if (pATI->ProgrammableClock == ATI_CLOCK_CH8398) { /* First two are fixed */ pScreenInfo->numClocks = 2; @@ -641,656 +153,6 @@ ATIClockPreInit */ pATI->ReferenceNumerator <<= 1; } - - return; /* ... to ATIPreInit() */ - } - } - -#ifndef AVOID_CPIO - - /* Set default clock maps */ - pATI->NewHW.ClockMap = ATIVGAWonderClockMap; - pATI->NewHW.ClockUnmap = ATIVGAWonderClockUnmap; - -#endif /* AVOID_CPIO */ - - /* - * Determine the number of clock values the adapter should be able to - * generate and the dot clock to use for probe calibration. - */ -ProbeClocks: - -#ifndef AVOID_CPIO - - if (pATI->Adapter == ATI_ADAPTER_VGA) - { - NumberOfDividers = 1; - NumberOfUndividedClocks = 4; - CalibrationClockNumber = 1; - CalibrationClockValue = 28322; - } - else - -#endif /* AVOID_CPIO */ - - { - -#ifndef AVOID_CPIO - - NumberOfDividers = 4; - if ((pATI->Chip <= ATI_CHIP_18800) || - (pATI->Adapter == ATI_ADAPTER_V4)) - { - NumberOfUndividedClocks = 8; - /* Actually, any undivided clock will do */ - CalibrationClockNumber = 1; - CalibrationClockValue = 56644; - } - else - -#endif /* AVOID_CPIO */ - - { - NumberOfUndividedClocks = 16; - -#ifndef AVOID_CPIO - - CalibrationClockNumber = 7; - CalibrationClockValue = 36000; - if (pATI->Chip >= ATI_CHIP_68800) - -#endif /* AVOID_CPIO */ - - { - NumberOfDividers = 2; - if (pATI->Chip >= ATI_CHIP_264CT) - { - NumberOfDividers = 1; - NumberOfUndividedClocks = 4; - CalibrationClockNumber = 1; - CalibrationClockValue = 28322; - } - else - -#ifndef AVOID_CPIO - - if (pATI->Adapter >= ATI_ADAPTER_MACH64) - -#endif /* AVOID_CPIO */ - - { - CalibrationClockNumber = 10 /* or 11 */; - CalibrationClockValue = 75000 /* or 65000 */; - } - - /* - * When selecting clocks, all ATI accelerators use a different - * clock ordering. - */ - -#ifndef AVOID_CPIO - - if (pATI->NewHW.crtc == ATI_CRTC_VGA) - { - pATI->NewHW.ClockMap = ATIMachVGAClockMap; - pATI->NewHW.ClockUnmap = ATIMachVGAClockUnmap; - } - else - -#endif /* AVOID_CPIO */ - - { - pATI->NewHW.ClockMap = ATIAcceleratorClockMap; - pATI->NewHW.ClockUnmap = ATIAcceleratorClockUnmap; - } - } - } - } - - pATI->OldHW.ClockMap = pATI->NewHW.ClockMap; - pATI->OldHW.ClockUnmap = pATI->NewHW.ClockUnmap; - - NumberOfClocks = NumberOfUndividedClocks * NumberOfDividers; - - /* - * Respect any XF86Config clocks line. Well, that's the theory, anyway. - * In practice, however, the regular use of probed values is widespread, at - * times causing otherwise inexplicable results. So, attempt to normalise - * the clocks to known (i.e. specification) values. - */ - if (!pGDev->numclocks || pATI->OptionProbeClocks || - xf86ServerIsOnlyProbing()) - { - if (pATI->ProgrammableClock != ATI_CLOCK_FIXED) - { - /* - * For unsupported programmable clock generators, pick the highest - * frequency set by BIOS initialisation for clock calibration. - */ - CalibrationClockNumber = CalibrationClockValue = 0; - for (ClockIndex = 0; - ClockIndex < NumberOfUndividedClocks; - ClockIndex++) - { - if (CalibrationClockValue < pATI->BIOSClocks[ClockIndex]) - { - CalibrationClockNumber = ClockIndex; - CalibrationClockValue = pATI->BIOSClocks[ClockIndex]; - } - } - CalibrationClockNumber = - MapClockIndex(pATI->NewHW.ClockUnmap, CalibrationClockNumber); - CalibrationClockValue *= 10; - } - -#ifndef AVOID_CPIO - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - { - /* - * The current video state needs to be saved before the clock - * probe, and restored after. Video memory corruption and other - * effects occur because, at this early stage, the clock probe - * cannot reliably be prevented from enabling frequencies that are - * greater than what the adapter can handle. - */ - ATIModeSave(pScreenInfo, pATI, &pATI->OldHW); - - /* Ensure clock select pins are not OR'ed with anything */ - if (pATI->CPIO_VGAWonder && (pATI->OldHW.crtc == ATI_CRTC_VGA)) - ATIModifyExtReg(pATI, 0xB5U, pATI->OldHW.b5, 0x7FU, 0x00U); - } - -#endif /* AVOID_CPIO */ - - /* - * Probe the adapter for clock values. The following is essentially - * the common layer's xf86GetClocks() reworked to fit. One difference - * is the ability to monitor a VSync bit in MMIO space. - */ - CanDisableInterrupts = TRUE; /* An assumption verified below */ - - for (ClockIndex = 0; ClockIndex < NumberOfClocks; ClockIndex++) - { - pScreenInfo->clock[ClockIndex] = 0; - - /* Remap clock number */ - Index = MapClockIndex(pATI->OldHW.ClockMap, ClockIndex); - - /* Select the clock */ - switch (pATI->OldHW.crtc) - { - -#ifndef AVOID_CPIO - - case ATI_CRTC_VGA: - /* Get generic two low-order bits */ - genmo = (inb(R_GENMO) & 0xF3U) | ((Index << 2) & 0x0CU); - - if (pATI->CPIO_VGAWonder) - { - /* - * On adapters with crystals, switching to one of the - * spare assignments doesn't do anything (i.e. the - * previous setting remains in effect). So, disable - * their selection. - */ - if (((Index & 0x03U) == 0x02U) && - ((pATI->Chip <= ATI_CHIP_18800) || - (pATI->Adapter == ATI_ADAPTER_V4))) - continue; - - /* Start sequencer reset */ - PutReg(SEQX, 0x00U, 0x00U); - - /* Set high-order bits */ - if (pATI->Chip <= ATI_CHIP_18800) - { - ATIModifyExtReg(pATI, 0xB2U, -1, 0xBFU, - Index << 4); - } - else - { - ATIModifyExtReg(pATI, 0xBEU, -1, 0xEFU, - Index << 2); - if (pATI->Adapter != ATI_ADAPTER_V4) - { - Index >>= 1; - ATIModifyExtReg(pATI, 0xB9U, -1, 0xFDU, - Index >> 1); - } - } - - /* Set clock divider bits */ - ATIModifyExtReg(pATI, 0xB8U, -1, 0x00U, - (Index << 3) & 0xC0U); - } - else - { - /* - * Reject clocks that cannot be selected. - */ - if (Index & ~0x03U) - continue; - - /* Start sequencer reset */ - PutReg(SEQX, 0x00U, 0x00U); - } - - /* Must set miscellaneous output register last */ - outb(GENMO, genmo); - - /* End sequencer reset */ - PutReg(SEQX, 0x00U, 0x03U); - - break; - -#endif /* AVOID_CPIO */ - - case ATI_CRTC_MACH64: - out8(CLOCK_CNTL, CLOCK_STROBE | - SetBits(Index, CLOCK_SELECT | CLOCK_DIVIDER)); - break; - - default: - continue; - } - - usleep(50000); /* Let clock stabilise */ - - xf86SetPriority(TRUE); - - /* Try to disable interrupts */ - if (CanDisableInterrupts && !xf86DisableInterrupts()) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Unable to disable interrupts; Clock probe will not be as" - " accurate.\n"); - CanDisableInterrupts = FALSE; - } - - /* - * Generate a count while monitoring the vertical sync or blanking - * pulse. This is dependent on the CRTC used by the mode on server - * entry. - */ - switch (pATI->OldHW.crtc) - { - -#ifndef AVOID_CPIO - - case ATI_CRTC_VGA: - /* Verify vertical sync pulses are in fact occurring */ - Index = 1 << 19; - while (!(inb(GENS1(pATI->CPIO_VGABase)) & 0x08U)) - if (Index-- <= 0) - goto EnableInterrupts; - Index = 1 << 19; - while (inb(GENS1(pATI->CPIO_VGABase)) & 0x08U) - if (Index-- <= 0) - goto EnableInterrupts; - Index = 1 << 19; - while (!(inb(GENS1(pATI->CPIO_VGABase)) & 0x08U)) - if (Index-- <= 0) - goto EnableInterrupts; - - /* Generate the count */ - for (Index = 0; Index < 8; Index++) - { - while (inb(GENS1(pATI->CPIO_VGABase)) & 0x08U) - pScreenInfo->clock[ClockIndex]++; - while (!(inb(GENS1(pATI->CPIO_VGABase)) & 0x08U)) - pScreenInfo->clock[ClockIndex]++; - } - break; - -#endif /* AVOID_CPIO */ - - case ATI_CRTC_MACH64: - /* Verify vertical blanking pulses are in fact occurring */ - Index = 1 << 19; - while (!(inr(CRTC_INT_CNTL) & CRTC_VBLANK)) - if (Index-- <= 0) - goto EnableInterrupts; - Index = 1 << 19; - while (inr(CRTC_INT_CNTL) & CRTC_VBLANK) - if (Index-- <= 0) - goto EnableInterrupts; - Index = 1 << 19; - while (!(inr(CRTC_INT_CNTL) & CRTC_VBLANK)) - if (Index-- <= 0) - goto EnableInterrupts; - - /* Generate the count */ - for (Index = 0; Index < 4; Index++) - { - while (inr(CRTC_INT_CNTL) & CRTC_VBLANK) - pScreenInfo->clock[ClockIndex]++; - while (!(inr(CRTC_INT_CNTL) & CRTC_VBLANK)) - pScreenInfo->clock[ClockIndex]++; - } - break; - - default: - break; - } - - EnableInterrupts: - if (CanDisableInterrupts) - xf86EnableInterrupts(); - - xf86SetPriority(FALSE); - } - - ScaleFactor = (double)CalibrationClockValue * - (double)pScreenInfo->clock[CalibrationClockNumber]; - - /* Scale the clocks from counts to kHz */ - for (ClockIndex = 0; ClockIndex < NumberOfClocks; ClockIndex++) - { - if (ClockIndex == CalibrationClockNumber) - pScreenInfo->clock[ClockIndex] = CalibrationClockValue; - else if (pScreenInfo->clock[ClockIndex]) - /* Round to the nearest 10 kHz */ - pScreenInfo->clock[ClockIndex] = - (int)(((ScaleFactor / - (double)pScreenInfo->clock[ClockIndex]) + - 5) / 10) * 10; - } - - pScreenInfo->numClocks = NumberOfClocks; - -#ifndef AVOID_CPIO - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - { - /* Restore video state */ - ATIModeSet(pScreenInfo, pATI, &pATI->OldHW); - xfree(pATI->OldHW.frame_buffer); - pATI->OldHW.frame_buffer = NULL; - } - -#endif /* AVOID_CPIO */ - - /* Tell user clocks were probed, instead of supplied */ - pATI->OptionProbeClocks = TRUE; - - /* Attempt to match probed clocks to a known specification */ - pATI->Clock = ATIMatchClockLine(pScreenInfo, pATI, - SpecificationClockLine, NumberOfUndividedClocks, - CalibrationClockNumber, 0); - -#ifndef AVOID_CPIO - - if ((pATI->Chip <= ATI_CHIP_18800) || - (pATI->Adapter == ATI_ADAPTER_V4)) - { - /* V3 and V4 adapters don't have clock chips */ - if (pATI->Clock > ATI_CLOCK_CRYSTALS) - pATI->Clock = ATI_CLOCK_NONE; - } - else - -#endif /* AVOID_CPIO */ - - { - /* All others don't have crystals */ - if (pATI->Clock == ATI_CLOCK_CRYSTALS) - pATI->Clock = ATI_CLOCK_NONE; - } - } - else - { - /* - * Allow for an initial subset of specification clocks. Can't allow - * for any more than that though... - */ - if (NumberOfClocks > pGDev->numclocks) - { - NumberOfClocks = pGDev->numclocks; - if (NumberOfUndividedClocks > NumberOfClocks) - NumberOfUndividedClocks = NumberOfClocks; - } - - /* Move XF86Config clocks into the ScrnInfoRec */ - for (ClockIndex = 0; ClockIndex < NumberOfClocks; ClockIndex++) - pScreenInfo->clock[ClockIndex] = pGDev->clock[ClockIndex]; - pScreenInfo->numClocks = NumberOfClocks; - - /* Attempt to match clocks to a known specification */ - pATI->Clock = ATIMatchClockLine(pScreenInfo, pATI, - SpecificationClockLine, NumberOfUndividedClocks, -1, 0); - -#ifndef AVOID_CPIO - - if (pATI->Adapter != ATI_ADAPTER_VGA) - -#endif /* AVOID_CPIO */ - - { - if (pATI->Clock == ATI_CLOCK_NONE) - { - /* - * Reject certain clock lines that are obviously wrong. This - * includes the standard VGA clocks for ATI adapters, and clock - * lines that could have been used with the pre-2.1.1 driver. - */ - if (ATIMatchClockLine(pScreenInfo, pATI, InvalidClockLine, - NumberOfClocks, -1, 0)) - { - pATI->OptionProbeClocks = TRUE; - } - else - -#ifndef AVOID_CPIO - - if ((pATI->Chip >= ATI_CHIP_18800) && - (pATI->Adapter != ATI_ADAPTER_V4)) - -#endif /* AVOID_CPIO */ - - { - /* - * Check for clocks that are specified in the wrong order. - * This is meant to catch those who are trying to use the - * clock order intended for the old accelerated servers. - */ - while ((++ClockMap, ClockMap %= NumberOf(ClockMaps))) - { - pATI->Clock = ATIMatchClockLine(pScreenInfo, pATI, - SpecificationClockLine, NumberOfUndividedClocks, - -1, ClockMap); - if (pATI->Clock != ATI_CLOCK_NONE) - { - xf86DrvMsgVerb(pScreenInfo->scrnIndex, - X_WARNING, 0, - "XF86Config clock ordering incorrect. Clocks" - " will be reordered.\n"); - break; - } - } - } - } - else - /* Ensure crystals are not matched to clock chips, and vice versa */ - -#ifndef AVOID_CPIO - - if ((pATI->Chip <= ATI_CHIP_18800) || - (pATI->Adapter == ATI_ADAPTER_V4)) - { - if (pATI->Clock > ATI_CLOCK_CRYSTALS) - pATI->OptionProbeClocks = TRUE; - } - else - -#endif /* AVOID_CPIO */ - - { - if (pATI->Clock == ATI_CLOCK_CRYSTALS) - pATI->OptionProbeClocks = TRUE; - } - - if (pATI->OptionProbeClocks) - { - xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, - "Invalid or obsolete XF86Config clocks line rejected.\n" - " Clocks will be probed.\n"); - goto ProbeClocks; - } - } - } - - if (pATI->ProgrammableClock != ATI_CLOCK_FIXED) - { - pATI->ProgrammableClock = ATI_CLOCK_FIXED; - } - else if (pATI->Clock == ATI_CLOCK_NONE) - { - xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, - "Unknown clock generator detected.\n"); - } - else - -#ifndef AVOID_CPIO - - if (pATI->Clock == ATI_CLOCK_CRYSTALS) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "This adapter uses crystals to generate clock frequencies.\n"); - } - else if (pATI->Clock != ATI_CLOCK_VGA) - -#endif /* AVOID_CPIO */ - - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "%s clock chip detected.\n", ATIClockNames[pATI->Clock]); - } - - if (pATI->Clock != ATI_CLOCK_NONE) - { - /* Replace undivided clocks with specification values */ - for (ClockIndex = 0; - ClockIndex < NumberOfUndividedClocks; - ClockIndex++) - { - /* - * Don't replace clocks that are probed, documented, or set by the - * user to zero. One exception is that we need to override the - * user's value for the spare settings on a crystal-based adapter. - * Another exception is when the user specifies the clock ordering - * intended for the old accelerated servers. - */ - SpecificationClock = - SpecificationClockLine[pATI->Clock][ClockIndex]; - if (SpecificationClock < 0) - break; - if (!ClockMap) - { - if (!pScreenInfo->clock[ClockIndex]) - continue; - if (!SpecificationClock) - { - if (pATI->Clock != ATI_CLOCK_CRYSTALS) - continue; - } - else - { - /* - * Due to the way clock lines are matched, the following - * can prevent the override if the clock is probed, - * documented or set by the user to a value greater than - * maxClock. - */ - if (abs(SpecificationClock - - pScreenInfo->clock[ClockIndex]) > CLOCK_TOLERANCE) - continue; - } - } - pScreenInfo->clock[ClockIndex] = SpecificationClock; - } - - /* Adjust divided clocks */ - for (ClockIndex = NumberOfUndividedClocks; - ClockIndex < NumberOfClocks; - ClockIndex++) - pScreenInfo->clock[ClockIndex] = ATIDivide( - pScreenInfo->clock[ClockIndex % NumberOfUndividedClocks], - (ClockIndex / NumberOfUndividedClocks) + 1, 0, 0); - } - - /* Tell user about fixed clocks */ - xf86ShowClocks(pScreenInfo, pATI->OptionProbeClocks ? X_PROBED : X_CONFIG); - - /* Prevent selection of high clocks, even by V_CLKDIV2 modes */ - for (ClockIndex = 0; ClockIndex < NumberOfClocks; ClockIndex++) - if (pScreenInfo->clock[ClockIndex] > pRange->maxClock) - pScreenInfo->clock[ClockIndex] = 0; -} - -/* - * ATIClockSave -- - * - * This function saves that part of an ATIHWRec that relates to clocks. - */ -void -ATIClockSave -( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI, - ATIHWPtr pATIHW -) -{ - if (pScreenInfo->vtSema && (pATI->ProgrammableClock > ATI_CLOCK_FIXED)) - { - -#ifndef AVOID_CPIO - - if (pATIHW->crtc == ATI_CRTC_VGA) - { - pATIHW->ClockMap = ATIVGAProgrammableClockMap; - pATIHW->ClockUnmap = ATIVGAProgrammableClockUnmap; - } - else - -#endif /* AVOID_CPIO */ - - { - pATIHW->ClockMap = ATIProgrammableClockMap; - pATIHW->ClockUnmap = ATIProgrammableClockUnmap; - } - } - else - { - -#ifndef AVOID_CPIO - - if (pATIHW->crtc != ATI_CRTC_VGA) - -#endif /* AVOID_CPIO */ - - { - pATIHW->ClockMap = ATIAcceleratorClockMap; - pATIHW->ClockUnmap = ATIAcceleratorClockUnmap; - } - -#ifndef AVOID_CPIO - - else if (pATI->Chip < ATI_CHIP_68800) - { - pATIHW->ClockMap = ATIVGAWonderClockMap; - pATIHW->ClockUnmap = ATIVGAWonderClockUnmap; - } - else - { - pATIHW->ClockMap = ATIMachVGAClockMap; - pATIHW->ClockUnmap = ATIMachVGAClockUnmap; - } - -#endif /* AVOID_CPIO */ - - } } /* @@ -1315,14 +177,14 @@ ATIClockCalculate /* Set default values */ pATIHW->FeedbackDivider = pATIHW->ReferenceDivider = pATIHW->PostDivider = 0; - if ((pATI->ProgrammableClock <= ATI_CLOCK_FIXED) || - ((pATI->ProgrammableClock == ATI_CLOCK_CH8398) && + if (((pATI->ProgrammableClock == ATI_CLOCK_CH8398) && (pMode->ClockIndex < 2))) { - /* Use a fixed clock */ - ClockSelect = pMode->ClockIndex; + xf86DrvMsg(iScreen, X_ERROR, + "First two clocks of Chrontel 8398 clock generator are fixed\n"); + return FALSE; } - else + { /* Generate clock programme word, using units of kHz */ MinimumGap = ((unsigned int)(-1)) >> 1; @@ -1410,54 +272,12 @@ ATIClockCalculate ATIDSPCalculate(pATI, pATIHW, pMode); } - /* Set clock select bits, after remapping them */ - pATIHW->clock = ClockSelect; /* Save pre-map clock number */ - ClockSelect = MapClockIndex(pATIHW->ClockMap, ClockSelect); + /* Set clock select bits */ + pATIHW->clock = ClockSelect; - switch (pATIHW->crtc) { - -#ifndef AVOID_CPIO - - case ATI_CRTC_VGA: - pATIHW->genmo = (pATIHW->genmo & 0xF3U) | - ((ClockSelect << 2) & 0x0CU); - - if (pATI->CPIO_VGAWonder) - { - /* Set ATI clock select bits */ - if (pATI->Chip <= ATI_CHIP_18800) - { - pATIHW->b2 = (pATIHW->b2 & 0xBFU) | - ((ClockSelect << 4) & 0x40U); - } - else - { - pATIHW->be = (pATIHW->be & 0xEFU) | - ((ClockSelect << 2) & 0x10U); - if (pATI->Adapter != ATI_ADAPTER_V4) - { - ClockSelect >>= 1; - pATIHW->b9 = (pATIHW->b9 & 0xFDU) | - ((ClockSelect >> 1) & 0x02U); - } - } - - /* Set clock divider bits */ - pATIHW->b8 = (pATIHW->b8 & 0x3FU) | - ((ClockSelect << 3) & 0xC0U); - } - break; - -#endif /* AVOID_CPIO */ - - case ATI_CRTC_MACH64: pATIHW->clock_cntl = CLOCK_STROBE | SetBits(ClockSelect, CLOCK_SELECT | CLOCK_DIVIDER); - break; - - default: - break; } return TRUE; diff --git a/src/aticlock.h b/src/aticlock.h index b58b824..1d3f1b9 100644 --- a/src/aticlock.h +++ b/src/aticlock.h @@ -28,24 +28,6 @@ #include "xf86str.h" /* - * Definitions related to non-programmable clock generators. - */ -typedef enum -{ - ATI_CLOCK_NONE = 0, - ATI_CLOCK_VGA = 1, - ATI_CLOCK_CRYSTALS = 2, - ATI_CLOCK_18810, - ATI_CLOCK_18811_0, - ATI_CLOCK_18811_1, - ATI_CLOCK_2494AM, - ATI_CLOCK_MACH64A, - ATI_CLOCK_MACH64B, - ATI_CLOCK_MACH64C -} ATIClockType; -extern const char *ATIClockNames[]; - -/* * Definitions related to programmable clock generators. */ typedef enum @@ -73,8 +55,7 @@ typedef struct } ClockRec, *ClockPtr; extern ClockRec ATIClockDescriptors[]; -extern void ATIClockPreInit(ScrnInfoPtr, ATIPtr, GDevPtr, ClockRangePtr); -extern void ATIClockSave(ScrnInfoPtr, ATIPtr, ATIHWPtr); +extern void ATIClockPreInit(ScrnInfoPtr, ATIPtr); extern Bool ATIClockCalculate(int, ATIPtr, ATIHWPtr, DisplayModePtr); extern void ATIClockSet(ATIPtr, ATIHWPtr); diff --git a/src/aticonfig.c b/src/aticonfig.c index feb5b95..988edfd 100644 --- a/src/aticonfig.c +++ b/src/aticonfig.c @@ -30,7 +30,6 @@ #include <string.h> #include "ati.h" -#include "atiadapter.h" #include "atichip.h" #include "aticonfig.h" #include "aticursor.h" @@ -113,6 +112,7 @@ ATIProcessOptions (void)memcpy(PublicOption, ATIPublicOptions, ATIPublicOptionSize); +# define ProbeSparse PublicOption[ATI_OPTION_PROBE_SPARSE].value.bool # define Accel PublicOption[ATI_OPTION_ACCEL].value.bool # define BIOSDisplay PrivateOption[ATI_OPTION_BIOS_DISPLAY].value.bool # define Blend PrivateOption[ATI_OPTION_BLEND].value.bool @@ -122,12 +122,6 @@ ATIProcessOptions # define Devel PrivateOption[ATI_OPTION_DEVEL].value.bool # define HWCursor PublicOption[ATI_OPTION_HWCURSOR].value.bool -#ifndef AVOID_CPIO - -# define Linear PublicOption[ATI_OPTION_LINEAR].value.bool - -#endif /* AVOID_CPIO */ - #ifdef XF86DRI_DEVEL # define IsPCI PublicOption[ATI_OPTION_IS_PCI].value.bool @@ -149,7 +143,6 @@ ATIProcessOptions # define CacheMMIO PublicOption[ATI_OPTION_MMIO_CACHE].value.bool # define TestCacheMMIO PublicOption[ATI_OPTION_TEST_MMIO_CACHE].value.bool # define PanelDisplay PublicOption[ATI_OPTION_PANEL_DISPLAY].value.bool -# define ProbeClocks PublicOption[ATI_OPTION_PROBE_CLOCKS].value.bool # define ShadowFB PublicOption[ATI_OPTION_SHADOW_FB].value.bool # define SWCursor PublicOption[ATI_OPTION_SWCURSOR].value.bool # define AccelMethod PublicOption[ATI_OPTION_ACCELMETHOD].value.str @@ -163,22 +156,9 @@ ATIProcessOptions xf86CollectOptions(pScreenInfo, NULL); /* Set non-zero defaults */ - -#ifndef AVOID_CPIO - - if (pATI->Adapter >= ATI_ADAPTER_MACH64) - -#endif /* AVOID_CPIO */ - { Accel = CacheMMIO = HWCursor = TRUE; -#ifndef AVOID_CPIO - - Linear = TRUE; - -#endif /* AVOID_CPIO */ - #ifdef TV_OUT TvStd = "None"; /* No tv standard change requested */ @@ -208,20 +188,8 @@ ATIProcessOptions xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, PrivateOption); -#ifndef AVOID_CPIO - - /* Disable linear apertures if the OS doesn't support them */ - if (!xf86LinearVidMem() && Linear) - { - if (PublicOption[ATI_OPTION_LINEAR].found) - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "OS does not support linear apertures.\n"); - Linear = FALSE; - } - -#endif /* AVOID_CPIO */ - /* Move option values into driver private structure */ + pATI->OptionProbeSparse = ProbeSparse; pATI->OptionAccel = Accel; pATI->OptionBIOSDisplay = BIOSDisplay; pATI->OptionBlend = Blend; @@ -229,12 +197,6 @@ ATIProcessOptions pATI->OptionCSync = CSync; pATI->OptionDevel = Devel; -#ifndef AVOID_CPIO - - pATI->OptionLinear = Linear; - -#endif /* AVOID_CPIO */ - #ifdef TV_OUT if (TvOut && pATI->Chip < ATI_CHIP_264GT) { @@ -262,7 +224,6 @@ ATIProcessOptions pATI->OptionMMIOCache = CacheMMIO; pATI->OptionTestMMIOCache = TestCacheMMIO; - pATI->OptionProbeClocks = ProbeClocks; pATI->OptionShadowFB = ShadowFB; pATI->OptionLCDSync = LCDSync; diff --git a/src/aticonsole.c b/src/aticonsole.c index 5e06578..6d0c662 100644 --- a/src/aticonsole.c +++ b/src/aticonsole.c @@ -29,9 +29,7 @@ #endif #include "ati.h" -#include "atiadapter.h" #include "aticonsole.h" -#include "aticrtc.h" #include "atii2c.h" #include "atilock.h" #include "atimach64.h" @@ -46,12 +44,6 @@ #include "atidri.h" #endif -#include "mach64_common.h" - - - -#include "xf86.h" - #ifdef TV_OUT #include "atichip.h" @@ -92,23 +84,8 @@ ATISaveScreen return TRUE; pATI = ATIPTR(pScreenInfo); - switch (pATI->NewHW.crtc) { - -#ifndef AVOID_CPIO - - case ATI_CRTC_VGA: - ATIVGASaveScreen(pATI, Mode); - break; - -#endif /* AVOID_CPIO */ - - case ATI_CRTC_MACH64: ATIMach64SaveScreen(pATI, Mode); - break; - - default: - break; } return TRUE; @@ -135,27 +112,8 @@ ATISetDPMSMode pATI = ATIPTR(pScreenInfo); - switch (pATI->Adapter) { - case ATI_ADAPTER_MACH64: ATIMach64SetDPMSMode(pScreenInfo, pATI, DPMSMode); - break; - - default: - -#ifndef AVOID_CPIO - - /* Assume EGA/VGA */ - ATIVGASetDPMSMode(pATI, DPMSMode); - break; - - case ATI_ADAPTER_NONE: - case ATI_ADAPTER_8514A: - case ATI_ADAPTER_MACH8: - -#endif /* AVOID_CPIO */ - - break; } } @@ -758,14 +716,6 @@ ATIEnterVT return TRUE; } -#ifndef AVOID_CPIO - - /* If used, modify banking interface */ - if (!miModifyBanking(pScreen, &pATI->BankInfo)) - return FALSE; - -#endif /* AVOID_CPIO */ - pScreenPixmap = (*pScreen->GetScreenPixmap)(pScreen); PixmapPrivate = pScreenPixmap->devPrivate; if (!PixmapPrivate.ptr) diff --git a/src/aticursor.c b/src/aticursor.c index a7c98ac..e2da78c 100644 --- a/src/aticursor.c +++ b/src/aticursor.c @@ -24,7 +24,6 @@ #include "config.h" #endif -#include "atiadapter.h" #include "aticursor.h" #include "atimach64cursor.h" #include "atistruct.h" @@ -53,14 +52,8 @@ ATIInitializeCursor if (!(pATI->pCursorInfo = xf86CreateCursorInfoRec())) return FALSE; - switch (pATI->Adapter) + if (!ATIMach64CursorInit(pATI->pCursorInfo)) { - case ATI_ADAPTER_MACH64: - if (ATIMach64CursorInit(pATI->pCursorInfo)) - break; - /* Fall through */ - - default: xf86DestroyCursorInfoRec(pATI->pCursorInfo); pATI->pCursorInfo = NULL; return FALSE; diff --git a/src/atidac.c b/src/atidac.c index 95b478d..f94e8ad 100644 --- a/src/atidac.c +++ b/src/atidac.c @@ -29,7 +29,6 @@ #include "ati.h" #include "atidac.h" #include "atimach64io.h" -#include "atimono.h" /* * RAMDAC-related definitions. @@ -186,55 +185,6 @@ ATIDACPreInit pATIHW->lut[Index2 + 1] = 0x00U; pATIHW->lut[Index2 + 2] = maxColour; } - -#ifndef AVOID_CPIO - - if (pATI->depth == 1) - { - rgb blackColour = pScreenInfo->display->blackColour, - whiteColour = pScreenInfo->display->whiteColour; - - if (blackColour.red > maxColour) - blackColour.red = maxColour; - if (blackColour.green > maxColour) - blackColour.green = maxColour; - if (blackColour.blue > maxColour) - blackColour.blue = maxColour; - if (whiteColour.red > maxColour) - whiteColour.red = maxColour; - if (whiteColour.green > maxColour) - whiteColour.green = maxColour; - if (whiteColour.blue > maxColour) - whiteColour.blue = maxColour; - - if ((blackColour.red == whiteColour.red) && - (blackColour.green == whiteColour.green) && - (blackColour.blue == whiteColour.blue)) - { - blackColour.red ^= maxColour; - blackColour.green ^= maxColour; - blackColour.blue ^= maxColour; - } - - pATIHW->lut[(MONO_BLACK * 3) + 0] = blackColour.red; - pATIHW->lut[(MONO_BLACK * 3) + 1] = blackColour.green; - pATIHW->lut[(MONO_BLACK * 3) + 2] = blackColour.blue; - pATIHW->lut[(MONO_WHITE * 3) + 0] = whiteColour.red; - pATIHW->lut[(MONO_WHITE * 3) + 1] = whiteColour.green; - pATIHW->lut[(MONO_WHITE * 3) + 2] = whiteColour.blue; - } - - if (pATIHW->crtc == ATI_CRTC_VGA) - { - /* Initialise overscan to black */ - Index = pATIHW->attr[17] * 3; - pATIHW->lut[Index + 0] = - pATIHW->lut[Index + 1] = - pATIHW->lut[Index + 2] = 0x00U; - } - -#endif /* AVOID_CPIO */ - } } @@ -370,6 +320,44 @@ ATIDACSet } /* + * ATISetLUTEntry -- + * + * This function is called to set one of a DAC's LUT entries. + */ +static void +ATISetLUTEntry +( + ATIPtr pATI, + int Index, + CARD8 *LUTEntry +) +{ +#ifdef AVOID_CPIO + + out8(M64_DAC_WRITE, Index); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[0]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[1]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[2]); + DACDelay; + +#else /* AVOID_CPIO */ + + outb(pATI->CPIO_DAC_WRITE, Index); + DACDelay; + outb(pATI->CPIO_DAC_DATA, LUTEntry[0]); + DACDelay; + outb(pATI->CPIO_DAC_DATA, LUTEntry[1]); + DACDelay; + outb(pATI->CPIO_DAC_DATA, LUTEntry[2]); + DACDelay; + +#endif /* AVOID_CPIO */ +} + +/* * ATILoadPalette -- * * This function updates the RAMDAC's LUT and the in-memory copy of it in @@ -450,35 +438,8 @@ ATILoadPalette for (Index = 0; Index < (SizeOf(pATI->NewHW.lut) / 3); Index += i, LUTEntry += i * 3) - { - if (!fChanged[Index]) - continue; - -#ifdef AVOID_CPIO - - out8(M64_DAC_WRITE, Index); - DACDelay; - out8(M64_DAC_DATA, LUTEntry[0]); - DACDelay; - out8(M64_DAC_DATA, LUTEntry[1]); - DACDelay; - out8(M64_DAC_DATA, LUTEntry[2]); - DACDelay; - -#else /* AVOID_CPIO */ - - outb(pATI->CPIO_DAC_WRITE, Index); - DACDelay; - outb(pATI->CPIO_DAC_DATA, LUTEntry[0]); - DACDelay; - outb(pATI->CPIO_DAC_DATA, LUTEntry[1]); - DACDelay; - outb(pATI->CPIO_DAC_DATA, LUTEntry[2]); - DACDelay; - -#endif /* AVOID_CPIO */ - - } + if (fChanged[Index]) + ATISetLUTEntry(pATI, Index, LUTEntry); } } else @@ -495,33 +456,7 @@ ATILoadPalette LUTEntry[2] = Colours[Index].blue; if (pScreenInfo->vtSema || pATI->currentMode) - { - -#ifdef AVOID_CPIO - - out8(M64_DAC_WRITE, Index); - DACDelay; - out8(M64_DAC_DATA, LUTEntry[0]); - DACDelay; - out8(M64_DAC_DATA, LUTEntry[1]); - DACDelay; - out8(M64_DAC_DATA, LUTEntry[2]); - DACDelay; - -#else /* AVOID_CPIO */ - - outb(pATI->CPIO_DAC_WRITE, Index); - DACDelay; - outb(pATI->CPIO_DAC_DATA, LUTEntry[0]); - DACDelay; - outb(pATI->CPIO_DAC_DATA, LUTEntry[1]); - DACDelay; - outb(pATI->CPIO_DAC_DATA, LUTEntry[2]); - DACDelay; - -#endif /* AVOID_CPIO */ - - } + ATISetLUTEntry(pATI, Index, LUTEntry); } } } diff --git a/src/atidga.c b/src/atidga.c index 5367610..e6783a4 100644 --- a/src/atidga.c +++ b/src/atidga.c @@ -414,19 +414,6 @@ ATIDGAInit if (!pATI->nDGAMode) { - -#ifndef AVOID_CPIO - - /* - * Contrary to previous extension versions, DGA 2 does not support - * banked framebuffers. Also, disable DGA when non-DGA server modes - * are planar. - */ - if (pATI->BankInfo.BankSize || (pScreenInfo->depth <= 4)) - return FALSE; - -#endif /* AVOID_CPIO */ - /* Set up DGA callbacks */ pATI->ATIDGAFunctions.OpenFramebuffer = ATIDGAOpenFramebuffer; pATI->ATIDGAFunctions.SetMode = ATIDGASetMode; @@ -459,8 +446,7 @@ ATIDGAInit ATIDGAAddModes(pScreenInfo, pATI, flags, 8, 8, 0, 0, 0, PseudoColor); - if ((pATI->Chip >= ATI_CHIP_264CT) && - (pATI->Chipset == ATI_CHIPSET_ATI)) + if ((pATI->Chip >= ATI_CHIP_264CT)) { ATIDGAAddModes(pScreenInfo, pATI, flags, 15, 16, 0x7C00U, 0x03E0U, 0x001FU, TrueColor); diff --git a/src/atidsp.c b/src/atidsp.c index 6692425..adea2cd 100644 --- a/src/atidsp.c +++ b/src/atidsp.c @@ -25,7 +25,6 @@ #endif #include "ati.h" #include "atichip.h" -#include "aticrtc.h" #include "atidsp.h" #include "atimach64io.h" #include "atividmem.h" @@ -222,12 +221,6 @@ ATIDSPCalculate pATI->ClockDescriptor.PostDividers[pATIHW->PostDivider]; Divider = pATIHW->FeedbackDivider * pATI->XCLKReferenceDivider; -#ifndef AVOID_CPIO - - if (pATI->depth >= 8) - -#endif /* AVOID_CPIO */ - { Divider *= pATI->bitsPerPixel / 4; } @@ -235,13 +228,6 @@ ATIDSPCalculate /* Start by assuming a display FIFO width of 64 bits */ vshift = (6 - 2) - pATI->XCLKPostDivider; -#ifndef AVOID_CPIO - - if (pATIHW->crtc == ATI_CRTC_VGA) - vshift--; /* Nope, it's 32 bits wide */ - -#endif /* AVOID_CPIO */ - if (pATI->OptionPanelDisplay && (pATI->LCDPanelID >= 0)) { /* Compensate for horizontal stretching */ @@ -269,21 +255,6 @@ ATIDSPCalculate vshift, -1) - ATIDivide(1, 1, vshift - xshift, 1); /* Next is dsp_on */ - -#ifndef AVOID_CPIO - - if ((pATIHW->crtc == ATI_CRTC_VGA) /* && (dsp_precision < 3) */) - { - /* - * TODO: I don't yet know why something like this appears necessary. - * But I don't have time to explore this right now. - */ - dsp_on = ATIDivide(Multiplier * 5, Divider, vshift + 2, 1); - } - else - -#endif /* AVOID_CPIO */ - { dsp_on = ATIDivide(Multiplier, Divider, vshift, 1); tmp = ATIDivide(RASMultiplier, RASDivider, xshift, 1); diff --git a/src/atii2c.c b/src/atii2c.c index a32ea5e..73febf7 100644 --- a/src/atii2c.c +++ b/src/atii2c.c @@ -24,7 +24,6 @@ #include "config.h" #endif -#include "atiadapter.h" #include "atii2c.h" #include "atiload.h" #include "atimach64i2c.h" @@ -366,18 +365,10 @@ ATII2CPreInit ATIPtr pATI ) { - switch (pATI->Adapter) - { - case ATI_ADAPTER_MACH64: if (!ATILoadModule(pScreenInfo, "i2c", ATIi2cSymbols)) return; ATIMach64I2CPreInit(pScreenInfo, pATI); - break; - - default: - break; - } } /* diff --git a/src/atiident.c b/src/atiident.c index dfbe1e7..cffa817 100644 --- a/src/atiident.c +++ b/src/atiident.c @@ -32,45 +32,6 @@ #include "r128_probe.h" #include "radeon_probe.h" -const char *ATIChipsetNames[] = -{ - "ati", - -#ifndef AVOID_CPIO - - "ativga", - "ibmvga", - "ibm8514", - "vgawonder", - "mach8", - "mach32", - -#endif /* AVOID_CPIO */ - - "mach64", - "rage128", - "radeon" -}; - -static SymTabRec ATIPublicChipsetNames[] = -{ - {ATI_CHIPSET_ATI, "ati"}, - -#ifndef AVOID_CPIO - - {ATI_CHIPSET_ATIVGA, "ativga"}, -#ifdef __MAYBE_NOT__ - {ATI_CHIPSET_IBMVGA, "ibmvga"}, -#endif -#ifdef __NOT_YET__ - {ATI_CHIPSET_IBM8514, "ibm8514"}, -#endif - -#endif /* AVOID_CPIO */ - - {-1, NULL} -}; - /* * ATIIdentify -- * @@ -82,56 +43,8 @@ ATIIdentify int flags ) { - xf86PrintChipsets(ATI_NAME, - (NumberOf(ATIPublicChipsetNames) <= 2) ? - "ATI driver (version " ATI_VERSION_NAME ") for chipset" : - "ATI driver (version " ATI_VERSION_NAME ") for chipsets", - ATIPublicChipsetNames); + xf86Msg(X_INFO, "%s: %s\n", ATI_NAME, + "ATI driver (version " ATI_VERSION_NAME ") for chipset: mach64"); R128Identify(flags); RADEONIdentify(flags); } - -/* - * ATIIdentProbe -- - * - * This function determines if the user specified a chipset name acceptable to - * the driver. It returns an ATIChipsetType or -1. - */ -int -ATIIdentProbe -( - const char *ChipsetName -) -{ - int Chipset; - - static SymTabRec SpecificNames[] = - { - -#ifndef AVOID_CPIO - - {ATI_CHIPSET_VGAWONDER, "vgawonder"}, -#ifdef __NOT_YET__ - {ATI_CHIPSET_MACH8, "mach8"}, -#endif - {ATI_CHIPSET_MACH32, "mach32"}, - -#endif /* AVOID_CPIO */ - - {ATI_CHIPSET_MACH64, "mach64"}, - {ATI_CHIPSET_RAGE128, "rage128"}, - {ATI_CHIPSET_RADEON, "radeon"}, - {-1, NULL} - }; - - /* If no Chipset specification, default to "ati" */ - if (!ChipsetName || !*ChipsetName) - return ATI_CHIPSET_ATI; - - Chipset = xf86StringToToken(ATIPublicChipsetNames, ChipsetName); - if (Chipset != -1) - return Chipset; - - /* Check for some other chipset names */ - return xf86StringToToken(SpecificNames, ChipsetName); -} diff --git a/src/atiident.h b/src/atiident.h index 84777e0..38699ec 100644 --- a/src/atiident.h +++ b/src/atiident.h @@ -23,30 +23,6 @@ #ifndef ___ATIIDENT_H___ #define ___ATIIDENT_H___ 1 -typedef enum -{ - ATI_CHIPSET_ATI, - -#ifndef AVOID_CPIO - - ATI_CHIPSET_ATIVGA, - ATI_CHIPSET_IBMVGA, - ATI_CHIPSET_IBM8514, - ATI_CHIPSET_VGAWONDER, - ATI_CHIPSET_MACH8, - ATI_CHIPSET_MACH32, - -#endif /* AVOID_CPIO */ - - ATI_CHIPSET_MACH64, - ATI_CHIPSET_RAGE128, - ATI_CHIPSET_RADEON, - ATI_CHIPSET_MAX /* Must be last */ -} ATIChipsetType; - -extern const char *ATIChipsetNames[]; - extern void ATIIdentify(int); -extern int ATIIdentProbe(const char *); #endif /* ___ATIIDENT_H___ */ diff --git a/src/atiio.h b/src/atiio.h deleted file mode 100644 index 6477f36..0000000 --- a/src/atiio.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 1997 through 2003 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of Marc Aurele La France not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Marc Aurele La France makes no representations - * about the suitability of this software for any purpose. It is provided - * "as-is" without express or implied warranty. - * - * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef ___ATIIO_H___ - -#if !defined(___ATI_H___) && defined(XFree86Module) -# error missing #include "ati.h" before #include "atiio.h" -# undef XFree86Module -#endif - -#define ___ATIIO_H___ 1 - -#include "atiregs.h" - -#include "compiler.h" - -/* I/O decoding definitions */ -typedef enum -{ - SPARSE_IO, - BLOCK_IO -} ATIIODecodingType; - -#ifndef AVOID_CPIO - -/* Wait until "n" queue entries are free */ -#define ibm8514WaitQueue(_n) \ - { \ - while (inw(GP_STAT) & (0x0100U >> (_n))); \ - } -#define ATIWaitQueue(_n) \ - { \ - while (inw(EXT_FIFO_STATUS) & (0x010000U >> (_n))); \ - } - -/* Wait until GP is idle and queue is empty */ -#define WaitIdleEmpty() \ - { \ - while (inw(GP_STAT) & (GPBUSY | 1)); \ - } -#define ProbeWaitIdleEmpty() \ - { \ - int _i; \ - CARD16 _value; \ - for (_i = 0; _i < 100000; _i++) \ - { \ - _value = inw(GP_STAT); \ - if (_value == (CARD16)(-1)) \ - break; \ - if (!(_value & (GPBUSY | 1))) \ - break; \ - } \ - } - -/* Wait until GP has data available */ -#define WaitDataReady() \ - { \ - while (!(inw(GP_STAT) & DATARDY)); \ - } - -#endif /* AVOID_CPIO */ - -#endif /* ___ATIIO_H___ */ diff --git a/src/atiload.c b/src/atiload.c index aa36d46..0001ced 100644 --- a/src/atiload.c +++ b/src/atiload.c @@ -62,22 +62,6 @@ const char *ATIvbeSymbols[] = NULL }; -#ifndef AVOID_CPIO - -const char *ATIxf1bppSymbols[] = -{ - "xf1bppScreenInit", - NULL -}; - -const char *ATIxf4bppSymbols[] = -{ - "xf4bppScreenInit", - NULL -}; - -#endif /* AVOID_CPIO */ - #ifdef XF86DRI_DEVEL const char *ATIdrmSymbols[] = { @@ -228,19 +212,6 @@ ATILoadModules /* Load depth-specific entry points */ switch (pATI->bitsPerPixel) { - -#ifndef AVOID_CPIO - - case 1: - fbPtr = ATILoadModule(pScreenInfo, "xf1bpp", ATIxf1bppSymbols); - break; - - case 4: - fbPtr = ATILoadModule(pScreenInfo, "xf4bpp", ATIxf4bppSymbols); - break; - -#endif /* AVOID_CPIO */ - case 8: case 16: case 24: diff --git a/src/atiload.h b/src/atiload.h index ac8fa15..ebccd75 100644 --- a/src/atiload.h +++ b/src/atiload.h @@ -34,12 +34,6 @@ extern const char *ATIint10Symbols[], *ATIddcSymbols[], *ATIvbeSymbols[], -#ifndef AVOID_CPIO - - *ATIxf1bppSymbols[], *ATIxf4bppSymbols[], - -#endif /* AVOID_CPIO */ - #ifdef XF86DRI_DEVEL *ATIdrmSymbols[], *ATIdriSymbols[], diff --git a/src/atilock.c b/src/atilock.c index 7b963c1..ba70087 100644 --- a/src/atilock.c +++ b/src/atilock.c @@ -25,7 +25,6 @@ #endif #include "ati.h" -#include "atiadapter.h" #include "atichip.h" #include "atilock.h" #include "atimach64io.h" @@ -55,49 +54,6 @@ ATIUnlock return; pATI->Unlocked = TRUE; -#ifndef AVOID_CPIO - - if (pATI->ChipHasSUBSYS_CNTL) - { - /* Save register values to be modified */ - pATI->LockData.clock_sel = inw(CLOCK_SEL); - if (pATI->Chip >= ATI_CHIP_68800) - { - pATI->LockData.misc_options = inw(MISC_OPTIONS); - pATI->LockData.mem_bndry = inw(MEM_BNDRY); - pATI->LockData.mem_cfg = inw(MEM_CFG); - } - - tmp = inw(SUBSYS_STAT) & _8PLANE; - - /* Reset the 8514/A and disable all interrupts */ - outw(SUBSYS_CNTL, tmp | (GPCTRL_RESET | CHPTEST_NORMAL)); - outw(SUBSYS_CNTL, tmp | (GPCTRL_ENAB | CHPTEST_NORMAL | RVBLNKFLG | - RPICKFLAG | RINVALIDIO | RGPIDLE)); - - /* Ensure VGA is enabled */ - outw(CLOCK_SEL, pATI->LockData.clock_sel &~DISABPASSTHRU); - if (pATI->Chip >= ATI_CHIP_68800) - { - outw(MISC_OPTIONS, pATI->LockData.misc_options & - ~(DISABLE_VGA | DISABLE_DAC)); - - /* Disable any video memory boundary */ - outw(MEM_BNDRY, pATI->LockData.mem_bndry & - ~(MEM_PAGE_BNDRY | MEM_BNDRY_ENA)); - - /* Disable direct video memory aperture */ - outw(MEM_CFG, pATI->LockData.mem_cfg & - ~(MEM_APERT_SEL | MEM_APERT_PAGE | MEM_APERT_LOC)); - } - - /* Wait for all activity to die down */ - ProbeWaitIdleEmpty(); - } - else if (pATI->Chip >= ATI_CHIP_88800GXC) - -#endif /* AVOID_CPIO */ - { /* Reset everything */ pATI->LockData.bus_cntl = inr(BUS_CNTL); @@ -219,12 +175,11 @@ ATIUnlock } } } + } #ifndef AVOID_CPIO - } - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) { if (pATI->CPIO_VGAWonder) { @@ -244,11 +199,9 @@ ATIUnlock ATIModifyExtReg(pATI, 0xB8U, pATI->LockData.b8, 0xC0U, 0x00U); pATI->LockData.b9 = ATIGetExtReg(0xB9U); ATIModifyExtReg(pATI, 0xB9U, pATI->LockData.b9, 0x7FU, 0x00U); - if (pATI->Chip > ATI_CHIP_18800) { pATI->LockData.be = ATIGetExtReg(0xBEU); ATIModifyExtReg(pATI, 0xBEU, pATI->LockData.be, 0xFAU, 0x01U); - if (pATI->Chip >= ATI_CHIP_28800_2) { pATI->LockData.a6 = ATIGetExtReg(0xA6U); ATIModifyExtReg(pATI, 0xA6U, pATI->LockData.a6, @@ -417,10 +370,10 @@ ATIUnlock out8(LCD_INDEX, GetByte(pATI->LockData.lcd_index, 0)); } } + } #endif /* AVOID_CPIO */ - } } /* @@ -437,7 +390,7 @@ ATILock #ifndef AVOID_CPIO - CARD32 tmp, saved_lcd_gen_ctrl = 0, lcd_gen_ctrl = 0; + CARD32 saved_lcd_gen_ctrl = 0, lcd_gen_ctrl = 0; #endif /* AVOID_CPIO */ @@ -447,7 +400,7 @@ ATILock #ifndef AVOID_CPIO - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) { if (pATI->LCDPanelID >= 0) { @@ -519,10 +472,8 @@ ATILock ATIModifyExtReg(pATI, 0xB6U, -1, 0xDDU, pATI->LockData.b6); ATIModifyExtReg(pATI, 0xB8U, -1, 0xC0U, pATI->LockData.b8 & 0x03U); ATIModifyExtReg(pATI, 0xB9U, -1, 0x7FU, pATI->LockData.b9); - if (pATI->Chip > ATI_CHIP_18800) { ATIModifyExtReg(pATI, 0xBEU, -1, 0xFAU, pATI->LockData.be); - if (pATI->Chip >= ATI_CHIP_28800_2) { ATIModifyExtReg(pATI, 0xA6U, -1, 0x7FU, pATI->LockData.a6); ATIModifyExtReg(pATI, 0xABU, -1, 0xE7U, pATI->LockData.ab); @@ -532,29 +483,6 @@ ATILock } } - if (pATI->ChipHasSUBSYS_CNTL) - { - tmp = inw(SUBSYS_STAT) & _8PLANE; - - /* Reset the 8514/A and disable all interrupts */ - outw(SUBSYS_CNTL, tmp | (GPCTRL_RESET | CHPTEST_NORMAL)); - outw(SUBSYS_CNTL, tmp | (GPCTRL_ENAB | CHPTEST_NORMAL | RVBLNKFLG | - RPICKFLAG | RINVALIDIO | RGPIDLE)); - - /* Restore modified accelerator registers */ - outw(CLOCK_SEL, pATI->LockData.clock_sel); - if (pATI->Chip >= ATI_CHIP_68800) - { - outw(MISC_OPTIONS, pATI->LockData.misc_options); - outw(MEM_BNDRY, pATI->LockData.mem_bndry); - outw(MEM_CFG, pATI->LockData.mem_cfg); - } - - /* Wait for all activity to die down */ - ProbeWaitIdleEmpty(); - } - else if (pATI->Chip >= ATI_CHIP_88800GXC) - #endif /* AVOID_CPIO */ { diff --git a/src/atimach64.c b/src/atimach64.c index 38e0de2..98eb894 100644 --- a/src/atimach64.c +++ b/src/atimach64.c @@ -84,16 +84,6 @@ ATIMach64PreInit { CARD32 bus_cntl, config_cntl; -#ifndef AVOID_CPIO - - if (pATI->depth <= 4) - { - pATIHW->crtc_off_pitch = SetBits(pATI->displayWidth >> 4, CRTC_PITCH); - } - else - -#endif /* AVOID_CPIO */ - { pATIHW->crtc_off_pitch = SetBits(pATI->displayWidth >> 3, CRTC_PITCH); } @@ -156,7 +146,7 @@ ATIMach64PreInit #ifndef AVOID_CPIO - if (pATI->UseSmallApertures) + if (pATI->VGAAdapter) { pATIHW->config_cntl |= CFG_MEM_VGA_AP_EN; } @@ -168,7 +158,7 @@ ATIMach64PreInit pATIHW->config_cntl &= ~CFG_MEM_VGA_AP_EN; } - if (pATI->LinearBase && (pATI->Chip < ATI_CHIP_264CT)) + if ((pATI->Chip < ATI_CHIP_264CT)) { /* Replace linear aperture size and address */ pATIHW->config_cntl &= ~(CFG_MEM_AP_LOC | CFG_MEM_AP_SIZE); @@ -656,15 +646,16 @@ ATIMach64Calculate { pMode->Flags &= ~(V_PHSYNC | V_NHSYNC | V_PVSYNC | V_NVSYNC); - if (pATI->OptionPanelDisplay && (pATI->LCDPanelID >= 0) -#ifdef TV_OUT - && !pATI->tvActive -#endif -) + if (pATI->OptionPanelDisplay && (pATI->LCDPanelID >= 0)) VDisplay = pATI->LCDVertical; else VDisplay = pMode->CrtcVDisplay; +#ifdef TV_OUT + if (pATI->tvActive) + VDisplay = pMode->CrtcVDisplay; +#endif + if (VDisplay < 400) pMode->Flags |= V_PHSYNC | V_NVSYNC; else if (VDisplay < 480) @@ -722,19 +713,6 @@ ATIMach64Calculate CRTC_EXT_DISP_EN | CRTC_EN | CRTC_VGA_LINEAR | CRTC_CNT_EN; switch (pATI->depth) { - -#ifndef AVOID_CPIO - - case 1: - pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_1BPP, CRTC_PIX_WIDTH); - break; - - case 4: - pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_4BPP, CRTC_PIX_WIDTH); - break; - -#endif /* AVOID_CPIO */ - case 8: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_8BPP, CRTC_PIX_WIDTH); break; @@ -796,8 +774,7 @@ ATIMach64Set #endif /* AVOID_CPIO */ { - if ((pATIHW->FeedbackDivider > 0) && - (pATI->ProgrammableClock != ATI_CLOCK_NONE)) + if ((pATIHW->FeedbackDivider > 0)) ATIClockSet(pATI, pATIHW); /* Programme clock */ if (pATI->DAC == ATI_DAC_IBMRGB514) diff --git a/src/atimach64accel.c b/src/atimach64accel.c index e1908b1..090ae78 100644 --- a/src/atimach64accel.c +++ b/src/atimach64accel.c @@ -981,16 +981,7 @@ ATIMach64AccelInit if (pATI->XModifier == 1) { pXAAInfo->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS; - -#ifndef AVOID_CPIO - - if (!pATI->BankInfo.BankSize) - -#endif /* AVOID_CPIO */ - - { - pXAAInfo->Flags |= LINEAR_FRAMEBUFFER; - } + pXAAInfo->Flags |= LINEAR_FRAMEBUFFER; } /* Sync */ diff --git a/src/atimach64cursor.c b/src/atimach64cursor.c index d1fb5fd..be8ea11 100644 --- a/src/atimach64cursor.c +++ b/src/atimach64cursor.c @@ -25,7 +25,6 @@ #endif #include "ati.h" -#include "aticrtc.h" #include "atimach64accel.h" #include "atimach64cursor.h" #include "atimach64io.h" @@ -353,20 +352,6 @@ ATIMach64UseHWCursor if (!pATI->CursorBase) return FALSE; -#ifndef AVOID_CPIO - - /* - * For some reason, the hardware cursor isn't vertically scaled when a VGA - * doublescanned or multiscanned mode is in effect. - */ - if (pATI->NewHW.crtc == ATI_CRTC_MACH64) - return TRUE; - if ((pScreenInfo->currentMode->Flags & V_DBLSCAN) || - (pScreenInfo->currentMode->VScan > 1)) - return FALSE; - -#endif /* AVOID_CPIO */ - return TRUE; } diff --git a/src/atimach64io.h b/src/atimach64io.h index 15a92ad..d1b14d2 100644 --- a/src/atimach64io.h +++ b/src/atimach64io.h @@ -33,17 +33,17 @@ #define ___ATIMACH64IO_H___ 1 -#include "atiio.h" +#include "atiregs.h" #include "atistruct.h" +#include "compiler.h" + /* * A few important notes on some of the I/O statements provided: * * inl/outl 32-bit R/W through PIO space. The register is specified as the * actual PIO address. These are actually defined in compiler.h. * - * inw/outw 16-bit counterparts to inl/outl. Not used for Mach64 support. - * * inb/outb 8-bit counterparts to inl/outl. * * inm/outm 32-bit R/W through MMIO space. The register is specified as @@ -88,6 +88,13 @@ * accessed (nor by what). */ +/* I/O decoding definitions */ +typedef enum +{ + SPARSE_IO, + BLOCK_IO +} ATIIODecodingType; + #define inm(_Register) \ MMIO_IN32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ (_Register) & MM_IO_SELECT) @@ -111,17 +118,13 @@ /* Cause a cpp syntax error if any of these are used */ #undef inb -#undef inw #undef inl #undef outb -#undef outw #undef outl #define inb() /* Nothing */ -#define inw() /* Nothing */ #define inl() /* Nothing */ #define outb() /* Nothing */ -#define outw() /* Nothing */ #define outl() /* Nothing */ #else /* AVOID_CPIO */ diff --git a/src/atimisc.c b/src/atimisc.c index 8670112..e6012ec 100644 --- a/src/atimisc.c +++ b/src/atimisc.c @@ -110,13 +110,6 @@ ATISetup ATIddcSymbols, ATIvbeSymbols, -#ifndef AVOID_CPIO - - ATIxf1bppSymbols, - ATIxf4bppSymbols, - -#endif /* AVOID_CPIO */ - #ifdef XF86DRI_DEVEL ATIdrmSymbols, diff --git a/src/atimode.c b/src/atimode.c index 17210de..d455404 100644 --- a/src/atimode.c +++ b/src/atimode.c @@ -27,7 +27,6 @@ #include <string.h> #include "ati.h" -#include "atiadapter.h" #include "atichip.h" #include "atidac.h" #include "atidsp.h" @@ -231,16 +230,6 @@ ATISwap /* Back to bank 0 */ (*pATIHW->SetBank)(pATI, 0); - - /* - * If restoring video memory for a server video mode, free the frame buffer - * save area. - */ - if (ToFB && (pATIHW == &pATI->NewHW)) - { - xfree(pATIHW->frame_buffer); - pATIHW->frame_buffer = NULL; - } } #endif /* AVOID_CPIO */ @@ -263,7 +252,7 @@ ATIModePreInit #ifndef AVOID_CPIO - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) { /* Fill in VGA data */ ATIVGAPreInit(pATI, pATIHW); @@ -273,8 +262,6 @@ ATIModePreInit ATIVGAWonderPreInit(pATI, pATIHW); } - if (pATI->Chip >= ATI_CHIP_88800GXC) - #endif /* AVOID_CPIO */ { @@ -386,9 +373,6 @@ ATIModeSave #endif /* AVOID_CPIO */ - /* Save clock data */ - ATIClockSave(pScreenInfo, pATI, pATIHW); - if (pATI->Chip >= ATI_CHIP_264CT) { pATIHW->pll_vclk_cntl = ATIMach64GetPLLReg(PLL_VCLK_CNTL) | @@ -437,7 +421,7 @@ ATIModeSave #ifndef AVOID_CPIO - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) { /* Save VGA data */ ATIVGASave(pATI, pATIHW); @@ -447,8 +431,6 @@ ATIModeSave ATIVGAWonderSave(pATI, pATIHW); } - if (pATI->Chip >= ATI_CHIP_88800GXC) - #endif /* AVOID_CPIO */ { @@ -507,47 +489,20 @@ ATIModeSave ATIRGB514Save(pATI, pATIHW); } -#ifndef AVOID_CPIO - - /* - * For some unknown reason, CLKDIV2 needs to be turned off to save the - * DAC's LUT reliably on VGA Wonder VLB adapters. - */ - if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (pATIHW->seq[1] & 0x08U)) - PutReg(SEQX, 0x01U, pATIHW->seq[1] & ~0x08U); - -#endif /* AVOID_CPIO */ - /* Save RAMDAC state */ ATIDACSave(pATI, pATIHW); -#ifndef AVOID_CPIO - - if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (pATIHW->seq[1] & 0x08U)) - PutReg(SEQX, 0x01U, pATIHW->seq[1]); - -#endif /* AVOID_CPIO */ - - /* - * The server has already saved video memory contents when switching out of - * its virtual console, so don't do it again. - */ if (pATIHW != &pATI->NewHW) { pATIHW->FeedbackDivider = 0; /* Don't programme clock */ + } #ifndef AVOID_CPIO /* Save video memory */ ATISwap(pScreenInfo->scrnIndex, pATI, pATIHW, FALSE); -#endif /* AVOID_CPIO */ - - } - -#ifndef AVOID_CPIO - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) ATIVGASaveScreen(pATI, SCREEN_SAVER_OFF); /* Turn on screen */ #endif /* AVOID_CPIO */ @@ -588,29 +543,13 @@ ATIModeCalculate * limitations. */ VScan = pATI->LCDVertical / pMode->VDisplay; - switch (pATIHW->crtc) { - -#ifndef AVOID_CPIO - - case ATI_CRTC_VGA: - if (VScan > 64) - VScan = 64; - pMode->VScan = VScan; - break; - -#endif /* AVOID_CPIO */ - - case ATI_CRTC_MACH64: pMode->VScan = 0; - if (VScan <= 1) - break; + if (VScan > 1) + { VScan = 2; pMode->Flags |= V_DBLSCAN; - break; - - default: - break; + } } pMode->HSyncStart = pMode->HDisplay + pATI->LCDHSyncStart; @@ -625,132 +564,9 @@ ATIModeCalculate ATIDivide(pATI->LCDVBlankWidth, VScan, 0, 0); } - switch (pATIHW->crtc) { - -#ifndef AVOID_CPIO - - case ATI_CRTC_VGA: - /* Fill in VGA data */ - ATIVGACalculate(pATI, pATIHW, pMode); - - /* Fill in VGA Wonder data */ - if (pATI->CPIO_VGAWonder) - ATIVGAWonderCalculate(pATI, pATIHW, pMode); - - if (pATI->Chip >= ATI_CHIP_88800GXC) - { - if (pATI->Chip >= ATI_CHIP_264CT) - { - /* - * Selected bits of accelerator & VGA CRTC registers are - * actually copies of each other. - */ - pATIHW->crtc_h_total_disp = - SetBits(pMode->CrtcHTotal, CRTC_H_TOTAL) | - SetBits(pMode->CrtcHDisplay, CRTC_H_DISP); - pATIHW->crtc_h_sync_strt_wid = - SetBits(pMode->CrtcHSyncStart, CRTC_H_SYNC_STRT) | - SetBits(pMode->CrtcHSkew, CRTC_H_SYNC_DLY) | /* ? */ - SetBits(GetBits(pMode->CrtcHSyncStart, 0x0100U), - CRTC_H_SYNC_STRT_HI) | - SetBits(pMode->CrtcHSyncEnd, CRTC_H_SYNC_WID); - if (pMode->Flags & V_NHSYNC) - pATIHW->crtc_h_sync_strt_wid |= CRTC_H_SYNC_POL; - - pATIHW->crtc_v_total_disp = - SetBits(pMode->CrtcVTotal, CRTC_V_TOTAL) | - SetBits(pMode->CrtcVDisplay, CRTC_V_DISP); - pATIHW->crtc_v_sync_strt_wid = - SetBits(pMode->CrtcVSyncStart, CRTC_V_SYNC_STRT) | - SetBits(pMode->CrtcVSyncEnd, CRTC_V_SYNC_END_VGA); - if (pMode->Flags & V_NVSYNC) - pATIHW->crtc_v_sync_strt_wid |= CRTC_V_SYNC_POL; - } - - pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL) & - ~(CRTC_DBL_SCAN_EN | CRTC_INTERLACE_EN | - CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | CRTC_CSYNC_EN | - CRTC_PIX_BY_2_EN | CRTC_DISPLAY_DIS | - CRTC_VGA_XOVERSCAN | CRTC_PIX_WIDTH | - CRTC_BYTE_PIX_ORDER | CRTC_VGA_128KAP_PAGING | - CRTC_VFC_SYNC_TRISTATE | - CRTC_LOCK_REGS | /* Already off, but ... */ - CRTC_SYNC_TRISTATE | CRTC_EXT_DISP_EN | - CRTC_DISP_REQ_EN | CRTC_VGA_LINEAR | CRTC_VGA_TEXT_132 | - CRTC_CUR_B_TEST); - /* Some of these are not relevent, but that doesn't matter */ - switch (pATI->depth) - { - case 1: - pATIHW->crtc_gen_cntl |= - SetBits(PIX_WIDTH_1BPP, CRTC_PIX_WIDTH); - break; - - case 4: - pATIHW->crtc_gen_cntl |= - SetBits(PIX_WIDTH_4BPP, CRTC_PIX_WIDTH); - break; - - case 8: - pATIHW->crtc_gen_cntl |= - SetBits(PIX_WIDTH_8BPP, CRTC_PIX_WIDTH); - break; - - case 15: - pATIHW->crtc_gen_cntl |= - SetBits(PIX_WIDTH_15BPP, CRTC_PIX_WIDTH); - break; - - case 16: - pATIHW->crtc_gen_cntl |= - SetBits(PIX_WIDTH_16BPP, CRTC_PIX_WIDTH); - break; - - case 24: - if (pATI->bitsPerPixel == 24) - { - pATIHW->crtc_gen_cntl |= - SetBits(PIX_WIDTH_24BPP, CRTC_PIX_WIDTH); - break; - } - if (pATI->bitsPerPixel != 32) - break; - /* Fall through */ - - case 32: - pATIHW->crtc_gen_cntl |= - SetBits(PIX_WIDTH_32BPP, CRTC_PIX_WIDTH); - break; - - default: - break; - } -#if 0 /* This isn't needed, but is kept for reference */ - if (pMode->Flags & V_DBLSCAN) - pATIHW->crtc_gen_cntl |= CRTC_DBL_SCAN_EN; -#endif - if (pMode->Flags & V_INTERLACE) - pATIHW->crtc_gen_cntl |= CRTC_INTERLACE_EN; - if ((pMode->Flags & (V_CSYNC | V_PCSYNC)) || pATI->OptionCSync) - pATIHW->crtc_gen_cntl |= CRTC_CSYNC_EN; - if (pATI->depth <= 4) - pATIHW->crtc_gen_cntl |= CRTC_EN | CRTC_CNT_EN; - else - pATIHW->crtc_gen_cntl |= - CRTC_EN | CRTC_VGA_LINEAR | CRTC_CNT_EN; - } - break; - -#endif /* AVOID_CPIO */ - - case ATI_CRTC_MACH64: /* Fill in Mach64 data */ ATIMach64Calculate(pATI, pATIHW, pMode); - break; - - default: - break; } /* Set up LCD register values */ @@ -925,16 +741,17 @@ ATIModeCalculate MaxScalerClock = 80000; /* Conservative */ pATIHW->pll_vclk_cntl &= ~PLL_ECP_DIV; #ifdef TV_OUT - if (!pATI->OptionTvOut) { -#endif /* TV_OUT */ + if (pATI->OptionTvOut) { /* XXX Don't do this for TVOut! */ + } + else +#endif /* TV_OUT */ + { ECPClock = pMode->SynthClock; for (Index = 0; (ECPClock > MaxScalerClock) && (Index < 2); Index++) ECPClock >>= 1; pATIHW->pll_vclk_cntl |= SetBits(Index, PLL_ECP_DIV); -#ifdef TV_OUT } -#endif /* TV_OUT */ } else if (pATI->DAC == ATI_DAC_IBMRGB514) { @@ -1070,7 +887,6 @@ ATIModeSet #endif /* AVOID_CPIO */ - if (pATI->Chip >= ATI_CHIP_88800GXC) { /* Stop CRTC */ outr(CRTC_GEN_CNTL, @@ -1138,8 +954,7 @@ ATIModeSet PutReg(SEQX, 0x00U, 0x00U); /* Set pixel clock */ - if ((pATIHW->FeedbackDivider > 0) && - (pATI->ProgrammableClock > ATI_CLOCK_FIXED)) + if ((pATIHW->FeedbackDivider > 0)) ATIClockSet(pATI, pATIHW); /* Set up RAMDAC */ @@ -1154,7 +969,6 @@ ATIModeSet ATIVGASet(pATI, pATIHW); /* Load Mach64 registers */ - if (pATI->Chip >= ATI_CHIP_88800GXC) { /* Load MMIO registers */ if (pATI->Block0Base) @@ -1201,7 +1015,7 @@ ATIModeSet #ifndef AVOID_CPIO - if (pATI->UseSmallApertures) + if (pATI->VGAAdapter) { /* Oddly enough, these need to be set also, maybe others */ PutReg(SEQX, 0x02U, pATIHW->seq[2]); @@ -1302,7 +1116,7 @@ ATIModeSet /* Restore video memory */ ATISwap(pScreenInfo->scrnIndex, pATI, pATIHW, TRUE); - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) ATIVGASaveScreen(pATI, SCREEN_SAVER_OFF); /* Turn on screen */ #endif /* AVOID_CPIO */ diff --git a/src/atimono.h b/src/atimono.h deleted file mode 100644 index 7830e5e..0000000 --- a/src/atimono.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 1997 through 2003 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of Marc Aurele La France not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Marc Aurele La France makes no representations - * about the suitability of this software for any purpose. It is provided - * "as-is" without express or implied warranty. - * - * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef ___ATIMONO_H___ -#define ___ATIMONO_H___ 1 - -#ifndef BIT_PLANE -# define BIT_PLANE 3 -#endif - -#ifndef MONO_BLACK -# define MONO_BLACK 0x00U -#endif - -#ifndef MONO_WHITE -# define MONO_WHITE 0x3FU -#endif - -#ifndef MONO_OVERSCAN -# define MONO_OVERSCAN 0x01U -#endif - -#endif /* ___ATIMONO_H___ */ diff --git a/src/atioption.c b/src/atioption.c index 5f2bd01..4cb965d 100644 --- a/src/atioption.c +++ b/src/atioption.c @@ -61,6 +61,13 @@ const char *ATITVStandardNames[ATI_TV_STDS_MAX_VALID+1] = { const OptionInfoRec ATIPublicOptions[] = { { + ATI_OPTION_PROBE_SPARSE, + "probe_sparse", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { ATI_OPTION_ACCEL, "accel", OPTV_BOOLEAN, @@ -89,18 +96,6 @@ const OptionInfoRec ATIPublicOptions[] = FALSE, }, -#ifndef AVOID_CPIO - - { - ATI_OPTION_LINEAR, - "linear", - OPTV_BOOLEAN, - {0, }, - FALSE - }, - -#endif /* AVOID_CPIO */ - #ifdef XF86DRI_DEVEL { @@ -190,13 +185,6 @@ const OptionInfoRec ATIPublicOptions[] = FALSE }, { - ATI_OPTION_PROBE_CLOCKS, - "probe_clocks", - OPTV_BOOLEAN, - {0, }, - FALSE - }, - { ATI_OPTION_REFERENCE_CLOCK, "reference_clock", OPTV_FREQ, diff --git a/src/atioption.h b/src/atioption.h index 23a9fcf..f68f641 100644 --- a/src/atioption.h +++ b/src/atioption.h @@ -33,17 +33,12 @@ */ typedef enum { + ATI_OPTION_PROBE_SPARSE, ATI_OPTION_ACCEL, ATI_OPTION_CRT_DISPLAY, ATI_OPTION_CSYNC, ATI_OPTION_HWCURSOR, -#ifndef AVOID_CPIO - - ATI_OPTION_LINEAR, - -#endif /* AVOID_CPIO */ - #ifdef XF86DRI_DEVEL ATI_OPTION_IS_PCI, @@ -65,7 +60,6 @@ typedef enum ATI_OPTION_MMIO_CACHE, ATI_OPTION_TEST_MMIO_CACHE, ATI_OPTION_PANEL_DISPLAY, - ATI_OPTION_PROBE_CLOCKS, ATI_OPTION_REFERENCE_CLOCK, ATI_OPTION_SHADOW_FB, ATI_OPTION_SWCURSOR, diff --git a/src/atipreinit.c b/src/atipreinit.c index 047aeed..b9111fc 100644 --- a/src/atipreinit.c +++ b/src/atipreinit.c @@ -28,7 +28,6 @@ #include <stdio.h> #include "ati.h" -#include "atiadapter.h" #include "atiadjust.h" #include "atiaudio.h" #include "atibus.h" @@ -54,251 +53,21 @@ #include "vbe.h" #include "xf86RAC.h" -#ifndef AVOID_CPIO - -typedef CARD16 Colour; /* The correct spelling should be OK :-) */ - /* - * Bit patterns which are extremely unlikely to show up when reading from - * nonexistant memory (which normally shows up as either all bits set or all - * bits clear). + * FreeScreen handles the clean-up. */ -static const Colour Test_Pixel[] = {0x5AA5U, 0x55AAU, 0xA55AU, 0xCA53U}; - -static const struct +static Bool +Mach64GetRec(ScrnInfoPtr pScrn) { - int videoRamSize; - int Miscellaneous_Options_Setting; - struct - { - short int x, y; + if (!pScrn->driverPrivate) { + pScrn->driverPrivate = xnfcalloc(sizeof(ATIRec), 1); + memset(pScrn->driverPrivate, 0, sizeof(ATIRec)); } - Coordinates[NumberOf(Test_Pixel) + 1]; -} -Test_Case[] = -{ - /* - * Given the engine settings used, only a 4M card will have enough memory - * to back up the 1025th line of the display. Since the pixel coordinates - * are zero-based, line 1024 will be the first one which is only backed on - * 4M cards. - * - * <Mark_Weaver@brown.edu>: - * In case memory is being wrapped, (0,0) and (0,1024) to make sure they - * can each hold a unique value. - */ - {4096, MEM_SIZE_4M, {{0,0}, {0,1024}, {-1,-1}}}, - - /* - * This card has 2M or less. On a 1M card, the first 2M of the card's - * memory will have even doublewords backed by physical memory and odd - * doublewords unbacked. - * - * Pixels 0 and 1 of a row will be in the zeroth doubleword, while pixels 2 - * and 3 will be in the first. Check both pixels 2 and 3 in case this is a - * pseudo-1M card (one chip pulled to turn a 2M card into a 1M card). - * - * <Mark_Weaver@brown.edu>: - * I don't have a 1M card, so I'm taking a stab in the dark. Maybe memory - * wraps every 512 lines, or maybe odd doublewords are aliases of their - * even doubleword counterparts. I try everything here. - */ - {2048, MEM_SIZE_2M, {{0,0}, {0,512}, {2,0}, {3,0}, {-1,-1}}}, - - /* - * This is a either a 1M card or a 512k card. Test pixel 1, since it is an - * odd word in an even doubleword. - * - * <Mark_Weaver@brown.edu>: - * This is the same idea as the test above. - */ - {1024, MEM_SIZE_1M, {{0,0}, {0,256}, {1,0}, {-1,-1}}}, - - /* - * Assume it is a 512k card by default, since that is the minimum - * configuration. - */ - {512, MEM_SIZE_512K, {{-1,-1}}} -}; - -/* - * ATIMach32ReadPixel -- - * - * Return the colour of the specified screen location. Called from - * ATIMach32videoRam function below. - */ -static Colour -ATIMach32ReadPixel -( - const short int X, - const short int Y -) -{ - Colour Pixel_Colour; - - /* Wait for idle engine */ - ProbeWaitIdleEmpty(); - - /* Set up engine for pixel read */ - ATIWaitQueue(7); - outw(RD_MASK, (CARD16)(~0)); - outw(DP_CONFIG, FG_COLOR_SRC_BLIT | DATA_WIDTH | DRAW | DATA_ORDER); - outw(CUR_X, X); - outw(CUR_Y, Y); - outw(DEST_X_START, X); - outw(DEST_X_END, X + 1); - outw(DEST_Y_END, Y + 1); - - /* Wait for data to become ready */ - ATIWaitQueue(16); - WaitDataReady(); - - /* Read pixel colour */ - Pixel_Colour = inw(PIX_TRANS); - ProbeWaitIdleEmpty(); - return Pixel_Colour; -} -/* - * ATIMach32WritePixel -- - * - * Set the colour of the specified screen location. Called from - * ATIMach32videoRam function below. - */ -static void -ATIMach32WritePixel -( - const short int X, - const short int Y, - const Colour Pixel_Colour -) -{ - /* Set up engine for pixel write */ - ATIWaitQueue(9); - outw(WRT_MASK, (CARD16)(~0)); - outw(DP_CONFIG, FG_COLOR_SRC_FG | DRAW | READ_WRITE); - outw(ALU_FG_FN, MIX_FN_PAINT); - outw(FRGD_COLOR, Pixel_Colour); - outw(CUR_X, X); - outw(CUR_Y, Y); - outw(DEST_X_START, X); - outw(DEST_X_END, X + 1); - outw(DEST_Y_END, Y + 1); + return TRUE; } /* - * ATIMach32videoRam -- - * - * Determine the amount of video memory installed on an 68800-6 based adapter. - * This is done because these chips exhibit a bug that causes their - * MISC_OPTIONS register to report 1M rather than the true amount of memory. - * - * This function is adapted from a similar function in mach32mem.c written by - * Robert Wolff, David Dawes and Mark Weaver. - */ -static int -ATIMach32videoRam -( - void -) -{ - CARD16 clock_sel, mem_bndry, misc_options, ext_ge_config; - Colour saved_Pixel[NumberOf(Test_Pixel)]; - unsigned int Case_Number, Pixel_Number; - Bool AllPixelsOK; - - /* Save register values to be modified */ - clock_sel = inw(CLOCK_SEL); - mem_bndry = inw(MEM_BNDRY); - misc_options = inw(MISC_OPTIONS) & ~MEM_SIZE_ALIAS; - ext_ge_config = inw(R_EXT_GE_CONFIG); - - /* Wait for enough FIFO entries */ - ATIWaitQueue(7); - - /* Enable accelerator */ - outw(CLOCK_SEL, clock_sel | DISABPASSTHRU); - - /* Make accelerator and VGA share video memory */ - outw(MEM_BNDRY, mem_bndry & ~(MEM_PAGE_BNDRY | MEM_BNDRY_ENA)); - - /* Prevent video memory wrap */ - outw(MISC_OPTIONS, misc_options | MEM_SIZE_4M); - - /* - * Set up the drawing engine for a pitch of 1024 at 16 bits per pixel. No - * need to mess with the CRT because the results of this test are not - * intended to be seen. - */ - outw(EXT_GE_CONFIG, PIXEL_WIDTH_16 | ORDER_16BPP_565 | MONITOR_8514 | - ALIAS_ENA); - outw(GE_PITCH, 1024 >> 3); - outw(GE_OFFSET_HI, 0); - outw(GE_OFFSET_LO, 0); - - for (Case_Number = 0; - Case_Number < (NumberOf(Test_Case) - 1); - Case_Number++) - { - /* Reduce redundancy as per Mark_Weaver@brown.edu */ -# define TestPixel Test_Case[Case_Number].Coordinates[Pixel_Number] -# define ForEachTestPixel \ - for (Pixel_Number = 0; TestPixel.x >= 0; Pixel_Number++) - - /* Save pixel colours that will be clobbered */ - ForEachTestPixel - saved_Pixel[Pixel_Number] = - ATIMach32ReadPixel(TestPixel.x, TestPixel.y); - - /* Write test patterns */ - ForEachTestPixel - ATIMach32WritePixel(TestPixel.x, TestPixel.y, - Test_Pixel[Pixel_Number]); - - /* Test for lost pixels */ - AllPixelsOK = TRUE; - ForEachTestPixel - { - if (ATIMach32ReadPixel(TestPixel.x, TestPixel.y) != - Test_Pixel[Pixel_Number]) - { - AllPixelsOK = FALSE; - break; - } - } - - /* Restore clobbered pixels */ - ForEachTestPixel - ATIMach32WritePixel(TestPixel.x, TestPixel.y, - saved_Pixel[Pixel_Number]); - - /* End test on success */ - if (AllPixelsOK) - break; - - /* Completeness */ -# undef ForEachTestPixel -# undef TestPixel - } - - /* Restore what was changed and correct MISC_OPTIONS register */ - ATIWaitQueue(4); - outw(EXT_GE_CONFIG, ext_ge_config); - misc_options |= Test_Case[Case_Number].Miscellaneous_Options_Setting; - outw(MISC_OPTIONS, misc_options); - outw(MEM_BNDRY, mem_bndry); - outw(CLOCK_SEL, clock_sel); - - /* Wait for activity to die down */ - ProbeWaitIdleEmpty(); - - /* Tell ATIPreInit the REAL story */ - return Test_Case[Case_Number].videoRamSize; -} - -#endif /* AVOID_CPIO */ - -/* * ATIReportMemory -- * * This function reports on the amount and type of video memory found. @@ -317,19 +86,6 @@ ATIReportMemory snprintf(Buffer, SizeOf(Buffer), "%d kB of %s detected", pATI->VideoRAM, MemoryTypeName); -#ifndef AVOID_CPIO - - if (pATI->depth == 1) - { - /* 1bpp only uses one plane of four */ - pScreenInfo->videoRam /= 4; - Message += snprintf(Message, Buffer + SizeOf(Buffer) - Message, - " (using %d kB)", pScreenInfo->videoRam); - } - else - -#endif /* AVOID_CPIO */ - if (pATI->VideoRAM > pScreenInfo->videoRam) { Message += snprintf(Message, Buffer + SizeOf(Buffer) - Message, @@ -339,7 +95,7 @@ ATIReportMemory } static const int videoRamSizes[] = - {0, 256, 512, 1024, 2*1024, 4*1024, 6*1024, 8*1024, 12*1024, 16*1024, 0}; + {512, 1024, 2*1024, 4*1024, 6*1024, 8*1024, 12*1024, 16*1024}; static const rgb defaultWeight = {0, 0, 0}; static const Gamma defaultGamma = {0.0, 0.0, 0.0}; @@ -420,10 +176,10 @@ ATIPreInit DisplayModePtr pMode; unsigned long Block0Base; CARD32 IOValue; - int i, j, AcceleratorVideoRAM = 0, ServerVideoRAM; + int i, j; int Numerator, Denominator; int MinX, MinY; - ClockRange ATIClockRange = {NULL, 0, 80000, 0, TRUE, TRUE, 1, 1, 0}; + ClockRange ATIClockRange = {NULL, 0, 80000, -1, TRUE, TRUE, 1, 1, 0}; int DefaultmaxClock = 0; int minPitch, maxPitch = 0xFFU, maxHeight = 0; int ApertureSize = 0x00010000U; @@ -436,10 +192,8 @@ ATIPreInit #ifndef AVOID_CPIO xf86Int10InfoPtr pInt10Info = NULL; - vbeInfoPtr pVBE; + vbeInfoPtr pVBE = NULL; pointer pInt10Module, pDDCModule = NULL, pVBEModule = NULL; - int VGAVideoRAM = 0; - resRange Resources[2] = {{0, 0, 0}, _END}; #endif /* AVOID_CPIO */ @@ -450,23 +204,24 @@ ATIPreInit return FALSE; } - pATI = ATIPTR(pScreenInfo); - - if (pATI->iEntity != pScreenInfo->entityList[0]) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Logic error: Entity mismatch.\n"); + if (!Mach64GetRec(pScreenInfo)) return FALSE; - } + + pATI = ATIPTR(pScreenInfo); /* Register resources */ - pEntity = xf86GetEntityInfo(pATI->iEntity); + pEntity = xf86GetEntityInfo(pScreenInfo->entityList[0]); pGDev = pEntity->device; pResources = pEntity->resources; + + pATI->iEntity = pEntity->index; + pATI->Chip = pEntity->chipset; + pVideo = xf86GetPciInfoForEntity(pATI->iEntity); + xfree(pEntity); + if (!pResources) - pResources = xf86RegisterResources(pATI->iEntity, NULL, - pATI->SharedAccelerator ? ResShared : ResExclusive); + pResources = xf86RegisterResources(pATI->iEntity, NULL, ResShared); if (pResources) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, @@ -481,51 +236,11 @@ ATIPreInit if (!(flags & PROBE_DETECT)) { - xf86DrvMsg(pScreenInfo->scrnIndex, - pATI->Chipset ? X_CONFIG : X_DEFAULT, - "Chipset: \"%s\".\n", ATIChipsetNames[pATI->Chipset]); - - /* Promote chipset specification */ - switch (pATI->Chipset) - { - -#ifndef AVOID_CPIO - - case ATI_CHIPSET_IBMVGA: - if (pATI->Adapter == ATI_ADAPTER_VGA) - break; /* XXX */ - /* Fall through */ - - case ATI_CHIPSET_VGAWONDER: - pATI->Chipset = ATI_CHIPSET_ATIVGA; - break; - - case ATI_CHIPSET_IBM8514: - if (pATI->Adapter == ATI_ADAPTER_8514A) - break; /* XXX */ - /* Fall through */ - - case ATI_CHIPSET_MACH8: - case ATI_CHIPSET_MACH32: - -#endif /* AVOID_CPIO */ - - case ATI_CHIPSET_MACH64: - case ATI_CHIPSET_RAGE128: - case ATI_CHIPSET_RADEON: - pATI->Chipset = ATI_CHIPSET_ATI; - break; - - default: - break; - } - /* Set monitor */ pScreenInfo->monitor = pScreenInfo->confScreen->monitor; /* Set depth, bpp, etc. */ - if ((pATI->Chipset != ATI_CHIPSET_ATI) || - (pATI->Chip < ATI_CHIP_264CT)) + if ((pATI->Chip < ATI_CHIP_264CT)) { i = NoDepth24Support; /* No support for >8bpp either */ DefaultDepth = 8; @@ -543,15 +258,6 @@ ATIPreInit { static const CARD8 AllowedDepthBpp[][2] = { - -#ifndef AVOID_CPIO - - { 1, 1}, - { 4, 4}, - { 4, 8}, - -#endif /* AVOID_CPIO */ - { 8, 8}, {15, 16}, {16, 16}, @@ -594,14 +300,12 @@ ATIPreInit ATIProcessOptions(pScreenInfo, pATI); } -#ifdef AVOID_CPIO + if (!ATIMach64ProbeIO(pVideo, pATI)) + return FALSE; - else /* if (flags & PROBE_DETECT) */ - { - return TRUE; - } + ATIClaimBusSlot(pGDev->active, pATI); -#else /* AVOID_CPIO */ +#ifndef AVOID_CPIO #ifdef TV_OUT @@ -642,17 +346,7 @@ ATIPreInit if ((pVBE = VBEInit(pInt10Info, pATI->iEntity))) { ConfiguredMonitor = vbeDoEDID(pVBE, pDDCModule); -#ifdef TV_OUT - pATI->pInt10 = pInt10Info; - pATI->pVBE = pVBE; - pVBE = NULL; -#else - vbeFree(pVBE); -#endif /* TV_OUT */ } -#ifndef TV_OUT - xf86UnloadSubModule(pVBEModule); -#endif /* TV_OUT */ } if (!(flags & PROBE_DETECT)) @@ -676,20 +370,21 @@ ATIPreInit } #ifndef TV_OUT + /* De-activate VBE */ + vbeFree(pVBE); + xf86UnloadSubModule(pVBEModule); + /* De-activate int10 */ xf86FreeInt10(pInt10Info); xf86UnloadSubModule(pInt10Module); #else + pATI->pInt10 = pInt10Info; + pATI->pVBE = pVBE; + pVBE = NULL; pInt10Info = NULL; #endif /* TV_OUT */ - if (flags & PROBE_DETECT) - { - xf86UnloadSubModule(pDDCModule); - return TRUE; - } - - if (ConfiguredMonitor) + if (ConfiguredMonitor && !(flags & PROBE_DETECT)) { xf86PrintEDID(ConfiguredMonitor); xf86SetDDCproperties(pScreenInfo, ConfiguredMonitor); @@ -700,6 +395,11 @@ ATIPreInit #endif /* AVOID_CPIO */ + if (flags & PROBE_DETECT) + { + return TRUE; + } + pATI->Block0Base = 0; /* Might no longer be valid */ if ((pVideo = pATI->PCIInfo)) { @@ -729,124 +429,15 @@ ATIPreInit #endif /* AVOID_CPIO */ - /* Deal with ChipID & ChipRev overrides */ - if (pGDev->chipID >= 0) - { - ATIChipType Chip; - - Chip = ATIChipID(pGDev->chipID, - (pGDev->chipRev < 0) ? pATI->ChipRev : pGDev->chipRev); - if (Chip != pATI->Chip) - { - pATI->Chip = Chip; - pATI->ChipType = pGDev->chipID; - if (pGDev->chipRev < 0) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, - "Driver messages reflect ChipID 0x%04X override.\n", - pATI->ChipType); - } - else - { - pATI->ChipRev = pGDev->chipRev; - pATI->ChipVersion = GetBits(pATI->ChipRev, - GetBits(CFG_CHIP_VERSION, CFG_CHIP_REV)); - pATI->ChipFoundry = GetBits(pATI->ChipRev, - GetBits(CFG_CHIP_FOUNDRY, CFG_CHIP_REV)); - pATI->ChipRevision = GetBits(pATI->ChipRev, - GetBits(CFG_CHIP_REVISION, CFG_CHIP_REV)); - xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, - "Driver messages reflect ChipID 0x%04X and ChipRev 0x%02X" - " overrides.\n", pATI->ChipType, pATI->ChipRev); - } - } - } - /* Finish private area initialisation */ pATI->DAC = ATI_DAC_GENERIC; -#ifndef AVOID_CPIO - - pATI->NewHW.SetBank = ATIx8800SetBank; - pATI->BankInfo.SetSourceBank = ATIx8800SetRead; - pATI->BankInfo.SetDestinationBank = ATIx8800SetWrite; - pATI->BankInfo.SetSourceAndDestinationBanks = ATIx8800SetReadWrite; - pATI->BankInfo.BankSize = 0x00010000U; /* 64kB */ - -#endif /* AVOID_CPIO */ - pATI->LCDPanelID = -1; pATI->nFIFOEntries = 16; /* For now */ pATI->Audio = ATI_AUDIO_NONE; /* Finish probing the adapter */ - switch (pATI->Adapter) { - -#ifndef AVOID_CPIO - - case ATI_ADAPTER_NONE: - case ATI_ADAPTER_EGA: - case ATI_ADAPTER_EGA_PLUS: - case ATI_ADAPTER_VGA: - case ATI_ADAPTER_BASIC: - pATI->NewHW.SetBank = (ATIBankProcPtr)NoopDDA; - pATI->BankInfo.SetSourceBank = - pATI->BankInfo.SetDestinationBank = - pATI->BankInfo.SetSourceAndDestinationBanks = - (miBankProcPtr)NoopDDA; - break; - - case ATI_ADAPTER_V3: - pATI->NewHW.SetBank = ATIV3SetBank; - pATI->BankInfo.SetSourceBank = ATIV3SetRead; - pATI->BankInfo.SetDestinationBank = ATIV3SetWrite; - pATI->BankInfo.SetSourceAndDestinationBanks = ATIV3SetReadWrite; - break; - - case ATI_ADAPTER_V4: - case ATI_ADAPTER_V5: - pATI->NewHW.SetBank = ATIV4V5SetBank; - pATI->BankInfo.SetSourceBank = ATIV4V5SetRead; - pATI->BankInfo.SetDestinationBank = ATIV4V5SetWrite; - pATI->BankInfo.SetSourceAndDestinationBanks = ATIV4V5SetReadWrite; - break; - - case ATI_ADAPTER_XL: - pATI->DAC = ATI_DAC_SC11483; - break; - - case ATI_ADAPTER_8514A: - pATI->VideoRAM = - videoRamSizes[GetBits(inw(SUBSYS_STAT), _8PLANE) + 2]; - break; - - case ATI_ADAPTER_MACH8: - pATI->VideoRAM = - videoRamSizes[GetBits(inw(CONFIG_STATUS_1), MEM_INSTALLED) + 2]; - break; - - case ATI_ADAPTER_MACH32: - IOValue = inw(CONFIG_STATUS_1); - pATI->DAC = ATI_DAC(GetBits(IOValue, DACTYPE), 0); - pATI->MemoryType = GetBits(IOValue, MEM_TYPE); - - IOValue = inw(MISC_OPTIONS); - pATI->VideoRAM = - videoRamSizes[GetBits(IOValue, MEM_SIZE_ALIAS) + 2]; - - /* - * The 68800-6 doesn't necessarily report the correct video memory - * size. - */ - if ((pATI->Chip == ATI_CHIP_68800_6) && (pATI->VideoRAM == 1024)) - pATI->VideoRAM = ATIMach32videoRam(); - - break; - -#endif /* AVOID_CPIO */ - - case ATI_ADAPTER_MACH64: do { /* @@ -919,8 +510,8 @@ ATIPreInit pATIHW->mem_cntl = inr(MEM_CNTL); if (pATI->Chip < ATI_CHIP_264VTB) { - pATI->VideoRAM = - videoRamSizes[GetBits(pATIHW->mem_cntl, CTL_MEM_SIZE) + 2]; + IOValue = GetBits(pATIHW->mem_cntl, CTL_MEM_SIZE); + pATI->VideoRAM = videoRamSizes[IOValue]; } else { @@ -1025,24 +616,12 @@ ATIPreInit */ if (pATI->DAC < ATI_DAC_ATI68875) pATI->DAC += ATI_DAC_INTERNAL; - - break; - - default: - break; } /* * For Mach64 adapters, pick up, from the BIOS, the type of programmable * clock generator (if any), and various information about it. */ - -#ifndef AVOID_CPIO - - if (pATI->Chip >= ATI_CHIP_88800GXC) - -#endif /* AVOID_CPIO */ - { CARD16 ClockDac; @@ -1085,16 +664,6 @@ ATIPreInit if (ClockTable > 0) { - FrequencyTable = BIOSWord(ClockTable - 0x02U); - if ((FrequencyTable > 0) && - ((FrequencyTable + 0x20U) <= BIOSSize)) - { - for (i = 0; i < 16; i++) - { - pATI->BIOSClocks[i] = BIOSWord(FrequencyTable); - FrequencyTable += 2; - } - } pATI->ProgrammableClock = BIOSByte(ClockTable); pATI->ClockNumberToProgramme = BIOSByte(ClockTable + 0x06U); switch (BIOSWord(ClockTable + 0x08U) / 10) @@ -1162,9 +731,7 @@ ATIPreInit * accelerator modes. */ if ((pATI->ProgrammableClock == ATI_CLOCK_ICS2595) && - (pATI->DAC == ATI_DAC_IBMRGB514) && - (pScreenInfo->depth >= 8) && - (pATI->Chipset == ATI_CHIPSET_ATI)) + (pATI->DAC == ATI_DAC_IBMRGB514)) pATI->ProgrammableClock = ATI_CLOCK_IBMRGB514; pATI->ClockDescriptor = @@ -1415,29 +982,10 @@ ATIPreInit ATIUnlock(pATI); /* Unlock registers */ -#ifndef AVOID_CPIO - - /* Sometimes, the BIOS lies about the chip */ - if ((pATI->Chip >= ATI_CHIP_28800_4) && (pATI->Chip <= ATI_CHIP_28800_6)) - { - IOValue = GetBits(ATIGetExtReg(0xAAU), 0x0FU) + - (ATI_CHIP_28800_4 - 4); - if ((IOValue <= ATI_CHIP_28800_6) && (IOValue > pATI->Chip)) - pATI->Chip = IOValue; - } - -#endif /* AVOID_CPIO */ - /* Report what was found */ xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s graphics controller detected.\n", ATIChipNames[pATI->Chip]); -#ifndef AVOID_CPIO - - if ((pATI->Chip >= ATI_CHIP_68800) && (pATI->Chip != ATI_CHIP_68800_3)) - -#endif /* AVOID_CPIO */ - { Message = Buffer + snprintf(Buffer, SizeOf(Buffer), "Chip type %04X", pATI->ChipType); @@ -1459,19 +1007,12 @@ ATIPreInit Buffer, pATI->ChipClass, pATI->ChipRevision); } -#ifndef AVOID_CPIO - - if (pATI->Adapter >= ATI_ADAPTER_MACH8) - -#endif /* AVOID_CPIO */ - { Message = Buffer + snprintf(Buffer, SizeOf(Buffer), "%s bus interface detected", ATIBusNames[pATI->BusType]); #ifndef AVOID_CPIO - if (pATI->Adapter >= ATI_ADAPTER_MACH64) { Message += snprintf(Message, Buffer + SizeOf(Buffer) - Message, "; %s I/O base is 0x%04lX", @@ -1491,16 +1032,10 @@ ATIPreInit "VGA Wonder registers at I/O port 0x%04lX.\n", pATI->CPIO_VGAWonder); - if (pATI->Coprocessor != ATI_CHIP_NONE) - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "%s graphics accelerator detected,\n with %d kB of coprocessor" - " memory.\n", - ATIChipNames[pATI->Coprocessor], pATI->VideoRAM); - #endif /* AVOID_CPIO */ xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "%s adapter detected.\n", ATIAdapterNames[pATI->Adapter]); + "ATI Mach64 adapter detected.\n"); if (pATI->Chip >= ATI_CHIP_264GT) xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, @@ -1534,8 +1069,6 @@ ATIPreInit } } -#ifdef AVOID_CPIO - if (!xf86LinearVidMem()) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, @@ -1546,8 +1079,6 @@ ATIPreInit return FALSE; } -#endif /* AVOID_CPIO */ - /* * Set colour weights. */ @@ -1612,14 +1143,6 @@ ATIPreInit /* * Set colour gamma. */ - -#ifndef AVOID_CPIO - - if (pScreenInfo->depth > 1) - -#endif /* AVOID_CPIO */ - - { if (!xf86SetGamma(pScreenInfo, defaultGamma)) { ATILock(pATI); @@ -1627,7 +1150,6 @@ ATIPreInit ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } - } pATI->depth = pScreenInfo->depth; pATI->bitsPerPixel = pScreenInfo->bitsPerPixel; @@ -1638,14 +1160,6 @@ ATIPreInit * Determine which CRT controller to use for video modes. */ -#ifndef AVOID_CPIO - - if ((pATI->Chip >= ATI_CHIP_88800GXC) && - (pATI->depth >= 8) && - (pATI->Chipset == ATI_CHIPSET_ATI)) - -#endif /* AVOID_CPIO */ - { pATI->NewHW.crtc = ATI_CRTC_MACH64; @@ -1654,7 +1168,7 @@ ATIPreInit #ifndef AVOID_CPIO - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) { /* * No need for VGA I/O resources during operating state (but they @@ -1687,42 +1201,6 @@ ATIPreInit } -#ifndef AVOID_CPIO - - else - { - pATI->NewHW.crtc = ATI_CRTC_VGA; - - xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, - "Using VGA CRTC.\n"); - } - - /* Complain if VGA is needed but not there */ - if ((pATI->NewHW.crtc == ATI_CRTC_VGA) || !pATI->OptionLinear) - { - /* VGA is required at this point */ - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "VGA is not available through this adapter.\n"); - ATILock(pATI); - ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); - return FALSE; - } - - if (pATI->Coprocessor != ATI_CHIP_NONE) - { - /* Ignore any 8514/A or Mach8 accelerator from this point on */ - pATI->Adapter = pATI->VGAAdapter; - - /* Accelerator and VGA cannot share memory */ - pATI->VideoRAM = 0; - } - } - -#endif /* AVOID_CPIO */ - /* * Decide between the CRT and the panel. */ @@ -2330,89 +1808,7 @@ ATIPreInit */ pScreenInfo->videoRam = pATI->VideoRAM; -#ifndef AVOID_CPIO - - AcceleratorVideoRAM = pScreenInfo->videoRam; - if (pATI->Chip == ATI_CHIP_VGA) - { - if (pATI->depth <= 4) - VGAVideoRAM = 256; - else - VGAVideoRAM = 64; - - /* For VGA, allow a lower override */ - if ((pGDev->videoRam > 0) && (pGDev->videoRam < VGAVideoRAM)) - VGAVideoRAM = pGDev->videoRam; - } - else if (pATI->CPIO_VGAWonder) - { - /* - * XXX There's an assumption here that the values retrieved are those - * set by BIOS initialisation. - */ - if (pATI->Chip <= ATI_CHIP_18800_1) - { - VGAVideoRAM = - videoRamSizes[GetBits(ATIGetExtReg(0xBBU), 0x20U) + 1]; - if (AcceleratorVideoRAM > 512) - AcceleratorVideoRAM = 512; - } - else - { - IOValue = ATIGetExtReg(0xB0U); - if (IOValue & 0x08U) - VGAVideoRAM = 1024; - else if (IOValue & 0x10U) - VGAVideoRAM = 512; - else - VGAVideoRAM = 256; - if (AcceleratorVideoRAM > 1024) - AcceleratorVideoRAM = 1024; - } - } - - /* Check for hardware limitations */ - if (!AcceleratorVideoRAM) - { - pScreenInfo->videoRam = pATI->VideoRAM = VGAVideoRAM; - - /* - * VGA Wonder V3's, V4's and V5's don't appear to support banking in - * planar modes. - */ - if ((pATI->depth <= 4) && - (pATI->Chip <= ATI_CHIP_18800_1) && - (VGAVideoRAM > 256)) - { - if (pATI->OptionDevel) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "Virtual resolutions requiring more than %s kB\n of video" - " memory might not function properly.\n", - (pATI->depth == 1) ? "64" : "256"); - } - else - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "VideoRAM reduced to 256 kB due to hardware" - " limitations.\n"); - pScreenInfo->videoRam = 256; - } - } - } - else if ((pATI->NewHW.crtc == ATI_CRTC_MACH64) || - (pATI->Chip >= ATI_CHIP_264CT)) - -#endif /* AVOID_CPIO */ - { - -#ifndef AVOID_CPIO - - if (pATI->depth >= 8) - -#endif /* AVOID_CPIO */ - { /* Get adapter's linear aperture configuration */ pATIHW->config_cntl = inr(CONFIG_CNTL); @@ -2437,63 +1833,11 @@ ATIPreInit } } -#ifndef AVOID_CPIO - - /* Except for PCI & AGP, allow for user override */ - if (!pVideo) - { - if (pATI->Chip == ATI_CHIP_88800CX) - IOValue = ~((CARD32)((1 << 23) - 1)); - else if (pATI->Chip >= ATI_CHIP_88800GXE) - IOValue = ~((CARD32)((1 << 24) - 1)); - else if (pATI->VideoRAM >= 4096) - IOValue = ~((CARD32)((1 << 23) - 1)); - else - IOValue = ~((CARD32)((1 << 22) - 1)); - - IOValue &= pGDev->MemBase; - if (IOValue && - (IOValue <= (CARD32)(MaxBits(CFG_MEM_AP_LOC) << 22))) - pATI->LinearBase = IOValue; - - if (!pATI->LinearBase) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Linear aperture not configured. Specify \"MemBase\"" - " override in XF86Config \"Device\" section.\n"); - } - else - { - if (!pATI->LinearSize) - { - if ((pATI->Chip <= ATI_CHIP_88800GXD) && - (pATI->VideoRAM < 4096)) - pATI->LinearSize = 4 * 1024 * 1024; - else - pATI->LinearSize = 8 * 1024 * 1024; - } - - Resources[0].type = ResExcMemBlock | ResBus; - Resources[0].rBegin = pATI->LinearBase; - Resources[0].rEnd = - pATI->LinearBase + pATI->LinearSize - 1; - if (xf86RegisterResources(pATI->iEntity, Resources, - ResNone)) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Unable to register %d MB linear aperture at" - " 0x%08lX.\n", pATI->LinearSize >> 10, - pATI->LinearBase); - - pATI->LinearSize = 0; - } - } - } - -#endif /* AVOID_CPIO */ - if (pATI->LinearBase && pATI->LinearSize) { + int AcceleratorVideoRAM = pATI->LinearSize >> 10; + int ServerVideoRAM = pATI->VideoRAM; + /* * Unless specified in PCI configuration space, set MMIO * address to tail end of linear aperture. @@ -2505,8 +1849,6 @@ ATIPreInit pATI->MMIOInLinear = TRUE; } - AcceleratorVideoRAM = pATI->LinearSize >> 10; - /* * Account for MMIO area at the tail end of the linear * aperture, if it is needed or if it cannot be disabled. @@ -2514,8 +1856,6 @@ ATIPreInit if (pATI->MMIOInLinear || (pATI->Chip < ATI_CHIP_264VTB)) AcceleratorVideoRAM -= 2; - ServerVideoRAM = pATI->VideoRAM; - if (pATI->Cursor > ATI_CURSOR_SOFTWARE) { /* @@ -2535,12 +1875,6 @@ ATIPreInit pATI->CursorBase); } -#ifndef AVOID_CPIO - - if (pATI->OptionLinear) - -#endif /* AVOID_CPIO */ - { CARD32 PageSize = getpagesize() >> 10; @@ -2606,74 +1940,14 @@ ATIPreInit } } -#ifndef AVOID_CPIO - - /* Set up for a banked aperture */ - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - { - pATI->UseSmallApertures = TRUE; - - /* Set banking functions */ - if (pATI->depth <= 4) - { - pATI->NewHW.SetBank = ATIMach64SetBankPlanar; - pATI->BankInfo.SetSourceBank = ATIMach64SetReadPlanar; - pATI->BankInfo.SetDestinationBank = ATIMach64SetWritePlanar; - pATI->BankInfo.SetSourceAndDestinationBanks = - ATIMach64SetReadWritePlanar; - } - else - { - pATI->NewHW.SetBank = ATIMach64SetBankPacked; - pATI->BankInfo.SetSourceBank = ATIMach64SetReadPacked; - pATI->BankInfo.SetDestinationBank = ATIMach64SetWritePacked; - pATI->BankInfo.SetSourceAndDestinationBanks = - ATIMach64SetReadWritePacked; - } - - /* - * Unless specified in PCI configuration space, or at the top of - * of a little-endian linear aperture, set MMIO address to the one - * just above the VGA aperture. This does not work on the CT - * (maybe others). - */ - if (!pATI->Block0Base && - ((pATI->Chip < ATI_CHIP_264CT) || - (pATI->Chip >= ATI_CHIP_264VT) || - pATI->OptionDevel)) - pATI->Block0Base = 0x000BFC00U; - } - - if (!pATI->OptionLinear) - pATI->LinearBase = 0; /* Not needed */ - -#endif /* AVOID_CPIO */ - if (!pATI->LinearBase || !pATI->LinearSize) { - -#ifndef AVOID_CPIO - - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - -#endif /* AVOID_CPIO */ - - { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Linear aperture not available.\n"); ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; - } - -#ifndef AVOID_CPIO - - /* Insurance */ - pATI->LinearBase = pATI->LinearSize = 0; - -#endif /* AVOID_CPIO */ - } if (pATI->Block0Base) @@ -2694,48 +1968,7 @@ ATIPreInit #ifndef AVOID_CPIO - else - /* - * After BIOS initialisation, the accelerator (if any) and the VGA won't - * necessarily agree on the amount of video memory, depending on whether or - * where the memory boundary is configured. Any discrepancy will be - * resolved by ATIModePreInit(). - * - * However, it's possible that there is more video memory than VGA Wonder - * can architecturally handle. - */ - if (((pATI->Chip < ATI_CHIP_68800) || (pATI->Chip > ATI_CHIP_68800AX)) && - (AcceleratorVideoRAM < pScreenInfo->videoRam)) - { - if (pATI->OptionDevel) - { - if (pATI->depth == 1) - AcceleratorVideoRAM /= 4; - - xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "Virtual resolutions requiring more than %d kB\n of video" - " memory might not function correctly.\n", - AcceleratorVideoRAM); - } - else - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "VideoRAM reduced to %d kB due to hardware limitations.\n", - AcceleratorVideoRAM); - - pScreenInfo->videoRam = AcceleratorVideoRAM; - } - } - - if (pATI->OptionLinear) - { - if (!pATI->LinearBase) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Linear aperture not supported in this configuration.\n"); - pATI->OptionLinear = FALSE; - } - else if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) { /* * Free VGA memory aperture during operating state (but it is still @@ -2751,18 +1984,9 @@ ATIPreInit xf86FreeResList(pResources); } } - } #endif /* AVOID_CPIO */ - if ((pATI->Cursor > ATI_CURSOR_SOFTWARE) && !pATI->CursorBase) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Unable to store hardware cursor image. Reverting to software" - " cursor.\n"); - pATI->Cursor = ATI_CURSOR_SOFTWARE; - } - /* * Remap apertures. Must lock and re-unlock around this in case the * remapping fails. @@ -2776,32 +2000,11 @@ ATIPreInit if (pATI->OptionAccel) { - -#ifndef AVOID_CPIO - - if (!pATI->Block0Base || (pATI->NewHW.crtc == ATI_CRTC_VGA)) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Acceleration not supported in this configuration.\n"); - pATI->OptionAccel = FALSE; - } - else - -#endif /* AVOID_CPIO */ - - { xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "MMIO write caching %sabled.\n", pATI->OptionMMIOCache ? "en" : "dis"); - } } -#ifndef AVOID_CPIO - - if (pATI->Adapter >= ATI_ADAPTER_MACH32) - -#endif /* AVOID_CPIO */ - { if (pATI->Chip >= ATI_CHIP_264CT) ATIReportMemory(pScreenInfo, pATI, @@ -2814,20 +2017,6 @@ ATIPreInit ATIMemoryTypeNames_Mach[pATI->MemoryType]); } -#ifndef AVOID_CPIO - - else if (pATI->Adapter >= ATI_ADAPTER_V3) - { - ATIReportMemory(pScreenInfo, pATI, - (ATIGetExtReg(0xB7U) & 0x04U) ? "DRAM" : "VRAM"); - } - else - { - ATIReportMemory(pScreenInfo, pATI, "video memory"); - } - -#endif /* AVOID_CPIO */ - /* * Finish banking setup. This needs to be fixed to not assume the mode on * entry is a VGA mode. XXX @@ -2835,72 +2024,38 @@ ATIPreInit #ifndef AVOID_CPIO - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - -#endif /* AVOID_CPIO */ - + if (!pATI->VGAAdapter) { - pATIHW->crtc = pATI->NewHW.crtc; + pATI->NewHW.SetBank = ATIx8800SetBank; + pATI->NewHW.nPlane = 0; -#ifndef AVOID_CPIO + pATIHW->crtc = pATI->NewHW.crtc; pATIHW->SetBank = (ATIBankProcPtr)NoopDDA; - pATI->BankInfo.BankSize = 0; /* No banking */ - -#endif /* AVOID_CPIO */ - } - -#ifndef AVOID_CPIO - else { + Bool ext_disp_en = (pATI->LockData.crtc_gen_cntl & CRTC_EXT_DISP_EN); + Bool vga_ap_en = (pATI->LockData.config_cntl & CFG_MEM_VGA_AP_EN); + Bool vga_color_256 = (GetReg(SEQX, 0x04U) & 0x08U); + + pATI->NewHW.SetBank = ATIMach64SetBankPacked; + pATI->NewHW.nPlane = 1; + pATIHW->crtc = ATI_CRTC_VGA; -#if 0 /* ___NOT_YET___ */ - if (pATI->ChipHasSUBSYS_CNTL) - { - } - else -#endif - if ((pATI->Chip >= ATI_CHIP_88800GXC) && - (pATI->LockData.crtc_gen_cntl & CRTC_EXT_DISP_EN)) - { - pATIHW->crtc = ATI_CRTC_MACH64; - } - if (pATI->depth <= 4) - { - pATI->BankInfo.nBankDepth = 1; - pATI->NewHW.nPlane = 4; - } - else - { - pATI->BankInfo.nBankDepth = pATI->depth; - pATI->NewHW.nPlane = 1; - } + if (ext_disp_en) + pATIHW->crtc = ATI_CRTC_MACH64; - if ((pATIHW->crtc != ATI_CRTC_VGA) || (GetReg(SEQX, 0x04U) & 0x08U)) + if ((pATIHW->crtc != ATI_CRTC_VGA) || vga_color_256) pATIHW->nPlane = 1; else pATIHW->nPlane = 4; - pATIHW->nBank = ATIDivide(pATI->VideoRAM, - pATIHW->nPlane * pATI->BankInfo.BankSize, 10, 1); - pATI->NewHW.nBank = ATIDivide(pATI->VideoRAM, - pATI->NewHW.nPlane * pATI->BankInfo.BankSize, 10, 1); + /* VideoRAM is a multiple of 512kB and BankSize is 64kB */ + pATIHW->nBank = pATI->VideoRAM / (pATIHW->nPlane * 0x40U); - if (pATI->VGAAdapter == ATI_ADAPTER_VGA) - { - pATIHW->SetBank = pATI->NewHW.SetBank = - (ATIBankProcPtr)NoopDDA; - pATIHW->nBank = pATI->NewHW.nBank = 1; - } - else if (!pATI->UseSmallApertures) - { - pATIHW->SetBank = pATI->NewHW.SetBank; - } - else if ((pATIHW->crtc == ATI_CRTC_VGA) && - !(pATI->LockData.config_cntl & CFG_MEM_VGA_AP_EN)) + if ((pATIHW->crtc == ATI_CRTC_VGA) && !vga_ap_en) { pATIHW->SetBank = (ATIBankProcPtr)NoopDDA; pATIHW->nBank = 1; @@ -2913,10 +2068,12 @@ ATIPreInit { pATIHW->SetBank = ATIMach64SetBankPlanar; } + } - if (((ApertureSize * pATI->depth) / pATI->BankInfo.nBankDepth) >= - (unsigned)(pScreenInfo->videoRam * 1024)) - pATI->BankInfo.BankSize = 0; /* No banking */ +#else /* AVOID_CPIO */ + + { + pATIHW->crtc = pATI->NewHW.crtc; } #endif /* AVOID_CPIO */ @@ -2925,24 +2082,6 @@ ATIPreInit { /* Until ShadowFB becomes a true screen wrapper, if it ever does... */ -#ifndef AVOID_CPIO - - if (pATI->BankInfo.BankSize) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Cannot shadow a banked frame buffer.\n"); - pATI->OptionShadowFB = FALSE; - } - else if (pATI->depth < 8) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Cannot shadow a planar frame buffer.\n"); - pATI->OptionShadowFB = FALSE; - } - else - -#endif /* AVOID_CPIO */ - if (pATI->OptionAccel) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, @@ -2982,8 +2121,6 @@ ATIPreInit */ if (pATI->ProgrammableClock == ATI_CLOCK_INTERNAL) Numerator <<= 1; - else if (pATI->depth > 8) - Denominator *= (pATI->bitsPerPixel / 8); ATIClockRange.maxClock = (Numerator / (Denominator * 1000)) * 1000; @@ -3004,25 +2141,12 @@ ATIPreInit Denominator = pATI->ClockDescriptor.MinM * pATI->XCLKReferenceDivider * pATI->ReferenceDenominator; -#ifndef AVOID_CPIO - - if (pATI->depth >= 8) - -#endif /* AVOID_CPIO */ - { Denominator *= pATI->bitsPerPixel / 4; } i = (6 - 2) - pATI->XCLKPostDivider; -#ifndef AVOID_CPIO - - if (pATI->NewHW.crtc == ATI_CRTC_VGA) - i--; - -#endif /* AVOID_CPIO */ - i = (ATIDivide(Numerator, Denominator, i, -1) / 1000) * 1000; if (i < ATIClockRange.maxClock) ATIClockRange.maxClock = i; @@ -3094,17 +2218,6 @@ ATIPreInit case ATI_DAC_IBMRGB514: pATI->maxClock = 220000; - -#ifndef AVOID_CPIO - - if (pATI->NewHW.crtc == ATI_CRTC_VGA) - { - DefaultmaxClock = 100000; - } - else - -#endif /* AVOID_CPIO */ - { DefaultmaxClock = 220000; } @@ -3114,19 +2227,7 @@ ATIPreInit #ifndef AVOID_CPIO - /* - * 80 MHz is too high in some cases. Limit 18800-x's to 40 - * MHz. Don't exceed the memory clock on VGA Wonder capables - * with less than 1 MB, if using a packed mode. - */ - if ((pATI->Chip == ATI_CHIP_18800) || - (pATI->Chip == ATI_CHIP_18800_1)) - { - DefaultmaxClock = 40000; - } - else if (pATI->CPIO_VGAWonder && - (pATI->VideoRAM < 1024) && - (pATI->depth >= 8)) + if (pATI->CPIO_VGAWonder && (pATI->VideoRAM < 1024)) { DefaultmaxClock = (GetBits(BIOSByte(0x44U), 0x04U) * 5000) + 40000; @@ -3146,50 +2247,31 @@ ATIPreInit ATIClockRange.maxClock = DefaultmaxClock; } - if (pATI->ClockDescriptor.MaxN <= 0) - { - ATIClockRange.maxClock = DefaultmaxClock; - xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, - "Maximum pixel clock: %.3f MHz.\n", - (double)ATIClockRange.maxClock / 1000.0); - } - /* * Determine available pixel clock frequencies. */ - ATIClockPreInit(pScreenInfo, pATI, pGDev, &ATIClockRange); - if (pATI->ProgrammableClock > ATI_CLOCK_FIXED) - Strategy = LOOKUP_BEST_REFRESH; + if ((pATI->ProgrammableClock <= ATI_CLOCK_FIXED) || + (pATI->ProgrammableClock >= ATI_CLOCK_MAX)) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Unsupported or non-programmable clock generator.\n"); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } + + ATIClockPreInit(pScreenInfo, pATI); + Strategy = LOOKUP_BEST_REFRESH; /* * Mode validation. */ -#ifdef AVOID_CPIO - if (pATI->Chip >= ATI_CHIP_264CT) { minPitch = 8; } - -#else /* AVOID_CPIO */ - - if ((pATI->depth >= 8) && (pATI->Chip >= ATI_CHIP_264CT)) - { - minPitch = 8; - } - else if (pATI->CPIO_VGAWonder && - (pATI->Chip <= ATI_CHIP_18800_1) && - (pATI->VideoRAM == 256) && - (pATI->depth >= 8)) - { - minPitch = 32; /* Very strange, but true */ - maxPitch = 0x3FU; - } - -#endif /* AVOID_CPIO */ - else { minPitch = 16; @@ -3197,65 +2279,11 @@ ATIPreInit pATI->pitchInc = minPitch; -#ifndef AVOID_CPIO - - if (pATI->depth >= 8) - -#endif /* AVOID_CPIO */ - { pATI->pitchInc *= pATI->bitsPerPixel; } - switch (pATI->NewHW.crtc) { - -#ifndef AVOID_CPIO - - case ATI_CRTC_VGA: - /* - * IBM's VGA doesn't allow for interlaced modes. - */ - if (pATI->Adapter <= ATI_ADAPTER_VGA) - ATIClockRange.interlaceAllowed = FALSE; - - pScreenInfo->maxHValue = (0xFFU + 1) << 3; /* max HTotal */ - - /* - * The maximum VTotal value set here applies to all modes, - * including interlaced, doublescanned or multiscanned modes. - * Finer-grained checks are done in ATIValidateMode(). - */ - pScreenInfo->maxVValue = 0x03FFU + 1; - if (pATI->Adapter > ATI_ADAPTER_VGA) - { - pScreenInfo->maxVValue <<= 1; - if (ATIClockRange.interlaceAllowed && - (pATI->Chip < ATI_CHIP_264CT)) - pScreenInfo->maxVValue <<= 1; - } - - /* - * 18800-x and 28800-x do not support interlaced modes when the - * scanline pitch is 2048 pixels or more. For 18800-x's with 256 - * kB of video memory, the limit for 8bpp is 1024. - */ - if (ATIClockRange.interlaceAllowed && - (pATI->Chip <= ATI_CHIP_28800_6)) - { - if (minPitch == 32) - pATI->MaximumInterlacedPitch = 0x1FU * 32; - else - pATI->MaximumInterlacedPitch = 0x7FU * minPitch; - } - - Strategy |= LOOKUP_CLKDIV2; - - break; - -#endif /* AVOID_CPIO */ - - case ATI_CRTC_MACH64: pScreenInfo->maxHValue = (MaxBits(CRTC_H_TOTAL) + 1) << 3; if (pATI->Chip < ATI_CHIP_264VT) @@ -3275,11 +2303,6 @@ ATIPreInit pScreenInfo->maxVValue = MaxBits(CRTC_V_TOTAL) + 1; maxPitch = MaxBits(CRTC_PITCH); - - break; - - default: - break; } maxPitch *= minPitch; @@ -3499,7 +2522,7 @@ ATIPreInit ATII2CPreInit(pScreenInfo, pATI); if (!pScreenInfo->chipset || !*pScreenInfo->chipset) - pScreenInfo->chipset = (char *)ATIChipsetNames[0]; + pScreenInfo->chipset = "mach64"; ATILock(pATI); ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); diff --git a/src/atiprint.c b/src/atiprint.c index 11cf6b7..243dcf5 100644 --- a/src/atiprint.c +++ b/src/atiprint.c @@ -28,7 +28,6 @@ #include <ctype.h> #include "ati.h" -#include "atiadapter.h" #include "atichip.h" #include "atidac.h" #include "atimach64io.h" @@ -365,11 +364,11 @@ ATIPrintRegisters #ifndef AVOID_CPIO - CARD8 genmo, seq1 = 0; + CARD8 genmo; crtc = ATI_CRTC_VGA; - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) { xf86ErrorFVerb(4, "\n Miscellaneous output register value: 0x%02X.\n", genmo = inb(R_GENMO)); @@ -469,36 +468,10 @@ ATIPrintRegisters ATIPrintIndexedRegisters(SEQX, 0, 8, "Sequencer", 0); if (pATI->CPIO_VGAWonder) - ATIPrintIndexedRegisters(pATI->CPIO_VGAWonder, - xf86ServerIsOnlyProbing() ? 0x80U : pATI->VGAOffset, 0xC0U, + ATIPrintIndexedRegisters(pATI->CPIO_VGAWonder, 0x80U, 0xC0U, "ATI extended VGA", 0); } - if (pATI->ChipHasSUBSYS_CNTL) - { - xf86ErrorFVerb(4, "\n 8514/A register values:"); - for (Index = 0x02E8U; Index <= 0x0FEE8; Index += 0x0400U) - { - if (!((Index - 0x02E8U) & 0x0C00U)) - xf86ErrorFVerb(4, "\n 0x%04X: ", Index); - xf86ErrorFVerb(4, " %04X", inw(Index)); - } - - if (pATI->Adapter >= ATI_ADAPTER_MACH8) - { - xf86ErrorFVerb(4, "\n\n Mach8/Mach32 register values:"); - for (Index = 0x02EEU; Index <= 0x0FEEE; Index += 0x0400U) - { - if (!((Index - 0x02EEU) & 0x0C00U)) - xf86ErrorFVerb(4, "\n 0x%04X: ", Index); - xf86ErrorFVerb(4, " %04X", inw(Index)); - } - } - - xf86ErrorFVerb(4, "\n"); - } - else - #endif /* AVOID_CPIO */ if (pATI->Chip == ATI_CHIP_264LT) @@ -565,13 +538,6 @@ ATIPrintRegisters xf86ErrorFVerb(4, "\n"); } else - -#ifndef AVOID_CPIO - - if (pATI->Chip >= ATI_CHIP_88800GXC) - -#endif /* AVOID_CPIO */ - { #ifdef AVOID_CPIO @@ -634,14 +600,6 @@ ATIPrintRegisters ATISetDACIOPorts(pATI, crtc); - /* Temporarily turn off CLKDIV2 while reading DAC's LUT */ - if (pATI->Adapter == ATI_ADAPTER_NONISA) - { - seq1 = GetReg(SEQX, 0x01U); - if (seq1 & 0x08U) - PutReg(SEQX, 0x01U, seq1 & ~0x08U); - } - dac_read = inb(pATI->CPIO_DAC_READ); DACDelay; dac_write = inb(pATI->CPIO_DAC_WRITE); @@ -678,9 +636,6 @@ ATIPrintRegisters outb(pATI->CPIO_DAC_READ, dac_read); DACDelay; - if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (seq1 & 0x08U)) - PutReg(SEQX, 0x01U, seq1); - #endif /* AVOID_CPIO */ if ((pVideo = pATI->PCIInfo)) diff --git a/src/atiprobe.c b/src/atiprobe.c index 9c30a31..e869bf0 100644 --- a/src/atiprobe.c +++ b/src/atiprobe.c @@ -28,7 +28,6 @@ #include <stdio.h> #include "ati.h" -#include "atiadapter.h" #include "atiadjust.h" #include "atibus.h" #include "atichip.h" @@ -50,228 +49,9 @@ #include "r128_probe.h" #include "r128_version.h" -/* - * NOTES: - * - * - The driver private structures (ATIRec's) are allocated here, rather than - * in ATIPreInit(). This allows ATIProbe() to pass information to later - * stages. - * - A minor point, perhaps, is that XF86Config Chipset names denote functional - * levels, rather than specific graphics controller chips. - * - ATIProbe() does not call xf86MatchPciInstances(), because ATIProbe() - * should be able to match a mix of PCI and non-PCI devices to XF86Config - * Device sections. Also, PCI configuration space for Mach32's is to be - * largely ignored. - */ - -/* Used as a temporary buffer */ -#define Identifier ((char *)(pATI->MMIOCache)) - -/* - * An internal structure definition to facilitate the matching of detected - * adapters to XF86Config Device sections. - */ -typedef struct _ATIGDev -{ - GDevPtr pGDev; - int iATIPtr; - CARD8 Chipset; -} ATIGDev, *ATIGDevPtr; - #ifndef AVOID_CPIO /* - * Definitions for I/O conflict avoidance. - */ -#define LongPort(_Port) GetBits(_Port, PCIGETIO(SPARSE_IO_BASE)) -#define DetectedVGA (1 << 0) -#define Detected8514A (1 << 1) -#define DetectedMach64 (1 << 2) -#define Allowed (1 << 3) -#define DoProbe (1 << 4) -typedef struct -{ - IOADDRESS Base; - CARD8 Size; - CARD8 Flag; -} PortRec, *PortPtr; - -/* - * ATIScanPCIBases -- - * - * This function loops though a device's PCI registered bases and accumulates - * a list of block I/O bases in use in the system. - */ -static void -ATIScanPCIBases -( - PortPtr *PCIPorts, - int *nPCIPort, - const CARD32 *pBase, - const int *pSize, - const CARD8 ProbeFlag -) -{ - IOADDRESS Base; - int i, j; - - for (i = 6; --i >= 0; pBase++, pSize++) - { - if (*pBase & PCI_MAP_IO) - { - Base = *pBase & ~IO_BYTE_SELECT; - for (j = 0; ; j++) - { - if (j >= *nPCIPort) - { - (*nPCIPort)++; - *PCIPorts = (PortPtr)xnfrealloc(*PCIPorts, - *nPCIPort * SizeOf(PortRec)); - (*PCIPorts)[j].Base = Base; - (*PCIPorts)[j].Size = (CARD8)*pSize; - (*PCIPorts)[j].Flag = ProbeFlag; - break; - } - - if (Base == (*PCIPorts)[j].Base) - break; - } - - continue; - } - - /* Allow for 64-bit addresses */ - if (!PCI_MAP_IS64BITMEM(*pBase)) - continue; - - i--; - pBase++; - pSize++; - } -} - -/* - * ATICheckSparseIOBases -- - * - * This function checks whether a sparse I/O base can safely be probed. - */ -static CARD8 -ATICheckSparseIOBases -( - pciVideoPtr pVideo, - CARD8 *ProbeFlags, - const IOADDRESS IOBase, - const int Count, - const Bool Override -) -{ - CARD32 FirstPort, LastPort; - - if (!pVideo || !xf86IsPrimaryPci(pVideo)) - { - FirstPort = LongPort(IOBase); - LastPort = LongPort(IOBase + Count - 1); - - for (; FirstPort <= LastPort; FirstPort++) - { - CARD8 ProbeFlag = ProbeFlags[FirstPort]; - - if (ProbeFlag & DoProbe) - continue; - - if (!(ProbeFlag & Allowed)) - return ProbeFlag; - - if (Override) - continue; - - /* User might wish to override this decision */ - xf86Msg(X_WARNING, - ATI_NAME ": Sparse I/O base 0x%04lX not probed.\n", IOBase); - return Allowed; - } - } - - return DoProbe; -} - -#ifndef AVOID_NON_PCI - -/* - * ATIClaimSparseIOBases -- - * - * This function updates the sparse I/O base table with information from the - * hardware probes. - */ -static void -ATIClaimSparseIOBases -( - CARD8 *ProbeFlags, - const IOADDRESS IOBase, - const int Count, - const CARD8 ProbeFlag -) -{ - CARD32 FirstPort = LongPort(IOBase), - LastPort = LongPort(IOBase + Count - 1); - - for (; FirstPort <= LastPort; FirstPort++) - ProbeFlags[FirstPort] = ProbeFlag; -} - -#endif /* AVOID_NON_PCI */ - -/* - * ATIVGAProbe -- - * - * This function looks for an IBM standard VGA, or clone, and sets - * pATI->VGAAdapter if one is found. - */ -static ATIPtr -ATIVGAProbe -( - ATIPtr pVGA -) -{ - CARD8 IOValue1, IOValue2, IOValue3; - - if (!pVGA) - pVGA = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - - /* - * VGA has one more attribute register than EGA. See if it can be read and - * written. Note that the CRTC registers are not used here, so there's no - * need to unlock them. - */ - ATISetVGAIOBase(pVGA, inb(R_GENMO)); - (void)inb(GENS1(pVGA->CPIO_VGABase)); - IOValue1 = inb(ATTRX); - (void)inb(GENS1(pVGA->CPIO_VGABase)); - IOValue2 = GetReg(ATTRX, 0x14U | 0x20U); - outb(ATTRX, IOValue2 ^ 0x0FU); - IOValue3 = GetReg(ATTRX, 0x14U | 0x20U); - outb(ATTRX, IOValue2); - outb(ATTRX, IOValue1); - (void)inb(GENS1(pVGA->CPIO_VGABase)); - if (IOValue3 == (IOValue2 ^ 0x0FU)) - { - /* VGA device detected */ - if (pVGA->Chip == ATI_CHIP_NONE) - pVGA->Chip = ATI_CHIP_VGA; - if (pVGA->VGAAdapter == ATI_ADAPTER_NONE) - pVGA->VGAAdapter = ATI_ADAPTER_VGA; - if (pVGA->Adapter == ATI_ADAPTER_NONE) - pVGA->Adapter = ATI_ADAPTER_VGA; - } - else - { - pVGA->VGAAdapter = ATI_ADAPTER_NONE; - } - - return pVGA; -} - -/* * ATIVGAWonderProbe -- * * This function determines if ATI extended VGA registers can be accessed @@ -282,50 +62,29 @@ static void ATIVGAWonderProbe ( pciVideoPtr pVideo, - ATIPtr pATI, - ATIPtr p8514, - CARD8 *ProbeFlags + ATIPtr pATI ) { CARD8 IOValue1, IOValue2, IOValue3, IOValue4, IOValue5, IOValue6; - switch (ATICheckSparseIOBases(pVideo, ProbeFlags, - pATI->CPIO_VGAWonder, 2, TRUE)) - { - case 0: - xf86Msg(X_WARNING, - ATI_NAME ": Expected VGA Wonder capability could not be" - " detected at I/O port 0x%04lX because it would conflict with" - " a non-video PCI/AGP device.\n", pATI->CPIO_VGAWonder); - pATI->CPIO_VGAWonder = 0; - break; - - case Detected8514A: - xf86Msg(X_WARNING, - ATI_NAME ": Expected VGA Wonder capability could not be" - " detected at I/O port 0x%04lX because it would conflict with" - " a %s %s.\n", pATI->CPIO_VGAWonder, - ATIBusNames[p8514->BusType], ATIAdapterNames[p8514->Adapter]); - pATI->CPIO_VGAWonder = 0; - break; - - case DetectedMach64: - xf86Msg(X_WARNING, - ATI_NAME ": Expected VGA Wonder capability could not be" - " detected at I/O port 0x%04lX because it would conflict with" - " a Mach64.\n", pATI->CPIO_VGAWonder); - pATI->CPIO_VGAWonder = 0; - break; - - case DetectedVGA: - default: /* Must be DoProbe */ + if (!pATI->OptionProbeSparse) + { + xf86Msg(X_WARNING, + ATI_NAME ": Expected VGA Wonder capability at I/O port" + " 0x%04lX will not be probed\n" + "set option \"probe_sparse\" to force probing.\n", + pATI->CPIO_VGAWonder); + + pATI->CPIO_VGAWonder = 0; + return; + } + if (pVideo && !xf86IsPrimaryPci(pVideo) && (pATI->Chip <= ATI_CHIP_88800GXD)) { /* Set up extended VGA register addressing */ PutReg(GRAX, 0x50U, GetByte(pATI->CPIO_VGAWonder, 0)); - PutReg(GRAX, 0x51U, - GetByte(pATI->CPIO_VGAWonder, 1) | pATI->VGAOffset); + PutReg(GRAX, 0x51U, GetByte(pATI->CPIO_VGAWonder, 1) | 0x80U); } /* * Register 0xBB is used by the BIOS to keep track of various @@ -341,10 +100,7 @@ ATIVGAWonderProbe ATIPutExtReg(0xBBU, IOValue3 ^ 0x55U); IOValue5 = ATIGetExtReg(0xBBU); ATIPutExtReg(0xBBU, IOValue3); - if (pATI->Chip <= ATI_CHIP_18800_1) - IOValue6 = 0; - else - IOValue6 = ATIGetExtReg(0xBCU); + IOValue6 = ATIGetExtReg(0xBCU); ATIPutExtReg(IOValue1, IOValue2); if ((IOValue4 == (IOValue3 ^ 0xAAU)) && @@ -362,151 +118,6 @@ ATIVGAWonderProbe " 0x%04lX was not detected.\n", pATI->CPIO_VGAWonder); pATI->CPIO_VGAWonder = 0; } - break; - } -} - -/* - * ATI8514Probe -- - * - * This function looks for an 8514/A compatible and returns an ATIRec if one is - * found. The function also determines whether or not the detected 8514/A - * compatible device is actually a Mach8 or Mach32, and sets pATI->Adapter - * accordingly. - */ -static ATIPtr -ATI8514Probe -( - pciVideoPtr pVideo -) -{ - ATIPtr pATI = NULL; - CARD16 IOValue1, IOValue2; - - /* - * Save register value to be modified, just in case there is no 8514/A - * compatible accelerator. Note that, in more ways than one, - * SUBSYS_STAT == SUBSYS_CNTL. - */ - IOValue1 = inw(SUBSYS_STAT); - IOValue2 = IOValue1 & _8PLANE; - - /* Reset any 8514/A compatible adapter that might be present */ - outw(SUBSYS_CNTL, IOValue2 | (GPCTRL_RESET | CHPTEST_NORMAL)); - outw(SUBSYS_CNTL, IOValue2 | (GPCTRL_ENAB | CHPTEST_NORMAL | - RVBLNKFLG | RPICKFLAG | RINVALIDIO | RGPIDLE)); - - /* Probe for an 8514/A compatible */ - IOValue2 = inw(ERR_TERM); - outw(ERR_TERM, 0x5A5AU); - ProbeWaitIdleEmpty(); - if (inw(ERR_TERM) == 0x5A5AU) - { - outw(ERR_TERM, 0x2525U); - if (inw(ERR_TERM) == 0x2525U) - { - pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - pATI->Adapter = ATI_ADAPTER_8514A; - pATI->ChipHasSUBSYS_CNTL = TRUE; - pATI->PCIInfo = pVideo; - } - } - outw(ERR_TERM, IOValue2); - - /* Restore register value clobbered by 8514/A reset attempt */ - if (!pATI) - { - outw(SUBSYS_CNTL, IOValue1); - return NULL; - } - - /* Ensure any Mach8 or Mach32 is not in 8514/A emulation mode */ - IOValue1 = inw(CLOCK_SEL); - outw(CLOCK_SEL, IOValue1); - ProbeWaitIdleEmpty(); - - IOValue1 = IOValue2 = inw(ROM_ADDR_1); - outw(ROM_ADDR_1, 0x5555U); - ProbeWaitIdleEmpty(); - if (inw(ROM_ADDR_1) == 0x5555U) - { - outw(ROM_ADDR_1, 0x2A2AU); - ProbeWaitIdleEmpty(); - if (inw(ROM_ADDR_1) == 0x2A2AU) - pATI->Adapter = ATI_ADAPTER_MACH8; - } - outw(ROM_ADDR_1, IOValue1); - - if (pATI->Adapter == ATI_ADAPTER_MACH8) - { - /* A Mach8 or Mach32 has been detected */ - IOValue1 = inw(READ_SRC_X); - outw(DESTX_DIASTP, 0xAAAAU); - ProbeWaitIdleEmpty(); - if (inw(READ_SRC_X) == 0x02AAU) - pATI->Adapter = ATI_ADAPTER_MACH32; - - outw(DESTX_DIASTP, 0x5555U); - ProbeWaitIdleEmpty(); - if (inw(READ_SRC_X) == 0x0555U) - { - if (pATI->Adapter != ATI_ADAPTER_MACH32) - pATI->Adapter = ATI_ADAPTER_8514A; - } - else - { - if (pATI->Adapter != ATI_ADAPTER_MACH8) - pATI->Adapter = ATI_ADAPTER_8514A; - } - outw(DESTX_DIASTP, IOValue1); - } - - switch (pATI->Adapter) - { - case ATI_ADAPTER_8514A: - pATI->Coprocessor = ATI_CHIP_8514A; - IOValue1 = inb(EXT_CONFIG_3); - outb(EXT_CONFIG_3, IOValue1 & 0x0FU); - if (!(inb(EXT_CONFIG_3) & 0xF0U)) - { - outb(EXT_CONFIG_3, IOValue1 | 0xF0U); - if ((inb(EXT_CONFIG_3) & 0xF0U) == 0xF0U) - pATI->Coprocessor = ATI_CHIP_CT480; - } - outb(EXT_CONFIG_3, IOValue1); - break; - - case ATI_ADAPTER_MACH8: - pATI->Coprocessor = ATI_CHIP_38800_1; - if (inw(CONFIG_STATUS_1) & MC_BUS) - pATI->BusType = ATI_BUS_MCA16; - break; - - case ATI_ADAPTER_MACH32: - IOValue1 = inw(CONFIG_STATUS_1); - pATI->BusType = GetBits(IOValue1, BUS_TYPE); - pATI->BIOSBase = 0x000C0000U + - (GetBits(IOValue2, BIOS_BASE_SEGMENT) << 11); - if (!(IOValue1 & (_8514_ONLY | CHIP_DIS))) - { - pATI->VGAAdapter = ATI_ADAPTER_MACH32; - if ((xf86ReadBIOS(pATI->BIOSBase, 0x10U, - (pointer)(&pATI->CPIO_VGAWonder), - SizeOf(pATI->CPIO_VGAWonder)) < - SizeOf(pATI->CPIO_VGAWonder)) || - !(pATI->CPIO_VGAWonder &= SPARSE_IO_PORT)) - pATI->CPIO_VGAWonder = 0x01CEU; - pATI->VGAOffset = 0x80U; - } - - ATIMach32ChipID(pATI); - break; - - default: - break; - } - - return pATI; } #endif /* AVOID_CPIO */ @@ -526,6 +137,7 @@ ATIMach64Detect ) { CARD32 IOValue, bus_cntl, gen_test_cntl; + Bool DetectSuccess = FALSE; (void)ATIMapApertures(-1, pATI); /* Ignore errors */ @@ -575,7 +187,7 @@ ATIMach64Detect ATIMach64ChipID(pATI, ChipType); if ((pATI->Chip != ATI_CHIP_Mach64) || (pATI->CPIODecoding == BLOCK_IO)) - pATI->Adapter = ATI_ADAPTER_MACH64; + DetectSuccess = TRUE; } } @@ -583,7 +195,7 @@ ATIMach64Detect outr(SCRATCH_REG0, IOValue); /* If no Mach64 was detected, return now */ - if (pATI->Adapter != ATI_ADAPTER_MACH64) + if (!DetectSuccess) { outr(GEN_TEST_CNTL, gen_test_cntl); outr(BUS_CNTL, bus_cntl); @@ -596,7 +208,6 @@ ATIMach64Detect (GetBits(inr(SCRATCH_REG1), BIOS_BASE_SEGMENT) << 11); ATIUnmapApertures(-1, pATI); - pATI->PCIInfo = NULL; return TRUE; } @@ -611,22 +222,12 @@ ATIMach64Detect static ATIPtr ATIMach64Probe ( + ATIPtr pATI, pciVideoPtr pVideo, - const IOADDRESS IOBase, - const CARD8 IODecoding, const ATIChipType Chip ) { - ATIPtr pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - CARD16 ChipType = 0; - - pATI->CPIOBase = IOBase; - pATI->CPIODecoding = IODecoding; - - if (pVideo) - { - pATI->PCIInfo = pVideo; - ChipType = pVideo->chipType; + CARD16 ChipType = pVideo->chipType; /* * Probe through auxiliary MMIO aperture if one exists. Because such @@ -656,7 +257,6 @@ ATIMach64Probe if (ATIMach64Detect(pATI, ChipType, Chip)) return pATI; } - } /* * A last, perhaps desparate, probe attempt. Note that if this succeeds, @@ -669,7 +269,6 @@ LastProbe: if (ATIMach64Detect(pATI, ChipType, Chip)) return pATI; - xfree(pATI); return NULL; } @@ -681,40 +280,24 @@ LastProbe: * This function looks for a Mach64 at a particular PIO address and returns an * ATIRec if one is found. */ -static ATIPtr +ATIPtr ATIMach64Probe ( + ATIPtr pATI, pciVideoPtr pVideo, - const IOADDRESS IOBase, - const CARD8 IODecoding, const ATIChipType Chip ) { - ATIPtr pATI; CARD32 IOValue; - CARD16 ChipType = 0; - - if (!IOBase) - return NULL; + CARD16 ChipType = pVideo->chipType; - if (pVideo) - { - if ((IODecoding == BLOCK_IO) && + if ((pATI->CPIODecoding == BLOCK_IO) && ((pVideo->size[1] < 8) || - (IOBase >= (CARD32)(-1 << pVideo->size[1])))) + (pATI->CPIOBase >= (CARD32)(-1 << pVideo->size[1])))) return NULL; - ChipType = pVideo->chipType; - } - - pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - pATI->CPIOBase = IOBase; - pATI->CPIODecoding = IODecoding; - pATI->PCIInfo = pVideo; - if (!ATIMach64Detect(pATI, ChipType, Chip)) { - xfree(pATI); return NULL; } @@ -724,7 +307,7 @@ ATIMach64Probe */ if (pATI->Chip >= ATI_CHIP_264CT) { - pATI->VGAAdapter = ATI_ADAPTER_MACH64; + pATI->VGAAdapter = TRUE; } else { @@ -735,153 +318,24 @@ ATIMach64Probe IOValue |= CFG_VGA_EN; if (IOValue == (CFG_VGA_EN | CFG_CHIP_EN)) { - pATI->VGAAdapter = ATI_ADAPTER_MACH64; + pATI->VGAAdapter = TRUE; pATI->CPIO_VGAWonder = 0x01CEU; - pATI->VGAOffset = 0x80U; } } return pATI; } -/* - * ATIAssignVGA -- - * - * This function is called to associate a VGA interface with an accelerator. - * This is done by temporarily configuring the accelerator to route VGA RAMDAC - * I/O through the accelerator's RAMDAC. A value is then written through the - * VGA DAC ports and a check is made to see if the same value shows up on the - * accelerator side. - */ static void ATIAssignVGA ( pciVideoPtr pVideo, - ATIPtr *ppVGA, - ATIPtr pATI, - ATIPtr p8514, - CARD8 *ProbeFlags + ATIPtr pATI ) { - ATIPtr pVGA = *ppVGA; - CARD8 OldDACMask; - - /* Assume unassignable VGA */ - pATI->VGAAdapter = ATI_ADAPTER_NONE; - - /* If no assignable VGA, return now */ - if ((pATI != pVGA) && (!pVGA || (pVGA->Adapter > ATI_ADAPTER_VGA))) - return; - - switch (pATI->Adapter) - { - case ATI_ADAPTER_8514A: - { - /* - * Assumption: Bit DISABPASSTHRU in ADVFUNC_CNTL is already - * off. - */ - OldDACMask = inb(VGA_DAC_MASK); - - if (inb(IBM_DAC_MASK) == OldDACMask) - { - outb(VGA_DAC_MASK, 0xA5U); - if (inb(IBM_DAC_MASK) == 0xA5U) - pATI->VGAAdapter = ATI_ADAPTER_VGA; - outb(VGA_DAC_MASK, OldDACMask); - } - } - break; - - case ATI_ADAPTER_MACH8: - { - CARD16 ClockSel = inw(CLOCK_SEL); - - if (ClockSel & DISABPASSTHRU) - outw(CLOCK_SEL, ClockSel & ~DISABPASSTHRU); - - ProbeWaitIdleEmpty(); - - OldDACMask = inb(VGA_DAC_MASK); - - if (inb(IBM_DAC_MASK) == OldDACMask) - { - outb(VGA_DAC_MASK, 0xA5U); - if (inb(IBM_DAC_MASK) == 0xA5U) - pATI->VGAAdapter = ATI_ADAPTER_VGA; - outb(VGA_DAC_MASK, OldDACMask); - } - - if (ClockSel & DISABPASSTHRU) - outw(CLOCK_SEL, ClockSel); - } - break; - - case ATI_ADAPTER_MACH32: - { - CARD16 ClockSel = inw(CLOCK_SEL), - MiscOptions = inw(MISC_OPTIONS); - - if (ClockSel & DISABPASSTHRU) - outw(CLOCK_SEL, ClockSel & ~DISABPASSTHRU); - if (MiscOptions & (DISABLE_VGA | DISABLE_DAC)) - outw(MISC_OPTIONS, - MiscOptions & ~(DISABLE_VGA | DISABLE_DAC)); - - ProbeWaitIdleEmpty(); - - OldDACMask = inb(VGA_DAC_MASK); - - if (inb(IBM_DAC_MASK) == OldDACMask) - { - outb(VGA_DAC_MASK, 0xA5U); - if (inb(IBM_DAC_MASK) == 0xA5U) - pATI->VGAAdapter = ATI_ADAPTER_MACH32; - outb(VGA_DAC_MASK, OldDACMask); - } - - if (ClockSel & DISABPASSTHRU) - outw(CLOCK_SEL, ClockSel); - if (MiscOptions & (DISABLE_VGA | DISABLE_DAC)) - outw(MISC_OPTIONS, MiscOptions); - } - break; - - case ATI_ADAPTER_MACH64: - { - CARD32 DACCntl = inr(DAC_CNTL); - - if (!(DACCntl & DAC_VGA_ADR_EN)) - outr(DAC_CNTL, DACCntl | DAC_VGA_ADR_EN); - - OldDACMask = inb(VGA_DAC_MASK); - - if (in8(M64_DAC_MASK) == OldDACMask) - { - outb(VGA_DAC_MASK, 0xA5U); - if (in8(M64_DAC_MASK) == 0xA5U) - pATI->VGAAdapter = ATI_ADAPTER_MACH64; - outb(VGA_DAC_MASK, OldDACMask); - } - - if (!(DACCntl & DAC_VGA_ADR_EN)) - outr(DAC_CNTL, DACCntl); - } - break; - - default: - break; - } - - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - { - pATI->CPIO_VGAWonder = 0; - return; - } - if (pATI->CPIO_VGAWonder) { - ATIVGAWonderProbe(pVideo, pATI, p8514, ProbeFlags); + ATIVGAWonderProbe(pVideo, pATI); if (!pATI->CPIO_VGAWonder) { /* @@ -891,55 +345,11 @@ ATIAssignVGA * of I/O through the bus tree. */ pATI->CPIO_VGAWonder = GRAX; - ATIVGAWonderProbe(pVideo, pATI, p8514, ProbeFlags); + ATIVGAWonderProbe(pVideo, pATI); } } - - if (pATI == pVGA) - { - pATI->SharedVGA = TRUE; - return; - } - - /* Assign the VGA to this adapter */ - xfree(pVGA); - *ppVGA = pATI; - - xf86MsgVerb(X_INFO, 3, ATI_NAME ": VGA assigned to this adapter.\n"); -} - -#ifndef AVOID_NON_PCI - -/* - * ATIClaimVGA -- - * - * Attempt to assign a non-shareable VGA to an accelerator. If successful, - * update ProbeFlags array. - */ -static void -ATIClaimVGA -( - pciVideoPtr pVideo, - ATIPtr *ppVGA, - ATIPtr pATI, - ATIPtr p8514, - CARD8 *ProbeFlags, - int Detected -) -{ - ATIAssignVGA(pVideo, ppVGA, pATI, p8514, ProbeFlags); - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - return; - - ATIClaimSparseIOBases(ProbeFlags, MonochromeIOBase, 48, Detected); - if (!pATI->CPIO_VGAWonder) - return; - - ATIClaimSparseIOBases(ProbeFlags, pATI->CPIO_VGAWonder, 2, Detected); } -#endif /* AVOID_NON_PCI */ - /* * ATIFindVGA -- * @@ -950,16 +360,9 @@ static void ATIFindVGA ( pciVideoPtr pVideo, - ATIPtr *ppVGA, - ATIPtr *ppATI, - ATIPtr p8514, - CARD8 *ProbeFlags + ATIPtr pATI ) { - ATIPtr pATI = *ppATI; - - if (!*ppVGA) - { /* * An ATI PCI adapter has been detected at this point, and its VGA, if * any, is shareable. Ensure the VGA isn't in sleep mode. @@ -968,1330 +371,290 @@ ATIFindVGA outb(GENVS, 0x01U); outb(GENENA, 0x0EU); - pATI = ATIVGAProbe(pATI); - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - return; - - ppVGA = ppATI; - } - - ATIAssignVGA(pVideo, ppVGA, pATI, p8514, ProbeFlags); + ATIAssignVGA(pVideo, pATI); } #endif /* AVOID_CPIO */ /* - * ATIProbe -- + * ATIMach64ProbeIO -- * - * This function is called once, at the start of the first server generation to - * do a minimal probe for supported hardware. + * This function determines the IO method and IO base of the ATI PCI adapter. */ Bool -ATIProbe +ATIMach64ProbeIO ( - DriverPtr pDriver, - int flags + pciVideoPtr pVideo, + ATIPtr pATI ) { - ATIPtr pATI, *ATIPtrs = NULL; - GDevPtr *GDevs, pGDev; - pciVideoPtr pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo(); - ATIGDev *ATIGDevs = NULL, *pATIGDev; - ScrnInfoPtr pScreenInfo; - Bool ProbeSuccess = FALSE; - Bool DoRage128 = FALSE, DoRadeon = FALSE; - int i, j, k; - int nGDev, nATIGDev = -1, nATIPtr = 0; - int Chipset; - ATIChipType Chip; - -#if !defined(AVOID_NON_PCI) || !defined(AVOID_CPIO) - pciConfigPtr pPCI; - CARD32 PciReg; -#endif /* AVOID_NON_PCI || AVOID_CPIO */ - -#ifndef AVOID_NON_PCI - ATIPtr pMach64[3] = {NULL, NULL, NULL}; -#endif - -#ifndef AVOID_CPIO - - ATIPtr pVGA = NULL, p8514 = NULL; - pciConfigPtr *xf86PciInfo = xf86GetPciConfigInfo(); - PortPtr PCIPorts = NULL; - int nPCIPort = 0; - CARD8 fChipsets[ATI_CHIPSET_MAX]; - static const IOADDRESS Mach64SparseIOBases[] = {0x02ECU, 0x01CCU, 0x01C8U}; - CARD8 ProbeFlags[LongPort(SPARSE_IO_BASE) + 1]; - - unsigned long BIOSBase; - static const CARD8 ATISignature[] = " 761295520"; -# define SignatureSize 10 -# define PrefixSize 0x50U -# define BIOSSignature 0x30U - CARD8 BIOS[PrefixSize]; -# define BIOSWord(_n) (BIOS[_n] | (BIOS[(_n) + 1] << 8)) - -#endif /* AVOID_CPIO */ - -# define AddAdapter(_p) \ - do \ - { \ - nATIPtr++; \ - ATIPtrs = (ATIPtr *)xnfrealloc(ATIPtrs, SizeOf(ATIPtr) * nATIPtr); \ - ATIPtrs[nATIPtr - 1] = (_p); \ - (_p)->iEntity = -2; \ - } while (0) + Bool ProbeSuccess = FALSE; #ifndef AVOID_CPIO - (void)memset(fChipsets, FALSE, SizeOf(fChipsets)); - -#endif /* AVOID_CPIO */ - - if (!(flags & PROBE_DETECT)) + /* Next, look for sparse I/O Mach64's */ + if (!pVideo->size[1]) { - /* - * Get a list of XF86Config device sections whose "Driver" is either - * not specified, or specified as this driver. From this list, - * eliminate those device sections that specify a "Chipset" or a - * "ChipID" not recognised by the driver. Those device sections that - * specify a "ChipRev" without a "ChipID" are also weeded out. - */ - nATIGDev = 0; - if ((nGDev = xf86MatchDevice(ATI_NAME, &GDevs)) > 0) - { - ATIGDevs = (ATIGDevPtr)xnfcalloc(nGDev, SizeOf(ATIGDev)); - - for (i = 0, pATIGDev = ATIGDevs; i < nGDev; i++) - { - pGDev = GDevs[i]; - Chipset = ATIIdentProbe(pGDev->chipset); - if (Chipset == -1) - continue; - - if ((pGDev->chipID > (int)((CARD16)(-1))) || - (pGDev->chipRev > (int)((CARD8)(-1)))) - continue; - - if (pGDev->chipID >= 0) - { - if (ATIChipID(pGDev->chipID, 0) == ATI_CHIP_Mach64) - continue; - } - else - { - if (pGDev->chipRev >= 0) - continue; - } - - pATIGDev->pGDev = pGDev; - pATIGDev->Chipset = Chipset; - nATIGDev++; - pATIGDev++; - - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": Candidate \"Device\" section \"%s\".\n", - pGDev->identifier); - -#ifndef AVOID_CPIO - - fChipsets[Chipset] = TRUE; - -#endif /* AVOID_CPIO */ - - } - - xfree(GDevs); - - if (!nATIGDev) - { - xfree(ATIGDevs); - ATIGDevs = NULL; - } - } - - if (xf86MatchDevice(R128_NAME, NULL) > 0) - DoRage128 = TRUE; - if (xf86MatchDevice(RADEON_NAME, NULL) > 0) - DoRadeon = TRUE; - } - -#ifndef AVOID_CPIO - - /* - * Collect hardware information. This must be done with care to avoid - * lockups due to overlapping I/O port assignments. - * - * First, scan PCI configuration space for registered I/O ports (which will - * be block I/O bases). Each such port is used to generate a list of - * sparse I/O bases it precludes. This list is then used to decide whether - * or not certain sparse I/O probes are done. Unfortunately, this assumes - * that any registered I/O base actually reserves upto the full 256 ports - * allowed by the PCI specification. This assumption holds true for PCI - * Mach64, but probably doesn't for other device types. For some things, - * such as video devices, the number of ports a base represents is - * determined by the server's PCI probe, but, for other devices, this - * cannot be done by a user-level process without jeopardizing system - * integrity. This information should ideally be retrieved from the OS's - * own PCI probe (if any), but there's currently no portable way of doing - * so. The following allows sparse I/O probes to be forced in certain - * circumstances when an appropriate chipset specification is used in any - * XF86Config Device section. - * - * Note that this is not bullet-proof. Lockups can still occur, but they - * will usually be due to devices that are misconfigured to respond to the - * same I/O ports as 8514/A's or ATI sparse I/O devices without registering - * them in PCI configuration space. - */ - if (nATIGDev) - { - if (xf86PciVideoInfo) - { - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor == PCI_VENDOR_ATI) || - !(pPCI = pVideo->thisCard)) - continue; - - ATIScanPCIBases(&PCIPorts, &nPCIPort, - &pPCI->pci_base0, pVideo->size, - (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & - PCI_CMD_IO_ENABLE) ? 0 : Allowed); - } - } - - /* Check non-video PCI devices for I/O bases */ - if (xf86PciInfo) - { - for (i = 0; (pPCI = xf86PciInfo[i++]); ) - { - if ((pPCI->pci_vendor == PCI_VENDOR_ATI) || - (pPCI->pci_base_class == PCI_CLASS_BRIDGE) || - (pPCI->pci_header_type & - ~GetByte(PCI_HEADER_MULTIFUNCTION, 2))) - continue; - - ATIScanPCIBases(&PCIPorts, &nPCIPort, - &pPCI->pci_base0, pPCI->basesize, - (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & - PCI_CMD_IO_ENABLE) ? 0 : Allowed); - } - } - - /* Generate ProbeFlags array from list of registered PCI I/O bases */ - (void)memset(ProbeFlags, Allowed | DoProbe, SizeOf(ProbeFlags)); - for (i = 0; i < nPCIPort; i++) + static const IOADDRESS Mach64SparseIOBases[] = { + 0x02ECU, + 0x01CCU, + 0x01C8U + }; + pciConfigPtr pPCI = pVideo->thisCard; + CARD32 PciReg; + CARD32 j; + + if (pPCI == NULL) + goto SkipSparse; + + PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + j = PciReg & 0x03U; + + if (j == 0x03U) { - CARD32 Base = PCIPorts[i].Base; - CARD16 Count = (1 << PCIPorts[i].Size) - 1; - CARD8 ProbeFlag = PCIPorts[i].Flag; + xf86Msg(X_WARNING, ATI_NAME ": " + "PCI Mach64 in slot %d:%d:%d cannot be enabled\n" + "because it has neither a block, nor a sparse, I/O base.\n", + pVideo->bus, pVideo->device, pVideo->func); - /* - * The following reduction of Count is based on the assumption that - * PCI-registered I/O port ranges do not overlap. - */ - for (j = 0; j < nPCIPort; j++) - { - CARD32 Base2 = PCIPorts[j].Base; - - if (Base < Base2) - while ((Base + Count) >= Base2) - Count >>= 1; - } - - Base = LongPort(Base); - Count = LongPort((Count | IO_BYTE_SELECT) + 1); - while (Count--) - ProbeFlags[Base++] &= ProbeFlag; + goto SkipSparse; } - xfree(PCIPorts); - -#ifndef AVOID_NON_PCI - - /* - * A note on probe strategy. I/O and memory response by certain PCI - * devices has been disabled by the common layer at this point, - * including any devices this driver might be interested in. The - * following does sparse I/O probes, followed by block I/O probes. - * Block I/O probes are dictated by what is found to be of interest in - * PCI configuration space. All this will detect ATI adapters that do - * not implement this disablement, pre-PCI or not. + /* FIXME: + * Should not probe at sparse I/O bases which have been registered to + * other PCI devices. The old ATIProbe() would scan the PCI space and + * build a list of registered I/O ports. If there was a conflict + * between a mach64 sparse I/O base and a registered I/0 port, probing + * that port was not allowed... * - * PCI configuration space is then scanned again for ATI devices that - * failed to be detected the first time around. Each such device is - * probed for again, this time with I/O temporarily enabled through - * PCI. + * We just add an option and let the user decide, this will not work + * with "X -configure" though... */ - if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == - DoProbe) + if (!pATI->OptionProbeSparse) { - pATI = ATIVGAProbe(NULL); - if (pATI->Adapter == ATI_ADAPTER_NONE) - { - xfree(pATI); + xf86Msg(X_WARNING, ATI_NAME ": " + "PCI Mach64 in slot %d:%d:%d will not be probed\n" + "set option \"probe_sparse\" to force sparse I/O probing.\n", + pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 4, - ATI_NAME ": Unshared VGA not detected.\n"); - } - else - { - /* - * Claim all MDA/HGA/CGA/EGA/VGA I/O ports. This might need to - * be more selective. - */ - ATIClaimSparseIOBases(ProbeFlags, MonochromeIOBase, 48, - DetectedVGA); - - pVGA = pATI; - strcpy(Identifier, "Unshared VGA"); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s detected.\n", Identifier); - } - } - else - { - xf86MsgVerb(X_INFO, 2, ATI_NAME ": Unshared VGA not probed.\n"); + goto SkipSparse; } - /* - * Mach8/32 probing doesn't work well on some legacy free ia64 - * However if we use AVOID_CPIO we don't get here at all. - */ - if (ATICheckSparseIOBases(NULL, ProbeFlags, 0x02E8U, 8, - fChipsets[ATI_CHIPSET_IBM8514] || - fChipsets[ATI_CHIPSET_MACH8] || - fChipsets[ATI_CHIPSET_MACH32]) == DoProbe) - { - if ((pATI = ATI8514Probe(NULL))) - { - strcpy(Identifier, "Unshared 8514/A"); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s detected.\n", Identifier); - - AddAdapter(p8514 = pATI); + /* Possibly fix block I/O indicator */ + if (PciReg & 0x00000004U) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, PciReg & ~0x00000004U); - if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || - (pATI->Coprocessor != ATI_CHIP_NONE)) - ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, - Detected8514A); + pATI->CPIOBase = Mach64SparseIOBases[j]; + pATI->CPIODecoding = SPARSE_IO; + pATI->PCIInfo = pVideo; - ATIClaimSparseIOBases(ProbeFlags, 0x02E8U, 8, Detected8514A); - } - else - { - xf86MsgVerb(X_INFO, 4, - ATI_NAME ": Unshared 8514/A not detected.\n"); - } - } - else + if (!ATIMach64Probe(pATI, pVideo, pATI->Chip)) { - xf86MsgVerb(X_INFO, 2, - ATI_NAME ": Unshared 8514/A not probed.\n"); + xf86Msg(X_WARNING, ATI_NAME ": " + "PCI Mach64 in slot %d:%d:%d could not be detected!\n", + pVideo->bus, pVideo->device, pVideo->func); } - - /* - * Also NONPCI Mach64 probing is evil on legacy free platforms. - * However if we use AVOID_CPIO we don't get here at all. - */ - for (i = 0; i < NumberOf(Mach64SparseIOBases); i++) + else { - if (ATICheckSparseIOBases(NULL, ProbeFlags, Mach64SparseIOBases[i], - 4, fChipsets[ATI_CHIPSET_MACH64]) != DoProbe) - { - xf86MsgVerb(X_INFO, 2, - ATI_NAME ": Unshared Mach64 at PIO base 0x%04lX not" - " probed.\n", - Mach64SparseIOBases[i]); - continue; - } - - pATI = ATIMach64Probe(NULL, Mach64SparseIOBases[i], SPARSE_IO, 0); - if (!pATI) - { - xf86MsgVerb(X_INFO, 4, - ATI_NAME ": Unshared Mach64 at PIO base 0x%04lX not" - " detected.\n", Mach64SparseIOBases[i]); - continue; - } - - sprintf(Identifier, "Unshared Mach64 at sparse PIO base 0x%04lX", - Mach64SparseIOBases[i]); - xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", Identifier); - - AddAdapter(pMach64[i] = pATI); - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, - DetectedMach64); - - ATIClaimSparseIOBases(ProbeFlags, Mach64SparseIOBases[i], 4, - DetectedMach64); + ProbeSuccess = TRUE; + xf86Msg(X_INFO, ATI_NAME ": " + "Shared PCI Mach64 in slot %d:%d:%d with sparse PIO base" + " 0x%04lX detected.\n", + pVideo->bus, pVideo->device, pVideo->func, + Mach64SparseIOBases[j]); + + if (pATI->VGAAdapter) + ATIFindVGA(pVideo, pATI); } -#endif /* AVOID_NON_PCI */ - } -#endif /* AVOID_CPIO */ - - if (xf86PciVideoInfo) - { - if (nATIGDev) - { - -#ifndef AVOID_NON_PCI - -#ifdef AVOID_CPIO - - /* PCI sparse I/O adapters can still be used through MMIO */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - pVideo->size[1] || - !(pPCI = pVideo->thisCard)) - continue; - - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); - - /* Possibly fix block I/O indicator */ - if (PciReg & 0x00000004U) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg & ~0x00000004U); - - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - - /* - * The CPIO base used by the adapter is of little concern here. - */ - pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); - if (!pATI) - continue; - - sprintf(Identifier, - "Unshared PCI sparse I/O Mach64 in slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s detected through Block 0 at 0x%08lX.\n", - Identifier, pATI->Block0Base); - AddAdapter(pATI); - pATI->PCIInfo = pVideo; - } - -#endif /* AVOID_CPIO */ - - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - !pVideo->size[1]) - continue; - - /* For now, ignore Rage128's and Radeon's */ - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - if ((Chip > ATI_CHIP_Mach64) || - !(pPCI = pVideo->thisCard)) - continue; - - /* - * Possibly fix block I/O indicator in PCI configuration space. - */ - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); - if (!(PciReg & 0x00000004U)) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg | 0x00000004U); - - pATI = - ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip); - if (!pATI) - continue; - - sprintf(Identifier, "Unshared PCI/AGP Mach64 in slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s detected.\n", Identifier); - AddAdapter(pATI); - -#ifndef AVOID_CPIO - - /* This is probably not necessary */ - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIClaimVGA(pVideo, &pVGA, pATI, p8514, - ProbeFlags, DetectedMach64); - -#endif /* AVOID_CPIO */ - - } - -#endif /* AVOID_NON_PCI */ - -#ifndef AVOID_CPIO - - /* - * This is the second pass through PCI configuration space. Much - * of this is verbiage to deal with potential situations that are - * very unlikely to occur in practice. - * - * First, look for non-ATI shareable VGA's. For now, these must - * the primary device. - */ - if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == - DoProbe) - { - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor == PCI_VENDOR_ATI) || - !xf86IsPrimaryPci(pVideo)) - continue; - - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) - continue; - - xf86SetPciVideo(pVideo, MEM_IO); - - pATI = ATIVGAProbe(NULL); - if (pATI->Adapter == ATI_ADAPTER_NONE) - { - xfree(pATI); - xf86Msg(X_WARNING, - ATI_NAME ": PCI/AGP VGA compatible in slot" - " %d:%d:%d could not be detected!\n", - pVideo->bus, pVideo->device, pVideo->func); - } - else - { - sprintf(Identifier, - "Shared non-ATI VGA in PCI/AGP slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", - Identifier); - AddAdapter(pATI); - pATI->SharedVGA = TRUE; - pATI->BusType = ATI_BUS_PCI; - pATI->PCIInfo = pVideo; - } - - xf86SetPciVideo(NULL, NONE); - } - } - - /* Next, look for PCI Mach32's */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType != PCI_CHIP_MACH32)) - continue; - - switch (ATICheckSparseIOBases(pVideo, ProbeFlags, - 0x02E8U, 8, TRUE)) - { - case 0: - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach32 in slot %d:%d:%d will not" - " be enabled\n because it conflicts with a" - " non-video PCI/AGP device.\n", - pVideo->bus, pVideo->device, pVideo->func); - break; - -#ifndef AVOID_NON_PCI - - case Detected8514A: - if ((p8514->BusType >= ATI_BUS_PCI) && !p8514->PCIInfo) - p8514->PCIInfo = pVideo; - else - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach32 in slot %d:%d:%d will" - " not be enabled\n because it conflicts with" - " another %s %s.\n", - pVideo->bus, pVideo->device, pVideo->func, - ATIBusNames[p8514->BusType], - ATIAdapterNames[p8514->Adapter]); - break; - - case DetectedMach64: - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach32 in slot %d:%d:%d will not" - " be enabled\n because it conflicts with a Mach64" - " at I/O base 0x02EC.\n", - pVideo->bus, pVideo->device, pVideo->func); - break; - -#endif /* AVOID_NON_PCI */ - - default: /* Must be DoProbe */ - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) - continue; - - xf86SetPciVideo(pVideo, MEM_IO); - - if (!(pATI = ATI8514Probe(pVideo))) - { - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach32 in slot %d:%d:%d could" - " not be detected!\n", - pVideo->bus, pVideo->device, pVideo->func); - } - else - { - sprintf(Identifier, - "Shared 8514/A in PCI slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s detected.\n", Identifier); - if (pATI->Adapter != ATI_ADAPTER_MACH32) - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach32 in slot %d:%d:%d" - " could only be detected as an %s!\n", - pVideo->bus, pVideo->device, pVideo->func, - ATIAdapterNames[pATI->Adapter]); - - AddAdapter(pATI); - pATI->SharedAccelerator = TRUE; - - if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || - (pATI->Coprocessor != ATI_CHIP_NONE)) - ATIFindVGA(pVideo, &pVGA, &pATI, p8514, - ProbeFlags); - } - xf86SetPciVideo(NULL, NONE); - break; - } - } - - /* Next, look for sparse I/O Mach64's */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - /* For some Radeons, pvideo->size[1] is not there but the card - * still works properly. Thus adding check that if the chip was - * correctly identified as being Rage128 or a Radeon, continue - * also in that case. See fd.o bug 6796. */ - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - (Chip > ATI_CHIP_Mach64) || - pVideo->size[1]) - continue; - - pPCI = pVideo->thisCard; - if (pPCI == NULL) - continue; - - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); - j = PciReg & 0x03U; - if (j == 0x03U) - { - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach64 in slot %d:%d:%d cannot be" - " enabled\n because it has neither a block, nor a" - " sparse, I/O base.\n", - pVideo->bus, pVideo->device, pVideo->func); - } - else switch(ATICheckSparseIOBases(pVideo, ProbeFlags, - Mach64SparseIOBases[j], 4, TRUE)) - { - case 0: - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach64 in slot %d:%d:%d will not" - " be enabled\n because it conflicts with another" - " non-video PCI device.\n", - pVideo->bus, pVideo->device, pVideo->func); - break; - -#ifndef AVOID_NON_PCI - - case Detected8514A: - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach64 in slot %d:%d:%d will not" - " be enabled\n because it conflicts with an %s.\n", - pVideo->bus, pVideo->device, pVideo->func, - ATIAdapterNames[p8514->Adapter]); - break; - - case DetectedMach64: - pATI = pMach64[j]; - if ((pATI->BusType >= ATI_BUS_PCI) && !pATI->PCIInfo) - pATI->PCIInfo = pVideo; - else - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach64 in slot %d:%d:%d will" - " not be enabled\n because it conflicts with" - " another %s Mach64 at sparse I/O base" - " 0x%04lX.\n", - pVideo->bus, pVideo->device, pVideo->func, - ATIBusNames[pATI->BusType], - Mach64SparseIOBases[j]); - break; - -#endif /* AVOID_NON_PCI */ - - default: /* Must be DoProbe */ - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) - continue; - - /* Possibly fix block I/O indicator */ - if (PciReg & 0x00000004U) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg & ~0x00000004U); - - xf86SetPciVideo(pVideo, MEM_IO); - - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - pATI = ATIMach64Probe(pVideo, Mach64SparseIOBases[j], - SPARSE_IO, Chip); - if (!pATI) - { - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach64 in slot %d:%d:%d could" - " not be detected!\n", - pVideo->bus, pVideo->device, pVideo->func); - } - else - { - sprintf(Identifier, - "Shared PCI Mach64 in slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s with sparse PIO base 0x%04lX" - " detected.\n", Identifier, - Mach64SparseIOBases[j]); - AddAdapter(pATI); - pATI->SharedAccelerator = TRUE; - pATI->PCIInfo = pVideo; - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIFindVGA(pVideo, &pVGA, &pATI, p8514, - ProbeFlags); - } - - xf86SetPciVideo(NULL, NONE); - break; - } - } +SkipSparse: #else /* AVOID_CPIO */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - pVideo->size[1]) - continue; - - /* Check if this one has already been detected */ - for (j = 0; j < nATIPtr; j++) - { - pATI = ATIPtrs[j]; - if (pATI->PCIInfo == pVideo) - goto SkipThisSlot; - } - - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) - continue; - - xf86SetPciVideo(pVideo, MEM_IO); - - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - - /* The adapter's CPIO base is of little concern here */ - pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); - if (pATI) - { - sprintf(Identifier, "Shared PCI Mach64 in slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s with Block 0 base 0x%08lX detected.\n", - Identifier, pATI->Block0Base); - AddAdapter(pATI); - pATI->SharedAccelerator = TRUE; - pATI->PCIInfo = pVideo; - } - else - { - xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach64 in slot %d:%d:%d could not be" - " detected!\n", - pVideo->bus, pVideo->device, pVideo->func); - } - - xf86SetPciVideo(NULL, NONE); - - SkipThisSlot:; - } - -#endif /* AVOID_CPIO */ - - } - - /* Lastly, look for block I/O devices */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - /* For some Radeons, !pvideo->size[1] applies but the card still - * works properly. Thus don't make !pVideo->size[1] check to continue - * automatically (instead check that the chip actually is below - * ATI_CHIP_Mach64 (includes ATI_CHIP_NONE)). See fd.o bug 6796. */ - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - (!pVideo->size[1] && Chip < ATI_CHIP_Mach64)) - continue; - - /* Check for Rage128's, Radeon's and later adapters */ - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - if (Chip > ATI_CHIP_Mach64) - { - if (Chip <= ATI_CHIP_Rage128) - DoRage128 = TRUE; - else if (Chip <= ATI_CHIP_Radeon) - DoRadeon = TRUE; - - continue; - } - - if (!nATIGDev) - continue; - - /* Check if this one has already been detected */ - for (j = 0; j < nATIPtr; j++) - { - pATI = ATIPtrs[j]; - if (pATI->CPIOBase == pVideo->ioBase[1]) - goto SetPCIInfo; - } - - if (!xf86CheckPciSlot(pVideo->bus, pVideo->device, pVideo->func)) - continue; - - /* Probe for it */ - xf86SetPciVideo(pVideo, MEM_IO); - - pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip); - if (pATI) - { - sprintf(Identifier, "Shared PCI/AGP Mach64 in slot %d:%d:%d", - pVideo->bus, pVideo->device, pVideo->func); - xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", - Identifier); - AddAdapter(pATI); - pATI->SharedAccelerator = TRUE; - -#ifndef AVOID_CPIO - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIFindVGA(pVideo, &pVGA, &pATI, p8514, ProbeFlags); - -#endif /* AVOID_CPIO */ - - } - - xf86SetPciVideo(NULL, NONE); - - if (!pATI) - { - xf86Msg(X_WARNING, - ATI_NAME ": PCI/AGP Mach64 in slot %d:%d:%d could not be" - " detected!\n", pVideo->bus, pVideo->device, pVideo->func); - continue; - } - - SetPCIInfo: - pATI->PCIInfo = pVideo; - } - } - -#ifndef AVOID_CPIO - - /* - * At this point, if there's a non-shareable VGA with its own framebuffer, - * find out if it's an ATI VGA Wonder. - */ - do + if (!pVideo->size[1]) { - if (!nATIGDev || !pVGA || (pVGA->VGAAdapter > ATI_ADAPTER_VGA)) - break; - - /* If it has not been assigned to a coprocessor, keep track of it */ - if (pVGA->Coprocessor == ATI_CHIP_NONE) - AddAdapter(pVGA); - - /* - * A VGA should have installed its int 10 vector. Use that to find the - * VGA BIOS. If this fails, scan all legacy BIOS segments, in 512-byte - * increments. - */ - if (xf86ReadBIOS(0U, 0x42U, BIOS, 2) != 2) - goto NoVGAWonder; - - pATI = NULL; - BIOSBase = 0; - if (!(BIOS[0] & 0x1FU)) /* Otherwise there's no 512-byte alignment */ - BIOSBase = ((BIOS[1] << 8) | BIOS[0]) << 4; + /* The adapter's CPIO base is of little concern here */ + pATI->CPIOBase = 0; + pATI->CPIODecoding = SPARSE_IO; + pATI->PCIInfo = pVideo; - /* Look for its BIOS */ - for(; ; BIOSBase += 0x00000200U) + if (ATIMach64Probe(pATI, pVideo, pATI->Chip)) { - if (!BIOSBase) - goto SkipBiosSegment; - - if (BIOSBase >= 0x000F8000U) - goto NoVGAWonder; - - /* Skip over those that are already known */ - for (i = 0; i < nATIPtr; i++) - if (ATIPtrs[i]->BIOSBase == BIOSBase) - goto SkipBiosSegment; - - /* Get first 80 bytes of video BIOS */ - if (xf86ReadBIOS(BIOSBase, 0, BIOS, SizeOf(BIOS)) != - SizeOf(BIOS)) - goto NoVGAWonder; - - if ((BIOS[0x00U] != 0x55U) || (BIOS[0x01U] != 0xAAU)) - goto SkipBiosSegment; - - if ((BIOS[0x1EU] == 'I') && - (BIOS[0x1FU] == 'B') && - (BIOS[0x20U] == 'M')) - break; - - /* XXX Should PCI BIOS signature be checked for here ? */ - if ((BIOS[0x20U] == 'P') && - (BIOS[0x21U] == 'C') && - (BIOS[0x22U] == 'I')) - break; - - SkipBiosSegment: - if (pATI) - continue; - - pATI = pVGA; - BIOSBase = 0x000C0000U - 0x00000200U; + ProbeSuccess = TRUE; + xf86Msg(X_INFO, ATI_NAME ": " + "Shared PCI Mach64 in slot %d:%d:%d with Block 0 base" + " 0x%08lX detected.\n", + pVideo->bus, pVideo->device, pVideo->func, + pATI->Block0Base); } - - pVGA->BIOSBase = BIOSBase; - - /* Look for the ATI signature string */ - if (memcmp(BIOS + BIOSSignature, ATISignature, SignatureSize)) - break; - - if (BIOS[0x40U] != '3') - break; - - switch (BIOS[0x41U]) + else { - case '1': - /* This is a Mach8 or VGA Wonder adapter of some kind */ - if ((BIOS[0x43U] >= '1') && (BIOS[0x43U] <= '6')) - pVGA->Chip = BIOS[0x43U] - ('1' - ATI_CHIP_18800); - - switch (BIOS[0x43U]) - { - case '1': /* ATI_CHIP_18800 */ - pVGA->VGAOffset = 0xB0U; - pVGA->VGAAdapter = ATI_ADAPTER_V3; - break; - - case '2': /* ATI_CHIP_18800_1 */ - pVGA->VGAOffset = 0xB0U; - if (BIOS[0x42U] & 0x10U) - pVGA->VGAAdapter = ATI_ADAPTER_V5; - else - pVGA->VGAAdapter = ATI_ADAPTER_V4; - break; - - case '3': /* ATI_CHIP_28800_2 */ - case '4': /* ATI_CHIP_28800_4 */ - case '5': /* ATI_CHIP_28800_5 */ - case '6': /* ATI_CHIP_28800_6 */ - pVGA->VGAOffset = 0xA0U; - if (BIOS[0x44U] & 0x80U) - pVGA->VGAAdapter = ATI_ADAPTER_XL; - else - pVGA->VGAAdapter = ATI_ADAPTER_PLUS; - break; - - case 'a': /* A crippled Mach32 */ - case 'b': - case 'c': - pVGA->VGAOffset = 0x80U; - pVGA->VGAAdapter = ATI_ADAPTER_NONISA; - ATIMach32ChipID(pVGA); - ProbeWaitIdleEmpty(); - if (inw(SUBSYS_STAT) != (CARD16)(-1)) - pVGA->ChipHasSUBSYS_CNTL = TRUE; - break; -#if 0 - case ' ': /* A crippled Mach64 */ - pVGA->VGAOffset = 0x80U; - pVGA->VGAAdapter = ATI_ADAPTER_NONISA; - ATIMach64ChipID(pVGA, 0); - break; -#endif - default: - break; - } - - if (pVGA->VGAAdapter == ATI_ADAPTER_NONE) - break; - - /* Set VGA Wonder I/O port */ - pVGA->CPIO_VGAWonder = BIOSWord(0x10U) & SPARSE_IO_PORT; - if (!pVGA->CPIO_VGAWonder) - pVGA->CPIO_VGAWonder = 0x01CEU; - - ATIVGAWonderProbe(NULL, pVGA, p8514, ProbeFlags); - break; -#if 0 - case '2': - pVGA->VGAOffset = 0xB0U; /* Presumably */ - pVGA->VGAAdapter = ATI_ADAPTER_EGA_PLUS; - break; - - case '3': - pVGA->VGAOffset = 0xB0U; /* Presumably */ - pVGA->VGAAdapter = ATI_ADAPTER_BASIC; - break; - - case '?': /* A crippled Mach64 */ - pVGA->VGAAdapter = ATI_ADAPTER_NONISA; - ATIMach64ChipID(pVGA, 0); - break; -#endif - default: - break; + xf86Msg(X_WARNING, ATI_NAME ": " + "PCI Mach64 in slot %d:%d:%d could not be detected!\n", + pVideo->bus, pVideo->device, pVideo->func); } - - if (pVGA->Adapter <= ATI_ADAPTER_VGA) - pVGA->Adapter = pVGA->VGAAdapter; - -NoVGAWonder:; - } while (0); + } #endif /* AVOID_CPIO */ - /* - * Re-order list of detected devices so that the primary device is before - * any other PCI device. - */ - for (i = 0; i < nATIPtr; i++) + /* Lastly, look for block I/O devices */ + if (pVideo->size[1]) { - if (!ATIPtrs[i]->PCIInfo) - continue; - - for (j = i; j < nATIPtr; j++) - { - pATI = ATIPtrs[j]; - if (!xf86IsPrimaryPci(pATI->PCIInfo)) - continue; - - for (; j > i; j--) - ATIPtrs[j] = ATIPtrs[j - 1]; - ATIPtrs[j] = pATI; - break; - } - - break; - } + pATI->CPIOBase = pVideo->ioBase[1]; + pATI->CPIODecoding = BLOCK_IO; + pATI->PCIInfo = pVideo; - if (flags & PROBE_DETECT) - { - /* - * No XF86Config information available, so use the default Chipset of - * "ati", and as many device sections as there are adapters. - */ - for (i = 0; i < nATIPtr; i++) + if (ATIMach64Probe(pATI, pVideo, pATI->Chip)) { - pATI = ATIPtrs[i]; + ProbeSuccess = TRUE; + xf86Msg(X_INFO, ATI_NAME ": " + "Shared PCI/AGP Mach64 in slot %d:%d:%d detected.\n", + pVideo->bus, pVideo->device, pVideo->func); #ifndef AVOID_CPIO - if ((pATI->Adapter != ATI_ADAPTER_VGA) && - ((pATI->Adapter != ATI_ADAPTER_8514A) || - ((pATI->VGAAdapter != ATI_ADAPTER_VGA) && - (pATI->VGAAdapter != ATI_ADAPTER_NONE)))) + if (pATI->VGAAdapter) + ATIFindVGA(pVideo, pATI); #endif /* AVOID_CPIO */ - { - ProbeSuccess = TRUE; - pGDev = xf86AddDeviceToConfigure(ATI_DRIVER_NAME, - pATI->PCIInfo, ATI_CHIPSET_ATI); - if (pGDev) - { - /* Fill in additional information */ - pGDev->vendor = ATI_NAME; - pGDev->chipset = (char *)ATIChipsetNames[ATI_CHIPSET_ATI]; - if (!pATI->PCIInfo) - pGDev->busID = NULL; - } - } - - xfree(pATI); } - } - else - { - /* - * Assign detected devices to XF86Config Device sections. This is done - * by comparing certain Device section specifications against the - * corresponding adapter information. Begin with those specifications - * that are independent of the adapter's bus location. - */ - for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) + else { - pGDev = pATIGDev->pGDev; - - for (j = 0; j < nATIPtr; j++) - { - pATI = ATIPtrs[j]; - - /* - * First check the Chipset specification. The placement of - * "break" and "continue" statements here is carefully chosen - * to produce the intended behaviour for each Chipset value. - */ - switch (pATIGDev->Chipset) - { - case ATI_CHIPSET_ATI: - -#ifndef AVOID_CPIO - - if (pATI->Adapter == ATI_ADAPTER_VGA) - continue; - if (pATI->Adapter != ATI_ADAPTER_8514A) - break; - /* Fall through */ - - case ATI_CHIPSET_ATIVGA: - if (pATI->VGAAdapter == ATI_ADAPTER_VGA) - continue; - /* Fall through */ - - case ATI_CHIPSET_IBMVGA: - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - continue; - break; - - case ATI_CHIPSET_VGAWONDER: - if (!pATI->CPIO_VGAWonder) - continue; - break; - - case ATI_CHIPSET_IBM8514: - if (pATI->Adapter == ATI_ADAPTER_8514A) - break; - /* Fall through */ - - case ATI_CHIPSET_MACH8: - if (pATI->Adapter == ATI_ADAPTER_MACH8) - break; - /* Fall through */ - - case ATI_CHIPSET_MACH32: - if (pATI->Adapter == ATI_ADAPTER_MACH32) - break; - continue; - -#endif /* AVOID_CPIO */ - - case ATI_CHIPSET_MACH64: - if (pATI->Adapter == ATI_ADAPTER_MACH64) - break; - continue; - - default: - continue; - } - - /* - * The ChipID and ChipRev specifications are compared next. - * First, require these to be unspecified for anything other - * than Mach32 or Mach64 adapters. ChipRev is also required to - * be unspecified for Mach32's. ChipID is optional for - * Mach32's, and both specifications are optional for Mach64's. - * Lastly, allow both specifications to override their detected - * value in the case of Mach64 adapters whose ChipID is - * unrecognised. - */ - pVideo = pATI->PCIInfo; - if (pGDev->chipID >= 0) - { - if ((pATI->ChipType != pGDev->chipID) && - (!pVideo || (pGDev->chipID != pVideo->chipType))) - { - if ((pATI->Adapter != ATI_ADAPTER_MACH64) || - (pATI->Chip != ATI_CHIP_Mach64)) - continue; - - Chip = ATIChipID(pGDev->chipID, 0); - if ((Chip <= ATI_CHIP_264GTB) || - (Chip == ATI_CHIP_Mach64)) - continue; - } - if ((pGDev->chipRev >= 0) && - (pATI->ChipRev != pGDev->chipRev) && - (!pVideo || (pGDev->chipRev != pVideo->chipRev) || - (pGDev->chipID != pVideo->chipType))) - { - if (pATI->Chip < ATI_CHIP_264CT) - continue; - - if (pATI->Chip != ATI_CHIP_Mach64) - { - /* - * There are two foundry codes for UMC. Some - * adapters will advertise one in CONFIG_CHIP_ID - * and the other in PCI configuration space. For - * matching purposes, make both codes compare - * equal. - */ -# define UMC_IGNORE \ - (ATI_FOUNDRY_UMC ^ ATI_FOUNDRY_UMCA) -# define UMC_NOCARE \ - GetBits(SetBits(UMC_IGNORE, CFG_CHIP_FOUNDRY), \ - CFG_CHIP_REV) - - if ((pATI->ChipRev ^ pGDev->chipRev) & ~UMC_NOCARE) - continue; - - if ((pATI->ChipFoundry != ATI_FOUNDRY_UMC) && - (pATI->ChipFoundry != ATI_FOUNDRY_UMCA)) - continue; - - k = GetBits(pGDev->chipRev, - GetBits(CFG_CHIP_FOUNDRY, CFG_CHIP_REV)); - if ((k != ATI_FOUNDRY_UMC) && - (k != ATI_FOUNDRY_UMCA)) - continue; - } - } - } - - /* - * IOBase is next. This is the first specification that is - * potentially dependent on bus location. It is only allowed - * for Mach64 adapters, and is optional. - */ - if (pGDev->IOBase && (pATI->CPIOBase != pGDev->IOBase)) - continue; - - /* - * Compare BusID's. This specification is only allowed for PCI - * Mach32's or Mach64's and is optional. - */ - if (pGDev->busID && pGDev->busID[0]) - { - pVideo = pATI->PCIInfo; + xf86Msg(X_WARNING, ATI_NAME ": " + "PCI/AGP Mach64 in slot %d:%d:%d could not be detected!\n", + pVideo->bus, pVideo->device, pVideo->func); + } + } -#ifndef AVOID_CPIO + return ProbeSuccess; +} - if (!pVideo) - continue; +static SymTabRec +Mach64Chipsets[] = { + {ATI_CHIP_88800GXC, "ATI 88800GX-C"}, + {ATI_CHIP_88800GXD, "ATI 88800GX-D"}, + {ATI_CHIP_88800GXE, "ATI 88800GX-E"}, + {ATI_CHIP_88800GXF, "ATI 88800GX-F"}, + {ATI_CHIP_88800GX, "ATI 88800GX"}, + {ATI_CHIP_88800CX, "ATI 88800CX"}, + {ATI_CHIP_264CT, "ATI 264CT"}, + {ATI_CHIP_264ET, "ATI 264ET"}, + {ATI_CHIP_264VT, "ATI 264VT"}, + {ATI_CHIP_264VTB, "ATI 264VT-B"}, + {ATI_CHIP_264GT, "ATI 3D Rage"}, + {ATI_CHIP_264GTB, "ATI 3D Rage II"}, + {ATI_CHIP_264VT3, "ATI 264VT3"}, + {ATI_CHIP_264GTDVD, "ATI 3D Rage II+DVD"}, + {ATI_CHIP_264LT, "ATI 3D Rage LT"}, + {ATI_CHIP_264VT4, "ATI 264VT4"}, + {ATI_CHIP_264GT2C, "ATI 3D Rage IIc"}, + {ATI_CHIP_264GTPRO, "ATI 3D Rage Pro"}, + {ATI_CHIP_264LTPRO, "ATI 3D Rage LT Pro"}, + {ATI_CHIP_264XL, "ATI 3D Rage XL or XC"}, + {ATI_CHIP_MOBILITY, "ATI 3D Rage Mobility"}, + {-1, NULL } +}; -#endif /* AVOID_CPIO */ +/* + * This table maps a PCI device ID to a chipset family identifier. + */ +static PciChipsets +Mach64PciChipsets[] = { + {ATI_CHIP_88800GX, PCI_CHIP_MACH64GX, RES_SHARED_VGA}, + {ATI_CHIP_88800CX, PCI_CHIP_MACH64CX, RES_SHARED_VGA}, + {ATI_CHIP_264CT, PCI_CHIP_MACH64CT, RES_SHARED_VGA}, + {ATI_CHIP_264ET, PCI_CHIP_MACH64ET, RES_SHARED_VGA}, + {ATI_CHIP_264VT, PCI_CHIP_MACH64VT, RES_SHARED_VGA}, + {ATI_CHIP_264GT, PCI_CHIP_MACH64GT, RES_SHARED_VGA}, + {ATI_CHIP_264VT3, PCI_CHIP_MACH64VU, RES_SHARED_VGA}, + {ATI_CHIP_264GTDVD, PCI_CHIP_MACH64GU, RES_SHARED_VGA}, + {ATI_CHIP_264LT, PCI_CHIP_MACH64LG, RES_SHARED_VGA}, + {ATI_CHIP_264VT4, PCI_CHIP_MACH64VV, RES_SHARED_VGA}, + {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GV, RES_SHARED_VGA}, + {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GW, RES_SHARED_VGA}, + {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GY, RES_SHARED_VGA}, + {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GZ, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GB, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GD, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GI, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GP, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GQ, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LB, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LD, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LI, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LP, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LQ, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GL, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GM, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GN, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GO, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GR, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GS, RES_SHARED_VGA}, + {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LM, RES_SHARED_VGA}, + {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LN, RES_SHARED_VGA}, + {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LR, RES_SHARED_VGA}, + {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LS, RES_SHARED_VGA}, + {-1, -1, RES_UNDEFINED} +}; - if (!xf86ComparePciBusString(pGDev->busID, - pVideo->bus, pVideo->device, pVideo->func)) - continue; - } - - /* - * Ensure no two adapters are assigned to the same XF86Config - * Device section. - */ - if (pATIGDev->iATIPtr) - { - if (pATIGDev->iATIPtr < 0) - break; - - xf86Msg(X_ERROR, - ATI_NAME ": XF86Config Device section \"%s\" may not" - " be assigned to more than one adapter.\n", - pGDev->identifier); - pATIGDev->iATIPtr = -1; - break; - } - - /* Assign adapter */ - pATIGDev->iATIPtr = j + 1; - - /* - * For compatibility with previous releases, assign the first - * applicable adapter if there is only one Device section. - */ - if (nATIGDev == 1) - break; - } - } +/* + * Mach64Probe -- + * + * This function is called once, at the start of the first server generation to + * do a minimal probe for supported hardware. + */ +static Bool +Mach64Probe(DriverPtr pDriver, int flags) +{ + GDevPtr *devSections; + int *usedChips; + int numDevSections; + int numUsed; + Bool ProbeSuccess = FALSE; - /* - * Ensure no two XF86Config Device sections are assigned to the same - * adapter. Then, generate screens for any that are left. - */ - for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) - { - pGDev = pATIGDev->pGDev; + if ((numDevSections = xf86MatchDevice(ATI_DRIVER_NAME, &devSections)) <= 0) + return FALSE; - j = pATIGDev->iATIPtr; - if (j <= 0) - continue; + if (xf86GetPciVideoInfo() == NULL) + return FALSE; - for (k = i; ++k < nATIGDev; ) - { - if (j == ATIGDevs[k].iATIPtr) - { - xf86Msg(X_ERROR, - ATI_NAME ": XF86Config Device sections \"%s\" and" - " \"%s\" may not be assigned to the same adapter.\n", - pGDev->identifier, ATIGDevs[k].pGDev->identifier); - pATIGDev->iATIPtr = ATIGDevs[k].iATIPtr = -1; - } - } + numUsed = xf86MatchPciInstances(ATI_DRIVER_NAME, PCI_VENDOR_ATI, + Mach64Chipsets, Mach64PciChipsets, + devSections, numDevSections, + pDriver, &usedChips); + xfree(devSections); - j = ATIGDevs[i].iATIPtr; - if (j <= 0) - continue; + if (numUsed <= 0) + return FALSE; - pATI = ATIPtrs[j - 1]; + if (flags & PROBE_DETECT) { + ProbeSuccess = TRUE; + } else { + int i; - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": %s assigned to %sactive \"Device\" section" - " \"%s\".\n", - Identifier, pGDev->active ? "" : "in", pGDev->identifier); + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn; + EntityInfoPtr pEnt; + pciVideoPtr pVideo; - /* - * Attach adapter to XF86Config Device section and register its - * resources. - */ - if (ATIClaimBusSlot(pDriver, pATIGDev->Chipset, - pGDev, pGDev->active, pATI) < 0) - { - xf86Msg(X_ERROR, - ATI_NAME ": Could not claim bus slot for %s.\n", - Identifier); - continue; - } + pScrn = xf86ConfigPciEntity(NULL, 0, usedChips[i], Mach64PciChipsets, + 0, 0, 0, 0, NULL); - if (!pGDev->active) + if (!pScrn) continue; - /* Allocate screen */ - pScreenInfo = xf86AllocateScreen(pDriver, 0); + pEnt = xf86GetEntityInfo(usedChips[i]); + pVideo = xf86GetPciInfoForEntity(usedChips[i]); #ifdef XFree86LOADER - if (!xf86LoadSubModule(pScreenInfo, "atimisc")) + if (!xf86LoadSubModule(pScrn, "atimisc")) { xf86Msg(X_ERROR, ATI_NAME ": Failed to load \"atimisc\" module.\n"); - xf86DeleteScreen(pScreenInfo->scrnIndex, 0); + xf86DeleteScreen(pScrn->scrnIndex, 0); continue; } @@ -2299,45 +662,74 @@ NoVGAWonder:; #endif - /* Attach device to screen */ - xf86AddEntityToScreen(pScreenInfo, pATI->iEntity); - - ATIPtrs[j - 1] = NULL; - - /* Fill in probe data */ - ATIFillInScreenInfo(pScreenInfo); + ATIFillInScreenInfo(pScrn); - pScreenInfo->driverPrivate = pATI; - - pATI->Chipset = pATIGDev->Chipset; + pScrn->Probe = Mach64Probe; ProbeSuccess = TRUE; } + } - /* Deal with unassigned adapters */ - for (i = 0; i < nATIPtr; i++) - { - if (!(pATI = ATIPtrs[i])) - continue; + return ProbeSuccess; +} -#ifndef AVOID_CPIO +/* + * ATIProbe -- + * + * This function is called once, at the start of the first server generation to + * do a minimal probe for supported hardware. + */ +Bool +ATIProbe +( + DriverPtr pDriver, + int flags +) +{ + pciVideoPtr pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo(); + Bool ProbeSuccess = FALSE; + Bool DoMach64 = FALSE; + Bool DoRage128 = FALSE, DoRadeon = FALSE; + int i; + ATIChipType Chip; - if (pATI->Adapter > ATI_ADAPTER_VGA) + if (!(flags & PROBE_DETECT)) + { + if (xf86MatchDevice(ATI_NAME, NULL) > 0) + DoMach64 = TRUE; + if (xf86MatchDevice(R128_NAME, NULL) > 0) + DoRage128 = TRUE; + if (xf86MatchDevice(RADEON_NAME, NULL) > 0) + DoRadeon = TRUE; + } -#endif /* AVOID_CPIO */ + if (xf86PciVideoInfo) + { + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32)) + continue; + /* Check for Rage128's, Radeon's and later adapters */ + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + if (Chip > ATI_CHIP_Mach64) { - if (pATI->iEntity < 0) - (void)ATIClaimBusSlot(pDriver, 0, NULL, FALSE, pATI); + if (Chip <= ATI_CHIP_Rage128) + DoRage128 = TRUE; + else if (Chip <= ATI_CHIP_Radeon) + DoRadeon = TRUE; + + continue; } - xfree(pATI); + DoMach64 = TRUE; } - - xfree(ATIGDevs); } - xfree(ATIPtrs); + /* Call Mach64 driver probe */ + if (DoMach64 && Mach64Probe(pDriver, flags)) + ProbeSuccess = TRUE; /* Call Rage 128 driver probe */ if (DoRage128 && R128Probe(pDriver, flags)) diff --git a/src/atiscreen.c b/src/atiscreen.c index ca41ff1..e849941 100644 --- a/src/atiscreen.c +++ b/src/atiscreen.c @@ -61,12 +61,8 @@ #include "shadowfb.h" #include "xf86cmap.h" -#include "xf1bpp.h" -#include "xf4bpp.h" - #include "fb.h" -#include "mibank.h" #include "micmap.h" #include "mipointer.h" @@ -139,11 +135,6 @@ ATIMach64SetupMemXAA_NoDRI int maxScanlines = ATIMach64MaxY; int maxPixelArea, PixelArea; -#ifndef AVOID_CPIO - - if (!pATI->BankInfo.BankSize) - -#endif /* AVOID_CPIO */ { /* * Note: If PixelArea exceeds the engine's maximum, the excess is @@ -457,23 +448,6 @@ ATIScreenInit /* Initialise framebuffer layer */ switch (pATI->bitsPerPixel) { - -#ifndef AVOID_CPIO - - case 1: - pATI->Closeable = xf1bppScreenInit(pScreen, pFB, - pScreenInfo->virtualX, pScreenInfo->virtualY, - pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth); - break; - - case 4: - pATI->Closeable = xf4bppScreenInit(pScreen, pFB, - pScreenInfo->virtualX, pScreenInfo->virtualY, - pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth); - break; - -#endif /* AVOID_CPIO */ - case 8: case 16: case 24: @@ -512,7 +486,6 @@ ATIScreenInit } /* If applicable, initialise RENDER extension */ - if (pATI->bitsPerPixel > 4) { if (pATI->OptionShadowFB) { @@ -521,19 +494,6 @@ ATIScreenInit "RENDER extension not supported with a shadowed" " framebuffer.\n"); } - -#ifndef AVOID_CPIO - - else if (pATI->BankInfo.BankSize) - { - if (serverGeneration == 1) - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "RENDER extension not supported with a banked" - " framebuffer.\n"); - } - -#endif /* AVOID_CPIO */ - else if (!fbPictureInit(pScreen, NULL, 0) && (serverGeneration == 1)) { @@ -544,16 +504,6 @@ ATIScreenInit xf86SetBlackWhitePixels(pScreen); -#ifndef AVOID_CPIO - - /* Initialise banking if needed */ - if (!miInitializeBanking(pScreen, - pScreenInfo->virtualX, pScreenInfo->virtualY, - pATI->displayWidth, &pATI->BankInfo)) - return FALSE; - -#endif /* AVOID_CPIO */ - #ifdef USE_XAA if (!pATI->useEXA) { @@ -612,24 +562,11 @@ ATIScreenInit if (!miCreateDefColormap(pScreen)) return FALSE; -#ifdef AVOID_CPIO - if (!xf86HandleColormaps(pScreen, 256, pATI->rgbBits, ATILoadPalette, NULL, CMAP_PALETTED_TRUECOLOR | CMAP_LOAD_EVEN_IF_OFFSCREEN)) return FALSE; -#else /* AVOID_CPIO */ - - if (pATI->depth > 1) - if (!xf86HandleColormaps(pScreen, (pATI->depth == 4) ? 16 : 256, - pATI->rgbBits, ATILoadPalette, NULL, - CMAP_PALETTED_TRUECOLOR | - CMAP_LOAD_EVEN_IF_OFFSCREEN)) - return FALSE; - -#endif /* AVOID_CPIO */ - /* Initialise shadow framebuffer */ if (pATI->OptionShadowFB && !ShadowFBInit(pScreen, ATIRefreshArea)) diff --git a/src/atistruct.h b/src/atistruct.h index 16bb4fa..e50cbb5 100644 --- a/src/atistruct.h +++ b/src/atistruct.h @@ -160,9 +160,6 @@ typedef struct _ATIHWRec scaler_buf0_offset_u, scaler_buf0_offset_v, scaler_buf1_offset_u, scaler_buf1_offset_v; - /* Clock map pointers */ - const CARD8 *ClockMap, *ClockUnmap; - /* Clock programming data */ int FeedbackDivider, ReferenceDivider, PostDivider; @@ -214,15 +211,6 @@ typedef struct _Mach64ContextRegs3D */ typedef struct _ATIRec { - /* - * Definitions related to XF86Config "Chipset" specifications. - */ - CARD8 Chipset; - - /* - * Adapter-related definitions. - */ - CARD8 Adapter; #ifndef AVOID_CPIO @@ -238,12 +226,6 @@ typedef struct _ATIRec CARD8 Chip; CARD8 ChipClass, ChipRevision, ChipRev, ChipVersion, ChipFoundry; -#ifndef AVOID_CPIO - - CARD8 Coprocessor, ChipHasSUBSYS_CNTL; - -#endif /* AVOID_CPIO */ - /* * Processor I/O decoding definitions. */ @@ -261,8 +243,6 @@ typedef struct _ATIRec * Processor I/O port definitions for VGA Wonder. */ IOADDRESS CPIO_VGAWonder; - CARD8 B2Reg; /* The B2 mirror */ - CARD8 VGAOffset; /* Low index for CPIO_VGAWonder */ #endif /* AVOID_CPIO */ @@ -285,11 +265,9 @@ typedef struct _ATIRec */ pciVideoPtr PCIInfo; CARD8 BusType; - CARD8 SharedAccelerator; #ifndef AVOID_CPIO - CARD8 SharedVGA; resRange VGAWonderResources[2]; #endif /* AVOID_CPIO */ @@ -319,9 +297,7 @@ typedef struct _ATIRec /* * Banking interface. */ - miBankInfoRec BankInfo; pointer pBank; - CARD8 UseSmallApertures; #endif /* AVOID_CPIO */ @@ -378,8 +354,6 @@ typedef struct _ATIRec int ClockNumberToProgramme, ReferenceNumerator, ReferenceDenominator; int ProgrammableClock, maxClock; ClockRec ClockDescriptor; - CARD16 BIOSClocks[16]; - CARD8 Clock; /* * DSP register data. @@ -452,9 +426,6 @@ typedef struct _ATIRec CARD32 config_cntl; - /* Mach8/Mach32 registers */ - CARD16 clock_sel, misc_options, mem_bndry, mem_cfg; - /* VGA Wonder registers */ CARD8 a6, ab, b1, b4, b5, b6, b8, b9, be; @@ -470,8 +441,6 @@ typedef struct _ATIRec /* Mode data */ ATIHWRec OldHW, NewHW; - int MaximumInterlacedPitch; - Bool InterlacedSeen; /* * Resource Access Control entity index. @@ -481,6 +450,7 @@ typedef struct _ATIRec /* * Driver options. */ + unsigned int OptionProbeSparse:1; /* Force probe for fixed (sparse) I/O */ unsigned int OptionAccel:1; /* Use hardware draw engine */ unsigned int OptionBIOSDisplay:1; /* Allow BIOS interference */ unsigned int OptionBlend:1; /* Force horizontal blending */ @@ -488,12 +458,6 @@ typedef struct _ATIRec unsigned int OptionCSync:1; /* Use composite sync */ unsigned int OptionDevel:1; /* Intentionally undocumented */ -#ifndef AVOID_CPIO - - unsigned int OptionLinear:1; /* Use linear aperture if available */ - -#endif /* AVOID_CPIO */ - #ifdef TV_OUT CARD8 OptionTvOut; /* Enable TV out if TV is connected */ @@ -504,7 +468,6 @@ typedef struct _ATIRec unsigned int OptionMMIOCache:1; /* Cache MMIO writes */ unsigned int OptionTestMMIOCache:1;/* Test MMIO cache integrity */ unsigned int OptionPanelDisplay:1; /* Prefer digital panel over CRT */ - unsigned int OptionProbeClocks:1; /* Force probe for fixed clocks */ unsigned int OptionShadowFB:1; /* Use shadow frame buffer */ unsigned int OptionLCDSync:1; /* Temporary */ diff --git a/src/ativalid.c b/src/ativalid.c index c2539a2..8a92e82 100644 --- a/src/ativalid.c +++ b/src/ativalid.c @@ -24,9 +24,7 @@ #include "config.h" #endif -#include "atiadapter.h" #include "atichip.h" -#include "aticrtc.h" #include "atistruct.h" #include "ativalid.h" @@ -48,42 +46,10 @@ ATIValidMode { ScrnInfoPtr pScreenInfo = xf86Screens[iScreen]; ATIPtr pATI = ATIPTR(pScreenInfo); - Bool InterlacedSeen; int HBlankWidth, HAdjust, VScan, VInterlace; -#ifndef AVOID_CPIO - - int VDisplay, VTotal; - -#endif /* AVOID_CPIO */ - if (flags & MODECHECK_FINAL) { - /* - * This is the final check before the common layer accepts a mode. - * pScreenInfo->displayWidth is set to the proposed virtual pitch - * should the mode be accepted. The only check needed here is for - * 18800's and 28800's, which don't support interlaced modes if the - * pitch is over half the chipset's maximum pitch. - */ - if (pATI->MaximumInterlacedPitch) - { - /* - * Ensure no interlaced modes have a scanline pitch larger than the - * limit. - */ - if (pMode->Flags & V_INTERLACE) - InterlacedSeen = TRUE; - else - InterlacedSeen = pATI->InterlacedSeen; - - if (InterlacedSeen && - (pScreenInfo->displayWidth > pATI->MaximumInterlacedPitch)) - return MODE_INTERLACE_WIDTH; - - pATI->InterlacedSeen = InterlacedSeen; - } - return MODE_OK; } @@ -186,52 +152,9 @@ ATIValidMode if (!HBlankWidth) return MODE_HBLANK_NARROW; - switch (pATI->NewHW.crtc) { - -#ifndef AVOID_CPIO - - case ATI_CRTC_VGA: - /* Prevent overscans */ - if (HBlankWidth > 63) - return MODE_HBLANK_WIDE; - - if (pMode->HDisplay > 2048) - return MODE_BAD_HVALUE; - - if (VScan > 64) - return MODE_BAD_VSCAN; - - VDisplay = pMode->VDisplay * VScan; - VTotal = pMode->VTotal * VScan; - - if ((pMode->Flags & V_INTERLACE) && (pATI->Chip < ATI_CHIP_264CT)) - { - VDisplay >>= 1; - VTotal >>= 1; - } - - if ((VDisplay > 2048) || (VTotal > 2050)) - return MODE_BAD_VVALUE; - - if (pATI->Adapter != ATI_ADAPTER_VGA) - break; - - if ((VDisplay > 1024) || (VTotal > 1025)) - return MODE_BAD_VVALUE; - - break; - -#endif /* AVOID_CPIO */ - - case ATI_CRTC_MACH64: if (VScan > 2) return MODE_NO_VSCAN; - - break; - - default: - break; } return MODE_OK; diff --git a/src/ativga.c b/src/ativga.c index 5678c6e..8f4b0da 100644 --- a/src/ativga.c +++ b/src/ativga.c @@ -25,18 +25,11 @@ #endif #include "ati.h" -#include "atiadapter.h" #include "atichip.h" -#include "atimono.h" #include "atistruct.h" #include "ativga.h" #include "ativgaio.h" -#ifndef DPMS_SERVER -# define DPMS_SERVER -#endif -#include <X11/extensions/dpms.h> - #ifndef AVOID_CPIO /* @@ -56,68 +49,32 @@ ATIVGAPreInit /* Initialise sequencer register values */ pATIHW->seq[0] = 0x03U; - if (pATI->depth == 1) - pATIHW->seq[2] = 0x01U << BIT_PLANE; - else pATIHW->seq[2] = 0x0FU; - if (pATI->depth <= 4) - pATIHW->seq[4] = 0x06U; - else if (pATI->Adapter == ATI_ADAPTER_VGA) - pATIHW->seq[4] = 0x0EU; - else pATIHW->seq[4] = 0x0AU; /* Initialise CRTC register values */ - if ((pATI->depth >= 8) && - ((pATI->Chip >= ATI_CHIP_264CT) || - (pATI->CPIO_VGAWonder && - (pATI->Chip <= ATI_CHIP_18800_1) && - (pATI->VideoRAM == 256)))) + if (((pATI->Chip >= ATI_CHIP_264CT))) pATIHW->crt[19] = pATI->displayWidth >> 3; else pATIHW->crt[19] = pATI->displayWidth >> 4; - if ((pATI->depth >= 8) && (pATI->Adapter == ATI_ADAPTER_VGA)) - pATIHW->crt[23] = 0xC3U; - else + pATIHW->crt[23] = 0xE3U; pATIHW->crt[24] = 0xFFU; /* Initialise attribute controller register values */ - if (pATI->depth == 1) - { - Bool FlipPixels = xf86GetFlipPixels(); - - for (Index = 0; Index < 16; Index++) - if (((Index & (0x01U << BIT_PLANE)) != 0) != FlipPixels) - pATIHW->attr[Index] = MONO_WHITE; - else - pATIHW->attr[Index] = MONO_BLACK; - pATIHW->attr[16] = 0x01U; - pATIHW->attr[17] = MONO_OVERSCAN; - } - else { for (Index = 0; Index < 16; Index++) pATIHW->attr[Index] = Index; - if (pATI->depth <= 4) - pATIHW->attr[16] = 0x81U; - else if (pATI->Adapter == ATI_ADAPTER_VGA) - pATIHW->attr[16] = 0x41U; - else + pATIHW->attr[16] = 0x01U; pATIHW->attr[17] = 0xFFU; } pATIHW->attr[18] = 0x0FU; /* Initialise graphics controller register values */ - if (pATI->depth == 1) - pATIHW->gra[4] = BIT_PLANE; - else if (pATI->depth <= 4) - pATIHW->gra[5] = 0x02U; - else if (pATI->Chip >= ATI_CHIP_264CT) + if (pATI->Chip >= ATI_CHIP_264CT) pATIHW->gra[5] = 0x40U; - if (pATI->UseSmallApertures && (pATI->Chip >= ATI_CHIP_264CT) && - ((pATI->Chip >= ATI_CHIP_264VT) || !pATI->LinearBase)) + if (pATI->Chip >= ATI_CHIP_264VT) pATIHW->gra[6] = 0x01U; /* 128kB aperture */ else pATIHW->gra[6] = 0x05U; /* 64kB aperture */ @@ -164,265 +121,6 @@ ATIVGASave } /* - * ATIVGACalculate -- - * - * This function fills in the VGA portion of an ATIHWRec. - */ -void -ATIVGACalculate -( - ATIPtr pATI, - ATIHWPtr pATIHW, - DisplayModePtr pMode -) -{ - int Index, VDisplay; - - /* If not already done, adjust horizontal timings */ - if (!pMode->CrtcHAdjusted) - { - pMode->CrtcHAdjusted = TRUE; - pMode->CrtcHDisplay = (pMode->HDisplay >> 3) - 1; - pMode->CrtcHBlankStart = (pMode->HDisplay >> 3); - if ((pATI->Chip == ATI_CHIP_18800_1) || - (pATI->Chip >= ATI_CHIP_264CT)) - pMode->CrtcHBlankStart--; - pMode->CrtcHSyncStart = pMode->HSyncStart >> 3; - if (pATI->LCDPanelID >= 0) - pMode->CrtcHSyncStart--; - pMode->CrtcHSyncEnd = pMode->HSyncEnd >> 3; - if (pATI->LCDPanelID >= 0) - pMode->CrtcHSyncEnd--; - pMode->CrtcHBlankEnd = (pMode->HTotal >> 3) - 1; - pMode->CrtcHTotal = (pMode->HTotal >> 3) - 5; - pMode->CrtcHSkew = pMode->HSkew; - - /* Check sync pulse width */ - Index = pMode->CrtcHSyncEnd - pMode->CrtcHSyncStart - 0x1F; - if (Index > 0) - { - pMode->CrtcHSyncStart += Index / 2; - pMode->CrtcHSyncEnd = pMode->CrtcHSyncStart + 0x1F; - } - - /* Check blank pulse width */ - Index = pMode->CrtcHBlankEnd - pMode->CrtcHBlankStart - 0x3F; - if (Index > 0) - { - if ((pMode->CrtcHBlankEnd - Index) > pMode->CrtcHSyncEnd) - { - pMode->CrtcHBlankStart += Index / 2; - if (pMode->CrtcHBlankStart >= pMode->CrtcHSyncStart) - pMode->CrtcHBlankStart = pMode->CrtcHSyncStart - 1; - pMode->CrtcHBlankEnd = pMode->CrtcHBlankStart + 0x3F; - } - else - { - Index -= 0x40; - if (Index > 0) - { - pMode->CrtcHBlankStart += Index / 2; - if (pMode->CrtcHBlankStart >= pMode->CrtcHSyncStart) - pMode->CrtcHBlankStart = pMode->CrtcHSyncStart - 1; - pMode->CrtcHBlankEnd = pMode->CrtcHBlankStart + 0x7F; - } - } - } - } - - /* - * Because of the use of CRTC[23] bit 0x04's for vertical doubling, it is - * necessary to always re-adjust vertical timings here. - */ - pMode->CrtcVDisplay = pMode->VDisplay; - pMode->CrtcVBlankStart = pMode->VDisplay; - pMode->CrtcVSyncStart = pMode->VSyncStart; - pMode->CrtcVSyncEnd = pMode->VSyncEnd; - pMode->CrtcVBlankEnd = pMode->VTotal; - pMode->CrtcVTotal = pMode->VTotal; - - /* Adjust for doublescanned modes */ - if (pMode->Flags & V_DBLSCAN) - { - pMode->CrtcVDisplay <<= 1; - pMode->CrtcVBlankStart <<= 1; - pMode->CrtcVSyncStart <<= 1; - pMode->CrtcVSyncEnd <<= 1; - pMode->CrtcVBlankEnd <<= 1; - pMode->CrtcVTotal <<= 1; - } - - /* Adjust for multiscanned modes */ - if (pMode->VScan > 1) - { - pMode->CrtcVDisplay *= pMode->VScan; - pMode->CrtcVBlankStart *= pMode->VScan; - pMode->CrtcVSyncStart *= pMode->VScan; - pMode->CrtcVSyncEnd *= pMode->VScan; - pMode->CrtcVBlankEnd *= pMode->VScan; - pMode->CrtcVTotal *= pMode->VScan; - } - - /* Set up miscellaneous output register value */ - pATIHW->genmo = 0x23U; - if ((pMode->Flags & (V_PHSYNC | V_NHSYNC)) && - (pMode->Flags & (V_PVSYNC | V_NVSYNC))) - { - if (pMode->Flags & V_NHSYNC) - pATIHW->genmo |= 0x40U; - if (pMode->Flags & V_NVSYNC) - pATIHW->genmo |= 0x80U; - } - else - { - pMode->Flags &= ~(V_PHSYNC | V_NHSYNC | V_PVSYNC | V_NVSYNC); - - if (pATI->OptionPanelDisplay && (pATI->LCDPanelID >= 0)) - VDisplay = pATI->LCDVertical; - else - VDisplay = pMode->CrtcVDisplay; - - if (VDisplay < 400) - { - pMode->Flags |= V_PHSYNC | V_NVSYNC; - pATIHW->genmo |= 0x80U; - } - else if (VDisplay < 480) - { - pMode->Flags |= V_NHSYNC | V_PVSYNC; - pATIHW->genmo |= 0x40U; - } - else if (VDisplay < 768) - { - pMode->Flags |= V_NHSYNC | V_NVSYNC; - pATIHW->genmo |= 0xC0U; - } - else - { - pMode->Flags |= V_PHSYNC | V_PVSYNC; - } - } - - /* Adjust for interlaced modes */ - if ((pMode->Flags & V_INTERLACE) && (pATI->Chip < ATI_CHIP_264CT)) - { - pMode->CrtcVDisplay >>= 1; - pMode->CrtcVBlankStart >>= 1; - pMode->CrtcVSyncStart >>= 1; - pMode->CrtcVSyncEnd >>= 1; - pMode->CrtcVBlankEnd >>= 1; - pMode->CrtcVTotal >>= 1; - } - - if (pMode->CrtcVTotal > 1024) - { - pATIHW->crt[23] |= 0x04U; - pMode->CrtcVDisplay >>= 1; - pMode->CrtcVBlankStart >>= 1; - pMode->CrtcVSyncStart >>= 1; - pMode->CrtcVSyncEnd >>= 1; - pMode->CrtcVBlankEnd >>= 1; - pMode->CrtcVTotal >>= 1; - } - else - { - pATIHW->crt[23] &= ~0x04U; - } - - pMode->CrtcVDisplay--; - if (pATI->Chip == ATI_CHIP_18800) - pMode->CrtcVBlankStart++; - else - pMode->CrtcVBlankStart--; - if (pATI->LCDPanelID >= 0) - { - pMode->CrtcVSyncStart--; - pMode->CrtcVSyncEnd--; - } - pMode->CrtcVBlankEnd--; - if (pATI->Chip < ATI_CHIP_264CT) - pMode->CrtcVBlankEnd--; - pMode->CrtcVTotal -= 2; - pMode->CrtcVAdjusted = TRUE; /* Redundant */ - - /* Check sync pulse width */ - Index = pMode->CrtcVSyncEnd - pMode->CrtcVSyncStart - 0x0F; - if (Index > 0) - { - pMode->CrtcVSyncStart += Index / 2; - pMode->CrtcVSyncEnd = pMode->CrtcVSyncStart + 0x0F; - } - - /* Check blank pulse width */ - Index = pMode->CrtcVBlankEnd - pMode->CrtcVBlankStart - 0x00FF; - if (Index > 0) - { - if ((pMode->CrtcVBlankEnd - Index) > pMode->CrtcVSyncEnd) - { - pMode->CrtcVBlankStart += Index / 2; - if (pMode->CrtcVBlankStart >= pMode->CrtcVSyncStart) - pMode->CrtcVBlankStart = pMode->CrtcVSyncStart - 1; - pMode->CrtcVBlankEnd = pMode->CrtcVBlankStart + 0x00FF; - } - else - { - Index -= 0x0100; - if (Index > 0) - { - pMode->CrtcVBlankStart += Index / 2; - if (pMode->CrtcVBlankStart >= pMode->CrtcVSyncStart) - pMode->CrtcVBlankStart = pMode->CrtcVSyncStart - 1; - pMode->CrtcVBlankEnd = pMode->CrtcVBlankStart + 0x01FF; - } - } - } - - /* Set up sequencer register values */ - if (pMode->Flags & V_CLKDIV2) - pATIHW->seq[1] = 0x09U; - else - pATIHW->seq[1] = 0x01U; - - /* Set up CRTC register values */ - pATIHW->crt[0] = pMode->CrtcHTotal; - pATIHW->crt[1] = pMode->CrtcHDisplay; - pATIHW->crt[2] = pMode->CrtcHBlankStart; - pATIHW->crt[3] = (pMode->CrtcHBlankEnd & 0x1FU) | 0x80U; - Index = ((pMode->CrtcHSkew << 2) + 0x10U) & ~0x1FU; - if (Index < 0x0080) - pATIHW->crt[3] |= Index; - pATIHW->crt[4] = pMode->CrtcHSyncStart; - pATIHW->crt[5] = ((pMode->CrtcHBlankEnd & 0x20U) << 2) | - ((pMode->CrtcHSyncEnd & 0x1FU) ); - pATIHW->crt[6] = pMode->CrtcVTotal & 0xFFU; - pATIHW->crt[7] = ((pMode->CrtcVTotal & 0x0100U) >> 8) | - ((pMode->CrtcVDisplay & 0x0100U) >> 7) | - ((pMode->CrtcVSyncStart & 0x0100U) >> 6) | - ((pMode->CrtcVBlankStart & 0x0100U) >> 5) | - 0x10U | - ((pMode->CrtcVTotal & 0x0200U) >> 4) | - ((pMode->CrtcVDisplay & 0x0200U) >> 3) | - ((pMode->CrtcVSyncStart & 0x0200U) >> 2); - pATIHW->crt[9] = ((pMode->CrtcVBlankStart & 0x0200U) >> 4) | 0x40U; - /* - * Doublescanned modes are missing the top scanline. Convert - * doublescanning to multiscanning, using the doublescan bit only as a last - * resort. - */ - if ((Index = pMode->VScan) <= 0) - Index = 1; - if (pMode->Flags & V_DBLSCAN) - Index <<= 1; - Index--; - pATIHW->crt[9] |= (Index & 0x1FU) | ((Index & 0x20U) << 2); - pATIHW->crt[16] = pMode->CrtcVSyncStart & 0xFFU; - pATIHW->crt[17] = (pMode->CrtcVSyncEnd & 0x0FU) | 0x20U; - pATIHW->crt[18] = pMode->CrtcVDisplay & 0xFFU; - pATIHW->crt[21] = pMode->CrtcVBlankStart & 0xFFU; - pATIHW->crt[22] = pMode->CrtcVBlankEnd & 0xFFU; -} - -/* * ATIVGASet -- * * This function is called to load the VGA portion of a video state. @@ -494,53 +192,4 @@ ATIVGASaveScreen } } -/* - * ATIVGASetDPMSMode -- - * - * This function sets a VGA's VESA Display Power Management Signaling mode. - */ -void -ATIVGASetDPMSMode -( - ATIPtr pATI, - int DPMSMode -) -{ - CARD8 seq1, crt17; - - switch (DPMSMode) - { - case DPMSModeOn: /* HSync on, VSync on */ - seq1 = 0x00U; - crt17 = 0x80U; - break; - - case DPMSModeStandby: /* HSync off, VSync on -- unsupported */ - seq1 = 0x20U; - crt17 = 0x80U; - break; - - case DPMSModeSuspend: /* HSync on, VSync off -- unsupported */ - seq1 = 0x20U; - crt17 = 0x80U; - break; - - case DPMSModeOff: /* HSync off, VSync off */ - seq1 = 0x20U; - crt17 = 0x00U; - break; - - default: /* Muffle compiler */ - return; - } - - PutReg(SEQX, 0x00U, 0x01U); /* Start synchonous reset */ - seq1 |= GetReg(SEQX, 0x01U) & ~0x20U; - PutReg(SEQX, 0x01U, seq1); - crt17 |= GetReg(CRTX(pATI->CPIO_VGABase), 0x17U) & ~0x80U; - usleep(10000); - PutReg(CRTX(pATI->CPIO_VGABase), 0x17U, crt17); - PutReg(SEQX, 0x01U, 0x03U); /* End synchonous reset */ -} - #endif /* AVOID_CPIO */ diff --git a/src/ativga.h b/src/ativga.h index 90c3ef4..3dd6f0e 100644 --- a/src/ativga.h +++ b/src/ativga.h @@ -31,11 +31,9 @@ extern void ATIVGAPreInit(ATIPtr, ATIHWPtr); extern void ATIVGASave(ATIPtr, ATIHWPtr); -extern void ATIVGACalculate(ATIPtr, ATIHWPtr, DisplayModePtr); extern void ATIVGASet(ATIPtr, ATIHWPtr); extern void ATIVGASaveScreen(ATIPtr, int); -extern void ATIVGASetDPMSMode(ATIPtr, int); #endif /* AVOID_CPIO */ diff --git a/src/ativgaio.h b/src/ativgaio.h index 0409a72..c73e8ae 100644 --- a/src/ativgaio.h +++ b/src/ativgaio.h @@ -29,9 +29,11 @@ #define ___ATIVGAIO_H___ 1 -#include "atiio.h" +#include "atiregs.h" #include "atipriv.h" +#include "compiler.h" + #ifndef AVOID_CPIO extern void ATISetVGAIOBase(ATIPtr, const CARD8); diff --git a/src/atividmem.c b/src/atividmem.c index d06ca7c..99560f5 100644 --- a/src/atividmem.c +++ b/src/atividmem.c @@ -25,7 +25,6 @@ #endif #include "ati.h" -#include "atiadapter.h" #include "atistruct.h" #include "atividmem.h" @@ -87,7 +86,7 @@ ATIUnmapVGA xf86UnMapVidMem(iScreen, pATI->pBank, 0x00010000U); - pATI->pBank = pATI->BankInfo.pBankA = pATI->BankInfo.pBankB = NULL; + pATI->pBank = NULL; } #endif /* AVOID_CPIO */ @@ -104,18 +103,7 @@ ATIUnmapLinear ATIPtr pATI ) { - -#ifdef AVOID_CPIO - - if (!pATI->pMemory) - return; - -#else /* AVOID_CPIO */ - - if (pATI->pMemory != pATI->pBank) - -#endif /* AVOID_CPIO */ - + if (pATI->pMemory) { xf86UnMapVidMem(iScreen, pATI->pMemory, pATI->LinearSize); @@ -179,35 +167,17 @@ ATIMapApertures ATIPtr pATI ) { - pciVideoPtr pVideo; - PCITAG Tag; - unsigned long PageSize; + pciVideoPtr pVideo = pATI->PCIInfo; + PCITAG Tag = ((pciConfigPtr)(pVideo->thisCard))->tag; + unsigned long PageSize = getpagesize(); if (pATI->Mapped) return TRUE; #ifndef AVOID_CPIO - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - -#endif /* AVOID_CPIO */ - - { - if (!pATI->LinearBase && !pATI->Block0Base) - return FALSE; - } - - PageSize = getpagesize(); - - if ((pVideo = pATI->PCIInfo)) - Tag = ((pciConfigPtr)(pVideo->thisCard))->tag; - else - Tag = 0; - -#ifndef AVOID_CPIO - /* Map VGA aperture */ - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + if (pATI->VGAAdapter) { /* * No relocation, resizing, caching or write-combining of this @@ -223,10 +193,6 @@ ATIMapApertures if (!pATI->pBank) return FALSE; - pATI->pMemory = - pATI->BankInfo.pBankA = - pATI->BankInfo.pBankB = pATI->pBank; - pATI->Mapped = TRUE; } diff --git a/src/atiwonder.c b/src/atiwonder.c index e6a4ec2..371e251 100644 --- a/src/atiwonder.c +++ b/src/atiwonder.c @@ -74,21 +74,12 @@ ATIVGAWonderPreInit ) { pATIHW->b3 = ATIGetExtReg(0xB3U) & 0x20U; - if (pATI->depth <= 4) - pATIHW->b6 = 0x40U; - else pATIHW->b6 = 0x04U; - if (pATI->Chip <= ATI_CHIP_18800) - pATIHW->ba = 0x08U; - else if (pATI->Chip >= ATI_CHIP_28800_2) - { - if (pATI->VideoRAM > 256) - pATIHW->b6 |= 0x01U; + pATIHW->b6 |= 0x01U; pATIHW->bf = ATIGetExtReg(0xBFU) & 0x5FU; pATIHW->a3 = ATIGetExtReg(0xA3U) & 0x67U; pATIHW->ab = ATIGetExtReg(0xABU) & 0xE7U; pATIHW->ae = ATIGetExtReg(0xAEU) & 0xE0U; - } } /* @@ -114,10 +105,8 @@ ATIVGAWonderSave pATIHW->b9 = ATIGetExtReg(0xB9U); pATIHW->ba = ATIGetExtReg(0xBAU); pATIHW->bd = ATIGetExtReg(0xBDU); - if (pATI->Chip > ATI_CHIP_18800) { pATIHW->be = ATIGetExtReg(0xBEU); - if (pATI->Chip >= ATI_CHIP_28800_2) { pATIHW->bf = ATIGetExtReg(0xBFU); pATIHW->a3 = ATIGetExtReg(0xA3U); @@ -132,138 +121,6 @@ ATIVGAWonderSave } /* - * ATIVGAWonderCalculate -- - * - * This function fills in the VGA Wonder portion of an ATIHWRec structure - * occurrence. - */ -void -ATIVGAWonderCalculate -( - ATIPtr pATI, - ATIHWPtr pATIHW, - DisplayModePtr pMode -) -{ - /* Set up the default horizontal display enable skew */ - if ((pATI->Chip >= ATI_CHIP_28800_2) && (pATI->Chip <= ATI_CHIP_28800_6) && - !(pMode->Flags & V_HSKEW)) - { - /* - * Modes using the higher clock frequencies need a non-zero Display - * Enable Skew. The following number has been empirically determined - * to be somewhere between 4.2 and 4.7 MHz. - */ -# define DisplayEnableSkewThreshold 4500 - - /* Set a reasonable default Display Enable Skew */ - pMode->HSkew = pMode->CrtcHSkew = - ATIDivide(pMode->SynthClock, DisplayEnableSkewThreshold, 0, 0); - } - pMode->Flags |= V_HSKEW; - - /* - * Fill in mode-specific VGA Wonder data. - */ - pATIHW->b0 = 0x00U; - if (pATI->depth >= 8) - pATIHW->b0 = 0x20U; - if (pATI->Chip >= ATI_CHIP_28800_2) - { - if (pATI->VideoRAM > 512) - pATIHW->b0 |= 0x08U; - else if (pATI->VideoRAM > 256) - pATIHW->b0 |= 0x10U; - } - else if (pATI->depth <= 4) - { - if (pATI->VideoRAM > 256) - pATIHW->b0 |= 0x08U; - } - else - { - if (pATI->VideoRAM > 256) - pATIHW->b0 |= 0x18U; - else - pATIHW->b0 |= 0x06U; - } - pATIHW->b1 = ATIGetExtReg(0xB1U) & 0x04U; - /* - * Setting the following bit causes hangs on return to text mode from - * packed modes on 18800-1's. The hang occurs because the adapter's I/O - * response is completely disabled when the register is rewritten. The - * adapter can then only be re-enabled with a powerdown. The bit, when on, - * blanks out the overscan. - */ - if ((pATI->Chip == ATI_CHIP_18800_1) && (pATI->depth >= 8)) - pATIHW->b5 = 0x00U; - else - pATIHW->b5 = 0x01U; - pATIHW->b8 = ATIGetExtReg(0xB8U) & 0xC0U; - pATIHW->b9 = ATIGetExtReg(0xB9U) & 0x7FU; - pATIHW->bd = ATIGetExtReg(0xBDU) & 0x02U; - if (pATI->Chip <= ATI_CHIP_18800) - pATIHW->b2 = ATIGetExtReg(0xB2U) & 0xC0U; - else - { - pATIHW->b2 = 0x00U; - pATIHW->be = (ATIGetExtReg(0xBEU) & 0x30U) | 0x09U; - if (pATI->Chip >= ATI_CHIP_28800_2) - { - pATIHW->a6 = (ATIGetExtReg(0xA6U) & 0x38U) | 0x04U; - pATIHW->a7 = (ATIGetExtReg(0xA7U) & 0xBEU) ; - pATIHW->ac = (ATIGetExtReg(0xACU) & 0x8EU) ; - } - } - if (pMode->Flags & V_INTERLACE) - { /* Enable interlace */ - if (pATI->Chip <= ATI_CHIP_18800) - pATIHW->b2 |= 0x01U; - else - pATIHW->be |= 0x02U; - } -#if 0 /* This is no longer needed but is left in for reference */ - if (pMode->Flags & V_DBLSCAN) /* Enable doublescan */ - pATIHW->b1 |= 0x08U; -#endif - if (pATI->OptionCSync || (pMode->Flags & (V_CSYNC | V_PCSYNC))) - pATIHW->bd |= 0x08U; /* Enable composite sync */ - if (pMode->Flags & V_NCSYNC) - pATIHW->bd |= 0x09U; /* Invert composite sync */ - if (pMode->HSkew > 0) - { - if (pMode->HSkew <= 3) - pATIHW->b5 |= 0x04U; - else if (pATI->Chip >= ATI_CHIP_28800_2) - switch ((pMode->HSkew + 4) >> 3) - { - case 1: /* Use ATI override */ - pATIHW->crt[3] &= ~0x60U; - pATIHW->b0 |= 0x01U; - break; - case 2: /* Use ATI override */ - pATIHW->crt[3] &= ~0x60U; - pATIHW->a6 |= 0x01U; - break; - case 3: - pATIHW->crt[3] |= 0x60U; - break; - case 4: - pATIHW->a7 |= 0x40U; - break; - case 5: - pATIHW->ac |= 0x10U; - break; - case 6: - pATIHW->ac |= 0x20U; - break; - default: - break; - } - } -} - -/* * ATIVGAWonderSet -- * * This function loads the VGA Wonder portion of a video state. @@ -275,12 +132,8 @@ ATIVGAWonderSet ATIHWPtr pATIHW ) { - if (pATI->Chip <= ATI_CHIP_18800) - ATIModifyExtReg(pATI, 0xB2U, -1, 0x00U, pATIHW->b2); - else { ATIModifyExtReg(pATI, 0xBEU, -1, 0x00U, pATIHW->be); - if (pATI->Chip >= ATI_CHIP_28800_2) { ATIModifyExtReg(pATI, 0xBFU, -1, 0x00U, pATIHW->bf); ATIModifyExtReg(pATI, 0xA3U, -1, 0x00U, pATIHW->a3); diff --git a/src/atiwonder.h b/src/atiwonder.h index 1412be2..2fe5e5e 100644 --- a/src/atiwonder.h +++ b/src/atiwonder.h @@ -31,7 +31,6 @@ extern void ATIVGAWonderPreInit(ATIPtr, ATIHWPtr); extern void ATIVGAWonderSave(ATIPtr, ATIHWPtr); -extern void ATIVGAWonderCalculate(ATIPtr, ATIHWPtr, DisplayModePtr); extern void ATIVGAWonderSet(ATIPtr, ATIHWPtr); #endif /* AVOID_CPIO */ diff --git a/src/atiwonderio.c b/src/atiwonderio.c index 79293d8..e6c0db7 100644 --- a/src/atiwonderio.c +++ b/src/atiwonderio.c @@ -60,29 +60,6 @@ ATIModifyExtReg if (CurrentValue == NewValue) return; - /* - * The following is taken from ATI's VGA Wonder programmer's reference - * manual which says that this is needed to "ensure the proper state of the - * 8/16 bit ROM toggle". I suspect a timing glitch appeared in the 18800 - * after its die was cast. 18800-1 and later chips do not exhibit this - * problem. - */ - if ((pATI->Chip <= ATI_CHIP_18800) && (Index == 0xB2U) && - ((NewValue ^ 0x40U) & CurrentValue & 0x40U)) - { - CARD8 misc = inb(R_GENMO); - CARD8 bb = ATIGetExtReg(0xBBU); - - outb(GENMO, (misc & 0xF3U) | 0x04U | ((bb & 0x10U) >> 1)); - CurrentValue &= (CARD8)(~0x40U); - ATIPutExtReg(0xB2U, CurrentValue); - ATIDelay(5); - outb(GENMO, misc); - ATIDelay(5); - if (CurrentValue != NewValue) - ATIPutExtReg(0xB2U, NewValue); - } - else ATIPutExtReg(Index, NewValue); } diff --git a/src/atixv.c b/src/atixv.c index 35223ec..ef86ec3 100644 --- a/src/atixv.c +++ b/src/atixv.c @@ -24,7 +24,6 @@ #include "config.h" #endif -#include "atiadapter.h" #include "atimach64xv.h" #include "atistruct.h" #include "atixv.h" @@ -68,16 +67,9 @@ ATIXVInitializeAdaptor XF86VideoAdaptorPtr *ppAdaptor = NULL; int nAdaptor; - switch (pATI->Adapter) { - case ATI_ADAPTER_MACH64: nAdaptor = ATIMach64XVInitialiseAdaptor(pScreen, pScreenInfo, pATI, &ppAdaptor); - break; - - default: - nAdaptor = 0; - break; } if (pppAdaptor) @@ -100,15 +92,6 @@ ATIXVPreInit ATIPtr pATI ) { - -#ifndef AVOID_CPIO - - /* Currently a linear aperture is needed ... */ - if (!pATI->LinearBase) - return; - -#endif /* AVOID_CPIO */ - (void)xf86XVRegisterGenericAdaptorDriver(ATIXVInitializeAdaptor); } @@ -129,9 +112,7 @@ ATIInitializeXVideo int nAdaptor; Bool result; - if (!(pScreenInfo->memPhysBase = pATI->LinearBase)) - return FALSE; - + pScreenInfo->memPhysBase = pATI->LinearBase; pScreenInfo->fbOffset = 0; nAdaptor = xf86XVListGenericAdaptors(pScreenInfo, &ppAdaptor); @@ -156,13 +137,5 @@ ATICloseXVideo ATIPtr pATI ) { - switch (pATI->Adapter) - { - case ATI_ADAPTER_MACH64: ATIMach64CloseXVideo(pScreen, pScreenInfo, pATI); - break; - - default: - break; - } } |