xfree86: configure: move buses references to their own location
This patch makes xf86Configure.c free of PCI and SBUS code, moving to a more meaningful location. Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
This commit is contained in:
parent
49b817501f
commit
fc3ab84de7
|
@ -34,6 +34,7 @@
|
||||||
#define IN_XSERVER
|
#define IN_XSERVER
|
||||||
#include "Configint.h"
|
#include "Configint.h"
|
||||||
#include "xf86DDC.h"
|
#include "xf86DDC.h"
|
||||||
|
#include "xf86pciBus.h"
|
||||||
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
||||||
#include "xf86Bus.h"
|
#include "xf86Bus.h"
|
||||||
#include "xf86Sbus.h"
|
#include "xf86Sbus.h"
|
||||||
|
@ -71,85 +72,6 @@ static char *DFLT_MOUSE_DEV = "/dev/mouse";
|
||||||
static char *DFLT_MOUSE_PROTO = "auto";
|
static char *DFLT_MOUSE_PROTO = "auto";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Bool
|
|
||||||
bus_pci_configure(void *busData)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct pci_device * pVideo = NULL;
|
|
||||||
|
|
||||||
pVideo = (struct pci_device *) busData;
|
|
||||||
for (i = 0; i < nDevToConfig; i++)
|
|
||||||
if (DevToConfig[i].pVideo &&
|
|
||||||
(DevToConfig[i].pVideo->domain == pVideo->domain) &&
|
|
||||||
(DevToConfig[i].pVideo->bus == pVideo->bus) &&
|
|
||||||
(DevToConfig[i].pVideo->dev == pVideo->dev) &&
|
|
||||||
(DevToConfig[i].pVideo->func == pVideo->func))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Bool
|
|
||||||
bus_sbus_configure(void *busData)
|
|
||||||
{
|
|
||||||
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < nDevToConfig; i++)
|
|
||||||
if (DevToConfig[i].sVideo &&
|
|
||||||
DevToConfig[i].sVideo->fbNum == ((sbusDevicePtr) busData)->fbNum)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
bus_pci_newdev_configure(void *busData, int i, int *chipset)
|
|
||||||
{
|
|
||||||
char busnum[8];
|
|
||||||
struct pci_device * pVideo = NULL;
|
|
||||||
|
|
||||||
pVideo = (struct pci_device *) busData;
|
|
||||||
|
|
||||||
DevToConfig[i].pVideo = pVideo;
|
|
||||||
|
|
||||||
DevToConfig[i].GDev.busID = xnfalloc(16);
|
|
||||||
xf86FormatPciBusNumber(pVideo->bus, busnum);
|
|
||||||
sprintf(DevToConfig[i].GDev.busID, "PCI:%s:%d:%d",
|
|
||||||
busnum, pVideo->dev, pVideo->func);
|
|
||||||
|
|
||||||
DevToConfig[i].GDev.chipID = pVideo->device_id;
|
|
||||||
DevToConfig[i].GDev.chipRev = pVideo->revision;
|
|
||||||
|
|
||||||
if (*chipset < 0) {
|
|
||||||
*chipset = (pVideo->vendor_id << 16) | pVideo->device_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
bus_sbus_newdev_configure(void *busData, int i)
|
|
||||||
{
|
|
||||||
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
|
||||||
char *promPath = NULL;
|
|
||||||
DevToConfig[i].sVideo = (sbusDevicePtr) busData;
|
|
||||||
DevToConfig[i].GDev.identifier = DevToConfig[i].sVideo->descr;
|
|
||||||
if (sparcPromInit() >= 0) {
|
|
||||||
promPath = sparcPromNode2Pathname(&DevToConfig[i].sVideo->node);
|
|
||||||
sparcPromClose();
|
|
||||||
}
|
|
||||||
if (promPath) {
|
|
||||||
DevToConfig[i].GDev.busID = xnfalloc(strlen(promPath) + 6);
|
|
||||||
sprintf(DevToConfig[i].GDev.busID, "SBUS:%s", promPath);
|
|
||||||
free(promPath);
|
|
||||||
} else {
|
|
||||||
DevToConfig[i].GDev.busID = xnfalloc(12);
|
|
||||||
sprintf(DevToConfig[i].GDev.busID, "SBUS:fb%d",
|
|
||||||
DevToConfig[i].sVideo->fbNum);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is called by the driver, either through xf86Match???Instances() or
|
* This is called by the driver, either through xf86Match???Instances() or
|
||||||
* directly. We allocate a GDevRec and fill it in as much as we can, letting
|
* directly. We allocate a GDevRec and fill it in as much as we can, letting
|
||||||
|
@ -164,19 +86,22 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Check for duplicates */
|
/* Check for duplicates */
|
||||||
|
for (i = 0; i < nDevToConfig; i++) {
|
||||||
switch (bus) {
|
switch (bus) {
|
||||||
case BUS_PCI:
|
case BUS_PCI:
|
||||||
ret = bus_pci_configure(busData);
|
ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
|
||||||
break;
|
break;
|
||||||
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
||||||
case BUS_SBUS:
|
case BUS_SBUS:
|
||||||
ret = bus_sbus_configure(busData);
|
ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate new structure occurrence */
|
/* Allocate new structure occurrence */
|
||||||
i = nDevToConfig++;
|
i = nDevToConfig++;
|
||||||
|
@ -195,11 +120,15 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
|
||||||
|
|
||||||
switch (bus) {
|
switch (bus) {
|
||||||
case BUS_PCI:
|
case BUS_PCI:
|
||||||
bus_pci_newdev_configure(busData, i, &chipset);
|
xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
|
||||||
|
&DevToConfig[i].GDev, &chipset);
|
||||||
break;
|
break;
|
||||||
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
||||||
case BUS_SBUS:
|
case BUS_SBUS:
|
||||||
bus_sbus_newdev_configure(busData, i);
|
xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
|
||||||
|
&DevToConfig[i].GDev);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1327,3 +1327,38 @@ xf86PciMatchDriver(char* matches[], int nmatches) {
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bool
|
||||||
|
xf86PciConfigure(void *busData, struct pci_device *pDev)
|
||||||
|
{
|
||||||
|
struct pci_device * pVideo = NULL;
|
||||||
|
|
||||||
|
pVideo = (struct pci_device *) busData;
|
||||||
|
if (pDev &&
|
||||||
|
(pDev->domain == pVideo->domain) &&
|
||||||
|
(pDev->bus == pVideo->bus) &&
|
||||||
|
(pDev->dev == pVideo->dev) &&
|
||||||
|
(pDev->func == pVideo->func))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
|
||||||
|
GDevRec *GDev, int *chipset)
|
||||||
|
{
|
||||||
|
char busnum[8];
|
||||||
|
|
||||||
|
pVideo = (struct pci_device *) busData;
|
||||||
|
|
||||||
|
GDev->busID = xnfalloc(16);
|
||||||
|
xf86FormatPciBusNumber(pVideo->bus, busnum);
|
||||||
|
sprintf(GDev->busID, "PCI:%s:%d:%d", busnum, pVideo->dev, pVideo->func);
|
||||||
|
|
||||||
|
GDev->chipID = pVideo->device_id;
|
||||||
|
GDev->chipRev = pVideo->revision;
|
||||||
|
|
||||||
|
if (*chipset < 0)
|
||||||
|
*chipset = (pVideo->vendor_id << 16) | pVideo->device_id;
|
||||||
|
}
|
||||||
|
|
|
@ -38,5 +38,8 @@ Bool xf86PciAddMatchingDev(DriverPtr drvp);
|
||||||
Bool xf86PciProbeDev(DriverPtr drvp);
|
Bool xf86PciProbeDev(DriverPtr drvp);
|
||||||
void xf86PciIsolateDevice(char *argument);
|
void xf86PciIsolateDevice(char *argument);
|
||||||
int xf86PciMatchDriver(char* matches[], int nmatches);
|
int xf86PciMatchDriver(char* matches[], int nmatches);
|
||||||
|
Bool xf86PciConfigure(void *busData, struct pci_device *pDev);
|
||||||
|
void xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
|
||||||
|
GDevRec *GDev, int *chipset);
|
||||||
|
|
||||||
#endif /* _XF86_PCI_BUS_H */
|
#endif /* _XF86_PCI_BUS_H */
|
||||||
|
|
|
@ -685,3 +685,32 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
|
||||||
return xf86HandleColormaps(pScreen, 256, 8,
|
return xf86HandleColormaps(pScreen, 256, 8,
|
||||||
xf86SbusCmapLoadPalette, NULL, 0);
|
xf86SbusCmapLoadPalette, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bool
|
||||||
|
xf86SbusConfigure(void *busData, sbusDevicePtr sBus)
|
||||||
|
{
|
||||||
|
if (sBus && sBus->fbNum == ((sbusDevicePtr) busData)->fbNum)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec *GDev)
|
||||||
|
{
|
||||||
|
char *promPath = NULL;
|
||||||
|
|
||||||
|
sBus = (sbusDevicePtr) busData;
|
||||||
|
GDev->identifier = sBus->descr;
|
||||||
|
if (sparcPromInit() >= 0) {
|
||||||
|
promPath = sparcPromNode2Pathname(&sBus->node);
|
||||||
|
sparcPromClose();
|
||||||
|
}
|
||||||
|
if (promPath) {
|
||||||
|
GDev->busID = xnfalloc(strlen(promPath) + 6);
|
||||||
|
sprintf(GDev->busID, "SBUS:%s", promPath);
|
||||||
|
free(promPath);
|
||||||
|
} else {
|
||||||
|
GDev->busID = xnfalloc(12);
|
||||||
|
sprintf(GDev->busID, "SBUS:fb%d", sBus->fbNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -97,4 +97,8 @@ extern _X_EXPORT char * sparcPromNode2Pathname(sbusPromNodePtr pnode);
|
||||||
extern _X_EXPORT int sparcPromPathname2Node(const char *pathName);
|
extern _X_EXPORT int sparcPromPathname2Node(const char *pathName);
|
||||||
extern _X_EXPORT char *sparcDriverName(void);
|
extern _X_EXPORT char *sparcDriverName(void);
|
||||||
|
|
||||||
|
extern Bool xf86SbusConfigure(void *busData, sbusDevicePtr sBus);
|
||||||
|
extern void xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus,
|
||||||
|
GDevRec *GDev);
|
||||||
|
|
||||||
#endif /* _XF86_SBUSBUS_H */
|
#endif /* _XF86_SBUSBUS_H */
|
||||||
|
|
Loading…
Reference in New Issue