xserver/hw/kdrive/ati ati.c,1.18,1.19 ati_reg.h,1.8,1.9
Eric Anholt
xserver-commit at pdx.freedesktop.org
Mon Sep 13 23:26:56 PDT 2004
Committed by: anholt
Update of /cvs/xserver/xserver/hw/kdrive/ati
In directory gabe:/tmp/cvs-serv5936/hw/kdrive/ati
Modified Files:
ati.c ati_reg.h
Log Message:
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.
Index: ati.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- ati.c 24 Jul 2004 17:02:49 -0000 1.18
+++ ati.c 14 Sep 2004 06:26:53 -0000 1.19
@@ -698,31 +698,23 @@
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?)
Index: ati_reg.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_reg.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ati_reg.h 11 Sep 2004 09:28:19 -0000 1.8
+++ ati_reg.h 14 Sep 2004 06:26:54 -0000 1.9
@@ -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)
More information about the xserver-commit
mailing list