diff --git a/sys/dev/drm/drm_agpsupport.c b/sys/dev/drm/drm_agpsupport.c index f809acb7f166..3d657da18ab9 100644 --- a/sys/dev/drm/drm_agpsupport.c +++ b/sys/dev/drm/drm_agpsupport.c @@ -46,7 +46,7 @@ static int drm_device_find_capability(drm_device_t *dev, int cap) { #ifdef __FreeBSD__ -#if __FreeBSD_version >= 700010 +#if __FreeBSD_version >= 602102 return (pci_find_extcap(dev->device, cap, NULL) == 0); #else diff --git a/sys/pci/agp.c b/sys/pci/agp.c index 6757ebc60316..b44cfc94a31b 100644 --- a/sys/pci/agp.c +++ b/sys/pci/agp.c @@ -101,33 +101,12 @@ agp_flush_cache() u_int8_t agp_find_caps(device_t dev) { - u_int32_t status; - u_int8_t ptr, next; + int capreg; - /* - * Check the CAP_LIST bit of the PCI status register first. - */ - status = pci_read_config(dev, PCIR_STATUS, 2); - if (!(status & 0x10)) - return 0; - /* - * Traverse the capabilities list. - */ - for (ptr = pci_read_config(dev, AGP_CAPPTR, 1); - ptr != 0; - ptr = next) { - u_int32_t capid = pci_read_config(dev, 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 ptr; - } - - return 0; + if (pci_find_extcap(dev, PCIY_AGP, &capreg) != 0) + capreg = 0; + return (capreg); } /* diff --git a/sys/pci/agpreg.h b/sys/pci/agpreg.h index 8e5365e952f6..7786efe5fa52 100644 --- a/sys/pci/agpreg.h +++ b/sys/pci/agpreg.h @@ -32,18 +32,12 @@ /* * Offsets for various AGP configuration registers. */ -#define AGP_APBASE 0x10 -#define AGP_CAPPTR 0x34 +#define AGP_APBASE PCIR_BAR(0) /* * Offsets from the AGP Capability pointer. */ #define AGP_CAPID 0x0 -#define AGP_CAPID_GET_MAJOR(x) (((x) & 0x00f00000U) >> 20) -#define AGP_CAPID_GET_MINOR(x) (((x) & 0x000f0000U) >> 16) -#define AGP_CAPID_GET_NEXT_PTR(x) (((x) & 0x0000ff00U) >> 8) -#define AGP_CAPID_GET_CAP_ID(x) (((x) & 0x000000ffU) >> 0) - #define AGP_STATUS 0x4 #define AGP_COMMAND 0x8 #define AGP_STATUS_AGP3 0x0008