2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1997-2003 by The XFree86 Project, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name of the copyright holder(s)
|
|
|
|
* and author(s) shall not be used in advertising or otherwise to promote
|
|
|
|
* the sale, use or other dealings in this Software without prior written
|
|
|
|
* authorization from the copyright holder(s) and author(s).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file contains the interfaces to the bus-specific code
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include "os.h"
|
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86Priv.h"
|
|
|
|
|
|
|
|
/* Bus-specific headers */
|
|
|
|
|
|
|
|
#include "xf86Bus.h"
|
|
|
|
|
|
|
|
#define XF86_OS_PRIVS
|
|
|
|
#include "xf86_OSproc.h"
|
2012-06-10 07:21:05 -06:00
|
|
|
#ifdef XSERVER_LIBPCIACCESS
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "xf86VGAarbiter.h"
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
/* Entity data */
|
2012-06-10 07:21:05 -06:00
|
|
|
EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
|
2006-11-26 11:13:41 -07:00
|
|
|
int xf86NumEntities = 0;
|
|
|
|
static int xf86EntityPrivateCount = 0;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
BusRec primaryBus = { BUS_NONE, {0} };
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
/**
|
|
|
|
* 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
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CallDriverProbe(DriverPtr drv, Bool detect_only)
|
2010-12-05 08:36:02 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool foundScreen = FALSE;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
#ifdef XSERVER_PLATFORM_BUS
|
|
|
|
if (drv->platformProbe != NULL) {
|
|
|
|
foundScreen = xf86platformProbeDev(drv);
|
|
|
|
}
|
|
|
|
if (ServerIsNotSeat0())
|
|
|
|
return foundScreen;
|
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#ifdef XSERVER_LIBPCIACCESS
|
2013-06-07 11:28:45 -06:00
|
|
|
if (!foundScreen && (drv->PciProbe != NULL)) {
|
2010-12-05 08:36:02 -07:00
|
|
|
if (xf86DoConfigure && xf86DoConfigurePass1) {
|
|
|
|
assert(detect_only);
|
|
|
|
foundScreen = xf86PciAddMatchingDev(drv);
|
|
|
|
}
|
|
|
|
else {
|
2012-06-10 07:21:05 -06:00
|
|
|
assert(!detect_only);
|
2010-12-05 08:36:02 -07:00
|
|
|
foundScreen = xf86PciProbeDev(drv);
|
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!foundScreen && (drv->Probe != NULL)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86Msg(X_WARNING, "Falling back to old probe method for %s\n",
|
|
|
|
drv->driverName);
|
|
|
|
foundScreen = (*drv->Probe) (drv, (detect_only) ? PROBE_DETECT
|
|
|
|
: PROBE_DEFAULT);
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return foundScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return TRUE if all buses are configured and set up correctly and FALSE
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
Bool
|
|
|
|
xf86BusConfig(void)
|
|
|
|
{
|
|
|
|
screenLayoutPtr layout;
|
|
|
|
int i, j;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
/*
|
|
|
|
* 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++) {
|
|
|
|
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;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
for (j = 0; j < xf86Screens[i]->numEntities; j++) {
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
GDevPtr dev =
|
|
|
|
xf86GetDevFromEntity(xf86Screens[i]->entityList[j],
|
|
|
|
xf86Screens[i]->entityInstanceList[j]);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (dev == layout->screen->device) {
|
|
|
|
/* A match has been found */
|
|
|
|
xf86Screens[i]->confScreen = layout->screen;
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (found)
|
|
|
|
break;
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
|
|
|
if (layout->screen == NULL) {
|
|
|
|
/* No match found */
|
|
|
|
xf86Msg(X_ERROR,
|
2012-06-10 07:21:05 -06:00
|
|
|
"Screen %d deleted because of no matching config section.\n",
|
|
|
|
i);
|
2013-06-07 11:28:45 -06:00
|
|
|
xf86DeleteScreen(xf86Screens[i--]);
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
/* bind GPU conf screen to protocol screen 0 */
|
|
|
|
for (i = 0; i < xf86NumGPUScreens; i++)
|
|
|
|
xf86GPUScreens[i]->confScreen = xf86Screens[0]->confScreen;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
/* If no screens left, return now. */
|
|
|
|
if (xf86NumScreens == 0) {
|
|
|
|
xf86Msg(X_ERROR,
|
2012-06-10 07:21:05 -06:00
|
|
|
"Device(s) detected, but none match those in the config file.\n");
|
2010-12-05 08:36:02 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Call the bus probes relevant to the architecture.
|
|
|
|
*
|
|
|
|
* The only one available so far is for PCI and SBUS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
xf86BusProbe(void)
|
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
#ifdef XSERVER_PLATFORM_BUS
|
|
|
|
xf86platformProbe();
|
|
|
|
if (ServerIsNotSeat0())
|
|
|
|
return;
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
#ifdef XSERVER_LIBPCIACCESS
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86PciProbe();
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif
|
2008-11-02 08:26:08 -07:00
|
|
|
#if (defined(__sparc__) || defined(__sparc))
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86SbusProbe();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine what bus type the busID string represents. The start of the
|
|
|
|
* bus-dependent part of the string is returned as retID.
|
|
|
|
*/
|
|
|
|
|
|
|
|
BusType
|
2012-06-10 07:21:05 -06:00
|
|
|
StringToBusType(const char *busID, const char **retID)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
char *p, *s;
|
|
|
|
BusType ret = BUS_NONE;
|
|
|
|
|
|
|
|
/* If no type field, Default to PCI */
|
|
|
|
if (isdigit(busID[0])) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (retID)
|
|
|
|
*retID = busID;
|
|
|
|
return BUS_PCI;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
s = xstrdup(busID);
|
|
|
|
p = strtok(s, ":");
|
|
|
|
if (p == NULL || *p == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(s);
|
|
|
|
return BUS_NONE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (!xf86NameCmp(p, "pci") || !xf86NameCmp(p, "agp"))
|
2012-06-10 07:21:05 -06:00
|
|
|
ret = BUS_PCI;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!xf86NameCmp(p, "sbus"))
|
2012-06-10 07:21:05 -06:00
|
|
|
ret = BUS_SBUS;
|
2013-06-07 11:28:45 -06:00
|
|
|
if (!xf86NameCmp(p, "platform"))
|
|
|
|
ret = BUS_PLATFORM;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (ret != BUS_NONE)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (retID)
|
|
|
|
*retID = busID + strlen(p) + 1;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(s);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
xf86AllocateEntity(void)
|
|
|
|
{
|
|
|
|
xf86NumEntities++;
|
|
|
|
xf86Entities = xnfrealloc(xf86Entities,
|
2012-06-10 07:21:05 -06:00
|
|
|
sizeof(EntityPtr) * xf86NumEntities);
|
|
|
|
xf86Entities[xf86NumEntities - 1] = xnfcalloc(1, sizeof(EntityRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86Entities[xf86NumEntities - 1]->entityPrivates =
|
2012-06-10 07:21:05 -06:00
|
|
|
xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
|
2010-12-05 08:36:02 -07:00
|
|
|
return xf86NumEntities - 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86IsEntityPrimary(int entityIndex)
|
|
|
|
{
|
|
|
|
EntityPtr pEnt = xf86Entities[entityIndex];
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2013-12-28 07:40:01 -07:00
|
|
|
#ifdef XSERVER_LIBPCIACCESS
|
|
|
|
if (primaryBus.type == BUS_PLATFORM && pEnt->bus.type == BUS_PCI)
|
|
|
|
return MATCH_PCI_DEVICES(pEnt->bus.id.pci, primaryBus.id.plat->pdev);
|
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (primaryBus.type != pEnt->bus.type)
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
switch (pEnt->bus.type) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case BUS_PCI:
|
2012-06-10 07:21:05 -06:00
|
|
|
return pEnt->bus.id.pci == primaryBus.id.pci;
|
2006-11-26 11:13:41 -07:00
|
|
|
case BUS_SBUS:
|
2012-06-10 07:21:05 -06:00
|
|
|
return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
|
2013-06-07 11:28:45 -06:00
|
|
|
case BUS_PLATFORM:
|
|
|
|
return pEnt->bus.id.plat == primaryBus.id.plat;
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
Bool
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
|
2012-06-10 07:21:05 -06:00
|
|
|
EntityProc leave, pointer private)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (entityIndex >= xf86NumEntities)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86Entities[entityIndex]->entityInit = init;
|
|
|
|
xf86Entities[entityIndex]->entityEnter = enter;
|
|
|
|
xf86Entities[entityIndex]->entityLeave = leave;
|
|
|
|
xf86Entities[entityIndex]->private = private;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
xf86DriverHasEntities(DriverPtr drvp)
|
|
|
|
{
|
|
|
|
int i;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
for (i = 0; i < xf86NumEntities; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (xf86Entities[i]->driver == drvp)
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
|
|
|
|
{
|
|
|
|
if (entityIndex == -1)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (xf86Entities[entityIndex]->inUse &&
|
2012-06-10 07:21:05 -06:00
|
|
|
!(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) {
|
|
|
|
ErrorF("Requested Entity already in use!\n");
|
|
|
|
return;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScrn->numEntities++;
|
|
|
|
pScrn->entityList = xnfrealloc(pScrn->entityList,
|
2012-06-10 07:21:05 -06:00
|
|
|
pScrn->numEntities * sizeof(int));
|
2006-11-26 11:13:41 -07:00
|
|
|
pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
|
|
|
|
xf86Entities[entityIndex]->inUse = TRUE;
|
|
|
|
pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
|
2012-06-10 07:21:05 -06:00
|
|
|
pScrn->numEntities * sizeof(int));
|
2006-11-26 11:13:41 -07:00
|
|
|
pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (entityIndex == -1 || entityIndex >= xf86NumEntities)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
for (i = 0; i < pScrn->numEntities; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pScrn->entityList[i] == entityIndex) {
|
|
|
|
pScrn->entityInstanceList[i] = instance;
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX This needs to be updated for the case where a single entity may have
|
|
|
|
* instances associated with more than one screen.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
ScrnInfoPtr
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86FindScreenForEntity(int entityIndex)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
if (entityIndex == -1)
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (xf86Screens) {
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < xf86NumScreens; i++) {
|
|
|
|
for (j = 0; j < xf86Screens[i]->numEntities; j++) {
|
|
|
|
if (xf86Screens[i]->entityList[j] == entityIndex)
|
|
|
|
return xf86Screens[i];
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)
|
|
|
|
{
|
|
|
|
int i;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
for (i = 0; i < pScrn->numEntities; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-06-07 11:28:45 -06:00
|
|
|
* xf86ClearEntityListForScreen() - called when a screen is deleted
|
2006-11-26 11:13:41 -07:00
|
|
|
* to mark it's entities unused. Called by xf86DeleteScreen().
|
|
|
|
*/
|
|
|
|
void
|
2013-06-07 11:28:45 -06:00
|
|
|
xf86ClearEntityListForScreen(ScrnInfoPtr pScrn)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int i, entityIndex;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (pScrn->entityList == NULL || pScrn->numEntities == 0)
|
|
|
|
return;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
for (i = 0; i < pScrn->numEntities; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
entityIndex = pScrn->entityList[i];
|
|
|
|
xf86Entities[entityIndex]->inUse = FALSE;
|
|
|
|
/* disable resource: call the disable function */
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pScrn->entityList);
|
|
|
|
free(pScrn->entityInstanceList);
|
2006-11-26 11:13:41 -07:00
|
|
|
pScrn->entityList = NULL;
|
|
|
|
pScrn->entityInstanceList = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add an extra device section (GDevPtr) to an entity.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
xf86AddDevToEntity(int entityIndex, GDevPtr dev)
|
|
|
|
{
|
|
|
|
EntityPtr pEnt;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (entityIndex >= xf86NumEntities)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pEnt = xf86Entities[entityIndex];
|
|
|
|
pEnt->numInstances++;
|
|
|
|
pEnt->devices = xnfrealloc(pEnt->devices,
|
2012-06-10 07:21:05 -06:00
|
|
|
pEnt->numInstances * sizeof(GDevPtr));
|
2006-11-26 11:13:41 -07:00
|
|
|
pEnt->devices[pEnt->numInstances - 1] = dev;
|
|
|
|
dev->claimed = TRUE;
|
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
void
|
|
|
|
xf86RemoveDevFromEntity(int entityIndex, GDevPtr dev)
|
|
|
|
{
|
|
|
|
EntityPtr pEnt;
|
|
|
|
int i, j;
|
|
|
|
if (entityIndex >= xf86NumEntities)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pEnt = xf86Entities[entityIndex];
|
|
|
|
for (i = 0; i < pEnt->numInstances; i++) {
|
|
|
|
if (pEnt->devices[i] == dev) {
|
|
|
|
for (j = i; j < pEnt->numInstances - 1; j++)
|
|
|
|
pEnt->devices[j] = pEnt->devices[j + 1];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pEnt->numInstances--;
|
|
|
|
dev->claimed = FALSE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* xf86GetEntityInfo() -- This function hands information from the
|
|
|
|
* EntityRec struct to the drivers. The EntityRec structure itself
|
|
|
|
* remains invisible to the driver.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
EntityInfoPtr
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86GetEntityInfo(int entityIndex)
|
|
|
|
{
|
|
|
|
EntityInfoPtr pEnt;
|
|
|
|
int i;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (entityIndex == -1)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (entityIndex >= xf86NumEntities)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pEnt = xnfcalloc(1, sizeof(EntityInfoRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
pEnt->index = entityIndex;
|
|
|
|
pEnt->location = xf86Entities[entityIndex]->bus;
|
|
|
|
pEnt->active = xf86Entities[entityIndex]->active;
|
|
|
|
pEnt->chipset = xf86Entities[entityIndex]->chipset;
|
|
|
|
pEnt->driver = xf86Entities[entityIndex]->driver;
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
return pEnt;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86GetNumEntityInstances(int entityIndex)
|
|
|
|
{
|
|
|
|
if (entityIndex >= xf86NumEntities)
|
2012-06-10 07:21:05 -06:00
|
|
|
return -1;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
return xf86Entities[entityIndex]->numInstances;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
GDevPtr
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86GetDevFromEntity(int entityIndex, int instance)
|
|
|
|
{
|
|
|
|
int i;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* We might not use AddDevtoEntity */
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!xf86Entities[entityIndex]->devices) ||
|
|
|
|
(!xf86Entities[entityIndex]->devices[0]))
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (entityIndex >= xf86NumEntities ||
|
2012-06-10 07:21:05 -06:00
|
|
|
instance >= xf86Entities[entityIndex]->numInstances)
|
|
|
|
return NULL;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (xf86Entities[entityIndex]->devices[i]->screen == instance)
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
return xf86Entities[entityIndex]->devices[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* xf86AccessEnter() -- gets called to save the text mode VGA IO
|
|
|
|
* resources when reentering the server after a VT switch.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xf86AccessEnter(void)
|
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < xf86NumEntities; i++)
|
|
|
|
if (xf86Entities[i]->entityEnter)
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86Entities[i]->entityEnter(i, xf86Entities[i]->private);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
xf86AccessLeave(void)
|
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
for (i = 0; i < xf86NumEntities; i++)
|
|
|
|
if (xf86Entities[i]->entityLeave)
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86Entities[i]->entityLeave(i, xf86Entities[i]->private);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
2010-07-27 13:02:24 -06:00
|
|
|
* xf86PostProbe() -- Allocate all non conflicting resources
|
|
|
|
* This function gets called by xf86Init().
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
|
|
|
xf86PostProbe(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
int i;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (fbSlotClaimed && (
|
2010-07-27 13:02:24 -06:00
|
|
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
2012-06-10 07:21:05 -06:00
|
|
|
sbusSlotClaimed ||
|
2010-07-27 13:02:24 -06:00
|
|
|
#endif
|
2013-06-07 11:28:45 -06:00
|
|
|
#ifdef XSERVER_PLATFORM_BUS
|
|
|
|
platformSlotClaimed ||
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
#ifdef XSERVER_LIBPCIACCESS
|
|
|
|
pciSlotClaimed
|
|
|
|
#else
|
|
|
|
TRUE
|
|
|
|
#endif
|
|
|
|
))
|
|
|
|
FatalError("Cannot run in framebuffer mode. Please specify busIDs "
|
|
|
|
" for all framebuffer devices\n");
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
for (i = 0; i < xf86NumEntities; i++)
|
|
|
|
if (xf86Entities[i]->entityInit)
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86Entities[i]->entityInit(i, xf86Entities[i]->private);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
|
|
|
xf86GetLastScrnFlag(int entityIndex)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (entityIndex < xf86NumEntities) {
|
2010-12-05 08:36:02 -07:00
|
|
|
return xf86Entities[entityIndex]->lastScrnFlag;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2010-07-27 13:02:24 -06:00
|
|
|
return -1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
|
|
|
xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (entityIndex < xf86NumEntities) {
|
2010-07-27 13:02:24 -06:00
|
|
|
xf86Entities[entityIndex]->lastScrnFlag = scrnIndex;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
|
|
|
xf86IsEntityShared(int entityIndex)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (entityIndex < xf86NumEntities) {
|
|
|
|
if (xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
|
|
|
xf86SetEntityShared(int entityIndex)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (entityIndex < xf86NumEntities) {
|
2010-07-27 13:02:24 -06:00
|
|
|
xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
|
|
|
xf86IsEntitySharable(int entityIndex)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (entityIndex < xf86NumEntities) {
|
|
|
|
if (xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86SetEntitySharable(int entityIndex)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (entityIndex < xf86NumEntities) {
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86IsPrimInitDone(int entityIndex)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (entityIndex < xf86NumEntities) {
|
|
|
|
if (xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86SetPrimInitDone(int entityIndex)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (entityIndex < xf86NumEntities) {
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86ClearPrimInitDone(int entityIndex)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (entityIndex < xf86NumEntities) {
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a private in the entities.
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86AllocateEntityPrivateIndex(void)
|
|
|
|
{
|
|
|
|
int idx, i;
|
|
|
|
EntityPtr pEnt;
|
|
|
|
DevUnion *nprivs;
|
|
|
|
|
|
|
|
idx = xf86EntityPrivateCount++;
|
|
|
|
for (i = 0; i < xf86NumEntities; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pEnt = xf86Entities[i];
|
|
|
|
nprivs = xnfrealloc(pEnt->entityPrivates,
|
|
|
|
xf86EntityPrivateCount * sizeof(DevUnion));
|
|
|
|
/* Zero the new private */
|
|
|
|
memset(&nprivs[idx], 0, sizeof(DevUnion));
|
|
|
|
pEnt->entityPrivates = nprivs;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
DevUnion *
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86GetEntityPrivate(int entityIndex, int privIndex)
|
|
|
|
{
|
|
|
|
if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return &(xf86Entities[entityIndex]->entityPrivates[privIndex]);
|
|
|
|
}
|