2006-11-26 11:13:41 -07: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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86Config.h"
|
|
|
|
#include "xf86_OSlib.h"
|
|
|
|
#include "xf86Priv.h"
|
|
|
|
#define IN_XSERVER
|
|
|
|
#include "Configint.h"
|
|
|
|
#include "xf86DDC.h"
|
2014-09-27 11:52:59 -06:00
|
|
|
#include "xf86pciBus.h"
|
2011-11-05 07:32:40 -06:00
|
|
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "xf86Bus.h"
|
|
|
|
#include "xf86Sbus.h"
|
|
|
|
#endif
|
2011-11-05 07:32:40 -06:00
|
|
|
#include "misc.h"
|
2019-07-27 01:57:06 -06:00
|
|
|
#include "loaderProcs.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
typedef struct _DevToConfig {
|
|
|
|
GDevRec GDev;
|
2012-06-10 07:21:05 -06:00
|
|
|
struct pci_device *pVideo;
|
2011-11-05 07:32:40 -06:00
|
|
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
2006-11-26 11:13:41 -07:00
|
|
|
sbusDevicePtr sVideo;
|
|
|
|
#endif
|
|
|
|
int iDriver;
|
|
|
|
} DevToConfigRec, *DevToConfigPtr;
|
|
|
|
|
|
|
|
static DevToConfigPtr DevToConfig = NULL;
|
|
|
|
static int nDevToConfig = 0, CurrentDriver;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
xf86MonPtr ConfiguredMonitor;
|
2006-11-26 11:13:41 -07:00
|
|
|
Bool xf86DoConfigurePass1 = TRUE;
|
2007-11-24 12:04:00 -07:00
|
|
|
static Bool foundMouse = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *DFLT_MOUSE_DEV = "/dev/sysmouse";
|
|
|
|
static const char *DFLT_MOUSE_PROTO = "auto";
|
2019-07-27 01:57:06 -06:00
|
|
|
#elif defined(__linux__)
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *DFLT_MOUSE_DEV = "/dev/input/mice";
|
|
|
|
static const char *DFLT_MOUSE_PROTO = "auto";
|
2011-11-05 07:32:40 -06:00
|
|
|
#elif defined(WSCONS_SUPPORT)
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *DFLT_MOUSE_DEV = "/dev/wsmouse";
|
|
|
|
static const char *DFLT_MOUSE_PROTO = "wsmouse";
|
2006-11-26 11:13:41 -07:00
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *DFLT_MOUSE_DEV = "/dev/mouse";
|
|
|
|
static const char *DFLT_MOUSE_PROTO = "auto";
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2010-07-27 13:02:24 -06: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
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData,
|
|
|
|
int chipset)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int ret, i, j;
|
2014-09-27 11:52:59 -06:00
|
|
|
char *lower_driver;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (!xf86DoConfigure || !xf86DoConfigurePass1)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
/* Check for duplicates */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < nDevToConfig; i++) {
|
2011-11-05 07:32:40 -06:00
|
|
|
switch (bus) {
|
2012-06-10 07:21:05 -06:00
|
|
|
#ifdef XSERVER_LIBPCIACCESS
|
|
|
|
case BUS_PCI:
|
|
|
|
ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
|
|
|
|
break;
|
|
|
|
#endif
|
2011-11-05 07:32:40 -06:00
|
|
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
2012-06-10 07:21:05 -06:00
|
|
|
case BUS_SBUS:
|
|
|
|
ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
|
|
|
|
break;
|
2011-11-05 07:32:40 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
|
|
|
return NULL;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
if (ret == 0)
|
|
|
|
goto out;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate new structure occurrence */
|
|
|
|
i = nDevToConfig++;
|
|
|
|
DevToConfig =
|
2016-05-29 06:02:34 -06:00
|
|
|
xnfreallocarray(DevToConfig, nDevToConfig, sizeof(DevToConfigRec));
|
2010-07-27 13:02:24 -06:00
|
|
|
memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
|
|
|
|
|
|
|
|
DevToConfig[i].GDev.chipID =
|
2012-06-10 07:21:05 -06:00
|
|
|
DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
DevToConfig[i].iDriver = CurrentDriver;
|
|
|
|
|
|
|
|
/* Fill in what we know, converting the driver name to lower case */
|
2014-09-27 11:52:59 -06:00
|
|
|
lower_driver = xnfalloc(strlen(driver) + 1);
|
|
|
|
for (j = 0; (lower_driver[j] = tolower(driver[j])); j++);
|
|
|
|
DevToConfig[i].GDev.driver = lower_driver;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
switch (bus) {
|
2012-06-10 07:21:05 -06:00
|
|
|
#ifdef XSERVER_LIBPCIACCESS
|
|
|
|
case BUS_PCI:
|
2014-05-02 13:27:46 -06:00
|
|
|
DevToConfig[i].pVideo = busData;
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
|
|
|
|
&DevToConfig[i].GDev, &chipset);
|
|
|
|
break;
|
|
|
|
#endif
|
2011-11-05 07:32:40 -06:00
|
|
|
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|
2012-06-10 07:21:05 -06:00
|
|
|
case BUS_SBUS:
|
2014-05-02 13:27:46 -06:00
|
|
|
DevToConfig[i].sVideo = busData;
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
|
|
|
|
&DevToConfig[i].GDev);
|
|
|
|
break;
|
2011-11-05 07:32:40 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get driver's available options */
|
|
|
|
if (xf86DriverList[CurrentDriver]->AvailableOptions)
|
2012-06-10 07:21:05 -06:00
|
|
|
DevToConfig[i].GDev.options = (OptionInfoPtr)
|
|
|
|
(*xf86DriverList[CurrentDriver]->AvailableOptions) (chipset, bus);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
return &DevToConfig[i].GDev;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
out:
|
2010-07-27 13:02:24 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfInputPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
configureInputSection(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XF86ConfInputPtr mouse = NULL;
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
parsePrologue(XF86ConfInputPtr, XF86ConfInputRec);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
ptr->inp_identifier = xnfstrdup("Keyboard0");
|
|
|
|
ptr->inp_driver = xnfstrdup("kbd");
|
2006-11-26 11:13:41 -07:00
|
|
|
ptr->list.next = NULL;
|
|
|
|
|
|
|
|
/* Crude mechanism to auto-detect mouse (os dependent) */
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
|
|
|
int fd;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
fd = open(DFLT_MOUSE_DEV, 0);
|
|
|
|
if (fd != -1) {
|
|
|
|
foundMouse = TRUE;
|
|
|
|
close(fd);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
mouse = calloc(1, sizeof(XF86ConfInputRec));
|
2014-09-27 11:52:59 -06:00
|
|
|
mouse->inp_identifier = xnfstrdup("Mouse0");
|
|
|
|
mouse->inp_driver = xnfstrdup("mouse");
|
2012-06-10 07:21:05 -06:00
|
|
|
mouse->inp_option_lst =
|
2014-09-27 11:52:59 -06:00
|
|
|
xf86addNewOption(mouse->inp_option_lst, xnfstrdup("Protocol"),
|
|
|
|
xnfstrdup(DFLT_MOUSE_PROTO));
|
2012-06-10 07:21:05 -06:00
|
|
|
mouse->inp_option_lst =
|
2014-09-27 11:52:59 -06:00
|
|
|
xf86addNewOption(mouse->inp_option_lst, xnfstrdup("Device"),
|
|
|
|
xnfstrdup(DFLT_MOUSE_DEV));
|
2012-06-10 07:21:05 -06:00
|
|
|
mouse->inp_option_lst =
|
2014-09-27 11:52:59 -06:00
|
|
|
xf86addNewOption(mouse->inp_option_lst, xnfstrdup("ZAxisMapping"),
|
|
|
|
xnfstrdup("4 5 6 7"));
|
2012-06-10 07:21:05 -06:00
|
|
|
ptr = (XF86ConfInputPtr) xf86addListItem((glp) ptr, (glp) mouse);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfScreenPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
configureScreenSection(int screennum)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int i;
|
2012-06-10 07:21:05 -06:00
|
|
|
int depths[] = { 1, 4, 8, 15, 16, 24 /*, 32 */ };
|
2014-09-27 11:52:59 -06:00
|
|
|
char *tmp;
|
2019-07-27 01:57:06 -06:00
|
|
|
parsePrologue(XF86ConfScreenPtr, XF86ConfScreenRec);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
XNFasprintf(&tmp, "Screen%d", screennum);
|
|
|
|
ptr->scrn_identifier = tmp;
|
|
|
|
XNFasprintf(&tmp, "Monitor%d", screennum);
|
|
|
|
ptr->scrn_monitor_str = tmp;
|
|
|
|
XNFasprintf(&tmp, "Card%d", screennum);
|
|
|
|
ptr->scrn_device_str = tmp;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
for (i = 0; i < ARRAY_SIZE(depths); i++) {
|
2014-09-27 11:52:59 -06:00
|
|
|
XF86ConfDisplayPtr conf_display;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
conf_display = calloc(1, sizeof(XF86ConfDisplayRec));
|
|
|
|
conf_display->disp_depth = depths[i];
|
|
|
|
conf_display->disp_black.red = conf_display->disp_white.red = -1;
|
|
|
|
conf_display->disp_black.green = conf_display->disp_white.green = -1;
|
|
|
|
conf_display->disp_black.blue = conf_display->disp_white.blue = -1;
|
2012-06-10 07:21:05 -06:00
|
|
|
ptr->scrn_display_lst = (XF86ConfDisplayPtr) xf86addListItem((glp) ptr->
|
|
|
|
scrn_display_lst,
|
|
|
|
(glp)
|
2014-09-27 11:52:59 -06:00
|
|
|
conf_display);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *
|
2010-12-05 08:36:02 -07:00
|
|
|
optionTypeToString(OptionValueType type)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case OPTV_NONE:
|
|
|
|
return "";
|
|
|
|
case OPTV_INTEGER:
|
|
|
|
return "<i>";
|
|
|
|
case OPTV_STRING:
|
|
|
|
return "<str>";
|
|
|
|
case OPTV_ANYSTR:
|
2012-06-10 07:21:05 -06:00
|
|
|
return "[<str>]";
|
2006-11-26 11:13:41 -07:00
|
|
|
case OPTV_REAL:
|
|
|
|
return "<f>";
|
|
|
|
case OPTV_BOOLEAN:
|
|
|
|
return "[<bool>]";
|
|
|
|
case OPTV_FREQ:
|
|
|
|
return "<freq>";
|
2010-12-05 08:36:02 -07:00
|
|
|
case OPTV_PERCENT:
|
|
|
|
return "<percent>";
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfDevicePtr
|
2012-06-10 07:21:05 -06:00
|
|
|
configureDeviceSection(int screennum)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
int i = 0;
|
2014-09-27 11:52:59 -06:00
|
|
|
char *identifier;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
parsePrologue(XF86ConfDevicePtr, XF86ConfDeviceRec);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
/* Move device info to parser structure */
|
2014-09-27 11:52:59 -06:00
|
|
|
if (asprintf(&identifier, "Card%d", screennum) == -1)
|
|
|
|
identifier = NULL;
|
|
|
|
ptr->dev_identifier = identifier;
|
2006-11-26 11:13:41 -07:00
|
|
|
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;
|
2016-08-09 12:59:50 -06:00
|
|
|
for (i = 0; i < MAXDACSPEEDS; i++)
|
2006-11-26 11:13:41 -07:00
|
|
|
ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
|
|
|
|
ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
|
|
|
|
ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
|
|
|
|
ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
|
|
|
|
ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks);
|
|
|
|
i++)
|
2006-11-26 11:13:41 -07:00
|
|
|
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) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* 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"
|
|
|
|
" ### <percent>: \"<f>%\"\n"
|
|
|
|
" ### [arg]: arg optional\n";
|
2014-09-27 11:52:59 -06:00
|
|
|
ptr->dev_comment = xnfstrdup(descrip);
|
2012-06-10 07:21:05 -06:00
|
|
|
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 = optionTypeToString(p->type);
|
|
|
|
char *optname;
|
|
|
|
int len = strlen(ptr->dev_comment) + strlen(prefix) +
|
|
|
|
strlen(middle) + strlen(suffix) + 1;
|
|
|
|
|
|
|
|
if (asprintf(&optname, "\"%s\"", p->name) == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
len += max(20, strlen(optname));
|
|
|
|
len += strlen(opttype);
|
|
|
|
|
|
|
|
ptr->dev_comment = realloc(ptr->dev_comment, len);
|
|
|
|
if (!ptr->dev_comment)
|
|
|
|
break;
|
|
|
|
p_e = ptr->dev_comment + strlen(ptr->dev_comment);
|
2013-06-07 11:28:45 -06:00
|
|
|
sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
|
|
|
|
opttype, suffix);
|
2012-06-10 07:21:05 -06:00
|
|
|
free(optname);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfLayoutPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
configureLayoutSection(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int scrnum = 0;
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
parsePrologue(XF86ConfLayoutPtr, XF86ConfLayoutRec);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
ptr->lay_identifier = "X.org Configured";
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
|
|
|
XF86ConfInputrefPtr iptr;
|
|
|
|
|
|
|
|
iptr = malloc(sizeof(XF86ConfInputrefRec));
|
|
|
|
iptr->list.next = NULL;
|
|
|
|
iptr->iref_option_lst = NULL;
|
2014-09-27 11:52:59 -06:00
|
|
|
iptr->iref_inputdev_str = xnfstrdup("Mouse0");
|
2012-06-10 07:21:05 -06:00
|
|
|
iptr->iref_option_lst =
|
2014-09-27 11:52:59 -06:00
|
|
|
xf86addNewOption(iptr->iref_option_lst, xnfstrdup("CorePointer"),
|
2012-06-10 07:21:05 -06:00
|
|
|
NULL);
|
|
|
|
ptr->lay_input_lst = (XF86ConfInputrefPtr)
|
|
|
|
xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86ConfInputrefPtr iptr;
|
|
|
|
|
|
|
|
iptr = malloc(sizeof(XF86ConfInputrefRec));
|
|
|
|
iptr->list.next = NULL;
|
|
|
|
iptr->iref_option_lst = NULL;
|
2014-09-27 11:52:59 -06:00
|
|
|
iptr->iref_inputdev_str = xnfstrdup("Keyboard0");
|
2012-06-10 07:21:05 -06:00
|
|
|
iptr->iref_option_lst =
|
2014-09-27 11:52:59 -06:00
|
|
|
xf86addNewOption(iptr->iref_option_lst, xnfstrdup("CoreKeyboard"),
|
2012-06-10 07:21:05 -06:00
|
|
|
NULL);
|
|
|
|
ptr->lay_input_lst = (XF86ConfInputrefPtr)
|
|
|
|
xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
|
|
|
|
XF86ConfAdjacencyPtr aptr;
|
2014-09-27 11:52:59 -06:00
|
|
|
char *tmp;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
aptr = malloc(sizeof(XF86ConfAdjacencyRec));
|
|
|
|
aptr->list.next = NULL;
|
|
|
|
aptr->adj_x = 0;
|
|
|
|
aptr->adj_y = 0;
|
|
|
|
aptr->adj_scrnum = scrnum;
|
2014-09-27 11:52:59 -06:00
|
|
|
XNFasprintf(&tmp, "Screen%d", scrnum);
|
|
|
|
aptr->adj_screen_str = tmp;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (scrnum == 0) {
|
|
|
|
aptr->adj_where = CONF_ADJ_ABSOLUTE;
|
|
|
|
aptr->adj_refscreen = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aptr->adj_where = CONF_ADJ_RIGHTOF;
|
2014-09-27 11:52:59 -06:00
|
|
|
XNFasprintf(&tmp, "Screen%d", scrnum - 1);
|
|
|
|
aptr->adj_refscreen = tmp;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
ptr->lay_adjacency_lst =
|
|
|
|
(XF86ConfAdjacencyPtr) xf86addListItem((glp) ptr->lay_adjacency_lst,
|
|
|
|
(glp) aptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfFlagsPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
configureFlagsSection(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2019-07-27 01:57:06 -06:00
|
|
|
parsePrologue(XF86ConfFlagsPtr, XF86ConfFlagsRec);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
return ptr;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfModulePtr
|
2012-06-10 07:21:05 -06:00
|
|
|
configureModuleSection(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2014-09-27 11:52:59 -06:00
|
|
|
const char **elist, **el;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
parsePrologue(XF86ConfModulePtr, XF86ConfModuleRec);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
elist = LoaderListDir("extensions", NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (elist) {
|
2012-06-10 07:21:05 -06:00
|
|
|
for (el = elist; *el; el++) {
|
|
|
|
XF86LoadPtr module;
|
|
|
|
|
|
|
|
module = calloc(1, sizeof(XF86LoadRec));
|
|
|
|
module->load_name = *el;
|
|
|
|
ptr->mod_load_lst = (XF86LoadPtr) xf86addListItem((glp) ptr->
|
|
|
|
mod_load_lst,
|
|
|
|
(glp) module);
|
|
|
|
}
|
|
|
|
free(elist);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfFilesPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
configureFilesSection(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2019-07-27 01:57:06 -06:00
|
|
|
parsePrologue(XF86ConfFilesPtr, XF86ConfFilesRec);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
if (xf86ModulePath)
|
2014-09-27 11:52:59 -06:00
|
|
|
ptr->file_modulepath = xnfstrdup(xf86ModulePath);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (defaultFontPath)
|
2014-09-27 11:52:59 -06:00
|
|
|
ptr->file_fontpath = xnfstrdup(defaultFontPath);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ConfMonitorPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
configureMonitorSection(int screennum)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2014-09-27 11:52:59 -06:00
|
|
|
char *tmp;
|
2019-07-27 01:57:06 -06:00
|
|
|
parsePrologue(XF86ConfMonitorPtr, XF86ConfMonitorRec);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
XNFasprintf(&tmp, "Monitor%d", screennum);
|
|
|
|
ptr->mon_identifier = tmp;
|
|
|
|
ptr->mon_vendor = xnfstrdup("Monitor Vendor");
|
|
|
|
ptr->mon_modelname = xnfstrdup("Monitor Model");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/* Initialize Configure Monitor from Detailed Timing Block */
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
handle_detailed_input(struct detailed_monitor_section *det_mon, void *data)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
XF86ConfMonitorPtr ptr = (XF86ConfMonitorPtr) data;
|
|
|
|
|
|
|
|
switch (det_mon->type) {
|
|
|
|
case DS_NAME:
|
|
|
|
ptr->mon_modelname = realloc(ptr->mon_modelname,
|
2012-06-10 07:21:05 -06:00
|
|
|
strlen((char *) (det_mon->section.name)) +
|
2010-07-27 13:02:24 -06:00
|
|
|
1);
|
2012-06-10 07:21:05 -06:00
|
|
|
strcpy(ptr->mon_modelname, (char *) (det_mon->section.name));
|
2010-07-27 13:02:24 -06:00
|
|
|
break;
|
|
|
|
case DS_RANGES:
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2010-07-27 13:02:24 -06:00
|
|
|
ptr->mon_n_vrefresh = 1;
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2010-07-27 13:02:24 -06:00
|
|
|
ptr->mon_n_hsync++;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
static XF86ConfMonitorPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
configureDDCMonitorSection(int screennum)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int len, mon_width, mon_height;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#define displaySizeMaxLen 80
|
|
|
|
char displaySize_string[displaySizeMaxLen];
|
|
|
|
int displaySizeLen;
|
2014-09-27 11:52:59 -06:00
|
|
|
char *tmp;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
parsePrologue(XF86ConfMonitorPtr, XF86ConfMonitorRec);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
XNFasprintf(&tmp, "Monitor%d", screennum);
|
|
|
|
ptr->mon_identifier = tmp;
|
|
|
|
ptr->mon_vendor = xnfstrdup(ConfiguredMonitor->vendor.name);
|
2011-11-05 07:32:40 -06:00
|
|
|
XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* features in centimetres, we want millimetres */
|
2012-06-10 07:21:05 -06:00
|
|
|
mon_width = 10 * ConfiguredMonitor->features.hsize;
|
|
|
|
mon_height = 10 * ConfiguredMonitor->features.vsize;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef CONFIGURE_DISPLAYSIZE
|
2012-06-10 07:21:05 -06:00
|
|
|
ptr->mon_width = mon_width;
|
2006-11-26 11:13:41 -07:00
|
|
|
ptr->mon_height = mon_height;
|
|
|
|
#else
|
|
|
|
if (mon_width && mon_height) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* 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 =
|
|
|
|
realloc(ptr->mon_comment,
|
|
|
|
len + strlen(displaySize_string) + 1))) {
|
|
|
|
strcpy(ptr->mon_comment + len, displaySize_string);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* def CONFIGURE_DISPLAYSIZE */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input, ptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (ConfiguredMonitor->features.dpms) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ptr->mon_option_lst =
|
2014-09-27 11:52:59 -06:00
|
|
|
xf86addNewOption(ptr->mon_option_lst, xnfstrdup("DPMS"), NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
static int
|
|
|
|
is_fallback(const char *s)
|
|
|
|
{
|
|
|
|
/* later entries are less preferred */
|
|
|
|
const char *fallback[5] = { "modesetting", "fbdev", "vesa", "wsfb", NULL };
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; fallback[i]; i++)
|
|
|
|
if (strstr(s, fallback[i]))
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
driver_sort(const void *_l, const void *_r)
|
|
|
|
{
|
|
|
|
const char *l = *(const char **)_l;
|
|
|
|
const char *r = *(const char **)_r;
|
|
|
|
int left = is_fallback(l);
|
|
|
|
int right = is_fallback(r);
|
|
|
|
|
|
|
|
/* neither is a fallback, asciibetize */
|
|
|
|
if (left == -1 && right == -1)
|
|
|
|
return strcmp(l, r);
|
|
|
|
|
|
|
|
/* left is a fallback, right is not */
|
|
|
|
if (left >= 0 && right == -1)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* right is a fallback, left is not */
|
|
|
|
if (right >= 0 && left == -1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* both are fallbacks, decide which is worse */
|
|
|
|
return left - right;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fixup_video_driver_list(const char **drivers)
|
|
|
|
{
|
|
|
|
const char **end;
|
|
|
|
|
|
|
|
/* walk to the end of the list */
|
|
|
|
for (end = drivers; *end && **end; end++);
|
|
|
|
|
|
|
|
qsort(drivers, end - drivers, sizeof(const char *), driver_sort);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char **
|
|
|
|
GenerateDriverList(void)
|
|
|
|
{
|
|
|
|
const char **ret;
|
|
|
|
static const char *patlist[] = { "(.*)_drv\\.so", NULL };
|
|
|
|
ret = LoaderListDir("drivers", patlist);
|
|
|
|
|
|
|
|
/* fix up the probe order for video drivers */
|
|
|
|
if (ret != NULL)
|
|
|
|
fixup_video_driver_list(ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
void
|
2009-09-06 13:44:18 -06:00
|
|
|
DoConfigure(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i, j, screennum = -1;
|
|
|
|
const char *home = NULL;
|
2009-09-06 13:44:18 -06:00
|
|
|
char filename[PATH_MAX];
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *addslash = "";
|
2006-11-26 11:13:41 -07:00
|
|
|
XF86ConfigPtr xf86config = NULL;
|
2014-09-27 11:52:59 -06:00
|
|
|
const char **vlist, **vl;
|
2006-11-26 11:13:41 -07:00
|
|
|
int *dev2screen;
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
vlist = GenerateDriverList();
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!vlist) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("Missing output drivers. Configuration failed.\n");
|
|
|
|
goto bail;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ErrorF("List of video drivers:\n");
|
|
|
|
for (vl = vlist; *vl; vl++)
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("\t%s\n", *vl);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Load all the drivers that were found. */
|
|
|
|
xf86LoadModules(vlist, NULL);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(vlist);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
xorgHWAccess = xf86EnableIO();
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Create XF86Config file structure */
|
2009-09-06 13:44:18 -06:00
|
|
|
xf86config = calloc(1, sizeof(XF86ConfigRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Call all of the probe functions, reporting the results. */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
|
|
|
|
Bool found_screen;
|
|
|
|
DriverRec *const drv = xf86DriverList[CurrentDriver];
|
|
|
|
|
|
|
|
found_screen = xf86CallDriverProbe(drv, TRUE);
|
|
|
|
if (found_screen && drv->Identify) {
|
|
|
|
(*drv->Identify) (0);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nDevToConfig <= 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("No devices to configure. Configuration failed.\n");
|
|
|
|
goto bail;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add device, monitor and screen sections for detected devices */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (screennum = 0; screennum < nDevToConfig; screennum++) {
|
2014-09-27 11:52:59 -06:00
|
|
|
XF86ConfDevicePtr device_ptr;
|
|
|
|
XF86ConfMonitorPtr monitor_ptr;
|
|
|
|
XF86ConfScreenPtr screen_ptr;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
device_ptr = configureDeviceSection(screennum);
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86config->conf_device_lst = (XF86ConfDevicePtr) xf86addListItem((glp)
|
|
|
|
xf86config->
|
|
|
|
conf_device_lst,
|
|
|
|
(glp)
|
2014-09-27 11:52:59 -06:00
|
|
|
device_ptr);
|
|
|
|
monitor_ptr = configureMonitorSection(screennum);
|
|
|
|
xf86config->conf_monitor_lst = (XF86ConfMonitorPtr) xf86addListItem((glp) xf86config->conf_monitor_lst, (glp) monitor_ptr);
|
|
|
|
screen_ptr = configureScreenSection(screennum);
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86config->conf_screen_lst = (XF86ConfScreenPtr) xf86addListItem((glp)
|
|
|
|
xf86config->
|
|
|
|
conf_screen_lst,
|
|
|
|
(glp)
|
2014-09-27 11:52:59 -06:00
|
|
|
screen_ptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
xf86config->conf_files = configureFilesSection();
|
|
|
|
xf86config->conf_modules = configureModuleSection();
|
|
|
|
xf86config->conf_flags = configureFlagsSection();
|
2007-11-24 12:04:00 -07:00
|
|
|
xf86config->conf_videoadaptor_lst = NULL;
|
|
|
|
xf86config->conf_modes_lst = NULL;
|
|
|
|
xf86config->conf_vendor_lst = NULL;
|
|
|
|
xf86config->conf_dri = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86config->conf_input_lst = configureInputSection();
|
|
|
|
xf86config->conf_layout_lst = configureLayoutSection();
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
home = getenv("HOME");
|
|
|
|
if ((home == NULL) || (home[0] == '\0')) {
|
2012-06-10 07:21:05 -06:00
|
|
|
home = "/";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Determine if trailing slash is present or needed */
|
|
|
|
int l = strlen(home);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (home[l - 1] != '/') {
|
|
|
|
addslash = "/";
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new",
|
2012-06-10 07:21:05 -06:00
|
|
|
home, addslash);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (xf86writeConfigFile(filename, xf86config) == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
|
|
|
|
filename, strerror(errno));
|
|
|
|
goto bail;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
xf86DoConfigurePass1 = FALSE;
|
|
|
|
/* Try to get DDC information filled in */
|
|
|
|
xf86ConfigFile = filename;
|
|
|
|
if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
|
2012-06-10 07:21:05 -06:00
|
|
|
goto bail;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
xf86DoConfigurePass1 = FALSE;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
dev2screen = xnfcalloc(nDevToConfig, sizeof(int));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
{
|
2016-05-29 06:02:34 -06:00
|
|
|
Bool *driverProbed = xnfcalloc(xf86NumDrivers, sizeof(Bool));
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
for (screennum = 0; screennum < nDevToConfig; screennum++) {
|
|
|
|
int k, l, n, oldNumScreens;
|
|
|
|
|
|
|
|
i = DevToConfig[screennum].iDriver;
|
|
|
|
|
|
|
|
if (driverProbed[i])
|
|
|
|
continue;
|
|
|
|
driverProbed[i] = TRUE;
|
|
|
|
|
|
|
|
oldNumScreens = xf86NumScreens;
|
|
|
|
|
|
|
|
xf86CallDriverProbe(xf86DriverList[i], FALSE);
|
|
|
|
|
|
|
|
/* 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 */
|
2015-09-16 13:10:19 -06:00
|
|
|
/*
|
|
|
|
* NOTE: we assume that devices in DevToConfig
|
2012-06-10 07:21:05 -06:00
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(driverProbed);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (nDevToConfig != xf86NumScreens) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("Number of created screens does not match number of detected"
|
|
|
|
" devices.\n Configuration failed.\n");
|
|
|
|
goto bail;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
xf86PostProbe();
|
|
|
|
|
|
|
|
for (j = 0; j < xf86NumScreens; j++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86Screens[j]->scrnIndex = j;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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++) {
|
2014-09-27 11:52:59 -06:00
|
|
|
XF86ConfMonitorPtr monitor_ptr;
|
|
|
|
XF86ConfScreenPtr screen_ptr;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ConfiguredMonitor = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
if ((*xf86Screens[dev2screen[j]]->PreInit) &&
|
|
|
|
(*xf86Screens[dev2screen[j]]->PreInit) (xf86Screens[dev2screen[j]],
|
2012-06-10 07:21:05 -06:00
|
|
|
PROBE_DETECT) &&
|
|
|
|
ConfiguredMonitor) {
|
2014-09-27 11:52:59 -06:00
|
|
|
monitor_ptr = configureDDCMonitorSection(j);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2014-09-27 11:52:59 -06:00
|
|
|
monitor_ptr = configureMonitorSection(j);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2014-09-27 11:52:59 -06:00
|
|
|
screen_ptr = configureScreenSection(j);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
xf86config->conf_monitor_lst = (XF86ConfMonitorPtr) xf86addListItem((glp) xf86config->conf_monitor_lst, (glp) monitor_ptr);
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86config->conf_screen_lst = (XF86ConfScreenPtr) xf86addListItem((glp)
|
|
|
|
xf86config->
|
|
|
|
conf_screen_lst,
|
|
|
|
(glp)
|
2014-09-27 11:52:59 -06:00
|
|
|
screen_ptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (xf86writeConfigFile(filename, xf86config) == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
|
|
|
|
filename, strerror(errno));
|
|
|
|
goto bail;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
ErrorF("\n");
|
|
|
|
|
|
|
|
if (!foundMouse) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("\n" __XSERVERNAME__ " is not able to detect your mouse.\n"
|
|
|
|
"Edit the file and correct the Device.\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ErrorF("\n" __XSERVERNAME__ " detected your mouse at device %s.\n"
|
|
|
|
"Please check your config if the mouse is still not\n"
|
|
|
|
"operational, as by default " __XSERVERNAME__
|
|
|
|
" tries to autodetect\n" "the protocol.\n", DFLT_MOUSE_DEV);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xf86NumScreens > 1) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("\n" __XSERVERNAME__
|
|
|
|
" has configured a multihead system, please check your config.\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE, filename);
|
2006-11-26 11:13:41 -07:00
|
|
|
ErrorF("To test the server, run 'X -config %s'\n\n", filename);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
bail:
|
2007-02-04 13:20:19 -07:00
|
|
|
CloseWellKnownConnections();
|
2006-11-26 11:13:41 -07:00
|
|
|
OsCleanup(TRUE);
|
2011-11-05 07:32:40 -06:00
|
|
|
AbortDDX(EXIT_ERR_CONFIGURE);
|
2006-11-26 11:13:41 -07:00
|
|
|
fflush(stderr);
|
|
|
|
exit(0);
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
/* Xorg -showopts:
|
|
|
|
* For each driver module installed, print out the list
|
|
|
|
* of options and their argument types, then exit
|
|
|
|
*
|
|
|
|
* Author: Marcus Schaefer, ms@suse.de
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
DoShowOptions(void)
|
|
|
|
{
|
|
|
|
int i = 0;
|
2014-09-27 11:52:59 -06:00
|
|
|
const char **vlist = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
char *pSymbol = 0;
|
|
|
|
XF86ModuleData *initData = 0;
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
if (!(vlist = GenerateDriverList())) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("Missing output drivers\n");
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
xf86LoadModules(vlist, 0);
|
|
|
|
free(vlist);
|
|
|
|
for (i = 0; i < xf86NumDrivers; i++) {
|
|
|
|
if (xf86DriverList[i]->AvailableOptions) {
|
|
|
|
const OptionInfoRec *pOption =
|
|
|
|
(*xf86DriverList[i]->AvailableOptions) (0, 0);
|
|
|
|
if (!pOption) {
|
|
|
|
ErrorF("(EE) Couldn't read option table for %s driver\n",
|
|
|
|
xf86DriverList[i]->driverName);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
XNFasprintf(&pSymbol, "%sModuleData",
|
|
|
|
xf86DriverList[i]->driverName);
|
|
|
|
initData = LoaderSymbol(pSymbol);
|
|
|
|
if (initData) {
|
|
|
|
XF86ModuleVersionInfo *vers = initData->vers;
|
|
|
|
const OptionInfoRec *p;
|
|
|
|
|
|
|
|
ErrorF("Driver[%d]:%s[%s] {\n",
|
|
|
|
i, xf86DriverList[i]->driverName, vers->vendor);
|
|
|
|
for (p = pOption; p->name != NULL; p++) {
|
|
|
|
ErrorF("\t%s:%s\n", p->name, optionTypeToString(p->type));
|
|
|
|
}
|
|
|
|
ErrorF("}\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bail:
|
|
|
|
OsCleanup(TRUE);
|
|
|
|
AbortDDX(EXIT_ERR_DRIVERS);
|
|
|
|
fflush(stderr);
|
|
|
|
exit(0);
|
|
|
|
}
|