summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Dirsch <sndirsch@suse.de>2008-11-23 11:16:03 +0100
committerStefan Dirsch <sndirsch@suse.de>2008-11-23 11:16:03 +0100
commitf6e01fa1b87ea190ea5ad723ce46893784ea1de4 (patch)
tree3871135c3732879e16d744e92b515826e75b5312
parent8964b8d0ec2b7b3b6bf540cd647b14a20e8f64a5 (diff)
Added '-showopts' option to print available driver options (#5564).
-rw-r--r--hw/xfree86/common/Makefile.am2
-rw-r--r--hw/xfree86/common/xf86.h1
-rw-r--r--hw/xfree86/common/xf86Globals.c1
-rw-r--r--hw/xfree86/common/xf86Init.c15
-rw-r--r--hw/xfree86/common/xf86Priv.h1
-rw-r--r--hw/xfree86/common/xf86ShowOpts.c129
6 files changed, 147 insertions, 2 deletions
diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 87913e8fa..06d53c14b 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -25,7 +25,7 @@ xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES)
BUILT_SOURCES = xf86DefModeSet.c
AM_LDFLAGS = -r
-libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \
+libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \
xf86Cursor.c xf86DGA.c xf86DPMS.c \
xf86DoProbe.c xf86Events.c \
xf86Globals.c xf86AutoConfig.c \
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 459712ea0..4432c551b 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -56,6 +56,7 @@
/* General parameters */
extern int xf86DoConfigure;
+extern int xf86DoShowOptions;
extern Bool xf86DoModalias;
extern Bool xf86DoConfigurePass1;
extern DevPrivateKey xf86ScreenKey;
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index db3b68463..57142beab 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -153,6 +153,7 @@ Bool xf86Resetting = FALSE;
Bool xf86Initialising = FALSE;
Bool xf86DoProbe = FALSE;
Bool xf86DoConfigure = FALSE;
+Bool xf86DoShowOptions = FALSE;
Bool xf86DoModalias = FALSE;
DriverPtr *xf86DriverList = NULL;
int xf86NumDrivers = 0;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 45c116a8b..86f25de12 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -688,7 +688,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
}
/* Read and parse the config file */
- if (!xf86DoProbe && !xf86DoConfigure && !xf86DoModalias) {
+ if (!xf86DoProbe && !xf86DoConfigure && !xf86DoModalias && !xf86DoShowOptions) {
switch (xf86HandleConfigFile(FALSE)) {
case CONFIG_OK:
break;
@@ -713,6 +713,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
}
+ if (xf86DoShowOptions)
+ DoShowOptions();
+
xf86OpenConsole();
/* Do a general bus probe. This will be a PCI probe for x86 platforms */
@@ -1774,6 +1777,15 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86AllowMouseOpenFail = TRUE;
return 1;
}
+ if (!strcmp(argv[i], "-showopts"))
+ {
+ if (getuid() != 0 && geteuid() == 0) {
+ ErrorF("The '-showopts' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86DoShowOptions = TRUE;
+ return 1;
+ }
if (!strcmp(argv[i], "-isolateDevice"))
{
int bus, device, func;
@@ -1812,6 +1824,7 @@ ddxUseMsg()
ErrorF("-modulepath paths specify the module search path\n");
ErrorF("-logfile file specify a log file name\n");
ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n");
+ ErrorF("-showopts print available options for all installed drivers\n");
}
ErrorF("-modalias output a modalias-style filter for each driver installed\n");
ErrorF("-config file specify a configuration file, relative to the\n");
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index 159dfb26b..f3dfd70d8 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -153,6 +153,7 @@ extern const int xf86NumDefaultModes;
/* xf86DoProbe.c */
void DoProbe(void);
void DoConfigure(void);
+void DoShowOptions(void);
/* xf86Events.c */
diff --git a/hw/xfree86/common/xf86ShowOpts.c b/hw/xfree86/common/xf86ShowOpts.c
new file mode 100644
index 000000000..b8efa73c2
--- /dev/null
+++ b/hw/xfree86/common/xf86ShowOpts.c
@@ -0,0 +1,129 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86ShopwOpts.c,v 3.80 2003/10/08 14:58:27 dawes Exp $ */
+/*
+ * 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: Marcus Schaefer, ms@suse.de
+ *
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "os.h"
+#ifdef XFree86LOADER
+#include "loaderProcs.h"
+#endif
+#include "xf86.h"
+#include "xf86Config.h"
+#include "xf86_OSlib.h"
+#include "xf86Priv.h"
+/* #include "xf86PciData.h" */
+#define IN_XSERVER
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include "vbe.h"
+#include "xf86DDC.h"
+#if defined(__sparc__) && !defined(__OpenBSD__)
+#include "xf86Bus.h"
+#include "xf86Sbus.h"
+#endif
+#include "globals.h"
+
+static const char*
+optionTypeToSting(OptionValueType type)
+{
+ switch (type) {
+ case OPTV_NONE:
+ return "";
+ case OPTV_INTEGER:
+ return "<int>";
+ case OPTV_STRING:
+ return "<str>";
+ case OPTV_ANYSTR:
+ return "<str>";
+ case OPTV_REAL:
+ return "<real>";
+ case OPTV_BOOLEAN:
+ return "<bool>";
+ case OPTV_FREQ:
+ return "<freq>";
+ default:
+ return "<undef>";
+ }
+}
+
+void DoShowOptions (void) {
+ int i = 0;
+ char **vlist = 0;
+ char *pSymbol = 0;
+ XF86ModuleData *initData = 0;
+ if (! (vlist = xf86DriverlistFromCompile())) {
+ ErrorF("Missing output drivers\n");
+ goto bail;
+ }
+ xf86LoadModules (vlist,0);
+ xfree (vlist);
+ for (i = 0; i < xf86NumDrivers; i++) {
+ if (xf86DriverList[i]->AvailableOptions) {
+ OptionInfoPtr pOption = (OptionInfoPtr)(*xf86DriverList[i]->AvailableOptions)(0,0);
+ if (! pOption) {
+ ErrorF ("(EE) Couldn't read option table for %s driver\n",
+ xf86DriverList[i]->driverName
+ );
+ continue;
+ }
+ pSymbol = xalloc (
+ strlen(xf86DriverList[i]->driverName) + strlen("ModuleData") + 1
+ );
+ strcpy (pSymbol, xf86DriverList[i]->driverName);
+ strcat (pSymbol, "ModuleData");
+ initData = LoaderSymbol (pSymbol);
+ if (initData) {
+ XF86ModuleVersionInfo *vers = initData->vers;
+ ErrorF ("Driver[%d]:%s[%s] {\n",
+ i,xf86DriverList[i]->driverName,vers->vendor
+ );
+ OptionInfoPtr p;
+ for (p = pOption; p->name != NULL; p++) {
+ const char *opttype = optionTypeToSting(p->type);
+ char *optname = xalloc(strlen(p->name) + 2 + 1);
+ if (!optname) {
+ continue;
+ }
+ sprintf(optname, "%s", p->name);
+ ErrorF ("\t%s:%s\n", optname,opttype);
+ }
+ ErrorF ("}\n");
+ }
+ }
+ }
+ bail:
+ OsCleanup (TRUE);
+ AbortDDX ();
+ fflush (stderr);
+ exit (0);
+}