From 31935f454f6fc81b04c4d9411923d7d58935d96f Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 6 Jul 2009 18:55:08 +0800 Subject: [PATCH] agp/drm: Adapt according to the recent pci code change Submitted-by: hasso@ --- sys/dev/agp/agp.c | 30 ++++-------------------------- sys/dev/agp/agp_i810.c | 16 +++------------- sys/dev/drm/drm_agpsupport.c | 29 +---------------------------- sys/dev/drm/drm_drv.c | 11 ++--------- sys/dev/drm/i915_drv.c | 8 -------- sys/dev/drm/mach64_drv.c | 4 ---- sys/dev/drm/mga_drv.c | 4 ---- sys/dev/drm/r128_drv.c | 4 ---- sys/dev/drm/radeon_drv.c | 4 ---- sys/dev/drm/savage_drv.c | 4 ---- sys/dev/drm/sis_drv.c | 4 ---- sys/dev/drm/tdfx_drv.c | 4 ---- 12 files changed, 10 insertions(+), 112 deletions(-) diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c index 32d809b99d..18660c33b4 100644 --- a/sys/dev/agp/agp.c +++ b/sys/dev/agp/agp.c @@ -91,33 +91,11 @@ agp_flush_cache(void) 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/dev/agp/agp_i810.c b/sys/dev/agp/agp_i810.c index 617cf77de4..a63e9b621c 100644 --- a/sys/dev/agp/agp_i810.c +++ b/sys/dev/agp/agp_i810.c @@ -216,7 +216,8 @@ agp_i810_find_bridge(device_t dev) match = agp_i810_match(dev); devid = match->devid - match->bridge_offset; - if (device_get_children(device_get_parent(dev), &children, &nchildren)) + if (device_get_children(device_get_parent(device_get_parent(dev)), + &children, &nchildren)) return 0; for (i = 0; i < nchildren; i++) { @@ -679,11 +680,6 @@ agp_i810_attach(device_t dev) gatt->ag_physical = pgtblctl & ~1; } - /* Add a device for the drm to attach to */ - /* XXX This will go away once we have vgapci */ - if (!device_add_child(dev, "drmsub", -1)) - device_printf(dev, "could not add drm subdevice\n"); - if (0) agp_i810_dump_regs(dev); @@ -694,7 +690,6 @@ static int agp_i810_detach(device_t dev) { struct agp_i810_softc *sc = device_get_softc(dev); - device_t child; agp_free_cdev(dev); @@ -719,11 +714,6 @@ agp_i810_detach(device_t dev) bus_release_resources(dev, sc->sc_res_spec, sc->sc_res); agp_free_res(dev); - /* XXX This will go away once we have vgapci */ - child = device_find_child(dev, "drmsub", 0); - if (child != NULL) - device_delete_child(dev, child); - return 0; } @@ -1134,6 +1124,6 @@ static driver_t agp_i810_driver = { static devclass_t agp_devclass; -DRIVER_MODULE(agp_i810, pci, agp_i810_driver, agp_devclass, 0, 0); +DRIVER_MODULE(agp_i810, vgapci, agp_i810_driver, agp_devclass, 0, 0); MODULE_DEPEND(agp_i810, agp, 1, 1, 1); MODULE_DEPEND(agp_i810, pci, 1, 1, 1); diff --git a/sys/dev/drm/drm_agpsupport.c b/sys/dev/drm/drm_agpsupport.c index c610c03df7..66bc6a78a2 100644 --- a/sys/dev/drm/drm_agpsupport.c +++ b/sys/dev/drm/drm_agpsupport.c @@ -42,34 +42,7 @@ static int drm_device_find_capability(struct drm_device *dev, int cap) { - /* 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 cap, then we are done. - */ - if (AGP_CAPID_GET_CAP_ID(capid) == cap) - return 1; - } - - return 0; + return (pci_find_extcap(dev->device, cap, NULL) == 0); } int drm_device_is_agp(struct drm_device *dev) diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 1342e5e60c..231637fb8e 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -157,20 +157,13 @@ int drm_probe(device_t kdev, drm_pci_id_list_t *idlist) { drm_pci_id_list_t *id_entry; int vendor, device; - device_t realdev; - if (!strcmp(device_get_name(kdev), "drmsub")) - realdev = device_get_parent(kdev); - else - realdev = kdev; - vendor = pci_get_vendor(realdev); - device = pci_get_device(realdev); + vendor = pci_get_vendor(kdev); + device = pci_get_device(kdev); -#if 0 /* XXX */ if (pci_get_class(kdev) != PCIC_DISPLAY || pci_get_subclass(kdev) != PCIS_DISPLAY_VGA) return ENXIO; -#endif id_entry = drm_find_description(vendor, device, idlist); if (id_entry != NULL) { diff --git a/sys/dev/drm/i915_drv.c b/sys/dev/drm/i915_drv.c index 1736612fd9..60b37edf03 100644 --- a/sys/dev/drm/i915_drv.c +++ b/sys/dev/drm/i915_drv.c @@ -143,19 +143,11 @@ static device_method_t i915_methods[] = { }; static driver_t i915_driver = { -#if __FreeBSD_version >= 700010 "drm", -#else - "drmsub", -#endif i915_methods, sizeof(struct drm_device) }; extern devclass_t drm_devclass; -#if __FreeBSD_version >= 700010 DRIVER_MODULE(i915, vgapci, i915_driver, drm_devclass, 0, 0); -#else -DRIVER_MODULE(i915, agp, i915_driver, drm_devclass, 0, 0); -#endif MODULE_DEPEND(i915, drm, 1, 1, 1); diff --git a/sys/dev/drm/mach64_drv.c b/sys/dev/drm/mach64_drv.c index e3af15bd82..8abf99097d 100644 --- a/sys/dev/drm/mach64_drv.c +++ b/sys/dev/drm/mach64_drv.c @@ -126,9 +126,5 @@ static driver_t mach64_driver = { }; extern devclass_t drm_devclass; -#if __FreeBSD_version >= 700010 DRIVER_MODULE(mach64, vgapci, mach64_driver, drm_devclass, 0, 0); -#else -DRIVER_MODULE(mach64, pci, mach64_driver, drm_devclass, 0, 0); -#endif MODULE_DEPEND(mach64, drm, 1, 1, 1); diff --git a/sys/dev/drm/mga_drv.c b/sys/dev/drm/mga_drv.c index 89d9d3e6eb..007b105957 100644 --- a/sys/dev/drm/mga_drv.c +++ b/sys/dev/drm/mga_drv.c @@ -164,9 +164,5 @@ static driver_t mga_driver = { }; extern devclass_t drm_devclass; -#if __FreeBSD_version >= 700010 DRIVER_MODULE(mga, vgapci, mga_driver, drm_devclass, 0, 0); -#else -DRIVER_MODULE(mga, pci, mga_driver, drm_devclass, 0, 0); -#endif MODULE_DEPEND(mga, drm, 1, 1, 1); diff --git a/sys/dev/drm/r128_drv.c b/sys/dev/drm/r128_drv.c index 4d719dce7b..9958767687 100644 --- a/sys/dev/drm/r128_drv.c +++ b/sys/dev/drm/r128_drv.c @@ -125,9 +125,5 @@ static driver_t r128_driver = { }; extern devclass_t drm_devclass; -#if __FreeBSD_version >= 700010 DRIVER_MODULE(r128, vgapci, r128_driver, drm_devclass, 0, 0); -#else -DRIVER_MODULE(r128, pci, r128_driver, drm_devclass, 0, 0); -#endif MODULE_DEPEND(r128, drm, 1, 1, 1); diff --git a/sys/dev/drm/radeon_drv.c b/sys/dev/drm/radeon_drv.c index 86f73de238..24b5cf9c10 100644 --- a/sys/dev/drm/radeon_drv.c +++ b/sys/dev/drm/radeon_drv.c @@ -124,9 +124,5 @@ static driver_t radeon_driver = { }; extern devclass_t drm_devclass; -#if __FreeBSD_version >= 700010 DRIVER_MODULE(radeon, vgapci, radeon_driver, drm_devclass, 0, 0); -#else -DRIVER_MODULE(radeon, pci, radeon_driver, drm_devclass, 0, 0); -#endif MODULE_DEPEND(radeon, drm, 1, 1, 1); diff --git a/sys/dev/drm/savage_drv.c b/sys/dev/drm/savage_drv.c index 97783de409..75cc59e19b 100644 --- a/sys/dev/drm/savage_drv.c +++ b/sys/dev/drm/savage_drv.c @@ -110,9 +110,5 @@ static driver_t savage_driver = { }; extern devclass_t drm_devclass; -#if __FreeBSD_version >= 700010 DRIVER_MODULE(savage, vgapci, savage_driver, drm_devclass, 0, 0); -#else -DRIVER_MODULE(savage, pci, savage_driver, drm_devclass, 0, 0); -#endif MODULE_DEPEND(savage, drm, 1, 1, 1); diff --git a/sys/dev/drm/sis_drv.c b/sys/dev/drm/sis_drv.c index eb087369a4..e753ca588f 100644 --- a/sys/dev/drm/sis_drv.c +++ b/sys/dev/drm/sis_drv.c @@ -104,9 +104,5 @@ static driver_t sis_driver = { }; extern devclass_t drm_devclass; -#if __FreeBSD_version >= 700010 DRIVER_MODULE(sisdrm, vgapci, sis_driver, drm_devclass, 0, 0); -#else -DRIVER_MODULE(sisdrm, pci, sis_driver, drm_devclass, 0, 0); -#endif MODULE_DEPEND(sisdrm, drm, 1, 1, 1); diff --git a/sys/dev/drm/tdfx_drv.c b/sys/dev/drm/tdfx_drv.c index d023aa6bfa..05216e964f 100644 --- a/sys/dev/drm/tdfx_drv.c +++ b/sys/dev/drm/tdfx_drv.c @@ -106,9 +106,5 @@ static driver_t tdfx_driver = { }; extern devclass_t drm_devclass; -#if __FreeBSD_version >= 700010 DRIVER_MODULE(tdfx, vgapci, tdfx_driver, drm_devclass, 0, 0); -#else -DRIVER_MODULE(tdfx, pci, tdfx_driver, drm_devclass, 0, 0); -#endif MODULE_DEPEND(tdfx, drm, 1, 1, 1); -- 2.41.0