aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/common/xf86Bus.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-05-20 07:07:37 +0000
committermarha <marha@users.sourceforge.net>2010-05-20 07:07:37 +0000
commit3319741e6f9fc3232eb40462a261271b9af2dcb2 (patch)
treeffe7fbae59390aafa850dcdbd3ea48d2cb59bda0 /xorg-server/hw/xfree86/common/xf86Bus.c
parent153f5cafa19da4e4c0cf21e9c909958359ed8ebd (diff)
downloadvcxsrv-3319741e6f9fc3232eb40462a261271b9af2dcb2.tar.gz
vcxsrv-3319741e6f9fc3232eb40462a261271b9af2dcb2.tar.bz2
vcxsrv-3319741e6f9fc3232eb40462a261271b9af2dcb2.zip
xserver git update 20/5/2010
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86Bus.c')
-rw-r--r--xorg-server/hw/xfree86/common/xf86Bus.c283
1 files changed, 155 insertions, 128 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c
index 5c1668644..09b94654c 100644
--- a/xorg-server/hw/xfree86/common/xf86Bus.c
+++ b/xorg-server/hw/xfree86/common/xf86Bus.c
@@ -58,9 +58,139 @@ static int xf86EntityPrivateCount = 0;
BusRec primaryBus = { BUS_NONE, { 0 } };
-static Bool xf86ResAccessEnter = FALSE;
+/**
+ * Call the driver's correct probe function.
+ *
+ * If the driver implements the \c DriverRec::PciProbe entry-point and an
+ * appropriate PCI device (with matching Device section in the xorg.conf file)
+ * is found, it is called. If \c DriverRec::PciProbe or no devices can be
+ * successfully probed with it (e.g., only non-PCI devices are available),
+ * the driver's \c DriverRec::Probe function is called.
+ *
+ * \param drv Driver to probe
+ *
+ * \return
+ * If a device can be successfully probed by the driver, \c TRUE is
+ * returned. Otherwise, \c FALSE is returned.
+ */
+Bool
+xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
+{
+ Bool foundScreen = FALSE;
+
+ if (drv->PciProbe != NULL) {
+ if (xf86DoConfigure && xf86DoConfigurePass1) {
+ assert(detect_only);
+ foundScreen = xf86PciAddMatchingDev(drv);
+ }
+ else {
+ assert(! detect_only);
+ foundScreen = xf86PciProbeDev(drv);
+ }
+ }
+
+ if (!foundScreen && (drv->Probe != NULL)) {
+ xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
+ drv->driverName);
+ foundScreen = (*drv->Probe)(drv, (detect_only) ? PROBE_DETECT
+ : PROBE_DEFAULT);
+ }
+
+ return foundScreen;
+}
+
+/**
+ * @return TRUE if all buses are configured and set up correctly and FALSE
+ * otherwise.
+ */
+Bool
+xf86BusConfig(void)
+{
+ screenLayoutPtr layout;
+ int i, j;
+
+ /* Enable full I/O access */
+ if (xorgHWAccess)
+ xorgHWAccess = xf86EnableIO();
+
+ /* Locate bus slot that had register IO enabled at server startup */
+ if (xorgHWAccess)
+ xf86FindPrimaryDevice();
+
+ /*
+ * Now call each of the Probe functions. Each successful probe will
+ * result in an extra entry added to the xf86Screens[] list for each
+ * instance of the hardware found.
+ */
+ for (i = 0; i < xf86NumDrivers; i++) {
+ xorgHWFlags flags;
+ if (!xorgHWAccess) {
+ if (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags))
+ continue;
+ }
+
+ xf86CallDriverProbe(xf86DriverList[i], FALSE);
+ }
+
+ /* If nothing was detected, return now */
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR, "No devices detected.\n");
+ return FALSE;
+ }
+
+ xf86VGAarbiterInit();
+
+ /*
+ * Match up the screens found by the probes against those specified
+ * in the config file. Remove the ones that won't be used. Sort
+ * them in the order specified.
+ *
+ * What is the best way to do this?
+ *
+ * For now, go through the screens allocated by the probes, and
+ * look for screen config entry which refers to the same device
+ * section as picked out by the probe.
+ *
+ */
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
+ layout++) {
+ Bool found = FALSE;
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+
+ GDevPtr dev = xf86GetDevFromEntity(
+ xf86Screens[i]->entityList[j],
+ xf86Screens[i]->entityInstanceList[j]);
+ if (dev == layout->screen->device) {
+ /* A match has been found */
+ xf86Screens[i]->confScreen = layout->screen;
+ found = TRUE;
+ break;
+ }
+ }
+ if (found) break;
+ }
+ if (layout->screen == NULL) {
+ /* No match found */
+ xf86Msg(X_ERROR,
+ "Screen %d deleted because of no matching config section.\n", i);
+ xf86DeleteScreen(i--, 0);
+ }
+ }
-static Bool doFramebufferMode = FALSE;
+ /* If no screens left, return now. */
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR,
+ "Device(s) detected, but none match those in the config file.\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
/*
* Call the bus probes relevant to the architecture.
@@ -112,21 +242,6 @@ StringToBusType(const char* busID, const char **retID)
return ret;
}
-/*
- * Entity related code.
- */
-
-void
-xf86EntityInit(void)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++)
- if (xf86Entities[i]->entityInit) {
- xf86Entities[i]->entityInit(i,xf86Entities[i]->private);
- }
-}
-
int
xf86AllocateEntity(void)
{
@@ -139,28 +254,6 @@ xf86AllocateEntity(void)
return (xf86NumEntities - 1);
}
-static void
-EntityEnter(void)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++)
- if (xf86Entities[i]->entityEnter) {
- xf86Entities[i]->entityEnter(i,xf86Entities[i]->private);
- }
-}
-
-static void
-EntityLeave(void)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++)
- if (xf86Entities[i]->entityLeave) {
- xf86Entities[i]->entityLeave(i,xf86Entities[i]->private);
- }
-}
-
Bool
xf86IsEntityPrimary(int entityIndex)
{
@@ -386,72 +479,29 @@ xf86GetDevFromEntity(int entityIndex, int instance)
}
/*
- * xf86AccessInit() - set up everything needed for access control
- * called only once on first server generation.
- */
-void
-xf86AccessInit(void)
-{
- xf86ResAccessEnter = TRUE;
-}
-
-/*
* xf86AccessEnter() -- gets called to save the text mode VGA IO
* resources when reentering the server after a VT switch.
*/
void
xf86AccessEnter(void)
{
- if (xf86ResAccessEnter)
- return;
+ int i;
+
+ for (i = 0; i < xf86NumEntities; i++)
+ if (xf86Entities[i]->entityEnter)
+ xf86Entities[i]->entityEnter(i,xf86Entities[i]->private);
- /*
- * on enter we simply disable routing of special resources
- * to any bus and let the RAC code to "open" the right bridges.
- */
- EntityEnter();
xf86EnterServerState(SETUP);
- xf86ResAccessEnter = TRUE;
}
-/*
- * xf86AccessLeave() -- prepares access for and calls the
- * entityLeave() functions.
- * xf86AccessLeaveState() --- gets called to restore the
- * access to the VGA IO resources when switching VT or on
- * server exit.
- * This was split to call xf86AccessLeaveState() from
- * ddxGiveUp().
- */
void
xf86AccessLeave(void)
{
- if (!xf86ResAccessEnter)
- return;
- EntityLeave();
-}
-
-/*
- * xf86EnableAccess() -- enable access to controlled resources.
- * To reduce latency when switching access the ScrnInfoRec has
- * a linked list of the EntityAccPtr of all screen entities.
- */
-/*
- * switching access needs to be done in te following oder:
- * disable
- * 1. disable old entity
- * 2. reroute bus
- * 3. enable new entity
- * Otherwise resources needed for access control might be shadowed
- * by other resources!
- */
-
-void
-xf86EnableAccess(ScrnInfoPtr pScrn)
-{
- DebugF("Enable access %i\n",pScrn->scrnIndex);
+ int i;
- return;
+ for (i = 0; i < xf86NumEntities; i++)
+ if (xf86Entities[i]->entityLeave)
+ xf86Entities[i]->entityLeave(i,xf86Entities[i]->private);
}
/*
@@ -460,12 +510,17 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
typedef enum { TRI_UNSET, TRI_TRUE, TRI_FALSE } TriState;
-static void
-SetSIGIOForState(xf86State state)
+void
+xf86EnterServerState(xf86State state)
{
static int sigio_state;
static TriState sigio_blocked = TRI_UNSET;
+ /*
+ * This is a good place to block SIGIO during SETUP state. SIGIO should be
+ * blocked in SETUP state otherwise (u)sleep() might get interrupted
+ * early. We take care not to call xf86BlockSIGIO() twice.
+ */
if ((state == SETUP) && (sigio_blocked != TRI_TRUE)) {
sigio_state = xf86BlockSIGIO();
sigio_blocked = TRI_TRUE;
@@ -475,24 +530,6 @@ SetSIGIOForState(xf86State state)
}
}
-void
-xf86EnterServerState(xf86State state)
-{
- /*
- * This is a good place to block SIGIO during SETUP state.
- * SIGIO should be blocked in SETUP state otherwise (u)sleep()
- * might get interrupted early.
- * We take care not to call xf86BlockSIGIO() twice.
- */
- SetSIGIOForState(state);
- if (state == SETUP)
- DebugF("Entering SETUP state\n");
- else
- DebugF("Entering OPERATING state\n");
-
- return;
-}
-
/*
* xf86PostProbe() -- Allocate all non conflicting resources
* This function gets called by xf86Init().
@@ -500,35 +537,25 @@ xf86EnterServerState(xf86State state)
void
xf86PostProbe(void)
{
- if (fbSlotClaimed) {
- if (pciSlotClaimed
+ int i;
+
+ if (fbSlotClaimed && (pciSlotClaimed
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|| sbusSlotClaimed
#endif
- ) {
+ ))
FatalError("Cannot run in framebuffer mode. Please specify busIDs "
" for all framebuffer devices\n");
- return;
- } else {
- xf86Msg(X_INFO,"Running in FRAMEBUFFER Mode\n");
- doFramebufferMode = TRUE;
- return;
- }
- }
+ for (i = 0; i < xf86NumEntities; i++)
+ if (xf86Entities[i]->entityInit)
+ xf86Entities[i]->entityInit(i,xf86Entities[i]->private);
}
void
xf86PostScreenInit(void)
{
- if (doFramebufferMode) {
- SetSIGIOForState(OPERATING);
- return;
- }
-
xf86VGAarbiterWrapFunctions();
-
- DebugF("PostScreenInit generation: %i\n",serverGeneration);
xf86EnterServerState(OPERATING);
}