* Michel Dänzer ([EMAIL PROTECTED]) [030828 14:19]: > The X server knows which PCI devices are in use by its drivers, couldn't > this be just a boolean option to only deal with those? >
yes. here is a revised patch by Aivils Stoss <[EMAIL PROTECTED]> doing just that: now it is possible to use either the "SingleCard" option, when a given Xserver only is supposed to use one card, Section "ServerLayout" Identifier "Anaconda Configured" Screen 0 "Screen0" 0 0 InputDevice "Mouse0" "CorePointer" InputDevice "Mouse1" "SendCoreEvents" InputDevice "Keyboard0" "CoreKeyboard" Option "SingleCard" "true" EndSection or if you use xinerama, and the xserver has several cards, one can say: Section "ServerLayout" Identifier "Anaconda Configured" Screen 0 "Screen0" 0 0 InputDevice "Mouse0" "CorePointer" InputDevice "Mouse1" "SendCoreEvents" InputDevice "Keyboard0" "CoreKeyboard" Option "PrefBusID" "1:0:0" EndSection with a list of PrefBusIDs. (No one has tested xinerama yet!) this works also instead of SingleCard. Branden wondered what happend if a given busid, specified by PrefBusID, was not found or wrong or so: Since the ServerLayout is loaded from XF86Config before any device tests are performed we can not protect against misconfiguration. 1) Option "PrefBusID" "1:0:0" good - all runs. bad - the server would report "no devices" syntax error - ignored 2) Option "SingleCard" "true" (The BusID option in the Device section is needed.) Wrong BusID option in Device section - server report no devices. No BusID option in Device section - ignored. syntax error - ignored. 3) both Layout options. Primary is "PrefBusID". "SingleCard" ignored. Works as 1). Users can verify that the patch works as expected by looking for the line "Preferred PCI BusID set to \"%d:%d:%d\"". in XFree86.0.log. (or other logfiles) If that exists, the layout options are active. diff -Nurp xc/programs/Xserver/hw/xfree86/common/xf86Config.c xc-changed/programs/Xserver/hw/xfree86/common/xf86Config.c --- xc/programs/Xserver/hw/xfree86/common/xf86Config.c 2003-02-20 04:36:07.000000000 +0000 +++ xc-changed/programs/Xserver/hw/xfree86/common/xf86Config.c 2003-09-08 17:48:10.000000000 +0100 @@ -1416,6 +1416,20 @@ checkCoreInputDevices(serverLayoutPtr se return TRUE; } +typedef enum { + LAYOUT_PREFERREDBUSID, + LAYOUT_SINGLECARD +} LayoutValues; + +static OptionInfoRec LayoutOptions[] = { + { LAYOUT_PREFERREDBUSID, "PrefBusID", OPTV_STRING, + {0}, FALSE }, + { LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN, + {0}, FALSE }, + { -1, NULL, OPTV_NONE, + {0}, FALSE }, +}; + /* * figure out which layout is active, which screens are used in that layout, * which drivers and monitors are used in these screens @@ -2213,6 +2227,8 @@ xf86HandleConfigFile(void) const char *filename; char *searchpath; MessageType from = X_DEFAULT; + char *scanptr; + Bool singlecard = 0; if (getuid() == 0) searchpath = ROOT_CONFIGPATH; @@ -2283,6 +2299,28 @@ xf86HandleConfigFile(void) } } + xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions); + + if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_PREFERREDBUSID))) { + ; /* PrefBusID is primary */ + } + else { + xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard); + if (singlecard) scanptr = xf86ConfigLayout.screens->screen->device->busID; + } + if (scanptr) { + int bus, device, func, stroffset = 0; + if (tolower(scanptr[0]) == 'p' && strlen(scanptr) >= 4) stroffset = 4; + if (sscanf(scanptr + stroffset, "%d:%d:%d", &bus, &device, &func) == 3) { + xf86PrefBusId.bus = bus; + xf86PrefBusId.device = device; + xf86PrefBusId.func = func; + xf86Msg(X_INFO, + "Preferred PCI BusID set to \"%d:%d:%d\"\n",bus,device,func); + } + } + + /* Now process everything else */ if (!configFiles(xf86configptr->conf_files) || diff -Nurp xc/programs/Xserver/hw/xfree86/common/xf86Globals.c xc-changed/programs/Xserver/hw/xfree86/common/xf86Globals.c --- xc/programs/Xserver/hw/xfree86/common/xf86Globals.c 2003-02-20 04:05:14.000000000 +0000 +++ xc-changed/programs/Xserver/hw/xfree86/common/xf86Globals.c 2003-04-02 13:03:00.000000000 +0100 @@ -215,6 +215,7 @@ Bool xf86MiscModInDevAllowNonLocal = FAL #endif PropertyPtr *xf86RegisteredPropertiesTable = NULL; Bool xf86inSuspend = FALSE; +PciBusId xf86PrefBusId; #ifdef DLOPEN_HACK /* diff -Nurp xc/programs/Xserver/hw/xfree86/common/xf86Init.c xc-changed/programs/Xserver/hw/xfree86/common/xf86Init.c --- xc/programs/Xserver/hw/xfree86/common/xf86Init.c 2003-02-26 09:21:38.000000000 +0000 +++ xc-changed/programs/Xserver/hw/xfree86/common/xf86Init.c 2003-08-26 14:55:22.000000000 +0100 @@ -1553,6 +1553,22 @@ ddxProcessArgument(int argc, char **argv xf86AllowMouseOpenFail = TRUE; return 1; } + if (!strcmp(argv[i], "-prefbusid")) + { + int bus, device, func; + if (++i >= argc) + return 0; + if (sscanf(argv[i], "%d:%d:%d", &bus, &device, &func) == 3) { + xf86PrefBusId.bus = bus; + xf86PrefBusId.device = device; + xf86PrefBusId.func = func; + return 2; + } + else { + ErrorF("Invalid preferred PCI BusId\n"); + return 0; + } + } /* OS-specific processing */ return xf86ProcessArgument(argc, argv, i); } diff -Nurp xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c xc-changed/programs/Xserver/hw/xfree86/common/xf86pciBus.c --- xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c 2003-02-18 15:42:11.000000000 +0000 +++ xc-changed/programs/Xserver/hw/xfree86/common/xf86pciBus.c 2003-04-02 13:03:00.000000000 +0100 @@ -160,7 +160,10 @@ FindPCIVideoInfo(void) int num = 0; pciVideoPtr info; Bool mem64 = FALSE; + int DoPrefBusIdCheck = 0; + if( xf86PrefBusId.bus || xf86PrefBusId.device || xf86PrefBusId.func ) + DoPrefBusIdCheck = 1; pcrpp = xf86PciInfo = xf86scanpci(0); getPciClassFlags(pcrpp); @@ -182,7 +185,11 @@ FindPCIVideoInfo(void) subclass = pcrp->pci_sub_class; } - if (PCIINFOCLASSES(baseclass, subclass)) { + if (PCIINFOCLASSES(baseclass, subclass) && + (DoPrefBusIdCheck ? + (xf86PrefBusId.bus == pcrp->busnum && + xf86PrefBusId.device == pcrp->devnum && + xf86PrefBusId.func == pcrp->funcnum):1)) { num++; xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo, sizeof(pciVideoPtr) * (num + 1)); diff -Nurp xc/programs/Xserver/hw/xfree86/common/xf86Priv.h xc-changed/programs/Xserver/hw/xfree86/common/xf86Priv.h --- xc/programs/Xserver/hw/xfree86/common/xf86Priv.h 2002-12-12 18:29:10.000000000 +0000 +++ xc-changed/programs/Xserver/hw/xfree86/common/xf86Priv.h 2003-04-02 13:03:00.000000000 +0100 @@ -53,6 +53,7 @@ extern Bool xf86BestRefresh; extern Gamma xf86Gamma; extern char *xf86ServerName; extern Bool xf86ShowUnresolved; +extern PciBusId xf86PrefBusId; /* Other parameters */