Add proper PCI/AGP detection, based on Mike Harris's code for Radeon, but

using the MMIO mirror of the bits instead of config space.
This commit is contained in:
Eric Anholt 2004-09-14 06:26:54 +00:00
parent d9df39ee2b
commit ba3b6fd23b
2 changed files with 22 additions and 19 deletions

View File

@ -698,31 +698,23 @@ static Bool
ATIIsAGP(ATICardInfo *atic) ATIIsAGP(ATICardInfo *atic)
{ {
char *mmio = atic->reg_base; char *mmio = atic->reg_base;
CARD32 agp_command; CARD32 cap_ptr, cap_id;
Bool is_agp = FALSE;
if (mmio == NULL) if (mmio == NULL)
return FALSE; return FALSE;
if (atic->is_radeon) { if (MMIO_IN32(mmio, ATI_REG_PCI_CFG_STATUS) & ATI_CAP_LIST) {
/* XXX: Apparently this doesn't work. Maybe it needs to be done cap_ptr = MMIO_IN32(mmio, ATI_REG_PCI_CFG_CAPABILITIES_PTR) &
* through the PCI config aperture then. ATI_CAP_PTR_MASK;
*/ while (cap_ptr != ATI_CAP_ID_NULL) {
agp_command = MMIO_IN32(mmio, RADEON_REG_AGP_COMMAND); cap_id = MMIO_IN32(mmio, ATI_PCI_CFG_OFFSET + cap_ptr);
MMIO_OUT32(mmio, RADEON_REG_AGP_COMMAND, agp_command | if ((cap_id & 0xff) == ATI_CAP_ID_AGP)
RADEON_AGP_ENABLE); return TRUE;
if (MMIO_IN32(mmio, RADEON_REG_AGP_COMMAND) & RADEON_AGP_ENABLE) cap_ptr = (cap_id >> 8) & ATI_CAP_PTR_MASK;
is_agp = TRUE; }
MMIO_OUT32(mmio, RADEON_REG_AGP_COMMAND, agp_command);
} else {
/* Don't know any way to detect R128 AGP automatically, so
* assume AGP for all cards not marked as PCI-only by XFree86.
*/
if ((atic->pci_id->caps & CAP_FEATURESMASK) != CAP_NOAGP)
is_agp = TRUE;
} }
return is_agp; return FALSE;
} }
/* This function is required to work around a hardware bug in some (all?) /* This function is required to work around a hardware bug in some (all?)

View File

@ -283,6 +283,17 @@
# define R128_BM_PM4_RD_FORCE_TO_PCI (1 << 22) # define R128_BM_PM4_RD_FORCE_TO_PCI (1 << 22)
# define R128_BM_GLOBAL_FORCE_TO_PCI (1 << 23) # define R128_BM_GLOBAL_FORCE_TO_PCI (1 << 23)
/* Offset of the PCI config space mirror */
#define ATI_PCI_CFG_OFFSET 0x0f00
#define ATI_REG_PCI_CFG_STATUS 0x0f06
# define ATI_CAP_LIST 0x0010
#define ATI_REG_PCI_CFG_CAPABILITIES_PTR 0x0f34
# define ATI_CAP_PTR_MASK 0x00fc
# define ATI_CAP_ID_NULL 0x0000 /* End of capability list */
# define ATI_CAP_ID_AGP 0x0002 /* AGP capability ID */
#define R128_REG_AGP_COMMAND 0x0f58 #define R128_REG_AGP_COMMAND 0x0f58
# define R128_AGP_ENABLE (1 << 8) # define R128_AGP_ENABLE (1 << 8)