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:
parent
d9df39ee2b
commit
ba3b6fd23b
|
@ -698,31 +698,23 @@ static Bool
|
|||
ATIIsAGP(ATICardInfo *atic)
|
||||
{
|
||||
char *mmio = atic->reg_base;
|
||||
CARD32 agp_command;
|
||||
Bool is_agp = FALSE;
|
||||
CARD32 cap_ptr, cap_id;
|
||||
|
||||
if (mmio == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (atic->is_radeon) {
|
||||
/* XXX: Apparently this doesn't work. Maybe it needs to be done
|
||||
* through the PCI config aperture then.
|
||||
*/
|
||||
agp_command = MMIO_IN32(mmio, RADEON_REG_AGP_COMMAND);
|
||||
MMIO_OUT32(mmio, RADEON_REG_AGP_COMMAND, agp_command |
|
||||
RADEON_AGP_ENABLE);
|
||||
if (MMIO_IN32(mmio, RADEON_REG_AGP_COMMAND) & RADEON_AGP_ENABLE)
|
||||
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;
|
||||
if (MMIO_IN32(mmio, ATI_REG_PCI_CFG_STATUS) & ATI_CAP_LIST) {
|
||||
cap_ptr = MMIO_IN32(mmio, ATI_REG_PCI_CFG_CAPABILITIES_PTR) &
|
||||
ATI_CAP_PTR_MASK;
|
||||
while (cap_ptr != ATI_CAP_ID_NULL) {
|
||||
cap_id = MMIO_IN32(mmio, ATI_PCI_CFG_OFFSET + cap_ptr);
|
||||
if ((cap_id & 0xff) == ATI_CAP_ID_AGP)
|
||||
return TRUE;
|
||||
cap_ptr = (cap_id >> 8) & ATI_CAP_PTR_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
return is_agp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* This function is required to work around a hardware bug in some (all?)
|
||||
|
|
|
@ -283,6 +283,17 @@
|
|||
# define R128_BM_PM4_RD_FORCE_TO_PCI (1 << 22)
|
||||
# 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_AGP_ENABLE (1 << 8)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user