int xf86platformAddDevice(int index) { int i, old_screens, scr_index; DriverPtr drvp = NULL; screenLayoutPtr layout; static const char *hotplug_driver_name = "modesetting"; /* force load the driver for now */ xf86LoadOneModule(hotplug_driver_name, NULL); for (i = 0; i < xf86NumDrivers; i++) { if (!xf86DriverList[i]) continue; if (!strcmp(xf86DriverList[i]->driverName, hotplug_driver_name)) { drvp = xf86DriverList[i]; break; } } if (i == xf86NumDrivers) return -1; old_screens = xf86NumGPUScreens; doPlatformProbe(&xf86_platform_devices[index], drvp, NULL, PLATFORM_PROBE_GPU_SCREEN, 0); if (old_screens == xf86NumGPUScreens) return -1; i = old_screens; for (layout = xf86ConfigLayout.screens; layout->screen != NULL; layout++) { xf86GPUScreens[i]->confScreen = layout->screen; break; } if (xf86GPUScreens[i]->PreInit && xf86GPUScreens[i]->PreInit(xf86GPUScreens[i], 0)) xf86GPUScreens[i]->configured = TRUE; if (!xf86GPUScreens[i]->configured) { ErrorF("hotplugged device %d didn't configure\n", i); xf86DeleteScreen(xf86GPUScreens[i]); return -1; } scr_index = AddGPUScreen(xf86GPUScreens[i]->ScreenInit, 0, NULL); if (scr_index == -1) { xf86DeleteScreen(xf86GPUScreens[i]); xf86UnclaimPlatformSlot(&xf86_platform_devices[index], NULL); xf86NumGPUScreens = old_screens; return -1; } dixSetPrivate(&xf86GPUScreens[i]->pScreen->devPrivates, xf86ScreenKey, xf86GPUScreens[i]); CreateScratchPixmapsForScreen(xf86GPUScreens[i]->pScreen); if (xf86GPUScreens[i]->pScreen->CreateScreenResources && !(*xf86GPUScreens[i]->pScreen->CreateScreenResources) (xf86GPUScreens[i]->pScreen)) { RemoveGPUScreen(xf86GPUScreens[i]->pScreen); xf86DeleteScreen(xf86GPUScreens[i]); xf86UnclaimPlatformSlot(&xf86_platform_devices[index], NULL); xf86NumGPUScreens = old_screens; return -1; } /* attach unbound to 0 protocol screen */ AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen); RRResourcesChanged(xf86Screens[0]->pScreen); RRTellChanged(xf86Screens[0]->pScreen); return 0; }
void ati_gdev_subdriver(pointer options) { int nATIGDev, nMach64GDev, nR128GDev, nRadeonGDev; GDevPtr *ATIGDevs; Bool load_mach64 = FALSE, load_r128 = FALSE, load_radeon = FALSE; int i; /* let the subdrivers configure for themselves */ if (xf86ServerIsOnlyDetecting()) return; /* get Device sections with Driver "ati" */ nATIGDev = xf86MatchDevice(ATI_DRIVER_NAME, &ATIGDevs); nMach64GDev = xf86MatchDevice(MACH64_DRIVER_NAME, NULL); nR128GDev = xf86MatchDevice(R128_DRIVER_NAME, NULL); nRadeonGDev = xf86MatchDevice(RADEON_DRIVER_NAME, NULL); for (i = 0; i < nATIGDev; i++) { GDevPtr ati_gdev = ATIGDevs[i]; pciVideoPtr device = NULL; int chip_family; /* get pci device for the Device section */ if (ati_gdev->busID) { int bus, dev, func; if (!xf86ParsePciBusString(ati_gdev->busID, &bus, &dev, &func)) continue; device = ati_device_get_from_busid(bus, dev, func); } else { device = ati_device_get_primary(); } if (!device) continue; /* check for non-ati devices and prehistoric mach32 */ if ((PCI_DEV_VENDOR_ID(device) != PCI_VENDOR_ATI) || (PCI_DEV_DEVICE_ID(device) == PCI_CHIP_MACH32)) continue; /* replace Driver line in the Device section */ chip_family = ATIChipID(PCI_DEV_DEVICE_ID(device)); if (chip_family == ATI_CHIP_FAMILY_Mach64) { ati_gdev->driver = MACH64_DRIVER_NAME; load_mach64 = TRUE; } if (chip_family == ATI_CHIP_FAMILY_Rage128) { ati_gdev->driver = R128_DRIVER_NAME; load_r128 = TRUE; } if (chip_family == ATI_CHIP_FAMILY_Radeon) { ati_gdev->driver = RADEON_DRIVER_NAME; load_radeon = TRUE; } } free(ATIGDevs); /* load subdrivers as primary modules and only if they do not get loaded * from other device sections */ if (load_mach64 && (nMach64GDev == 0)) xf86LoadOneModule(MACH64_DRIVER_NAME, options); if (load_r128 && (nR128GDev == 0)) xf86LoadOneModule(R128_DRIVER_NAME, options); if (load_radeon && (nRadeonGDev == 0)) xf86LoadOneModule(RADEON_DRIVER_NAME, options); }