From 74fa9a70a4817660f1c2ec3b3cc2bbe56db4fc58 Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 25 May 2010 06:29:35 +0000 Subject: xserver git update 25/5/2010 --- xorg-server/hw/xfree86/common/xf86.h | 57 +- xorg-server/hw/xfree86/common/xf86AutoConfig.c | 248 +-- xorg-server/hw/xfree86/common/xf86Bus.c | 39 - xorg-server/hw/xfree86/common/xf86Bus.h | 151 +- xorg-server/hw/xfree86/common/xf86Configure.c | 2 - xorg-server/hw/xfree86/common/xf86Helper.c | 505 ------ xorg-server/hw/xfree86/common/xf86Priv.h | 4 - xorg-server/hw/xfree86/common/xf86Xinput.c | 6 +- xorg-server/hw/xfree86/common/xf86pciBus.c | 746 +++++++++ xorg-server/hw/xfree86/common/xf86pciBus.h | 1 + xorg-server/hw/xfree86/common/xf86str.h | 1836 +++++++++++----------- xorg-server/hw/xfree86/doc/Makefile.am | 17 +- xorg-server/hw/xfree86/doc/README.DRI | 1256 --------------- xorg-server/hw/xfree86/doc/README.rapidaccess | 48 - xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre | 3 +- xorg-server/hw/xfree86/modes/xf86Crtc.c | 61 +- xorg-server/hw/xfree86/os-support/bus/Pci.c | 315 ++-- xorg-server/hw/xfree86/os-support/bus/Pci.h | 330 ++-- xorg-server/hw/xfree86/vbe/vbe.c | 1 - xorg-server/hw/xfree86/vbe/vbe.h | 2 +- 20 files changed, 2143 insertions(+), 3485 deletions(-) delete mode 100644 xorg-server/hw/xfree86/doc/README.DRI delete mode 100644 xorg-server/hw/xfree86/doc/README.rapidaccess (limited to 'xorg-server/hw') diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h index 2a8b7e0a9..b7a884b2a 100644 --- a/xorg-server/hw/xfree86/common/xf86.h +++ b/xorg-server/hw/xfree86/common/xf86.h @@ -41,8 +41,6 @@ #include #endif -#include - #include "xf86str.h" #include "xf86Opt.h" #include @@ -62,7 +60,6 @@ extern _X_EXPORT DevPrivateKey xf86CreateRootWindowKey; extern _X_EXPORT DevPrivateKey xf86PixmapKey; extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */ extern _X_EXPORT const unsigned char byte_reversed[256]; -extern _X_EXPORT Bool pciSlotClaimed; extern _X_EXPORT Bool fbSlotClaimed; #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) extern _X_EXPORT Bool sbusSlotClaimed; @@ -91,21 +88,39 @@ extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */ /* Function Prototypes */ #ifndef _NO_XF86_PROTOTYPES -/* xf86Bus.c */ +/* PCI related */ +#include +extern _X_EXPORT Bool pciSlotClaimed; -extern _X_EXPORT Bool xf86CheckPciSlot( const struct pci_device * ); -extern _X_EXPORT int xf86ClaimPciSlot( struct pci_device *, DriverPtr drvp, - int chipset, GDevPtr dev, Bool active); +extern _X_EXPORT Bool xf86CheckPciSlot(const struct pci_device *); +extern _X_EXPORT int xf86ClaimPciSlot(struct pci_device *, DriverPtr drvp, + int chipset, GDevPtr dev, Bool active); extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *); -extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus, int *device, - int *func); -extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func); +extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus, + int *device, int *func); +extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus, + int device, int func); extern _X_EXPORT void xf86FormatPciBusNumber(int busnum, char *buffer); +extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci); +extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci, + memType base); +extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex); +extern _X_EXPORT int xf86MatchPciInstances(const char *driverName, + int vendorID, SymTabPtr chipsets, PciChipsets *PCIchipsets, + GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities); +extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, + int scrnFlag, int entityIndex,PciChipsets *p_chip, void *dummy, + EntityProc init, EntityProc enter, EntityProc leave, pointer private); +/* Obsolete! don't use */ +extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, + int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init, + EntityProc enter, EntityProc leave, pointer private); + +/* xf86Bus.c */ + extern _X_EXPORT int xf86GetFbInfoForScreen(int scrnIndex); extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); -extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci); -/* new RAC */ extern _X_EXPORT Bool xf86DriverHasEntities(DriverPtr drvp); extern _X_EXPORT void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex); extern _X_EXPORT void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, @@ -114,10 +129,8 @@ extern _X_EXPORT int xf86GetNumEntityInstances(int entityIndex); extern _X_EXPORT GDevPtr xf86GetDevFromEntity(int entityIndex, int instance); extern _X_EXPORT void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex); extern _X_EXPORT EntityInfoPtr xf86GetEntityInfo(int entityIndex); -extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex); extern _X_EXPORT Bool xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter, EntityProc leave, pointer); -extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci, memType base); extern _X_EXPORT Bool xf86IsEntityPrimary(int entityIndex); extern _X_EXPORT void xf86EnterServerState(xf86State state); extern _X_EXPORT ScrnInfoPtr xf86FindScreenForEntity(int entityIndex); @@ -223,10 +236,6 @@ extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from); extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips); extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist); -extern _X_EXPORT int xf86MatchPciInstances(const char *driverName, int vendorID, - SymTabPtr chipsets, PciChipsets *PCIchipsets, - GDevPtr *devList, int numDevs, DriverPtr drvp, - int **foundEntities); extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int), void (*ProtectRegs)(ScrnInfoPtr, Bool), @@ -265,23 +274,11 @@ extern _X_EXPORT void xf86SetSilkenMouse(ScreenPtr pScreen); extern _X_EXPORT pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name, char **adaptor_name, pointer *adaptor_options); extern _X_EXPORT void xf86GetOS(const char **name, int *major, int *minor, int *teeny); -extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, - int entityIndex,PciChipsets *p_chip, - void *dummy, EntityProc init, - EntityProc enter, EntityProc leave, - pointer private); extern _X_EXPORT ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, EntityProc init, EntityProc enter, EntityProc leave, pointer private); -/* Obsolete! don't use */ -extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, - int entityIndex,PciChipsets *p_chip, - void *dummy, EntityProc init, - EntityProc enter, EntityProc leave, - pointer private); - extern _X_EXPORT Bool xf86IsScreenPrimary(int scrnIndex); extern _X_EXPORT int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, int format, unsigned long len, diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c index 88891e5a7..9f6348681 100644 --- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c +++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c @@ -39,10 +39,10 @@ #include "xf86Config.h" #include "xf86Priv.h" #include "xf86_OSlib.h" +#include "xf86pciBus.h" #ifdef __sparc__ # include "xf86sbusBus.h" #endif -#include "dirent.h" #ifdef sun # include @@ -140,102 +140,6 @@ AppendToConfig(const char *s) AppendToList(s, &builtinConfig, &builtinLines); } -static int -videoPtrToDriverList(struct pci_device *dev, - char *returnList[], int returnListMax) -{ - int i; - /* Add more entries here if we ever return more than 4 drivers for - any device */ - char *driverList[5] = { NULL, NULL, NULL, NULL, NULL }; - - switch (dev->vendor_id) - { - /* AMD Geode LX */ - case 0x1022: - if (dev->device_id == 0x2081) - driverList[0] = "geode"; - break; - /* older Geode products acquired by AMD still carry an NSC vendor_id */ - case 0x100b: - if (dev->device_id == 0x0030) { - /* NSC Geode GX2 specifically */ - driverList[0] = "geode"; - /* GX2 support started its life in the NSC tree and was later - forked by AMD for GEODE so we keep it as a backup */ - driverList[1] = "nsc"; - } else - /* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */ - driverList[0] = "nsc"; - break; - /* Cyrix Geode GX1 */ - case 0x1078: - if (dev->device_id == 0x0104) - driverList[0] = "cyrix"; - break; - case 0x1142: driverList[0] = "apm"; break; - case 0xedd8: driverList[0] = "ark"; break; - case 0x1a03: driverList[0] = "ast"; break; - case 0x1002: driverList[0] = "ati"; break; - case 0x102c: driverList[0] = "chips"; break; - case 0x1013: driverList[0] = "cirrus"; break; - case 0x3d3d: driverList[0] = "glint"; break; - case 0x105d: driverList[0] = "i128"; break; - case 0x8086: - if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) { - driverList[0] = "i740"; - } else if (dev->device_id == 0x8108) { - break; /* "hooray" for poulsbo */ - } else { - driverList[0] = "intel"; - } - break; - case 0x102b: driverList[0] = "mga"; break; - case 0x10c8: driverList[0] = "neomagic"; break; - case 0x10de: case 0x12d2: driverList[0] = "nv"; break; - case 0x1106: driverList[0] = "openchrome"; break; - case 0x1b36: driverList[0] = "qxl"; break; - case 0x1163: driverList[0] = "rendition"; break; - case 0x5333: - switch (dev->device_id) - { - case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811: - case 0x8812: case 0x8814: case 0x8901: - driverList[0] = "s3"; break; - case 0x5631: case 0x883d: case 0x8a01: case 0x8a10: - case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13: - driverList[0] = "s3virge"; break; - default: - driverList[0] = "savage"; break; - } - break; - case 0x1039: driverList[0] = "sis"; break; - case 0x126f: driverList[0] = "siliconmotion"; break; - case 0x121a: - if (dev->device_id < 0x0003) - driverList[0] = "voodoo"; - else - driverList[0] = "tdfx"; - break; - case 0x1011: driverList[0] = "tga"; break; - case 0x1023: driverList[0] = "trident"; break; - case 0x100c: driverList[0] = "tseng"; break; - case 0x80ee: driverList[0] = "vboxvideo"; break; - case 0x15ad: driverList[0] = "vmware"; break; - case 0x18ca: - if (dev->device_id == 0x47) - driverList[0] = "xgixp"; - else - driverList[0] = "xgi"; - break; - default: break; - } - for (i = 0; (i < returnListMax) && (driverList[i] != NULL); i++) { - returnList[i] = xnfstrdup(driverList[i]); - } - return i; /* Number of entries added */ -} - Bool xf86AutoConfig(void) { @@ -285,132 +189,9 @@ xf86AutoConfig(void) return (ret == CONFIG_OK); } -static int -xchomp(char *line) -{ - size_t len = 0; - - if (!line) { - return 1; - } - - len = strlen(line); - if (line[len - 1] == '\n' && len > 0) { - line[len - 1] = '\0'; - } - return 0; -} - -#ifdef __linux__ -/* This function is used to provide a workaround for binary drivers that - * don't export their PCI ID's properly. If distros don't end up using this - * feature it can and should be removed because the symbol-based resolution - * scheme should be the primary one */ -static void -matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip) -{ - DIR *idsdir; - FILE *fp; - struct dirent *direntry; - char *line = NULL; - size_t len; - ssize_t read; - char path_name[256], vendor_str[5], chip_str[5]; - uint16_t vendor, chip; - int i, j; - - idsdir = opendir(PCI_TXT_IDS_PATH); - if (!idsdir) - return; - - xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH); - direntry = readdir(idsdir); - /* Read the directory */ - while (direntry) { - if (direntry->d_name[0] == '.') { - direntry = readdir(idsdir); - continue; - } - len = strlen(direntry->d_name); - /* A tiny bit of sanity checking. We should probably do better */ - if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) { - /* We need the full path name to open the file */ - strncpy(path_name, PCI_TXT_IDS_PATH, 256); - strncat(path_name, "/", 1); - strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1)); - fp = fopen(path_name, "r"); - if (fp == NULL) { - xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name); - goto end; - } - /* Read the file */ -#ifdef __GLIBC__ - while ((read = getline(&line, &len, fp)) != -1) { -#else - while ((line = fgetln(fp, &len)) != (char *)NULL) { -#endif /* __GLIBC __ */ - xchomp(line); - if (isdigit(line[0])) { - strncpy(vendor_str, line, 4); - vendor_str[4] = '\0'; - vendor = (int)strtol(vendor_str, NULL, 16); - if ((strlen(&line[4])) == 0) { - chip_str[0] = '\0'; - chip = -1; - } else { - /* Handle trailing whitespace */ - if (isspace(line[4])) { - chip_str[0] = '\0'; - chip = -1; - } else { - /* Ok, it's a real ID */ - strncpy(chip_str, &line[4], 4); - chip_str[4] = '\0'; - chip = (int)strtol(chip_str, NULL, 16); - } - } - if (vendor == match_vendor && chip == match_chip ) { - i = 0; - while (matches[i]) { - i++; - } - matches[i] = (char*)malloc(sizeof(char) * strlen(direntry->d_name) - 3); - if (!matches[i]) { - xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n"); - goto end; - } - /* hack off the .ids suffix. This should guard - * against other problems, but it will end up - * taking off anything after the first '.' */ - for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) { - if (direntry->d_name[j] == '.') { - matches[i][j] = '\0'; - break; - } else { - matches[i][j] = direntry->d_name[j]; - } - } - xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name); - } - } else { - /* TODO Handle driver overrides here */ - } - } - fclose(fp); - } - direntry = readdir(idsdir); - } - end: - free(line); - closedir(idsdir); -} -#endif /* __linux__ */ - static void listPossibleVideoDrivers(char *matches[], int nmatches) { - struct pci_device * info = NULL; - struct pci_device_iterator *iter; int i; for (i = 0 ; i < nmatches ; i++) { @@ -476,32 +257,7 @@ listPossibleVideoDrivers(char *matches[], int nmatches) } #endif - /* Find the primary device, and get some information about it. */ - iter = pci_slot_match_iterator_create(NULL); - while ((info = pci_device_next(iter)) != NULL) { - if (xf86IsPrimaryPci(info)) { - break; - } - } - - pci_iterator_destroy(iter); - - if (!info) { - ErrorF("Primary device is not PCI\n"); - } -#ifdef __linux__ - else { - matchDriverFromFiles(matches, info->vendor_id, info->device_id); - } -#endif /* __linux__ */ - - for (i = 0; (i < nmatches) && (matches[i]); i++) { - /* find end of matches list */ - } - - if ((info != NULL) && (i < nmatches)) { - i += videoPtrToDriverList(info, &(matches[i]), nmatches - i); - } + xf86PciMatchDriver(matches, nmatches); /* Fallback to platform default hardware */ if (i < (nmatches - 1)) { diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c index 09b94654c..77693d742 100644 --- a/xorg-server/hw/xfree86/common/xf86Bus.c +++ b/xorg-server/hw/xfree86/common/xf86Bus.c @@ -49,8 +49,6 @@ #include "xf86_OSproc.h" #include "xf86VGAarbiter.h" -#include "Pci.h" - /* Entity data */ EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */ int xf86NumEntities = 0; @@ -113,10 +111,6 @@ xf86BusConfig(void) 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 @@ -559,39 +553,6 @@ xf86PostScreenInit(void) xf86EnterServerState(OPERATING); } -/* - * xf86FindPrimaryDevice() - Find the display device which - * was active when the server was started. - */ -void -xf86FindPrimaryDevice(void) -{ - if (primaryBus.type != BUS_NONE) { - char *bus; - char loc[16]; - - switch (primaryBus.type) { - case BUS_PCI: - bus = "PCI"; - snprintf(loc, sizeof(loc), " %2.2x@%2.2x:%2.2x:%1.1x", - primaryBus.id.pci->bus, - primaryBus.id.pci->domain, - primaryBus.id.pci->dev, - primaryBus.id.pci->func); - break; - case BUS_SBUS: - bus = "SBUS"; - snprintf(loc, sizeof(loc), " %2.2x", primaryBus.id.sbus.fbNum); - break; - default: - bus = ""; - loc[0] = '\0'; - } - - xf86MsgVerb(X_INFO, 2, "Primary Device is: %s%s\n",bus,loc); - } -} - int xf86GetLastScrnFlag(int entityIndex) { diff --git a/xorg-server/hw/xfree86/common/xf86Bus.h b/xorg-server/hw/xfree86/common/xf86Bus.h index b22e2e772..4e3d7d7cb 100644 --- a/xorg-server/hw/xfree86/common/xf86Bus.h +++ b/xorg-server/hw/xfree86/common/xf86Bus.h @@ -1,76 +1,75 @@ -/* - * 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 definitions of the bus-related data structures/types. - * Everything contained here is private to xf86Bus.c. In particular the - * video drivers must not include this file. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#ifndef _XF86_BUS_H -#define _XF86_BUS_H - -#include "xf86pciBus.h" -#if defined(__sparc__) || defined(__sparc) -#include "xf86sbusBus.h" -#endif - -typedef struct { - DriverPtr driver; - int chipset; - int entityProp; - EntityProc entityInit; - EntityProc entityEnter; - EntityProc entityLeave; - pointer private; - Bool active; - Bool inUse; - BusRec bus; - pointer busAcc; - int lastScrnFlag; - DevUnion * entityPrivates; - int numInstances; - GDevPtr * devices; - IOADDRESS domainIO; -} EntityRec, *EntityPtr; - -#define ACCEL_IS_SHARABLE 0x100 -#define IS_SHARED_ACCEL 0x200 -#define SA_PRIM_INIT_DONE 0x400 - -extern EntityPtr *xf86Entities; -extern int xf86NumEntities; -extern BusRec primaryBus; - -int xf86AllocateEntity(void); -BusType StringToBusType(const char* busID, const char **retID); - -#endif /* _XF86_BUS_H */ +/* + * 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 definitions of the bus-related data structures/types. + * Everything contained here is private to xf86Bus.c. In particular the + * video drivers must not include this file. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef _XF86_BUS_H +#define _XF86_BUS_H + +#include "xf86pciBus.h" +#if defined(__sparc__) || defined(__sparc) +#include "xf86sbusBus.h" +#endif + +typedef struct { + DriverPtr driver; + int chipset; + int entityProp; + EntityProc entityInit; + EntityProc entityEnter; + EntityProc entityLeave; + pointer private; + Bool active; + Bool inUse; + BusRec bus; + int lastScrnFlag; + DevUnion * entityPrivates; + int numInstances; + GDevPtr * devices; + IOADDRESS domainIO; +} EntityRec, *EntityPtr; + +#define ACCEL_IS_SHARABLE 0x100 +#define IS_SHARED_ACCEL 0x200 +#define SA_PRIM_INIT_DONE 0x400 + +extern EntityPtr *xf86Entities; +extern int xf86NumEntities; +extern BusRec primaryBus; + +int xf86AllocateEntity(void); +BusType StringToBusType(const char* busID, const char **retID); + +#endif /* _XF86_BUS_H */ diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c index 11dfcb848..c2b7464cd 100644 --- a/xorg-server/hw/xfree86/common/xf86Configure.c +++ b/xorg-server/hw/xfree86/common/xf86Configure.c @@ -681,8 +681,6 @@ DoConfigure(void) xorgHWAccess = FALSE; } - xf86FindPrimaryDevice(); - /* Create XF86Config file structure */ xf86config = calloc(1, sizeof(XF86ConfigRec)); diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c index 4cc543fc4..1b9bd1f1e 100644 --- a/xorg-server/hw/xfree86/common/xf86Helper.c +++ b/xorg-server/hw/xfree86/common/xf86Helper.c @@ -38,9 +38,6 @@ #include #endif -#include -#include "Pci.h" - #include #include "os.h" #include "servermd.h" @@ -57,7 +54,6 @@ #include "xf86Xinput.h" #include "xf86InPriv.h" #include "mivalidate.h" -#include "xf86Bus.h" #include "xf86Crtc.h" /* For xf86GetClocks */ @@ -1444,8 +1440,6 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist) if (sectlist) *sectlist = NULL; - if (xf86DoConfigure && xf86DoConfigurePass1) return 1; - /* * This is a very important function that matches the device sections * as they show up in the config file with the drivers that the server @@ -1506,420 +1500,6 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist) return i; } -static Bool -pciDeviceHasBars(struct pci_device *pci) -{ - int i; - - for (i = 0; i < 6; i++) - if (pci->regions[i].size) - return TRUE; - - if (pci->rom_size) - return TRUE; - - return FALSE; -} - -struct Inst { - struct pci_device * pci; - GDevPtr dev; - Bool foundHW; /* PCIid in list of supported chipsets */ - Bool claimed; /* BusID matches with a device section */ - int chip; - int screen; -}; - - -/** - * Find set of unclaimed devices matching a given vendor ID. - * - * Used by drivers to find as yet unclaimed devices matching the specified - * vendor ID. - * - * \param driverName Name of the driver. This is used to find Device - * sections in the config file. - * \param vendorID PCI vendor ID of associated devices. If zero, then - * the true vendor ID must be encoded in the \c PCIid - * fields of the \c PCIchipsets entries. - * \param chipsets Symbol table used to associate chipset names with - * PCI IDs. - * \param devList List of Device sections parsed from the config file. - * \param numDevs Number of entries in \c devList. - * \param drvp Pointer the driver's control structure. - * \param foundEntities Returned list of entity indicies associated with the - * driver. - * - * \returns - * The number of elements in returned in \c foundEntities on success or zero - * on failure. - * - * \todo - * This function does a bit more than short description says. Fill in some - * more of the details of its operation. - * - * \todo - * The \c driverName parameter is redundant. It is the same as - * \c DriverRec::driverName. In a future version of this function, remove - * that parameter. - */ -int -xf86MatchPciInstances(const char *driverName, int vendorID, - SymTabPtr chipsets, PciChipsets *PCIchipsets, - GDevPtr *devList, int numDevs, DriverPtr drvp, - int **foundEntities) -{ - int i,j; - struct pci_device * pPci; - struct pci_device_iterator *iter; - struct Inst *instances = NULL; - int numClaimedInstances = 0; - int allocatedInstances = 0; - int numFound = 0; - SymTabRec *c; - PciChipsets *id; - int *retEntities = NULL; - - *foundEntities = NULL; - - - /* Each PCI device will contribute at least one entry. Each device - * section can contribute at most one entry. The sum of the two is - * guaranteed to be larger than the maximum possible number of entries. - * Do this calculation and memory allocation once now to eliminate the - * need for realloc calls inside the loop. - */ - if (!(xf86DoConfigure && xf86DoConfigurePass1)) { - unsigned max_entries = numDevs; - - iter = pci_slot_match_iterator_create(NULL); - while ((pPci = pci_device_next(iter)) != NULL) { - max_entries++; - } - - pci_iterator_destroy(iter); - instances = xnfalloc(max_entries * sizeof(struct Inst)); - } - - iter = pci_slot_match_iterator_create(NULL); - while ((pPci = pci_device_next(iter)) != NULL) { - unsigned device_class = pPci->device_class; - Bool foundVendor = FALSE; - - - /* Convert the pre-PCI 2.0 device class for a VGA adapter to the - * 2.0 version of the same class. - */ - if ( device_class == 0x00000101 ) { - device_class = 0x00030000; - } - - - /* Find PCI devices that match the given vendor ID. The vendor ID is - * either specified explicitly as a parameter to the function or - * implicitly encoded in the high bits of id->PCIid. - * - * The first device with a matching vendor is recorded, even if the - * device ID doesn't match. This is done because the Device section - * in the xorg.conf file can over-ride the device ID. A matching PCI - * ID might not be found now, but after the device ID over-ride is - * applied there /might/ be a match. - */ - for (id = PCIchipsets; id->PCIid != -1; id++) { - const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16) - | vendorID; - const unsigned device_id = (id->PCIid & 0x0000FFFF); - const unsigned match_class = 0x00030000 | id->PCIid; - - if ((vendor_id == pPci->vendor_id) - || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) { - if (!foundVendor && (instances != NULL)) { - ++allocatedInstances; - instances[allocatedInstances - 1].pci = pPci; - instances[allocatedInstances - 1].dev = NULL; - instances[allocatedInstances - 1].claimed = FALSE; - instances[allocatedInstances - 1].foundHW = FALSE; - instances[allocatedInstances - 1].screen = 0; - } - - foundVendor = TRUE; - - if ( (device_id == pPci->device_id) - || ((vendorID == PCI_VENDOR_GENERIC) - && (match_class == device_class)) ) { - if ( instances != NULL ) { - instances[allocatedInstances - 1].foundHW = TRUE; - instances[allocatedInstances - 1].chip = id->numChipset; - } - - - if ( xf86DoConfigure && xf86DoConfigurePass1 ) { - if (xf86CheckPciSlot(pPci)) { - GDevPtr pGDev = - xf86AddBusDeviceToConfigure(drvp->driverName, - BUS_PCI, pPci, -1); - if (pGDev) { - /* After configure pass 1, chipID and chipRev - * are treated as over-rides, so clobber them - * here. - */ - pGDev->chipID = -1; - pGDev->chipRev = -1; - } - - numFound++; - } - } - else { - numFound++; - } - - break; - } - } - } - } - - pci_iterator_destroy(iter); - - - /* In "probe only" or "configure" mode (signaled by instances being NULL), - * our work is done. Return the number of detected devices. - */ - if ( instances == NULL ) { - return numFound; - } - - - /* - * This may be debatable, but if no PCI devices with a matching vendor - * type is found, return zero now. It is probably not desirable to - * allow the config file to override this. - */ - if (allocatedInstances <= 0) { - free(instances); - return 0; - } - - - DebugF("%s instances found: %d\n", driverName, allocatedInstances); - - /* - * Check for devices that need duplicated instances. This is required - * when there is more than one screen per entity. - * - * XXX This currently doesn't work for cases where the BusID isn't - * specified explicitly in the config file. - */ - - for (j = 0; j < numDevs; j++) { - if (devList[j]->screen > 0 && devList[j]->busID - && *devList[j]->busID) { - for (i = 0; i < allocatedInstances; i++) { - pPci = instances[i].pci; - if (xf86ComparePciBusString(devList[j]->busID, - PCI_MAKE_BUS( pPci->domain, pPci->bus ), - pPci->dev, - pPci->func)) { - allocatedInstances++; - instances[allocatedInstances - 1] = instances[i]; - instances[allocatedInstances - 1].screen = - devList[j]->screen; - numFound++; - break; - } - } - } - } - - for (i = 0; i < allocatedInstances; i++) { - GDevPtr dev = NULL; - GDevPtr devBus = NULL; - - pPci = instances[i].pci; - for (j = 0; j < numDevs; j++) { - if (devList[j]->busID && *devList[j]->busID) { - if (xf86ComparePciBusString(devList[j]->busID, - PCI_MAKE_BUS( pPci->domain, pPci->bus ), - pPci->dev, - pPci->func) && - devList[j]->screen == instances[i].screen) { - - if (devBus) - xf86MsgVerb(X_WARNING,0, - "%s: More than one matching Device section for " - "instances\n\t(BusID: %s) found: %s\n", - driverName, devList[j]->busID, - devList[j]->identifier); - else - devBus = devList[j]; - } - } else { - /* - * if device section without BusID is found - * only assign to it to the primary device. - */ - if (xf86IsPrimaryPci(pPci)) { - xf86Msg(X_PROBED, "Assigning device section with no busID" - " to primary device\n"); - if (dev || devBus) - xf86MsgVerb(X_WARNING, 0, - "%s: More than one matching Device section " - "found: %s\n", driverName, devList[j]->identifier); - else - dev = devList[j]; - } - } - } - if (devBus) dev = devBus; /* busID preferred */ - if (!dev) { - if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) { - xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section " - "for instance (BusID PCI:%u@%u:%u:%u) found\n", - driverName, pPci->domain, pPci->bus, pPci->dev, - pPci->func); - } - } else { - numClaimedInstances++; - instances[i].claimed = TRUE; - instances[i].dev = dev; - } - } - DebugF("%s instances found: %d\n", driverName, numClaimedInstances); - /* - * Now check that a chipset or chipID override in the device section - * is valid. Chipset has precedence over chipID. - * If chipset is not valid ignore BusSlot completely. - */ - for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { - MessageType from = X_PROBED; - - if (!instances[i].claimed) { - continue; - } - if (instances[i].dev->chipset) { - for (c = chipsets; c->token >= 0; c++) { - if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0) - break; - } - if (c->token == -1) { - instances[i].claimed = FALSE; - numClaimedInstances--; - xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device " - "section \"%s\" isn't valid for this driver\n", - driverName, instances[i].dev->chipset, - instances[i].dev->identifier); - } else { - instances[i].chip = c->token; - - for (id = PCIchipsets; id->numChipset >= 0; id++) { - if (id->numChipset == instances[i].chip) - break; - } - if(id->numChipset >=0){ - xf86Msg(X_CONFIG,"Chipset override: %s\n", - instances[i].dev->chipset); - from = X_CONFIG; - } else { - instances[i].claimed = FALSE; - numClaimedInstances--; - xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device " - "section \"%s\" isn't a valid PCI chipset\n", - driverName, instances[i].dev->chipset, - instances[i].dev->identifier); - } - } - } else if (instances[i].dev->chipID > 0) { - for (id = PCIchipsets; id->numChipset >= 0; id++) { - if (id->PCIid == instances[i].dev->chipID) - break; - } - if (id->numChipset == -1) { - instances[i].claimed = FALSE; - numClaimedInstances--; - xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device " - "section \"%s\" isn't valid for this driver\n", - driverName, instances[i].dev->chipID, - instances[i].dev->identifier); - } else { - instances[i].chip = id->numChipset; - - xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n", - instances[i].dev->chipID); - from = X_CONFIG; - } - } else if (!instances[i].foundHW) { - /* - * This means that there was no override and the PCI chipType - * doesn't match one that is supported - */ - instances[i].claimed = FALSE; - numClaimedInstances--; - } - if (instances[i].claimed == TRUE){ - for (c = chipsets; c->token >= 0; c++) { - if (c->token == instances[i].chip) - break; - } - xf86Msg(from,"Chipset %s found\n", - c->name); - } - } - - /* - * Of the claimed instances, check that another driver hasn't already - * claimed its slot. - */ - numFound = 0; - for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { - - if (!instances[i].claimed) - continue; - pPci = instances[i].pci; - - - /* - * 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. - * - * XXX Need to make sure that two different drivers don't claim - * the same screen > 0 instance. - */ - if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci )) - continue; - - DebugF("%s: card at %d:%d:%d is claimed by a Device section\n", - driverName, pPci->bus, pPci->dev, pPci->func); - - /* Allocate an entry in the lists to be returned */ - numFound++; - retEntities = xnfrealloc(retEntities, numFound * sizeof(int)); - retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp, - instances[i].chip, - instances[i].dev, - instances[i].dev->active); - if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) { - for (j = 0; j < xf86NumEntities; j++) { - EntityPtr pEnt = xf86Entities[j]; - if (pEnt->bus.type != BUS_PCI) - continue; - if (pEnt->bus.id.pci == pPci) { - retEntities[numFound - 1] = j; - xf86AddDevToEntity(j, instances[i].dev); - break; - } - } - } - } - free(instances); - if (numFound > 0) { - *foundEntities = retEntities; - } - - return numFound; -} - /* * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ... */ @@ -2349,28 +1929,6 @@ xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name, #define LoaderGetOS xf86GetOS #include "loader/os.c" -/* new RAC */ -/* - * xf86ConfigPciEntityInactive() -- This function can be used - * to configure an inactive entity as well as to reconfigure an - * previously active entity inactive. If the entity has been - * assigned to a screen before it will be removed. If p_chip is - * non-NULL all static resources listed there will be registered. - */ -static void -xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip, - EntityProc init, EntityProc enter, - EntityProc leave, pointer private) -{ - ScrnInfoPtr pScrn; - - if ((pScrn = xf86FindScreenForEntity(pEnt->index))) - xf86RemoveEntityFromScreen(pScrn,pEnt->index); - - /* shared resources are only needed when entity is active: remove */ - xf86SetEntityFuncs(pEnt->index,init,enter,leave,private); -} - static void xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init, EntityProc enter, EntityProc leave, pointer private) @@ -2382,42 +1940,6 @@ xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init, xf86SetEntityFuncs(pEnt->index,init,enter,leave,private); } -ScrnInfoPtr -xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, - PciChipsets *p_chip, void *dummy, EntityProc init, - EntityProc enter, EntityProc leave, pointer private) -{ - EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); - if (!pEnt) return pScrn; - - if (!(pEnt->location.type == BUS_PCI) - || !xf86GetPciInfoForEntity(entityIndex)) { - free(pEnt); - return pScrn; - } - if (!pEnt->active) { - xf86ConfigPciEntityInactive(pEnt, p_chip, init, enter, - leave, private); - free(pEnt); - return pScrn; - } - - if (!pScrn) - pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag); - if (xf86IsEntitySharable(entityIndex)) { - xf86SetEntityShared(entityIndex); - } - xf86AddEntityToScreen(pScrn,entityIndex); - if (xf86IsEntityShared(entityIndex)) { - return pScrn; - } - free(pEnt); - - xf86SetEntityFuncs(entityIndex,init,enter,leave,private); - - return pScrn; -} - ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, EntityProc init, EntityProc enter, EntityProc leave, @@ -2446,33 +1968,6 @@ xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, return pScrn; } -/* - * - * OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function. - * It is likely to be removed. Don't use! - */ - -Bool -xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex, - PciChipsets *p_chip, void *dummy, EntityProc init, - EntityProc enter, EntityProc leave, pointer private) -{ - EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); - if (!pEnt) return FALSE; - - if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) { - free(pEnt); - return FALSE; - } - xf86AddEntityToScreen(pScrn,entityIndex); - - free(pEnt); - if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private)) - return FALSE; - - return TRUE; -} - Bool xf86IsScreenPrimary(int scrnIndex) { diff --git a/xorg-server/hw/xfree86/common/xf86Priv.h b/xorg-server/hw/xfree86/common/xf86Priv.h index b0a0f44cc..17fd5aaa9 100644 --- a/xorg-server/hw/xfree86/common/xf86Priv.h +++ b/xorg-server/hw/xfree86/common/xf86Priv.h @@ -110,14 +110,10 @@ extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable; #ifndef _NO_XF86_PROTOTYPES /* xf86Bus.c */ - extern _X_EXPORT Bool xf86BusConfig(void); extern _X_EXPORT void xf86BusProbe(void); extern _X_EXPORT void xf86AccessEnter(void); extern _X_EXPORT void xf86AccessLeave(void); - -extern _X_EXPORT void xf86FindPrimaryDevice(void); -/* new RAC */ extern _X_EXPORT void xf86PostProbe(void); extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex); extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev); diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c index f1096f1a5..55cd49c1f 100644 --- a/xorg-server/hw/xfree86/common/xf86Xinput.c +++ b/xorg-server/hw/xfree86/common/xf86Xinput.c @@ -551,9 +551,9 @@ InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs) return FALSE; for (cur = iclass->match_tag, match = FALSE; *cur && !match; cur++) { - const char *tag; - for(tag = *attrs->tags; *tag; tag++) { - if (!strcmp(tag, *cur)) { + char * const *tag; + for(tag = attrs->tags; *tag; tag++) { + if (!strcmp(*tag, *cur)) { match = TRUE; break; } diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c index 925751256..8d968dc39 100644 --- a/xorg-server/hw/xfree86/common/xf86pciBus.c +++ b/xorg-server/hw/xfree86/common/xf86pciBus.c @@ -41,6 +41,7 @@ #include "Pci.h" #include "xf86.h" #include "xf86Priv.h" +#include "dirent.h" /* DIR, FILE type definitions */ /* Bus-specific headers */ #include "xf86Bus.h" @@ -581,3 +582,748 @@ xf86PciIsolateDevice(char *argument) } else FatalError("Invalid isolated device specification\n"); } + +static Bool +pciDeviceHasBars(struct pci_device *pci) +{ + int i; + + for (i = 0; i < 6; i++) + if (pci->regions[i].size) + return TRUE; + + if (pci->rom_size) + return TRUE; + + return FALSE; +} + +struct Inst { + struct pci_device * pci; + GDevPtr dev; + Bool foundHW; /* PCIid in list of supported chipsets */ + Bool claimed; /* BusID matches with a device section */ + int chip; + int screen; +}; + + +/** + * Find set of unclaimed devices matching a given vendor ID. + * + * Used by drivers to find as yet unclaimed devices matching the specified + * vendor ID. + * + * \param driverName Name of the driver. This is used to find Device + * sections in the config file. + * \param vendorID PCI vendor ID of associated devices. If zero, then + * the true vendor ID must be encoded in the \c PCIid + * fields of the \c PCIchipsets entries. + * \param chipsets Symbol table used to associate chipset names with + * PCI IDs. + * \param devList List of Device sections parsed from the config file. + * \param numDevs Number of entries in \c devList. + * \param drvp Pointer the driver's control structure. + * \param foundEntities Returned list of entity indicies associated with the + * driver. + * + * \returns + * The number of elements in returned in \c foundEntities on success or zero + * on failure. + * + * \todo + * This function does a bit more than short description says. Fill in some + * more of the details of its operation. + * + * \todo + * The \c driverName parameter is redundant. It is the same as + * \c DriverRec::driverName. In a future version of this function, remove + * that parameter. + */ +int +xf86MatchPciInstances(const char *driverName, int vendorID, + SymTabPtr chipsets, PciChipsets *PCIchipsets, + GDevPtr *devList, int numDevs, DriverPtr drvp, + int **foundEntities) +{ + int i,j; + struct pci_device * pPci; + struct pci_device_iterator *iter; + struct Inst *instances = NULL; + int numClaimedInstances = 0; + int allocatedInstances = 0; + int numFound = 0; + SymTabRec *c; + PciChipsets *id; + int *retEntities = NULL; + + *foundEntities = NULL; + + + /* Each PCI device will contribute at least one entry. Each device + * section can contribute at most one entry. The sum of the two is + * guaranteed to be larger than the maximum possible number of entries. + * Do this calculation and memory allocation once now to eliminate the + * need for realloc calls inside the loop. + */ + if (!(xf86DoConfigure && xf86DoConfigurePass1)) { + unsigned max_entries = numDevs; + + iter = pci_slot_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + max_entries++; + } + + pci_iterator_destroy(iter); + instances = xnfalloc(max_entries * sizeof(struct Inst)); + } + + iter = pci_slot_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + unsigned device_class = pPci->device_class; + Bool foundVendor = FALSE; + + + /* Convert the pre-PCI 2.0 device class for a VGA adapter to the + * 2.0 version of the same class. + */ + if ( device_class == 0x00000101 ) { + device_class = 0x00030000; + } + + + /* Find PCI devices that match the given vendor ID. The vendor ID is + * either specified explicitly as a parameter to the function or + * implicitly encoded in the high bits of id->PCIid. + * + * The first device with a matching vendor is recorded, even if the + * device ID doesn't match. This is done because the Device section + * in the xorg.conf file can over-ride the device ID. A matching PCI + * ID might not be found now, but after the device ID over-ride is + * applied there /might/ be a match. + */ + for (id = PCIchipsets; id->PCIid != -1; id++) { + const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16) + | vendorID; + const unsigned device_id = (id->PCIid & 0x0000FFFF); + const unsigned match_class = 0x00030000 | id->PCIid; + + if ((vendor_id == pPci->vendor_id) + || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) { + if (!foundVendor && (instances != NULL)) { + ++allocatedInstances; + instances[allocatedInstances - 1].pci = pPci; + instances[allocatedInstances - 1].dev = NULL; + instances[allocatedInstances - 1].claimed = FALSE; + instances[allocatedInstances - 1].foundHW = FALSE; + instances[allocatedInstances - 1].screen = 0; + } + + foundVendor = TRUE; + + if ( (device_id == pPci->device_id) + || ((vendorID == PCI_VENDOR_GENERIC) + && (match_class == device_class)) ) { + if ( instances != NULL ) { + instances[allocatedInstances - 1].foundHW = TRUE; + instances[allocatedInstances - 1].chip = id->numChipset; + } + + + if ( xf86DoConfigure && xf86DoConfigurePass1 ) { + if (xf86CheckPciSlot(pPci)) { + GDevPtr pGDev = + xf86AddBusDeviceToConfigure(drvp->driverName, + BUS_PCI, pPci, -1); + if (pGDev) { + /* After configure pass 1, chipID and chipRev + * are treated as over-rides, so clobber them + * here. + */ + pGDev->chipID = -1; + pGDev->chipRev = -1; + } + + numFound++; + } + } + else { + numFound++; + } + + break; + } + } + } + } + + pci_iterator_destroy(iter); + + + /* In "probe only" or "configure" mode (signaled by instances being NULL), + * our work is done. Return the number of detected devices. + */ + if ( instances == NULL ) { + return numFound; + } + + + /* + * This may be debatable, but if no PCI devices with a matching vendor + * type is found, return zero now. It is probably not desirable to + * allow the config file to override this. + */ + if (allocatedInstances <= 0) { + free(instances); + return 0; + } + + + DebugF("%s instances found: %d\n", driverName, allocatedInstances); + + /* + * Check for devices that need duplicated instances. This is required + * when there is more than one screen per entity. + * + * XXX This currently doesn't work for cases where the BusID isn't + * specified explicitly in the config file. + */ + + for (j = 0; j < numDevs; j++) { + if (devList[j]->screen > 0 && devList[j]->busID + && *devList[j]->busID) { + for (i = 0; i < allocatedInstances; i++) { + pPci = instances[i].pci; + if (xf86ComparePciBusString(devList[j]->busID, + PCI_MAKE_BUS( pPci->domain, pPci->bus ), + pPci->dev, + pPci->func)) { + allocatedInstances++; + instances[allocatedInstances - 1] = instances[i]; + instances[allocatedInstances - 1].screen = devList[j]->screen; + numFound++; + break; + } + } + } + } + + for (i = 0; i < allocatedInstances; i++) { + GDevPtr dev = NULL; + GDevPtr devBus = NULL; + + pPci = instances[i].pci; + for (j = 0; j < numDevs; j++) { + if (devList[j]->busID && *devList[j]->busID) { + if (xf86ComparePciBusString(devList[j]->busID, + PCI_MAKE_BUS( pPci->domain, pPci->bus ), + pPci->dev, + pPci->func) && + devList[j]->screen == instances[i].screen) { + + if (devBus) + xf86MsgVerb(X_WARNING,0, + "%s: More than one matching Device section for " + "instances\n\t(BusID: %s) found: %s\n", + driverName, devList[j]->busID, + devList[j]->identifier); + else + devBus = devList[j]; + } + } else { + /* + * if device section without BusID is found + * only assign to it to the primary device. + */ + if (xf86IsPrimaryPci(pPci)) { + xf86Msg(X_PROBED, "Assigning device section with no busID" + " to primary device\n"); + if (dev || devBus) + xf86MsgVerb(X_WARNING, 0, + "%s: More than one matching Device section " + "found: %s\n", driverName, devList[j]->identifier); + else + dev = devList[j]; + } + } + } + if (devBus) dev = devBus; /* busID preferred */ + if (!dev) { + if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) { + xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section " + "for instance (BusID PCI:%u@%u:%u:%u) found\n", + driverName, pPci->domain, pPci->bus, pPci->dev, + pPci->func); + } + } else { + numClaimedInstances++; + instances[i].claimed = TRUE; + instances[i].dev = dev; + } + } + DebugF("%s instances found: %d\n", driverName, numClaimedInstances); + /* + * Now check that a chipset or chipID override in the device section + * is valid. Chipset has precedence over chipID. + * If chipset is not valid ignore BusSlot completely. + */ + for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { + MessageType from = X_PROBED; + + if (!instances[i].claimed) { + continue; + } + if (instances[i].dev->chipset) { + for (c = chipsets; c->token >= 0; c++) { + if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0) + break; + } + if (c->token == -1) { + instances[i].claimed = FALSE; + numClaimedInstances--; + xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device " + "section \"%s\" isn't valid for this driver\n", + driverName, instances[i].dev->chipset, + instances[i].dev->identifier); + } else { + instances[i].chip = c->token; + + for (id = PCIchipsets; id->numChipset >= 0; id++) { + if (id->numChipset == instances[i].chip) + break; + } + if(id->numChipset >=0){ + xf86Msg(X_CONFIG,"Chipset override: %s\n", + instances[i].dev->chipset); + from = X_CONFIG; + } else { + instances[i].claimed = FALSE; + numClaimedInstances--; + xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device " + "section \"%s\" isn't a valid PCI chipset\n", + driverName, instances[i].dev->chipset, + instances[i].dev->identifier); + } + } + } else if (instances[i].dev->chipID > 0) { + for (id = PCIchipsets; id->numChipset >= 0; id++) { + if (id->PCIid == instances[i].dev->chipID) + break; + } + if (id->numChipset == -1) { + instances[i].claimed = FALSE; + numClaimedInstances--; + xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device " + "section \"%s\" isn't valid for this driver\n", + driverName, instances[i].dev->chipID, + instances[i].dev->identifier); + } else { + instances[i].chip = id->numChipset; + + xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n", + instances[i].dev->chipID); + from = X_CONFIG; + } + } else if (!instances[i].foundHW) { + /* + * This means that there was no override and the PCI chipType + * doesn't match one that is supported + */ + instances[i].claimed = FALSE; + numClaimedInstances--; + } + if (instances[i].claimed == TRUE){ + for (c = chipsets; c->token >= 0; c++) { + if (c->token == instances[i].chip) + break; + } + xf86Msg(from,"Chipset %s found\n", + c->name); + } + } + + /* + * Of the claimed instances, check that another driver hasn't already + * claimed its slot. + */ + numFound = 0; + for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { + if (!instances[i].claimed) + continue; + pPci = instances[i].pci; + + + /* + * 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. + * + * XXX Need to make sure that two different drivers don't claim + * the same screen > 0 instance. + */ + if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci )) + continue; + + DebugF("%s: card at %d:%d:%d is claimed by a Device section\n", + driverName, pPci->bus, pPci->dev, pPci->func); + + /* Allocate an entry in the lists to be returned */ + numFound++; + retEntities = xnfrealloc(retEntities, numFound * sizeof(int)); + retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp, + instances[i].chip, + instances[i].dev, + instances[i].dev->active); + if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) { + for (j = 0; j < xf86NumEntities; j++) { + EntityPtr pEnt = xf86Entities[j]; + if (pEnt->bus.type != BUS_PCI) + continue; + if (pEnt->bus.id.pci == pPci) { + retEntities[numFound - 1] = j; + xf86AddDevToEntity(j, instances[i].dev); + break; + } + } + } + } + free(instances); + if (numFound > 0) { + *foundEntities = retEntities; + } + + return numFound; +} + +/* + * xf86ConfigPciEntityInactive() -- This function can be used + * to configure an inactive entity as well as to reconfigure an + * previously active entity inactive. If the entity has been + * assigned to a screen before it will be removed. If p_chip is + * non-NULL all static resources listed there will be registered. + */ +static void +xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip, + EntityProc init, EntityProc enter, + EntityProc leave, pointer private) +{ + ScrnInfoPtr pScrn; + + if ((pScrn = xf86FindScreenForEntity(pEnt->index))) + xf86RemoveEntityFromScreen(pScrn,pEnt->index); + + /* shared resources are only needed when entity is active: remove */ + xf86SetEntityFuncs(pEnt->index,init,enter,leave,private); +} + +ScrnInfoPtr +xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, + PciChipsets *p_chip, void *dummy, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return pScrn; + + if (!(pEnt->location.type == BUS_PCI) + || !xf86GetPciInfoForEntity(entityIndex)) { + free(pEnt); + return pScrn; + } + if (!pEnt->active) { + xf86ConfigPciEntityInactive(pEnt, p_chip, init, enter, + leave, private); + free(pEnt); + return pScrn; + } + + if (!pScrn) + pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag); + if (xf86IsEntitySharable(entityIndex)) { + xf86SetEntityShared(entityIndex); + } + xf86AddEntityToScreen(pScrn,entityIndex); + if (xf86IsEntityShared(entityIndex)) { + return pScrn; + } + free(pEnt); + + xf86SetEntityFuncs(entityIndex,init,enter,leave,private); + + return pScrn; +} + +/* + * OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function. + * It is likely to be removed. Don't use! + */ +Bool +xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex, + PciChipsets *p_chip, void *dummy, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return FALSE; + + if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) { + free(pEnt); + return FALSE; + } + xf86AddEntityToScreen(pScrn,entityIndex); + + free(pEnt); + if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private)) + return FALSE; + + return TRUE; +} + +static int +videoPtrToDriverList(struct pci_device *dev, + char *returnList[], int returnListMax) +{ + int i; + /* Add more entries here if we ever return more than 4 drivers for + any device */ + char *driverList[5] = { NULL, NULL, NULL, NULL, NULL }; + + switch (dev->vendor_id) + { + /* AMD Geode LX */ + case 0x1022: + if (dev->device_id == 0x2081) + driverList[0] = "geode"; + break; + /* older Geode products acquired by AMD still carry an NSC vendor_id */ + case 0x100b: + if (dev->device_id == 0x0030) { + /* NSC Geode GX2 specifically */ + driverList[0] = "geode"; + /* GX2 support started its life in the NSC tree and was later + forked by AMD for GEODE so we keep it as a backup */ + driverList[1] = "nsc"; + } else + /* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */ + driverList[0] = "nsc"; + break; + /* Cyrix Geode GX1 */ + case 0x1078: + if (dev->device_id == 0x0104) + driverList[0] = "cyrix"; + break; + case 0x1142: driverList[0] = "apm"; break; + case 0xedd8: driverList[0] = "ark"; break; + case 0x1a03: driverList[0] = "ast"; break; + case 0x1002: driverList[0] = "ati"; break; + case 0x102c: driverList[0] = "chips"; break; + case 0x1013: driverList[0] = "cirrus"; break; + case 0x3d3d: driverList[0] = "glint"; break; + case 0x105d: driverList[0] = "i128"; break; + case 0x8086: + if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) { + driverList[0] = "i740"; + } else if (dev->device_id == 0x8108) { + break; /* "hooray" for poulsbo */ + } else { + driverList[0] = "intel"; + } + break; + case 0x102b: driverList[0] = "mga"; break; + case 0x10c8: driverList[0] = "neomagic"; break; + case 0x10de: case 0x12d2: driverList[0] = "nv"; break; + case 0x1106: driverList[0] = "openchrome"; break; + case 0x1b36: driverList[0] = "qxl"; break; + case 0x1163: driverList[0] = "rendition"; break; + case 0x5333: + switch (dev->device_id) + { + case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811: + case 0x8812: case 0x8814: case 0x8901: + driverList[0] = "s3"; break; + case 0x5631: case 0x883d: case 0x8a01: case 0x8a10: + case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13: + driverList[0] = "s3virge"; break; + default: + driverList[0] = "savage"; break; + } + break; + case 0x1039: driverList[0] = "sis"; break; + case 0x126f: driverList[0] = "siliconmotion"; break; + case 0x121a: + if (dev->device_id < 0x0003) + driverList[0] = "voodoo"; + else + driverList[0] = "tdfx"; + break; + case 0x1011: driverList[0] = "tga"; break; + case 0x1023: driverList[0] = "trident"; break; + case 0x100c: driverList[0] = "tseng"; break; + case 0x80ee: driverList[0] = "vboxvideo"; break; + case 0x15ad: driverList[0] = "vmware"; break; + case 0x18ca: + if (dev->device_id == 0x47) + driverList[0] = "xgixp"; + else + driverList[0] = "xgi"; + break; + default: break; + } + for (i = 0; (i < returnListMax) && (driverList[i] != NULL); i++) { + returnList[i] = xnfstrdup(driverList[i]); + } + return i; /* Number of entries added */ +} + +static int +xchomp(char *line) +{ + size_t len = 0; + + if (!line) { + return 1; + } + + len = strlen(line); + if (line[len - 1] == '\n' && len > 0) { + line[len - 1] = '\0'; + } + return 0; +} + +#ifdef __linux__ +/* This function is used to provide a workaround for binary drivers that + * don't export their PCI ID's properly. If distros don't end up using this + * feature it can and should be removed because the symbol-based resolution + * scheme should be the primary one */ +static void +matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip) +{ + DIR *idsdir; + FILE *fp; + struct dirent *direntry; + char *line = NULL; + size_t len; + ssize_t read; + char path_name[256], vendor_str[5], chip_str[5]; + uint16_t vendor, chip; + int i, j; + + idsdir = opendir(PCI_TXT_IDS_PATH); + if (!idsdir) + return; + + xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH); + direntry = readdir(idsdir); + /* Read the directory */ + while (direntry) { + if (direntry->d_name[0] == '.') { + direntry = readdir(idsdir); + continue; + } + len = strlen(direntry->d_name); + /* A tiny bit of sanity checking. We should probably do better */ + if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) { + /* We need the full path name to open the file */ + strncpy(path_name, PCI_TXT_IDS_PATH, 256); + strncat(path_name, "/", 1); + strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1)); + fp = fopen(path_name, "r"); + if (fp == NULL) { + xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name); + goto end; + } + /* Read the file */ +#ifdef __GLIBC__ + while ((read = getline(&line, &len, fp)) != -1) { +#else + while ((line = fgetln(fp, &len)) != (char *)NULL) { +#endif /* __GLIBC __ */ + xchomp(line); + if (isdigit(line[0])) { + strncpy(vendor_str, line, 4); + vendor_str[4] = '\0'; + vendor = (int)strtol(vendor_str, NULL, 16); + if ((strlen(&line[4])) == 0) { + chip_str[0] = '\0'; + chip = -1; + } else { + /* Handle trailing whitespace */ + if (isspace(line[4])) { + chip_str[0] = '\0'; + chip = -1; + } else { + /* Ok, it's a real ID */ + strncpy(chip_str, &line[4], 4); + chip_str[4] = '\0'; + chip = (int)strtol(chip_str, NULL, 16); + } + } + if (vendor == match_vendor && chip == match_chip ) { + i = 0; + while (matches[i]) { + i++; + } + matches[i] = (char*)malloc(sizeof(char) * strlen(direntry->d_name) - 3); + if (!matches[i]) { + xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n"); + goto end; + } + /* hack off the .ids suffix. This should guard + * against other problems, but it will end up + * taking off anything after the first '.' */ + for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) { + if (direntry->d_name[j] == '.') { + matches[i][j] = '\0'; + break; + } else { + matches[i][j] = direntry->d_name[j]; + } + } + xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name); + } + } else { + /* TODO Handle driver overrides here */ + } + } + fclose(fp); + } + direntry = readdir(idsdir); + } + end: + free(line); + closedir(idsdir); +} +#endif /* __linux__ */ + +void +xf86PciMatchDriver(char* matches[], int nmatches) { + int i; + struct pci_device * info = NULL; + struct pci_device_iterator *iter; + + /* Find the primary device, and get some information about it. */ + iter = pci_slot_match_iterator_create(NULL); + while ((info = pci_device_next(iter)) != NULL) { + if (xf86IsPrimaryPci(info)) { + break; + } + } + + pci_iterator_destroy(iter); + + if (!info) { + ErrorF("Primary device is not PCI\n"); + } +#ifdef __linux__ + else { + matchDriverFromFiles(matches, info->vendor_id, info->device_id); + } +#endif /* __linux__ */ + + for (i = 0; (i < nmatches) && (matches[i]); i++) { + /* find end of matches list */ + } + + if ((info != NULL) && (i < nmatches)) { + i += videoPtrToDriverList(info, &(matches[i]), nmatches - i); + } +} diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.h b/xorg-server/hw/xfree86/common/xf86pciBus.h index b534645ee..c8a2eebdd 100644 --- a/xorg-server/hw/xfree86/common/xf86pciBus.h +++ b/xorg-server/hw/xfree86/common/xf86pciBus.h @@ -37,5 +37,6 @@ void xf86PciProbe(void); Bool xf86PciAddMatchingDev(DriverPtr drvp); Bool xf86PciProbeDev(DriverPtr drvp); void xf86PciIsolateDevice(char *argument); +void xf86PciMatchDriver(char* matches[], int nmatches); #endif /* _XF86_PCI_BUS_H */ diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h index de1f1b60a..c4fbe0403 100644 --- a/xorg-server/hw/xfree86/common/xf86str.h +++ b/xorg-server/hw/xfree86/common/xf86str.h @@ -1,919 +1,917 @@ - -/* - * 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 definitions of the public XFree86 data structures/types. - * Any data structures that video drivers need to access should go here. - */ - -#ifndef _XF86STR_H -#define _XF86STR_H - -#include "misc.h" -#include "input.h" -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "colormapst.h" -#include "xf86Module.h" -#include "xf86Opt.h" -#include "xf86Pci.h" - -#include - -/** - * Integer type that is of the size of the addressable memory (machine size). - * On most platforms \c uintptr_t will suffice. However, on some mixed - * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this - * must be 64-bits. - */ -#include -#if defined(__powerpc__) -typedef uint64_t memType; -#else -typedef uintptr_t memType; -#endif - - -/* Video mode flags */ - -typedef enum { - V_PHSYNC = 0x0001, - V_NHSYNC = 0x0002, - V_PVSYNC = 0x0004, - V_NVSYNC = 0x0008, - V_INTERLACE = 0x0010, - V_DBLSCAN = 0x0020, - V_CSYNC = 0x0040, - V_PCSYNC = 0x0080, - V_NCSYNC = 0x0100, - V_HSKEW = 0x0200, /* hskew provided */ - V_BCAST = 0x0400, - V_PIXMUX = 0x1000, - V_DBLCLK = 0x2000, - V_CLKDIV2 = 0x4000 -} ModeFlags; - -typedef enum { - INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */ -} CrtcAdjustFlags; - -/* Flags passed to ChipValidMode() */ -typedef enum { - MODECHECK_INITIAL = 0, - MODECHECK_FINAL = 1 -} ModeCheckFlags; - -/* These are possible return values for xf86CheckMode() and ValidMode() */ -typedef enum { - MODE_OK = 0, /* Mode OK */ - MODE_HSYNC, /* hsync out of range */ - MODE_VSYNC, /* vsync out of range */ - MODE_H_ILLEGAL, /* mode has illegal horizontal timings */ - MODE_V_ILLEGAL, /* mode has illegal horizontal timings */ - MODE_BAD_WIDTH, /* requires an unsupported linepitch */ - MODE_NOMODE, /* no mode with a maching name */ - MODE_NO_INTERLACE, /* interlaced mode not supported */ - MODE_NO_DBLESCAN, /* doublescan mode not supported */ - MODE_NO_VSCAN, /* multiscan mode not supported */ - MODE_MEM, /* insufficient video memory */ - MODE_VIRTUAL_X, /* mode width too large for specified virtual size */ - MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */ - MODE_MEM_VIRT, /* insufficient video memory given virtual size */ - MODE_NOCLOCK, /* no fixed clock available */ - MODE_CLOCK_HIGH, /* clock required is too high */ - MODE_CLOCK_LOW, /* clock required is too low */ - MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */ - MODE_BAD_HVALUE, /* horizontal timing was out of range */ - MODE_BAD_VVALUE, /* vertical timing was out of range */ - MODE_BAD_VSCAN, /* VScan value out of range */ - MODE_HSYNC_NARROW, /* horizontal sync too narrow */ - MODE_HSYNC_WIDE, /* horizontal sync too wide */ - MODE_HBLANK_NARROW, /* horizontal blanking too narrow */ - MODE_HBLANK_WIDE, /* horizontal blanking too wide */ - MODE_VSYNC_NARROW, /* vertical sync too narrow */ - MODE_VSYNC_WIDE, /* vertical sync too wide */ - MODE_VBLANK_NARROW, /* vertical blanking too narrow */ - MODE_VBLANK_WIDE, /* vertical blanking too wide */ - MODE_PANEL, /* exceeds panel dimensions */ - MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */ - MODE_ONE_WIDTH, /* only one width is supported */ - MODE_ONE_HEIGHT, /* only one height is supported */ - MODE_ONE_SIZE, /* only one resolution is supported */ - MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */ - MODE_BANDWIDTH, /* mode requires too much memory bandwidth */ - MODE_BAD = -2, /* unspecified reason */ - MODE_ERROR = -1 /* error condition */ -} ModeStatus; - -/* - * The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN. - * Preferred will bubble a mode to the top within a set. - */ -# define M_T_BUILTIN 0x01 /* built-in mode */ -# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */ -# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */ -# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C) - /* built-in mode - configure CRTC and clock */ -# define M_T_PREFERRED 0x08 /* preferred mode within a set */ -# define M_T_DEFAULT 0x10 /* (VESA) default modes */ -# define M_T_USERDEF 0x20 /* One of the modes from the config file */ -# define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */ -# define M_T_USERPREF 0x80 /* mode preferred by the user config */ - -/* Video mode */ -typedef struct _DisplayModeRec { - struct _DisplayModeRec * prev; - struct _DisplayModeRec * next; - char * name; /* identifier for the mode */ - ModeStatus status; - int type; - - /* These are the values that the user sees/provides */ - int Clock; /* pixel clock freq (kHz) */ - int HDisplay; /* horizontal timing */ - int HSyncStart; - int HSyncEnd; - int HTotal; - int HSkew; - int VDisplay; /* vertical timing */ - int VSyncStart; - int VSyncEnd; - int VTotal; - int VScan; - int Flags; - - /* These are the values the hardware uses */ - int ClockIndex; - int SynthClock; /* Actual clock freq to - * be programmed (kHz) */ - int CrtcHDisplay; - int CrtcHBlankStart; - int CrtcHSyncStart; - int CrtcHSyncEnd; - int CrtcHBlankEnd; - int CrtcHTotal; - int CrtcHSkew; - int CrtcVDisplay; - int CrtcVBlankStart; - int CrtcVSyncStart; - int CrtcVSyncEnd; - int CrtcVBlankEnd; - int CrtcVTotal; - Bool CrtcHAdjusted; - Bool CrtcVAdjusted; - int PrivSize; - INT32 * Private; - int PrivFlags; - - float HSync, VRefresh; -} DisplayModeRec, *DisplayModePtr; - -/* The monitor description */ - -#define MAX_HSYNC 8 -#define MAX_VREFRESH 8 - -typedef struct { float hi, lo; } range; - -typedef struct { CARD32 red, green, blue; } rgb; - -typedef struct { float red, green, blue; } Gamma; - -/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */ -#define GAMMA_MAX 10.0 -#define GAMMA_MIN (1.0 / GAMMA_MAX) -#define GAMMA_ZERO (GAMMA_MIN / 100.0) - -typedef struct { - char * id; - char * vendor; - char * model; - int nHsync; - range hsync[MAX_HSYNC]; - int nVrefresh; - range vrefresh[MAX_VREFRESH]; - DisplayModePtr Modes; /* Start of the monitor's mode list */ - DisplayModePtr Last; /* End of the monitor's mode list */ - Gamma gamma; /* Gamma of the monitor */ - int widthmm; - int heightmm; - pointer options; - pointer DDC; - Bool reducedblanking; /* Allow CVT reduced blanking modes? */ - int maxPixClock; /* in kHz, like mode->Clock */ -} MonRec, *MonPtr; - -/* the list of clock ranges */ -typedef struct x_ClockRange { - struct x_ClockRange *next; - int minClock; /* (kHz) */ - int maxClock; /* (kHz) */ - int clockIndex; /* -1 for programmable clocks */ - Bool interlaceAllowed; - Bool doubleScanAllowed; - int ClockMulFactor; - int ClockDivFactor; - int PrivFlags; -} ClockRange, *ClockRangePtr; - -/* - * The driverFunc. xorgDriverFuncOp specifies the action driver should - * perform. If requested option is not supported function should return - * FALSE. pointer can be used to pass arguments to the function or - * to return data to the caller. - */ -typedef struct _ScrnInfoRec *ScrnInfoPtr; - -/* do not change order */ -typedef enum { - RR_GET_INFO, - RR_SET_CONFIG, - RR_GET_MODE_MM, - GET_REQUIRED_HW_INTERFACES = 10 -} xorgDriverFuncOp; - -typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp, - pointer); - -/* RR_GET_INFO, RR_SET_CONFIG */ -typedef struct { - int rotation; - int rate; - int width; - int height; -} xorgRRConfig; - -typedef union { - short RRRotations; - xorgRRConfig RRConfig; -} xorgRRRotation, *xorgRRRotationPtr; - -/* RR_GET_MODE_MM */ -typedef struct { - DisplayModePtr mode; - int virtX; - int virtY; - int mmWidth; - int mmHeight; -} xorgRRModeMM, *xorgRRModeMMPtr; - -/* GET_REQUIRED_HW_INTERFACES */ -#define HW_IO 1 -#define HW_MMIO 2 -#define HW_SKIP_CONSOLE 4 -#define NEED_IO_ENABLED(x) (x & HW_IO) - -typedef CARD32 xorgHWFlags; - -/* - * The driver list struct. This contains the information required for each - * driver before a ScrnInfoRec has been allocated. - */ -struct _DriverRec; - -typedef struct { - int driverVersion; - char * driverName; - void (*Identify)(int flags); - Bool (*Probe)(struct _DriverRec *drv, int flags); - const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype); - pointer module; - int refCount; -} DriverRec1; - -struct _SymTabRec; -struct _PciChipsets; - -typedef struct _DriverRec { - int driverVersion; - char * driverName; - void (*Identify)(int flags); - Bool (*Probe)(struct _DriverRec *drv, int flags); - const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype); - pointer module; - int refCount; - xorgDriverFuncProc *driverFunc; - - const struct pci_id_match * supported_devices; - Bool (*PciProbe)( struct _DriverRec * drv, int entity_num, - struct pci_device * dev, intptr_t match_data ); -} DriverRec, *DriverPtr; - -/* - * AddDriver flags - */ -#define HaveDriverFuncs 1 - -/* - * These are the private bus types. New types can be added here. Types - * required for the public interface should be added to xf86str.h, with - * function prototypes added to xf86.h. - */ - -/* Tolerate prior #include */ -#if defined(linux) && defined(_INPUT_H) -#undef BUS_NONE -#undef BUS_ISA -#undef BUS_PCI -#undef BUS_SBUS -#undef BUS_last -#endif - -typedef enum { - BUS_NONE, - BUS_ISA, - BUS_PCI, - BUS_SBUS, - BUS_last /* Keep last */ -} BusType; - -struct pci_device; - -typedef struct { - int fbNum; -} SbusBusId; - -typedef struct _bus { - BusType type; - union { - struct pci_device *pci; - SbusBusId sbus; - } id; -} BusRec, *BusPtr; - -#define MAXCLOCKS 128 -typedef enum { - DAC_BPP8 = 0, - DAC_BPP16, - DAC_BPP24, - DAC_BPP32, - MAXDACSPEEDS -} DacSpeedIndex; - -typedef struct { - char * identifier; - char * vendor; - char * board; - char * chipset; - char * ramdac; - char * driver; - struct _confscreenrec * myScreenSection; - Bool claimed; - int dacSpeeds[MAXDACSPEEDS]; - int numclocks; - int clock[MAXCLOCKS]; - char * clockchip; - char * busID; - Bool active; - Bool inUse; - int videoRam; - int textClockFreq; - unsigned long BiosBase; /* Base address of video BIOS */ - unsigned long MemBase; /* Frame buffer base address */ - unsigned long IOBase; - int chipID; - int chipRev; - pointer options; - int irq; - int screen; /* For multi-CRTC cards */ -} GDevRec, *GDevPtr; - -typedef struct { - char * identifier; - char * driver; - pointer commonOptions; - pointer extraOptions; -} IDevRec, *IDevPtr; - -typedef struct { - int frameX0; - int frameY0; - int virtualX; - int virtualY; - int depth; - int fbbpp; - rgb weight; - rgb blackColour; - rgb whiteColour; - int defaultVisual; - char ** modes; - pointer options; -} DispRec, *DispPtr; - -typedef struct _confxvportrec { - char * identifier; - pointer options; -} confXvPortRec, *confXvPortPtr; - -typedef struct _confxvadaptrec { - char * identifier; - int numports; - confXvPortPtr ports; - pointer options; -} confXvAdaptorRec, *confXvAdaptorPtr; - -typedef struct _confscreenrec { - char * id; - int screennum; - int defaultdepth; - int defaultbpp; - int defaultfbbpp; - MonPtr monitor; - GDevPtr device; - int numdisplays; - DispPtr displays; - int numxvadaptors; - confXvAdaptorPtr xvadaptors; - pointer options; -} confScreenRec, *confScreenPtr; - -typedef enum { - PosObsolete = -1, - PosAbsolute = 0, - PosRightOf, - PosLeftOf, - PosAbove, - PosBelow, - PosRelative -} PositionType; - -typedef struct _screenlayoutrec { - confScreenPtr screen; - char * topname; - confScreenPtr top; - char * bottomname; - confScreenPtr bottom; - char * leftname; - confScreenPtr left; - char * rightname; - confScreenPtr right; - PositionType where; - int x; - int y; - char * refname; - confScreenPtr refscreen; -} screenLayoutRec, *screenLayoutPtr; - -typedef struct _serverlayoutrec { - char * id; - screenLayoutPtr screens; - GDevPtr inactives; - IDevPtr* inputs; /* NULL terminated */ - pointer options; -} serverLayoutRec, *serverLayoutPtr; - -typedef struct _confdribufferrec { - int count; - int size; - enum { - XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */ - } flags; -} confDRIBufferRec, *confDRIBufferPtr; - -typedef struct _confdrirec { - int group; - int mode; - int bufs_count; - confDRIBufferRec *bufs; -} confDRIRec, *confDRIPtr; - -/* These values should be adjusted when new fields are added to ScrnInfoRec */ -#define NUM_RESERVED_INTS 16 -#define NUM_RESERVED_POINTERS 14 -#define NUM_RESERVED_FUNCS 11 - -typedef pointer (*funcPointer)(void); - -/* flags for depth 24 pixmap options */ -typedef enum { - Pix24DontCare = 0, - Pix24Use24, - Pix24Use32 -} Pix24Flags; - -/* Power management events: so far we only support APM */ - -typedef enum { - XF86_APM_UNKNOWN = -1, - XF86_APM_SYS_STANDBY, - XF86_APM_SYS_SUSPEND, - XF86_APM_CRITICAL_SUSPEND, - XF86_APM_USER_STANDBY, - XF86_APM_USER_SUSPEND, - XF86_APM_STANDBY_RESUME, - XF86_APM_NORMAL_RESUME, - XF86_APM_CRITICAL_RESUME, - XF86_APM_LOW_BATTERY, - XF86_APM_POWER_STATUS_CHANGE, - XF86_APM_UPDATE_TIME, - XF86_APM_CAPABILITY_CHANGED, - XF86_APM_STANDBY_FAILED, - XF86_APM_SUSPEND_FAILED -} pmEvent; - -typedef enum { - PM_WAIT, - PM_CONTINUE, - PM_FAILED, - PM_NONE -} pmWait; - -typedef struct _PciChipsets { - /** - * Key used to match this device with its name in an array of - * \c SymTabRec. - */ - int numChipset; - - /** - * This value is quirky. Depending on the driver, it can take on one of - * three meanings. In drivers that have exactly one vendor ID (e.g., - * radeon, mga, i810) the low 16-bits are the device ID. - * - * In drivers that can have multiple vendor IDs (e.g., the glint driver - * can have either 3dlabs' ID or TI's ID, the i740 driver can have either - * Intel's ID or Real3D's ID, etc.) the low 16-bits are the device ID and - * the high 16-bits are the vendor ID. - * - * In drivers that don't have a specific vendor (e.g., vga) contains the - * device ID for either the generic VGA or generic 8514 devices. This - * turns out to be the same as the subclass and programming interface - * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or - * 0x000101) and for 8514 is 0x030001). - */ - int PCIid; - -/* dummy place holders for drivers to build against old/new servers */ -#define RES_UNDEFINED NULL -#define RES_EXCLUSIVE_VGA NULL -#define RES_SHARED_VGA NULL - void *dummy; -} PciChipsets; - - -/* Entity properties */ -typedef void (*EntityProc)(int entityIndex,pointer private); - -typedef struct _entityInfo { - int index; - BusRec location; - int chipset; - Bool active; - GDevPtr device; - DriverPtr driver; -} EntityInfoRec, *EntityInfoPtr; - -/* server states */ - -typedef enum { - SETUP, - OPERATING -} xf86State; - -/* DGA */ - -typedef struct { - int num; /* A unique identifier for the mode (num > 0) */ - DisplayModePtr mode; - int flags; /* DGA_CONCURRENT_ACCESS, etc... */ - int imageWidth; /* linear accessible portion (pixels) */ - int imageHeight; - int pixmapWidth; /* Xlib accessible portion (pixels) */ - int pixmapHeight; /* both fields ignored if no concurrent access */ - int bytesPerScanline; - int byteOrder; /* MSBFirst, LSBFirst */ - int depth; - int bitsPerPixel; - unsigned long red_mask; - unsigned long green_mask; - unsigned long blue_mask; - short visualClass; - int viewportWidth; - int viewportHeight; - int xViewportStep; /* viewport position granularity */ - int yViewportStep; - int maxViewportX; /* max viewport origin */ - int maxViewportY; - int viewportFlags; /* types of page flipping possible */ - int offset; /* offset into physical memory */ - unsigned char *address; /* server's mapped framebuffer */ - int reserved1; - int reserved2; -} DGAModeRec, *DGAModePtr; - -typedef struct { - DGAModePtr mode; - PixmapPtr pPix; -} DGADeviceRec, *DGADevicePtr; - -/* - * Flags for driver Probe() functions. - */ -#define PROBE_DEFAULT 0x00 -#define PROBE_DETECT 0x01 -#define PROBE_TRYHARD 0x02 - -/* - * Driver entry point types - */ - -typedef Bool xf86ProbeProc (DriverPtr, int); -typedef Bool xf86PreInitProc (ScrnInfoPtr, int); -typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**); -typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int); -typedef void xf86AdjustFrameProc (int, int, int, int); -typedef Bool xf86EnterVTProc (int, int); -typedef void xf86LeaveVTProc (int, int); -typedef void xf86FreeScreenProc (int, int); -typedef ModeStatus xf86ValidModeProc (int, DisplayModePtr, Bool, int); -typedef void xf86EnableDisableFBAccessProc(int, Bool); -typedef int xf86SetDGAModeProc (int, int, DGADevicePtr); -typedef int xf86ChangeGammaProc (int, Gamma); -typedef void xf86PointerMovedProc (int, int, int); -typedef Bool xf86PMEventProc (int, pmEvent, Bool); -typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int); -typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr); -typedef void xf86SetOverscanProc (ScrnInfoPtr, int); - - -/* - * ScrnInfoRec - * - * There is one of these for each screen, and it holds all the screen-specific - * information. - * - * Note: the size and layout must be kept the same across versions. New - * fields are to be added in place of the "reserved*" fields. No fields - * are to be dependent on compile-time defines. - */ - - -typedef struct _ScrnInfoRec { - int driverVersion; - char * driverName; /* canonical name used in */ - /* the config file */ - ScreenPtr pScreen; /* Pointer to the ScreenRec */ - int scrnIndex; /* Number of this screen */ - Bool configured; /* Is this screen valid */ - int origIndex; /* initial number assigned to - * this screen before - * finalising the number of - * available screens */ - - /* Display-wide screenInfo values needed by this screen */ - int imageByteOrder; - int bitmapScanlineUnit; - int bitmapScanlinePad; - int bitmapBitOrder; - int numFormats; - PixmapFormatRec formats[MAXFORMATS]; - PixmapFormatRec fbFormat; - - int bitsPerPixel; /* fb bpp */ - Pix24Flags pixmap24; /* pixmap pref for depth 24 */ - int depth; /* depth of default visual */ - MessageType depthFrom; /* set from config? */ - MessageType bitsPerPixelFrom; /* set from config? */ - rgb weight; /* r/g/b weights */ - rgb mask; /* rgb masks */ - rgb offset; /* rgb offsets */ - int rgbBits; /* Number of bits in r/g/b */ - Gamma gamma; /* Gamma of the monitor */ - int defaultVisual; /* default visual class */ - int maxHValue; /* max horizontal timing */ - int maxVValue; /* max vertical timing value */ - int virtualX; /* Virtual width */ - int virtualY; /* Virtual height */ - int xInc; /* Horizontal timing increment */ - MessageType virtualFrom; /* set from config? */ - int displayWidth; /* memory pitch */ - int frameX0; /* viewport position */ - int frameY0; - int frameX1; - int frameY1; - int zoomLocked; /* Disallow mode changes */ - DisplayModePtr modePool; /* list of compatible modes */ - DisplayModePtr modes; /* list of actual modes */ - DisplayModePtr currentMode; /* current mode - * This was previously - * overloaded with the modes - * field, which is a pointer - * into a circular list */ - confScreenPtr confScreen; /* Screen config info */ - MonPtr monitor; /* Monitor information */ - DispPtr display; /* Display information */ - int * entityList; /* List of device entities */ - int numEntities; - int widthmm; /* physical display dimensions - * in mm */ - int heightmm; - int xDpi; /* width DPI */ - int yDpi; /* height DPI */ - char * name; /* Name to prefix messages */ - pointer driverPrivate; /* Driver private area */ - DevUnion * privates; /* Other privates can hook in - * here */ - DriverPtr drv; /* xf86DriverList[] entry */ - pointer module; /* Pointer to module head */ - int colorKey; - int overlayFlags; - - /* Some of these may be moved out of here into the driver private area */ - - char * chipset; /* chipset name */ - char * ramdac; /* ramdac name */ - char * clockchip; /* clock name */ - Bool progClock; /* clock is programmable */ - int numClocks; /* number of clocks */ - int clock[MAXCLOCKS]; /* list of clock frequencies */ - int videoRam; /* amount of video ram (kb) */ - unsigned long biosBase; /* Base address of video BIOS */ - unsigned long memPhysBase; /* Physical address of FB */ - unsigned long fbOffset; /* Offset of FB in the above */ - IOADDRESS domainIOBase; /* Domain I/O base address */ - int memClk; /* memory clock */ - int textClockFreq; /* clock of text mode */ - Bool flipPixels; /* swap default black/white */ - pointer options; - - int chipID; - int chipRev; - - /* Allow screens to be enabled/disabled individually */ - Bool vtSema; - DevUnion pixmapPrivate; /* saved devPrivate from pixmap */ - - /* hw cursor moves at SIGIO time */ - Bool silkenMouse; - - /* Storage for clockRanges and adjustFlags for use with the VidMode ext */ - ClockRangePtr clockRanges; - int adjustFlags; - - /* - * These can be used when the minor ABI version is incremented. - * The NUM_* parameters must be reduced appropriately to keep the - * structure size and alignment unchanged. - */ - int reservedInt[NUM_RESERVED_INTS]; - - int * entityInstanceList; - struct pci_device *vgaDev; - - pointer reservedPtr[NUM_RESERVED_POINTERS]; - - /* - * Driver entry points. - * - */ - - xf86ProbeProc *Probe; - xf86PreInitProc *PreInit; - xf86ScreenInitProc *ScreenInit; - xf86SwitchModeProc *SwitchMode; - xf86AdjustFrameProc *AdjustFrame; - xf86EnterVTProc *EnterVT; - xf86LeaveVTProc *LeaveVT; - xf86FreeScreenProc *FreeScreen; - xf86ValidModeProc *ValidMode; - xf86EnableDisableFBAccessProc *EnableDisableFBAccess; - xf86SetDGAModeProc *SetDGAMode; - xf86ChangeGammaProc *ChangeGamma; - xf86PointerMovedProc *PointerMoved; - xf86PMEventProc *PMEvent; - xf86DPMSSetProc *DPMSSet; - xf86LoadPaletteProc *LoadPalette; - xf86SetOverscanProc *SetOverscan; - xorgDriverFuncProc *DriverFunc; - - /* - * This can be used when the minor ABI version is incremented. - * The NUM_* parameter must be reduced appropriately to keep the - * structure size and alignment unchanged. - */ - funcPointer reservedFuncs[NUM_RESERVED_FUNCS]; - -} ScrnInfoRec; - - -typedef struct { - Bool (*OpenFramebuffer)( - ScrnInfoPtr pScrn, - char **name, - unsigned char **mem, - int *size, - int *offset, - int *extra - ); - void (*CloseFramebuffer)(ScrnInfoPtr pScrn); - Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode); - void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags); - int (*GetViewport)(ScrnInfoPtr pScrn); - void (*Sync)(ScrnInfoPtr); - void (*FillRect)( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned long color - ); - void (*BlitRect)( - ScrnInfoPtr pScrn, - int srcx, int srcy, - int w, int h, - int dstx, int dsty - ); - void (*BlitTransRect)( - ScrnInfoPtr pScrn, - int srcx, int srcy, - int w, int h, - int dstx, int dsty, - unsigned long color - ); -} DGAFunctionRec, *DGAFunctionPtr; - -typedef struct _SymTabRec { - int token; /* id of the token */ - const char * name; /* token name */ -} SymTabRec, *SymTabPtr; - -/* flags for xf86LookupMode */ -typedef enum { - LOOKUP_DEFAULT = 0, /* Use default mode lookup method */ - LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */ - LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */ - LOOKUP_LIST_ORDER, /* Pick first useful mode in list */ - LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */ - LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */ -} LookupModeFlags; - -#define NoDepth24Support 0x00 -#define Support24bppFb 0x01 /* 24bpp framebuffer supported */ -#define Support32bppFb 0x02 /* 32bpp framebuffer supported */ -#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */ -#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */ -#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */ -#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */ - - -/* For DPMS */ -typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int); - -/* Input handler proc */ -typedef void (*InputHandlerProc)(int fd, pointer data); - -/* These are used by xf86GetClocks */ -#define CLK_REG_SAVE -1 -#define CLK_REG_RESTORE -2 - -/* - * misc constants - */ -#define INTERLACE_REFRESH_WEIGHT 1.5 -#define SYNC_TOLERANCE 0.01 /* 1 percent */ -#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */ - - -#define OVERLAY_8_32_DUALFB 0x00000001 -#define OVERLAY_8_24_DUALFB 0x00000002 -#define OVERLAY_8_16_DUALFB 0x00000004 -#define OVERLAY_8_32_PLANAR 0x00000008 - -/* Values of xf86Info.mouseFlags */ -#define MF_CLEAR_DTR 1 -#define MF_CLEAR_RTS 2 - -/* Action Events */ -typedef enum { - ACTION_TERMINATE = 0, /* Terminate Server */ - ACTION_NEXT_MODE = 10, /* Switch to next video mode */ - ACTION_PREV_MODE, - ACTION_SWITCHSCREEN = 100, /* VT switch */ - ACTION_SWITCHSCREEN_NEXT, - ACTION_SWITCHSCREEN_PREV, -} ActionEvent; - -#endif /* _XF86STR_H */ + +/* + * 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 definitions of the public XFree86 data structures/types. + * Any data structures that video drivers need to access should go here. + */ + +#ifndef _XF86STR_H +#define _XF86STR_H + +#include "misc.h" +#include "input.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "colormapst.h" +#include "xf86Module.h" +#include "xf86Opt.h" +#include "xf86Pci.h" + +#include + +/** + * Integer type that is of the size of the addressable memory (machine size). + * On most platforms \c uintptr_t will suffice. However, on some mixed + * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this + * must be 64-bits. + */ +#include +#if defined(__powerpc__) +typedef uint64_t memType; +#else +typedef uintptr_t memType; +#endif + + +/* Video mode flags */ + +typedef enum { + V_PHSYNC = 0x0001, + V_NHSYNC = 0x0002, + V_PVSYNC = 0x0004, + V_NVSYNC = 0x0008, + V_INTERLACE = 0x0010, + V_DBLSCAN = 0x0020, + V_CSYNC = 0x0040, + V_PCSYNC = 0x0080, + V_NCSYNC = 0x0100, + V_HSKEW = 0x0200, /* hskew provided */ + V_BCAST = 0x0400, + V_PIXMUX = 0x1000, + V_DBLCLK = 0x2000, + V_CLKDIV2 = 0x4000 +} ModeFlags; + +typedef enum { + INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */ +} CrtcAdjustFlags; + +/* Flags passed to ChipValidMode() */ +typedef enum { + MODECHECK_INITIAL = 0, + MODECHECK_FINAL = 1 +} ModeCheckFlags; + +/* These are possible return values for xf86CheckMode() and ValidMode() */ +typedef enum { + MODE_OK = 0, /* Mode OK */ + MODE_HSYNC, /* hsync out of range */ + MODE_VSYNC, /* vsync out of range */ + MODE_H_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_V_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_BAD_WIDTH, /* requires an unsupported linepitch */ + MODE_NOMODE, /* no mode with a maching name */ + MODE_NO_INTERLACE, /* interlaced mode not supported */ + MODE_NO_DBLESCAN, /* doublescan mode not supported */ + MODE_NO_VSCAN, /* multiscan mode not supported */ + MODE_MEM, /* insufficient video memory */ + MODE_VIRTUAL_X, /* mode width too large for specified virtual size */ + MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */ + MODE_MEM_VIRT, /* insufficient video memory given virtual size */ + MODE_NOCLOCK, /* no fixed clock available */ + MODE_CLOCK_HIGH, /* clock required is too high */ + MODE_CLOCK_LOW, /* clock required is too low */ + MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */ + MODE_BAD_HVALUE, /* horizontal timing was out of range */ + MODE_BAD_VVALUE, /* vertical timing was out of range */ + MODE_BAD_VSCAN, /* VScan value out of range */ + MODE_HSYNC_NARROW, /* horizontal sync too narrow */ + MODE_HSYNC_WIDE, /* horizontal sync too wide */ + MODE_HBLANK_NARROW, /* horizontal blanking too narrow */ + MODE_HBLANK_WIDE, /* horizontal blanking too wide */ + MODE_VSYNC_NARROW, /* vertical sync too narrow */ + MODE_VSYNC_WIDE, /* vertical sync too wide */ + MODE_VBLANK_NARROW, /* vertical blanking too narrow */ + MODE_VBLANK_WIDE, /* vertical blanking too wide */ + MODE_PANEL, /* exceeds panel dimensions */ + MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */ + MODE_ONE_WIDTH, /* only one width is supported */ + MODE_ONE_HEIGHT, /* only one height is supported */ + MODE_ONE_SIZE, /* only one resolution is supported */ + MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */ + MODE_BANDWIDTH, /* mode requires too much memory bandwidth */ + MODE_BAD = -2, /* unspecified reason */ + MODE_ERROR = -1 /* error condition */ +} ModeStatus; + +/* + * The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN. + * Preferred will bubble a mode to the top within a set. + */ +# define M_T_BUILTIN 0x01 /* built-in mode */ +# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */ +# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */ +# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C) + /* built-in mode - configure CRTC and clock */ +# define M_T_PREFERRED 0x08 /* preferred mode within a set */ +# define M_T_DEFAULT 0x10 /* (VESA) default modes */ +# define M_T_USERDEF 0x20 /* One of the modes from the config file */ +# define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */ +# define M_T_USERPREF 0x80 /* mode preferred by the user config */ + +/* Video mode */ +typedef struct _DisplayModeRec { + struct _DisplayModeRec * prev; + struct _DisplayModeRec * next; + char * name; /* identifier for the mode */ + ModeStatus status; + int type; + + /* These are the values that the user sees/provides */ + int Clock; /* pixel clock freq (kHz) */ + int HDisplay; /* horizontal timing */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int HSkew; + int VDisplay; /* vertical timing */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int VScan; + int Flags; + + /* These are the values the hardware uses */ + int ClockIndex; + int SynthClock; /* Actual clock freq to + * be programmed (kHz) */ + int CrtcHDisplay; + int CrtcHBlankStart; + int CrtcHSyncStart; + int CrtcHSyncEnd; + int CrtcHBlankEnd; + int CrtcHTotal; + int CrtcHSkew; + int CrtcVDisplay; + int CrtcVBlankStart; + int CrtcVSyncStart; + int CrtcVSyncEnd; + int CrtcVBlankEnd; + int CrtcVTotal; + Bool CrtcHAdjusted; + Bool CrtcVAdjusted; + int PrivSize; + INT32 * Private; + int PrivFlags; + + float HSync, VRefresh; +} DisplayModeRec, *DisplayModePtr; + +/* The monitor description */ + +#define MAX_HSYNC 8 +#define MAX_VREFRESH 8 + +typedef struct { float hi, lo; } range; + +typedef struct { CARD32 red, green, blue; } rgb; + +typedef struct { float red, green, blue; } Gamma; + +/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */ +#define GAMMA_MAX 10.0 +#define GAMMA_MIN (1.0 / GAMMA_MAX) +#define GAMMA_ZERO (GAMMA_MIN / 100.0) + +typedef struct { + char * id; + char * vendor; + char * model; + int nHsync; + range hsync[MAX_HSYNC]; + int nVrefresh; + range vrefresh[MAX_VREFRESH]; + DisplayModePtr Modes; /* Start of the monitor's mode list */ + DisplayModePtr Last; /* End of the monitor's mode list */ + Gamma gamma; /* Gamma of the monitor */ + int widthmm; + int heightmm; + pointer options; + pointer DDC; + Bool reducedblanking; /* Allow CVT reduced blanking modes? */ + int maxPixClock; /* in kHz, like mode->Clock */ +} MonRec, *MonPtr; + +/* the list of clock ranges */ +typedef struct x_ClockRange { + struct x_ClockRange *next; + int minClock; /* (kHz) */ + int maxClock; /* (kHz) */ + int clockIndex; /* -1 for programmable clocks */ + Bool interlaceAllowed; + Bool doubleScanAllowed; + int ClockMulFactor; + int ClockDivFactor; + int PrivFlags; +} ClockRange, *ClockRangePtr; + +/* + * The driverFunc. xorgDriverFuncOp specifies the action driver should + * perform. If requested option is not supported function should return + * FALSE. pointer can be used to pass arguments to the function or + * to return data to the caller. + */ +typedef struct _ScrnInfoRec *ScrnInfoPtr; + +/* do not change order */ +typedef enum { + RR_GET_INFO, + RR_SET_CONFIG, + RR_GET_MODE_MM, + GET_REQUIRED_HW_INTERFACES = 10 +} xorgDriverFuncOp; + +typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp, + pointer); + +/* RR_GET_INFO, RR_SET_CONFIG */ +typedef struct { + int rotation; + int rate; + int width; + int height; +} xorgRRConfig; + +typedef union { + short RRRotations; + xorgRRConfig RRConfig; +} xorgRRRotation, *xorgRRRotationPtr; + +/* RR_GET_MODE_MM */ +typedef struct { + DisplayModePtr mode; + int virtX; + int virtY; + int mmWidth; + int mmHeight; +} xorgRRModeMM, *xorgRRModeMMPtr; + +/* GET_REQUIRED_HW_INTERFACES */ +#define HW_IO 1 +#define HW_MMIO 2 +#define HW_SKIP_CONSOLE 4 +#define NEED_IO_ENABLED(x) (x & HW_IO) + +typedef CARD32 xorgHWFlags; + +/* + * The driver list struct. This contains the information required for each + * driver before a ScrnInfoRec has been allocated. + */ +struct _DriverRec; + +typedef struct { + int driverVersion; + char * driverName; + void (*Identify)(int flags); + Bool (*Probe)(struct _DriverRec *drv, int flags); + const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype); + pointer module; + int refCount; +} DriverRec1; + +struct _SymTabRec; +struct _PciChipsets; + +typedef struct _DriverRec { + int driverVersion; + char * driverName; + void (*Identify)(int flags); + Bool (*Probe)(struct _DriverRec *drv, int flags); + const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype); + pointer module; + int refCount; + xorgDriverFuncProc *driverFunc; + + const struct pci_id_match * supported_devices; + Bool (*PciProbe)( struct _DriverRec * drv, int entity_num, + struct pci_device * dev, intptr_t match_data ); +} DriverRec, *DriverPtr; + +/* + * AddDriver flags + */ +#define HaveDriverFuncs 1 + +/* + * These are the private bus types. New types can be added here. Types + * required for the public interface should be added to xf86str.h, with + * function prototypes added to xf86.h. + */ + +/* Tolerate prior #include */ +#if defined(linux) && defined(_INPUT_H) +#undef BUS_NONE +#undef BUS_PCI +#undef BUS_SBUS +#undef BUS_last +#endif + +typedef enum { + BUS_NONE, + BUS_PCI, + BUS_SBUS, + BUS_last /* Keep last */ +} BusType; + +struct pci_device; + +typedef struct { + int fbNum; +} SbusBusId; + +typedef struct _bus { + BusType type; + union { + struct pci_device *pci; + SbusBusId sbus; + } id; +} BusRec, *BusPtr; + +#define MAXCLOCKS 128 +typedef enum { + DAC_BPP8 = 0, + DAC_BPP16, + DAC_BPP24, + DAC_BPP32, + MAXDACSPEEDS +} DacSpeedIndex; + +typedef struct { + char * identifier; + char * vendor; + char * board; + char * chipset; + char * ramdac; + char * driver; + struct _confscreenrec * myScreenSection; + Bool claimed; + int dacSpeeds[MAXDACSPEEDS]; + int numclocks; + int clock[MAXCLOCKS]; + char * clockchip; + char * busID; + Bool active; + Bool inUse; + int videoRam; + int textClockFreq; + unsigned long BiosBase; /* Base address of video BIOS */ + unsigned long MemBase; /* Frame buffer base address */ + unsigned long IOBase; + int chipID; + int chipRev; + pointer options; + int irq; + int screen; /* For multi-CRTC cards */ +} GDevRec, *GDevPtr; + +typedef struct { + char * identifier; + char * driver; + pointer commonOptions; + pointer extraOptions; +} IDevRec, *IDevPtr; + +typedef struct { + int frameX0; + int frameY0; + int virtualX; + int virtualY; + int depth; + int fbbpp; + rgb weight; + rgb blackColour; + rgb whiteColour; + int defaultVisual; + char ** modes; + pointer options; +} DispRec, *DispPtr; + +typedef struct _confxvportrec { + char * identifier; + pointer options; +} confXvPortRec, *confXvPortPtr; + +typedef struct _confxvadaptrec { + char * identifier; + int numports; + confXvPortPtr ports; + pointer options; +} confXvAdaptorRec, *confXvAdaptorPtr; + +typedef struct _confscreenrec { + char * id; + int screennum; + int defaultdepth; + int defaultbpp; + int defaultfbbpp; + MonPtr monitor; + GDevPtr device; + int numdisplays; + DispPtr displays; + int numxvadaptors; + confXvAdaptorPtr xvadaptors; + pointer options; +} confScreenRec, *confScreenPtr; + +typedef enum { + PosObsolete = -1, + PosAbsolute = 0, + PosRightOf, + PosLeftOf, + PosAbove, + PosBelow, + PosRelative +} PositionType; + +typedef struct _screenlayoutrec { + confScreenPtr screen; + char * topname; + confScreenPtr top; + char * bottomname; + confScreenPtr bottom; + char * leftname; + confScreenPtr left; + char * rightname; + confScreenPtr right; + PositionType where; + int x; + int y; + char * refname; + confScreenPtr refscreen; +} screenLayoutRec, *screenLayoutPtr; + +typedef struct _serverlayoutrec { + char * id; + screenLayoutPtr screens; + GDevPtr inactives; + IDevPtr* inputs; /* NULL terminated */ + pointer options; +} serverLayoutRec, *serverLayoutPtr; + +typedef struct _confdribufferrec { + int count; + int size; + enum { + XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */ + } flags; +} confDRIBufferRec, *confDRIBufferPtr; + +typedef struct _confdrirec { + int group; + int mode; + int bufs_count; + confDRIBufferRec *bufs; +} confDRIRec, *confDRIPtr; + +/* These values should be adjusted when new fields are added to ScrnInfoRec */ +#define NUM_RESERVED_INTS 16 +#define NUM_RESERVED_POINTERS 14 +#define NUM_RESERVED_FUNCS 11 + +typedef pointer (*funcPointer)(void); + +/* flags for depth 24 pixmap options */ +typedef enum { + Pix24DontCare = 0, + Pix24Use24, + Pix24Use32 +} Pix24Flags; + +/* Power management events: so far we only support APM */ + +typedef enum { + XF86_APM_UNKNOWN = -1, + XF86_APM_SYS_STANDBY, + XF86_APM_SYS_SUSPEND, + XF86_APM_CRITICAL_SUSPEND, + XF86_APM_USER_STANDBY, + XF86_APM_USER_SUSPEND, + XF86_APM_STANDBY_RESUME, + XF86_APM_NORMAL_RESUME, + XF86_APM_CRITICAL_RESUME, + XF86_APM_LOW_BATTERY, + XF86_APM_POWER_STATUS_CHANGE, + XF86_APM_UPDATE_TIME, + XF86_APM_CAPABILITY_CHANGED, + XF86_APM_STANDBY_FAILED, + XF86_APM_SUSPEND_FAILED +} pmEvent; + +typedef enum { + PM_WAIT, + PM_CONTINUE, + PM_FAILED, + PM_NONE +} pmWait; + +typedef struct _PciChipsets { + /** + * Key used to match this device with its name in an array of + * \c SymTabRec. + */ + int numChipset; + + /** + * This value is quirky. Depending on the driver, it can take on one of + * three meanings. In drivers that have exactly one vendor ID (e.g., + * radeon, mga, i810) the low 16-bits are the device ID. + * + * In drivers that can have multiple vendor IDs (e.g., the glint driver + * can have either 3dlabs' ID or TI's ID, the i740 driver can have either + * Intel's ID or Real3D's ID, etc.) the low 16-bits are the device ID and + * the high 16-bits are the vendor ID. + * + * In drivers that don't have a specific vendor (e.g., vga) contains the + * device ID for either the generic VGA or generic 8514 devices. This + * turns out to be the same as the subclass and programming interface + * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or + * 0x000101) and for 8514 is 0x030001). + */ + int PCIid; + +/* dummy place holders for drivers to build against old/new servers */ +#define RES_UNDEFINED NULL +#define RES_EXCLUSIVE_VGA NULL +#define RES_SHARED_VGA NULL + void *dummy; +} PciChipsets; + + +/* Entity properties */ +typedef void (*EntityProc)(int entityIndex,pointer private); + +typedef struct _entityInfo { + int index; + BusRec location; + int chipset; + Bool active; + GDevPtr device; + DriverPtr driver; +} EntityInfoRec, *EntityInfoPtr; + +/* server states */ + +typedef enum { + SETUP, + OPERATING +} xf86State; + +/* DGA */ + +typedef struct { + int num; /* A unique identifier for the mode (num > 0) */ + DisplayModePtr mode; + int flags; /* DGA_CONCURRENT_ACCESS, etc... */ + int imageWidth; /* linear accessible portion (pixels) */ + int imageHeight; + int pixmapWidth; /* Xlib accessible portion (pixels) */ + int pixmapHeight; /* both fields ignored if no concurrent access */ + int bytesPerScanline; + int byteOrder; /* MSBFirst, LSBFirst */ + int depth; + int bitsPerPixel; + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + short visualClass; + int viewportWidth; + int viewportHeight; + int xViewportStep; /* viewport position granularity */ + int yViewportStep; + int maxViewportX; /* max viewport origin */ + int maxViewportY; + int viewportFlags; /* types of page flipping possible */ + int offset; /* offset into physical memory */ + unsigned char *address; /* server's mapped framebuffer */ + int reserved1; + int reserved2; +} DGAModeRec, *DGAModePtr; + +typedef struct { + DGAModePtr mode; + PixmapPtr pPix; +} DGADeviceRec, *DGADevicePtr; + +/* + * Flags for driver Probe() functions. + */ +#define PROBE_DEFAULT 0x00 +#define PROBE_DETECT 0x01 +#define PROBE_TRYHARD 0x02 + +/* + * Driver entry point types + */ + +typedef Bool xf86ProbeProc (DriverPtr, int); +typedef Bool xf86PreInitProc (ScrnInfoPtr, int); +typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**); +typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int); +typedef void xf86AdjustFrameProc (int, int, int, int); +typedef Bool xf86EnterVTProc (int, int); +typedef void xf86LeaveVTProc (int, int); +typedef void xf86FreeScreenProc (int, int); +typedef ModeStatus xf86ValidModeProc (int, DisplayModePtr, Bool, int); +typedef void xf86EnableDisableFBAccessProc(int, Bool); +typedef int xf86SetDGAModeProc (int, int, DGADevicePtr); +typedef int xf86ChangeGammaProc (int, Gamma); +typedef void xf86PointerMovedProc (int, int, int); +typedef Bool xf86PMEventProc (int, pmEvent, Bool); +typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int); +typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr); +typedef void xf86SetOverscanProc (ScrnInfoPtr, int); + + +/* + * ScrnInfoRec + * + * There is one of these for each screen, and it holds all the screen-specific + * information. + * + * Note: the size and layout must be kept the same across versions. New + * fields are to be added in place of the "reserved*" fields. No fields + * are to be dependent on compile-time defines. + */ + + +typedef struct _ScrnInfoRec { + int driverVersion; + char * driverName; /* canonical name used in */ + /* the config file */ + ScreenPtr pScreen; /* Pointer to the ScreenRec */ + int scrnIndex; /* Number of this screen */ + Bool configured; /* Is this screen valid */ + int origIndex; /* initial number assigned to + * this screen before + * finalising the number of + * available screens */ + + /* Display-wide screenInfo values needed by this screen */ + int imageByteOrder; + int bitmapScanlineUnit; + int bitmapScanlinePad; + int bitmapBitOrder; + int numFormats; + PixmapFormatRec formats[MAXFORMATS]; + PixmapFormatRec fbFormat; + + int bitsPerPixel; /* fb bpp */ + Pix24Flags pixmap24; /* pixmap pref for depth 24 */ + int depth; /* depth of default visual */ + MessageType depthFrom; /* set from config? */ + MessageType bitsPerPixelFrom; /* set from config? */ + rgb weight; /* r/g/b weights */ + rgb mask; /* rgb masks */ + rgb offset; /* rgb offsets */ + int rgbBits; /* Number of bits in r/g/b */ + Gamma gamma; /* Gamma of the monitor */ + int defaultVisual; /* default visual class */ + int maxHValue; /* max horizontal timing */ + int maxVValue; /* max vertical timing value */ + int virtualX; /* Virtual width */ + int virtualY; /* Virtual height */ + int xInc; /* Horizontal timing increment */ + MessageType virtualFrom; /* set from config? */ + int displayWidth; /* memory pitch */ + int frameX0; /* viewport position */ + int frameY0; + int frameX1; + int frameY1; + int zoomLocked; /* Disallow mode changes */ + DisplayModePtr modePool; /* list of compatible modes */ + DisplayModePtr modes; /* list of actual modes */ + DisplayModePtr currentMode; /* current mode + * This was previously + * overloaded with the modes + * field, which is a pointer + * into a circular list */ + confScreenPtr confScreen; /* Screen config info */ + MonPtr monitor; /* Monitor information */ + DispPtr display; /* Display information */ + int * entityList; /* List of device entities */ + int numEntities; + int widthmm; /* physical display dimensions + * in mm */ + int heightmm; + int xDpi; /* width DPI */ + int yDpi; /* height DPI */ + char * name; /* Name to prefix messages */ + pointer driverPrivate; /* Driver private area */ + DevUnion * privates; /* Other privates can hook in + * here */ + DriverPtr drv; /* xf86DriverList[] entry */ + pointer module; /* Pointer to module head */ + int colorKey; + int overlayFlags; + + /* Some of these may be moved out of here into the driver private area */ + + char * chipset; /* chipset name */ + char * ramdac; /* ramdac name */ + char * clockchip; /* clock name */ + Bool progClock; /* clock is programmable */ + int numClocks; /* number of clocks */ + int clock[MAXCLOCKS]; /* list of clock frequencies */ + int videoRam; /* amount of video ram (kb) */ + unsigned long biosBase; /* Base address of video BIOS */ + unsigned long memPhysBase; /* Physical address of FB */ + unsigned long fbOffset; /* Offset of FB in the above */ + IOADDRESS domainIOBase; /* Domain I/O base address */ + int memClk; /* memory clock */ + int textClockFreq; /* clock of text mode */ + Bool flipPixels; /* swap default black/white */ + pointer options; + + int chipID; + int chipRev; + + /* Allow screens to be enabled/disabled individually */ + Bool vtSema; + DevUnion pixmapPrivate; /* saved devPrivate from pixmap */ + + /* hw cursor moves at SIGIO time */ + Bool silkenMouse; + + /* Storage for clockRanges and adjustFlags for use with the VidMode ext */ + ClockRangePtr clockRanges; + int adjustFlags; + + /* + * These can be used when the minor ABI version is incremented. + * The NUM_* parameters must be reduced appropriately to keep the + * structure size and alignment unchanged. + */ + int reservedInt[NUM_RESERVED_INTS]; + + int * entityInstanceList; + struct pci_device *vgaDev; + + pointer reservedPtr[NUM_RESERVED_POINTERS]; + + /* + * Driver entry points. + * + */ + + xf86ProbeProc *Probe; + xf86PreInitProc *PreInit; + xf86ScreenInitProc *ScreenInit; + xf86SwitchModeProc *SwitchMode; + xf86AdjustFrameProc *AdjustFrame; + xf86EnterVTProc *EnterVT; + xf86LeaveVTProc *LeaveVT; + xf86FreeScreenProc *FreeScreen; + xf86ValidModeProc *ValidMode; + xf86EnableDisableFBAccessProc *EnableDisableFBAccess; + xf86SetDGAModeProc *SetDGAMode; + xf86ChangeGammaProc *ChangeGamma; + xf86PointerMovedProc *PointerMoved; + xf86PMEventProc *PMEvent; + xf86DPMSSetProc *DPMSSet; + xf86LoadPaletteProc *LoadPalette; + xf86SetOverscanProc *SetOverscan; + xorgDriverFuncProc *DriverFunc; + + /* + * This can be used when the minor ABI version is incremented. + * The NUM_* parameter must be reduced appropriately to keep the + * structure size and alignment unchanged. + */ + funcPointer reservedFuncs[NUM_RESERVED_FUNCS]; + +} ScrnInfoRec; + + +typedef struct { + Bool (*OpenFramebuffer)( + ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, + int *offset, + int *extra + ); + void (*CloseFramebuffer)(ScrnInfoPtr pScrn); + Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode); + void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags); + int (*GetViewport)(ScrnInfoPtr pScrn); + void (*Sync)(ScrnInfoPtr); + void (*FillRect)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color + ); + void (*BlitRect)( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty + ); + void (*BlitTransRect)( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color + ); +} DGAFunctionRec, *DGAFunctionPtr; + +typedef struct _SymTabRec { + int token; /* id of the token */ + const char * name; /* token name */ +} SymTabRec, *SymTabPtr; + +/* flags for xf86LookupMode */ +typedef enum { + LOOKUP_DEFAULT = 0, /* Use default mode lookup method */ + LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */ + LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */ + LOOKUP_LIST_ORDER, /* Pick first useful mode in list */ + LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */ + LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */ +} LookupModeFlags; + +#define NoDepth24Support 0x00 +#define Support24bppFb 0x01 /* 24bpp framebuffer supported */ +#define Support32bppFb 0x02 /* 32bpp framebuffer supported */ +#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */ +#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */ +#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */ +#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */ + + +/* For DPMS */ +typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int); + +/* Input handler proc */ +typedef void (*InputHandlerProc)(int fd, pointer data); + +/* These are used by xf86GetClocks */ +#define CLK_REG_SAVE -1 +#define CLK_REG_RESTORE -2 + +/* + * misc constants + */ +#define INTERLACE_REFRESH_WEIGHT 1.5 +#define SYNC_TOLERANCE 0.01 /* 1 percent */ +#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */ + + +#define OVERLAY_8_32_DUALFB 0x00000001 +#define OVERLAY_8_24_DUALFB 0x00000002 +#define OVERLAY_8_16_DUALFB 0x00000004 +#define OVERLAY_8_32_PLANAR 0x00000008 + +/* Values of xf86Info.mouseFlags */ +#define MF_CLEAR_DTR 1 +#define MF_CLEAR_RTS 2 + +/* Action Events */ +typedef enum { + ACTION_TERMINATE = 0, /* Terminate Server */ + ACTION_NEXT_MODE = 10, /* Switch to next video mode */ + ACTION_PREV_MODE, + ACTION_SWITCHSCREEN = 100, /* VT switch */ + ACTION_SWITCHSCREEN_NEXT, + ACTION_SWITCHSCREEN_PREV, +} ActionEvent; + +#endif /* _XF86STR_H */ diff --git a/xorg-server/hw/xfree86/doc/Makefile.am b/xorg-server/hw/xfree86/doc/Makefile.am index 5809fa05f..a8cbc3c6b 100644 --- a/xorg-server/hw/xfree86/doc/Makefile.am +++ b/xorg-server/hw/xfree86/doc/Makefile.am @@ -1,9 +1,8 @@ -if BUILDDOCS -SUBDIRS = devel man sgml -else -SUBDIRS = man -endif - -EXTRA_DIST = \ - README.DRI \ - README.rapidaccess +if BUILDDOCS +SUBDIRS = devel man sgml +else +SUBDIRS = man +endif + +EXTRA_DIST = \ + README.modes diff --git a/xorg-server/hw/xfree86/doc/README.DRI b/xorg-server/hw/xfree86/doc/README.DRI deleted file mode 100644 index 7fc52eb32..000000000 --- a/xorg-server/hw/xfree86/doc/README.DRI +++ /dev/null @@ -1,1256 +0,0 @@ - DRI User Guide - - VA Linux Systems, Inc. Professional Services - Graphics. - - 15 June 2001 - -1. Preamble - -1.1 Copyright - -Copyright 2000-2001 by VA Linux Systems, Inc. All Rights Reserved. - -Permission is granted to make and distribute verbatim copies of this document -provided the copyright notice and this permission notice are preserved on all -copies. - -1.2 Trademarks - -OpenGL is a registered trademark and SGI is a trademark of Silicon Graphics, -Inc. Unix is a registered trademark of The Open Group. The `X' device and X -Window System are trademarks of The Open Group. XFree86 is a trademark of -The XFree86 Project. Linux is a registered trademark of Linus Torvalds. -Intel is a registered trademark of Intel Corporation. 3Dlabs, GLINT, and -Oxygen are either registered trademarks or trademarks of 3Dlabs Inc. Ltd. -3dfx, Voodoo3, Voodoo4, and Voodoo5 are registered trademarks of 3dfx Inter- -active, Incorporated. Matrox is a registered trademark of Matrox Electronic -Systems Ltd. ATI Rage and Radeon are registered trademarks of ATI Technolo- -gies, Inc. All other trademarks mentioned are the property of their respec- -tive owners. - -2. Introduction - -With XFree86 4.x and the Direct Rendering Interface (DRI), hardware acceler- -ated 3D graphics can be considered a standard feature on Linux workstations. -Support for other operating systems, such as FreeBSD, is underway. - -This document describes how to use the DRI system and troubleshoot problems -which may occur. Readers should have a basic understanding of Linux, X and -OpenGL. See the resources section at the end for more documentation and -software downloads. - -This document does not cover compilation or installation of XFree86 4.x. It -is assumed that you've already installed a Linux distribution which includes -XFree86 4.x or that you're an experienced Linux developer who has compiled -the DRI for himself. DRI download, compilation and installation instructions -can be found at http://dri.sourceforge.net/DRIcompile.html - -Edits, corrections and updates to this document may be mailed to . - -3. Supported Architectures & Hardware - -3.1 CPU Architectures - -The architectures currently supported by the DRI have grown from the initial -Intel i386 systems to now include the Alpha Processor and the Sun SPARC -machines. - -Intel's SSE (a.k.a. Katmai) instructions are used in optimized vertex trans- -formation functions in Mesa-based drivers. This requires a recent Linux ker- -nel both at compile and runtime. See the DRI Compile Guide for compile-time -requirements. At runtime a check is made to determine if the CPU can execute -SSE instructions. They're disabled otherwise. - -AMD's 3DNow! instructions are also used in optimized vertex transformation -functions in the Mesa-based DRI drivers. 3DNow! is supported in most ver- -sions of Linux. Like the SSE optimizations, a runtime check is made to -determine if the CPU can execute 3DNow! instructions. - -Alpha-based systems can use Compaq's optimized math library for improved 3D -performance. See the DRI Compilation Guide for details. - -3.2 Graphics Hardware - -XFree86 4.2 (or later versions) includes 3D acceleration for the following -graphics hardware: - - o 3dfx, supported on Intel x86, AMD and Alpha: - - o Voodoo5 5500 - - o Voodoo4 4500 - - o Voodoo3 3500 TV - - o Voodoo3 3000 AGP - - o Voodoo3 3000 PCI - - o Voodoo3 2000 AGP - - o Voodoo3 2000 PCI - - o Voodoo Banshee - - o Velocity 100/200 - - There are many configurations of 3dfx cards on the market. Not all have - been tested. - - o Matrox, supported on Intel x86 and AMD: - - o Matrox G200 - - o Matrox G400 - - o Intel i810/i815/i830 (motherboard chipsets) - - o i810 - - o i810-dc100 - - o i810e - - o i815 - - o i830 - - o ATI Rage 128, supported on Intel x86, AMD and Alpha: - - o Rage Fury - - o Rage Magnum - - o XPERT 2000 - - o XPERT 128 - - o XPERT 99 - - o All-in-Wonder 128 - - o Rage 128 PCI (Alpha-based systems) - - Note that both PCI and AGP versions of Rage 128 based cards are sup- - ported at this time. - - o ATI Radeon, supported on Intel x86, AMD and Alpha: - - o Radeon SDR AGP - - o Radeon DDR AGP - - o Radeon 32MB SDR PCI (Alpha-based systems) - - o Radeon 7000, M6 (RV100) - - o Radeon 7200 (R100) - - o Radeon 7500, M7 (RV200) - - o Radeon 8500, 9100 (R200) - - o Radeon 9000, M9 (RV250) - - o 3Dlabs, supported on Intel x86 and AMD: - - o Oxygen GMX 2000 (MX/Gamma based). Note: this driver is no longer - being actively developed. - -Support for other hardware is underway. Most of the DRI development work is -funded by contracts with IHVs. These contracts often prevent us from -announcing drivers before they're released. Queries about upcoming drivers -may not be answerable. - -4. Prerequisite Software - - o The DRI is available in XFree86 4.0 and later. - - o Some hardware drivers require specific versions of the Linux kernel for - AGP support, etc. See section 10 for specifics. - - o You DO NOT need to install Mesa separately. The parts of Mesa needed - for hardware acceleration are already in the XFree86/DRI project. - -5. Kernel Modules - -3D hardware acceleration requires a DRI kernel module that's specific to your -graphics hardware. - -The DRI kernel module version must exactly match your running kernel version. -Since there are so many versions of the kernel, it's difficult to provide -precompiled kernel modules. - -While the Linux source tree includes the DRI kernel module sources, the lat- -est DRI kernel sources will be found in the DRI source tree. - -See the DRI Compilation Guide for information on compiling the DRI kernel -modules. - -XFree86 4.0.1 added automatic kernel module loading to the X server. On -Linux, the X server uses modprobe to load kernel modules. In Linux 2.4.x the -DRM kernel modules should be kept in /lib/modules/2.4.x/ker- -nel/drivers/char/drm/ for automatic loading to work. - -Optionally, DRM kernel modules can be loaded manually with insmod prior to -starting the X server. - -You can verify that the kernel module was installed with lsmod, checking the -X server startup log, and checking that /proc/dri/0 exists. - -6. XF86Config file - -The XFree86 configuration file is usually found in /etc/X11/XF86Config. This -section describes the parts which must be specially set for the DRI. - -First, the XF86Config file must load the GLX and DRI modules: - - Section "Module" - ... - # This loads the GLX module - Load "glx" - # This loads the DRI module - Load "dri" - EndSection - -Next, the DRI section can be used to restrict access to direct rendering. A -client can only use direct rendering if it has permission to open the -/dev/dri/card? file(s). The permissions on these DRI device files is con- -trolled by the "DRI" section in the XF86Config file. - -If you want all of the users on your system to be able to use direct-render- -ing, then use a simple DRI section like this: - - Section "DRI" - Mode 0666 - EndSection - -This section will allow any user with a current connection to the X server to -use direct rendering. - -If you want to restrict the use of direct-rendering to a certain group of -users, then create a group for those users by editing the /etc/group file on -your system. For example, you may want to create a group called xf86dri and -place two users (e.g., fred and jane) in that group. To do that, you might -add the following line to /etc/group: - - xf86dri:x:8000:fred,jane - -You have to be careful that the group id (8000 in this example) is unique. - -Then you would use the following DRI section: - - Section "DRI" - Group "xf86dri" - Mode 0660 - EndSection - -This would limit access to direct-rendering to those users in the xf86dri -group (fred and jane in this example). When other users tried to use direct -rendering, they would fall back to unaccelerated indirect rendering. - -[Note that there is a known bug in XFree86 4.0 that prevents some changes to -the DRI section from taking effect. Until this bug is fixed, if you change -the DRI section, please also remove the /dev/dri directory with the rm -rf -/dev/dri command.] - -Finally, the XF86Config file needs Device and Screen sections specific to -your hardware. Look in section 10: Hardware-Specific Information and Trou- -bleshooting for details. - -7. Memory usage - -Using the 3D features of a graphics card requires more memory than when it's -just used as a 2D device. Double buffering, depth buffering, stencil -buffers, textures, etc. all require extra graphics memory. These features -may require four times the memory used for a simple 2D display. - -If your graphics card doesn't have a lot of memory (less than 16MB, for exam- -ple), you may have to reduce your screen size and/or color depth in order to -use 3D features. Reducing the screen resolution will also leave more space -for texture images, possibly improving 3D performance. If, for example, you -play Quake3 at 1024x768 but start your display at 1600x1200 you might con- -sider restarting X at 1024x768 in order to maximize your texture memory -space. - -The documentation included with your card should have information about maxi- -mum screen size when using 3D. - -8. Using 3D Acceleration - -This section describes how to link your application with libGL.so and verify -that you are in fact using 3D acceleration. - -8.1 libGL.so - -Your OpenGL program must link with the libGL.so.1.2 library provided by -XFree86. The libGL.so.1.2 library contains a GLX protocol encoder for indi- -rect/remote rendering and DRI code for accessing hardware drivers. In par- -ticular, be sure you're not using libGL.so from another source such as Mesa -or the Utah GLX project. - -Unless it was built in a special way, the libGL.so library does not contain -any 3D hardware driver code. Instead, libGL.so dynamically loads the appro- -priate 3D driver during initialization. - -Most simple OpenGL programs also use the GLUT and GLU libraries. A source -for these libraries is listed in the Resources section below. - -8.2 Compiling and linking an OpenGL program - -A simple GLUT/OpenGL program may be compiled and linked as follows: - - gcc program.c -I/usr/local/include -L/usr/local/lib -L/usr/X11R6/lib -lglut -lGLU -lGL -o program - -The -I option is used to specify where the GL/glut.h (and possibly the -GL/gl.h and GL/glu.h) header file may be found. - -The -L options specify where the libglut.so and the X libraries are located. -libGL.so and libGLU.so should be in /usr/lib, as specified by the -Linux/OpenGL ABI standard. - -The -lglut -lGLU -lGL arguments specify that the application should link with -the GLUT, GLU and GL libraries, in that order. - -8.3 Running your OpenGL program - -Simply typing ./program in your shell should execute the program. - -If you get an error message such as - - gears: error in loading shared libraries: libGL.so.1: cannot - open shared object file: No such file or directory - -if means that the libGL.so.1 file is not the right location. Proceed to the -trouble shooting section. - -8.4 libOSMesa.so - -OSMesa (Off-Screen Mesa) is an interface and driver for rendering 3D images -into a user-allocated block of memory rather than an on-screen window. It -was originally developed for Mesa before Mesa became part of the XFree86/DRI -project. It can now be used with the XFree86/DRI libGL.so as well. - -libOSMesa.so implements the OSMesa interface and it must be linked with your -application if you want to use the OSMesa functions. You must also link with -libGL.so. For example: - - gcc osdemo.c -lOSMesa -lGLU -lGL -o osdemo - -In stand-alone Mesa this interface was compiled into the monolithic libGL.so -(formerly libMesaGL.so) library. In XFree86 4.0.1 and later this interface -is implemented in a separate library. - -8.5 glxinfo - -glxinfo is a useful program for checking which version of libGL you're using -as well as which DRI-based driver. Simply type glxinfo and examine the -OpenGL vendor, renderer, and version lines. Among the output you should see -something like this: - - OpenGL vendor string: VA Linux Systems, Inc. - OpenGL renderer string: Mesa DRI Voodoo3 20000224 - OpenGL version string: 1.2 Mesa 3.4 - -or this: - - OpenGL vendor string: VA Linux Systems, Inc. - OpenGL renderer string: Mesa GLX Indirect - OpenGL version string: 1.2 Mesa 3.4 - -The first example indicates that the 3dfx driver is using Voodoo3 hardware. -The second example indicates that no hardware driver was found and indirect, -unaccelerated rendering is being used. - -If you see that indirect rendering is being used when direct rendering was -expected, proceed to the troubleshooting section. - -glxinfo also lists all of the GLX-enhanced visuals available so you can -determine which visuals are double-bufferd, have depth (Z) buffers, stencil -buffers, accumulation buffers, etc. - -8.6 Environment Variables - -The libGL.so library recognizes three environment variables. Normally, none -of them need to be defined. If you're using the csh or tcsh shells, type -setenv VARNAME value to set the variable. Otherwise, if you're using sh or -bash, type export VARNAME=value. - - 1. LIBGL_DEBUG, if defined will cause libGL.so to print error and diagnos- - tic messages. This can help to solve problems. Setting LIBGL_DEBUG to - verbose may provide additional information. - - 2. LIBGL_ALWAYS_INDIRECT, if defined this will force libGL.so to always - use indirect rendering instead of hardware acceleration. This can be - useful to isolate rendering errors. - - 3. LIBGL_DRIVERS_PATH can be used to override the default directories - which are searched for 3D drivers. The value is one or more paths sep- - arated by colons. In a typical XFree86 installation, the 3D drivers - should be in /usr/X11R6/lib/modules/dri/ and LIBGL_DRIVERS_PATH need - not be defined. Note that this feature is disabled for set-uid pro- - grams. This variable replaces the LIBGL_DRIVERS_DIR env var used in - XFree86 4.0. - - 4. MESA_DEBUG, if defined, will cause Mesa-based 3D drivers to print user - error messages to stderr. These are errors that you'd otherwise detect - by calling glGetError. - -Mesa-based drivers (this includes most of the drivers listed above) also -observe many of the existing Mesa environment variables. These include the -MESA_DEBUG and MESA_INFO variables. - -9. General Trouble Shooting - -This section contains information to help you diagnose general problems. See -below for additional information for specific hardware. - -9.1 Bus Mastering - -DMA-based DRI drivers (that's most DRI drivers) cannot function unless bus -mastering is enabled for your graphics card. By default, some systems don't -having bus mastering on. You should enable it in your BIOS. - -Alternately, you can check the status of bus mastering and change the setting -from within Linux. There may be similar procedures for other operating sys- -tems. - -Run lspci (as root) and find the information describing your graphics -adapter. For example: - - 00:00.0 Host bridge: Intel Corporation 440BX/ZX - 82443BX/ZX Host bridge (rev 03) - 00:01.0 PCI bridge: Intel Corporation 440BX/ZX - 82443BX/ZX AGP bridge (rev 03) - 00:07.0 ISA bridge: Intel Corporation 82371AB PIIX4 ISA (rev 02) - 00:07.1 IDE interface: Intel Corporation 82371AB PIIX4 IDE (rev 01) - 00:07.2 USB Controller: Intel Corporation 82371AB PIIX4 USB (rev 01) - 00:07.3 Bridge: Intel Corporation 82371AB PIIX4 ACPI (rev 02) - 00:11.0 Ethernet controller: Intel Corporation 82557 [Ethernet Pro 100] (rev 08) - 00:12.0 SCSI storage controller: Symbios Logic Inc. (formerly NCR) 53c895 (rev 02) - 00:14.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 08) - 01:00.0 VGA compatible controller: 3Dfx Interactive, Inc.: Unknown device 0009 (rev 01) - -The bus, device, and function number comprise the device id, which is conven- -tionally written in the form bus:dev.func, or in this case 01:00.0. - -Use the setpci command to examine bit two of register 4 for your graphics -card. This will indicate whether or not bus mastering is enabled. - - setpci -s 01:00.0 4.w - -A hexadecimal value will be printed. Convert the least significant digit to -binary. For example, if you see 3, that's 0011 in binary (bit two is 0). If -you see 7, that's 0111 in binary (bit two is 1). In the first example, bus -mastering is disabled. It's enabled in the second example. - -The following shell script will enabled bus mastering for your graphics card -and host bridge. Run it as root. - - #!/bin/bash - dev=01:00.0 # change as appropriate - echo Enabling bus mastering on device $dev - setpci -s $dev 4.w=$(printf %x $((0x$(setpci -s $dev 4.w)|4))) - dev=00:00.0 - echo Enabling bus mastering on host bridge $dev - setpci -s $dev 4.w=$(printf %x $((0x$(setpci -s $dev 4.w)|4))) - -You can check if this worked by running the first setpci command again. - -9.2 The X Server - - 1. Before you start the X server, verify the appropriate 3D kernel module - is installed. Type lsmod and look for the appropriate kernel module. - For 3dfx hardware you should see tdfx, for example. - - 2. Verify you're running XFree86 4.0 (or newer) and not an older version. - If you run xdpyinfo and look for the following line near the top: - - vendor release number: 4000 - - 3. Verify that your XF86Config file (usually found at /etc/X11/XF86Config) - loads the glx and dri modules and has a DRI section. - - See the Software Resources section below for sample XF86Config files. - - 4. Examine the messages printed during X server startup and check that the - DRM module loaded. Using the Voodoo3 as an example: - - (==) TDFX(0): Write-combining range (0xf0000000,0x2000000) - (II) TDFX(0): Textures Memory 7.93 MB - (0): [drm] created "tdfx" driver at busid "PCI:1:0:0" - (0): [drm] added 4096 byte SAREA at 0xc65dd000 - (0): [drm] mapped SAREA 0xc65dd000 to 0x40013000 - (0): [drm] framebuffer handle = 0xf0000000 - (0): [drm] added 1 reserved context for kernel - (II) TDFX(0): [drm] Registers = 0xfc000000 - (II) TDFX(0): visual configs initialized - (II) TDFX(0): Using XFree86 Acceleration Architecture (XAA) - Screen to screen bit blits - Solid filled rectangles - 8x8 mono pattern filled rectangles - Indirect CPU to Screen color expansion - Solid Lines - Dashed Lines - Offscreen Pixmaps - Driver provided NonTEGlyphRenderer replacement - Setting up tile and stipple cache: - 10 128x128 slots - (==) TDFX(0): Backing store disabled - (==) TDFX(0): Silken mouse enabled - (0): X context handle = 0x00000001 - (0): [drm] installed DRM signal handler - (0): [DRI] installation complete - (II) TDFX(0): direct rendering enabled - - 5. After the X server has started, verify that the required X server - extensions are loaded. Run xdpyinfo and look for the following entries - in the extensions list: - - GLX - SGI-GLX - XFree86-DRI - -9.3 Linking, running and verifying 3D acceleration - -After you've verified that the X server and DRI have started correctly it's -time to verify that the GL library and hardware drivers are working cor- -rectly. - - 1. Verify that you're using the correct libGL.so library with ldd. The - /usr/lib and /usr/X11R6/lib directories are expected locations for - libGL.so. - - Example: - - % ldd /usr/local/bin/glxinfo - libglut.so.3 => /usr/local/lib/libglut.so.3 (0x40019000) - libGLU.so.1 => /usr/local/lib/libGLU.so.1 (0x40051000) - libGL.so.1 => /usr/lib/libGL.so.1 (0x40076000) - libXmu.so.6 => /usr/X11R6/lib/libXmu.so.6 (0x402ee000) - libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x40301000) - libm.so.6 => /lib/libm.so.6 (0x40309000) - libc.so.6 => /lib/libc.so.6 (0x40325000) - libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40419000) - libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x404bd000) - libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x40509000) - libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x40512000) - libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40529000) - libvga.so.1 => /usr/lib/libvga.so.1 (0x40537000) - libpthread.so.0 => /lib/libpthread.so.0 (0x4057d000) - /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) - - 2. You may also double check that libGL.so is in fact DRI-capable. Run - strings libGL.so.1.2 | grep DRI and look for symbols prefixed with - "XF86DRI", such as "XF86DRIQueryExtension". - - 3. To be safe one should run ldconfig after installing libGL.so to be sure - the runtime loader will find the proper library. - - 4. Verify that the appropriate 3D driver is in /usr/X11R6/lib/modules/dri/ - For example, the 3dfx driver will be named tdfx_dri.so. - - 5. Set the LIBGL_DEBUG environment variable. This will cause libGL.so to - print an error message if it fails to load a DRI driver. Any error - message printed should be self-explanatory. - - 6. Run glxinfo. Note the line labeled "OpenGL renderer string". It - should have a value which starts with "Mesa DRI" followed by the name - of your hardware. - - 7. Older Linux OpenGL applications may have been linked against Mesa's GL - library and will not automatically use libGL.so. In some cases, making - symbolic links from the Mesa GL library to libGL.so.1 will solve the - problem: - - ln -s libGL.so.1 libMesaGL.so.3 - - In other cases, the application will have to be relinked against the - new XFree86 libGL.so. - - It is reported that part of the problem is that running ldconfig will - silently rewrite symbolic links based on the SONAME field in libraries. - -If you're still having trouble, look in the next section for information spe- -cific to your graphics card. - -10. Hardware-Specific Information and Troubleshooting - -This section presents hardware-specific information for normal use and trou- -bleshooting. - -10.1 3dfx Banshee, Voodoo3, Voodoo4 and Voodoo5 Series - -10.1.1 Requirements - -The 3dfx DRI driver requires special versions of the 3dfx Glide library. -Different versions of Glide are needed for Banshee/Voodoo3 than for -Voodoo4/5. The Glide libraries can be downloaded from the DRI website. - -10.1.2 Configuration - -Your XF86Config file's device section must specify the tdfx device. For -example: - - Section "Device" - Identifier "Voodoo3" - VendorName "3dfx" - Driver "tdfx" - EndSection - -Or, - - Section "Device" - Identifier "Voodoo5" - VendorName "3dfx" - Driver "tdfx" - EndSection - -The Screen section should then reference the Voodoo device: - - Section "Screen" - Identifier "Screen 1" - Device "Voodoo3" - Monitor "High Res Monitor" - DefaultDepth 16 - Subsection "Display" - Depth 16 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - EndSection - -Or, - - Section "Screen" - Identifier "Screen 1" - Device "Voodoo5" - Monitor "High Res Monitor" - DefaultDepth 24 - Subsection "Display" - Depth 16 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - Subsection "Display" - Depth 24 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - EndSection - -The kernel module for 3dfx hardware is named tdfx.o and should be installed -in /lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically -loaded by the Xserver if needed. - -The DRI 3D driver for 3dfx hardware should be in /usr/X11R6/lib/mod- -ules/dri/tdfx_dri.so. This will be automatically loaded by libGL.so. - -The Voodoo5 supports 3D rendering in 16 and 32 bpp modes. When running in -32bpp mode an 8-bit stencil buffer and 24-bit Z (depth) buffer are offered. -When running in 16bpp mode only a 16-bit Z (depth) buffer is offered and -stencil is implemented in software. - -A software-based accumulation buffer is available in both 16 and 32bpp modes. - -10.1.3 Troubleshooting - - o If you try to run an OpenGL application and see an error message similar - to - - gd error (glide): gd error (glide): grSstSelect: non-existent SSTgd error (glide): grSstSelect: non-existent SSTS - - it means that you have the wrong version of the Glide library for your - hardware. - - o 3D acceleration for Banshee and Voodoo3 is only supported in the 16 - bit/pixel screen mode. Use xdpyinfo to verify that all your visuals are - depth 16. Edit your XF86Config file if needed. - - o The /dev/3dfx device is not used for DRI; it's only for Glide on older - 3dfx hardware. - - o Different versions of Glide are needed for Voodoo3 and Voodoo5. See the - DRI website's resources page to download the right version of Glide. - - o Voodoo4/5 may be run at 24bpp (instead of 32bpp, the default) but 3D - acceleration is not supported in that mode. 32bpp mode is fully 3D - accelerated. - -10.1.4 Performance and Features - - o Normally, buffer swapping in double-buffered applications is synchro- - nized to your monitor's refresh rate. This may be overridden by setting - the FX_GLIDE_SWAPINTERVAL environment variable. The value of this vari- - able indicates the maximum number of swap buffer commands can be - buffered. Zero allows maximum frame rate. - - o On Voodoo4/5, rendering with 16-bits/texel textures is faster than using - 32-bit per texel textures. The internalFormat parameter to glTexImage2D - can be used to control texel size. Quake3 and other games let you con- - trol this as well. - - o The glTexEnv mode GL_BLEND is not directly supported by the Voodoo3 - hardware. It can be accomplished with a multipass algorithm but it's - not implemented at this time. Applications which use that mode, such as - the Performer Town demo, may become sluggish when falling back to soft- - ware rendering to render in that mode. - - o The Voodoo3/Banshee driver reverts to software rendering under the fol- - lowing conditions: - - o Setting GL_LIGHT_MODEL_COLOR_CONTROL to GL_SEPARATE_SPECULAR_COLOR. - - o Enabling line stippling or polygon stippling. - - o Enabling point smoothing or polygon smoothing. - - o Enabling line smoothing when line width is not 1.0. That is, - antialiased lines are done in hardware only when the line width is - 1.0. - - o Using 1-D or 3-D texture maps. - - o Using the GL_BLEND texture environment. - - o Using stencil operations. - - o Using the accumulation buffer. - - o Using glBlendEquation(GL_LOGIC_OP). - - o Using glDrawBuffer(GL_FRONT_AND_BACK). - - o Using glPolygonMode(face, GL_POINT) or glPolygonMode(face, - GL_LINE). - - o Using point size attenuation (i.e. GL_DISTANCE_ATTENUATION_EXT). - - o Using glColorMask(r, g, b, a) when r!=g or g!=b. - - o The Voodoo5 driver reverts to software rendering under the same condi- - tions Voodoo3 with three exceptions. First, stencil operations are - implemented in hardware when the screen is configured for 32 bits/pixel. - Second, the GL_BLEND texture env mode is fully supported in hardware. - Third, glColorMask is fully supported in hardware when the screen is - configured for 32 bits/pixel. - - o As of January, 2001 the second VSA-100 chip on the Voodoo5 is not yet - operational. Therefore, the board isn't being used to its full capac- - ity. The second VSA-100 chip will allow Scan-Line Interleave (SLI) mode - for full-screen applications and games, potentially doubling the sys- - tem's fill rate. When the second VSA-100 chip is activated glGet- - String(GL_RENDERER) will report Voodoo5 instead of Voodoo4. - - o The lowest mipmap level is sometimes miscolored in trilinear- sampled - polygons. - - o The GL_EXT_texture_env_combine extension is supported on the Voodoo4 and - Voodoo5. - -10.1.5 Known Problems - - o The lowest mipmap level is sometimes miscolored in trilinear- sampled - polygons (Voodoo3/Banshee). - - o Fog doesn't work with orthographic projections. - - o The accuracy of blending operations on Voodoo4/5 isn't always very good. - If you run Glean, you'll find some test failures. - - o The Glide library cannot be used directly; it's only meant to be used - via the tdfx DRI driver. - - o SSystem has problems because of poorly set near and far clipping planes. - The office.unc Performer model also suffers from this problem. - -10.2 Intel i810 - -10.2.1 Requirements - -A kernel with AGP GART support (such as Linux 2.4.x) is needed. - -10.2.2 Configuration - -Your XF86Config file's device section must specify the i810 device, and spec- -ify a usable amount of video ram to reserve. - - Section "Device" - Identifier "i810" - VendorName "Intel" - Driver "i810" - Option "AGPMode" "1" - VideoRam 10000 - EndSection - -The Screen section should then reference the i810 device: - - Section "Screen" - Identifier "Screen 1" - Device "i810" - Monitor "High Res Monitor" - DefaultDepth 16 - Subsection "Display" - Depth 16 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - EndSection - -The kernel module for the i810 is named i810.o and should be installed in -/lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically loaded -by the Xserver if needed. - -The DRI 3D driver for the i810 should be in /usr/X11R6/lib/mod- -ules/dri/i810_dri.so. This will be automatically loaded by libGL.so. - -10.2.3 Troubleshooting - - o 3D acceleration for the i810 is only available in the 16 bit/pixel - screen mode at this time. 32bpp acceleration is not supported by this - hardware. Use xdpyinfo to verify that all your visuals are depth 16. - Edit your XF86Config file if needed. - - o The i810 uses system ram for video and 3d graphics. The X server will - ordinarily reserve 4mb of ram for graphics, which is too little for an - effective 3d setup. To tell the driver to use a larger amount, specify - a VideoRam option in the Device section of your XF86Config file. A num- - ber between 10000 and 16384 seems adequate for most requirements. If - too little memory is available for DMA buffers, back and depth buffers - and textures, direct rendering will be disabled. - -10.2.4 Performance and Features - -Basically all of the i810 features which can be exposed through OpenGL 1.2 -are implemented. However, the following OpenGL features are implemented in -software and will be slow: - - o Stencil buffer and accumulation buffer operations - - o Blend subtract, min/max and logic op blend modes - - o glColorMask when any mask is set to false - - o GL_SEPARATE_SPECULAR_COLOR lighting mode - - o glDrawBuffer(GL_FRONT_AND_BACK) - - o Using 1D or 3D textures - - o Using texture borders - -10.3 Matrox G200 and G400 - -10.3.1 Requirements - -A kernel with AGP GART support (such as Linux 2.4.x) is needed. - -10.3.2 Configuration - -Your XF86Config file's device section must specify the mga device: - - Section "Device" - Identifier "MGA" - VendorName "Matrox" - Driver "mga" - Option "AGPMode" "1" - VideoRam 32768 - EndSection - -The Screen section should then reference the MGA device: - - Section "Screen" - Identifier "Screen 1" - Device "MGA" - Monitor "High Res Monitor" - DefaultDepth 16 - Subsection "Display" - Depth 16 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - EndSection - -To use a 32bpp screen mode, use this Screen section instead: - - Section "Screen" - Identifier "Screen 1" - Device "MGA" - Monitor "High Res Monitor" - DefaultDepth 24 - DefaultFbBpp 32 - Subsection "Display" - Depth 24 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - EndSection - -The kernel module for the G200/G400 is named mga.o and should be installed in -/lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically loaded -by the Xserver if needed. - -The DRI 3D driver for the G200/G400 should be in /usr/X11R6/lib/mod- -ules/dri/mga_dri.so. This will be automatically loaded by libGL.so. - -10.3.3 Performance and Features - -Software rendering will be used under any of the following conditions: - - o Using glDrawBuffer(GL_FRONT_AND_BACK). - - o Using point, line, or triangle smoothing. - - o Using glLogicOp. - - o Using glPolygonStipple or glLineStipple. - - o Using 1D or 3D textures. - - o Using texture borders. - - o Using glDepthFunc(GL_NEVER). - - o Using the accumulation buffer. - -The AGP mode may be set to 1, 2, or 4. One is used by default. Higher AGP -speeds may result in unreliable performance depending on your motherboard. - -Compaq has funded the implementation of AGP accelerated ReadPixels and Draw- -Pixels in this driver. With this implementation, on a G400 drawing directly -from AGP memory (exported to the client), throughput of up to 1 GB/sec has -been measured. - -Additionally Compaq's funding has produced several new extensions in Mesa, -including one (packed_depth_stencil_MESA) which enables Read/DrawPixels func- -tionality to operate directly on the packed 24/8 depth/stencil buffers of -this hardware. - -In order to access this functionality, the application must ensure that all -pixel processing operations are disabled. There are in addition a fairly -complex set of rules regarding which packing/unpacking modes must be used, -and which data formats are supported, and alignment constraints. See the -files in lib/GL/mesa/src/drv/mga/DOCS for a summary of these. The extension -definitions are included in the Mesa 3.4 source distribution. - -10.3.4 IRQ Assignment - -There have been problems in the past with the MGA driver being very sluggish -when the DRI is enabled (to the point of being unusable.) This is caused by -the graphics card not having an interrupt assigned to it. The current DRI -trunk will attempt to detect this condition and bail out gracefully. - -The solution to the above problem is to assign an interrupt to your graphics -card. This is something you must turn on in your system BIOS configuration. -Please consult your system BIOS manual for instructions on how to enable an -interrupt for your graphics card. - -10.3.5 MGA HAL lib - -MGAHALlib.a is a binary library Matrox has provided for use under Linux to -expose functionality for which they can not provide documentation. (For -example TV-Out requires MacroVision be enabled on the output.) This binary -library also sets the pixel/memory clocks to the optimal settings for your -Matrox card. - -Currently the MGAHAL library is required for the G450 to work. You can down- -load this from the driver section on Matrox's website: www.matrox.com/mga - -Here modifications to the DRI build instructions which make the mga ddx -driver use the MGAHAL library: - - 1.Put the following define in your host.def file - #define UseMatroxHal YES - 2. Place mgaHALlib.a in the following directory - xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/ - -You can use DualHead on the G400/G450 DH cards by creating two device sec- -tions which both point to the same BusID. For most AGP devices the BusID -will be "PCI:1:0:0". Configure your screen section as you would normally -configure XFree86 4.x Multihead. It should be noted that currently the sec- -ond head does not support direct rendering. - -10.3.6 Known Problems - -None. - -10.4 ATI Rage 128 - -10.4.1 Requirements - -A kernel with AGP GART support (such as Linux 2.4.x) is needed. - -10.4.2 Configuration - -Your XF86Config file's device section must specify the ati device: - - Section "Device" - Identifier "Rage128" - VendorName "ATI" - Driver "ati" - Option "AGPMode" "1" - Option "UseCCEFor2D" "false" - EndSection - -The Screen section should then reference the Rage 128 device: - - Section "Screen" - Identifier "Screen 1" - Device "Rage128" - Monitor "High Res Monitor" - DefaultDepth 16 - Subsection "Display" - Depth 16 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - Subsection "Display" - Depth 32 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - EndSection - -The kernel module for the Rage 128 is named r128.o and should be installed in -/lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically loaded -by the Xserver if needed. - -The DRI 3D driver for the Rage 128 should be in /usr/X11R6/lib/mod- -ules/dri/r128_dri.so. This will be automatically loaded by libGL.so. - -You may also set your screen depth to 32 for 32bpp mode. - -10.4.3 Performance and Features - -While PCI Rage 128 based cards are supported, they do not yet support PCI -GART, so they will not perform as well as their AGP counterparts. - -For AGP cards, the AGP mode may be set to 1, 2, or 4. One is used by -default. Higher AGP speeds may result in unreliable performance depending on -your motherboard. - -Note that even at 32bpp there is no alpha channel. - -The following OpenGL features are implemented in software and will be slow: - - o accumulation buffer operations - - o stencil, when using a 16bpp screen - - o Blend subtract, min/max and logic op blend modes - - o GL_SEPARATE_SPECULAR_COLOR lighting mode - - o glDrawBuffer(GL_FRONT_AND_BACK) - - o Using 1D or 3D textures - - o Using texture borders - -10.4.4 Known Problems - -If you experience stability problems you may try setting the UseCCEFor2D -option to true. This will effectively disable 2D hardware acceleration. -Performance will be degraded, of course. - -10.5 ATI Radeon - -10.5.1 Requirements - -A kernel with AGP GART support (such as Linux 2.4.x) is needed. - -10.5.2 Configuration - -Your XF86Config file's device section must specify the ati device: - - Section "Device" - Identifier "Radeon" - VendorName "ATI" - Driver "ati" - Option "AGPMode" "1" - EndSection - -The Screen section should then reference the Radeon device: - - Section "Screen" - Identifier "Screen 1" - Device "Radeon" - Monitor "High Res Monitor" - DefaultDepth 16 - Subsection "Display" - Depth 16 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - Subsection "Display" - Depth 32 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - EndSection - -The kernel module for the Radeon is named radeon.o and should be installed in -/lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically loaded -by the Xserver if needed. - -The DRI 3D driver for the Radeon should be in /usr/X11R6/lib/mod- -ules/dri/radeon_dri.so. This will be automatically loaded by libGL.so. - -You may also set your screen depth to 32 for 32bpp mode. - -10.5.3 Performance and Features - -While this driver supports many of the features of ATI Radeon cards, we do -not yet fully support the card's TCL features. This work is progressing, but -is not yet ready. - -The AGP mode may be set to 1, 2, or 4. One is used by default. Higher AGP -speeds may result in unreliable performance depending on your motherboard. - -The following OpenGL features are implemented in software and will be slow: - - o Blend subtract, blend min/max and blend logicops - - o Stencil and accumulation operations - - o 1D and 3D textures - - o Texture borders - -The GL_EXT_texture_env_combine, GL_EXT_texture_env_add and GL_EXT_tex- -ture_env_dot3 extensions are supported (or will be soon supported in the new -driver based on Mesa 3.5). - -We hope to implement support for the following features in the future: - - o Vertex transformation, clipping and lighting (TCL) - - o Hardware stencil buffer - - o Cube map textures - - o 3D textures - - o Three texture units - -10.5.4 Known Problems - -Certain (early?) revisions of the AMD Irongate chipset have AGPGART problems -which effect Radeon, and other graphics cards. The card may work unreliably, -or not work at all. If the DRM kernel module is not loaded, the 2D Xserver -may work. There's hope that this can be fixed in the future. - -10.6 3DLabs Oxygen GMX 2000 - -The driver for this hardware was experimental and is no longer being devel- -oped or supported. - -11. General Limitations and Known Bugs - -11.1 OpenGL - -The following OpenGL features are not supported at this time: overlays, -stereo, hardware-accelerated indirect rendering. - -OpenGL-like functionality is provided with the Mesa library. XFree86 4.1.0 -uses Mesa 3.4.2. Subsequent releases of XFree86 will use newer versions of -Mesa. When newer versions of Mesa are available, the 3D drivers can be -updated without reinstalling XFree86 or libGL.so. - -11.2 GLX - -The GLX 1.3 API is exported but none of the new 1.3 functions are opera- -tional. - -The new glXGetProcAddressARB function is fully supported. - -GLXPixmap rendering is only supported for indirect rendering contexts. This -is a common OpenGL limitation. Attempting to use a direct rendering context -with a GLXPixmap will result in an X protocol error. - -11.3 Debugging - -Debugging DRI drivers with gdb can be difficult because of the locking -involved. When debugging OpenGL applications, you should avoid stepping -inside the GL functions. If you're trying to debug a DRI driver it's recom- -mended that you do so remotely, from a second system. - -11.4 Scheduling - -When you run multiple GL applications at once you may notice poor time slic- -ing. This is due to an interaction problem with the Linux scheduler which -will be addressed in the future. - -11.5 libGL.so and dlopen() - -A number of popular OpenGL applications on Linux (such as Quake3, HereticII, -Heavy Gear 2, etc) dynamically open the libGL.so library at runtime with -dlopen(), rather than linking with -lGL at compile/link time. - -If dynamic loading of libGL.so is not implemented carefully, there can be a -number of serious problems. Here are the things to be careful of in your -application: - - o Specify the RTLD_GLOBAL flag to dlopen(). If you don't do this then - you'll likely see a runtime error message complaining that _glapi_Con- - text is undefined when libGL.so tries to open a hardware-specific - driver. Without this flag, nested opening of dynamic libraries does not - work. - - o Do not close the library with dlclose() until after XCloseDisplay() has - been called. When libGL.so initializes itself it registers several - callbacks functions with Xlib. When XCloseDisplay() is called those - callback functions are called. If libGL.so has already been unloaded - with dlclose() this will cause a segmentation fault. - - o Your application should link with -lpthread. On Linux, libGL.so uses - the pthreads library in order to provide thread safety. There is appar- - ently a bug in the dlopen()/dlclose() code which causes crashes if the - library uses pthreads but the parent application doesn't. The only - known work-around is to link the application with -lpthread. - -Some applications don't yet incorporate these procedures and may fail. For -example, changing the graphics settings in some video games will expose this -problem. The DRI developers are working with game vendors to prevent this -problem in the future. - -11.6 Bug Database - -The DRI bug database which includes bugs related to specific drivers is at -the SourceForge DRI Bug Database - -Please scan both the open and closed bug lists to determine if your problem -has already been reported and perhaps fixed. - -12. Resources - -12.1 Software - -A collection of useful configuration files, libraries, headers, utilities and -demo programs is available from http://dri.sourceforge.net/res.phtml - -12.2 Documentation - - o General OpenGL information is available at the OpenGL Home Page - - o XFree86 information is available at the XFree86 Home Page - - o Information about the design of the DRI is available from Precision - Insight, Inc. - - o Visit the DRI project on SourceForge.net for the latest development news - about the DRI and 3D drivers. - - o The DRI Compilation Guide explains how to download, compile and install - the DRI for yourself. - -12.3 Support - - o The DRI-users mailing list at SourceForge is a forum for people to dis- - cuss DRI problems. - - o In the future there may be IHV and Linux vendor support resources for - the DRI. - - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.28 dawes Exp $ - - diff --git a/xorg-server/hw/xfree86/doc/README.rapidaccess b/xorg-server/hw/xfree86/doc/README.rapidaccess deleted file mode 100644 index 39f515ee2..000000000 --- a/xorg-server/hw/xfree86/doc/README.rapidaccess +++ /dev/null @@ -1,48 +0,0 @@ -The IBM Rapid Access keyboard have some extra buttons -on it to launch programs, control a cd-player and so on. - -These buttons is not functional when the computer is turned -on but have to be activated by sending the codes 0xea 0x71 -to it. - -I've written the following hack to send codes to the keyboard: - --------------------------------------------------------------- -/* gcc -O2 -s -Wall -osend_to_keyboard send_to_keyboard.c */ -#include -#include -#include - -int main( int argc, char *argv[] ) -{ - int i; - - ioperm( 0x60, 3, 1 ); - - for( i = 1; i < argc; i++ ) { - int x = strtol( argv[i], 0, 16 ); - - usleep( 300 ); - outb( x, 0x60 ); - } - - return 0; -} --------------------------------------------------------------- - -As root you can then call this program (in your boot scripts) -as "send_to_keyboard ea 71" to turn on the extra buttons. - -It's not a good idea to run several instances of this program -at the same time. It is a hack but it works. If you try to -send other codes to the keyboard it probably will lock up. -For other codes see: - -http://www.win.tue.nl/~aeb/linux/kbd/scancodes-2.html#ss2.22 - --- -Dennis Björklund - - - -$XFree86$ diff --git a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre index 2eb52ae4d..bf1adc4e8 100644 --- a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre +++ b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre @@ -2342,8 +2342,7 @@ section for a dual headed configuration with two mice: .SH "DRI SECTION" This optional section is used to provide some information for the Direct Rendering Infrastructure. -Details about the format of this section -can be found in the README.DRI document, which is also available on-line at +Details about the format of this section can be found on-line at .IR . .SH "VENDOR SECTION" The optional diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c index 417a75ff6..5705d7da3 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.c +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c @@ -46,6 +46,8 @@ #include "xf86xv.h" +#define NO_OUTPUT_DEFAULT_WIDTH 1024 +#define NO_OUTPUT_DEFAULT_HEIGHT 768 /* * Initialize xf86CrtcConfig structure */ @@ -1923,7 +1925,7 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn) #endif } -static void +static Bool xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, Bool *enabled) { @@ -1938,8 +1940,10 @@ xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, "No outputs definitely connected, trying again...\n"); for (o = 0; o < config->num_output; o++) - enabled[o] = xf86OutputEnabled(config->output[o], FALSE); + any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], FALSE); } + + return any_enabled; } static Bool @@ -2339,6 +2343,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) Bool *enabled; int width, height; int i = scrn->scrnIndex; + Bool have_outputs = TRUE; + Bool ret; /* Set up the device options */ config->options = xnfalloc (sizeof (xf86DeviceOptions)); @@ -2364,18 +2370,23 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) modes = xnfcalloc (config->num_output, sizeof (DisplayModePtr)); enabled = xnfcalloc (config->num_output, sizeof (Bool)); - xf86CollectEnabledOutputs(scrn, config, enabled); - - if (xf86TargetUserpref(scrn, config, modes, enabled, width, height)) - xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n"); - else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height)) - xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n"); - else if (xf86TargetAspect(scrn, config, modes, enabled, width, height)) - xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n"); - else if (xf86TargetFallback(scrn, config, modes, enabled, width, height)) - xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n"); - else - xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n"); + ret = xf86CollectEnabledOutputs(scrn, config, enabled); + if (ret == FALSE && canGrow) { + xf86DrvMsg(i, X_WARNING, "Unable to find connected outputs - setting %dx%d initial framebuffer\n", + NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT); + have_outputs = FALSE; + } else { + if (xf86TargetUserpref(scrn, config, modes, enabled, width, height)) + xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n"); + else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height)) + xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n"); + else if (xf86TargetAspect(scrn, config, modes, enabled, width, height)) + xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n"); + else if (xf86TargetFallback(scrn, config, modes, enabled, width, height)) + xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n"); + else + xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n"); + } for (o = -1; nextEnabledOutput(config, enabled, &o); ) { if (!modes[o]) @@ -2406,7 +2417,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) /* * Assign CRTCs to fit output configuration */ - if (!xf86PickCrtcs (scrn, crtcs, modes, 0, width, height)) + if (have_outputs && !xf86PickCrtcs (scrn, crtcs, modes, 0, width, height)) { free(crtcs); free(modes); @@ -2468,6 +2479,13 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) */ xf86DefaultScreenLimits (scrn, &width, &height, canGrow); + if (have_outputs == FALSE) { + if (width < NO_OUTPUT_DEFAULT_WIDTH && height < NO_OUTPUT_DEFAULT_HEIGHT) { + width = NO_OUTPUT_DEFAULT_WIDTH; + height = NO_OUTPUT_DEFAULT_HEIGHT; + } + } + scrn->display->virtualX = width; scrn->display->virtualY = height; } @@ -2493,8 +2511,17 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) width, height); } - /* Mirror output modes to scrn mode list */ - xf86SetScrnInfoModes (scrn); + if (have_outputs) { + /* Mirror output modes to scrn mode list */ + xf86SetScrnInfoModes (scrn); + } else { + /* Clear any existing modes from scrn->modes */ + while (scrn->modes != NULL) + xf86DeleteMode(&scrn->modes, scrn->modes); + scrn->modes = xf86ModesAdd(scrn->modes, + xf86CVTMode(width, height, 60, 0, 0)); + } + free(crtcs); free(modes); diff --git a/xorg-server/hw/xfree86/os-support/bus/Pci.c b/xorg-server/hw/xfree86/os-support/bus/Pci.c index b7fa25f71..7151cc885 100644 --- a/xorg-server/hw/xfree86/os-support/bus/Pci.c +++ b/xorg-server/hw/xfree86/os-support/bus/Pci.c @@ -1,158 +1,157 @@ -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - * Copyright 1998 by Metro Link Incorporated - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - * This software is derived from the original XFree86 PCI code - * which includes the following copyright notices as well: - * - * Copyright 1995 by Robin Cutshaw - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of the above listed copyright holder(s) - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. The above listed - * copyright holder(s) make(s) no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * This code is also based heavily on the code in FreeBSD-current, which was - * written by Wolfgang Stanglmeier, and contains the following copyright: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/* - * Copyright (c) 1999-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). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include -#include -#include -#include "compiler.h" -#include "xf86.h" -#include "xf86Priv.h" -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" -#include "Pci.h" - -#include - -/* Global data */ - -PCITAG -pciTag(int busnum, int devnum, int funcnum) -{ - return(PCI_MAKE_TAG(busnum,devnum,funcnum)); -} - -Bool -xf86scanpci(void) -{ - Bool success = FALSE; - - success = (pci_system_init() == 0); - - /* choose correct platform/OS specific PCI init routine */ - ARCH_PCI_INIT(); - - return success; -} +/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * This software is derived from the original XFree86 PCI code + * which includes the following copyright notices as well: + * + * Copyright 1995 by Robin Cutshaw + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holder(s) + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holder(s) make(s) no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * This code is also based heavily on the code in FreeBSD-current, which was + * written by Wolfgang Stanglmeier, and contains the following copyright: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/* + * Copyright (c) 1999-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). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include "compiler.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "Pci.h" + +#include + +/* Global data */ + +PCITAG +pciTag(int busnum, int devnum, int funcnum) +{ + return(PCI_MAKE_TAG(busnum,devnum,funcnum)); +} + +Bool +xf86scanpci(void) +{ + Bool success = FALSE; + + success = (pci_system_init() == 0); + + /* choose correct platform/OS specific PCI init routine */ + ARCH_PCI_INIT(); + + return success; +} diff --git a/xorg-server/hw/xfree86/os-support/bus/Pci.h b/xorg-server/hw/xfree86/os-support/bus/Pci.h index b52a6cfae..618dd3783 100644 --- a/xorg-server/hw/xfree86/os-support/bus/Pci.h +++ b/xorg-server/hw/xfree86/os-support/bus/Pci.h @@ -1,169 +1,161 @@ -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - * Copyright 1998 by Metro Link Incorporated - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - * This file is derived in part from the original xf86_PCI.h that included - * following copyright message: - * - * Copyright 1995 by Robin Cutshaw - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of the above listed copyright holder(s) - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. The above listed - * copyright holder(s) make(s) no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ -/* - * Copyright (c) 1999-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 has the private Pci definitions. The public ones are imported - * from xf86Pci.h. Drivers should not use this file. - */ -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#ifndef _PCI_H -#define _PCI_H 1 - -#include -#include -#include "xf86Pci.h" -#include "xf86PciInfo.h" - -/* - * Global Definitions - */ -#if (defined(__alpha__) || defined(__ia64__)) && defined (linux) -#define PCI_DOM_MASK 0x01fful -#else -#define PCI_DOM_MASK 0x0ffu -#endif - -#define DEVID(vendor, device) \ - ((CARD32)((PCI_##device << 16) | PCI_##vendor)) - -#ifndef PCI_DOM_MASK -# define PCI_DOM_MASK 0x0ffu -#endif -#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) - -/* - * "b" contains an optional domain number. - */ -#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ - (((d) & 0x00001fu) << 11) | \ - (((f) & 0x000007u) << 8)) - -#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu)) - -#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK)) -#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) -#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) -#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) - -#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) -#define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u) - -#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK)) -#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu) -#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u) - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ - defined(__OpenBSD__) || defined(__NetBSD__) || \ - defined(__DragonFly__) || defined(__sun) || defined(__GNU__) -#define ARCH_PCI_INIT bsdPciInit -#endif - -#if defined(linux) -#define ARCH_PCI_INIT linuxPciInit -#endif /* defined(linux) */ - -#ifndef ARCH_PCI_INIT -#error No PCI support available for this architecture/OS combination -#endif - -extern void ARCH_PCI_INIT(void); - -#endif /* _PCI_H */ +/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * This file is derived in part from the original xf86_PCI.h that included + * following copyright message: + * + * Copyright 1995 by Robin Cutshaw + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holder(s) + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holder(s) make(s) no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 1999-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 has the private Pci definitions. The public ones are imported + * from xf86Pci.h. Drivers should not use this file. + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef _PCI_H +#define _PCI_H 1 + +#include "xf86Pci.h" +#include "xf86PciInfo.h" + +/* + * Global Definitions + */ +#if (defined(__alpha__) || defined(__ia64__)) && defined (linux) +#define PCI_DOM_MASK 0x01fful +#else +#define PCI_DOM_MASK 0x0ffu +#endif + +#ifndef PCI_DOM_MASK +# define PCI_DOM_MASK 0x0ffu +#endif +#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) + +/* + * "b" contains an optional domain number. + */ +#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ + (((d) & 0x00001fu) << 11) | \ + (((f) & 0x000007u) << 8)) + +#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu)) + +#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK)) +#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) +#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) +#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) + +#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK)) +#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu) +#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u) + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__OpenBSD__) || defined(__NetBSD__) || \ + defined(__DragonFly__) || defined(__sun) || defined(__GNU__) +#define ARCH_PCI_INIT bsdPciInit +#endif + +#if defined(linux) +#define ARCH_PCI_INIT linuxPciInit +#endif /* defined(linux) */ + +#ifndef ARCH_PCI_INIT +#error No PCI support available for this architecture/OS combination +#endif + +extern void ARCH_PCI_INIT(void); + +#endif /* _PCI_H */ diff --git a/xorg-server/hw/xfree86/vbe/vbe.c b/xorg-server/hw/xfree86/vbe/vbe.c index bb88b86cf..21fe0c812 100644 --- a/xorg-server/hw/xfree86/vbe/vbe.c +++ b/xorg-server/hw/xfree86/vbe/vbe.c @@ -17,7 +17,6 @@ #include "xf86.h" #include "vbe.h" -#include #include #define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x) diff --git a/xorg-server/hw/xfree86/vbe/vbe.h b/xorg-server/hw/xfree86/vbe/vbe.h index 4786709ea..5bb163df8 100644 --- a/xorg-server/hw/xfree86/vbe/vbe.h +++ b/xorg-server/hw/xfree86/vbe/vbe.h @@ -65,7 +65,7 @@ typedef struct vbeControllerInfoBlock { #pragma pack(0) #endif -#ifndef __GNUC__ +#if !( defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) ) #define __attribute__(a) #endif -- cgit v1.2.3