static int xf86ClaimPlatformSlot(struct xf86_platform_device * d, DriverPtr drvp, int chipset, GDevPtr dev, Bool active) { EntityPtr p = NULL; int num; if (xf86_check_platform_slot(d)) { num = xf86AllocateEntity(); p = xf86Entities[num]; p->driver = drvp; p->chipset = chipset; p->bus.type = BUS_PLATFORM; p->bus.id.plat = d; p->active = active; p->inUse = FALSE; if (dev) xf86AddDevToEntity(num, dev); platformSlotClaimed++; return num; } else return -1; }
int xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp, GDevPtr dev, Bool active) { EntityPtr p = NULL; int num; if (xf86CheckSbusSlot(psdp->fbNum)) { num = xf86AllocateEntity(); p = xf86Entities[num]; p->driver = drvp; p->chipset = -1; p->busType = BUS_SBUS; xf86AddDevToEntity(num, dev); p->sbusBusId.fbNum = psdp->fbNum; p->active = active; p->inUse = FALSE; /* Here we initialize the access structure */ p->access = xnfcalloc(1,sizeof(EntityAccessRec)); p->access->fallback = &AccessNULL; p->access->pAccess = &AccessNULL; sbusSlotClaimed = TRUE; return num; } else return -1; }
int xf86ClaimPciSlot(struct pci_device *d, DriverPtr drvp, int chipset, GDevPtr dev, Bool active) { EntityPtr p = NULL; int num; if (xf86CheckPciSlot(d)) { num = xf86AllocateEntity(); p = xf86Entities[num]; p->driver = drvp; p->chipset = chipset; p->bus.type = BUS_PCI; p->bus.id.pci = d; p->active = active; p->inUse = FALSE; if (dev) xf86AddDevToEntity(num, dev); pciSlotClaimed++; return num; } else return -1; }
static Bool doPlatformProbe(struct xf86_platform_device *dev, DriverPtr drvp, GDevPtr gdev, int flags, intptr_t match_data) { Bool foundScreen = FALSE; int entity, fd, major, minor; if (gdev && gdev->screen == 0 && !xf86_check_platform_slot(dev)) return FALSE; entity = xf86ClaimPlatformSlot(dev, drvp, 0, gdev, gdev ? gdev->active : 0); if ((entity == -1) && gdev && (gdev->screen > 0)) { unsigned nent; for (nent = 0; nent < xf86NumEntities; nent++) { EntityPtr pEnt = xf86Entities[nent]; if (pEnt->bus.type != BUS_PLATFORM) continue; if (pEnt->bus.id.plat == dev) { entity = nent; xf86AddDevToEntity(nent, gdev); break; } } } if (entity != -1) { if ((dev->flags & XF86_PDEV_SERVER_FD) && (!drvp->driverFunc || !drvp->driverFunc(NULL, SUPPORTS_SERVER_FDS, NULL))) { fd = xf86_get_platform_device_int_attrib(dev, ODEV_ATTRIB_FD, -1); major = xf86_get_platform_device_int_attrib(dev, ODEV_ATTRIB_MAJOR, 0); minor = xf86_get_platform_device_int_attrib(dev, ODEV_ATTRIB_MINOR, 0); systemd_logind_release_fd(major, minor); close(fd); config_odev_add_int_attribute(dev->attribs, ODEV_ATTRIB_FD, -1); dev->flags &= ~XF86_PDEV_SERVER_FD; } if (drvp->platformProbe(drvp, entity, flags, dev, match_data)) foundScreen = TRUE; else xf86UnclaimPlatformSlot(dev, gdev); } return foundScreen; }
_X_EXPORT int xf86MatchSbusInstances(const char *driverName, int sbusDevId, GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities) { int *retEntities = NULL; EntityPtr p = NULL; int num; *foundEntities = NULL; if (sbusDevId == sbusInfo.devId) { if (xf86DoConfigure && xf86DoConfigurePass1) { GDevPtr pGDev; pGDev = xf86AddBusDeviceToConfigure(drvp->driverName, BUS_SBUS, &sbusInfo, -1); if (pGDev) { /* * XF86Match???Instances() treat * chipID and chipRev as overrides, so * clobber them here. */ pGDev->chipID = pGDev->chipRev = -1; } return 1; } sbusInfo.device = devList[0]->identifier; num = xf86AllocateEntity(); p = xf86Entities[num]; p->driver = drvp; p->chipset = -1; p->bus.type = BUS_SBUS; xf86AddDevToEntity(num, devList[0]); p->active = TRUE; p->inUse = FALSE; retEntities = malloc(sizeof(int)); retEntities[0] = num; *foundEntities = retEntities; return 1; } return 0; }
_X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active) { EntityPtr p; int num; num = xf86AllocateEntity(); p = xf86Entities[num]; p->driver = drvp; p->chipset = 0; p->busType = BUS_NONE; p->active = active; p->inUse = FALSE; xf86AddDevToEntity(num, dev); p->access = xnfcalloc(1,sizeof(EntityAccessRec)); p->access->fallback = &AccessNULL; p->access->pAccess = &AccessNULL; p->busAcc = NULL; return num; }
int xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp, GDevPtr dev, Bool active) { EntityPtr p = NULL; int num; if (xf86CheckSbusSlot(psdp->fbNum)) { num = xf86AllocateEntity(); p = xf86Entities[num]; p->driver = drvp; p->chipset = -1; p->bus.type = BUS_SBUS; xf86AddDevToEntity(num, dev); p->bus.id.sbus.fbNum = psdp->fbNum; p->active = active; p->inUse = FALSE; sbusSlotClaimed = TRUE; return num; } else return -1; }
Bool xf86PciProbeDev(DriverPtr drvp) { int i, j; struct pci_device *pPci; Bool foundScreen = FALSE; const struct pci_id_match *const devices = drvp->supported_devices; GDevPtr *devList; const unsigned numDevs = xf86MatchDevice(drvp->driverName, &devList); for (i = 0; i < numDevs; i++) { struct pci_device_iterator *iter; unsigned device_id; /* Find the pciVideoRec associated with this device section. */ iter = pci_id_match_iterator_create(NULL); while ((pPci = pci_device_next(iter)) != NULL) { if (devList[i]->busID && *devList[i]->busID) { if (xf86ComparePciBusString(devList[i]->busID, ((pPci->domain << 8) | pPci->bus), pPci->dev, pPci->func)) { break; } } else if (xf86IsPrimaryPci(pPci)) { break; } } pci_iterator_destroy(iter); if (pPci == NULL) { continue; } device_id = (devList[i]->chipID > 0) ? devList[i]->chipID : pPci->device_id; /* Once the pciVideoRec is found, determine if the device is supported * by the driver. If it is, probe it! */ for (j = 0; !END_OF_MATCHES(devices[j]); j++) { if (PCI_ID_COMPARE(devices[j].vendor_id, pPci->vendor_id) && PCI_ID_COMPARE(devices[j].device_id, device_id) && ((devices[j].device_class_mask & pPci->device_class) == devices[j].device_class)) { int entry; /* Allow the same entity to be used more than once for * devices with multiple screens per entity. This assumes * implicitly that there will be a screen == 0 instance. * * FIXME Need to make sure that two different drivers don't * FIXME claim the same screen > 0 instance. */ if ((devList[i]->screen == 0) && !xf86CheckPciSlot(pPci)) continue; DebugF("%s: card at %d:%d:%d is claimed by a Device section\n", drvp->driverName, pPci->bus, pPci->dev, pPci->func); /* Allocate an entry in the lists to be returned */ entry = xf86ClaimPciSlot(pPci, drvp, device_id, devList[i], devList[i]->active); if ((entry == -1) && (devList[i]->screen > 0)) { unsigned k; for (k = 0; k < xf86NumEntities; k++) { EntityPtr pEnt = xf86Entities[k]; if (pEnt->bus.type != BUS_PCI) continue; if (pEnt->bus.id.pci == pPci) { entry = k; xf86AddDevToEntity(k, devList[i]); break; } } } if (entry != -1) { if ((*drvp->PciProbe) (drvp, entry, pPci, devices[j].match_data)) { foundScreen = TRUE; } else xf86UnclaimPciSlot(pPci, devList[i]); } break; } } } free(devList); return foundScreen; }