summaryrefslogtreecommitdiff
path: root/bsd-core/drm_agpsupport.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2005-01-17 20:24:52 +0000
committerEric Anholt <anholt@freebsd.org>2005-01-17 20:24:52 +0000
commit7d0cb01cbf620e090230978ccee6cf7a882c832c (patch)
tree31d7eab6ab05aaaf1c6d6087503e44b8e5cee96f /bsd-core/drm_agpsupport.c
parentc74052cfae9cf3929e692551ce657f8fb55b6f08 (diff)
Add detection of whether the device is AGP by walking the capabilities
list.
Diffstat (limited to 'bsd-core/drm_agpsupport.c')
-rw-r--r--bsd-core/drm_agpsupport.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/bsd-core/drm_agpsupport.c b/bsd-core/drm_agpsupport.c
index e26be833..ff890e27 100644
--- a/bsd-core/drm_agpsupport.c
+++ b/bsd-core/drm_agpsupport.c
@@ -32,11 +32,47 @@
#include "drmP.h"
+#ifdef __FreeBSD__
+#include <pci/agpreg.h>
+#include <dev/pci/pcireg.h>
+#endif
+
int
drm_device_is_agp(drm_device_t *dev)
{
- /* XXX: FILL ME IN HERE */
+#ifdef __FreeBSD__
+ /* Code taken from agp.c. IWBNI that was a public interface. */
+ u_int32_t status;
+ u_int8_t ptr, next;
+
+ /*
+ * Check the CAP_LIST bit of the PCI status register first.
+ */
+ status = pci_read_config(dev->device, PCIR_STATUS, 2);
+ if (!(status & 0x10))
+ return 0;
+
+ /*
+ * Traverse the capabilities list.
+ */
+ for (ptr = pci_read_config(dev->device, AGP_CAPPTR, 1);
+ ptr != 0;
+ ptr = next) {
+ u_int32_t capid = pci_read_config(dev->device, ptr, 4);
+ next = AGP_CAPID_GET_NEXT_PTR(capid);
+
+ /*
+ * If this capability entry ID is 2, then we are done.
+ */
+ if (AGP_CAPID_GET_CAP_ID(capid) == 2)
+ return 1;
+ }
+
+ return 0;
+#else
+ /* XXX: fill me in for non-FreeBSD */
return 1;
+#endif
}
int drm_agp_info(DRM_IOCTL_ARGS)