summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-02-13 10:26:53 -0800
committerAaron Plattner <aplattner@nvidia.com>2008-02-13 10:26:53 -0800
commitb03157d67b34e51465b788d38c1a9a0ce97a8637 (patch)
tree9d6f34390e0faa0f58c8081b9a189bf1d24641f6
parent9544a6e9c1e4faf27a28ca7d8fb1425a570befe1 (diff)
169.04169.04
-rw-r--r--XF86Config-parser/Flags.c82
-rw-r--r--XF86Config-parser/Generate.c35
-rw-r--r--XF86Config-parser/Input.c33
-rw-r--r--XF86Config-parser/Merge.c16
-rw-r--r--XF86Config-parser/Pointer.c50
-rw-r--r--XF86Config-parser/xf86Parser.h7
-rw-r--r--make_usable.c2
-rw-r--r--multiple_screens.c4
-rw-r--r--nvidia-xconfig.1.m43
-rw-r--r--nvidia-xconfig.c18
-rw-r--r--nvidia-xconfig.h1
-rw-r--r--option_table.h51
-rw-r--r--options.c19
-rw-r--r--tree.c11
14 files changed, 149 insertions, 183 deletions
diff --git a/XF86Config-parser/Flags.c b/XF86Config-parser/Flags.c
index 21413c9..b86b7a4 100644
--- a/XF86Config-parser/Flags.c
+++ b/XF86Config-parser/Flags.c
@@ -123,30 +123,26 @@ xconfigParseFlagsSection (void)
int i = 0;
while (ServerFlagsTab[i].token != -1)
{
- char *tmp;
-
if (ServerFlagsTab[i].token == token)
{
+ char buff[16];
char *valstr = NULL;
- /* can't use strdup because it calls malloc */
- tmp = xconfigStrdup (ServerFlagsTab[i].name);
if (hasvalue)
{
tokentype = xconfigGetSubToken(&(ptr->comment));
if (strvalue) {
if (tokentype != STRING)
- Error (QUOTE_MSG, tmp);
+ Error (QUOTE_MSG, ServerFlagsTab[i].name);
valstr = val.str;
} else {
if (tokentype != NUMBER)
- Error (NUMBER_MSG, tmp);
- valstr = malloc(16);
- if (valstr)
- sprintf(valstr, "%d", val.num);
+ Error (NUMBER_MSG, ServerFlagsTab[i].name);
+ snprintf(buff, 16, "%d", val.num);
+ valstr = buff;
}
}
ptr->options = xconfigAddNewOption
- (ptr->options, tmp, valstr);
+ (ptr->options, ServerFlagsTab[i].name, valstr);
}
i++;
}
@@ -185,8 +181,8 @@ xconfigPrintServerFlagsSection (FILE * f, XConfigFlagsPtr flags)
fprintf (f, "EndSection\n\n");
}
-static XConfigOptionPtr
-addNewOption2 (XConfigOptionPtr head, char *name, char *val, int used)
+XConfigOptionPtr
+xconfigAddNewOption (XConfigOptionPtr head, const char *name, const char *val)
{
XConfigOptionPtr new, old = NULL;
@@ -196,12 +192,11 @@ addNewOption2 (XConfigOptionPtr head, char *name, char *val, int used)
TEST_FREE(old->val);
new = old;
} else {
- new = calloc (1, sizeof (XConfigOptionRec));
+ new = calloc(1, sizeof (XConfigOptionRec));
new->next = NULL;
}
- new->name = name;
- new->val = val;
- new->used = used;
+ new->name = xconfigStrdup(name);
+ new->val = xconfigStrdup(val);
if (old == NULL)
return ((XConfigOptionPtr) xconfigAddListItem ((GenericListPtr) head,
@@ -210,12 +205,6 @@ addNewOption2 (XConfigOptionPtr head, char *name, char *val, int used)
return head;
}
-XConfigOptionPtr
-xconfigAddNewOption (XConfigOptionPtr head, char *name, char *val)
-{
- return addNewOption2(head, name, val, 0);
-}
-
void
xconfigFreeFlags (XConfigFlagsPtr flags)
{
@@ -233,11 +222,8 @@ xconfigOptionListDup (XConfigOptionPtr opt)
while (opt)
{
- newopt = xconfigAddNewOption(newopt, xconfigStrdup(opt->name),
- xconfigStrdup(opt->val));
- newopt->used = opt->used;
- if (opt->comment)
- newopt->comment = xconfigStrdup(opt->comment);
+ newopt = xconfigAddNewOption(newopt, opt->name, opt->val);
+ newopt->comment = xconfigStrdup(opt->comment);
opt = opt->next;
}
return newopt;
@@ -276,7 +262,7 @@ xconfigOptionValue(XConfigOptionPtr opt)
}
XConfigOptionPtr
-xconfigNewOption(char *name, char *value)
+xconfigNewOption(const char *name, const char *value)
{
XConfigOptionPtr opt;
@@ -284,10 +270,9 @@ xconfigNewOption(char *name, char *value)
if (!opt)
return NULL;
- opt->used = 0;
- opt->next = 0;
- opt->name = name;
- opt->val = value;
+ opt->name = xconfigStrdup(name);
+ opt->val = xconfigStrdup(value);
+ opt->next = NULL;
return opt;
}
@@ -388,39 +373,6 @@ xconfigFindOptionBoolean (XConfigOptionPtr list, const char *name)
return 0;
}
-XConfigOptionPtr
-xconfigOptionListCreate( const char **options, int count, int used )
-{
- XConfigOptionPtr p = NULL;
- char *t1, *t2;
- int i;
-
- if (count == -1)
- {
- for (count = 0; options[count]; count++)
- ;
- }
- if( (count % 2) != 0 )
- {
- xconfigErrorMsg(InternalErrorMsg, "xconfigOptionListCreate: count must "
- "be an even number.\n");
- return (NULL);
- }
- for (i = 0; i < count; i += 2)
- {
- /* can't use strdup because it calls malloc */
- t1 = malloc (sizeof (char) *
- (strlen (options[i]) + 1));
- strcpy (t1, options[i]);
- t2 = malloc (sizeof (char) *
- (strlen (options[i + 1]) + 1));
- strcpy (t2, options[i + 1]);
- p = addNewOption2 (p, t1, t2, used);
- }
-
- return (p);
-}
-
/* the 2 given lists are merged. If an option with the same name is present in
* both, the option from the user list - specified in the second argument -
* is used. The end result is a single valid list of options. Duplicates
diff --git a/XF86Config-parser/Generate.c b/XF86Config-parser/Generate.c
index 008730a..0b6c9bd 100644
--- a/XF86Config-parser/Generate.c
+++ b/XF86Config-parser/Generate.c
@@ -450,7 +450,7 @@ XConfigMonitorPtr xconfigAddMonitor(XConfigPtr config, int count)
monitor->vrefresh[0].lo = 50.0;
monitor->vrefresh[0].hi = 150.0;
- opt = xconfigAddNewOption(opt, xconfigStrdup("DPMS"), NULL);
+ opt = xconfigAddNewOption(opt, "DPMS", NULL);
monitor->options = opt;
@@ -584,7 +584,7 @@ static void add_inputref(XConfigPtr config, XConfigLayoutPtr layout,
inputRef->input_name = xconfigStrdup(name);
inputRef->input = xconfigFindInput(inputRef->input_name, config->inputs);
inputRef->options =
- xconfigAddNewOption(NULL, xconfigStrdup(coreKeyword), NULL);
+ xconfigAddNewOption(NULL, coreKeyword, NULL);
inputRef->next = layout->inputs;
layout->inputs = inputRef;
@@ -1032,20 +1032,19 @@ int xconfigAddMouse(GenerateOptions *gop, XConfigPtr config)
device_path = xconfigStrcat("/dev/", entry->device, NULL);
- opt = xconfigAddNewOption(opt, xconfigStrdup("Protocol"),
- xconfigStrdup(entry->Xproto));
- opt = xconfigAddNewOption(opt, xconfigStrdup("Device"), device_path);
- opt = xconfigAddNewOption(opt, xconfigStrdup("Emulate3Buttons"),
- entry->emulate3 ?
- xconfigStrdup("yes") : xconfigStrdup("no"));
+ opt = xconfigAddNewOption(opt, "Protocol", entry->Xproto);
+ opt = xconfigAddNewOption(opt, "Device", device_path);
+ opt = xconfigAddNewOption(opt, "Emulate3Buttons",
+ (entry->emulate3 ? "yes" : "no"));
+ TEST_FREE(device_path);
+
/*
* This will make wheel mice work, and non-wheel mice should
* ignore ZAxisMapping
*/
- opt = xconfigAddNewOption(opt, xconfigStrdup("ZAxisMapping"),
- xconfigStrdup("4 5"));
+ opt = xconfigAddNewOption(opt, "ZAxisMapping", "4 5");
input->options = opt;
@@ -1299,21 +1298,13 @@ int xconfigAddKeyboard(GenerateOptions *gop, XConfigPtr config)
*/
if (entry && entry->layout)
- opt = xconfigAddNewOption(opt,
- xconfigStrdup("XkbLayout"),
- xconfigStrdup(entry->layout));
+ opt = xconfigAddNewOption(opt, "XkbLayout", entry->layout);
if (entry && entry->model)
- opt = xconfigAddNewOption(opt,
- xconfigStrdup("XkbModel"),
- xconfigStrdup(entry->model));
+ opt = xconfigAddNewOption(opt, "XkbModel", entry->model);
if (entry && entry->variant)
- opt = xconfigAddNewOption(opt,
- xconfigStrdup("XkbVariant"),
- xconfigStrdup(entry->variant));
+ opt = xconfigAddNewOption(opt, "XkbVariant", entry->variant);
if (entry && entry->options)
- opt = xconfigAddNewOption(opt,
- xconfigStrdup("XkbOptions"),
- xconfigStrdup(entry->options));
+ opt = xconfigAddNewOption(opt, "XkbOptions", entry->options);
input->options = opt;
diff --git a/XF86Config-parser/Input.c b/XF86Config-parser/Input.c
index 1665600..4b660f6 100644
--- a/XF86Config-parser/Input.c
+++ b/XF86Config-parser/Input.c
@@ -239,9 +239,9 @@ static int getCoreInputDevice(GenerateOptions *gop,
opt2 = xconfigFindOption(inputRef->options, coreKeyword);
if (opt1 || opt2) {
- if (!core) {
- core = input;
- } else {
+ if (!core) {
+ core = input;
+ } else {
if (opt1) input->options =
xconfigRemoveOption(input->options, opt1);
if (opt2) inputRef->options =
@@ -265,13 +265,13 @@ static int getCoreInputDevice(GenerateOptions *gop,
*/
if (!core) {
- for (input = config->inputs; input; input = input->next) {
- if (xconfigFindOption(input->options, coreKeyword)) {
+ for (input = config->inputs; input; input = input->next) {
+ if (xconfigFindOption(input->options, coreKeyword)) {
core = input;
found_msg = foundMsg0;
break;
- }
- }
+ }
+ }
}
/*
@@ -285,16 +285,16 @@ static int getCoreInputDevice(GenerateOptions *gop,
if (!core) {
input = xconfigFindInput(implicitDriverName, config->inputs);
- if (!input && defaultDriver0) {
- input = xconfigFindInputByDriver(defaultDriver0, config->inputs);
- }
+ if (!input && defaultDriver0) {
+ input = xconfigFindInputByDriver(defaultDriver0, config->inputs);
+ }
if (!input && defaultDriver1) {
- input = xconfigFindInputByDriver(defaultDriver1, config->inputs);
+ input = xconfigFindInputByDriver(defaultDriver1, config->inputs);
+ }
+ if (input) {
+ core = input;
+ found_msg = foundMsg1;
}
- if (input) {
- core = input;
- found_msg = foundMsg1;
- }
}
/*
@@ -368,8 +368,7 @@ static int getCoreInputDevice(GenerateOptions *gop,
if (!opt1 && !opt2) {
inputRef->options = xconfigAddNewOption(inputRef->options,
- strdup(coreKeyword),
- NULL);
+ coreKeyword, NULL);
}
break;
}
diff --git a/XF86Config-parser/Merge.c b/XF86Config-parser/Merge.c
index 2931934..a9f2c97 100644
--- a/XF86Config-parser/Merge.c
+++ b/XF86Config-parser/Merge.c
@@ -120,8 +120,7 @@ static void xconfigMergeOption(XConfigOptionPtr *dstHead,
xconfigAddRemovedOptionComment(comments, dstOption);
}
*dstHead = xconfigAddNewOption
- (*dstHead, xconfigStrdup(name),
- xconfigStrdup(xconfigOptionValue(srcOption)));
+ (*dstHead, name, xconfigOptionValue(srcOption));
}
}
@@ -402,8 +401,7 @@ static int xconfigMergeDriverOptions(XConfigScreenPtr dstScreen,
dstScreen->options =
xconfigAddNewOption(dstScreen->options,
- xconfigStrdup(name),
- xconfigStrdup(xconfigOptionValue(option)));
+ name, xconfigOptionValue(option));
option = option->next;
}
@@ -424,7 +422,6 @@ static int xconfigMergeDisplays(XConfigScreenPtr dstScreen,
{
XConfigDisplayPtr dstDisplay;
XConfigDisplayPtr srcDisplay;
- XConfigOptionPtr srcOption;
XConfigModePtr srcMode, dstMode, lastDstMode;
/* Free all the displays in the destination screen */
@@ -458,14 +455,7 @@ static int xconfigMergeDisplays(XConfigScreenPtr dstScreen,
/* Copy options over */
- srcOption = srcDisplay->options;
- while (srcOption) {
- xconfigMergeOption(&(dstDisplay->options),
- &(srcDisplay->options),
- xconfigOptionName(srcOption),
- NULL);
- srcOption = srcOption->next;
- }
+ dstDisplay->options = xconfigOptionListDup(srcDisplay->options);
/* Copy modes over */
diff --git a/XF86Config-parser/Pointer.c b/XF86Config-parser/Pointer.c
index d1e282a..ed49669 100644
--- a/XF86Config-parser/Pointer.c
+++ b/XF86Config-parser/Pointer.c
@@ -111,76 +111,68 @@ xconfigParsePointerSection (void)
if (xconfigGetSubToken (&(ptr->comment)) != STRING)
Error (QUOTE_MSG, "Protocol");
ptr->options = xconfigAddNewOption(ptr->options,
- xconfigStrdup("Protocol"),
- val.str);
+ "Protocol", val.str);
break;
case PDEVICE:
if (xconfigGetSubToken (&(ptr->comment)) != STRING)
Error (QUOTE_MSG, "Device");
ptr->options = xconfigAddNewOption(ptr->options,
- xconfigStrdup("Device"),
- val.str);
+ "Device", val.str);
break;
case EMULATE3:
ptr->options =
- xconfigAddNewOption(ptr->options,
- xconfigStrdup("Emulate3Buttons"),
- NULL);
+ xconfigAddNewOption(ptr->options, "Emulate3Buttons", NULL);
break;
case EM3TIMEOUT:
if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0)
Error (POSITIVE_INT_MSG, "Emulate3Timeout");
s = xconfigULongToString(val.num);
ptr->options =
- xconfigAddNewOption(ptr->options,
- xconfigStrdup("Emulate3Timeout"),
- s);
+ xconfigAddNewOption(ptr->options, "Emulate3Timeout", s);
+ TEST_FREE(s);
break;
case CHORDMIDDLE:
- ptr->options = xconfigAddNewOption(ptr->options,
- xconfigStrdup("ChordMiddle"),
- NULL);
+ ptr->options = xconfigAddNewOption(ptr->options, "ChordMiddle",
+ NULL);
break;
case PBUTTONS:
if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0)
Error (POSITIVE_INT_MSG, "Buttons");
s = xconfigULongToString(val.num);
- ptr->options = xconfigAddNewOption(ptr->options,
- xconfigStrdup("Buttons"), s);
+ ptr->options = xconfigAddNewOption(ptr->options, "Buttons", s);
+ TEST_FREE(s);
break;
case BAUDRATE:
if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0)
Error (POSITIVE_INT_MSG, "BaudRate");
s = xconfigULongToString(val.num);
ptr->options =
- xconfigAddNewOption(ptr->options,
- xconfigStrdup("BaudRate"), s);
+ xconfigAddNewOption(ptr->options, "BaudRate", s);
+ TEST_FREE(s);
break;
case SAMPLERATE:
if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0)
Error (POSITIVE_INT_MSG, "SampleRate");
s = xconfigULongToString(val.num);
ptr->options =
- xconfigAddNewOption(ptr->options,
- xconfigStrdup("SampleRate"), s);
+ xconfigAddNewOption(ptr->options, "SampleRate", s);
+ TEST_FREE(s);
break;
case PRESOLUTION:
if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0)
Error (POSITIVE_INT_MSG, "Resolution");
s = xconfigULongToString(val.num);
ptr->options =
- xconfigAddNewOption(ptr->options,
- xconfigStrdup("Resolution"), s);
+ xconfigAddNewOption(ptr->options, "Resolution", s);
+ TEST_FREE(s);
break;
case CLEARDTR:
ptr->options =
- xconfigAddNewOption(ptr->options,
- xconfigStrdup("ClearDTR"), NULL);
+ xconfigAddNewOption(ptr->options, "ClearDTR", NULL);
break;
case CLEARRTS:
ptr->options =
- xconfigAddNewOption(ptr->options,
- xconfigStrdup("ClearRTS"), NULL);
+ xconfigAddNewOption(ptr->options, "ClearRTS", NULL);
break;
case ZAXISMAPPING:
switch (xconfigGetToken(ZMapTab)) {
@@ -209,9 +201,8 @@ xconfigParsePointerSection (void)
break;
}
ptr->options =
- xconfigAddNewOption(ptr->options,
- xconfigStrdup("ZAxisMapping"),
- s);
+ xconfigAddNewOption(ptr->options, "ZAxisMapping", s);
+ TEST_FREE(s);
break;
case ALWAYSCORE:
break;
@@ -226,8 +217,7 @@ xconfigParsePointerSection (void)
ptr->identifier = xconfigStrdup(CONF_IMPLICIT_POINTER);
ptr->driver = xconfigStrdup("mouse");
- ptr->options = xconfigAddNewOption(ptr->options,
- xconfigStrdup("CorePointer"), NULL);
+ ptr->options = xconfigAddNewOption(ptr->options, "CorePointer", NULL);
return ptr;
}
diff --git a/XF86Config-parser/xf86Parser.h b/XF86Config-parser/xf86Parser.h
index 7013b9b..c81574c 100644
--- a/XF86Config-parser/xf86Parser.h
+++ b/XF86Config-parser/xf86Parser.h
@@ -148,7 +148,6 @@ typedef struct __xconfigoptionrec {
struct __xconfigoptionrec *next;
char *name;
char *val;
- int used;
char *comment;
} XConfigOptionRec, *XConfigOptionPtr;
@@ -675,22 +674,20 @@ XConfigLoadPtr xconfigRemoveLoadDirective(XConfigLoadPtr head,
*/
XConfigOptionPtr xconfigAddNewOption(XConfigOptionPtr head,
- char *name, char *val);
+ const char *name, const char *val);
XConfigOptionPtr xconfigRemoveOption(XConfigOptionPtr list,
XConfigOptionPtr opt);
XConfigOptionPtr xconfigOptionListDup(XConfigOptionPtr opt);
void xconfigOptionListFree(XConfigOptionPtr opt);
char *xconfigOptionName(XConfigOptionPtr opt);
char *xconfigOptionValue(XConfigOptionPtr opt);
-XConfigOptionPtr xconfigNewOption(char *name, char *value);
+XConfigOptionPtr xconfigNewOption(const char *name, const char *value);
XConfigOptionPtr xconfigNextOption(XConfigOptionPtr list);
XConfigOptionPtr xconfigFindOption(XConfigOptionPtr list, const char *name);
char *xconfigFindOptionValue(XConfigOptionPtr list,
const char *name);
int xconfigFindOptionBoolean (XConfigOptionPtr,
const char *name);
-XConfigOptionPtr xconfigOptionListCreate(const char **options,
- int count, int used);
XConfigOptionPtr xconfigOptionListMerge(XConfigOptionPtr head,
XConfigOptionPtr tail);
diff --git a/make_usable.c b/make_usable.c
index 74c4ca2..6afb8ed 100644
--- a/make_usable.c
+++ b/make_usable.c
@@ -195,7 +195,7 @@ int update_extensions(Options *op, XConfigPtr config)
config->extensions->options =
xconfigAddNewOption(config->extensions->options,
- nvstrdup("Composite"), nvstrdup(value));
+ "Composite", value);
}
return TRUE;
diff --git a/multiple_screens.c b/multiple_screens.c
index d57f4c7..09fd5dc 100644
--- a/multiple_screens.c
+++ b/multiple_screens.c
@@ -320,8 +320,8 @@ static int set_xinerama(int xinerama_enabled, XConfigPtr config)
config->flags->options =
xconfigAddNewOption(config->flags->options,
- nvstrdup("Xinerama"),
- nvstrdup(xinerama_enabled?"1":"0"));
+ "Xinerama",
+ (xinerama_enabled ? "1" : "0"));
return TRUE;
diff --git a/nvidia-xconfig.1.m4 b/nvidia-xconfig.1.m4
index 3e19099..97191ad 100644
--- a/nvidia-xconfig.1.m4
+++ b/nvidia-xconfig.1.m4
@@ -79,6 +79,9 @@ Examines the system and configures an X screen for each display device it finds.
.BI "nvidia-xconfig \-\-mode=" 1600x1200
Adds a 1600x1200 mode to an existing X configuration.
.TP
+.BI "nvidia-xconfig \-\-mode-list=" "1600x1200 1280x1024"
+Removes any existing modes from the X configuration file, replacing them with "1600x1200" and "1280x1024".
+.TP
.B nvidia-xconfig \-\-only\-one\-x\-screen \-\-sli=Auto
Configures the X server to have just one X screen that will use SLI when available.
.\" .SH FILES
diff --git a/nvidia-xconfig.c b/nvidia-xconfig.c
index be6a4ff..4aa0deb 100644
--- a/nvidia-xconfig.c
+++ b/nvidia-xconfig.c
@@ -472,6 +472,24 @@ Options *parse_commandline(int argc, char *argv[])
}
break;
+ case MODE_LIST_OPTION:
+ {
+ char *token;
+ token = strtok(strval, " ");
+ if (!token) {
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Invalid Mode List string: %s.\n", strval);
+ fprintf(stderr, "\n");
+ goto fail;
+ }
+ do {
+ nv_text_rows_append(&op->add_modes_list, token);
+ token = strtok(NULL, " ");
+ } while (token != NULL);
+
+ break;
+ }
+
case REMOVE_MODE_OPTION:
nv_text_rows_append(&op->remove_modes, strval);
break;
diff --git a/nvidia-xconfig.h b/nvidia-xconfig.h
index c6084ab..40a77d8 100644
--- a/nvidia-xconfig.h
+++ b/nvidia-xconfig.h
@@ -170,6 +170,7 @@ typedef struct __options {
} virtual;
TextRows add_modes;
+ TextRows add_modes_list;
TextRows remove_modes;
int supports_extension_section;
diff --git a/option_table.h b/option_table.h
index 0b19d10..2b07848 100644
--- a/option_table.h
+++ b/option_table.h
@@ -20,27 +20,28 @@
#define FORCE_GENERATE_OPTION 9
#define MOUSE_LIST_OPTION 10
#define MODE_OPTION 11
-#define REMOVE_MODE_OPTION 12
-#define NVIDIA_CFG_PATH_OPTION 13
-#define NVAGP_OPTION 14
-#define SLI_OPTION 15
-#define DISABLE_SCF_OPTION 16
-#define TRANSPARENT_INDEX_OPTION 17
-#define STEREO_OPTION 18
-#define ROTATE_OPTION 19
-#define QUERY_GPU_INFO_OPTION 20
-#define EXTRACT_EDIDS_OUTPUT_FILE_OPTION 21
-#define MULTI_GPU_OPTION 22
-#define TWINVIEW_XINERAMA_INFO_ORDER_OPTION 23
-#define LOGO_PATH_OPTION 24
-#define TWINVIEW_ORIENTATION_OPTION 25
-#define VIRTUAL_OPTION 26
-#define USE_DISPLAY_DEVICE_OPTION 27
-#define CUSTOM_EDID_OPTION 28
-#define TV_STANDARD_OPTION 29
-#define TV_OUT_FORMAT_OPTION 30
-#define TV_OVER_SCAN_OPTION 31
-#define COOL_BITS_OPTION 32
+#define MODE_LIST_OPTION 12
+#define REMOVE_MODE_OPTION 13
+#define NVIDIA_CFG_PATH_OPTION 14
+#define NVAGP_OPTION 15
+#define SLI_OPTION 16
+#define DISABLE_SCF_OPTION 17
+#define TRANSPARENT_INDEX_OPTION 18
+#define STEREO_OPTION 19
+#define ROTATE_OPTION 20
+#define QUERY_GPU_INFO_OPTION 21
+#define EXTRACT_EDIDS_OUTPUT_FILE_OPTION 22
+#define MULTI_GPU_OPTION 23
+#define TWINVIEW_XINERAMA_INFO_ORDER_OPTION 24
+#define LOGO_PATH_OPTION 25
+#define TWINVIEW_ORIENTATION_OPTION 26
+#define VIRTUAL_OPTION 27
+#define USE_DISPLAY_DEVICE_OPTION 28
+#define CUSTOM_EDID_OPTION 29
+#define TV_STANDARD_OPTION 30
+#define TV_OUT_FORMAT_OPTION 31
+#define TV_OVER_SCAN_OPTION 32
+#define COOL_BITS_OPTION 33
/*
* To add a boolean option to nvidia-xconfig:
@@ -304,6 +305,10 @@ static const NVGetoptOption __options[] = {
MODE_OPTION, NVGETOPT_IS_BOOLEAN | NVGETOPT_STRING_ARGUMENT, NULL,
"Add the specified mode to the mode list." },
+ { "mode-list", MODE_LIST_OPTION, NVGETOPT_STRING_ARGUMENT, "MODELIST",
+ "Remove all existing modes from the X configuration's modelist and "
+ "add the one(s) specified in the [MODELIST] string." },
+
{ "remove-mode", REMOVE_MODE_OPTION, NVGETOPT_STRING_ARGUMENT, "MODE",
"Remove the specified mode from the mode list." },
@@ -320,7 +325,7 @@ static const NVGetoptOption __options[] = {
{ "multigpu", MULTI_GPU_OPTION,
NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
- "Enable or disable MultiGPU. Valid values for [MULTIGPU] are 'Off', "
+ "Enable or disable MultiGPU. Valid values for [MULTIGPU] are 'Off', 'On',"
" 'Auto', 'AFR', 'SFR', 'AA'." },
{ "multisample-compatibility",
@@ -429,7 +434,7 @@ static const NVGetoptOption __options[] = {
{ "sli", SLI_OPTION,
NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
- "Enable or disable SLI. Valid values for [SLI] are 'Off', 'Auto', "
+ "Enable or disable SLI. Valid values for [SLI] are 'Off', 'On', 'Auto', "
"'AFR', 'SFR', 'AA', 'AFRofAA'." },
{ "stereo", STEREO_OPTION,
diff --git a/options.c b/options.c
index 792b8dd..64292b4 100644
--- a/options.c
+++ b/options.c
@@ -277,8 +277,7 @@ static void set_option_value(XConfigScreenPtr screen,
/* then, add the option to the screen's option list */
- screen->options = xconfigAddNewOption(screen->options,
- nvstrdup(name), nvstrdup(val));
+ screen->options = xconfigAddNewOption(screen->options, name, val);
} /* set_option_value() */
@@ -344,7 +343,23 @@ static void update_display_options(Options *op, XConfigScreenPtr screen)
display->modes = xconfigAddMode(display->modes,
op->add_modes.t[i]);
}
+ if (op->add_modes_list.n) {
+ int mode_list_size = op->add_modes_list.n;
+ xconfigFreeModeList(display->modes);
+ display->modes = NULL;
+
+ /*
+ * xconfigAddMode() prepends, rather than appends, so add the
+ * modes in reverse order
+ */
+
+ for (i = 0; i < op->add_modes_list.n; i++) {
+ display->modes = xconfigAddMode(display->modes,
+ op->add_modes_list.t[mode_list_size-i-1]);
+ }
+ }
+
/* XXX should we sort the mode list? */
/*
diff --git a/tree.c b/tree.c
index 13ea6d2..456a36e 100644
--- a/tree.c
+++ b/tree.c
@@ -160,19 +160,24 @@ static void print_modes(XConfigScreenPtr screen)
{
XConfigDisplayPtr display;
XConfigModePtr mode;
-
- printf(" | |--> Modes");
+ int printedSomething = 0;
for (display = screen->displays; display; display = display->next) {
if (display->depth == screen->defaultdepth) {
for (mode = display->modes; mode; mode = mode->next) {
+ if (!printedSomething) {
+ printf(" | |--> Modes");
+ }
printf(" \"%s\"", mode->mode_name);
+ printedSomething = 1;
}
break;
}
}
- printf("\n");
+ if (printedSomething) {
+ printf("\n");
+ }
} /* print_modes() */