2003-11-14 17:48:57 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales.
|
|
|
|
*
|
|
|
|
* 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 Alan Hourihane not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
* specific, written prior permission. Alan Hourihane makes no representations
|
|
|
|
* about the suitability of this software for any purpose. It is provided
|
|
|
|
* "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL ALAN HOURIHANE 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.
|
|
|
|
*
|
|
|
|
* Author: Alan Hourihane, alanh@fairlite.demon.co.uk
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86Config.h"
|
2005-01-28 17:13:00 +01:00
|
|
|
#include "xf86_OSlib.h"
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "xf86Priv.h"
|
|
|
|
#define IN_XSERVER
|
|
|
|
#include "Configint.h"
|
|
|
|
#include "xf86DDC.h"
|
2006-12-04 22:36:30 +01:00
|
|
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "xf86Bus.h"
|
|
|
|
#include "xf86Sbus.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct _DevToConfig {
|
|
|
|
GDevRec GDev;
|
2006-06-07 23:09:02 +02:00
|
|
|
struct pci_device * pVideo;
|
2006-12-04 22:36:30 +01:00
|
|
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
2003-11-14 17:48:57 +01:00
|
|
|
sbusDevicePtr sVideo;
|
|
|
|
#endif
|
|
|
|
int iDriver;
|
|
|
|
} DevToConfigRec, *DevToConfigPtr;
|
|
|
|
|
|
|
|
static DevToConfigPtr DevToConfig = NULL;
|
|
|
|
static int nDevToConfig = 0, CurrentDriver;
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
xf86MonPtr ConfiguredMonitor;
|
|
|
|
Bool xf86DoConfigurePass1 = TRUE;
|
2007-03-25 18:27:01 +02:00
|
|
|
static Bool foundMouse = FALSE;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-06-29 00:59:05 +02:00
|
|
|
#if defined(__SCO__)
|
2003-11-14 17:48:57 +01:00
|
|
|
static char *DFLT_MOUSE_PROTO = "OSMouse";
|
2005-11-08 07:33:30 +01:00
|
|
|
#elif defined(__UNIXWARE__)
|
2006-08-12 19:39:08 +02:00
|
|
|
static char *DFLT_MOUSE_PROTO = "OSMouse";
|
2005-11-08 07:33:30 +01:00
|
|
|
static char *DFLT_MOUSE_DEV = "/dev/mouse";
|
2006-03-10 02:34:45 +01:00
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
|
2003-11-14 17:48:57 +01:00
|
|
|
static char *DFLT_MOUSE_DEV = "/dev/sysmouse";
|
|
|
|
static char *DFLT_MOUSE_PROTO = "auto";
|
2006-08-17 22:22:07 +02:00
|
|
|
#elif defined(linux)
|
|
|
|
static char DFLT_MOUSE_DEV[] = "/dev/input/mice";
|
|
|
|
static char DFLT_MOUSE_PROTO[] = "auto";
|
2003-11-14 17:48:57 +01:00
|
|
|
#else
|
|
|
|
static char *DFLT_MOUSE_DEV = "/dev/mouse";
|
|
|
|
static char *DFLT_MOUSE_PROTO = "auto";
|
|
|
|
#endif
|
|
|
|
|
2009-08-18 11:14:27 +02:00
|
|
|
static Bool
|
|
|
|
bus_pci_configure(void *busData)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2009-08-18 11:14:27 +02:00
|
|
|
int i;
|
2006-06-07 23:09:02 +02:00
|
|
|
struct pci_device * pVideo = NULL;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2006-06-07 23:09:02 +02:00
|
|
|
pVideo = (struct pci_device *) busData;
|
2003-11-14 17:48:57 +01:00
|
|
|
for (i = 0; i < nDevToConfig; i++)
|
|
|
|
if (DevToConfig[i].pVideo &&
|
2006-06-07 23:09:02 +02:00
|
|
|
(DevToConfig[i].pVideo->domain == pVideo->domain) &&
|
2003-11-14 17:48:57 +01:00
|
|
|
(DevToConfig[i].pVideo->bus == pVideo->bus) &&
|
2006-06-07 23:09:02 +02:00
|
|
|
(DevToConfig[i].pVideo->dev == pVideo->dev) &&
|
2003-11-14 17:48:57 +01:00
|
|
|
(DevToConfig[i].pVideo->func == pVideo->func))
|
2009-08-18 11:14:27 +02:00
|
|
|
return 0;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:14:27 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:14:27 +02:00
|
|
|
static Bool
|
|
|
|
bus_sbus_configure(void *busData)
|
|
|
|
{
|
|
|
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
|
|
|
int i;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:14:27 +02:00
|
|
|
for (i = 0; i < nDevToConfig; i++)
|
|
|
|
if (DevToConfig[i].sVideo &&
|
|
|
|
DevToConfig[i].sVideo->fbNum == ((sbusDevicePtr) busData)->fbNum)
|
|
|
|
return 0;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:14:27 +02:00
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:14:27 +02:00
|
|
|
static void
|
|
|
|
bus_pci_newdev_configure(void *busData, int i, int *chipset)
|
|
|
|
{
|
2003-11-14 17:48:57 +01:00
|
|
|
const char *VendorName;
|
|
|
|
const char *CardName;
|
|
|
|
char busnum[8];
|
2009-08-18 11:14:27 +02:00
|
|
|
struct pci_device * pVideo = NULL;
|
|
|
|
|
|
|
|
pVideo = (struct pci_device *) busData;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].pVideo = pVideo;
|
2006-06-07 23:09:02 +02:00
|
|
|
|
|
|
|
VendorName = pci_device_get_vendor_name( pVideo );
|
|
|
|
CardName = pci_device_get_device_name( pVideo );
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (!VendorName) {
|
|
|
|
VendorName = xnfalloc(15);
|
|
|
|
sprintf((char*)VendorName, "Unknown Vendor");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CardName) {
|
|
|
|
CardName = xnfalloc(14);
|
|
|
|
sprintf((char*)CardName, "Unknown Board");
|
|
|
|
}
|
|
|
|
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].GDev.identifier =
|
2003-11-14 17:48:57 +01:00
|
|
|
xnfalloc(strlen(VendorName) + strlen(CardName) + 2);
|
2009-08-18 11:53:47 +02:00
|
|
|
sprintf(DevToConfig[i].GDev.identifier, "%s %s", VendorName, CardName);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].GDev.vendor = (char *)VendorName;
|
|
|
|
DevToConfig[i].GDev.board = (char *)CardName;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].GDev.busID = xnfalloc(16);
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86FormatPciBusNumber(pVideo->bus, busnum);
|
2009-08-18 11:53:47 +02:00
|
|
|
sprintf(DevToConfig[i].GDev.busID, "PCI:%s:%d:%d",
|
2006-06-07 23:09:02 +02:00
|
|
|
busnum, pVideo->dev, pVideo->func);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].GDev.chipID = pVideo->device_id;
|
|
|
|
DevToConfig[i].GDev.chipRev = pVideo->revision;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:14:27 +02:00
|
|
|
if (*chipset < 0) {
|
|
|
|
*chipset = (pVideo->vendor_id << 16) | pVideo->device_id;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2009-08-18 11:14:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bus_sbus_newdev_configure(void *busData, int i)
|
|
|
|
{
|
2006-12-04 22:36:30 +01:00
|
|
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
2003-11-14 17:48:57 +01:00
|
|
|
char *promPath = NULL;
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].sVideo = (sbusDevicePtr) busData;
|
|
|
|
DevToConfig[i].GDev.identifier = DevToConfig[i].sVideo->descr;
|
2003-11-14 17:48:57 +01:00
|
|
|
if (sparcPromInit() >= 0) {
|
2009-08-18 11:53:47 +02:00
|
|
|
promPath = sparcPromNode2Pathname(&DevToConfig[i].sVideo->node);
|
2003-11-14 17:48:57 +01:00
|
|
|
sparcPromClose();
|
|
|
|
}
|
|
|
|
if (promPath) {
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].GDev.busID = xnfalloc(strlen(promPath) + 6);
|
|
|
|
sprintf(DevToConfig[i].GDev.busID, "SBUS:%s", promPath);
|
2003-11-14 17:48:57 +01:00
|
|
|
xfree(promPath);
|
|
|
|
} else {
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].GDev.busID = xnfalloc(12);
|
|
|
|
sprintf(DevToConfig[i].GDev.busID, "SBUS:fb%d",
|
|
|
|
DevToConfig[i].sVideo->fbNum);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
#endif
|
2009-08-18 11:14:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is called by the driver, either through xf86Match???Instances() or
|
|
|
|
* directly. We allocate a GDevRec and fill it in as much as we can, letting
|
|
|
|
* the caller fill in the rest and/or change it as it sees fit.
|
|
|
|
*/
|
|
|
|
GDevPtr
|
|
|
|
xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
|
|
|
|
{
|
|
|
|
int ret, i, j;
|
|
|
|
|
|
|
|
if (!xf86DoConfigure || !xf86DoConfigurePass1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Check for duplicates */
|
|
|
|
switch (bus) {
|
|
|
|
case BUS_PCI:
|
|
|
|
ret = bus_pci_configure(busData);
|
|
|
|
break;
|
|
|
|
case BUS_SBUS:
|
|
|
|
ret = bus_sbus_configure(busData);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Allocate new structure occurrence */
|
|
|
|
i = nDevToConfig++;
|
|
|
|
DevToConfig =
|
|
|
|
xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
|
|
|
|
memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
|
|
|
|
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].GDev.chipID =
|
|
|
|
DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1;
|
2009-08-18 11:14:27 +02:00
|
|
|
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].iDriver = CurrentDriver;
|
2009-08-18 11:14:27 +02:00
|
|
|
|
|
|
|
/* Fill in what we know, converting the driver name to lower case */
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1);
|
|
|
|
for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
|
2009-08-18 11:14:27 +02:00
|
|
|
|
|
|
|
switch (bus) {
|
|
|
|
case BUS_PCI:
|
|
|
|
bus_pci_newdev_configure(busData, i, &chipset);
|
|
|
|
break;
|
|
|
|
case BUS_SBUS:
|
|
|
|
bus_sbus_newdev_configure(busData, i);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get driver's available options */
|
|
|
|
if (xf86DriverList[CurrentDriver]->AvailableOptions)
|
2009-08-18 11:53:47 +02:00
|
|
|
DevToConfig[i].GDev.options = (OptionInfoPtr)
|
2003-11-14 17:48:57 +01:00
|
|
|
(*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
|
|
|
|
bus);
|
|
|
|
|
2009-08-18 11:53:47 +02:00
|
|
|
return &DevToConfig[i].GDev;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-08-18 11:14:27 +02:00
|
|
|
out:
|
|
|
|
return NULL;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfInputPtr
|
|
|
|
configureInputSection (void)
|
|
|
|
{
|
|
|
|
XF86ConfInputPtr mouse = NULL;
|
|
|
|
parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
|
|
|
|
|
|
|
|
ptr->inp_identifier = "Keyboard0";
|
2004-08-15 01:59:52 +02:00
|
|
|
ptr->inp_driver = "kbd";
|
2003-11-14 17:48:57 +01:00
|
|
|
ptr->list.next = NULL;
|
|
|
|
|
|
|
|
/* Crude mechanism to auto-detect mouse (os dependent) */
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
#ifdef WSCONS_SUPPORT
|
|
|
|
fd = open("/dev/wsmouse", 0);
|
2009-10-08 04:27:30 +02:00
|
|
|
if (fd >= 0) {
|
2003-11-14 17:48:57 +01:00
|
|
|
DFLT_MOUSE_DEV = "/dev/wsmouse";
|
|
|
|
DFLT_MOUSE_PROTO = "wsmouse";
|
|
|
|
close(fd);
|
2003-11-25 20:29:01 +01:00
|
|
|
} else {
|
|
|
|
ErrorF("cannot open /dev/wsmouse\n");
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-11-08 07:33:30 +01:00
|
|
|
#ifndef __SCO__
|
2003-11-14 17:48:57 +01:00
|
|
|
fd = open(DFLT_MOUSE_DEV, 0);
|
|
|
|
if (fd != -1) {
|
|
|
|
foundMouse = TRUE;
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
foundMouse = TRUE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-04-06 23:56:49 +02:00
|
|
|
mouse = calloc(1, sizeof(XF86ConfInputRec));
|
2003-11-14 17:48:57 +01:00
|
|
|
mouse->inp_identifier = "Mouse0";
|
|
|
|
mouse->inp_driver = "mouse";
|
|
|
|
mouse->inp_option_lst =
|
2007-04-10 22:48:00 +02:00
|
|
|
xf86addNewOption(mouse->inp_option_lst, xstrdup("Protocol"),
|
|
|
|
xstrdup(DFLT_MOUSE_PROTO));
|
2005-11-08 07:33:30 +01:00
|
|
|
#ifndef __SCO__
|
2003-11-14 17:48:57 +01:00
|
|
|
mouse->inp_option_lst =
|
2007-04-10 22:48:00 +02:00
|
|
|
xf86addNewOption(mouse->inp_option_lst, xstrdup("Device"),
|
|
|
|
xstrdup(DFLT_MOUSE_DEV));
|
2005-11-14 19:49:30 +01:00
|
|
|
#endif
|
2005-08-16 01:48:35 +02:00
|
|
|
mouse->inp_option_lst =
|
2007-04-10 22:48:00 +02:00
|
|
|
xf86addNewOption(mouse->inp_option_lst, xstrdup("ZAxisMapping"),
|
|
|
|
xstrdup("4 5 6 7"));
|
2003-11-14 17:48:57 +01:00
|
|
|
ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfScreenPtr
|
|
|
|
configureScreenSection (int screennum)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
|
|
|
|
parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
|
|
|
|
|
2009-04-06 23:56:49 +02:00
|
|
|
ptr->scrn_identifier = malloc(18);
|
2003-11-14 17:48:57 +01:00
|
|
|
sprintf(ptr->scrn_identifier, "Screen%d", screennum);
|
2009-04-06 23:56:49 +02:00
|
|
|
ptr->scrn_monitor_str = malloc(19);
|
2003-11-14 17:48:57 +01:00
|
|
|
sprintf(ptr->scrn_monitor_str, "Monitor%d", screennum);
|
2009-04-06 23:56:49 +02:00
|
|
|
ptr->scrn_device_str = malloc(16);
|
2003-11-14 17:48:57 +01:00
|
|
|
sprintf(ptr->scrn_device_str, "Card%d", screennum);
|
|
|
|
|
|
|
|
for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
|
|
|
|
{
|
|
|
|
XF86ConfDisplayPtr display;
|
|
|
|
|
2009-04-06 23:56:49 +02:00
|
|
|
display = calloc(1, sizeof(XF86ConfDisplayRec));
|
2003-11-14 17:48:57 +01:00
|
|
|
display->disp_depth = depths[i];
|
|
|
|
display->disp_black.red = display->disp_white.red = -1;
|
|
|
|
display->disp_black.green = display->disp_white.green = -1;
|
|
|
|
display->disp_black.blue = display->disp_white.blue = -1;
|
|
|
|
ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem(
|
|
|
|
(glp)ptr->scrn_display_lst, (glp)display);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char*
|
|
|
|
optionTypeToSting(OptionValueType type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case OPTV_NONE:
|
|
|
|
return "";
|
|
|
|
case OPTV_INTEGER:
|
|
|
|
return "<i>";
|
|
|
|
case OPTV_STRING:
|
|
|
|
return "<str>";
|
|
|
|
case OPTV_ANYSTR:
|
|
|
|
return "[<str>]";
|
|
|
|
case OPTV_REAL:
|
|
|
|
return "<f>";
|
|
|
|
case OPTV_BOOLEAN:
|
|
|
|
return "[<bool>]";
|
|
|
|
case OPTV_FREQ:
|
|
|
|
return "<freq>";
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfDevicePtr
|
|
|
|
configureDeviceSection (int screennum)
|
|
|
|
{
|
|
|
|
char identifier[16];
|
|
|
|
OptionInfoPtr p;
|
|
|
|
int i = 0;
|
|
|
|
parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
|
|
|
|
|
|
|
|
/* Move device info to parser structure */
|
|
|
|
sprintf(identifier, "Card%d", screennum);
|
|
|
|
ptr->dev_identifier = strdup(identifier);
|
|
|
|
/* ptr->dev_identifier = DevToConfig[screennum].GDev.identifier;*/
|
|
|
|
ptr->dev_vendor = DevToConfig[screennum].GDev.vendor;
|
|
|
|
ptr->dev_board = DevToConfig[screennum].GDev.board;
|
|
|
|
ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
|
|
|
|
ptr->dev_busid = DevToConfig[screennum].GDev.busID;
|
|
|
|
ptr->dev_driver = DevToConfig[screennum].GDev.driver;
|
|
|
|
ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
|
|
|
|
for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
|
|
|
|
ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
|
|
|
|
ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
|
|
|
|
ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
|
|
|
|
ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
|
|
|
|
ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
|
|
|
|
ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
|
|
|
|
ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
|
|
|
|
for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++)
|
|
|
|
ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
|
|
|
|
ptr->dev_clocks = i;
|
|
|
|
ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
|
|
|
|
ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev;
|
|
|
|
ptr->dev_irq = DevToConfig[screennum].GDev.irq;
|
|
|
|
|
|
|
|
/* Make sure older drivers don't segv */
|
|
|
|
if (DevToConfig[screennum].GDev.options) {
|
|
|
|
/* Fill in the available driver options for people to use */
|
|
|
|
const char *descrip =
|
|
|
|
" ### Available Driver options are:-\n"
|
|
|
|
" ### Values: <i>: integer, <f>: float, "
|
|
|
|
"<bool>: \"True\"/\"False\",\n"
|
|
|
|
" ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\"\n"
|
|
|
|
" ### [arg]: arg optional\n";
|
|
|
|
ptr->dev_comment = xstrdup(descrip);
|
|
|
|
if (ptr->dev_comment) {
|
|
|
|
for (p = DevToConfig[screennum].GDev.options;
|
|
|
|
p->name != NULL; p++) {
|
|
|
|
char *p_e;
|
|
|
|
const char *prefix = " #Option ";
|
|
|
|
const char *middle = " \t# ";
|
|
|
|
const char *suffix = "\n";
|
|
|
|
const char *opttype = optionTypeToSting(p->type);
|
|
|
|
char *optname;
|
|
|
|
int len = strlen(ptr->dev_comment) + strlen(prefix) +
|
|
|
|
strlen(middle) + strlen(suffix) + 1;
|
|
|
|
|
|
|
|
optname = xalloc(strlen(p->name) + 2 + 1);
|
|
|
|
if (!optname)
|
|
|
|
break;
|
|
|
|
sprintf(optname, "\"%s\"", p->name);
|
|
|
|
|
|
|
|
len += max(20, strlen(optname));
|
|
|
|
len += strlen(opttype);
|
|
|
|
|
|
|
|
ptr->dev_comment = xrealloc(ptr->dev_comment, len);
|
|
|
|
if (!ptr->dev_comment)
|
|
|
|
break;
|
|
|
|
p_e = ptr->dev_comment + strlen(ptr->dev_comment);
|
|
|
|
sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
|
|
|
|
opttype, suffix);
|
|
|
|
xfree(optname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfLayoutPtr
|
|
|
|
configureLayoutSection (void)
|
|
|
|
{
|
|
|
|
int scrnum = 0;
|
|
|
|
parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
|
|
|
|
|
2004-04-23 21:54:30 +02:00
|
|
|
ptr->lay_identifier = "X.org Configured";
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
XF86ConfInputrefPtr iptr;
|
|
|
|
|
2009-04-06 23:56:49 +02:00
|
|
|
iptr = malloc (sizeof (XF86ConfInputrefRec));
|
2003-11-14 17:48:57 +01:00
|
|
|
iptr->list.next = NULL;
|
|
|
|
iptr->iref_option_lst = NULL;
|
|
|
|
iptr->iref_inputdev_str = "Mouse0";
|
|
|
|
iptr->iref_option_lst =
|
2007-04-10 22:48:00 +02:00
|
|
|
xf86addNewOption (iptr->iref_option_lst, xstrdup("CorePointer"), NULL);
|
2003-11-14 17:48:57 +01:00
|
|
|
ptr->lay_input_lst = (XF86ConfInputrefPtr)
|
|
|
|
xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
XF86ConfInputrefPtr iptr;
|
|
|
|
|
2009-04-06 23:56:49 +02:00
|
|
|
iptr = malloc (sizeof (XF86ConfInputrefRec));
|
2003-11-14 17:48:57 +01:00
|
|
|
iptr->list.next = NULL;
|
|
|
|
iptr->iref_option_lst = NULL;
|
|
|
|
iptr->iref_inputdev_str = "Keyboard0";
|
|
|
|
iptr->iref_option_lst =
|
2007-04-10 22:48:00 +02:00
|
|
|
xf86addNewOption (iptr->iref_option_lst, xstrdup("CoreKeyboard"), NULL);
|
2003-11-14 17:48:57 +01:00
|
|
|
ptr->lay_input_lst = (XF86ConfInputrefPtr)
|
|
|
|
xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
|
|
|
|
XF86ConfAdjacencyPtr aptr;
|
|
|
|
|
2009-04-06 23:56:49 +02:00
|
|
|
aptr = malloc (sizeof (XF86ConfAdjacencyRec));
|
2003-11-14 17:48:57 +01:00
|
|
|
aptr->list.next = NULL;
|
|
|
|
aptr->adj_x = 0;
|
|
|
|
aptr->adj_y = 0;
|
|
|
|
aptr->adj_scrnum = scrnum;
|
|
|
|
aptr->adj_screen_str = xnfalloc(18);
|
|
|
|
sprintf(aptr->adj_screen_str, "Screen%d", scrnum);
|
|
|
|
if (scrnum == 0) {
|
|
|
|
aptr->adj_where = CONF_ADJ_ABSOLUTE;
|
|
|
|
aptr->adj_refscreen = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aptr->adj_where = CONF_ADJ_RIGHTOF;
|
|
|
|
aptr->adj_refscreen = xnfalloc(18);
|
|
|
|
sprintf(aptr->adj_refscreen, "Screen%d", scrnum - 1);
|
|
|
|
}
|
|
|
|
ptr->lay_adjacency_lst =
|
|
|
|
(XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
|
|
|
|
(glp)aptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfFlagsPtr
|
|
|
|
configureFlagsSection (void)
|
|
|
|
{
|
|
|
|
parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfModulePtr
|
|
|
|
configureModuleSection (void)
|
|
|
|
{
|
|
|
|
char **elist, **el;
|
2008-12-02 01:08:55 +01:00
|
|
|
/* Find the list of extension & font modules. */
|
2003-11-14 17:48:57 +01:00
|
|
|
const char *esubdirs[] = {
|
|
|
|
"extensions",
|
|
|
|
"fonts",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
|
|
|
|
|
|
|
|
elist = LoaderListDirs(esubdirs, NULL);
|
|
|
|
if (elist) {
|
|
|
|
for (el = elist; *el; el++) {
|
|
|
|
XF86LoadPtr module;
|
|
|
|
|
2009-04-06 23:56:49 +02:00
|
|
|
module = calloc(1, sizeof(XF86LoadRec));
|
2003-11-14 17:48:57 +01:00
|
|
|
module->load_name = *el;
|
2006-06-01 21:49:55 +02:00
|
|
|
ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
|
|
|
|
(glp)ptr->mod_load_lst, (glp)module);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
xfree(elist);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfFilesPtr
|
|
|
|
configureFilesSection (void)
|
|
|
|
{
|
|
|
|
parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
|
|
|
|
|
|
|
|
if (xf86ModulePath)
|
|
|
|
ptr->file_modulepath = strdup(xf86ModulePath);
|
|
|
|
if (defaultFontPath)
|
|
|
|
ptr->file_fontpath = strdup(defaultFontPath);
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfMonitorPtr
|
|
|
|
configureMonitorSection (int screennum)
|
|
|
|
{
|
|
|
|
parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
|
|
|
|
|
2009-04-06 23:56:49 +02:00
|
|
|
ptr->mon_identifier = malloc(19);
|
2003-11-14 17:48:57 +01:00
|
|
|
sprintf(ptr->mon_identifier, "Monitor%d", screennum);
|
|
|
|
ptr->mon_vendor = strdup("Monitor Vendor");
|
|
|
|
ptr->mon_modelname = strdup("Monitor Model");
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2009-02-18 10:41:26 +01:00
|
|
|
/* Initialize Configure Monitor from Detailed Timing Block */
|
|
|
|
static void handle_detailed_input(struct detailed_monitor_section *det_mon,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
XF86ConfMonitorPtr ptr = (XF86ConfMonitorPtr) data;
|
|
|
|
|
|
|
|
switch (det_mon->type) {
|
|
|
|
case DS_NAME:
|
|
|
|
ptr->mon_modelname = realloc(ptr->mon_modelname,
|
|
|
|
strlen((char*)(det_mon->section.name)) +
|
|
|
|
1);
|
|
|
|
strcpy(ptr->mon_modelname,
|
|
|
|
(char*)(det_mon->section.name));
|
|
|
|
break;
|
|
|
|
case DS_RANGES:
|
|
|
|
ptr->mon_hsync[ptr->mon_n_hsync].lo =
|
|
|
|
det_mon->section.ranges.min_h;
|
|
|
|
ptr->mon_hsync[ptr->mon_n_hsync].hi =
|
|
|
|
det_mon->section.ranges.max_h;
|
|
|
|
ptr->mon_n_vrefresh = 1;
|
|
|
|
ptr->mon_vrefresh[ptr->mon_n_hsync].lo =
|
|
|
|
det_mon->section.ranges.min_v;
|
|
|
|
ptr->mon_vrefresh[ptr->mon_n_hsync].hi =
|
|
|
|
det_mon->section.ranges.max_v;
|
|
|
|
ptr->mon_n_hsync++;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
static XF86ConfMonitorPtr
|
|
|
|
configureDDCMonitorSection (int screennum)
|
|
|
|
{
|
|
|
|
int len, mon_width, mon_height;
|
|
|
|
#define displaySizeMaxLen 80
|
|
|
|
char displaySize_string[displaySizeMaxLen];
|
|
|
|
int displaySizeLen;
|
|
|
|
|
|
|
|
parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
|
|
|
|
|
2009-04-06 23:56:49 +02:00
|
|
|
ptr->mon_identifier = malloc(19);
|
2003-11-14 17:48:57 +01:00
|
|
|
sprintf(ptr->mon_identifier, "Monitor%d", screennum);
|
|
|
|
ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
|
2009-04-06 23:56:49 +02:00
|
|
|
ptr->mon_modelname = malloc(12);
|
2003-11-14 17:48:57 +01:00
|
|
|
sprintf(ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
|
|
|
|
|
|
|
|
/* features in centimetres, we want millimetres */
|
|
|
|
mon_width = 10 * ConfiguredMonitor->features.hsize ;
|
|
|
|
mon_height = 10 * ConfiguredMonitor->features.vsize ;
|
|
|
|
|
|
|
|
#ifdef CONFIGURE_DISPLAYSIZE
|
|
|
|
ptr->mon_width = mon_width;
|
|
|
|
ptr->mon_height = mon_height;
|
|
|
|
#else
|
|
|
|
if (mon_width && mon_height) {
|
|
|
|
/* when values available add DisplaySize option AS A COMMENT */
|
|
|
|
|
|
|
|
displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
|
|
|
|
"\t#DisplaySize\t%5d %5d\t# mm\n",
|
|
|
|
mon_width, mon_height);
|
|
|
|
|
|
|
|
if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) {
|
|
|
|
if (ptr->mon_comment) {
|
|
|
|
len = strlen(ptr->mon_comment);
|
|
|
|
} else {
|
|
|
|
len = 0;
|
|
|
|
}
|
|
|
|
if ((ptr->mon_comment =
|
2010-03-15 22:46:36 +01:00
|
|
|
realloc(ptr->mon_comment, len + strlen(displaySize_string) + 1))) {
|
2003-11-14 17:48:57 +01:00
|
|
|
strcpy(ptr->mon_comment + len, displaySize_string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* def CONFIGURE_DISPLAYSIZE */
|
|
|
|
|
2009-02-18 10:41:26 +01:00
|
|
|
xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input,
|
|
|
|
ptr);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (ConfiguredMonitor->features.dpms) {
|
2007-04-10 22:48:00 +02:00
|
|
|
ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, xstrdup("DPMS"), NULL);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2008-11-25 05:34:46 +01:00
|
|
|
#if !defined(PATH_MAX)
|
|
|
|
# define PATH_MAX 1024
|
|
|
|
#endif
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2008-11-25 05:34:46 +01:00
|
|
|
DoConfigure(void)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
int i,j, screennum = -1;
|
|
|
|
char *home = NULL;
|
2008-11-25 05:34:46 +01:00
|
|
|
char filename[PATH_MAX];
|
|
|
|
char *addslash = "";
|
2003-11-14 17:48:57 +01:00
|
|
|
XF86ConfigPtr xf86config = NULL;
|
|
|
|
char **vlist, **vl;
|
|
|
|
int *dev2screen;
|
|
|
|
|
|
|
|
vlist = xf86DriverlistFromCompile();
|
|
|
|
|
|
|
|
if (!vlist) {
|
|
|
|
ErrorF("Missing output drivers. Configuration failed.\n");
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
ErrorF("List of video drivers:\n");
|
|
|
|
for (vl = vlist; *vl; vl++)
|
|
|
|
ErrorF("\t%s\n", *vl);
|
|
|
|
|
|
|
|
/* Load all the drivers that were found. */
|
|
|
|
xf86LoadModules(vlist, NULL);
|
|
|
|
|
|
|
|
xfree(vlist);
|
|
|
|
|
2005-01-28 17:13:00 +01:00
|
|
|
for (i = 0; i < xf86NumDrivers; i++) {
|
|
|
|
xorgHWFlags flags;
|
|
|
|
if (!xf86DriverList[i]->driverFunc
|
|
|
|
|| !xf86DriverList[i]->driverFunc(NULL,
|
|
|
|
GET_REQUIRED_HW_INTERFACES,
|
|
|
|
&flags)
|
|
|
|
|| NEED_IO_ENABLED(flags)) {
|
|
|
|
xorgHWAccess = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Enable full I/O access */
|
|
|
|
if (xorgHWAccess) {
|
|
|
|
if(!xf86EnableIO())
|
|
|
|
/* oops, we have failed */
|
|
|
|
xorgHWAccess = FALSE;
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86FindPrimaryDevice();
|
|
|
|
|
|
|
|
/* Create XF86Config file structure */
|
2008-10-06 21:36:51 +02:00
|
|
|
xf86config = calloc(1, sizeof(XF86ConfigRec));
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
/* Call all of the probe functions, reporting the results. */
|
|
|
|
for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
|
2005-01-28 17:13:00 +01:00
|
|
|
xorgHWFlags flags;
|
2006-06-07 23:09:02 +02:00
|
|
|
Bool found_screen;
|
|
|
|
DriverRec * const drv = xf86DriverList[CurrentDriver];
|
|
|
|
|
2005-01-28 17:13:00 +01:00
|
|
|
if (!xorgHWAccess) {
|
2006-06-07 23:09:02 +02:00
|
|
|
if (!drv->driverFunc
|
|
|
|
|| !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags )
|
2005-01-28 17:13:00 +01:00
|
|
|
|| NEED_IO_ENABLED(flags))
|
|
|
|
continue;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2006-06-07 23:09:02 +02:00
|
|
|
found_screen = xf86CallDriverProbe( drv, TRUE );
|
|
|
|
if ( found_screen && drv->Identify ) {
|
|
|
|
(*drv->Identify)(0);
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nDevToConfig <= 0) {
|
|
|
|
ErrorF("No devices to configure. Configuration failed.\n");
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add device, monitor and screen sections for detected devices */
|
|
|
|
for (screennum = 0; screennum < nDevToConfig; screennum++) {
|
|
|
|
XF86ConfDevicePtr DevicePtr;
|
|
|
|
XF86ConfMonitorPtr MonitorPtr;
|
|
|
|
XF86ConfScreenPtr ScreenPtr;
|
|
|
|
|
|
|
|
DevicePtr = configureDeviceSection(screennum);
|
|
|
|
xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem(
|
|
|
|
(glp)xf86config->conf_device_lst, (glp)DevicePtr);
|
|
|
|
MonitorPtr = configureMonitorSection(screennum);
|
|
|
|
xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
|
|
|
|
(glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
|
|
|
|
ScreenPtr = configureScreenSection(screennum);
|
|
|
|
xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
|
|
|
|
(glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
xf86config->conf_files = configureFilesSection();
|
|
|
|
xf86config->conf_modules = configureModuleSection();
|
|
|
|
xf86config->conf_flags = configureFlagsSection();
|
2007-02-07 02:44:34 +01:00
|
|
|
xf86config->conf_videoadaptor_lst = NULL;
|
|
|
|
xf86config->conf_modes_lst = NULL;
|
|
|
|
xf86config->conf_vendor_lst = NULL;
|
|
|
|
xf86config->conf_dri = NULL;
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86config->conf_input_lst = configureInputSection();
|
|
|
|
xf86config->conf_layout_lst = configureLayoutSection();
|
|
|
|
|
2008-11-25 05:34:46 +01:00
|
|
|
home = getenv("HOME");
|
2008-11-25 05:37:58 +01:00
|
|
|
if ((home == NULL) || (home[0] == '\0')) {
|
2003-11-14 17:48:57 +01:00
|
|
|
home = "/";
|
2008-11-25 05:34:46 +01:00
|
|
|
} else {
|
|
|
|
/* Determine if trailing slash is present or needed */
|
|
|
|
int l = strlen(home);
|
|
|
|
|
|
|
|
if (home[l-1] != '/') {
|
|
|
|
addslash = "/";
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2008-11-25 05:34:46 +01:00
|
|
|
snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new",
|
|
|
|
home, addslash);
|
|
|
|
|
2009-02-13 03:34:22 +01:00
|
|
|
if (xf86writeConfigFile(filename, xf86config) == 0) {
|
|
|
|
xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
|
|
|
|
filename, strerror(errno));
|
|
|
|
goto bail;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
xf86DoConfigurePass1 = FALSE;
|
|
|
|
/* Try to get DDC information filled in */
|
|
|
|
xf86ConfigFile = filename;
|
2003-11-25 20:29:01 +01:00
|
|
|
if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
|
2003-11-14 17:48:57 +01:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
xf86DoConfigurePass1 = FALSE;
|
|
|
|
|
|
|
|
dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int));
|
|
|
|
|
|
|
|
{
|
|
|
|
Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool));
|
|
|
|
for (screennum = 0; screennum < nDevToConfig; screennum++) {
|
|
|
|
int k,l,n,oldNumScreens;
|
|
|
|
|
|
|
|
i = DevToConfig[screennum].iDriver;
|
|
|
|
|
|
|
|
if (driverProbed[i]) continue;
|
|
|
|
driverProbed[i] = TRUE;
|
|
|
|
|
|
|
|
oldNumScreens = xf86NumScreens;
|
|
|
|
|
2006-06-07 23:09:02 +02:00
|
|
|
xf86CallDriverProbe( xf86DriverList[i], FALSE );
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
/* reorder */
|
|
|
|
k = screennum > 0 ? screennum : 1;
|
|
|
|
for (l = oldNumScreens; l < xf86NumScreens; l++) {
|
|
|
|
/* is screen primary? */
|
|
|
|
Bool primary = FALSE;
|
|
|
|
for (n = 0; n<xf86Screens[l]->numEntities; n++) {
|
|
|
|
if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
|
|
|
|
dev2screen[0] = l;
|
|
|
|
primary = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (primary) continue;
|
|
|
|
/* not primary: assign it to next device of same driver */
|
|
|
|
/*
|
|
|
|
* NOTE: we assume that devices in DevToConfig
|
|
|
|
* and xf86Screens[] have the same order except
|
|
|
|
* for the primary device which always comes first.
|
|
|
|
*/
|
|
|
|
for (; k < nDevToConfig; k++) {
|
|
|
|
if (DevToConfig[k].iDriver == i) {
|
|
|
|
dev2screen[k++] = l;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xfree(driverProbed);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (nDevToConfig != xf86NumScreens) {
|
|
|
|
ErrorF("Number of created screens does not match number of detected"
|
|
|
|
" devices.\n Configuration failed.\n");
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
xf86PostProbe();
|
|
|
|
xf86EntityInit();
|
|
|
|
|
|
|
|
for (j = 0; j < xf86NumScreens; j++) {
|
|
|
|
xf86Screens[j]->scrnIndex = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
xf86freeMonitorList(xf86config->conf_monitor_lst);
|
|
|
|
xf86config->conf_monitor_lst = NULL;
|
|
|
|
xf86freeScreenList(xf86config->conf_screen_lst);
|
|
|
|
xf86config->conf_screen_lst = NULL;
|
|
|
|
for (j = 0; j < xf86NumScreens; j++) {
|
|
|
|
XF86ConfMonitorPtr MonitorPtr;
|
|
|
|
XF86ConfScreenPtr ScreenPtr;
|
|
|
|
|
|
|
|
ConfiguredMonitor = NULL;
|
|
|
|
|
|
|
|
xf86EnableAccess(xf86Screens[dev2screen[j]]);
|
|
|
|
if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]],
|
|
|
|
PROBE_DETECT) &&
|
|
|
|
ConfiguredMonitor) {
|
|
|
|
MonitorPtr = configureDDCMonitorSection(j);
|
|
|
|
} else {
|
|
|
|
MonitorPtr = configureMonitorSection(j);
|
|
|
|
}
|
|
|
|
ScreenPtr = configureScreenSection(j);
|
|
|
|
xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
|
|
|
|
(glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
|
|
|
|
xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
|
|
|
|
(glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
|
|
|
|
}
|
|
|
|
|
2009-02-13 03:34:22 +01:00
|
|
|
if (xf86writeConfigFile(filename, xf86config) == 0) {
|
|
|
|
xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
|
|
|
|
filename, strerror(errno));
|
|
|
|
goto bail;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
ErrorF("\n");
|
|
|
|
|
2005-11-08 07:33:30 +01:00
|
|
|
#ifdef __SCO__
|
2004-04-23 21:54:30 +02:00
|
|
|
ErrorF("\n"__XSERVERNAME__
|
|
|
|
" is using the kernel event driver to access the mouse.\n"
|
|
|
|
"If you wish to use the internal "__XSERVERNAME__
|
2005-11-08 07:33:30 +01:00
|
|
|
" mouse drivers, please\n"
|
2003-11-14 17:48:57 +01:00
|
|
|
"edit the file and correct the Device.\n");
|
2005-11-08 07:33:30 +01:00
|
|
|
#else /* !__SCO__ */
|
2003-11-14 17:48:57 +01:00
|
|
|
if (!foundMouse) {
|
2004-04-23 21:54:30 +02:00
|
|
|
ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n"
|
2003-11-14 17:48:57 +01:00
|
|
|
"Edit the file and correct the Device.\n");
|
|
|
|
} else {
|
2004-04-23 21:54:30 +02:00
|
|
|
ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n"
|
2003-11-14 17:48:57 +01:00
|
|
|
"Please check your config if the mouse is still not\n"
|
2004-04-23 21:54:30 +02:00
|
|
|
"operational, as by default "__XSERVERNAME__
|
|
|
|
" tries to autodetect\n"
|
2003-11-14 17:48:57 +01:00
|
|
|
"the protocol.\n",DFLT_MOUSE_DEV);
|
|
|
|
}
|
2005-11-08 07:33:30 +01:00
|
|
|
#endif /* !__SCO__ */
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (xf86NumScreens > 1) {
|
2004-04-23 21:54:30 +02:00
|
|
|
ErrorF("\n"__XSERVERNAME__
|
|
|
|
" has configured a multihead system, please check your config.\n");
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2004-04-23 21:54:30 +02:00
|
|
|
ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename);
|
2004-05-24 21:05:01 +02:00
|
|
|
ErrorF("To test the server, run 'X -config %s'\n\n", filename);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
bail:
|
2003-11-25 20:29:01 +01:00
|
|
|
OsCleanup(TRUE);
|
2003-11-14 17:48:57 +01:00
|
|
|
AbortDDX();
|
|
|
|
fflush(stderr);
|
|
|
|
exit(0);
|
|
|
|
}
|