summaryrefslogtreecommitdiff
path: root/hw/xfree86/common/xf86Bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/common/xf86Bus.c')
-rw-r--r--hw/xfree86/common/xf86Bus.c296
1 files changed, 153 insertions, 143 deletions
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index c665a2019..b176e8cc4 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -51,11 +51,11 @@
#include "xf86VGAarbiter.h"
#endif
/* Entity data */
-EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
+EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
int xf86NumEntities = 0;
static int xf86EntityPrivateCount = 0;
-BusRec primaryBus = { BUS_NONE, { 0 } };
+BusRec primaryBus = { BUS_NONE, {0} };
/**
* Call the driver's correct probe function.
@@ -73,9 +73,10 @@ BusRec primaryBus = { BUS_NONE, { 0 } };
* returned. Otherwise, \c FALSE is returned.
*/
Bool
-xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
+xf86CallDriverProbe(DriverPtr drv, Bool detect_only)
{
- Bool foundScreen = FALSE;
+ Bool foundScreen = FALSE;
+
#ifdef XSERVER_LIBPCIACCESS
if (drv->PciProbe != NULL) {
if (xf86DoConfigure && xf86DoConfigurePass1) {
@@ -83,16 +84,16 @@ xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
foundScreen = xf86PciAddMatchingDev(drv);
}
else {
- assert(! detect_only);
+ assert(!detect_only);
foundScreen = xf86PciProbeDev(drv);
}
}
#endif
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);
+ 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;
@@ -119,13 +120,14 @@ xf86BusConfig(void)
*/
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;
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags))
+ continue;
}
xf86CallDriverProbe(xf86DriverList[i], FALSE);
@@ -155,11 +157,13 @@ xf86BusConfig(void)
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]);
+ 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;
@@ -167,12 +171,14 @@ xf86BusConfig(void)
break;
}
}
- if (found) 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);
+ "Screen %d deleted because of no matching config section.\n",
+ i);
xf86DeleteScreen(i--, 0);
}
}
@@ -180,7 +186,7 @@ xf86BusConfig(void)
/* If no screens left, return now. */
if (xf86NumScreens == 0) {
xf86Msg(X_ERROR,
- "Device(s) detected, but none match those in the config file.\n");
+ "Device(s) detected, but none match those in the config file.\n");
return FALSE;
}
@@ -210,31 +216,31 @@ xf86BusProbe(void)
*/
BusType
-StringToBusType(const char* busID, const char **retID)
+StringToBusType(const char *busID, const char **retID)
{
char *p, *s;
BusType ret = BUS_NONE;
/* If no type field, Default to PCI */
if (isdigit(busID[0])) {
- if (retID)
- *retID = busID;
- return BUS_PCI;
+ if (retID)
+ *retID = busID;
+ return BUS_PCI;
}
s = xstrdup(busID);
p = strtok(s, ":");
if (p == NULL || *p == 0) {
- free(s);
- return BUS_NONE;
+ free(s);
+ return BUS_NONE;
}
if (!xf86NameCmp(p, "pci") || !xf86NameCmp(p, "agp"))
- ret = BUS_PCI;
+ ret = BUS_PCI;
if (!xf86NameCmp(p, "sbus"))
- ret = BUS_SBUS;
+ ret = BUS_SBUS;
if (ret != BUS_NONE)
- if (retID)
- *retID = busID + strlen(p) + 1;
+ if (retID)
+ *retID = busID + strlen(p) + 1;
free(s);
return ret;
}
@@ -244,10 +250,10 @@ xf86AllocateEntity(void)
{
xf86NumEntities++;
xf86Entities = xnfrealloc(xf86Entities,
- sizeof(EntityPtr) * xf86NumEntities);
- xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
+ sizeof(EntityPtr) * xf86NumEntities);
+ xf86Entities[xf86NumEntities - 1] = xnfcalloc(1, sizeof(EntityRec));
xf86Entities[xf86NumEntities - 1]->entityPrivates =
- xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
+ xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
return xf86NumEntities - 1;
}
@@ -255,25 +261,26 @@ Bool
xf86IsEntityPrimary(int entityIndex)
{
EntityPtr pEnt = xf86Entities[entityIndex];
-
- if (primaryBus.type != pEnt->bus.type) return FALSE;
+
+ if (primaryBus.type != pEnt->bus.type)
+ return FALSE;
switch (pEnt->bus.type) {
case BUS_PCI:
- return pEnt->bus.id.pci == primaryBus.id.pci;
+ return pEnt->bus.id.pci == primaryBus.id.pci;
case BUS_SBUS:
- return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
+ return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
default:
- return FALSE;
+ return FALSE;
}
}
-
+
Bool
xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
- EntityProc leave, pointer private)
+ EntityProc leave, pointer private)
{
if (entityIndex >= xf86NumEntities)
- return FALSE;
+ return FALSE;
xf86Entities[entityIndex]->entityInit = init;
xf86Entities[entityIndex]->entityEnter = enter;
xf86Entities[entityIndex]->entityLeave = leave;
@@ -285,9 +292,10 @@ Bool
xf86DriverHasEntities(DriverPtr drvp)
{
int i;
+
for (i = 0; i < xf86NumEntities; i++) {
- if (xf86Entities[i]->driver == drvp)
- return TRUE;
+ if (xf86Entities[i]->driver == drvp)
+ return TRUE;
}
return FALSE;
}
@@ -296,20 +304,20 @@ void
xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
{
if (entityIndex == -1)
- return;
+ return;
if (xf86Entities[entityIndex]->inUse &&
- !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) {
- ErrorF("Requested Entity already in use!\n");
- return;
+ !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) {
+ ErrorF("Requested Entity already in use!\n");
+ return;
}
pScrn->numEntities++;
pScrn->entityList = xnfrealloc(pScrn->entityList,
- pScrn->numEntities * sizeof(int));
+ pScrn->numEntities * sizeof(int));
pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
xf86Entities[entityIndex]->inUse = TRUE;
pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
- pScrn->numEntities * sizeof(int));
+ pScrn->numEntities * sizeof(int));
pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
}
@@ -319,13 +327,13 @@ xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance)
int i;
if (entityIndex == -1 || entityIndex >= xf86NumEntities)
- return;
+ return;
for (i = 0; i < pScrn->numEntities; i++) {
- if (pScrn->entityList[i] == entityIndex) {
- pScrn->entityInstanceList[i] = instance;
- break;
- }
+ if (pScrn->entityList[i] == entityIndex) {
+ pScrn->entityInstanceList[i] = instance;
+ break;
+ }
}
}
@@ -336,17 +344,18 @@ xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance)
ScrnInfoPtr
xf86FindScreenForEntity(int entityIndex)
{
- int i,j;
+ int i, j;
+
+ if (entityIndex == -1)
+ return NULL;
- if (entityIndex == -1) return NULL;
-
if (xf86Screens) {
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numEntities; j++) {
- if ( xf86Screens[i]->entityList[j] == entityIndex )
- return xf86Screens[i];
- }
- }
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+ if (xf86Screens[i]->entityList[j] == entityIndex)
+ return xf86Screens[i];
+ }
+ }
}
return NULL;
}
@@ -355,15 +364,15 @@ void
xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)
{
int i;
-
+
for (i = 0; i < pScrn->numEntities; i++) {
- if (pScrn->entityList[i] == entityIndex) {
- for (i++; i < pScrn->numEntities; i++)
- pScrn->entityList[i-1] = pScrn->entityList[i];
- pScrn->numEntities--;
- xf86Entities[entityIndex]->inUse = FALSE;
- break;
- }
+ if (pScrn->entityList[i] == entityIndex) {
+ for (i++; i < pScrn->numEntities; i++)
+ pScrn->entityList[i - 1] = pScrn->entityList[i];
+ pScrn->numEntities--;
+ xf86Entities[entityIndex]->inUse = FALSE;
+ break;
+ }
}
}
@@ -376,13 +385,14 @@ xf86ClearEntityListForScreen(int scrnIndex)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
int i, entityIndex;
-
- if (pScrn->entityList == NULL || pScrn->numEntities == 0) return;
-
+
+ if (pScrn->entityList == NULL || pScrn->numEntities == 0)
+ return;
+
for (i = 0; i < pScrn->numEntities; i++) {
- entityIndex = pScrn->entityList[i];
- xf86Entities[entityIndex]->inUse = FALSE;
- /* disable resource: call the disable function */
+ entityIndex = pScrn->entityList[i];
+ xf86Entities[entityIndex]->inUse = FALSE;
+ /* disable resource: call the disable function */
}
free(pScrn->entityList);
free(pScrn->entityInstanceList);
@@ -398,14 +408,14 @@ void
xf86AddDevToEntity(int entityIndex, GDevPtr dev)
{
EntityPtr pEnt;
-
+
if (entityIndex >= xf86NumEntities)
- return;
-
+ return;
+
pEnt = xf86Entities[entityIndex];
pEnt->numInstances++;
pEnt->devices = xnfrealloc(pEnt->devices,
- pEnt->numInstances * sizeof(GDevPtr));
+ pEnt->numInstances * sizeof(GDevPtr));
pEnt->devices[pEnt->numInstances - 1] = dev;
dev->claimed = TRUE;
}
@@ -420,28 +430,29 @@ xf86GetEntityInfo(int entityIndex)
{
EntityInfoPtr pEnt;
int i;
-
+
if (entityIndex == -1)
- return NULL;
+ return NULL;
if (entityIndex >= xf86NumEntities)
- return NULL;
-
- pEnt = xnfcalloc(1,sizeof(EntityInfoRec));
+ return NULL;
+
+ pEnt = xnfcalloc(1, sizeof(EntityInfoRec));
pEnt->index = entityIndex;
pEnt->location = xf86Entities[entityIndex]->bus;
pEnt->active = xf86Entities[entityIndex]->active;
pEnt->chipset = xf86Entities[entityIndex]->chipset;
pEnt->driver = xf86Entities[entityIndex]->driver;
- if ( (xf86Entities[entityIndex]->devices) &&
- (xf86Entities[entityIndex]->devices[0]) ) {
- for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
- if (xf86Entities[entityIndex]->devices[i]->screen == 0)
- break;
- pEnt->device = xf86Entities[entityIndex]->devices[i];
- } else
- pEnt->device = NULL;
-
+ if ((xf86Entities[entityIndex]->devices) &&
+ (xf86Entities[entityIndex]->devices[0])) {
+ for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
+ if (xf86Entities[entityIndex]->devices[i]->screen == 0)
+ break;
+ pEnt->device = xf86Entities[entityIndex]->devices[i];
+ }
+ else
+ pEnt->device = NULL;
+
return pEnt;
}
@@ -449,8 +460,8 @@ int
xf86GetNumEntityInstances(int entityIndex)
{
if (entityIndex >= xf86NumEntities)
- return -1;
-
+ return -1;
+
return xf86Entities[entityIndex]->numInstances;
}
@@ -458,19 +469,19 @@ GDevPtr
xf86GetDevFromEntity(int entityIndex, int instance)
{
int i;
-
+
/* We might not use AddDevtoEntity */
- if ( (!xf86Entities[entityIndex]->devices) ||
- (!xf86Entities[entityIndex]->devices[0]) )
- return NULL;
+ if ((!xf86Entities[entityIndex]->devices) ||
+ (!xf86Entities[entityIndex]->devices[0]))
+ return NULL;
if (entityIndex >= xf86NumEntities ||
- instance >= xf86Entities[entityIndex]->numInstances)
- return NULL;
-
+ instance >= xf86Entities[entityIndex]->numInstances)
+ return NULL;
+
for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
- if (xf86Entities[entityIndex]->devices[i]->screen == instance)
- break;
+ if (xf86Entities[entityIndex]->devices[i]->screen == instance)
+ break;
return xf86Entities[entityIndex]->devices[i];
}
@@ -485,7 +496,7 @@ xf86AccessEnter(void)
for (i = 0; i < xf86NumEntities; i++)
if (xf86Entities[i]->entityEnter)
- xf86Entities[i]->entityEnter(i,xf86Entities[i]->private);
+ xf86Entities[i]->entityEnter(i, xf86Entities[i]->private);
}
void
@@ -495,7 +506,7 @@ xf86AccessLeave(void)
for (i = 0; i < xf86NumEntities; i++)
if (xf86Entities[i]->entityLeave)
- xf86Entities[i]->entityLeave(i,xf86Entities[i]->private);
+ xf86Entities[i]->entityLeave(i, xf86Entities[i]->private);
}
/*
@@ -509,28 +520,29 @@ xf86PostProbe(void)
if (fbSlotClaimed && (
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- sbusSlotClaimed ||
+ sbusSlotClaimed ||
#endif
#ifdef XSERVER_LIBPCIACCESS
- pciSlotClaimed
+ pciSlotClaimed
#else
- TRUE
+ TRUE
#endif
- ))
- FatalError("Cannot run in framebuffer mode. Please specify busIDs "
- " for all framebuffer devices\n");
+ ))
+ FatalError("Cannot run in framebuffer mode. Please specify busIDs "
+ " for all framebuffer devices\n");
for (i = 0; i < xf86NumEntities; i++)
if (xf86Entities[i]->entityInit)
- xf86Entities[i]->entityInit(i,xf86Entities[i]->private);
+ xf86Entities[i]->entityInit(i, xf86Entities[i]->private);
}
int
xf86GetLastScrnFlag(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
return xf86Entities[entityIndex]->lastScrnFlag;
- } else {
+ }
+ else {
return -1;
}
}
@@ -538,7 +550,7 @@ xf86GetLastScrnFlag(int entityIndex)
void
xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->lastScrnFlag = scrnIndex;
}
}
@@ -546,10 +558,10 @@ xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
Bool
xf86IsEntityShared(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
- return TRUE;
- }
+ if (entityIndex < xf86NumEntities) {
+ if (xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
+ return TRUE;
+ }
}
return FALSE;
}
@@ -557,7 +569,7 @@ xf86IsEntityShared(int entityIndex)
void
xf86SetEntityShared(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL;
}
}
@@ -565,10 +577,10 @@ xf86SetEntityShared(int entityIndex)
Bool
xf86IsEntitySharable(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
- return TRUE;
- }
+ if (entityIndex < xf86NumEntities) {
+ if (xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
+ return TRUE;
+ }
}
return FALSE;
}
@@ -576,7 +588,7 @@ xf86IsEntitySharable(int entityIndex)
void
xf86SetEntitySharable(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE;
}
}
@@ -584,10 +596,10 @@ xf86SetEntitySharable(int entityIndex)
Bool
xf86IsPrimInitDone(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
- return TRUE;
- }
+ if (entityIndex < xf86NumEntities) {
+ if (xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
+ return TRUE;
+ }
}
return FALSE;
}
@@ -595,7 +607,7 @@ xf86IsPrimInitDone(int entityIndex)
void
xf86SetPrimInitDone(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE;
}
}
@@ -603,12 +615,11 @@ xf86SetPrimInitDone(int entityIndex)
void
xf86ClearPrimInitDone(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE;
}
}
-
/*
* Allocate a private in the entities.
*/
@@ -622,12 +633,12 @@ xf86AllocateEntityPrivateIndex(void)
idx = xf86EntityPrivateCount++;
for (i = 0; i < xf86NumEntities; i++) {
- pEnt = xf86Entities[i];
- nprivs = xnfrealloc(pEnt->entityPrivates,
- xf86EntityPrivateCount * sizeof(DevUnion));
- /* Zero the new private */
- memset(&nprivs[idx], 0, sizeof(DevUnion));
- pEnt->entityPrivates = nprivs;
+ pEnt = xf86Entities[i];
+ nprivs = xnfrealloc(pEnt->entityPrivates,
+ xf86EntityPrivateCount * sizeof(DevUnion));
+ /* Zero the new private */
+ memset(&nprivs[idx], 0, sizeof(DevUnion));
+ pEnt->entityPrivates = nprivs;
}
return idx;
}
@@ -636,8 +647,7 @@ DevUnion *
xf86GetEntityPrivate(int entityIndex, int privIndex)
{
if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount)
- return NULL;
+ return NULL;
return &(xf86Entities[entityIndex]->entityPrivates[privIndex]);
}
-