diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index bfde44e63..200d8fbff 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -1603,192 +1603,6 @@ struct Inst { }; -#define END_OF_MATCHES(m) \ - (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0)) - -Bool -probe_devices_from_device_sections( DriverPtr drvp ) -{ - int i, j; - struct pci_device * pPci; - struct pci_device **ppPci; - 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++ ) { - unsigned device_id; - - - /* Find the pciVideoRec associated with this device section. - */ - pPci = NULL; - for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { - pPci = *ppPci; - - 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; - } - } - - 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; - -#ifdef DEBUG - ErrorF("%s: card at %d:%d:%d is claimed by a Device section\n", - drvp->driverName, pPci->bus, pPci->device, pPci->func); -#endif - - /* 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->busType != BUS_PCI) - continue; - - if (pEnt->pciBusId.bus == PCI_MAKE_BUS( pPci->domain, pPci->bus ) && - pEnt->pciBusId.device == pPci->dev && - pEnt->pciBusId.func == pPci->func) { - entry = k; - xf86AddDevToEntity( k, devList[i] ); - break; - } - } - } - - if ( entry != -1 ) { - if ( (*drvp->PciProbe)( drvp, entry, pPci, - devices[j].match_data ) ) { - foundScreen = TRUE; - } - } - - break; - } - } - } - - - return foundScreen; -} - - -Bool -add_matching_devices_to_configure_list( DriverPtr drvp ) -{ - const struct pci_id_match * const devices = drvp->supported_devices; - int j; - struct pci_device ** ppPci; - int numFound = 0; - - - for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { - const struct pci_device * pPci = *ppPci; - - - /* Determine if this device is supported by the driver. If it is, - * add it to the list of devices to configure. - */ - 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, pPci->device_id ) - && ((devices[j].device_class_mask & pPci->device_class) - == devices[j].device_class) ) { - if ( xf86CheckPciSlot( pPci ) ) { - GDevPtr pGDev = - xf86AddDeviceToConfigure( drvp->driverName, pPci, -1 ); - if ( pGDev != NULL ) { - /* After configure pass 1, chipID and chipRev are - * treated as over-rides, so clobber them here. - */ - pGDev->chipID = -1; - pGDev->chipRev = -1; - } - - numFound++; - } - - break; - } - } - } - - - return (numFound != 0); -} - - -Bool -check_for_matching_devices( DriverPtr drvp ) -{ - const struct pci_id_match * const devices = drvp->supported_devices; - int j; - struct pci_device ** ppPci; - - - for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { - const struct pci_device * pPci = *ppPci; - - - /* Determine if this device is supported by the driver. If it is, - * add it to the list of devices to configure. - */ - 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, pPci->device_id ) - && ((devices[j].device_class_mask & pPci->device_class) - == devices[j].device_class) ) { - return TRUE; - } - } - } - - - return FALSE; -} - - /** * Find set of unclaimed devices matching a given vendor ID. * diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index ae2ea79b0..db7b3f98c 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -99,6 +99,9 @@ #include "dpmsproc.h" #endif +#include +#include "Pci.h" +#include "xf86Bus.h" /* forward declarations */ @@ -106,6 +109,10 @@ static void xf86PrintBanner(void); static void xf86PrintMarkers(void); static void xf86RunVtInit(void); +static Bool probe_devices_from_device_sections(DriverPtr drvp); +static Bool add_matching_devices_to_configure_list(DriverPtr drvp); +static Bool check_for_matching_devices(DriverPtr drvp); + #ifdef __UNIXOS2__ extern void os2ServerVideoAccess(); #endif @@ -261,6 +268,192 @@ PostConfigInit(void) } +#define END_OF_MATCHES(m) \ + (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0)) + +Bool +probe_devices_from_device_sections(DriverPtr drvp) +{ + int i, j; + struct pci_device * pPci; + struct pci_device **ppPci; + 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++ ) { + unsigned device_id; + + + /* Find the pciVideoRec associated with this device section. + */ + pPci = NULL; + for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + pPci = *ppPci; + + 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; + } + } + + 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; + +#ifdef DEBUG + ErrorF("%s: card at %d:%d:%d is claimed by a Device section\n", + drvp->driverName, pPci->bus, pPci->device, pPci->func); +#endif + + /* 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->busType != BUS_PCI) + continue; + + if (pEnt->pciBusId.bus == PCI_MAKE_BUS( pPci->domain, pPci->bus ) && + pEnt->pciBusId.device == pPci->dev && + pEnt->pciBusId.func == pPci->func) { + entry = k; + xf86AddDevToEntity( k, devList[i] ); + break; + } + } + } + + if ( entry != -1 ) { + if ( (*drvp->PciProbe)( drvp, entry, pPci, + devices[j].match_data ) ) { + foundScreen = TRUE; + } + } + + break; + } + } + } + + + return foundScreen; +} + + +Bool +add_matching_devices_to_configure_list(DriverPtr drvp) +{ + const struct pci_id_match * const devices = drvp->supported_devices; + int j; + struct pci_device ** ppPci; + int numFound = 0; + + + for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + struct pci_device * const pPci = *ppPci; + + + /* Determine if this device is supported by the driver. If it is, + * add it to the list of devices to configure. + */ + 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, pPci->device_id ) + && ((devices[j].device_class_mask & pPci->device_class) + == devices[j].device_class) ) { + if (xf86CheckPciSlot(pPci)) { + GDevPtr pGDev = + xf86AddDeviceToConfigure(drvp->driverName, pPci, -1); + if (pGDev != NULL) { + /* After configure pass 1, chipID and chipRev are + * treated as over-rides, so clobber them here. + */ + pGDev->chipID = -1; + pGDev->chipRev = -1; + } + + numFound++; + } + + break; + } + } + } + + + return (numFound != 0); +} + + +Bool +check_for_matching_devices(DriverPtr drvp) +{ + const struct pci_id_match * const devices = drvp->supported_devices; + int j; + struct pci_device ** ppPci; + + + for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + const struct pci_device * pPci = *ppPci; + + + /* Determine if this device is supported by the driver. If it is, + * add it to the list of devices to configure. + */ + 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, pPci->device_id ) + && ((devices[j].device_class_mask & pPci->device_class) + == devices[j].device_class) ) { + return TRUE; + } + } + } + + + return FALSE; +} + + /** * Call the driver's correct probe function. *